@arcteninc/core 0.0.71 → 0.0.73

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,4 +1,4 @@
1
- "use strict";var _a=Object.create;var xi=Object.defineProperty;var Wa=Object.getOwnPropertyDescriptor;var Ka=Object.getOwnPropertyNames;var Ha=Object.getPrototypeOf,Ga=Object.prototype.hasOwnProperty;var Xa=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ka(e))!Ga.call(t,i)&&i!==n&&xi(t,i,{get:()=>e[i],enumerable:!(s=Wa(e,i))||s.enumerable});return t};var qa=(t,e,n)=>(n=t!=null?_a(Ha(t)):{},Xa(e||!t||!t.__esModule?xi(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),Y=require("lucide-react"),Lr=require("@ai-sdk/react"),bn=require("ai"),Or=require("@radix-ui/react-slot"),Fr=require("class-variance-authority"),Ya=require("clsx"),Ja=require("tailwind-merge"),Za=require("@radix-ui/react-tooltip"),vi=require("@radix-ui/react-use-controllable-state"),Qa=require("@radix-ui/react-collapsible"),tc=require("./server.cjs");function As(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Tt=As(m),Ae=As(Za),Cs=As(Qa);function Q(...t){return Ja.twMerge(Ya.clsx(t))}const se=Fr.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"}}),wn=Tt.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},o)=>{const r=s?Or.Slot:"button";return h.jsx(r,{ref:o,"data-slot":"button",className:Q(se({variant:e,size:n,className:t})),...i})});wn.displayName="Button";const ec=Fr.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 Fn({className:t,variant:e,asChild:n=!1,...s}){const i=n?Or.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:Q(ec({variant:e}),t),...s})}const nc=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,o]=Tt.useState(!0);Tt.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const c=a.scrollHeight;c>n?a.style.height=`${n}px`:a.style.height=`${c+6}px`}},[t.current,e])},Br=Tt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...o},r)=>{const a=Tt.useRef(null),[c,u]=Tt.useState("");return nc({textAreaRef:a,triggerAutoSize:c,maxHeight:t,minHeight:e}),m.useImperativeHandle(r,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),Tt.useEffect(()=>{u(i)},[o?.defaultValue,i]),h.jsx("textarea",{...o,value:i,ref:a,className:Q("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:l=>{u(l.target.value),s?.(l)}})});Br.displayName="AutosizeTextarea";function sc({delayDuration:t=0,...e}){return h.jsx(Ae.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Qt({...t}){return h.jsx(sc,{children:h.jsx(Ae.Root,{"data-slot":"tooltip",...t})})}function te({...t}){return h.jsx(Ae.Trigger,{"data-slot":"tooltip-trigger",...t})}function ee({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(Ae.Portal,{children:h.jsxs(Ae.Content,{"data-slot":"tooltip-content",sideOffset:e,className:Q("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",t),...s,children:[n,h.jsx(Ae.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function bi({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:Q("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",t),...e})}const Ps=m.createContext({});function Ms(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const js=typeof window<"u",$r=js?m.useLayoutEffect:m.useEffect,Mn=m.createContext(null);function Es(t,e){t.indexOf(e)===-1&&t.push(e)}function ks(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Nt=(t,e,n)=>n>e?e:n<t?t:n;function es(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let je=()=>{},It=()=>{};process.env.NODE_ENV!=="production"&&(je=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(es(e,n))},It=(t,e,n)=>{if(!t)throw new Error(es(e,n))});const Lt={},zr=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function Ur(t){return typeof t=="object"&&t!==null}const _r=t=>/^0[^.\s]+$/u.test(t);function Ds(t){let e;return()=>(e===void 0&&(e=t()),e)}const vt=t=>t,ic=(t,e)=>n=>e(t(n)),Qe=(...t)=>t.reduce(ic),Ge=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Vs{constructor(){this.subscriptions=[]}add(e){return Es(this.subscriptions,e),()=>ks(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const St=t=>t*1e3,xt=t=>t/1e3;function Wr(t,e){return e?t*(1e3/e):0}const wi=new Set;function Rs(t,e,n){t||wi.has(e)||(console.warn(es(e,n)),wi.add(e))}const Kr=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,rc=1e-7,oc=12;function ac(t,e,n,s,i){let o,r,a=0;do r=e+(n-e)/2,o=Kr(r,s,i)-t,o>0?n=r:e=r;while(Math.abs(o)>rc&&++a<oc);return r}function tn(t,e,n,s){if(t===e&&n===s)return vt;const i=o=>ac(o,0,1,t,n);return o=>o===0||o===1?o:Kr(i(o),e,s)}const Hr=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Gr=t=>e=>1-t(1-e),Xr=tn(.33,1.53,.69,.99),Ns=Gr(Xr),qr=Hr(Ns),Yr=t=>(t*=2)<1?.5*Ns(t):.5*(2-Math.pow(2,-10*(t-1))),Is=t=>1-Math.sin(Math.acos(t)),Jr=Gr(Is),Zr=Hr(Is),cc=tn(.42,0,1,1),lc=tn(0,0,.58,1),Qr=tn(.42,0,.58,1),uc=t=>Array.isArray(t)&&typeof t[0]!="number",to=t=>Array.isArray(t)&&typeof t[0]=="number",Ti={linear:vt,easeIn:cc,easeInOut:Qr,easeOut:lc,circIn:Is,circInOut:Zr,circOut:Jr,backIn:Ns,backInOut:qr,backOut:Xr,anticipate:Yr},dc=t=>typeof t=="string",Si=t=>{if(to(t)){It(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return tn(e,n,s,i)}else if(dc(t))return It(Ti[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Ti[t];return t},un=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function hc(t,e){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(l){r.has(l)&&(u.schedule(l),t()),l(a)}const u={schedule:(l,d=!1,f=!1)=>{const x=f&&i?n:s;return d&&r.add(l),x.has(l)||x.add(l),l},cancel:l=>{s.delete(l),r.delete(l)},process:l=>{if(a=l,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(c),n.clear(),i=!1,o&&(o=!1,u.process(l))}};return u}const fc=40;function eo(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=un.reduce((S,E)=>(S[E]=hc(o),S),{}),{setup:a,read:c,resolveKeyframes:u,preUpdate:l,update:d,preRender:f,render:g,postRender:x}=r,v=()=>{const S=Lt.useManualTiming?i.timestamp:performance.now();n=!1,Lt.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(S-i.timestamp,fc),1)),i.timestamp=S,i.isProcessing=!0,a.process(i),c.process(i),u.process(i),l.process(i),d.process(i),f.process(i),g.process(i),x.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},C=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:un.reduce((S,E)=>{const M=r[E];return S[E]=(j,L=!1,V=!1)=>(n||C(),M.schedule(j,L,V)),S},{}),cancel:S=>{for(let E=0;E<un.length;E++)r[un[E]].cancel(S)},state:i,steps:r}}const{schedule:W,cancel:Wt,state:Z,steps:Bn}=eo(typeof requestAnimationFrame<"u"?requestAnimationFrame:vt,!0);let pn;function mc(){pn=void 0}const ut={now:()=>(pn===void 0&&ut.set(Z.isProcessing||Lt.useManualTiming?Z.timestamp:performance.now()),pn),set:t=>{pn=t,queueMicrotask(mc)}},no=t=>e=>typeof e=="string"&&e.startsWith(t),Ls=no("--"),pc=no("var(--"),Os=t=>pc(t)?gc.test(t.split("/*")[0].trim()):!1,gc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Ee={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Xe={...Ee,transform:t=>Nt(0,1,t)},dn={...Ee,default:1},ze=t=>Math.round(t*1e5)/1e5,Fs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function yc(t){return t==null}const xc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Bs=(t,e)=>n=>!!(typeof n=="string"&&xc.test(n)&&n.startsWith(t)||e&&!yc(n)&&Object.prototype.hasOwnProperty.call(n,e)),so=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,a]=s.match(Fs);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},vc=t=>Nt(0,255,t),$n={...Ee,transform:t=>Math.round(vc(t))},re={test:Bs("rgb","red"),parse:so("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+$n.transform(t)+", "+$n.transform(e)+", "+$n.transform(n)+", "+ze(Xe.transform(s))+")"};function bc(t){let e="",n="",s="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,s+=s,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const ns={test:Bs("#"),parse:bc,transform:re.transform},en=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),_t=en("deg"),Et=en("%"),R=en("px"),wc=en("vh"),Tc=en("vw"),Ai={...Et,parse:t=>Et.parse(t)/100,transform:t=>Et.transform(t*100)},xe={test:Bs("hsl","hue"),parse:so("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+Et.transform(ze(e))+", "+Et.transform(ze(n))+", "+ze(Xe.transform(s))+")"},q={test:t=>re.test(t)||ns.test(t)||xe.test(t),parse:t=>re.test(t)?re.parse(t):xe.test(t)?xe.parse(t):ns.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?re.transform(t):xe.transform(t),getAnimatableNone:t=>{const e=q.parse(t);return e.alpha=0,q.transform(e)}},Sc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Ac(t){return isNaN(t)&&typeof t=="string"&&(t.match(Fs)?.length||0)+(t.match(Sc)?.length||0)>0}const io="number",ro="color",Cc="var",Pc="var(",Ci="${}",Mc=/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 qe(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let o=0;const a=e.replace(Mc,c=>(q.test(c)?(s.color.push(o),i.push(ro),n.push(q.parse(c))):c.startsWith(Pc)?(s.var.push(o),i.push(Cc),n.push(c)):(s.number.push(o),i.push(io),n.push(parseFloat(c))),++o,Ci)).split(Ci);return{values:n,split:a,indexes:s,types:i}}function oo(t){return qe(t).values}function ao(t){const{split:e,types:n}=qe(t),s=e.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=e[r],i[r]!==void 0){const a=n[r];a===io?o+=ze(i[r]):a===ro?o+=q.transform(i[r]):o+=i[r]}return o}}const jc=t=>typeof t=="number"?0:q.test(t)?q.getAnimatableNone(t):t;function Ec(t){const e=oo(t);return ao(t)(e.map(jc))}const Kt={test:Ac,parse:oo,createTransformer:ao,getAnimatableNone:Ec};function zn(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function kc({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,o=0,r=0;if(!e)i=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=zn(c,a,t+1/3),o=zn(c,a,t),r=zn(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function Tn(t,e){return n=>n>0?e:t}const H=(t,e,n)=>t+(e-t)*n,Un=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},Dc=[ns,re,xe],Vc=t=>Dc.find(e=>e.test(t));function Pi(t){const e=Vc(t);if(je(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===xe&&(n=kc(n)),n}const Mi=(t,e)=>{const n=Pi(t),s=Pi(e);if(!n||!s)return Tn(t,e);const i={...n};return o=>(i.red=Un(n.red,s.red,o),i.green=Un(n.green,s.green,o),i.blue=Un(n.blue,s.blue,o),i.alpha=H(n.alpha,s.alpha,o),re.transform(i))},ss=new Set(["none","hidden"]);function Rc(t,e){return ss.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function Nc(t,e){return n=>H(t,e,n)}function $s(t){return typeof t=="number"?Nc:typeof t=="string"?Os(t)?Tn:q.test(t)?Mi:Oc:Array.isArray(t)?co:typeof t=="object"?q.test(t)?Mi:Ic:Tn}function co(t,e){const n=[...t],s=n.length,i=t.map((o,r)=>$s(o)(o,e[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function Ic(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=$s(t[i])(t[i],e[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function Lc(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],r=t.indexes[o][s[o]],a=t.values[r]??0;n[i]=a,s[o]++}return n}const Oc=(t,e)=>{const n=Kt.createTransformer(e),s=qe(t),i=qe(e);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?ss.has(t)&&!i.values.length||ss.has(e)&&!s.values.length?Rc(t,e):Qe(co(Lc(s,i),i.values),n):(je(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),Tn(t,e))};function lo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?H(t,e,n):$s(t)(t,e)}const Fc=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>W.update(e,n),stop:()=>Wt(e),now:()=>Z.isProcessing?Z.timestamp:ut.now()}},uo=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)s+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Sn=2e4;function zs(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Sn;)e+=n,s=t.next(e);return e>=Sn?1/0:e}function Bc(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(zs(s),Sn);return{type:"keyframes",ease:o=>s.next(i*o).value/e,duration:xt(i)}}const $c=5;function ho(t,e,n){const s=Math.max(e-$c,0);return Wr(n-t(s),e-s)}const K={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},_n=.001;function zc({duration:t=K.duration,bounce:e=K.bounce,velocity:n=K.velocity,mass:s=K.mass}){let i,o;je(t<=St(K.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let r=1-e;r=Nt(K.minDamping,K.maxDamping,r),t=Nt(K.minDuration,K.maxDuration,xt(t)),r<1?(i=u=>{const l=u*r,d=l*t,f=l-n,g=is(u,r),x=Math.exp(-d);return _n-f/g*x},o=u=>{const d=u*r*t,f=d*n+n,g=Math.pow(r,2)*Math.pow(u,2)*t,x=Math.exp(-d),v=is(Math.pow(u,2),r);return(-i(u)+_n>0?-1:1)*((f-g)*x)/v}):(i=u=>{const l=Math.exp(-u*t),d=(u-n)*t+1;return-_n+l*d},o=u=>{const l=Math.exp(-u*t),d=(n-u)*(t*t);return l*d});const a=5/t,c=_c(i,o,a);if(t=St(t),isNaN(c))return{stiffness:K.stiffness,damping:K.damping,duration:t};{const u=Math.pow(c,2)*s;return{stiffness:u,damping:r*2*Math.sqrt(s*u),duration:t}}}const Uc=12;function _c(t,e,n){let s=n;for(let i=1;i<Uc;i++)s=s-t(s)/e(s);return s}function is(t,e){return t*Math.sqrt(1-e*e)}const Wc=["duration","bounce"],Kc=["stiffness","damping","mass"];function ji(t,e){return e.some(n=>t[n]!==void 0)}function Hc(t){let e={velocity:K.velocity,stiffness:K.stiffness,damping:K.damping,mass:K.mass,isResolvedFromDuration:!1,...t};if(!ji(t,Kc)&&ji(t,Wc))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*Nt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:K.mass,stiffness:i,damping:o}}else{const n=zc(t);e={...e,...n,mass:K.mass},e.isResolvedFromDuration=!0}return e}function An(t=K.visualDuration,e=K.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:c,damping:u,mass:l,duration:d,velocity:f,isResolvedFromDuration:g}=Hc({...n,velocity:-xt(n.velocity||0)}),x=f||0,v=u/(2*Math.sqrt(c*l)),C=r-o,y=xt(Math.sqrt(c/l)),w=Math.abs(C)<5;s||(s=w?K.restSpeed.granular:K.restSpeed.default),i||(i=w?K.restDelta.granular:K.restDelta.default);let S;if(v<1){const M=is(y,v);S=j=>{const L=Math.exp(-v*y*j);return r-L*((x+v*y*C)/M*Math.sin(M*j)+C*Math.cos(M*j))}}else if(v===1)S=M=>r-Math.exp(-y*M)*(C+(x+y*C)*M);else{const M=y*Math.sqrt(v*v-1);S=j=>{const L=Math.exp(-v*y*j),V=Math.min(M*j,300);return r-L*((x+v*y*C)*Math.sinh(V)+M*C*Math.cosh(V))/M}}const E={calculatedDuration:g&&d||null,next:M=>{const j=S(M);if(g)a.done=M>=d;else{let L=M===0?x:0;v<1&&(L=M===0?St(x):ho(S,M,j));const V=Math.abs(L)<=s,F=Math.abs(r-j)<=i;a.done=V&&F}return a.value=a.done?r:j,a},toString:()=>{const M=Math.min(zs(E),Sn),j=uo(L=>E.next(M*L).value,M,30);return M+"ms "+j},toTransition:()=>{}};return E}An.applyToOptions=t=>{const e=Bc(t,100,An);return t.ease=e.ease,t.duration=St(e.duration),t.type="keyframes",t};function rs({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:c,restDelta:u=.5,restSpeed:l}){const d=t[0],f={done:!1,value:d},g=V=>a!==void 0&&V<a||c!==void 0&&V>c,x=V=>a===void 0?c:c===void 0||Math.abs(a-V)<Math.abs(c-V)?a:c;let v=n*e;const C=d+v,y=r===void 0?C:r(C);y!==C&&(v=y-d);const w=V=>-v*Math.exp(-V/s),S=V=>y+w(V),E=V=>{const F=w(V),G=S(V);f.done=Math.abs(F)<=u,f.value=f.done?y:G};let M,j;const L=V=>{g(f.value)&&(M=V,j=An({keyframes:[f.value,x(f.value)],velocity:ho(S,V,f.value),damping:i,stiffness:o,restDelta:u,restSpeed:l}))};return L(0),{calculatedDuration:null,next:V=>{let F=!1;return!j&&M===void 0&&(F=!0,E(V),L(V)),M!==void 0&&V>=M?j.next(V-M):(!F&&E(V),f)}}}function Gc(t,e,n){const s=[],i=n||Lt.mix||lo,o=t.length-1;for(let r=0;r<o;r++){let a=i(t[r],t[r+1]);if(e){const c=Array.isArray(e)?e[r]||vt:e;a=Qe(c,a)}s.push(a)}return s}function Xc(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const o=t.length;if(It(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const r=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Gc(e,s,i),c=a.length,u=l=>{if(r&&l<t[0])return e[0];let d=0;if(c>1)for(;d<t.length-2&&!(l<t[d+1]);d++);const f=Ge(t[d],t[d+1],l);return a[d](f)};return n?l=>u(Nt(t[0],t[o-1],l)):u}function qc(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ge(0,e,s);t.push(H(n,1,i))}}function Yc(t){const e=[0];return qc(e,t.length-1),e}function Jc(t,e){return t.map(n=>n*e)}function Zc(t,e){return t.map(()=>e||Qr).splice(0,t.length-1)}function ve({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=uc(s)?s.map(Si):Si(s),o={done:!1,value:e[0]},r=Jc(n&&n.length===e.length?n:Yc(e),t),a=Xc(r,e,{ease:Array.isArray(i)?i:Zc(e,i)});return{calculatedDuration:t,next:c=>(o.value=a(c),o.done=c>=t,o)}}const Qc=t=>t!==null;function Us(t,{repeat:e,repeatType:n="loop"},s,i=1){const o=t.filter(Qc),a=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const tl={decay:rs,inertia:rs,tween:ve,keyframes:ve,spring:An};function fo(t){typeof t.type=="string"&&(t.type=tl[t.type])}class _s{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const el=t=>t/100;class Ws extends _s{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==ut.now()&&this.tick(ut.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;fo(e);const{type:n=ve,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const c=n||ve;process.env.NODE_ENV!=="production"&&c!==ve&&It(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),c!==ve&&typeof a[0]!="number"&&(this.mixKeyframes=Qe(el,lo(a[0],a[1])),a=[0,100]);const u=c({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-r})),u.calculatedDuration===null&&(u.calculatedDuration=zs(u));const{calculatedDuration:l}=u;this.calculatedDuration=l,this.resolvedDuration=l+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:l,repeat:d,repeatType:f,repeatDelay:g,type:x,onUpdate:v,finalKeyframe:C}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const y=this.currentTime-u*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?y<0:y>i;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let S=this.currentTime,E=s;if(d){const V=Math.min(this.currentTime,i)/a;let F=Math.floor(V),G=V%1;!G&&V>=1&&(G=1),G===1&&F--,F=Math.min(F,d+1),!!(F%2)&&(f==="reverse"?(G=1-G,g&&(G-=g/a)):f==="mirror"&&(E=r)),S=Nt(0,1,G)*a}const M=w?{done:!1,value:l[0]}:E.next(S);o&&(M.value=o(M.value));let{done:j}=M;!w&&c!==null&&(j=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const L=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&j);return L&&x!==rs&&(M.value=Us(l,this.options,C,this.speed)),v&&v(M.value),L&&this.finish(),M}then(e,n){return this.finished.then(e,n)}get duration(){return xt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+xt(e)}get time(){return xt(this.currentTime)}set time(e){e=St(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(ut.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=xt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Fc,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),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(ut.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function nl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const oe=t=>t*180/Math.PI,os=t=>{const e=oe(Math.atan2(t[1],t[0]));return as(e)},sl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:os,rotateZ:os,skewX:t=>oe(Math.atan(t[1])),skewY:t=>oe(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},as=t=>(t=t%360,t<0&&(t+=360),t),Ei=os,ki=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Di=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),il={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ki,scaleY:Di,scale:t=>(ki(t)+Di(t))/2,rotateX:t=>as(oe(Math.atan2(t[6],t[5]))),rotateY:t=>as(oe(Math.atan2(-t[2],t[0]))),rotateZ:Ei,rotate:Ei,skewX:t=>oe(Math.atan(t[4])),skewY:t=>oe(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function cs(t){return t.includes("scale")?1:0}function ls(t,e){if(!t||t==="none")return cs(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=il,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=sl,i=a}if(!i)return cs(e);const o=s[e],r=i[1].split(",").map(ol);return typeof o=="function"?o(r):r[o]}const rl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return ls(n,e)};function ol(t){return parseFloat(t.trim())}const ke=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],De=new Set(ke),Vi=t=>t===Ee||t===R,al=new Set(["x","y","z"]),cl=ke.filter(t=>!al.has(t));function ll(t){const e=[];return cl.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const ae={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>ls(e,"x"),y:(t,{transform:e})=>ls(e,"y")};ae.translateX=ae.x;ae.translateY=ae.y;const ce=new Set;let us=!1,ds=!1,hs=!1;function mo(){if(ds){const t=Array.from(ce).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=ll(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{s.getValue(o)?.set(r)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}ds=!1,us=!1,ce.forEach(t=>t.complete(hs)),ce.clear()}function po(){ce.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ds=!0)})}function ul(){hs=!0,po(),mo(),hs=!1}class Ks{constructor(e,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(ce.add(this),us||(us=!0,W.read(po),W.resolveKeyframes(mo))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const o=i?.get(),r=e[e.length-1];if(o!==void 0)e[0]=o;else if(s&&n){const a=s.readValue(n,r);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=r),i&&o===void 0&&i.set(e[0])}nl(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ce.delete(this)}cancel(){this.state==="scheduled"&&(ce.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const dl=t=>t.startsWith("--");function hl(t,e,n){dl(e)?t.style.setProperty(e,n):t.style[e]=n}const fl=Ds(()=>window.ScrollTimeline!==void 0),ml={};function pl(t,e){const n=Ds(t);return()=>ml[e]??n()}const go=pl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),$e=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,Ri={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:$e([0,.65,.55,1]),circOut:$e([.55,0,1,.45]),backIn:$e([.31,.01,.66,-.59]),backOut:$e([.33,1.53,.69,.99])};function yo(t,e){if(t)return typeof t=="function"?go()?uo(t,e):"ease-out":to(t)?$e(t):Array.isArray(t)?t.map(n=>yo(n,e)||Ri.easeOut):Ri[t]}function gl(t,e,n,{delay:s=0,duration:i=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:c}={},u=void 0){const l={[e]:n};c&&(l.offset=c);const d=yo(a,i);Array.isArray(d)&&(l.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(l,f)}function xo(t){return typeof t=="function"&&"applyToOptions"in t}function yl({type:t,...e}){return xo(t)&&go()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class xl extends _s{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,It(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=yl(e);this.animation=gl(n,s,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const l=Us(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(l):hl(n,s,l),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return xt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+xt(e)}get time(){return xt(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=St(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&fl()?(this.animation.timeline=e,vt):n(this)}}const vo={anticipate:Yr,backInOut:qr,circInOut:Zr};function vl(t){return t in vo}function bl(t){typeof t.ease=="string"&&vl(t.ease)&&(t.ease=vo[t.ease])}const Ni=10;class wl extends xl{constructor(e){bl(e),fo(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Ws({...r,autoplay:!1}),c=St(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-Ni).value,a.sample(c).value,Ni),a.stop()}}const Ii=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Kt.test(t)||t==="0")&&!t.startsWith("url("));function Tl(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function Sl(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],r=Ii(i,e),a=Ii(o,e);return je(r===a,`You are trying to animate ${e} from "${i}" to "${o}". "${r?o:i}" is not an animatable value.`,"value-not-animatable"),!r||!a?!1:Tl(t)||(n==="spring"||xo(n))&&s}function fs(t){t.duration=0,t.type="keyframes"}const Al=new Set(["opacity","clipPath","filter","transform"]),Cl=Ds(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Pl(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:o,type:r}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=e.owner.getProps();return Cl()&&n&&Al.has(n)&&(n!=="transform"||!u)&&!c&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const Ml=40;class jl extends _s{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:c,motionValue:u,element:l,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=ut.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:c,motionValue:u,element:l,...d},g=l?.KeyframeResolver||Ks;this.keyframeResolver=new g(a,(x,v,C)=>this.onKeyframesResolved(x,v,f,!C),c,u,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:c,isHandoff:u,onUpdate:l}=s;this.resolvedAt=ut.now(),Sl(e,o,r,a)||((Lt.instantAnimations||!c)&&l?.(Us(e,s,n)),e[0]=e[e.length-1],fs(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>Ml?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&Pl(f)?new wl({...f,element:f.motionValue.owner.current}):new Ws(f);g.finished.then(()=>this.notifyFinished()).catch(vt),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),ul()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const El=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function kl(t){const e=El.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const Dl=4;function bo(t,e,n=1){It(n<=Dl,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=kl(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const r=o.trim();return zr(r)?parseFloat(r):r}return Os(i)?bo(i,e,n+1):i}function Hs(t,e){return t?.[e]??t?.default??t}const wo=new Set(["width","height","top","left","right","bottom",...ke]),Vl={test:t=>t==="auto",parse:t=>t},To=t=>e=>e.test(t),So=[Ee,R,Et,_t,Tc,wc,Vl],Li=t=>So.find(To(t));function Rl(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||_r(t):!0}const Nl=new Set(["brightness","contrast","saturate","opacity"]);function Il(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(Fs)||[];if(!s)return t;const i=n.replace(s,"");let o=Nl.has(e)?1:0;return s!==n&&(o*=100),e+"("+o+i+")"}const Ll=/\b([a-z-]*)\(.*?\)/gu,ms={...Kt,getAnimatableNone:t=>{const e=t.match(Ll);return e?e.map(Il).join(" "):t}},Oi={...Ee,transform:Math.round},Ol={rotate:_t,rotateX:_t,rotateY:_t,rotateZ:_t,scale:dn,scaleX:dn,scaleY:dn,scaleZ:dn,skew:_t,skewX:_t,skewY:_t,distance:R,translateX:R,translateY:R,translateZ:R,x:R,y:R,z:R,perspective:R,transformPerspective:R,opacity:Xe,originX:Ai,originY:Ai,originZ:R},Gs={borderWidth:R,borderTopWidth:R,borderRightWidth:R,borderBottomWidth:R,borderLeftWidth:R,borderRadius:R,radius:R,borderTopLeftRadius:R,borderTopRightRadius:R,borderBottomRightRadius:R,borderBottomLeftRadius:R,width:R,maxWidth:R,height:R,maxHeight:R,top:R,right:R,bottom:R,left:R,padding:R,paddingTop:R,paddingRight:R,paddingBottom:R,paddingLeft:R,margin:R,marginTop:R,marginRight:R,marginBottom:R,marginLeft:R,backgroundPositionX:R,backgroundPositionY:R,...Ol,zIndex:Oi,fillOpacity:Xe,strokeOpacity:Xe,numOctaves:Oi},Fl={...Gs,color:q,backgroundColor:q,outlineColor:q,fill:q,stroke:q,borderColor:q,borderTopColor:q,borderRightColor:q,borderBottomColor:q,borderLeftColor:q,filter:ms,WebkitFilter:ms},Ao=t=>Fl[t];function Co(t,e){let n=Ao(t);return n!==ms&&(n=Kt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Bl=new Set(["auto","none","0"]);function $l(t,e,n){let s=0,i;for(;s<t.length&&!i;){const o=t[s];typeof o=="string"&&!Bl.has(o)&&qe(o).values.length&&(i=t[s]),s++}if(i&&n)for(const o of e)t[o]=Co(n,i)}class zl extends Ks{constructor(e,n,s,i,o){super(e,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let u=e[c];if(typeof u=="string"&&(u=u.trim(),Os(u))){const l=bo(u,n.current);l!==void 0&&(e[c]=l),c===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!wo.has(s)||e.length!==2)return;const[i,o]=e,r=Li(i),a=Li(o);if(r!==a)if(Vi(r)&&Vi(a))for(let c=0;c<e.length;c++){const u=e[c];typeof u=="string"&&(e[c]=parseFloat(u))}else ae[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||Rl(e[i]))&&s.push(i);s.length&&$l(e,s,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ae[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,r=s[o];s[o]=ae[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,c])=>{e.getValue(a).set(c)}),this.resolveNoneKeyframes()}}function Ul(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const Po=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Mo(t){return Ur(t)&&"offsetHeight"in t}const Fi=30,_l=t=>!isNaN(parseFloat(t));class Wl{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=ut.now();if(this.updatedAt!==i&&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(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=ut.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=_l(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&Rs(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Vs);const s=this.events[e].add(n);return e==="change"?()=>{s(),W.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=ut.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Fi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Fi);return Wr(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Pe(t,e){return new Wl(t,e)}const{schedule:Xs}=eo(queueMicrotask,!1),wt={x:!1,y:!1};function jo(){return wt.x||wt.y}function Kl(t){return t==="x"||t==="y"?wt[t]?null:(wt[t]=!0,()=>{wt[t]=!1}):wt.x||wt.y?null:(wt.x=wt.y=!0,()=>{wt.x=wt.y=!1})}function Eo(t,e){const n=Ul(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function Bi(t){return!(t.pointerType==="touch"||jo())}function Hl(t,e,n={}){const[s,i,o]=Eo(t,n),r=a=>{if(!Bi(a))return;const{target:c}=a,u=e(c,a);if(typeof u!="function"||!c)return;const l=d=>{Bi(d)&&(u(d),c.removeEventListener("pointerleave",l))};c.addEventListener("pointerleave",l,i)};return s.forEach(a=>{a.addEventListener("pointerenter",r,i)}),o}const ko=(t,e)=>e?t===e?!0:ko(t,e.parentElement):!1,qs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Gl=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Xl(t){return Gl.has(t.tagName)||t.tabIndex!==-1}const gn=new WeakSet;function $i(t){return e=>{e.key==="Enter"&&t(e)}}function Wn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const ql=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=$i(()=>{if(gn.has(n))return;Wn(n,"down");const i=$i(()=>{Wn(n,"up")}),o=()=>Wn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function zi(t){return qs(t)&&!jo()}function Yl(t,e,n={}){const[s,i,o]=Eo(t,n),r=a=>{const c=a.currentTarget;if(!zi(a))return;gn.add(c);const u=e(c,a),l=(g,x)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),gn.has(c)&&gn.delete(c),zi(g)&&typeof u=="function"&&u(g,{success:x})},d=g=>{l(g,c===window||c===document||n.useGlobalTarget||ko(c,g.target))},f=g=>{l(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,i),Mo(a)&&(a.addEventListener("focus",u=>ql(u,i)),!Xl(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function Do(t){return Ur(t)&&"ownerSVGElement"in t}function Jl(t){return Do(t)&&t.tagName==="svg"}const nt=t=>!!(t&&t.getVelocity),Zl=[...So,q,Kt],Ql=t=>Zl.find(To(t)),Ys=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function Ui(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function tu(...t){return e=>{let n=!1;const s=t.map(i=>{const o=Ui(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<s.length;i++){const o=s[i];typeof o=="function"?o():Ui(t[i],null)}}}}function eu(...t){return Tt.useCallback(tu(...t),t)}class nu extends Tt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=Mo(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=i-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function su({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),o=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Ys),c=eu(o,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:l,top:d,left:f,right:g}=r.current;if(e||!o.current||!u||!l)return;const x=n==="left"?`left: ${f}`:`right: ${g}`;o.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const C=s??document.head;return C.appendChild(v),v.sheet&&v.sheet.insertRule(`
1
+ "use strict";var $a=Object.create;var gi=Object.defineProperty;var za=Object.getOwnPropertyDescriptor;var Ua=Object.getOwnPropertyNames;var _a=Object.getPrototypeOf,Wa=Object.prototype.hasOwnProperty;var Ka=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ua(e))!Wa.call(t,i)&&i!==n&&gi(t,i,{get:()=>e[i],enumerable:!(s=za(e,i))||s.enumerable});return t};var Ha=(t,e,n)=>(n=t!=null?$a(_a(t)):{},Ka(e||!t||!t.__esModule?gi(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),Q=require("lucide-react"),Nr=require("@ai-sdk/react"),bn=require("ai"),Ir=require("@radix-ui/react-slot"),Lr=require("class-variance-authority"),Ga=require("clsx"),Xa=require("tailwind-merge"),qa=require("@radix-ui/react-tooltip"),yi=require("@radix-ui/react-use-controllable-state"),Ya=require("@radix-ui/react-collapsible"),Ja=require("./server.cjs");function As(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Pt=As(m),Ce=As(qa),Ps=As(Ya);function it(...t){return Xa.twMerge(Ga.clsx(t))}const ie=Lr.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"}}),wn=Pt.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},o)=>{const r=s?Ir.Slot:"button";return h.jsx(r,{ref:o,"data-slot":"button",className:it(ie({variant:e,size:n,className:t})),...i})});wn.displayName="Button";const Za=Lr.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 Fn({className:t,variant:e,asChild:n=!1,...s}){const i=n?Ir.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:it(Za({variant:e}),t),...s})}const Qa=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,o]=Pt.useState(!0);Pt.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const c=a.scrollHeight;c>n?a.style.height=`${n}px`:a.style.height=`${c+6}px`}},[t.current,e])},Or=Pt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...o},r)=>{const a=Pt.useRef(null),[c,u]=Pt.useState("");return Qa({textAreaRef:a,triggerAutoSize:c,maxHeight:t,minHeight:e}),m.useImperativeHandle(r,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),Pt.useEffect(()=>{u(i)},[o?.defaultValue,i]),h.jsx("textarea",{...o,value:i,ref:a,className:it("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:l=>{u(l.target.value),s?.(l)}})});Or.displayName="AutosizeTextarea";function tc({delayDuration:t=0,...e}){return h.jsx(Ce.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function te({...t}){return h.jsx(tc,{children:h.jsx(Ce.Root,{"data-slot":"tooltip",...t})})}function ee({...t}){return h.jsx(Ce.Trigger,{"data-slot":"tooltip-trigger",...t})}function ne({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(Ce.Portal,{children:h.jsxs(Ce.Content,{"data-slot":"tooltip-content",sideOffset:e,className:it("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",t),...s,children:[n,h.jsx(Ce.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function xi({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:it("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",t),...e})}const Cs=m.createContext({});function Ms(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const js=typeof window<"u",Fr=js?m.useLayoutEffect:m.useEffect,Mn=m.createContext(null);function Es(t,e){t.indexOf(e)===-1&&t.push(e)}function ks(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Lt=(t,e,n)=>n>e?e:n<t?t:n;function es(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let ke=()=>{},Ot=()=>{};process.env.NODE_ENV!=="production"&&(ke=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(es(e,n))},Ot=(t,e,n)=>{if(!t)throw new Error(es(e,n))});const Ft={},Br=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function $r(t){return typeof t=="object"&&t!==null}const zr=t=>/^0[^.\s]+$/u.test(t);function Ds(t){let e;return()=>(e===void 0&&(e=t()),e)}const wt=t=>t,ec=(t,e)=>n=>e(t(n)),Qe=(...t)=>t.reduce(ec),Ge=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Vs{constructor(){this.subscriptions=[]}add(e){return Es(this.subscriptions,e),()=>ks(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Ct=t=>t*1e3,bt=t=>t/1e3;function Ur(t,e){return e?t*(1e3/e):0}const vi=new Set;function Rs(t,e,n){t||vi.has(e)||(console.warn(es(e,n)),vi.add(e))}const _r=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,nc=1e-7,sc=12;function ic(t,e,n,s,i){let o,r,a=0;do r=e+(n-e)/2,o=_r(r,s,i)-t,o>0?n=r:e=r;while(Math.abs(o)>nc&&++a<sc);return r}function tn(t,e,n,s){if(t===e&&n===s)return wt;const i=o=>ic(o,0,1,t,n);return o=>o===0||o===1?o:_r(i(o),e,s)}const Wr=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Kr=t=>e=>1-t(1-e),Hr=tn(.33,1.53,.69,.99),Ns=Kr(Hr),Gr=Wr(Ns),Xr=t=>(t*=2)<1?.5*Ns(t):.5*(2-Math.pow(2,-10*(t-1))),Is=t=>1-Math.sin(Math.acos(t)),qr=Kr(Is),Yr=Wr(Is),rc=tn(.42,0,1,1),oc=tn(0,0,.58,1),Jr=tn(.42,0,.58,1),ac=t=>Array.isArray(t)&&typeof t[0]!="number",Zr=t=>Array.isArray(t)&&typeof t[0]=="number",bi={linear:wt,easeIn:rc,easeInOut:Jr,easeOut:oc,circIn:Is,circInOut:Yr,circOut:qr,backIn:Ns,backInOut:Gr,backOut:Hr,anticipate:Xr},cc=t=>typeof t=="string",wi=t=>{if(Zr(t)){Ot(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return tn(e,n,s,i)}else if(cc(t))return Ot(bi[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),bi[t];return t},un=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function lc(t,e){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(l){r.has(l)&&(u.schedule(l),t()),l(a)}const u={schedule:(l,d=!1,f=!1)=>{const x=f&&i?n:s;return d&&r.add(l),x.has(l)||x.add(l),l},cancel:l=>{s.delete(l),r.delete(l)},process:l=>{if(a=l,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(c),n.clear(),i=!1,o&&(o=!1,u.process(l))}};return u}const uc=40;function Qr(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=un.reduce((S,D)=>(S[D]=lc(o),S),{}),{setup:a,read:c,resolveKeyframes:u,preUpdate:l,update:d,preRender:f,render:g,postRender:x}=r,v=()=>{const S=Ft.useManualTiming?i.timestamp:performance.now();n=!1,Ft.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(S-i.timestamp,uc),1)),i.timestamp=S,i.isProcessing=!0,a.process(i),c.process(i),u.process(i),l.process(i),d.process(i),f.process(i),g.process(i),x.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},A=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:un.reduce((S,D)=>{const j=r[D];return S[D]=(E,O=!1,R=!1)=>(n||A(),j.schedule(E,O,R)),S},{}),cancel:S=>{for(let D=0;D<un.length;D++)r[un[D]].cancel(S)},state:i,steps:r}}const{schedule:G,cancel:_t,state:st,steps:Bn}=Qr(typeof requestAnimationFrame<"u"?requestAnimationFrame:wt,!0);let pn;function dc(){pn=void 0}const mt={now:()=>(pn===void 0&&mt.set(st.isProcessing||Ft.useManualTiming?st.timestamp:performance.now()),pn),set:t=>{pn=t,queueMicrotask(dc)}},to=t=>e=>typeof e=="string"&&e.startsWith(t),Ls=to("--"),hc=to("var(--"),Os=t=>hc(t)?fc.test(t.split("/*")[0].trim()):!1,fc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,De={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Xe={...De,transform:t=>Lt(0,1,t)},dn={...De,default:1},ze=t=>Math.round(t*1e5)/1e5,Fs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function mc(t){return t==null}const pc=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Bs=(t,e)=>n=>!!(typeof n=="string"&&pc.test(n)&&n.startsWith(t)||e&&!mc(n)&&Object.prototype.hasOwnProperty.call(n,e)),eo=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,a]=s.match(Fs);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},gc=t=>Lt(0,255,t),$n={...De,transform:t=>Math.round(gc(t))},oe={test:Bs("rgb","red"),parse:eo("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+$n.transform(t)+", "+$n.transform(e)+", "+$n.transform(n)+", "+ze(Xe.transform(s))+")"};function yc(t){let e="",n="",s="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,s+=s,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const ns={test:Bs("#"),parse:yc,transform:oe.transform},en=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Ut=en("deg"),Dt=en("%"),L=en("px"),xc=en("vh"),vc=en("vw"),Ti={...Dt,parse:t=>Dt.parse(t)/100,transform:t=>Dt.transform(t*100)},be={test:Bs("hsl","hue"),parse:eo("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+Dt.transform(ze(e))+", "+Dt.transform(ze(n))+", "+ze(Xe.transform(s))+")"},Z={test:t=>oe.test(t)||ns.test(t)||be.test(t),parse:t=>oe.test(t)?oe.parse(t):be.test(t)?be.parse(t):ns.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?oe.transform(t):be.transform(t),getAnimatableNone:t=>{const e=Z.parse(t);return e.alpha=0,Z.transform(e)}},bc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function wc(t){return isNaN(t)&&typeof t=="string"&&(t.match(Fs)?.length||0)+(t.match(bc)?.length||0)>0}const no="number",so="color",Tc="var",Sc="var(",Si="${}",Ac=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function qe(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let o=0;const a=e.replace(Ac,c=>(Z.test(c)?(s.color.push(o),i.push(so),n.push(Z.parse(c))):c.startsWith(Sc)?(s.var.push(o),i.push(Tc),n.push(c)):(s.number.push(o),i.push(no),n.push(parseFloat(c))),++o,Si)).split(Si);return{values:n,split:a,indexes:s,types:i}}function io(t){return qe(t).values}function ro(t){const{split:e,types:n}=qe(t),s=e.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=e[r],i[r]!==void 0){const a=n[r];a===no?o+=ze(i[r]):a===so?o+=Z.transform(i[r]):o+=i[r]}return o}}const Pc=t=>typeof t=="number"?0:Z.test(t)?Z.getAnimatableNone(t):t;function Cc(t){const e=io(t);return ro(t)(e.map(Pc))}const Wt={test:wc,parse:io,createTransformer:ro,getAnimatableNone:Cc};function zn(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function Mc({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,o=0,r=0;if(!e)i=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=zn(c,a,t+1/3),o=zn(c,a,t),r=zn(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function Tn(t,e){return n=>n>0?e:t}const q=(t,e,n)=>t+(e-t)*n,Un=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},jc=[ns,oe,be],Ec=t=>jc.find(e=>e.test(t));function Ai(t){const e=Ec(t);if(ke(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===be&&(n=Mc(n)),n}const Pi=(t,e)=>{const n=Ai(t),s=Ai(e);if(!n||!s)return Tn(t,e);const i={...n};return o=>(i.red=Un(n.red,s.red,o),i.green=Un(n.green,s.green,o),i.blue=Un(n.blue,s.blue,o),i.alpha=q(n.alpha,s.alpha,o),oe.transform(i))},ss=new Set(["none","hidden"]);function kc(t,e){return ss.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function Dc(t,e){return n=>q(t,e,n)}function $s(t){return typeof t=="number"?Dc:typeof t=="string"?Os(t)?Tn:Z.test(t)?Pi:Nc:Array.isArray(t)?oo:typeof t=="object"?Z.test(t)?Pi:Vc:Tn}function oo(t,e){const n=[...t],s=n.length,i=t.map((o,r)=>$s(o)(o,e[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function Vc(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=$s(t[i])(t[i],e[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function Rc(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],r=t.indexes[o][s[o]],a=t.values[r]??0;n[i]=a,s[o]++}return n}const Nc=(t,e)=>{const n=Wt.createTransformer(e),s=qe(t),i=qe(e);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?ss.has(t)&&!i.values.length||ss.has(e)&&!s.values.length?kc(t,e):Qe(oo(Rc(s,i),i.values),n):(ke(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),Tn(t,e))};function ao(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?q(t,e,n):$s(t)(t,e)}const Ic=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>G.update(e,n),stop:()=>_t(e),now:()=>st.isProcessing?st.timestamp:mt.now()}},co=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)s+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Sn=2e4;function zs(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Sn;)e+=n,s=t.next(e);return e>=Sn?1/0:e}function Lc(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(zs(s),Sn);return{type:"keyframes",ease:o=>s.next(i*o).value/e,duration:bt(i)}}const Oc=5;function lo(t,e,n){const s=Math.max(e-Oc,0);return Ur(n-t(s),e-s)}const X={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},_n=.001;function Fc({duration:t=X.duration,bounce:e=X.bounce,velocity:n=X.velocity,mass:s=X.mass}){let i,o;ke(t<=Ct(X.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let r=1-e;r=Lt(X.minDamping,X.maxDamping,r),t=Lt(X.minDuration,X.maxDuration,bt(t)),r<1?(i=u=>{const l=u*r,d=l*t,f=l-n,g=is(u,r),x=Math.exp(-d);return _n-f/g*x},o=u=>{const d=u*r*t,f=d*n+n,g=Math.pow(r,2)*Math.pow(u,2)*t,x=Math.exp(-d),v=is(Math.pow(u,2),r);return(-i(u)+_n>0?-1:1)*((f-g)*x)/v}):(i=u=>{const l=Math.exp(-u*t),d=(u-n)*t+1;return-_n+l*d},o=u=>{const l=Math.exp(-u*t),d=(n-u)*(t*t);return l*d});const a=5/t,c=$c(i,o,a);if(t=Ct(t),isNaN(c))return{stiffness:X.stiffness,damping:X.damping,duration:t};{const u=Math.pow(c,2)*s;return{stiffness:u,damping:r*2*Math.sqrt(s*u),duration:t}}}const Bc=12;function $c(t,e,n){let s=n;for(let i=1;i<Bc;i++)s=s-t(s)/e(s);return s}function is(t,e){return t*Math.sqrt(1-e*e)}const zc=["duration","bounce"],Uc=["stiffness","damping","mass"];function Ci(t,e){return e.some(n=>t[n]!==void 0)}function _c(t){let e={velocity:X.velocity,stiffness:X.stiffness,damping:X.damping,mass:X.mass,isResolvedFromDuration:!1,...t};if(!Ci(t,Uc)&&Ci(t,zc))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*Lt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:X.mass,stiffness:i,damping:o}}else{const n=Fc(t);e={...e,...n,mass:X.mass},e.isResolvedFromDuration=!0}return e}function An(t=X.visualDuration,e=X.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:c,damping:u,mass:l,duration:d,velocity:f,isResolvedFromDuration:g}=_c({...n,velocity:-bt(n.velocity||0)}),x=f||0,v=u/(2*Math.sqrt(c*l)),A=r-o,y=bt(Math.sqrt(c/l)),w=Math.abs(A)<5;s||(s=w?X.restSpeed.granular:X.restSpeed.default),i||(i=w?X.restDelta.granular:X.restDelta.default);let S;if(v<1){const j=is(y,v);S=E=>{const O=Math.exp(-v*y*E);return r-O*((x+v*y*A)/j*Math.sin(j*E)+A*Math.cos(j*E))}}else if(v===1)S=j=>r-Math.exp(-y*j)*(A+(x+y*A)*j);else{const j=y*Math.sqrt(v*v-1);S=E=>{const O=Math.exp(-v*y*E),R=Math.min(j*E,300);return r-O*((x+v*y*A)*Math.sinh(R)+j*A*Math.cosh(R))/j}}const D={calculatedDuration:g&&d||null,next:j=>{const E=S(j);if(g)a.done=j>=d;else{let O=j===0?x:0;v<1&&(O=j===0?Ct(x):lo(S,j,E));const R=Math.abs(O)<=s,B=Math.abs(r-E)<=i;a.done=R&&B}return a.value=a.done?r:E,a},toString:()=>{const j=Math.min(zs(D),Sn),E=co(O=>D.next(j*O).value,j,30);return j+"ms "+E},toTransition:()=>{}};return D}An.applyToOptions=t=>{const e=Lc(t,100,An);return t.ease=e.ease,t.duration=Ct(e.duration),t.type="keyframes",t};function rs({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:c,restDelta:u=.5,restSpeed:l}){const d=t[0],f={done:!1,value:d},g=R=>a!==void 0&&R<a||c!==void 0&&R>c,x=R=>a===void 0?c:c===void 0||Math.abs(a-R)<Math.abs(c-R)?a:c;let v=n*e;const A=d+v,y=r===void 0?A:r(A);y!==A&&(v=y-d);const w=R=>-v*Math.exp(-R/s),S=R=>y+w(R),D=R=>{const B=w(R),Y=S(R);f.done=Math.abs(B)<=u,f.value=f.done?y:Y};let j,E;const O=R=>{g(f.value)&&(j=R,E=An({keyframes:[f.value,x(f.value)],velocity:lo(S,R,f.value),damping:i,stiffness:o,restDelta:u,restSpeed:l}))};return O(0),{calculatedDuration:null,next:R=>{let B=!1;return!E&&j===void 0&&(B=!0,D(R),O(R)),j!==void 0&&R>=j?E.next(R-j):(!B&&D(R),f)}}}function Wc(t,e,n){const s=[],i=n||Ft.mix||ao,o=t.length-1;for(let r=0;r<o;r++){let a=i(t[r],t[r+1]);if(e){const c=Array.isArray(e)?e[r]||wt:e;a=Qe(c,a)}s.push(a)}return s}function Kc(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const o=t.length;if(Ot(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const r=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Wc(e,s,i),c=a.length,u=l=>{if(r&&l<t[0])return e[0];let d=0;if(c>1)for(;d<t.length-2&&!(l<t[d+1]);d++);const f=Ge(t[d],t[d+1],l);return a[d](f)};return n?l=>u(Lt(t[0],t[o-1],l)):u}function Hc(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ge(0,e,s);t.push(q(n,1,i))}}function Gc(t){const e=[0];return Hc(e,t.length-1),e}function Xc(t,e){return t.map(n=>n*e)}function qc(t,e){return t.map(()=>e||Jr).splice(0,t.length-1)}function we({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=ac(s)?s.map(wi):wi(s),o={done:!1,value:e[0]},r=Xc(n&&n.length===e.length?n:Gc(e),t),a=Kc(r,e,{ease:Array.isArray(i)?i:qc(e,i)});return{calculatedDuration:t,next:c=>(o.value=a(c),o.done=c>=t,o)}}const Yc=t=>t!==null;function Us(t,{repeat:e,repeatType:n="loop"},s,i=1){const o=t.filter(Yc),a=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Jc={decay:rs,inertia:rs,tween:we,keyframes:we,spring:An};function uo(t){typeof t.type=="string"&&(t.type=Jc[t.type])}class _s{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const Zc=t=>t/100;class Ws extends _s{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==mt.now()&&this.tick(mt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;uo(e);const{type:n=we,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const c=n||we;process.env.NODE_ENV!=="production"&&c!==we&&Ot(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),c!==we&&typeof a[0]!="number"&&(this.mixKeyframes=Qe(Zc,ao(a[0],a[1])),a=[0,100]);const u=c({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-r})),u.calculatedDuration===null&&(u.calculatedDuration=zs(u));const{calculatedDuration:l}=u;this.calculatedDuration=l,this.resolvedDuration=l+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:l,repeat:d,repeatType:f,repeatDelay:g,type:x,onUpdate:v,finalKeyframe:A}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const y=this.currentTime-u*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?y<0:y>i;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let S=this.currentTime,D=s;if(d){const R=Math.min(this.currentTime,i)/a;let B=Math.floor(R),Y=R%1;!Y&&R>=1&&(Y=1),Y===1&&B--,B=Math.min(B,d+1),!!(B%2)&&(f==="reverse"?(Y=1-Y,g&&(Y-=g/a)):f==="mirror"&&(D=r)),S=Lt(0,1,Y)*a}const j=w?{done:!1,value:l[0]}:D.next(S);o&&(j.value=o(j.value));let{done:E}=j;!w&&c!==null&&(E=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const O=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&E);return O&&x!==rs&&(j.value=Us(l,this.options,A,this.speed)),v&&v(j.value),O&&this.finish(),j}then(e,n){return this.finished.then(e,n)}get duration(){return bt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(this.currentTime)}set time(e){e=Ct(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(mt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=bt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Ic,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),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(mt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function Qc(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const ae=t=>t*180/Math.PI,os=t=>{const e=ae(Math.atan2(t[1],t[0]));return as(e)},tl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:os,rotateZ:os,skewX:t=>ae(Math.atan(t[1])),skewY:t=>ae(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},as=t=>(t=t%360,t<0&&(t+=360),t),Mi=os,ji=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),Ei=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),el={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ji,scaleY:Ei,scale:t=>(ji(t)+Ei(t))/2,rotateX:t=>as(ae(Math.atan2(t[6],t[5]))),rotateY:t=>as(ae(Math.atan2(-t[2],t[0]))),rotateZ:Mi,rotate:Mi,skewX:t=>ae(Math.atan(t[4])),skewY:t=>ae(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function cs(t){return t.includes("scale")?1:0}function ls(t,e){if(!t||t==="none")return cs(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=el,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=tl,i=a}if(!i)return cs(e);const o=s[e],r=i[1].split(",").map(sl);return typeof o=="function"?o(r):r[o]}const nl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return ls(n,e)};function sl(t){return parseFloat(t.trim())}const Ve=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Re=new Set(Ve),ki=t=>t===De||t===L,il=new Set(["x","y","z"]),rl=Ve.filter(t=>!il.has(t));function ol(t){const e=[];return rl.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const ce={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>ls(e,"x"),y:(t,{transform:e})=>ls(e,"y")};ce.translateX=ce.x;ce.translateY=ce.y;const le=new Set;let us=!1,ds=!1,hs=!1;function ho(){if(ds){const t=Array.from(le).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=ol(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{s.getValue(o)?.set(r)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}ds=!1,us=!1,le.forEach(t=>t.complete(hs)),le.clear()}function fo(){le.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ds=!0)})}function al(){hs=!0,fo(),ho(),hs=!1}class Ks{constructor(e,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(le.add(this),us||(us=!0,G.read(fo),G.resolveKeyframes(ho))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const o=i?.get(),r=e[e.length-1];if(o!==void 0)e[0]=o;else if(s&&n){const a=s.readValue(n,r);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=r),i&&o===void 0&&i.set(e[0])}Qc(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),le.delete(this)}cancel(){this.state==="scheduled"&&(le.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const cl=t=>t.startsWith("--");function ll(t,e,n){cl(e)?t.style.setProperty(e,n):t.style[e]=n}const ul=Ds(()=>window.ScrollTimeline!==void 0),dl={};function hl(t,e){const n=Ds(t);return()=>dl[e]??n()}const mo=hl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),$e=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,Di={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:$e([0,.65,.55,1]),circOut:$e([.55,0,1,.45]),backIn:$e([.31,.01,.66,-.59]),backOut:$e([.33,1.53,.69,.99])};function po(t,e){if(t)return typeof t=="function"?mo()?co(t,e):"ease-out":Zr(t)?$e(t):Array.isArray(t)?t.map(n=>po(n,e)||Di.easeOut):Di[t]}function fl(t,e,n,{delay:s=0,duration:i=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:c}={},u=void 0){const l={[e]:n};c&&(l.offset=c);const d=po(a,i);Array.isArray(d)&&(l.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(l,f)}function go(t){return typeof t=="function"&&"applyToOptions"in t}function ml({type:t,...e}){return go(t)&&mo()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class pl extends _s{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,Ot(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=ml(e);this.animation=fl(n,s,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const l=Us(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(l):ll(n,s,l),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return bt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=Ct(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&ul()?(this.animation.timeline=e,wt):n(this)}}const yo={anticipate:Xr,backInOut:Gr,circInOut:Yr};function gl(t){return t in yo}function yl(t){typeof t.ease=="string"&&gl(t.ease)&&(t.ease=yo[t.ease])}const Vi=10;class xl extends pl{constructor(e){yl(e),uo(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Ws({...r,autoplay:!1}),c=Ct(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-Vi).value,a.sample(c).value,Vi),a.stop()}}const Ri=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Wt.test(t)||t==="0")&&!t.startsWith("url("));function vl(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function bl(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],r=Ri(i,e),a=Ri(o,e);return ke(r===a,`You are trying to animate ${e} from "${i}" to "${o}". "${r?o:i}" is not an animatable value.`,"value-not-animatable"),!r||!a?!1:vl(t)||(n==="spring"||go(n))&&s}function fs(t){t.duration=0,t.type="keyframes"}const wl=new Set(["opacity","clipPath","filter","transform"]),Tl=Ds(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Sl(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:o,type:r}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=e.owner.getProps();return Tl()&&n&&wl.has(n)&&(n!=="transform"||!u)&&!c&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const Al=40;class Pl extends _s{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:c,motionValue:u,element:l,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=mt.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:c,motionValue:u,element:l,...d},g=l?.KeyframeResolver||Ks;this.keyframeResolver=new g(a,(x,v,A)=>this.onKeyframesResolved(x,v,f,!A),c,u,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:c,isHandoff:u,onUpdate:l}=s;this.resolvedAt=mt.now(),bl(e,o,r,a)||((Ft.instantAnimations||!c)&&l?.(Us(e,s,n)),e[0]=e[e.length-1],fs(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>Al?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&Sl(f)?new xl({...f,element:f.motionValue.owner.current}):new Ws(f);g.finished.then(()=>this.notifyFinished()).catch(wt),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),al()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const Cl=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Ml(t){const e=Cl.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const jl=4;function xo(t,e,n=1){Ot(n<=jl,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=Ml(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const r=o.trim();return Br(r)?parseFloat(r):r}return Os(i)?xo(i,e,n+1):i}function Hs(t,e){return t?.[e]??t?.default??t}const vo=new Set(["width","height","top","left","right","bottom",...Ve]),El={test:t=>t==="auto",parse:t=>t},bo=t=>e=>e.test(t),wo=[De,L,Dt,Ut,vc,xc,El],Ni=t=>wo.find(bo(t));function kl(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||zr(t):!0}const Dl=new Set(["brightness","contrast","saturate","opacity"]);function Vl(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(Fs)||[];if(!s)return t;const i=n.replace(s,"");let o=Dl.has(e)?1:0;return s!==n&&(o*=100),e+"("+o+i+")"}const Rl=/\b([a-z-]*)\(.*?\)/gu,ms={...Wt,getAnimatableNone:t=>{const e=t.match(Rl);return e?e.map(Vl).join(" "):t}},Ii={...De,transform:Math.round},Nl={rotate:Ut,rotateX:Ut,rotateY:Ut,rotateZ:Ut,scale:dn,scaleX:dn,scaleY:dn,scaleZ:dn,skew:Ut,skewX:Ut,skewY:Ut,distance:L,translateX:L,translateY:L,translateZ:L,x:L,y:L,z:L,perspective:L,transformPerspective:L,opacity:Xe,originX:Ti,originY:Ti,originZ:L},Gs={borderWidth:L,borderTopWidth:L,borderRightWidth:L,borderBottomWidth:L,borderLeftWidth:L,borderRadius:L,radius:L,borderTopLeftRadius:L,borderTopRightRadius:L,borderBottomRightRadius:L,borderBottomLeftRadius:L,width:L,maxWidth:L,height:L,maxHeight:L,top:L,right:L,bottom:L,left:L,padding:L,paddingTop:L,paddingRight:L,paddingBottom:L,paddingLeft:L,margin:L,marginTop:L,marginRight:L,marginBottom:L,marginLeft:L,backgroundPositionX:L,backgroundPositionY:L,...Nl,zIndex:Ii,fillOpacity:Xe,strokeOpacity:Xe,numOctaves:Ii},Il={...Gs,color:Z,backgroundColor:Z,outlineColor:Z,fill:Z,stroke:Z,borderColor:Z,borderTopColor:Z,borderRightColor:Z,borderBottomColor:Z,borderLeftColor:Z,filter:ms,WebkitFilter:ms},To=t=>Il[t];function So(t,e){let n=To(t);return n!==ms&&(n=Wt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Ll=new Set(["auto","none","0"]);function Ol(t,e,n){let s=0,i;for(;s<t.length&&!i;){const o=t[s];typeof o=="string"&&!Ll.has(o)&&qe(o).values.length&&(i=t[s]),s++}if(i&&n)for(const o of e)t[o]=So(n,i)}class Fl extends Ks{constructor(e,n,s,i,o){super(e,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let u=e[c];if(typeof u=="string"&&(u=u.trim(),Os(u))){const l=xo(u,n.current);l!==void 0&&(e[c]=l),c===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!vo.has(s)||e.length!==2)return;const[i,o]=e,r=Ni(i),a=Ni(o);if(r!==a)if(ki(r)&&ki(a))for(let c=0;c<e.length;c++){const u=e[c];typeof u=="string"&&(e[c]=parseFloat(u))}else ce[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||kl(e[i]))&&s.push(i);s.length&&Ol(e,s,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=ce[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,r=s[o];s[o]=ce[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,c])=>{e.getValue(a).set(c)}),this.resolveNoneKeyframes()}}function Bl(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const Ao=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Po(t){return $r(t)&&"offsetHeight"in t}const Li=30,$l=t=>!isNaN(parseFloat(t));class zl{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=mt.now();if(this.updatedAt!==i&&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(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=mt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=$l(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&Rs(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new Vs);const s=this.events[e].add(n);return e==="change"?()=>{s(),G.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=mt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Li)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Li);return Ur(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function je(t,e){return new zl(t,e)}const{schedule:Xs}=Qr(queueMicrotask,!1),At={x:!1,y:!1};function Co(){return At.x||At.y}function Ul(t){return t==="x"||t==="y"?At[t]?null:(At[t]=!0,()=>{At[t]=!1}):At.x||At.y?null:(At.x=At.y=!0,()=>{At.x=At.y=!1})}function Mo(t,e){const n=Bl(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function Oi(t){return!(t.pointerType==="touch"||Co())}function _l(t,e,n={}){const[s,i,o]=Mo(t,n),r=a=>{if(!Oi(a))return;const{target:c}=a,u=e(c,a);if(typeof u!="function"||!c)return;const l=d=>{Oi(d)&&(u(d),c.removeEventListener("pointerleave",l))};c.addEventListener("pointerleave",l,i)};return s.forEach(a=>{a.addEventListener("pointerenter",r,i)}),o}const jo=(t,e)=>e?t===e?!0:jo(t,e.parentElement):!1,qs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Wl=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Kl(t){return Wl.has(t.tagName)||t.tabIndex!==-1}const gn=new WeakSet;function Fi(t){return e=>{e.key==="Enter"&&t(e)}}function Wn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Hl=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=Fi(()=>{if(gn.has(n))return;Wn(n,"down");const i=Fi(()=>{Wn(n,"up")}),o=()=>Wn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function Bi(t){return qs(t)&&!Co()}function Gl(t,e,n={}){const[s,i,o]=Mo(t,n),r=a=>{const c=a.currentTarget;if(!Bi(a))return;gn.add(c);const u=e(c,a),l=(g,x)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),gn.has(c)&&gn.delete(c),Bi(g)&&typeof u=="function"&&u(g,{success:x})},d=g=>{l(g,c===window||c===document||n.useGlobalTarget||jo(c,g.target))},f=g=>{l(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,i),Po(a)&&(a.addEventListener("focus",u=>Hl(u,i)),!Kl(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function Eo(t){return $r(t)&&"ownerSVGElement"in t}function Xl(t){return Eo(t)&&t.tagName==="svg"}const ct=t=>!!(t&&t.getVelocity),ql=[...wo,Z,Wt],Yl=t=>ql.find(bo(t)),Ys=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function $i(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Jl(...t){return e=>{let n=!1;const s=t.map(i=>{const o=$i(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<s.length;i++){const o=s[i];typeof o=="function"?o():$i(t[i],null)}}}}function Zl(...t){return Pt.useCallback(Jl(...t),t)}class Ql extends Pt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=Po(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=i-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function tu({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),o=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Ys),c=Zl(o,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:l,top:d,left:f,right:g}=r.current;if(e||!o.current||!u||!l)return;const x=n==="left"?`left: ${f}`:`right: ${g}`;o.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const A=s??document.head;return A.appendChild(v),v.sheet&&v.sheet.insertRule(`
2
2
  [data-motion-pop-id="${i}"] {
3
3
  position: absolute !important;
4
4
  width: ${u}px !important;
@@ -6,7 +6,7 @@
6
6
  ${x}px !important;
7
7
  top: ${d}px !important;
8
8
  }
9
- `),()=>{C.contains(v)&&C.removeChild(v)}},[e]),h.jsx(nu,{isPresent:e,childRef:o,sizeRef:r,children:Tt.cloneElement(t,{ref:c})})}const iu=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:r,anchorX:a,root:c})=>{const u=Ms(ru),l=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:l,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const x of u.values())if(!x)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return o&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,x)=>u.set(x,!1))},[n]),Tt.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),r==="popLayout"&&(t=h.jsx(su,{isPresent:n,anchorX:a,root:c,children:t})),h.jsx(Mn.Provider,{value:f,children:t})};function ru(){return new Map}function Vo(t=!0){const e=m.useContext(Mn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,o=m.useId();m.useEffect(()=>{if(t)return i(o)},[t]);const r=m.useCallback(()=>t&&s&&s(o),[o,s,t]);return!n&&s?[!1,r]:[!0]}const hn=t=>t.key||"";function _i(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const ou=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:a="left",root:c})=>{const[u,l]=Vo(r),d=m.useMemo(()=>_i(t),[t]),f=r&&!u?[]:d.map(hn),g=m.useRef(!0),x=m.useRef(d),v=Ms(()=>new Map),[C,y]=m.useState(d),[w,S]=m.useState(d);$r(()=>{g.current=!1,x.current=d;for(let j=0;j<w.length;j++){const L=hn(w[j]);f.includes(L)?v.delete(L):v.get(L)!==!0&&v.set(L,!1)}},[w,f.length,f.join("-")]);const E=[];if(d!==C){let j=[...d];for(let L=0;L<w.length;L++){const V=w[L],F=hn(V);f.includes(F)||(j.splice(L,0,V),E.push(V))}return o==="wait"&&E.length&&(j=E),S(_i(j)),y(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&w.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:M}=m.useContext(Ps);return h.jsx(h.Fragment,{children:w.map(j=>{const L=hn(j),V=r&&!u?!1:d===w||f.includes(L),F=()=>{if(v.has(L))v.set(L,!0);else return;let G=!0;v.forEach(J=>{J||(G=!1)}),G&&(M?.(),S(x.current),r&&l?.(),s&&s())};return h.jsx(iu,{isPresent:V,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:o,root:c,onExitComplete:V?void 0:F,anchorX:a,children:j},L)})})},Js=m.createContext({strict:!1}),Wi={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"]},Me={};for(const t in Wi)Me[t]={isEnabled:e=>Wi[t].some(n=>!!e[n])};function ps(t){for(const e in t)Me[e]={...Me[e],...t[e]}}function au({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!Kn(e)),i=m.useRef(void 0);if(!Kn(e)){const{renderer:o,...r}=e;i.current=o,ps(r)}return m.useEffect(()=>{Kn(e)&&e().then(({renderer:o,...r})=>{ps(r),i.current=o,s(!0)})},[]),h.jsx(Js.Provider,{value:{renderer:i.current,strict:n},children:t})}function Kn(t){return typeof t=="function"}const cu=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 Cn(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||cu.has(t)}let Ro=t=>!Cn(t);function lu(t){typeof t=="function"&&(Ro=e=>e.startsWith("on")?!Cn(e):t(e))}try{lu(require("@emotion/is-prop-valid").default)}catch{}function uu(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(Ro(i)||n===!0&&Cn(i)||!e&&!Cn(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const jn=m.createContext({});function En(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Ye(t){return typeof t=="string"||Array.isArray(t)}const Zs=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Qs=["initial",...Zs];function kn(t){return En(t.animate)||Qs.some(e=>Ye(t[e]))}function No(t){return!!(kn(t)||t.variants)}function du(t,e){if(kn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Ye(n)?n:void 0,animate:Ye(s)?s:void 0}}return t.inherit!==!1?e:{}}function hu(t){const{initial:e,animate:n}=du(t,m.useContext(jn));return m.useMemo(()=>({initial:e,animate:n}),[Ki(e),Ki(n)])}function Ki(t){return Array.isArray(t)?t.join(" "):t}const Je={};function fu(t){for(const e in t)Je[e]=t[e],Ls(e)&&(Je[e].isCSSVariable=!0)}function Io(t,{layout:e,layoutId:n}){return De.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Je[t]||t==="opacity")}const mu={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},pu=ke.length;function gu(t,e,n){let s="",i=!0;for(let o=0;o<pu;o++){const r=ke[o],a=t[r];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(r.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const u=Po(a,Gs[r]);if(!c){i=!1;const l=mu[r]||r;s+=`${l}(${u}) `}n&&(e[r]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function ti(t,e,n){const{style:s,vars:i,transformOrigin:o}=t;let r=!1,a=!1;for(const c in e){const u=e[c];if(De.has(c)){r=!0;continue}else if(Ls(c)){i[c]=u;continue}else{const l=Po(u,Gs[c]);c.startsWith("origin")?(a=!0,o[c]=l):s[c]=l}}if(e.transform||(r||n?s.transform=gu(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:c="50%",originY:u="50%",originZ:l=0}=o;s.transformOrigin=`${c} ${u} ${l}`}}const ei=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Lo(t,e,n){for(const s in e)!nt(e[s])&&!Io(s,n)&&(t[s]=e[s])}function yu({transformTemplate:t},e){return m.useMemo(()=>{const n=ei();return ti(n,e,t),Object.assign({},n.vars,n.style)},[e])}function xu(t,e){const n=t.style||{},s={};return Lo(s,n,t),Object.assign(s,yu(t,e)),s}function vu(t,e){const n={},s=xu(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const bu={offset:"stroke-dashoffset",array:"stroke-dasharray"},wu={offset:"strokeDashoffset",array:"strokeDasharray"};function Tu(t,e,n=1,s=0,i=!0){t.pathLength=1;const o=i?bu:wu;t[o.offset]=R.transform(-s);const r=R.transform(e),a=R.transform(n);t[o.array]=`${r} ${a}`}function Oo(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...a},c,u,l){if(ti(t,a,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=l?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&Tu(d,i,o,r,!1)}const Fo=()=>({...ei(),attrs:{}}),Bo=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Su(t,e,n,s){const i=m.useMemo(()=>{const o=Fo();return Oo(o,e,Bo(s),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};Lo(o,t.style,t),i.style={...o,...i.style}}return i}const Au=["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 ni(t){return typeof t!="string"||t.includes("-")?!1:!!(Au.indexOf(t)>-1||/[A-Z]/u.test(t))}function Cu(t,e,n,{latestValues:s},i,o=!1){const a=(ni(t)?Su:vu)(e,s,i,t),c=uu(e,typeof t=="string",o),u=t!==m.Fragment?{...c,...a,ref:n}:{},{children:l}=e,d=m.useMemo(()=>nt(l)?l.get():l,[l]);return m.createElement(t,{...u,children:d})}function Hi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function si(t,e,n,s){if(typeof e=="function"){const[i,o]=Hi(s);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=Hi(s);e=e(n!==void 0?n:t.custom,i,o)}return e}function yn(t){return nt(t)?t.get():t}function Pu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:Mu(n,s,i,t),renderState:e()}}function Mu(t,e,n,s){const i={},o=s(t,{});for(const f in o)i[f]=yn(o[f]);let{initial:r,animate:a}=t;const c=kn(t),u=No(t);e&&u&&!c&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let l=n?n.initial===!1:!1;l=l||r===!1;const d=l?a:r;if(d&&typeof d!="boolean"&&!En(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const x=si(t,f[g]);if(x){const{transitionEnd:v,transition:C,...y}=x;for(const w in y){let S=y[w];if(Array.isArray(S)){const E=l?S.length-1:0;S=S[E]}S!==null&&(i[w]=S)}for(const w in v)i[w]=v[w]}}}return i}const $o=t=>(e,n)=>{const s=m.useContext(jn),i=m.useContext(Mn),o=()=>Pu(t,e,s,i);return n?o():Ms(o)};function ii(t,e,n){const{style:s}=t,i={};for(const o in s)(nt(s[o])||e.style&&nt(e.style[o])||Io(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}const ju=$o({scrapeMotionValuesFromProps:ii,createRenderState:ei});function zo(t,e,n){const s=ii(t,e,n);for(const i in t)if(nt(t[i])||nt(e[i])){const o=ke.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=t[i]}return s}const Eu=$o({scrapeMotionValuesFromProps:zo,createRenderState:Fo}),ku=Symbol.for("motionComponentSymbol");function be(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Du(t,e,n){return m.useCallback(s=>{s&&t.onMount&&t.onMount(s),e&&(s?e.mount(s):e.unmount()),n&&(typeof n=="function"?n(s):be(n)&&(n.current=s))},[e])}const ri=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Vu="framerAppearId",Uo="data-"+ri(Vu),_o=m.createContext({});function Ru(t,e,n,s,i){const{visualElement:o}=m.useContext(jn),r=m.useContext(Js),a=m.useContext(Mn),c=m.useContext(Ys).reducedMotion,u=m.useRef(null);s=s||r.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const l=u.current,d=m.useContext(_o);l&&!l.projection&&i&&(l.type==="html"||l.type==="svg")&&Nu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{l&&f.current&&l.update(n,a)});const g=n[Uo],x=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return $r(()=>{l&&(f.current=!0,window.MotionIsMounted=!0,l.updateFeatures(),l.scheduleRenderMicrotask(),x.current&&l.animationState&&l.animationState.animateChanges())}),m.useEffect(()=>{l&&(!x.current&&l.animationState&&l.animationState.animateChanges(),x.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),x.current=!1),l.enteringChildren=void 0)}),l}function Nu(t,e,n,s){const{layoutId:i,layout:o,drag:r,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutCrossfade:l}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Wo(t.parent)),t.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||a&&be(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:l,layoutScroll:c,layoutRoot:u})}function Wo(t){if(t)return t.options.allowProjection!==!1?t.projection:Wo(t.parent)}function xn(t,{forwardMotionProps:e=!1}={},n,s){n&&ps(n);const i=ni(t)?Eu:ju;function o(a,c){let u;const l={...m.useContext(Ys),...a,layoutId:Iu(a)},{isStatic:d}=l,f=hu(a),g=i(a,d);if(!d&&js){Lu(l,n);const x=Ou(l);u=x.MeasureLayout,f.visualElement=Ru(t,g,l,s,x.ProjectionNode)}return h.jsxs(jn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...l}):null,Cu(t,a,Du(g,f.visualElement,c),g,d,e)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const r=m.forwardRef(o);return r[ku]=t,r}function Iu({layoutId:t}){const e=m.useContext(Ps).id;return e&&t!==void 0?e+"-"+t:t}function Lu(t,e){const n=m.useContext(Js).strict;if(process.env.NODE_ENV!=="production"&&e&&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.";t.ignoreStrict?je(!1,s,"lazy-strict-mode"):It(!1,s,"lazy-strict-mode")}}function Ou(t){const{drag:e,layout:n}=Me;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Fu(t,e){if(typeof Proxy>"u")return xn;const n=new Map,s=(o,r)=>xn(o,r,t,e),i=(o,r)=>(process.env.NODE_ENV!=="production"&&Rs(!1,"motion() is deprecated. Use motion.create() instead."),s(o,r));return new Proxy(i,{get:(o,r)=>r==="create"?s:(n.has(r)||n.set(r,xn(r,void 0,t,e)),n.get(r))})}function Ko({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function Bu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function $u(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function Hn(t){return t===void 0||t===1}function gs({scale:t,scaleX:e,scaleY:n}){return!Hn(t)||!Hn(e)||!Hn(n)}function ie(t){return gs(t)||Ho(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Ho(t){return Gi(t.x)||Gi(t.y)}function Gi(t){return t&&t!=="0%"}function Pn(t,e,n){const s=t-n,i=e*s;return n+i}function Xi(t,e,n,s,i){return i!==void 0&&(t=Pn(t,i,s)),Pn(t,n,s)+e}function ys(t,e=0,n=1,s,i){t.min=Xi(t.min,e,n,s,i),t.max=Xi(t.max,e,n,s,i)}function Go(t,{x:e,y:n}){ys(t.x,e.translate,e.scale,e.originPoint),ys(t.y,n.translate,n.scale,n.originPoint)}const qi=.999999999999,Yi=1.0000000000001;function zu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,r;for(let a=0;a<i;a++){o=n[a],r=o.projectionDelta;const{visualElement:c}=o.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&Te(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,Go(t,r)),s&&ie(o.latestValues)&&Te(t,o.latestValues))}e.x<Yi&&e.x>qi&&(e.x=1),e.y<Yi&&e.y>qi&&(e.y=1)}function we(t,e){t.min=t.min+e,t.max=t.max+e}function Ji(t,e,n,s,i=.5){const o=H(t.min,t.max,i);ys(t,e,n,o,s)}function Te(t,e){Ji(t.x,e.x,e.scaleX,e.scale,e.originX),Ji(t.y,e.y,e.scaleY,e.scale,e.originY)}function Xo(t,e){return Ko($u(t.getBoundingClientRect(),e))}function Uu(t,e,n){const s=Xo(t,n),{scroll:i}=e;return i&&(we(s.x,i.offset.x),we(s.y,i.offset.y)),s}const Zi=()=>({translate:0,scale:1,origin:0,originPoint:0}),Se=()=>({x:Zi(),y:Zi()}),Qi=()=>({min:0,max:0}),X=()=>({x:Qi(),y:Qi()}),xs={current:null},qo={current:!1};function _u(){if(qo.current=!0,!!js)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>xs.current=t.matches;t.addEventListener("change",e),e()}else xs.current=!1}const Wu=new WeakMap;function Ku(t,e,n){for(const s in e){const i=e[s],o=n[s];if(nt(i))t.addValue(s,i);else if(nt(o))t.addValue(s,Pe(i,{owner:t}));else if(o!==i)if(t.hasValue(s)){const r=t.getValue(s);r.liveStyle===!0?r.jump(i):r.hasAnimated||r.set(i)}else{const r=t.getStaticValue(s);t.addValue(s,Pe(r!==void 0?r:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const tr=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Hu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Ks,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 f=ut.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,W.render(this.render,!1,!0))};const{latestValues:c,renderState:u}=r;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=kn(n),this.isVariantNode=No(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:l,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];c[f]!==void 0&&nt(g)&&g.set(c[f])}}mount(e){this.current=e,Wu.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),qo.current||_u(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:xs.current,process.env.NODE_ENV!=="production"&&Rs(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(),Wt(this.notifyUpdate),Wt(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=De.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",r=>{this.latestValues[e]=r,this.props.onUpdate&&W.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Me){const n=Me[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):X()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<tr.length;s++){const i=tr[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,r=e[o];r&&(this.propEventSubscriptions[i]=this.on(i,r))}this.prevMotionValues=Ku(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=Pe(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(zr(s)||_r(s))?s=parseFloat(s):!Ql(s)&&Kt.test(n)&&(s=Co(e,n)),this.setBaseTarget(e,nt(s)?s.get():s)),nt(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=si(this.props,n,this.presenceContext?.custom);o&&(s=o[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!nt(i)?i:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Vs),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){Xs.render(this.render)}}class Yo extends Hu{constructor(){super(...arguments),this.KeyframeResolver=zl}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;nt(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Jo(t,{style:e,vars:n},s,i){const o=t.style;let r;for(r in e)o[r]=e[r];i?.applyProjectionStyles(o,s);for(r in n)o.setProperty(r,n[r])}function Gu(t){return window.getComputedStyle(t)}class Xu extends Yo{constructor(){super(...arguments),this.type="html",this.renderInstance=Jo}readValueFromInstance(e,n){if(De.has(n))return this.projection?.isProjecting?cs(n):rl(e,n);{const s=Gu(e),i=(Ls(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Xo(e,n)}build(e,n,s){ti(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return ii(e,n,s)}}const Zo=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 qu(t,e,n,s){Jo(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Zo.has(i)?i:ri(i),e.attrs[i])}class Yu extends Yo{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=X}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(De.has(n)){const s=Ao(n);return s&&s.default||0}return n=Zo.has(n)?n:ri(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return zo(e,n,s)}build(e,n,s){Oo(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){qu(e,n,s,i)}mount(e){this.isSVGTag=Bo(e.tagName),super.mount(e)}}const Qo=(t,e)=>ni(t)?new Yu(e):new Xu(e,{allowProjection:t!==m.Fragment});function Ce(t,e,n){const s=t.getProps();return si(s,e,n!==void 0?n:s.custom,t)}const vs=t=>Array.isArray(t);function Ju(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,Pe(n))}function Zu(t){return vs(t)?t[t.length-1]||0:t}function Qu(t,e){const n=Ce(t,e);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const a=Zu(o[r]);Ju(t,r,a)}}function td(t){return!!(nt(t)&&t.add)}function bs(t,e){const n=t.getValue("willChange");if(td(n))return n.add(e);if(!n&&Lt.WillChange){const s=new Lt.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function ta(t){return t.props[Uo]}const ed=t=>t!==null;function nd(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(ed),o=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[o]}const sd={type:"spring",stiffness:500,damping:25,restSpeed:10},id=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),rd={type:"keyframes",duration:.8},od={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},ad=(t,{keyframes:e})=>e.length>2?rd:De.has(t)?t.startsWith("scale")?id(e[1]):sd:od;function cd({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:a,from:c,elapsed:u,...l}){return!!Object.keys(l).length}const oi=(t,e,n,s={},i,o)=>r=>{const a=Hs(s,t)||{},c=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-St(c);const l={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:i};cd(a)||Object.assign(l,ad(t,l)),l.duration&&(l.duration=St(l.duration)),l.repeatDelay&&(l.repeatDelay=St(l.repeatDelay)),l.from!==void 0&&(l.keyframes[0]=l.from);let d=!1;if((l.type===!1||l.duration===0&&!l.repeatDelay)&&(fs(l),l.delay===0&&(d=!0)),(Lt.instantAnimations||Lt.skipAnimations)&&(d=!0,fs(l),l.delay=0),l.allowFlatten=!a.type&&!a.ease,d&&!o&&e.get()!==void 0){const f=nd(l.keyframes,a);if(f!==void 0){W.update(()=>{l.onUpdate(f),l.onComplete()});return}}return a.isSync?new Ws(l):new jl(l)};function ld({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function ea(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:o=t.getDefaultTransition(),transitionEnd:r,...a}=e;s&&(o=s);const c=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const l in a){const d=t.getValue(l,t.latestValues[l]??null),f=a[l];if(f===void 0||u&&ld(u,l))continue;const g={delay:n,...Hs(o||{},l)},x=d.get();if(x!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===x&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const y=ta(t);if(y){const w=window.MotionHandoffAnimation(y,l,W);w!==null&&(g.startTime=w,v=!0)}}bs(t,l),d.start(oi(l,d,f,t.shouldReduceMotion&&wo.has(l)?{type:!1}:g,t,v));const C=d.animation;C&&c.push(C)}return r&&Promise.all(c).then(()=>{W.update(()=>{r&&Qu(t,r)})}),c}function na(t,e,n,s=0,i=1){const o=Array.from(t).sort((u,l)=>u.sortNodePosition(l)).indexOf(e),r=t.size,a=(r-1)*s;return typeof n=="function"?n(o,r):i===1?o*s:a-o*s}function ws(t,e,n={}){const s=Ce(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(ea(t,s,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:l,staggerDirection:d}=i;return ud(t,e,c,u,l,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,u]=a==="beforeChildren"?[o,r]:[r,o];return c().then(()=>u())}else return Promise.all([o(),r(n.delay)])}function ud(t,e,n=0,s=0,i=0,o=1,r){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(ws(c,e,{...r,delay:n+(typeof s=="function"?0:s)+na(t.variantChildren,c,s,i,o)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function dd(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(o=>ws(t,o,n));s=Promise.all(i)}else if(typeof e=="string")s=ws(t,e,n);else{const i=typeof e=="function"?Ce(t,e,n.custom):e;s=Promise.all(ea(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function sa(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}const hd=Qs.length;function ia(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?ia(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<hd;n++){const s=Qs[n],i=t.props[s];(Ye(i)||i===!1)&&(e[s]=i)}return e}const fd=[...Zs].reverse(),md=Zs.length;function pd(t){return e=>Promise.all(e.map(({animation:n,options:s})=>dd(t,n,s)))}function gd(t){let e=pd(t),n=er(),s=!0;const i=c=>(u,l)=>{const d=Ce(t,l,c==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...x}=d;u={...u,...x,...g}}return u};function o(c){e=c(t)}function r(c){const{props:u}=t,l=ia(t.parent)||{},d=[],f=new Set;let g={},x=1/0;for(let C=0;C<md;C++){const y=fd[C],w=n[y],S=u[y]!==void 0?u[y]:l[y],E=Ye(S),M=y===c?w.isActive:null;M===!1&&(x=C);let j=S===l[y]&&S!==u[y]&&E;if(j&&s&&t.manuallyAnimateOnMount&&(j=!1),w.protectedKeys={...g},!w.isActive&&M===null||!S&&!w.prevProp||En(S)||typeof S=="boolean")continue;const L=yd(w.prevProp,S);let V=L||y===c&&w.isActive&&!j&&E||C>x&&E,F=!1;const G=Array.isArray(S)?S:[S];let J=G.reduce(i(y),{});M===!1&&(J={});const{prevResolvedValues:z={}}=w,le={...z,...J},At=B=>{V=!0,f.has(B)&&(F=!0,f.delete(B)),w.needsAnimating[B]=!0;const it=t.getValue(B);it&&(it.liveStyle=!1)};for(const B in le){const it=J[B],rt=z[B];if(g.hasOwnProperty(B))continue;let ct=!1;vs(it)&&vs(rt)?ct=!sa(it,rt):ct=it!==rt,ct?it!=null?At(B):f.add(B):it!==void 0&&f.has(B)?At(B):w.protectedKeys[B]=!0}w.prevProp=S,w.prevResolvedValues=J,w.isActive&&(g={...g,...J}),s&&t.blockInitialAnimation&&(V=!1);const st=j&&L;V&&(!st||F)&&d.push(...G.map(B=>{const it={type:y};if(typeof B=="string"&&s&&!st&&t.manuallyAnimateOnMount&&t.parent){const{parent:rt}=t,ct=Ce(rt,B);if(rt.enteringChildren&&ct){const{delayChildren:ot}=ct.transition||{};it.delay=na(rt.enteringChildren,t,ot)}}return{animation:B,options:it}}))}if(f.size){const C={};if(typeof u.initial!="boolean"){const y=Ce(t,Array.isArray(u.initial)?u.initial[0]:u.initial);y&&y.transition&&(C.transition=y.transition)}f.forEach(y=>{const w=t.getBaseTarget(y),S=t.getValue(y);S&&(S.liveStyle=!0),C[y]=w??null}),d.push({animation:C})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(c,u){if(n[c].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(c,u)),n[c].isActive=u;const l=r(c);for(const d in n)n[d].protectedKeys={};return l}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=er()}}}function yd(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!sa(e,t):!1}function ne(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function er(){return{animate:ne(!0),whileInView:ne(),whileHover:ne(),whileTap:ne(),whileDrag:ne(),whileFocus:ne(),exit:ne()}}class Ht{constructor(e){this.isMounted=!1,this.node=e}update(){}}class xd extends Ht{constructor(e){super(e),e.animationState||(e.animationState=gd(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();En(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let vd=0;class bd extends Ht{constructor(){super(...arguments),this.id=vd++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const ra={animation:{Feature:xd},exit:{Feature:bd}};function Ze(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function nn(t){return{point:{x:t.pageX,y:t.pageY}}}const wd=t=>e=>qs(e)&&t(e,nn(e));function Ue(t,e,n,s){return Ze(t,e,wd(n),s)}const oa=1e-4,Td=1-oa,Sd=1+oa,aa=.01,Ad=0-aa,Cd=0+aa;function at(t){return t.max-t.min}function Pd(t,e,n){return Math.abs(t-e)<=n}function nr(t,e,n,s=.5){t.origin=s,t.originPoint=H(e.min,e.max,t.origin),t.scale=at(n)/at(e),t.translate=H(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Td&&t.scale<=Sd||isNaN(t.scale))&&(t.scale=1),(t.translate>=Ad&&t.translate<=Cd||isNaN(t.translate))&&(t.translate=0)}function _e(t,e,n,s){nr(t.x,e.x,n.x,s?s.originX:void 0),nr(t.y,e.y,n.y,s?s.originY:void 0)}function sr(t,e,n){t.min=n.min+e.min,t.max=t.min+at(e)}function Md(t,e,n){sr(t.x,e.x,n.x),sr(t.y,e.y,n.y)}function ir(t,e,n){t.min=e.min-n.min,t.max=t.min+at(e)}function We(t,e,n){ir(t.x,e.x,n.x),ir(t.y,e.y,n.y)}function yt(t){return[t("x"),t("y")]}const ca=({current:t})=>t?t.ownerDocument.defaultView:null,rr=(t,e)=>Math.abs(t-e);function jd(t,e){const n=rr(t.x,e.x),s=rr(t.y,e.y);return Math.sqrt(n**2+s**2)}class la{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:r=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 f=Xn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,x=jd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!x)return;const{point:v}=f,{timestamp:C}=Z;this.history.push({...v,timestamp:C});const{onStart:y,onMove:w}=this.handlers;g||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Gn(g,this.transformPagePoint),W.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:x,onSessionEnd:v,resumeAnimation:C}=this.handlers;if(this.dragSnapToOrigin&&C&&C(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=Xn(f.type==="pointercancel"?this.lastMoveEventInfo:Gn(g,this.transformPagePoint),this.history);this.startEvent&&x&&x(f,y),v&&v(f,y)},!qs(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=i||window;const a=nn(e),c=Gn(a,this.transformPagePoint),{point:u}=c,{timestamp:l}=Z;this.history=[{...u,timestamp:l}];const{onSessionStart:d}=n;d&&d(e,Xn(c,this.history)),this.removeListeners=Qe(Ue(this.contextWindow,"pointermove",this.handlePointerMove),Ue(this.contextWindow,"pointerup",this.handlePointerUp),Ue(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Wt(this.updatePoint)}}function Gn(t,e){return e?{point:e(t.point)}:t}function or(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Xn({point:t},e){return{point:t,delta:or(t,ua(e)),offset:or(t,Ed(e)),velocity:kd(e,.1)}}function Ed(t){return t[0]}function ua(t){return t[t.length-1]}function kd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=ua(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>St(e)));)n--;if(!s)return{x:0,y:0};const o=xt(i.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const r={x:(i.x-s.x)/o,y:(i.y-s.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function Dd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?H(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?H(n,t,s.max):Math.min(t,n)),t}function ar(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function Vd(t,{top:e,left:n,bottom:s,right:i}){return{x:ar(t.x,n,i),y:ar(t.y,e,s)}}function cr(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function Rd(t,e){return{x:cr(t.x,e.x),y:cr(t.y,e.y)}}function Nd(t,e){let n=.5;const s=at(t),i=at(e);return i>s?n=Ge(e.min,e.max-s,t.min):s>i&&(n=Ge(t.min,t.max-i,e.min)),Nt(0,1,n)}function Id(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Ts=.35;function Ld(t=Ts){return t===!1?t=0:t===!0&&(t=Ts),{x:lr(t,"left","right"),y:lr(t,"top","bottom")}}function lr(t,e,n){return{min:ur(t,e),max:ur(t,n)}}function ur(t,e){return typeof t=="number"?t:t[e]||0}const Od=new WeakMap;class Fd{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=X(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(nn(d).point)},r=(d,f)=>{const{drag:g,dragPropagation:x,onDragStart:v}=this.getProps();if(g&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Kl(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),yt(y=>{let w=this.getAxisMotionValue(y).get()||0;if(Et.test(w)){const{projection:S}=this.visualElement;if(S&&S.layout){const E=S.layout.layoutBox[y];E&&(w=at(E)*(parseFloat(w)/100))}}this.originPoint[y]=w}),v&&W.postRender(()=>v(d,f)),bs(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:x,onDirectionLock:v,onDrag:C}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:y}=f;if(x&&this.currentDirection===null){this.currentDirection=Bd(y),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),C&&C(d,f)},c=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>yt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:l}=this.getProps();this.panSession=new la(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:s,contextWindow:ca(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:r}=i;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&W.postRender(()=>a(s,i))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.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(e,n,s){const{drag:i}=this.getProps();if(!s||!fn(e,i,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(r=Dd(r,this.constraints[e],this.elastic[e])),o.set(r)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&be(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=Vd(s.layoutBox,e):this.constraints=!1,this.elastic=Ld(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&yt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Id(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!be(e))return!1;const s=e.current;It(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:i}=this.visualElement;if(!i||!i.layout)return!1;const o=Uu(s,i.root,this.visualElement.getTransformPagePoint());let r=Rd(i.layout.layoutBox,o);if(n){const a=n(Bu(r));this.hasMutatedConstraints=!!a,a&&(r=Ko(a))}return r}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=yt(l=>{if(!fn(l,n,this.currentDirection))return;let d=c&&c[l]||{};r&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,x={type:"inertia",velocity:s?e[l]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(l,x)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return bs(this.visualElement,e),s.start(oi(e,s,0,n,this.visualElement,!1))}stopAnimation(){yt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){yt(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){yt(n=>{const{drag:s}=this.getProps();if(!fn(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:a}=i.layout.layoutBox[n];o.set(e[n]-H(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!be(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};yt(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const c=a.get();i[r]=Nd({min:c,max:c},this.constraints[r])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),yt(r=>{if(!fn(r,e,null))return;const a=this.getAxisMotionValue(r),{min:c,max:u}=this.constraints[r];a.set(H(c,u,i[r]))})}addListeners(){if(!this.visualElement.current)return;Od.set(this.visualElement,this);const e=this.visualElement.current,n=Ue(e,"pointerdown",c=>{const{drag:u,dragListener:l=!0}=this.getProps();u&&l&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();be(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,o=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),W.read(s);const r=Ze(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(yt(l=>{const d=this.getAxisMotionValue(l);d&&(this.originPoint[l]+=c[l].translate,d.set(d.get()+c[l].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=Ts,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function fn(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Bd(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class $d extends Ht{constructor(e){super(e),this.removeGroupControls=vt,this.removeListeners=vt,this.controls=new Fd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||vt}unmount(){this.removeGroupControls(),this.removeListeners()}}const dr=t=>(e,n)=>{t&&W.postRender(()=>t(e,n))};class zd extends Ht{constructor(){super(...arguments),this.removePointerDownListener=vt}onPointerDown(e){this.session=new la(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:ca(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:dr(e),onStart:dr(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&W.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=Ue(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const vn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function hr(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Be={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(R.test(t))t=parseFloat(t);else return t;const n=hr(t,e.target.x),s=hr(t,e.target.y);return`${n}% ${s}%`}},Ud={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Kt.parse(t);if(i.length>5)return s;const o=Kt.createTransformer(t),r=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+r]/=a,i[1+r]/=c;const u=H(a,c,.5);return typeof i[2+r]=="number"&&(i[2+r]/=u),typeof i[3+r]=="number"&&(i[3+r]/=u),o(i)}};let qn=!1;class _d extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=e;fu(Wd),o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),qn&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),vn.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,qn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||W.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Xs.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;qn=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function da(t){const[e,n]=Vo(),s=m.useContext(Ps);return h.jsx(_d,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(_o),isPresent:e,safeToRemove:n})}const Wd={borderRadius:{...Be,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Be,borderTopRightRadius:Be,borderBottomLeftRadius:Be,borderBottomRightRadius:Be,boxShadow:Ud};function Kd(t,e,n){const s=nt(t)?t:Pe(t);return s.start(oi("",s,e,n)),s.animation}const Hd=(t,e)=>t.depth-e.depth;class Gd{constructor(){this.children=[],this.isDirty=!1}add(e){Es(this.children,e),this.isDirty=!0}remove(e){ks(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Hd),this.isDirty=!1,this.children.forEach(e)}}function Xd(t,e){const n=ut.now(),s=({timestamp:i})=>{const o=i-n;o>=e&&(Wt(s),t(o-e))};return W.setup(s,!0),()=>Wt(s)}const ha=["TopLeft","TopRight","BottomLeft","BottomRight"],qd=ha.length,fr=t=>typeof t=="string"?parseFloat(t):t,mr=t=>typeof t=="number"||R.test(t);function Yd(t,e,n,s,i,o){i?(t.opacity=H(0,n.opacity??1,Jd(s)),t.opacityExit=H(e.opacity??1,0,Zd(s))):o&&(t.opacity=H(e.opacity??1,n.opacity??1,s));for(let r=0;r<qd;r++){const a=`border${ha[r]}Radius`;let c=pr(e,a),u=pr(n,a);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||mr(c)===mr(u)?(t[a]=Math.max(H(fr(c),fr(u),s),0),(Et.test(u)||Et.test(c))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=H(e.rotate||0,n.rotate||0,s))}function pr(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Jd=fa(0,.5,Jr),Zd=fa(.5,.95,vt);function fa(t,e,n){return s=>s<t?0:s>e?1:n(Ge(t,e,s))}function gr(t,e){t.min=e.min,t.max=e.max}function gt(t,e){gr(t.x,e.x),gr(t.y,e.y)}function yr(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function xr(t,e,n,s,i){return t-=e,t=Pn(t,1/n,s),i!==void 0&&(t=Pn(t,1/i,s)),t}function Qd(t,e=0,n=1,s=.5,i,o=t,r=t){if(Et.test(e)&&(e=parseFloat(e),e=H(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=H(o.min,o.max,s);t===o&&(a-=e),t.min=xr(t.min,e,n,a,i),t.max=xr(t.max,e,n,a,i)}function vr(t,e,[n,s,i],o,r){Qd(t,e[n],e[s],e[i],e.scale,o,r)}const th=["x","scaleX","originX"],eh=["y","scaleY","originY"];function br(t,e,n,s){vr(t.x,e,th,n?n.x:void 0,s?s.x:void 0),vr(t.y,e,eh,n?n.y:void 0,s?s.y:void 0)}function wr(t){return t.translate===0&&t.scale===1}function ma(t){return wr(t.x)&&wr(t.y)}function Tr(t,e){return t.min===e.min&&t.max===e.max}function nh(t,e){return Tr(t.x,e.x)&&Tr(t.y,e.y)}function Sr(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function pa(t,e){return Sr(t.x,e.x)&&Sr(t.y,e.y)}function Ar(t){return at(t.x)/at(t.y)}function Cr(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class sh{constructor(){this.members=[]}add(e){Es(this.members,e),e.scheduleRender()}remove(e){if(ks(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function ih(t,e,n){let s="";const i=t.x.translate/e.x,o=t.y.translate/e.y,r=n?.z||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:l,rotateX:d,rotateY:f,skewX:g,skewY:x}=n;u&&(s=`perspective(${u}px) ${s}`),l&&(s+=`rotate(${l}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),x&&(s+=`skewY(${x}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(s+=`scale(${a}, ${c})`),s||"none"}const Yn=["","X","Y","Z"],rh=1e3;let oh=0;function Jn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function ga(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=ta(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",W,!(i||o))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&ga(s)}function ya({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},a=e?.()){this.id=oh++,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(lh),this.nodes.forEach(fh),this.nodes.forEach(mh),this.nodes.forEach(uh)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,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 c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new Gd)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new Vs),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const c=this.eventHandlers.get(r);c&&c.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=Do(r)&&!Jl(r),this.instance=r;const{layoutId:a,layout:c,visualElement:u}=this.options;if(u&&!u.current&&u.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let l,d=0;const f=()=>this.root.updateBlockedByResize=!1;W.read(()=>{d=window.innerWidth}),t(r,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,l&&l(),l=Xd(f,250),vn.hasAnimatedSinceResize&&(vn.hasAnimatedSinceResize=!1,this.nodes.forEach(jr)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||c)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||u.getDefaultTransition()||vh,{onLayoutAnimationStart:v,onLayoutAnimationComplete:C}=u.getProps(),y=!this.targetLayout||!pa(this.targetLayout,g),w=!d&&f;if(this.options.layoutRoot||this.resumeFrom||w||d&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...Hs(x,"layout"),onPlay:v,onComplete:C};(u.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(l,w)}else d||jr(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Wt(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(ph),this.animationId++)}getTransformTemplate(){const{visualElement:r}=this.options;return r&&r.getProps().transformTemplate}willUpdate(r=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&ga(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let l=0;l<this.path.length;l++){const d=this.path[l];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Pr);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Mr);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(hh),this.nodes.forEach(ah),this.nodes.forEach(ch)):this.nodes.forEach(Mr),this.clearAllSnapshots();const a=ut.now();Z.delta=Nt(0,1e3/60,a-Z.timestamp),Z.timestamp=a,Z.isProcessing=!0,Bn.update.process(Z),Bn.preRender.process(Z),Bn.render.process(Z),Z.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Xs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(dh),this.sharedNodes.forEach(gh)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,W.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){W.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!at(this.snapshot.measuredBox.x)&&!at(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 c=0;c<this.path.length;c++)this.path[c].updateScroll();const r=this.layout;this.layout=this.measure(!1),this.layoutCorrected=X(),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,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&this.instance){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:r,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const r=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!ma(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,l=u!==this.prevTransformTemplateValue;r&&this.instance&&(a||ie(this.latestValues)||l)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return r&&(c=this.removeTransform(c)),bh(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:r}=this.options;if(!r)return X();const a=r.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(wh))){const{scroll:u}=this.root;u&&(we(a.x,u.offset.x),we(a.y,u.offset.y))}return a}removeElementScroll(r){const a=X();if(gt(a,r),this.scroll?.wasRoot)return a;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:l,options:d}=u;u!==this.root&&l&&d.layoutScroll&&(l.wasRoot&&gt(a,r),we(a.x,l.offset.x),we(a.y,l.offset.y))}return a}applyTransform(r,a=!1){const c=X();gt(c,r);for(let u=0;u<this.path.length;u++){const l=this.path[u];!a&&l.options.layoutScroll&&l.scroll&&l!==l.root&&Te(c,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),ie(l.latestValues)&&Te(c,l.latestValues)}return ie(this.latestValues)&&Te(c,this.latestValues),c}removeTransform(r){const a=X();gt(a,r);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!ie(u.latestValues))continue;gs(u.latestValues)&&u.updateSnapshot();const l=X(),d=u.measurePageBox();gt(l,d),br(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,l)}return ie(this.latestValues)&&br(a,this.latestValues),a}setTargetDelta(r){this.targetDelta=r,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(r){this.options={...this.options,...r,crossfade:r.crossfade!==void 0?r.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!==Z.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(r||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:l,layoutId:d}=this.options;if(!(!this.layout||!(l||d))){if(this.resolvedRelativeTargetAt=Z.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=X(),this.relativeTargetOrigin=X(),We(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),gt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=X(),this.targetWithTransforms=X()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Md(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):gt(this.target,this.layout.layoutBox),Go(this.target,this.targetDelta)):gt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=X(),this.relativeTargetOrigin=X(),We(this.relativeTargetOrigin,this.target,f.target),gt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||gs(this.parent.latestValues)||Ho(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 r=this.getLead(),a=!!this.resumingFrom||this!==r;let c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===Z.timestamp&&(c=!1),c)return;const{layout:u,layoutId:l}=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||l))return;gt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;zu(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=X());const{target:g}=r;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(yr(this.prevProjectionDelta.x,this.projectionDelta.x),yr(this.prevProjectionDelta.y,this.projectionDelta.y)),_e(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Cr(this.projectionDelta.x,this.prevProjectionDelta.x)||!Cr(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){if(this.options.visualElement?.scheduleRender(),r){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Se(),this.projectionDelta=Se(),this.projectionDeltaWithTransform=Se()}setAnimationOrigin(r,a=!1){const c=this.snapshot,u=c?c.latestValues:{},l={...this.latestValues},d=Se();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=X(),g=c?c.source:void 0,x=this.layout?this.layout.source:void 0,v=g!==x,C=this.getStack(),y=!C||C.members.length<=1,w=!!(v&&!y&&this.options.crossfade===!0&&!this.path.some(xh));this.animationProgress=0;let S;this.mixTargetDelta=E=>{const M=E/1e3;Er(d.x,r.x,M),Er(d.y,r.y,M),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(We(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),yh(this.relativeTarget,this.relativeTargetOrigin,f,M),S&&nh(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=X()),gt(S,this.relativeTarget)),v&&(this.animationValues=l,Yd(l,u,this.latestValues,M,w,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=M},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Wt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=W.update(()=>{vn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Pe(0)),this.currentAnimation=Kd(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),r.onUpdate&&r.onUpdate(a)},onStop:()=>{},onComplete:()=>{r.onComplete&&r.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 r=this.getStack();r&&r.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(rh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:c,layout:u,latestValues:l}=r;if(!(!a||!c||!u)){if(this!==r&&this.layout&&u&&xa(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||X();const d=at(this.layout.layoutBox.x);c.x.min=r.target.x.min,c.x.max=c.x.min+d;const f=at(this.layout.layoutBox.y);c.y.min=r.target.y.min,c.y.max=c.y.min+f}gt(a,c),Te(a,l),_e(this.projectionDeltaWithTransform,this.layoutCorrected,a,l)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new sh),this.sharedNodes.get(r).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 r=this.getStack();return r?r.lead===this:!0}getLead(){const{layoutId:r}=this.options;return r?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:r}=this.options;return r?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:c}=r;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const u={};c.z&&Jn("z",r,u,this.animationValues);for(let l=0;l<Yn.length;l++)Jn(`rotate${Yn[l]}`,r,u,this.animationValues),Jn(`skew${Yn[l]}`,r,u,this.animationValues);r.render();for(const l in u)r.setStaticValue(l,u[l]),this.animationValues&&(this.animationValues[l]=u[l]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=yn(a?.pointerEvents)||"",r.transform=c?c(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=yn(a?.pointerEvents)||""),this.hasProjected&&!ie(this.latestValues)&&(r.transform=c?c({},""):"none",this.hasProjected=!1);return}r.visibility="";const l=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=ih(this.projectionDeltaWithTransform,this.treeScale,l);c&&(d=c(l,d)),r.transform=d;const{x:f,y:g}=this.projectionDelta;r.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?r.opacity=u===this?l.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:l.opacityExit:r.opacity=u===this?l.opacity!==void 0?l.opacity:"":l.opacityExit!==void 0?l.opacityExit:0;for(const x in Je){if(l[x]===void 0)continue;const{correct:v,applyTo:C,isCSSVariable:y}=Je[x],w=d==="none"?l[x]:v(l[x],u);if(C){const S=C.length;for(let E=0;E<S;E++)r[C[E]]=w}else y?this.options.visualElement.renderState.vars[x]=w:r[x]=w}this.options.layoutId&&(r.pointerEvents=u===this?yn(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>r.currentAnimation?.stop()),this.root.nodes.forEach(Pr),this.root.sharedNodes.clear()}}}function ah(t){t.updateLayout()}function ch(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?yt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=at(d);d.min=n[l].min,d.max=d.min+f}):xa(i,e.layoutBox,n)&&yt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=at(n[l]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[l].max=t.relativeTarget[l].min+f)});const r=Se();_e(r,n,e.layoutBox);const a=Se();o?_e(a,t.applyTransform(s,!0),e.measuredBox):_e(a,n,e.layoutBox);const c=!ma(r);let u=!1;if(!t.resumeFrom){const l=t.getClosestProjectingParent();if(l&&!l.resumeFrom){const{snapshot:d,layout:f}=l;if(d&&f){const g=X();We(g,e.layoutBox,d.layoutBox);const x=X();We(x,n,f.layoutBox),pa(g,x)||(u=!0),l.options.layoutRoot&&(t.relativeTarget=x,t.relativeTargetOrigin=g,t.relativeParent=l)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function lh(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function uh(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function dh(t){t.clearSnapshot()}function Pr(t){t.clearMeasurements()}function Mr(t){t.isLayoutDirty=!1}function hh(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function jr(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function fh(t){t.resolveTargetDelta()}function mh(t){t.calcProjection()}function ph(t){t.resetSkewAndRotation()}function gh(t){t.removeLeadSnapshot()}function Er(t,e,n){t.translate=H(e.translate,0,n),t.scale=H(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function kr(t,e,n,s){t.min=H(e.min,n.min,s),t.max=H(e.max,n.max,s)}function yh(t,e,n,s){kr(t.x,e.x,n.x,s),kr(t.y,e.y,n.y,s)}function xh(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const vh={duration:.45,ease:[.4,0,.1,1]},Dr=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Vr=Dr("applewebkit/")&&!Dr("chrome/")?Math.round:vt;function Rr(t){t.min=Vr(t.min),t.max=Vr(t.max)}function bh(t){Rr(t.x),Rr(t.y)}function xa(t,e,n){return t==="position"||t==="preserve-aspect"&&!Pd(Ar(e),Ar(n),.2)}function wh(t){return t!==t.root&&t.scroll?.wasRoot}const Th=ya({attachResizeListener:(t,e)=>Ze(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Zn={current:void 0},va=ya({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Zn.current){const t=new Th({});t.mount(window),t.setOptions({layoutScroll:!0}),Zn.current=t}return Zn.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Sh={pan:{Feature:zd},drag:{Feature:$d,ProjectionNode:va,MeasureLayout:da}};function Nr(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&W.postRender(()=>o(e,nn(e)))}class Ah extends Ht{mount(){const{current:e}=this.node;e&&(this.unmount=Hl(e,(n,s)=>(Nr(this.node,s,"Start"),i=>Nr(this.node,i,"End"))))}unmount(){}}class Ch extends Ht{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!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=Qe(Ze(this.node.current,"focus",()=>this.onFocus()),Ze(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Ir(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&W.postRender(()=>o(e,nn(e)))}class Ph extends Ht{mount(){const{current:e}=this.node;e&&(this.unmount=Yl(e,(n,s)=>(Ir(this.node,s,"Start"),(i,{success:o})=>Ir(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Ss=new WeakMap,Qn=new WeakMap,Mh=t=>{const e=Ss.get(t.target);e&&e(t)},jh=t=>{t.forEach(Mh)};function Eh({root:t,...e}){const n=t||document;Qn.has(n)||Qn.set(n,{});const s=Qn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(jh,{root:t,...e})),s[i]}function kh(t,e,n){const s=Eh(e);return Ss.set(t,n),s.observe(t),()=>{Ss.delete(t),s.unobserve(t)}}const Dh={some:0,all:1};class Vh extends Ht{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Dh[i]},a=c=>{const{isIntersecting:u}=c;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:l,onViewportLeave:d}=this.node.getProps(),f=u?l:d;f&&f(c)};return kh(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(Rh(e,n))&&this.startObserver()}unmount(){}}function Rh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const ba={inView:{Feature:Vh},tap:{Feature:Ph},focus:{Feature:Ch},hover:{Feature:Ah}},Nh={layout:{ProjectionNode:va,MeasureLayout:da}},Ih={...ra,...ba,...Sh,...Nh},Lh=Fu(Ih,Qo),Oh={renderer:Qo,...ra,...ba};function wa(t,e){return xn(t,e)}const mn=wa("div"),Fh=wa("p"),jt=Symbol.for("@arcteninc/core:originalName");function Bh(t,e){return t[jt]=e,t}function $h(t,e,n,s){if(typeof t!="function")return null;const i=t[jt];if(i){const a=e[i];if(a&&!n.has(a.name))return{fn:t,meta:a}}const o=t.name;let r;if(o&&(r=e[o],r&&!n.has(r.name)))return t[jt]=r.name,{fn:t,meta:r};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(r=e[a],r))return t[jt]=r.name,{fn:t,meta:r}}else if(r=Object.values(e).find(c=>!n.has(c.name)),r)return t[jt]=r.name,{fn:t,meta:r};return null}function Ta(t,e){let n,s;if(!e)throw new Error(`❌ toolMetadata is required!
9
+ `),()=>{A.contains(v)&&A.removeChild(v)}},[e]),h.jsx(Ql,{isPresent:e,childRef:o,sizeRef:r,children:Pt.cloneElement(t,{ref:c})})}const eu=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:r,anchorX:a,root:c})=>{const u=Ms(nu),l=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:l,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const x of u.values())if(!x)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return o&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,x)=>u.set(x,!1))},[n]),Pt.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),r==="popLayout"&&(t=h.jsx(tu,{isPresent:n,anchorX:a,root:c,children:t})),h.jsx(Mn.Provider,{value:f,children:t})};function nu(){return new Map}function ko(t=!0){const e=m.useContext(Mn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,o=m.useId();m.useEffect(()=>{if(t)return i(o)},[t]);const r=m.useCallback(()=>t&&s&&s(o),[o,s,t]);return!n&&s?[!1,r]:[!0]}const hn=t=>t.key||"";function zi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const su=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:a="left",root:c})=>{const[u,l]=ko(r),d=m.useMemo(()=>zi(t),[t]),f=r&&!u?[]:d.map(hn),g=m.useRef(!0),x=m.useRef(d),v=Ms(()=>new Map),[A,y]=m.useState(d),[w,S]=m.useState(d);Fr(()=>{g.current=!1,x.current=d;for(let E=0;E<w.length;E++){const O=hn(w[E]);f.includes(O)?v.delete(O):v.get(O)!==!0&&v.set(O,!1)}},[w,f.length,f.join("-")]);const D=[];if(d!==A){let E=[...d];for(let O=0;O<w.length;O++){const R=w[O],B=hn(R);f.includes(B)||(E.splice(O,0,R),D.push(R))}return o==="wait"&&D.length&&(E=D),S(zi(E)),y(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&w.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:j}=m.useContext(Cs);return h.jsx(h.Fragment,{children:w.map(E=>{const O=hn(E),R=r&&!u?!1:d===w||f.includes(O),B=()=>{if(v.has(O))v.set(O,!0);else return;let Y=!0;v.forEach(tt=>{tt||(Y=!1)}),Y&&(j?.(),S(x.current),r&&l?.(),s&&s())};return h.jsx(eu,{isPresent:R,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:o,root:c,onExitComplete:R?void 0:B,anchorX:a,children:E},O)})})},Js=m.createContext({strict:!1}),Ui={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"]},Ee={};for(const t in Ui)Ee[t]={isEnabled:e=>Ui[t].some(n=>!!e[n])};function ps(t){for(const e in t)Ee[e]={...Ee[e],...t[e]}}function iu({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!Kn(e)),i=m.useRef(void 0);if(!Kn(e)){const{renderer:o,...r}=e;i.current=o,ps(r)}return m.useEffect(()=>{Kn(e)&&e().then(({renderer:o,...r})=>{ps(r),i.current=o,s(!0)})},[]),h.jsx(Js.Provider,{value:{renderer:i.current,strict:n},children:t})}function Kn(t){return typeof t=="function"}const ru=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 Pn(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||ru.has(t)}let Do=t=>!Pn(t);function ou(t){typeof t=="function"&&(Do=e=>e.startsWith("on")?!Pn(e):t(e))}try{ou(require("@emotion/is-prop-valid").default)}catch{}function au(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(Do(i)||n===!0&&Pn(i)||!e&&!Pn(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const jn=m.createContext({});function En(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Ye(t){return typeof t=="string"||Array.isArray(t)}const Zs=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Qs=["initial",...Zs];function kn(t){return En(t.animate)||Qs.some(e=>Ye(t[e]))}function Vo(t){return!!(kn(t)||t.variants)}function cu(t,e){if(kn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Ye(n)?n:void 0,animate:Ye(s)?s:void 0}}return t.inherit!==!1?e:{}}function lu(t){const{initial:e,animate:n}=cu(t,m.useContext(jn));return m.useMemo(()=>({initial:e,animate:n}),[_i(e),_i(n)])}function _i(t){return Array.isArray(t)?t.join(" "):t}const Je={};function uu(t){for(const e in t)Je[e]=t[e],Ls(e)&&(Je[e].isCSSVariable=!0)}function Ro(t,{layout:e,layoutId:n}){return Re.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Je[t]||t==="opacity")}const du={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},hu=Ve.length;function fu(t,e,n){let s="",i=!0;for(let o=0;o<hu;o++){const r=Ve[o],a=t[r];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(r.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const u=Ao(a,Gs[r]);if(!c){i=!1;const l=du[r]||r;s+=`${l}(${u}) `}n&&(e[r]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function ti(t,e,n){const{style:s,vars:i,transformOrigin:o}=t;let r=!1,a=!1;for(const c in e){const u=e[c];if(Re.has(c)){r=!0;continue}else if(Ls(c)){i[c]=u;continue}else{const l=Ao(u,Gs[c]);c.startsWith("origin")?(a=!0,o[c]=l):s[c]=l}}if(e.transform||(r||n?s.transform=fu(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:c="50%",originY:u="50%",originZ:l=0}=o;s.transformOrigin=`${c} ${u} ${l}`}}const ei=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function No(t,e,n){for(const s in e)!ct(e[s])&&!Ro(s,n)&&(t[s]=e[s])}function mu({transformTemplate:t},e){return m.useMemo(()=>{const n=ei();return ti(n,e,t),Object.assign({},n.vars,n.style)},[e])}function pu(t,e){const n=t.style||{},s={};return No(s,n,t),Object.assign(s,mu(t,e)),s}function gu(t,e){const n={},s=pu(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const yu={offset:"stroke-dashoffset",array:"stroke-dasharray"},xu={offset:"strokeDashoffset",array:"strokeDasharray"};function vu(t,e,n=1,s=0,i=!0){t.pathLength=1;const o=i?yu:xu;t[o.offset]=L.transform(-s);const r=L.transform(e),a=L.transform(n);t[o.array]=`${r} ${a}`}function Io(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...a},c,u,l){if(ti(t,a,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=l?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&vu(d,i,o,r,!1)}const Lo=()=>({...ei(),attrs:{}}),Oo=t=>typeof t=="string"&&t.toLowerCase()==="svg";function bu(t,e,n,s){const i=m.useMemo(()=>{const o=Lo();return Io(o,e,Oo(s),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};No(o,t.style,t),i.style={...o,...i.style}}return i}const wu=["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 ni(t){return typeof t!="string"||t.includes("-")?!1:!!(wu.indexOf(t)>-1||/[A-Z]/u.test(t))}function Tu(t,e,n,{latestValues:s},i,o=!1){const a=(ni(t)?bu:gu)(e,s,i,t),c=au(e,typeof t=="string",o),u=t!==m.Fragment?{...c,...a,ref:n}:{},{children:l}=e,d=m.useMemo(()=>ct(l)?l.get():l,[l]);return m.createElement(t,{...u,children:d})}function Wi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function si(t,e,n,s){if(typeof e=="function"){const[i,o]=Wi(s);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=Wi(s);e=e(n!==void 0?n:t.custom,i,o)}return e}function yn(t){return ct(t)?t.get():t}function Su({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:Au(n,s,i,t),renderState:e()}}function Au(t,e,n,s){const i={},o=s(t,{});for(const f in o)i[f]=yn(o[f]);let{initial:r,animate:a}=t;const c=kn(t),u=Vo(t);e&&u&&!c&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let l=n?n.initial===!1:!1;l=l||r===!1;const d=l?a:r;if(d&&typeof d!="boolean"&&!En(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const x=si(t,f[g]);if(x){const{transitionEnd:v,transition:A,...y}=x;for(const w in y){let S=y[w];if(Array.isArray(S)){const D=l?S.length-1:0;S=S[D]}S!==null&&(i[w]=S)}for(const w in v)i[w]=v[w]}}}return i}const Fo=t=>(e,n)=>{const s=m.useContext(jn),i=m.useContext(Mn),o=()=>Su(t,e,s,i);return n?o():Ms(o)};function ii(t,e,n){const{style:s}=t,i={};for(const o in s)(ct(s[o])||e.style&&ct(e.style[o])||Ro(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}const Pu=Fo({scrapeMotionValuesFromProps:ii,createRenderState:ei});function Bo(t,e,n){const s=ii(t,e,n);for(const i in t)if(ct(t[i])||ct(e[i])){const o=Ve.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=t[i]}return s}const Cu=Fo({scrapeMotionValuesFromProps:Bo,createRenderState:Lo}),Mu=Symbol.for("motionComponentSymbol");function Te(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function ju(t,e,n){return m.useCallback(s=>{s&&t.onMount&&t.onMount(s),e&&(s?e.mount(s):e.unmount()),n&&(typeof n=="function"?n(s):Te(n)&&(n.current=s))},[e])}const ri=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),Eu="framerAppearId",$o="data-"+ri(Eu),zo=m.createContext({});function ku(t,e,n,s,i){const{visualElement:o}=m.useContext(jn),r=m.useContext(Js),a=m.useContext(Mn),c=m.useContext(Ys).reducedMotion,u=m.useRef(null);s=s||r.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const l=u.current,d=m.useContext(zo);l&&!l.projection&&i&&(l.type==="html"||l.type==="svg")&&Du(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{l&&f.current&&l.update(n,a)});const g=n[$o],x=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return Fr(()=>{l&&(f.current=!0,window.MotionIsMounted=!0,l.updateFeatures(),l.scheduleRenderMicrotask(),x.current&&l.animationState&&l.animationState.animateChanges())}),m.useEffect(()=>{l&&(!x.current&&l.animationState&&l.animationState.animateChanges(),x.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),x.current=!1),l.enteringChildren=void 0)}),l}function Du(t,e,n,s){const{layoutId:i,layout:o,drag:r,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutCrossfade:l}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Uo(t.parent)),t.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||a&&Te(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:l,layoutScroll:c,layoutRoot:u})}function Uo(t){if(t)return t.options.allowProjection!==!1?t.projection:Uo(t.parent)}function xn(t,{forwardMotionProps:e=!1}={},n,s){n&&ps(n);const i=ni(t)?Cu:Pu;function o(a,c){let u;const l={...m.useContext(Ys),...a,layoutId:Vu(a)},{isStatic:d}=l,f=lu(a),g=i(a,d);if(!d&&js){Ru(l,n);const x=Nu(l);u=x.MeasureLayout,f.visualElement=ku(t,g,l,s,x.ProjectionNode)}return h.jsxs(jn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...l}):null,Tu(t,a,ju(g,f.visualElement,c),g,d,e)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const r=m.forwardRef(o);return r[Mu]=t,r}function Vu({layoutId:t}){const e=m.useContext(Cs).id;return e&&t!==void 0?e+"-"+t:t}function Ru(t,e){const n=m.useContext(Js).strict;if(process.env.NODE_ENV!=="production"&&e&&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.";t.ignoreStrict?ke(!1,s,"lazy-strict-mode"):Ot(!1,s,"lazy-strict-mode")}}function Nu(t){const{drag:e,layout:n}=Ee;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Iu(t,e){if(typeof Proxy>"u")return xn;const n=new Map,s=(o,r)=>xn(o,r,t,e),i=(o,r)=>(process.env.NODE_ENV!=="production"&&Rs(!1,"motion() is deprecated. Use motion.create() instead."),s(o,r));return new Proxy(i,{get:(o,r)=>r==="create"?s:(n.has(r)||n.set(r,xn(r,void 0,t,e)),n.get(r))})}function _o({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function Lu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function Ou(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function Hn(t){return t===void 0||t===1}function gs({scale:t,scaleX:e,scaleY:n}){return!Hn(t)||!Hn(e)||!Hn(n)}function re(t){return gs(t)||Wo(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Wo(t){return Ki(t.x)||Ki(t.y)}function Ki(t){return t&&t!=="0%"}function Cn(t,e,n){const s=t-n,i=e*s;return n+i}function Hi(t,e,n,s,i){return i!==void 0&&(t=Cn(t,i,s)),Cn(t,n,s)+e}function ys(t,e=0,n=1,s,i){t.min=Hi(t.min,e,n,s,i),t.max=Hi(t.max,e,n,s,i)}function Ko(t,{x:e,y:n}){ys(t.x,e.translate,e.scale,e.originPoint),ys(t.y,n.translate,n.scale,n.originPoint)}const Gi=.999999999999,Xi=1.0000000000001;function Fu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,r;for(let a=0;a<i;a++){o=n[a],r=o.projectionDelta;const{visualElement:c}=o.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&Ae(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,Ko(t,r)),s&&re(o.latestValues)&&Ae(t,o.latestValues))}e.x<Xi&&e.x>Gi&&(e.x=1),e.y<Xi&&e.y>Gi&&(e.y=1)}function Se(t,e){t.min=t.min+e,t.max=t.max+e}function qi(t,e,n,s,i=.5){const o=q(t.min,t.max,i);ys(t,e,n,o,s)}function Ae(t,e){qi(t.x,e.x,e.scaleX,e.scale,e.originX),qi(t.y,e.y,e.scaleY,e.scale,e.originY)}function Ho(t,e){return _o(Ou(t.getBoundingClientRect(),e))}function Bu(t,e,n){const s=Ho(t,n),{scroll:i}=e;return i&&(Se(s.x,i.offset.x),Se(s.y,i.offset.y)),s}const Yi=()=>({translate:0,scale:1,origin:0,originPoint:0}),Pe=()=>({x:Yi(),y:Yi()}),Ji=()=>({min:0,max:0}),J=()=>({x:Ji(),y:Ji()}),xs={current:null},Go={current:!1};function $u(){if(Go.current=!0,!!js)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>xs.current=t.matches;t.addEventListener("change",e),e()}else xs.current=!1}const zu=new WeakMap;function Uu(t,e,n){for(const s in e){const i=e[s],o=n[s];if(ct(i))t.addValue(s,i);else if(ct(o))t.addValue(s,je(i,{owner:t}));else if(o!==i)if(t.hasValue(s)){const r=t.getValue(s);r.liveStyle===!0?r.jump(i):r.hasAnimated||r.set(i)}else{const r=t.getStaticValue(s);t.addValue(s,je(r!==void 0?r:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Zi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class _u{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Ks,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 f=mt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,G.render(this.render,!1,!0))};const{latestValues:c,renderState:u}=r;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=kn(n),this.isVariantNode=Vo(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:l,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];c[f]!==void 0&&ct(g)&&g.set(c[f])}}mount(e){this.current=e,zu.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Go.current||$u(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:xs.current,process.env.NODE_ENV!=="production"&&Rs(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(),_t(this.notifyUpdate),_t(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=Re.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",r=>{this.latestValues[e]=r,this.props.onUpdate&&G.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Ee){const n=Ee[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):J()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Zi.length;s++){const i=Zi[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,r=e[o];r&&(this.propEventSubscriptions[i]=this.on(i,r))}this.prevMotionValues=Uu(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=je(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(Br(s)||zr(s))?s=parseFloat(s):!Yl(s)&&Wt.test(n)&&(s=So(e,n)),this.setBaseTarget(e,ct(s)?s.get():s)),ct(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=si(this.props,n,this.presenceContext?.custom);o&&(s=o[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!ct(i)?i:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new Vs),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){Xs.render(this.render)}}class Xo extends _u{constructor(){super(...arguments),this.KeyframeResolver=Fl}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;ct(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function qo(t,{style:e,vars:n},s,i){const o=t.style;let r;for(r in e)o[r]=e[r];i?.applyProjectionStyles(o,s);for(r in n)o.setProperty(r,n[r])}function Wu(t){return window.getComputedStyle(t)}class Ku extends Xo{constructor(){super(...arguments),this.type="html",this.renderInstance=qo}readValueFromInstance(e,n){if(Re.has(n))return this.projection?.isProjecting?cs(n):nl(e,n);{const s=Wu(e),i=(Ls(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Ho(e,n)}build(e,n,s){ti(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return ii(e,n,s)}}const Yo=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 Hu(t,e,n,s){qo(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Yo.has(i)?i:ri(i),e.attrs[i])}class Gu extends Xo{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=J}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Re.has(n)){const s=To(n);return s&&s.default||0}return n=Yo.has(n)?n:ri(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return Bo(e,n,s)}build(e,n,s){Io(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Hu(e,n,s,i)}mount(e){this.isSVGTag=Oo(e.tagName),super.mount(e)}}const Jo=(t,e)=>ni(t)?new Gu(e):new Ku(e,{allowProjection:t!==m.Fragment});function Me(t,e,n){const s=t.getProps();return si(s,e,n!==void 0?n:s.custom,t)}const vs=t=>Array.isArray(t);function Xu(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,je(n))}function qu(t){return vs(t)?t[t.length-1]||0:t}function Yu(t,e){const n=Me(t,e);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const a=qu(o[r]);Xu(t,r,a)}}function Ju(t){return!!(ct(t)&&t.add)}function bs(t,e){const n=t.getValue("willChange");if(Ju(n))return n.add(e);if(!n&&Ft.WillChange){const s=new Ft.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Zo(t){return t.props[$o]}const Zu=t=>t!==null;function Qu(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Zu),o=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[o]}const td={type:"spring",stiffness:500,damping:25,restSpeed:10},ed=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),nd={type:"keyframes",duration:.8},sd={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},id=(t,{keyframes:e})=>e.length>2?nd:Re.has(t)?t.startsWith("scale")?ed(e[1]):td:sd;function rd({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:a,from:c,elapsed:u,...l}){return!!Object.keys(l).length}const oi=(t,e,n,s={},i,o)=>r=>{const a=Hs(s,t)||{},c=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-Ct(c);const l={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:i};rd(a)||Object.assign(l,id(t,l)),l.duration&&(l.duration=Ct(l.duration)),l.repeatDelay&&(l.repeatDelay=Ct(l.repeatDelay)),l.from!==void 0&&(l.keyframes[0]=l.from);let d=!1;if((l.type===!1||l.duration===0&&!l.repeatDelay)&&(fs(l),l.delay===0&&(d=!0)),(Ft.instantAnimations||Ft.skipAnimations)&&(d=!0,fs(l),l.delay=0),l.allowFlatten=!a.type&&!a.ease,d&&!o&&e.get()!==void 0){const f=Qu(l.keyframes,a);if(f!==void 0){G.update(()=>{l.onUpdate(f),l.onComplete()});return}}return a.isSync?new Ws(l):new Pl(l)};function od({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Qo(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:o=t.getDefaultTransition(),transitionEnd:r,...a}=e;s&&(o=s);const c=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const l in a){const d=t.getValue(l,t.latestValues[l]??null),f=a[l];if(f===void 0||u&&od(u,l))continue;const g={delay:n,...Hs(o||{},l)},x=d.get();if(x!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===x&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const y=Zo(t);if(y){const w=window.MotionHandoffAnimation(y,l,G);w!==null&&(g.startTime=w,v=!0)}}bs(t,l),d.start(oi(l,d,f,t.shouldReduceMotion&&vo.has(l)?{type:!1}:g,t,v));const A=d.animation;A&&c.push(A)}return r&&Promise.all(c).then(()=>{G.update(()=>{r&&Yu(t,r)})}),c}function ta(t,e,n,s=0,i=1){const o=Array.from(t).sort((u,l)=>u.sortNodePosition(l)).indexOf(e),r=t.size,a=(r-1)*s;return typeof n=="function"?n(o,r):i===1?o*s:a-o*s}function ws(t,e,n={}){const s=Me(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(Qo(t,s,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:l,staggerDirection:d}=i;return ad(t,e,c,u,l,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,u]=a==="beforeChildren"?[o,r]:[r,o];return c().then(()=>u())}else return Promise.all([o(),r(n.delay)])}function ad(t,e,n=0,s=0,i=0,o=1,r){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(ws(c,e,{...r,delay:n+(typeof s=="function"?0:s)+ta(t.variantChildren,c,s,i,o)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function cd(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(o=>ws(t,o,n));s=Promise.all(i)}else if(typeof e=="string")s=ws(t,e,n);else{const i=typeof e=="function"?Me(t,e,n.custom):e;s=Promise.all(Qo(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function ea(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}const ld=Qs.length;function na(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?na(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<ld;n++){const s=Qs[n],i=t.props[s];(Ye(i)||i===!1)&&(e[s]=i)}return e}const ud=[...Zs].reverse(),dd=Zs.length;function hd(t){return e=>Promise.all(e.map(({animation:n,options:s})=>cd(t,n,s)))}function fd(t){let e=hd(t),n=Qi(),s=!0;const i=c=>(u,l)=>{const d=Me(t,l,c==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...x}=d;u={...u,...x,...g}}return u};function o(c){e=c(t)}function r(c){const{props:u}=t,l=na(t.parent)||{},d=[],f=new Set;let g={},x=1/0;for(let A=0;A<dd;A++){const y=ud[A],w=n[y],S=u[y]!==void 0?u[y]:l[y],D=Ye(S),j=y===c?w.isActive:null;j===!1&&(x=A);let E=S===l[y]&&S!==u[y]&&D;if(E&&s&&t.manuallyAnimateOnMount&&(E=!1),w.protectedKeys={...g},!w.isActive&&j===null||!S&&!w.prevProp||En(S)||typeof S=="boolean")continue;const O=md(w.prevProp,S);let R=O||y===c&&w.isActive&&!E&&D||A>x&&D,B=!1;const Y=Array.isArray(S)?S:[S];let tt=Y.reduce(i(y),{});j===!1&&(tt={});const{prevResolvedValues:z={}}=w,ue={...z,...tt},Tt=F=>{R=!0,f.has(F)&&(B=!0,f.delete(F)),w.needsAnimating[F]=!0;const lt=t.getValue(F);lt&&(lt.liveStyle=!1)};for(const F in ue){const lt=tt[F],ut=z[F];if(g.hasOwnProperty(F))continue;let dt=!1;vs(lt)&&vs(ut)?dt=!ea(lt,ut):dt=lt!==ut,dt?lt!=null?Tt(F):f.add(F):lt!==void 0&&f.has(F)?Tt(F):w.protectedKeys[F]=!0}w.prevProp=S,w.prevResolvedValues=tt,w.isActive&&(g={...g,...tt}),s&&t.blockInitialAnimation&&(R=!1);const rt=E&&O;R&&(!rt||B)&&d.push(...Y.map(F=>{const lt={type:y};if(typeof F=="string"&&s&&!rt&&t.manuallyAnimateOnMount&&t.parent){const{parent:ut}=t,dt=Me(ut,F);if(ut.enteringChildren&&dt){const{delayChildren:ht}=dt.transition||{};lt.delay=ta(ut.enteringChildren,t,ht)}}return{animation:F,options:lt}}))}if(f.size){const A={};if(typeof u.initial!="boolean"){const y=Me(t,Array.isArray(u.initial)?u.initial[0]:u.initial);y&&y.transition&&(A.transition=y.transition)}f.forEach(y=>{const w=t.getBaseTarget(y),S=t.getValue(y);S&&(S.liveStyle=!0),A[y]=w??null}),d.push({animation:A})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(c,u){if(n[c].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(c,u)),n[c].isActive=u;const l=r(c);for(const d in n)n[d].protectedKeys={};return l}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Qi()}}}function md(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!ea(e,t):!1}function se(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Qi(){return{animate:se(!0),whileInView:se(),whileHover:se(),whileTap:se(),whileDrag:se(),whileFocus:se(),exit:se()}}class Kt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class pd extends Kt{constructor(e){super(e),e.animationState||(e.animationState=fd(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();En(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let gd=0;class yd extends Kt{constructor(){super(...arguments),this.id=gd++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const sa={animation:{Feature:pd},exit:{Feature:yd}};function Ze(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function nn(t){return{point:{x:t.pageX,y:t.pageY}}}const xd=t=>e=>qs(e)&&t(e,nn(e));function Ue(t,e,n,s){return Ze(t,e,xd(n),s)}const ia=1e-4,vd=1-ia,bd=1+ia,ra=.01,wd=0-ra,Td=0+ra;function ft(t){return t.max-t.min}function Sd(t,e,n){return Math.abs(t-e)<=n}function tr(t,e,n,s=.5){t.origin=s,t.originPoint=q(e.min,e.max,t.origin),t.scale=ft(n)/ft(e),t.translate=q(n.min,n.max,t.origin)-t.originPoint,(t.scale>=vd&&t.scale<=bd||isNaN(t.scale))&&(t.scale=1),(t.translate>=wd&&t.translate<=Td||isNaN(t.translate))&&(t.translate=0)}function _e(t,e,n,s){tr(t.x,e.x,n.x,s?s.originX:void 0),tr(t.y,e.y,n.y,s?s.originY:void 0)}function er(t,e,n){t.min=n.min+e.min,t.max=t.min+ft(e)}function Ad(t,e,n){er(t.x,e.x,n.x),er(t.y,e.y,n.y)}function nr(t,e,n){t.min=e.min-n.min,t.max=t.min+ft(e)}function We(t,e,n){nr(t.x,e.x,n.x),nr(t.y,e.y,n.y)}function vt(t){return[t("x"),t("y")]}const oa=({current:t})=>t?t.ownerDocument.defaultView:null,sr=(t,e)=>Math.abs(t-e);function Pd(t,e){const n=sr(t.x,e.x),s=sr(t.y,e.y);return Math.sqrt(n**2+s**2)}class aa{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:r=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 f=Xn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,x=Pd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!x)return;const{point:v}=f,{timestamp:A}=st;this.history.push({...v,timestamp:A});const{onStart:y,onMove:w}=this.handlers;g||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Gn(g,this.transformPagePoint),G.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:x,onSessionEnd:v,resumeAnimation:A}=this.handlers;if(this.dragSnapToOrigin&&A&&A(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=Xn(f.type==="pointercancel"?this.lastMoveEventInfo:Gn(g,this.transformPagePoint),this.history);this.startEvent&&x&&x(f,y),v&&v(f,y)},!qs(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=i||window;const a=nn(e),c=Gn(a,this.transformPagePoint),{point:u}=c,{timestamp:l}=st;this.history=[{...u,timestamp:l}];const{onSessionStart:d}=n;d&&d(e,Xn(c,this.history)),this.removeListeners=Qe(Ue(this.contextWindow,"pointermove",this.handlePointerMove),Ue(this.contextWindow,"pointerup",this.handlePointerUp),Ue(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),_t(this.updatePoint)}}function Gn(t,e){return e?{point:e(t.point)}:t}function ir(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Xn({point:t},e){return{point:t,delta:ir(t,ca(e)),offset:ir(t,Cd(e)),velocity:Md(e,.1)}}function Cd(t){return t[0]}function ca(t){return t[t.length-1]}function Md(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=ca(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>Ct(e)));)n--;if(!s)return{x:0,y:0};const o=bt(i.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const r={x:(i.x-s.x)/o,y:(i.y-s.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function jd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?q(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?q(n,t,s.max):Math.min(t,n)),t}function rr(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function Ed(t,{top:e,left:n,bottom:s,right:i}){return{x:rr(t.x,n,i),y:rr(t.y,e,s)}}function or(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function kd(t,e){return{x:or(t.x,e.x),y:or(t.y,e.y)}}function Dd(t,e){let n=.5;const s=ft(t),i=ft(e);return i>s?n=Ge(e.min,e.max-s,t.min):s>i&&(n=Ge(t.min,t.max-i,e.min)),Lt(0,1,n)}function Vd(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Ts=.35;function Rd(t=Ts){return t===!1?t=0:t===!0&&(t=Ts),{x:ar(t,"left","right"),y:ar(t,"top","bottom")}}function ar(t,e,n){return{min:cr(t,e),max:cr(t,n)}}function cr(t,e){return typeof t=="number"?t:t[e]||0}const Nd=new WeakMap;class Id{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=J(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(nn(d).point)},r=(d,f)=>{const{drag:g,dragPropagation:x,onDragStart:v}=this.getProps();if(g&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Ul(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),vt(y=>{let w=this.getAxisMotionValue(y).get()||0;if(Dt.test(w)){const{projection:S}=this.visualElement;if(S&&S.layout){const D=S.layout.layoutBox[y];D&&(w=ft(D)*(parseFloat(w)/100))}}this.originPoint[y]=w}),v&&G.postRender(()=>v(d,f)),bs(this.visualElement,"transform");const{animationState:A}=this.visualElement;A&&A.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:x,onDirectionLock:v,onDrag:A}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:y}=f;if(x&&this.currentDirection===null){this.currentDirection=Ld(y),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),A&&A(d,f)},c=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>vt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:l}=this.getProps();this.panSession=new aa(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:s,contextWindow:oa(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:r}=i;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&G.postRender(()=>a(s,i))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.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(e,n,s){const{drag:i}=this.getProps();if(!s||!fn(e,i,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(r=jd(r,this.constraints[e],this.elastic[e])),o.set(r)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&Te(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=Ed(s.layoutBox,e):this.constraints=!1,this.elastic=Rd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&vt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Vd(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Te(e))return!1;const s=e.current;Ot(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=Bu(s,i.root,this.visualElement.getTransformPagePoint());let r=kd(i.layout.layoutBox,o);if(n){const a=n(Lu(r));this.hasMutatedConstraints=!!a,a&&(r=_o(a))}return r}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=vt(l=>{if(!fn(l,n,this.currentDirection))return;let d=c&&c[l]||{};r&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,x={type:"inertia",velocity:s?e[l]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(l,x)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return bs(this.visualElement,e),s.start(oi(e,s,0,n,this.visualElement,!1))}stopAnimation(){vt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){vt(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){vt(n=>{const{drag:s}=this.getProps();if(!fn(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:a}=i.layout.layoutBox[n];o.set(e[n]-q(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Te(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};vt(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const c=a.get();i[r]=Dd({min:c,max:c},this.constraints[r])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),vt(r=>{if(!fn(r,e,null))return;const a=this.getAxisMotionValue(r),{min:c,max:u}=this.constraints[r];a.set(q(c,u,i[r]))})}addListeners(){if(!this.visualElement.current)return;Nd.set(this.visualElement,this);const e=this.visualElement.current,n=Ue(e,"pointerdown",c=>{const{drag:u,dragListener:l=!0}=this.getProps();u&&l&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();Te(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,o=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),G.read(s);const r=Ze(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(vt(l=>{const d=this.getAxisMotionValue(l);d&&(this.originPoint[l]+=c[l].translate,d.set(d.get()+c[l].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=Ts,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function fn(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Ld(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class Od extends Kt{constructor(e){super(e),this.removeGroupControls=wt,this.removeListeners=wt,this.controls=new Id(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||wt}unmount(){this.removeGroupControls(),this.removeListeners()}}const lr=t=>(e,n)=>{t&&G.postRender(()=>t(e,n))};class Fd extends Kt{constructor(){super(...arguments),this.removePointerDownListener=wt}onPointerDown(e){this.session=new aa(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:oa(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:lr(e),onStart:lr(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&G.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=Ue(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const vn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function ur(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Be={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(L.test(t))t=parseFloat(t);else return t;const n=ur(t,e.target.x),s=ur(t,e.target.y);return`${n}% ${s}%`}},Bd={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Wt.parse(t);if(i.length>5)return s;const o=Wt.createTransformer(t),r=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+r]/=a,i[1+r]/=c;const u=q(a,c,.5);return typeof i[2+r]=="number"&&(i[2+r]/=u),typeof i[3+r]=="number"&&(i[3+r]/=u),o(i)}};let qn=!1;class $d extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=e;uu(zd),o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),qn&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),vn.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,qn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||G.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Xs.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;qn=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function la(t){const[e,n]=ko(),s=m.useContext(Cs);return h.jsx($d,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(zo),isPresent:e,safeToRemove:n})}const zd={borderRadius:{...Be,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Be,borderTopRightRadius:Be,borderBottomLeftRadius:Be,borderBottomRightRadius:Be,boxShadow:Bd};function Ud(t,e,n){const s=ct(t)?t:je(t);return s.start(oi("",s,e,n)),s.animation}const _d=(t,e)=>t.depth-e.depth;class Wd{constructor(){this.children=[],this.isDirty=!1}add(e){Es(this.children,e),this.isDirty=!0}remove(e){ks(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(_d),this.isDirty=!1,this.children.forEach(e)}}function Kd(t,e){const n=mt.now(),s=({timestamp:i})=>{const o=i-n;o>=e&&(_t(s),t(o-e))};return G.setup(s,!0),()=>_t(s)}const ua=["TopLeft","TopRight","BottomLeft","BottomRight"],Hd=ua.length,dr=t=>typeof t=="string"?parseFloat(t):t,hr=t=>typeof t=="number"||L.test(t);function Gd(t,e,n,s,i,o){i?(t.opacity=q(0,n.opacity??1,Xd(s)),t.opacityExit=q(e.opacity??1,0,qd(s))):o&&(t.opacity=q(e.opacity??1,n.opacity??1,s));for(let r=0;r<Hd;r++){const a=`border${ua[r]}Radius`;let c=fr(e,a),u=fr(n,a);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||hr(c)===hr(u)?(t[a]=Math.max(q(dr(c),dr(u),s),0),(Dt.test(u)||Dt.test(c))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=q(e.rotate||0,n.rotate||0,s))}function fr(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Xd=da(0,.5,qr),qd=da(.5,.95,wt);function da(t,e,n){return s=>s<t?0:s>e?1:n(Ge(t,e,s))}function mr(t,e){t.min=e.min,t.max=e.max}function xt(t,e){mr(t.x,e.x),mr(t.y,e.y)}function pr(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function gr(t,e,n,s,i){return t-=e,t=Cn(t,1/n,s),i!==void 0&&(t=Cn(t,1/i,s)),t}function Yd(t,e=0,n=1,s=.5,i,o=t,r=t){if(Dt.test(e)&&(e=parseFloat(e),e=q(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=q(o.min,o.max,s);t===o&&(a-=e),t.min=gr(t.min,e,n,a,i),t.max=gr(t.max,e,n,a,i)}function yr(t,e,[n,s,i],o,r){Yd(t,e[n],e[s],e[i],e.scale,o,r)}const Jd=["x","scaleX","originX"],Zd=["y","scaleY","originY"];function xr(t,e,n,s){yr(t.x,e,Jd,n?n.x:void 0,s?s.x:void 0),yr(t.y,e,Zd,n?n.y:void 0,s?s.y:void 0)}function vr(t){return t.translate===0&&t.scale===1}function ha(t){return vr(t.x)&&vr(t.y)}function br(t,e){return t.min===e.min&&t.max===e.max}function Qd(t,e){return br(t.x,e.x)&&br(t.y,e.y)}function wr(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function fa(t,e){return wr(t.x,e.x)&&wr(t.y,e.y)}function Tr(t){return ft(t.x)/ft(t.y)}function Sr(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class th{constructor(){this.members=[]}add(e){Es(this.members,e),e.scheduleRender()}remove(e){if(ks(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function eh(t,e,n){let s="";const i=t.x.translate/e.x,o=t.y.translate/e.y,r=n?.z||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:l,rotateX:d,rotateY:f,skewX:g,skewY:x}=n;u&&(s=`perspective(${u}px) ${s}`),l&&(s+=`rotate(${l}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),x&&(s+=`skewY(${x}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(s+=`scale(${a}, ${c})`),s||"none"}const Yn=["","X","Y","Z"],nh=1e3;let sh=0;function Jn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function ma(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Zo(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",G,!(i||o))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&ma(s)}function pa({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},a=e?.()){this.id=sh++,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(oh),this.nodes.forEach(uh),this.nodes.forEach(dh),this.nodes.forEach(ah)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,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 c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new Wd)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new Vs),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const c=this.eventHandlers.get(r);c&&c.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=Eo(r)&&!Xl(r),this.instance=r;const{layoutId:a,layout:c,visualElement:u}=this.options;if(u&&!u.current&&u.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let l,d=0;const f=()=>this.root.updateBlockedByResize=!1;G.read(()=>{d=window.innerWidth}),t(r,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,l&&l(),l=Kd(f,250),vn.hasAnimatedSinceResize&&(vn.hasAnimatedSinceResize=!1,this.nodes.forEach(Cr)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||c)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||u.getDefaultTransition()||gh,{onLayoutAnimationStart:v,onLayoutAnimationComplete:A}=u.getProps(),y=!this.targetLayout||!fa(this.targetLayout,g),w=!d&&f;if(this.options.layoutRoot||this.resumeFrom||w||d&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...Hs(x,"layout"),onPlay:v,onComplete:A};(u.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(l,w)}else d||Cr(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),_t(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(hh),this.animationId++)}getTransformTemplate(){const{visualElement:r}=this.options;return r&&r.getProps().transformTemplate}willUpdate(r=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&ma(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let l=0;l<this.path.length;l++){const d=this.path[l];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Ar);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Pr);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(lh),this.nodes.forEach(ih),this.nodes.forEach(rh)):this.nodes.forEach(Pr),this.clearAllSnapshots();const a=mt.now();st.delta=Lt(0,1e3/60,a-st.timestamp),st.timestamp=a,st.isProcessing=!0,Bn.update.process(st),Bn.preRender.process(st),Bn.render.process(st),st.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Xs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(ch),this.sharedNodes.forEach(fh)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,G.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){G.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ft(this.snapshot.measuredBox.x)&&!ft(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 c=0;c<this.path.length;c++)this.path[c].updateScroll();const r=this.layout;this.layout=this.measure(!1),this.layoutCorrected=J(),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,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&this.instance){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:r,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const r=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!ha(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,l=u!==this.prevTransformTemplateValue;r&&this.instance&&(a||re(this.latestValues)||l)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return r&&(c=this.removeTransform(c)),yh(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:r}=this.options;if(!r)return J();const a=r.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(xh))){const{scroll:u}=this.root;u&&(Se(a.x,u.offset.x),Se(a.y,u.offset.y))}return a}removeElementScroll(r){const a=J();if(xt(a,r),this.scroll?.wasRoot)return a;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:l,options:d}=u;u!==this.root&&l&&d.layoutScroll&&(l.wasRoot&&xt(a,r),Se(a.x,l.offset.x),Se(a.y,l.offset.y))}return a}applyTransform(r,a=!1){const c=J();xt(c,r);for(let u=0;u<this.path.length;u++){const l=this.path[u];!a&&l.options.layoutScroll&&l.scroll&&l!==l.root&&Ae(c,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),re(l.latestValues)&&Ae(c,l.latestValues)}return re(this.latestValues)&&Ae(c,this.latestValues),c}removeTransform(r){const a=J();xt(a,r);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!re(u.latestValues))continue;gs(u.latestValues)&&u.updateSnapshot();const l=J(),d=u.measurePageBox();xt(l,d),xr(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,l)}return re(this.latestValues)&&xr(a,this.latestValues),a}setTargetDelta(r){this.targetDelta=r,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(r){this.options={...this.options,...r,crossfade:r.crossfade!==void 0?r.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!==st.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(r||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:l,layoutId:d}=this.options;if(!(!this.layout||!(l||d))){if(this.resolvedRelativeTargetAt=st.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=J(),this.relativeTargetOrigin=J(),We(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=J(),this.targetWithTransforms=J()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Ad(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):xt(this.target,this.layout.layoutBox),Ko(this.target,this.targetDelta)):xt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=J(),this.relativeTargetOrigin=J(),We(this.relativeTargetOrigin,this.target,f.target),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||gs(this.parent.latestValues)||Wo(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 r=this.getLead(),a=!!this.resumingFrom||this!==r;let c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===st.timestamp&&(c=!1),c)return;const{layout:u,layoutId:l}=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||l))return;xt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;Fu(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=J());const{target:g}=r;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(pr(this.prevProjectionDelta.x,this.projectionDelta.x),pr(this.prevProjectionDelta.y,this.projectionDelta.y)),_e(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Sr(this.projectionDelta.x,this.prevProjectionDelta.x)||!Sr(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){if(this.options.visualElement?.scheduleRender(),r){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Pe(),this.projectionDelta=Pe(),this.projectionDeltaWithTransform=Pe()}setAnimationOrigin(r,a=!1){const c=this.snapshot,u=c?c.latestValues:{},l={...this.latestValues},d=Pe();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=J(),g=c?c.source:void 0,x=this.layout?this.layout.source:void 0,v=g!==x,A=this.getStack(),y=!A||A.members.length<=1,w=!!(v&&!y&&this.options.crossfade===!0&&!this.path.some(ph));this.animationProgress=0;let S;this.mixTargetDelta=D=>{const j=D/1e3;Mr(d.x,r.x,j),Mr(d.y,r.y,j),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(We(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),mh(this.relativeTarget,this.relativeTargetOrigin,f,j),S&&Qd(this.relativeTarget,S)&&(this.isProjectionDirty=!1),S||(S=J()),xt(S,this.relativeTarget)),v&&(this.animationValues=l,Gd(l,u,this.latestValues,j,w,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=j},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(_t(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=G.update(()=>{vn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=je(0)),this.currentAnimation=Ud(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),r.onUpdate&&r.onUpdate(a)},onStop:()=>{},onComplete:()=>{r.onComplete&&r.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 r=this.getStack();r&&r.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(nh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:c,layout:u,latestValues:l}=r;if(!(!a||!c||!u)){if(this!==r&&this.layout&&u&&ga(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||J();const d=ft(this.layout.layoutBox.x);c.x.min=r.target.x.min,c.x.max=c.x.min+d;const f=ft(this.layout.layoutBox.y);c.y.min=r.target.y.min,c.y.max=c.y.min+f}xt(a,c),Ae(a,l),_e(this.projectionDeltaWithTransform,this.layoutCorrected,a,l)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new th),this.sharedNodes.get(r).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 r=this.getStack();return r?r.lead===this:!0}getLead(){const{layoutId:r}=this.options;return r?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:r}=this.options;return r?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:c}=r;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const u={};c.z&&Jn("z",r,u,this.animationValues);for(let l=0;l<Yn.length;l++)Jn(`rotate${Yn[l]}`,r,u,this.animationValues),Jn(`skew${Yn[l]}`,r,u,this.animationValues);r.render();for(const l in u)r.setStaticValue(l,u[l]),this.animationValues&&(this.animationValues[l]=u[l]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=yn(a?.pointerEvents)||"",r.transform=c?c(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=yn(a?.pointerEvents)||""),this.hasProjected&&!re(this.latestValues)&&(r.transform=c?c({},""):"none",this.hasProjected=!1);return}r.visibility="";const l=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=eh(this.projectionDeltaWithTransform,this.treeScale,l);c&&(d=c(l,d)),r.transform=d;const{x:f,y:g}=this.projectionDelta;r.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?r.opacity=u===this?l.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:l.opacityExit:r.opacity=u===this?l.opacity!==void 0?l.opacity:"":l.opacityExit!==void 0?l.opacityExit:0;for(const x in Je){if(l[x]===void 0)continue;const{correct:v,applyTo:A,isCSSVariable:y}=Je[x],w=d==="none"?l[x]:v(l[x],u);if(A){const S=A.length;for(let D=0;D<S;D++)r[A[D]]=w}else y?this.options.visualElement.renderState.vars[x]=w:r[x]=w}this.options.layoutId&&(r.pointerEvents=u===this?yn(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>r.currentAnimation?.stop()),this.root.nodes.forEach(Ar),this.root.sharedNodes.clear()}}}function ih(t){t.updateLayout()}function rh(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(d);d.min=n[l].min,d.max=d.min+f}):ga(i,e.layoutBox,n)&&vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(n[l]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[l].max=t.relativeTarget[l].min+f)});const r=Pe();_e(r,n,e.layoutBox);const a=Pe();o?_e(a,t.applyTransform(s,!0),e.measuredBox):_e(a,n,e.layoutBox);const c=!ha(r);let u=!1;if(!t.resumeFrom){const l=t.getClosestProjectingParent();if(l&&!l.resumeFrom){const{snapshot:d,layout:f}=l;if(d&&f){const g=J();We(g,e.layoutBox,d.layoutBox);const x=J();We(x,n,f.layoutBox),fa(g,x)||(u=!0),l.options.layoutRoot&&(t.relativeTarget=x,t.relativeTargetOrigin=g,t.relativeParent=l)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function oh(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function ah(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function ch(t){t.clearSnapshot()}function Ar(t){t.clearMeasurements()}function Pr(t){t.isLayoutDirty=!1}function lh(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Cr(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function uh(t){t.resolveTargetDelta()}function dh(t){t.calcProjection()}function hh(t){t.resetSkewAndRotation()}function fh(t){t.removeLeadSnapshot()}function Mr(t,e,n){t.translate=q(e.translate,0,n),t.scale=q(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function jr(t,e,n,s){t.min=q(e.min,n.min,s),t.max=q(e.max,n.max,s)}function mh(t,e,n,s){jr(t.x,e.x,n.x,s),jr(t.y,e.y,n.y,s)}function ph(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const gh={duration:.45,ease:[.4,0,.1,1]},Er=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),kr=Er("applewebkit/")&&!Er("chrome/")?Math.round:wt;function Dr(t){t.min=kr(t.min),t.max=kr(t.max)}function yh(t){Dr(t.x),Dr(t.y)}function ga(t,e,n){return t==="position"||t==="preserve-aspect"&&!Sd(Tr(e),Tr(n),.2)}function xh(t){return t!==t.root&&t.scroll?.wasRoot}const vh=pa({attachResizeListener:(t,e)=>Ze(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Zn={current:void 0},ya=pa({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Zn.current){const t=new vh({});t.mount(window),t.setOptions({layoutScroll:!0}),Zn.current=t}return Zn.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),bh={pan:{Feature:Fd},drag:{Feature:Od,ProjectionNode:ya,MeasureLayout:la}};function Vr(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&G.postRender(()=>o(e,nn(e)))}class wh extends Kt{mount(){const{current:e}=this.node;e&&(this.unmount=_l(e,(n,s)=>(Vr(this.node,s,"Start"),i=>Vr(this.node,i,"End"))))}unmount(){}}class Th extends Kt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!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=Qe(Ze(this.node.current,"focus",()=>this.onFocus()),Ze(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Rr(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&G.postRender(()=>o(e,nn(e)))}class Sh extends Kt{mount(){const{current:e}=this.node;e&&(this.unmount=Gl(e,(n,s)=>(Rr(this.node,s,"Start"),(i,{success:o})=>Rr(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Ss=new WeakMap,Qn=new WeakMap,Ah=t=>{const e=Ss.get(t.target);e&&e(t)},Ph=t=>{t.forEach(Ah)};function Ch({root:t,...e}){const n=t||document;Qn.has(n)||Qn.set(n,{});const s=Qn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(Ph,{root:t,...e})),s[i]}function Mh(t,e,n){const s=Ch(e);return Ss.set(t,n),s.observe(t),()=>{Ss.delete(t),s.unobserve(t)}}const jh={some:0,all:1};class Eh extends Kt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:jh[i]},a=c=>{const{isIntersecting:u}=c;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:l,onViewportLeave:d}=this.node.getProps(),f=u?l:d;f&&f(c)};return Mh(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(kh(e,n))&&this.startObserver()}unmount(){}}function kh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const xa={inView:{Feature:Eh},tap:{Feature:Sh},focus:{Feature:Th},hover:{Feature:wh}},Dh={layout:{ProjectionNode:ya,MeasureLayout:la}},Vh={...sa,...xa,...bh,...Dh},Rh=Iu(Vh,Jo),Nh={renderer:Jo,...sa,...xa};function va(t,e){return xn(t,e)}const mn=va("div"),Ih=va("p"),kt=Symbol.for("@arcteninc/core:originalName");function Lh(t,e){return t[kt]=e,t}function Oh(t,e,n,s){if(typeof t!="function")return null;const i=t[kt];if(i){const a=e[i];if(a&&!n.has(a.name))return{fn:t,meta:a}}const o=t.name;let r;if(o&&(r=e[o],r&&!n.has(r.name)))return t[kt]=r.name,{fn:t,meta:r};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(r=e[a],r))return t[kt]=r.name,{fn:t,meta:r}}else if(r=Object.values(e).find(c=>!n.has(c.name)),r)return t[kt]=r.name,{fn:t,meta:r};return null}function ba(t,e){let n,s;if(!e)throw new Error(`❌ toolMetadata is required!
10
10
 
11
11
  Please:
12
12
  1. Run "arcten-extract-types ." before build (add to package.json scripts)
@@ -15,10 +15,10 @@ Please:
15
15
  3. Pass it to useAgent/ArctenAgent:
16
16
  useAgent({ tools: [...], toolMetadata: toolMetadata })
17
17
  (Pass the full object for better minification support, or toolMetadata.functions for backward compatibility)
18
- `);if("functions"in e&&typeof e.functions=="object"){const o=e;n=o.functions,s=o.toolOrder}else n=e,s=void 0;const i=new Set;return t.map(o=>{const r=$h(o,n,i,s);if(!r){const a=o.name,u=o[jt]||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.
19
- To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return i.add(r.meta.name),{name:r.meta.name,description:r.meta.description,jsonSchema:r.meta.parameters}}).filter(o=>o!==null)}function zh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const o=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),o&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([r,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[r,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},r))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(wn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(Y.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(wn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(Y.X,{className:"h-3 w-3"})})]})]})})}function Uh({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,o]=m.useState(!1);if(t==="fetchDocContent")return null;const r=["k","maxResults","_organizationId"];t==="searchDocs"&&r.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!r.includes(u))),c=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>c&&o(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${c?"cursor-pointer hover:bg-opacity-80":""}`,children:[c&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(Y.ChevronDown,{className:"h-3 w-3"}):h.jsx(Y.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(Y.X,{className:"h-3 w-3"}):s?h.jsx(Y.Zap,{className:"h-3 w-3"}):h.jsx(Y.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&c&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},u))})})]})}function _h({...t}){return h.jsx(Cs.Root,{"data-slot":"collapsible",...t})}function Wh({...t}){return h.jsx(Cs.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Kh({...t}){return h.jsx(Cs.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const Hh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),ai=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Hh,{className:Q("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ai.displayName="Response";const Gh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const o=Lh.create(e),r=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(o,{animate:{backgroundPosition:"0% center"},className:Q("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":`${r}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},Xh=m.memo(Gh),Sa=m.createContext(null),qh=()=>{const t=m.useContext(Sa);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Yh=1e3,Jh=1e3,Aa=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:o,children:r,...a})=>{const[c,u]=vi.useControllableState({prop:n,defaultProp:s,onChange:i}),[l,d]=vi.useControllableState({prop:o,defaultProp:0}),[f,g]=m.useState(!1),[x,v]=m.useState(null);m.useEffect(()=>{e?x===null&&v(Date.now()):x!==null&&(d(Math.ceil((Date.now()-x)/Jh)),v(null))},[e,x,d]),m.useEffect(()=>{if(s&&!e&&c&&!f){const y=setTimeout(()=>{u(!1),g(!0)},Yh);return()=>clearTimeout(y)}},[e,c,s,u,f]);const C=y=>{u(y)};return h.jsx(Sa.Provider,{value:{isStreaming:e,isOpen:c,setIsOpen:u,duration:l},children:h.jsx(_h,{className:Q("not-prose mb-4",t),onOpenChange:C,open:c,...a,children:r})})}),Zh=(t,e)=>t||e===0?h.jsx(Xh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Ca=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:o}=qh();return h.jsx(Wh,{className:Q("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...n,children:e??h.jsxs(h.Fragment,{children:[h.jsx(Y.BrainIcon,{className:"size-4"}),Zh(s,o),h.jsx(Y.ChevronDownIcon,{className:Q("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Pa=m.memo(({className:t,children:e,...n})=>h.jsx(Kh,{className:Q("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",t),...n,children:h.jsx(ai,{className:"grid gap-2",children:e})}));Aa.displayName="Reasoning";Ca.displayName="ReasoningTrigger";Pa.displayName="ReasoningContent";function Qh(t){const e=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,n=t.match(e),s=new Map;if(n&&n[1]){const u=n[1],l=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let d;for(;(d=l.exec(u))!==null;)if(d[1]&&d[2]){const f=parseInt(d[1],10),g=d[2].replace(/[.,;:!?]+$/,"");s.set(f,g)}}const i=[];let o=0;const r=/```[\s\S]*?```|`[^`]+`/g;let a;for(;(a=r.exec(t))!==null;)a.index>o&&i.push({type:"text",content:t.slice(o,a.index),start:o,end:a.index}),i.push({type:"code",content:a[0],start:a.index,end:a.index+a[0].length}),o=a.index+a[0].length;return o<t.length&&i.push({type:"text",content:t.slice(o),start:o,end:t.length}),i.map(u=>{if(u.type==="code")return u.content;let l=u.content;l=l.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(v,C,y)=>{const w=parseInt(C,10);return`<sup><a href="${y.replace(/"/g,"&quot;")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${w}]</a></sup>`});const d=/\[([^\]]+)\]\([^\)]+\)/g,f=[];let g;for(;(g=d.exec(l))!==null;)f.push({start:g.index,end:g.index+g[0].length});return l.replace(/\[(\d+)\]/g,(v,C,y)=>{if(f.some(M=>y>=M.start&&y<M.end))return v;const S=parseInt(C,10),E=s.get(S);return E?`<sup><a href="${E.replace(/"/g,"&quot;")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${S}]</a></sup>`:v})}).join("")}function Ke(t){if(typeof t=="string")try{const e=JSON.parse(t);return Ke(e)}catch{return t}if(Array.isArray(t))return t.map(Ke);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=Ke(s);return e}return t}function ts(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return Ke(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?Ke(t):{}}function tf({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:o=void 0,defaultWidth:r=384,minWidth:a=300,maxWidth:c=800,initiallyExpanded:u=!1,tools:l=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:x="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:C,state:y,onStateChange:w,allowStateEdits:S=!0}){const[E,M]=m.useState(null),j=m.useRef(null),[L,V]=m.useState(null),[F,G]=m.useState(null),J=m.useRef(null),z=y!==void 0,[le,At]=m.useState({}),st=m.useRef({});z&&y?st.current=y:z||(st.current=le);const[Ot,B]=m.useState(!1),[it,rt]=m.useState(null),ct=m.useRef(!1),[ot,kt]=m.useState(u),[pt,ue]=m.useState(r),[Gt,Xt]=m.useState(600),[Ct,Dt]=m.useState(!1),[U,de]=m.useState(!1),[dt,qt]=m.useState(!1),[ht,he]=m.useState({x:100,y:100}),[bt,Ve]=m.useState(!1),[Yt,fe]=m.useState({x:0,y:0}),[Dn,me]=m.useState(!1),Jt=m.useRef(null),pe=m.useRef(null),[ge,Re]=m.useState(""),[sn,Vn]=m.useState("Thinking..."),[Ne,Ie]=m.useState(new Set),[Rn,P]=m.useState(""),[A,k]=m.useState([]),[I,$]=m.useState(!1),[_,tt]=m.useState([]),[lt,Ft]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Bt,ye]=m.useState(!1),[sf,rn]=m.useState(!1),[rf,on]=m.useState([]),ci=m.useCallback(async(p,b=3)=>{if(!lt||!j.current)return;const D=async()=>{const T=await fetch(`${v.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${j.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:lt,updates:p},format:"json"})});if(!T.ok){const O=await T.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${T.status} ${O}`)}};for(let T=0;T<b;T++)try{await D(),rt(null);return}catch(O){if(T===b-1){const et=O instanceof Error?O:new Error(String(O));throw rt(et),console.error("Failed to sync state to Convex after retries:",O),et}await new Promise(et=>setTimeout(et,Math.pow(2,T)*100))}},[lt,v,j]),li=m.useMemo(()=>function(){return st.current},[]),ui=m.useMemo(()=>async function(b){const D={...st.current,...b};st.current=D,z||At(D),w&&w(D);try{await ci(b)}catch(T){throw T}},[ci,w,z]);m.useEffect(()=>{z&&y&&(st.current=y)},[z,y]);const Zt=m.useMemo(()=>{const p=[...l,...d,li];return(!z||S)&&p.push(ui),p},[l,d,li,ui,z,S]),Nn=m.useMemo(()=>Ta(Zt,f),[Zt,f]),Vt=m.useMemo(()=>{const p=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}];return(!z||S)&&p.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"]}}),[...Nn,...p]},[Nn,z,S]),di=m.useMemo(()=>new Set(Vt.map(p=>p.name)),[Vt]),In=m.useMemo(()=>Vt.filter(p=>p.name==="getState"?!0:p.name==="setState"?!z||S:di.has(p.name)),[Vt,di,z,S]),hi=m.useMemo(()=>{const p=new Map,b=new Map(Nn.map(D=>[D.name,D]));return Zt.forEach(D=>{const T=D[jt];if(T){const N=b.get(T);if(N){p.set(N.name,D);return}}const O=Vt.find(N=>N.name===D.name);O&&p.set(O.name,D)}),p},[Zt,Vt]),fi=m.useMemo(()=>{const p=new Set;p.add("getState"),p.add("setState");const b=new Map(Vt.map(D=>[D.name,D]));return d.forEach(D=>{const T=D[jt];if(T&&b.has(T))p.add(T);else{const O=Vt.find(N=>N.name===D.name);O&&p.add(O.name)}}),p},[d,Vt]),mi=["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..."];m.useEffect(()=>{if(typeof window<"u"){const p=localStorage.getItem("arcten-sidebar-expanded");p&&kt(JSON.parse(p));const b=localStorage.getItem("arcten-sidebar-width");b&&ue(parseInt(b));const D=localStorage.getItem("arcten-sidebar-height");D&&Xt(parseInt(D));const T=localStorage.getItem("arcten-sidebar-detached");T&&de(JSON.parse(T));const O=localStorage.getItem("arcten-sidebar-position");if(O){const et=JSON.parse(O),Mt=50,zt=Math.max(Mt-r,Math.min(et.x,window.innerWidth-Mt)),ft=Math.max(0,Math.min(et.y,window.innerHeight-Mt));he({x:zt,y:ft})}const N=localStorage.getItem("arcten-sidebar-minimized");N&&qt(JSON.parse(N)),me(!0)}},[]);const $t=m.useMemo(()=>C,[C?.id]);m.useEffect(()=>((async()=>{try{const b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!b.ok)throw new Error("Failed to fetch token");const D=await b.json();M(D.clientToken),j.current=D.clientToken,G(D.expiresAt),V(null)}catch(b){V(b instanceof Error?b.message:"Failed to fetch token")}})(),()=>{J.current&&clearTimeout(J.current)}),[x,$t]),m.useEffect(()=>{if(!F)return;J.current&&clearTimeout(J.current);const p=Math.floor(Date.now()/1e3),b=F-p,T=Math.max(0,b-5);return J.current=setTimeout(async()=>{try{const O=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!O.ok)throw new Error("Failed to refresh token");const N=await O.json();M(N.clientToken),j.current=N.clientToken,G(N.expiresAt),V(null)}catch(O){console.error("Token refresh failed:",O),V(O instanceof Error?O.message:"Failed to refresh token")}},T*1e3),()=>{J.current&&clearTimeout(J.current)}},[F,x,$t]),m.useEffect(()=>{(async()=>{if(Zt.length!==0)try{const b=Zt.map(T=>({name:T.name,code:T.toString()})),D=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:b})});if(D.ok){const T=await D.json();k(T.tools)}}catch(b){console.error("Failed to fetch tool descriptions:",b)}})()},[Zt]),m.useEffect(()=>{const p=()=>{P(window.location.pathname)};p(),window.addEventListener("popstate",p);const b=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(b)}},[]);const Ln=m.useCallback(async()=>{if(!(!$t?.id||!E)){rn(!0);try{const b=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${E}`}})).json();tt(b.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{rn(!1)}}},[$t?.id,E,v]);m.useEffect(()=>{$t?.id&&E&&Ln()},[$t?.id,E,Ln]);function Ma(p){const b=Math.floor((Date.now()-p)/1e3);return b<60?"now":b<3600?`${Math.floor(b/60)}m`:b<86400?`${Math.floor(b/3600)}h`:`${Math.floor(b/86400)}d`}function ja(){const p=crypto.randomUUID();Ft(p),cn([]),on([]),ye(!1);const b=z?y||{}:{};st.current=b,z||At(b),w&&w(b),ct.current=!1}async function Ea(p){if(E)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${E}`}}),tt(_.filter(b=>b._id!==p)),p===lt&&ja()}catch(b){console.error("Failed to delete conversation:",b)}}async function ka(p){Ft(p.chatId),ye(!1),rn(!0);try{const b=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${j.current}`}});if(!b.ok)throw new Error(`Failed to fetch messages: ${b.statusText}`);const T=(await b.json()).messages||[];cn(T),on(T)}catch(b){console.error("Failed to load conversation messages:",b);const D=p.messages||[];cn(D),on(D)}finally{rn(!1)}}const Da=async(p,b={})=>{const D=b.headers?new Headers(b.headers):new Headers;return D.delete("user-agent"),D.delete("User-Agent"),fetch(p,{...b,headers:D})},{messages:Le,sendMessage:Va,status:Pt,error:pi,stop:an,addToolResult:Oe,setMessages:cn}=Lr.useChat({id:lt||void 0,transport:new bn.DefaultChatTransport({api:`${v}/chat`,fetch:Da,headers:()=>{const p={};return j.current&&(p.Authorization=`Bearer ${j.current}`),p},body:()=>({tools:In.map(b=>({name:b.name,description:b.description,inputSchema:b.jsonSchema})),systemPrompt:g,currentRoute:Rn,state:st.current})}),sendAutomaticallyWhen:bn.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{if(!lt||!j.current)return;(async()=>{B(!0),rt(null);try{const b=await fetch(`${v.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${j.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:lt},format:"json"})});if(!b.ok){const et=await b.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${b.status} ${et}`)}const T=(await b.json())?.value||{},O=!ct.current;let N;O?(N={...z?y||{}:{},...T},ct.current=!0):N=T,st.current=N,z||At(N),w&&w(N)}catch(b){console.error("Failed to fetch state:",b);const D=b instanceof Error?b:new Error(String(b));if(rt(D),!ct.current){const T=z?y||{}:{};st.current=T,z||At(T),w&&w(T),ct.current=!0}}finally{B(!1)}})()},[lt,v,z,y,w]),m.useEffect(()=>{ot&&pe.current&&pe.current.focus()},[ot,Le]);function Ra(){kt(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Na(){kt(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[ot]),m.useEffect(()=>{Jt.current&&Jt.current.scrollIntoView({behavior:"smooth"})},[Le]),m.useEffect(()=>{function p(b){b.key==="Escape"&&(Pt==="streaming"||Pt==="submitted")&&(b.preventDefault(),an())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[Pt,an]);function Ia(){const p=crypto.randomUUID();Ft(p),cn([]),on([]),ye(!1)}function gi(p){if(p.preventDefault(),!ge.trim())return;(Pt==="streaming"||Pt==="submitted")&&an();const b=mi[Math.floor(Math.random()*mi.length)]||"Thinking...";Vn(b),Va({text:ge}),Re("")}function La(p){const b=p.target.value;Re(b)}m.useEffect(()=>{if(!Ct)return;function p(D){if(U){const T=D.clientX-ht.x,O=D.clientY-ht.y;T>=a&&T<=c&&ue(T),O>=400&&O<=1e3&&Xt(O)}else{const T=window.innerWidth-D.clientX;T>=a&&T<=c&&ue(T)}}function b(){Dt(!1),localStorage.setItem("arcten-sidebar-width",pt.toString()),localStorage.setItem("arcten-sidebar-height",Gt.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[Ct,pt,Gt,U,ht,a,c]);function Oa(p){p.preventDefault(),Dt(!0)}function Fa(){de(!0),qt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ba(){de(!1),qt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function yi(){qt(!dt),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!dt))}function $a(p){U&&(Ve(!0),fe({x:p.clientX-ht.x,y:p.clientY-ht.y}))}return m.useEffect(()=>{if(!U)return;function p(){he(b=>{const T=window.innerWidth-50,O=window.innerHeight-50,N=50-pt,et=0,Mt=Math.max(N,Math.min(b.x,T)),zt=Math.max(et,Math.min(b.y,O));if(Mt!==b.x||zt!==b.y){const ft={x:Mt,y:zt};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(ft)),ft}return b})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[U,pt]),m.useEffect(()=>{if(!bt)return;function p(D){const T=D.clientX-Yt.x,O=D.clientY-Yt.y,N=50,et=window.innerWidth-N,Mt=window.innerHeight-N,zt=N-pt,ft=0,Rt=Math.max(zt,Math.min(T,et)),mt=Math.max(ft,Math.min(O,Mt));he({x:Rt,y:mt})}function b(){Ve(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(ht))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[bt,Yt,ht,pt]),Dn?L?h.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:h.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",L]})}):E?h.jsx(au,{features:Oh,children:h.jsx(mn,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:U?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:U?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
20
- ${U?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
21
- ${ot?"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"}
22
- ${U?"border border-border":"border-l border-border"}
23
- ${ot?"":"w-[30px]"}
24
- `,style:ot?U?{width:`${pt}px`,height:dt?"auto":`${Gt}px`,left:`${ht.x}px`,top:`${ht.y}px`}:{width:`${pt}px`}:void 0,onClick:ot?void 0:Ra,children:ot?h.jsxs(h.Fragment,{children:[!U&&h.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:Oa,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),U&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:p=>{p.preventDefault(),Dt(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:p=>{p.preventDefault(),p.stopPropagation(),Ve(!0),fe({x:p.clientX-ht.x,y:p.clientY-ht.y})},children:h.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"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:p=>{p.preventDefault(),Dt(!0)}})]}),h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${U?"cursor-move":""}`,onMouseDown:U?$a:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${U&&dt?"cursor-pointer":""}`,onClick:U&&dt?p=>{p.stopPropagation(),yi()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(se({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Ia,"aria-label":"New chat",children:h.jsx(Y.Plus,{className:"h-4 w-4"})})}),h.jsx(ee,{children:"Start a new conversation"})]}),h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(se({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:U?Ba:Fa,"aria-label":U?"Dock sidebar":"Float sidebar",children:U?h.jsx(Y.Dock,{className:"h-4 w-4"}):h.jsx(Y.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(ee,{children:U?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(se({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:U?yi:Na,"aria-label":U?dt?"Maximize":"Minimize":"Close sidebar",children:U?dt?h.jsx(Y.Maximize2,{className:"h-4 w-4"}):h.jsx(Y.Minimize2,{className:"h-4 w-4"}):h.jsx(Y.X,{className:"h-4 w-4"})})}),h.jsx(ee,{children:U?dt?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!dt&&h.jsxs(h.Fragment,{children:[C&&_.length>0&&h.jsxs("div",{className:`border-b border-border ${Bt?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(wn,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Bt||Ln(),ye(!Bt)},children:Bt?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Bt?"flex-1 overflow-y-auto":""}`,children:_.slice(0,Bt?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:Q(se({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>ka(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:Ma(p.updatedAt)})})]}),h.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:b=>{b.stopPropagation(),Ea(p._id)},"aria-label":"Delete conversation",children:h.jsx(Y.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:Le.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&h.jsx("div",{className:"mb-6",children:o}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),A.length>0&&h.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:h.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[(I?A:A.slice(0,10)).map(p=>h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsx(Fn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Re(p.sampleUsage),pe.current?.focus()},children:p.friendlyName})}),h.jsx(ee,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:p.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',p.sampleUsage,'"']}),p.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",p.params.join(", ")]})]})})]},p.name)),A.length>10&&!I&&h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsxs(Fn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>$(!0),children:["+",A.length-10," more"]})}),h.jsx(ee,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),h.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:A.slice(10).map(p=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[p.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:p.description})]},p.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),I&&A.length>10&&h.jsx(Fn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>$(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[Le.map(p=>{const D=p.parts.filter(T=>T.type==="text").map(T=>T.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(Fh,{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:D}):h.jsx("div",{className:"space-y-2",children:p.parts.map((T,O)=>{if(T.type?.startsWith("tool-")){const N=T.type?.replace("tool-","")||"",et=In.find(ft=>ft.name===N),Mt=T.state==="input-available",zt=T.state==="output-available";if(Mt){if(fi.has(N))return(async()=>{if(Ne.has(T.toolCallId))return;Ie(Ut=>new Set(Ut).add(T.toolCallId));const mt=hi.get(N);if(mt)try{const Ut=ts(T.input),On=In.find(ln=>ln.name===N);let Fe;if(On&&On.jsonSchema?.properties){const za=Object.keys(On.jsonSchema.properties).map(Ua=>Ut[Ua]);Fe=await mt(...za)}else if(N==="getState")Fe=mt();else if(N==="setState"){const ln=Ut.updates||Ut;Fe=await mt(ln)}else Fe=await mt(...Object.values(Ut));Oe({toolCallId:T.toolCallId,tool:N,output:Fe})}catch(Ut){Oe({toolCallId:T.toolCallId,tool:N,output:`Error: ${Ut}`})}})(),null;const ft=ts(T.input);return h.jsx(mn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(zh,{toolName:N,description:et?.description||"",args:ft,onApprove:async()=>{if(Ne.has(T.toolCallId))return;Ie(mt=>new Set(mt).add(T.toolCallId));const Rt=hi.get(N);if(Rt)try{const mt=await Rt(...Object.values(ft));Oe({toolCallId:T.toolCallId,tool:N,output:mt})}catch(mt){Oe({toolCallId:T.toolCallId,tool:N,output:`Error: ${mt}`})}},onDeny:async()=>{Ne.has(T.toolCallId)||(Ie(Rt=>new Set(Rt).add(T.toolCallId)),Oe({toolCallId:T.toolCallId,tool:N,output:"User denied tool execution"}))}})},`${T.toolCallId}-${O}`)}else if(zt){const ft=T.output==="User denied tool execution",Rt=ts(T.input);return h.jsx(Uh,{toolName:N,args:Rt,isDenied:ft,isSafe:fi.has(N)},`${T.toolCallId}-${O}`)}return null}if(T.type==="text"&&T.text){const N=Qh(T.text);return h.jsx(ai,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:N},`${p.id}-${O}`)}return T.type==="reasoning"&&T.text?h.jsxs(Aa,{className:"w-full",isStreaming:Pt==="streaming"&&O===p.parts.length-1&&p.id===Le.at(-1)?.id,children:[h.jsx(Ca,{}),h.jsx(Pa,{children:T.text})]},`${p.id}-${O}`):null})})})},p.id)}),h.jsx("div",{ref:Jt})]})}),pi&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",pi.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(ou,{mode:"wait",children:(Pt==="streaming"||Pt==="submitted")&&h.jsxs(mn,{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:[h.jsx(mn,{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]}}),h.jsx("p",{className:"text-xs text-muted-foreground",children:sn})]})}),h.jsxs("form",{onSubmit:gi,className:"relative",children:[h.jsx(Br,{ref:pe,value:ge,onChange:La,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),gi(p))}}),Pt==="streaming"||Pt==="submitted"?h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(se({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:an,children:h.jsx(Y.Square,{className:"h-4 w-4"})})}),h.jsxs(ee,{children:[h.jsx(bi,{children:"Escape"})," to stop"]})]}):h.jsxs(Qt,{children:[h.jsx(te,{asChild:!0,children:h.jsx("button",{type:"submit",className:Q(se({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!ge.trim(),children:h.jsx(Y.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(ee,{children:[h.jsx(bi,{children:"Enter"})," to send"]})]})]})]})]}),h.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:[h.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(Y.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),h.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):h.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:h.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function He(t){if(typeof t=="string")try{const e=JSON.parse(t);return He(e)}catch{return t}if(Array.isArray(t))return t.map(He);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=He(s);return e}return t}function ef(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return He(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?He(t):{}}function nf({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:o=[],safeTools:r=[],toolMetadata:a,systemPrompt:c="",initialMessages:u=[],conversationId:l,initialState:d={},onToolCall:f,onFinish:g,ragFilters:x}={}){const[v,C]=m.useState(n||null),y=m.useRef(n||null),[w,S]=m.useState(null),[E,M]=m.useState(null),j=m.useRef(null),[L,V]=m.useState([]),[F,G]=m.useState(l||(typeof window<"u"?crypto.randomUUID():null)),[J,z]=m.useState(!1),[le,At]=m.useState(new Set),[st,Ot]=m.useState(d),B=m.useRef(d),[it,rt]=m.useState(!1),[ct,ot]=m.useState(null),kt=m.useRef(!1),pt=m.useCallback(async(P,A=3)=>{if(!F||!y.current)return;const k=async()=>{const I=await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:F,updates:P},format:"json"})});if(!I.ok){const $=await I.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${I.status} ${$}`)}};for(let I=0;I<A;I++)try{await k(),ot(null);return}catch($){if(I===A-1){const tt=$ instanceof Error?$:new Error(String($));throw ot(tt),console.error("Failed to sync state to Convex after retries:",$),tt}await new Promise(tt=>setTimeout(tt,Math.pow(2,I)*100))}},[F,t,y]),ue=m.useMemo(()=>function(){return B.current},[]),Gt=m.useMemo(()=>async function(A){const k={...B.current,...A};B.current=k,Ot(k);try{await pt(A)}catch(I){throw I}},[pt]),Xt=m.useMemo(()=>[...o,...r,ue,Gt],[o,r,ue,Gt]),Ct=m.useMemo(()=>Ta(Xt,a),[Xt,a]),Dt=m.useMemo(()=>{const P=new Map,A=new Map(Ct.map(k=>[k.name,k]));return Xt.forEach(k=>{const I=k[jt];if(I){const _=A.get(I);if(_){P.set(_.name,k);return}}const $=Ct.find(_=>_.name===k.name);$&&P.set($.name,k)}),P},[Xt,Ct]),U=m.useMemo(()=>new Set(Ct.map(P=>P.name)),[Ct]),de=m.useMemo(()=>{const P=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}},{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"]}}];return[...Ct,...P]},[Ct]),dt=m.useMemo(()=>de.filter(P=>P.name==="getState"||P.name==="setState"?!0:U.has(P.name)),[de,U]),qt=m.useMemo(()=>{const P=new Set;return P.add("getState"),P.add("setState"),r.forEach(A=>{for(const[k,I]of Dt.entries())if(I===A){P.add(k);break}}),P},[r,Dt]);m.useEffect(()=>s||n?void 0:((async()=>{try{const A=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!A.ok)throw new Error("Failed to fetch token");const k=await A.json();C(k.clientToken),y.current=k.clientToken,M(k.expiresAt),S(null)}catch(A){console.error("[useAgent] Token fetch failed:",A),S(A instanceof Error?A.message:"Failed to fetch token")}})(),()=>{j.current&&clearTimeout(j.current)}),[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(!E||s||n)return;j.current&&clearTimeout(j.current);const P=Math.floor(Date.now()/1e3),A=E-P,I=Math.max(0,A-5);return j.current=setTimeout(async()=>{try{const $=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!$.ok)throw new Error("Failed to refresh token");const _=await $.json();C(_.clientToken),y.current=_.clientToken,M(_.expiresAt),S(null)}catch($){console.error("[useAgent] Token refresh failed:",$),S($ instanceof Error?$.message:"Failed to refresh token")}},I*1e3),()=>{j.current&&clearTimeout(j.current)}},[E,e,JSON.stringify(i),s,n]);const ht=async(P,A={})=>{const k=A.headers?new Headers(A.headers):new Headers;k.delete("user-agent"),k.delete("User-Agent"),console.log("[useAgent] Making request to:",P),console.log("[useAgent] Method:",A.method||"GET"),console.log("[useAgent] Has Authorization header:",k.has("Authorization")),console.log("[useAgent] Client token available:",!!y.current);try{const I=await fetch(P,{...A,headers:k});if(!I.ok){console.error("[useAgent] Request failed:",I.status,I.statusText);const $=await I.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",$)}return I}catch(I){throw console.error("[useAgent] Fetch error:",I),I}},he=`${t}/chat`;console.log("[useAgent] Chat API URL:",he);const{messages:bt,sendMessage:Ve,status:Yt,error:fe,stop:Dn,addToolResult:me,setMessages:Jt}=Lr.useChat({id:F||void 0,messages:u,transport:new bn.DefaultChatTransport({api:he,fetch:ht,headers:()=>{const P={};return y.current?(P.Authorization=`Bearer ${y.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),P},body:()=>{const P=dt.map(k=>({name:k.name,description:k.description,inputSchema:k.jsonSchema})),A=P.filter(k=>k.name==="getState"||k.name==="setState").map(k=>k.name);return A.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",A),{tools:P,systemPrompt:c,state:B.current,...x&&{ragFilters:x}}}}),sendAutomaticallyWhen:bn.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{bt.forEach(P=>{P.role==="assistant"&&P.parts.forEach(A=>{if(!A.type?.startsWith("tool-")||A.state!=="input-available")return;const k=A.type.replace("tool-",""),I=A.toolCallId;if(le.has(I))return;At(_=>new Set(_).add(I));const $=ef(A.input);if(qt.has(k)){const _=Dt.get(k);_?(async()=>{try{const tt=dt.find(Ft=>Ft.name===k);let lt;if(tt&&tt.jsonSchema?.properties){const Bt=Object.keys(tt.jsonSchema.properties).map(ye=>$[ye]);lt=await _(...Bt)}else if(k==="getState")lt=_();else if(k==="setState"){const Ft=$.updates||$;lt=await _(Ft)}else lt=await _(...Object.values($));me({toolCallId:I,tool:k,output:lt})}catch(tt){console.error(`[useAgent] Error executing tool ${k}:`,tt),me({toolCallId:I,tool:k,output:`Error: ${tt}`})}})():console.warn(`[useAgent] Tool ${k} not found in toolsMap`)}else f&&f({toolCall:{toolCallId:I,toolName:k,args:$}})})})},[bt,qt,Dt,f,me,le,Gt,dt]),m.useEffect(()=>{if(Yt==="ready"&&bt.length>0&&g){const P=bt[bt.length-1];P&&P.role==="assistant"&&g({message:P,messages:bt,isAbort:!1,isDisconnect:!1,isError:!!fe})}},[Yt,bt,fe,g]);async function pe(){if(!(!i?.id||!v)){z(!0);try{const A=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${v}`}})).json();V(A.conversations||[])}catch(P){console.error("Failed to fetch conversations:",P)}finally{z(!1)}}}m.useEffect(()=>{i?.id&&v&&pe()},[JSON.stringify(i),v,t]),m.useEffect(()=>{if(!F||!y.current)return;(async()=>{rt(!0),ot(null);try{const A=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:F},format:"json"})});if(!A.ok){const tt=await A.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${A.status} ${tt}`)}const I=(await A.json())?.value||{},$=!kt.current;let _;$?(_={...d,...I},kt.current=!0):_=I,B.current=_,Ot(_)}catch(A){console.error("Failed to fetch state:",A);const k=A instanceof Error?A:new Error(String(A));ot(k),kt.current||(B.current=d,Ot(d),kt.current=!0)}finally{rt(!1)}})()},[F,t]);async function ge(P){G(P),z(!0);try{const A=await fetch(`${t}/conversations/${P}/messages`,{headers:{Authorization:`Bearer ${y.current}`}});if(!A.ok)throw new Error(`Failed to fetch messages: ${A.statusText}`);const I=(await A.json()).messages||[];Jt(I)}catch(A){console.error("Failed to load conversation messages:",A)}finally{z(!1)}}async function Re(P){if(v)try{await fetch(`${t}/conversations/${P}`,{method:"DELETE",headers:{Authorization:`Bearer ${v}`}}),V(L.filter(A=>A._id!==P)),P===F&&sn()}catch(A){console.error("Failed to delete conversation:",A)}}function sn(){const P=crypto.randomUUID();G(P),Jt([]),At(new Set),B.current=d,Ot(d),kt.current=!1}function Vn(P){me(P)}async function Ne(P){const A={...B.current,...P};B.current=A,Ot(A);try{await pt(P)}catch(k){throw k}}async function Ie(){if(!i?.id||!y.current)throw new Error("User authentication required to share state");const P=`shared_${crypto.randomUUID()}`;try{return await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:create",args:{stateId:P,state:B.current,projectId:"default",createdBy:i.id},format:"json"})}),P}catch(A){throw console.error("Failed to share state:",A),A}}async function Rn(P){if(!y.current)throw new Error("Authentication required to import state");try{const A=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:getByStateId",args:{stateId:P},format:"json"})});if(!A.ok)throw new Error("Failed to fetch shared state");const I=(await A.json())?.value||{};B.current=I,Ot(I)}catch(A){throw console.error("Failed to import state:",A),A}}return{id:F,messages:bt,status:Yt,error:fe,sendMessage:Ve,stop:Dn,addToolOutput:Vn,setMessages:Jt,conversations:L,loadConversation:ge,deleteConversation:Re,startNewConversation:sn,isLoadingConversations:J,clientToken:v,tokenError:w,state:st,setState:Ne,shareState:Ie,importState:Rn,isStateLoading:it,stateError:ct}}exports.verifyToken=tc.verifyToken;exports.ARCTEN_ORIGINAL_NAME=jt;exports.ArctenAgent=tf;exports.preserveToolName=Bh;exports.useAgent=nf;
18
+ `);if("functions"in e&&typeof e.functions=="object"){const o=e;n=o.functions,s=o.toolOrder}else n=e,s=void 0;const i=new Set;return t.map(o=>{const r=Oh(o,n,i,s);if(!r){const a=o.name,u=o[kt]||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.
19
+ To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return i.add(r.meta.name),{name:r.meta.name,description:r.meta.description,jsonSchema:r.meta.parameters}}).filter(o=>o!==null)}function Fh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const o=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),o&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([r,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[r,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},r))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(wn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(Q.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(wn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(Q.X,{className:"h-3 w-3"})})]})]})})}function Bh({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,o]=m.useState(!1);if(t==="fetchDocContent")return null;const r=["k","maxResults","_organizationId"];t==="searchDocs"&&r.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!r.includes(u))),c=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>c&&o(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${c?"cursor-pointer hover:bg-opacity-80":""}`,children:[c&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(Q.ChevronDown,{className:"h-3 w-3"}):h.jsx(Q.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(Q.X,{className:"h-3 w-3"}):s?h.jsx(Q.Zap,{className:"h-3 w-3"}):h.jsx(Q.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&c&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},u))})})]})}function $h({...t}){return h.jsx(Ps.Root,{"data-slot":"collapsible",...t})}function zh({...t}){return h.jsx(Ps.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Uh({...t}){return h.jsx(Ps.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const _h=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),ai=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(_h,{className:it("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ai.displayName="Response";const Wh=Object.freeze(Object.defineProperty({__proto__:null,Response:ai},Symbol.toStringTag,{value:"Module"})),Kh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const o=Rh.create(e),r=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(o,{animate:{backgroundPosition:"0% center"},className:it("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":`${r}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},Hh=m.memo(Kh),wa=m.createContext(null),Gh=()=>{const t=m.useContext(wa);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Xh=1e3,qh=1e3,Ta=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:o,children:r,...a})=>{const[c,u]=yi.useControllableState({prop:n,defaultProp:s,onChange:i}),[l,d]=yi.useControllableState({prop:o,defaultProp:0}),[f,g]=m.useState(!1),[x,v]=m.useState(null);m.useEffect(()=>{e?x===null&&v(Date.now()):x!==null&&(d(Math.ceil((Date.now()-x)/qh)),v(null))},[e,x,d]),m.useEffect(()=>{if(s&&!e&&c&&!f){const y=setTimeout(()=>{u(!1),g(!0)},Xh);return()=>clearTimeout(y)}},[e,c,s,u,f]);const A=y=>{u(y)};return h.jsx(wa.Provider,{value:{isStreaming:e,isOpen:c,setIsOpen:u,duration:l},children:h.jsx($h,{className:it("not-prose mb-4",t),onOpenChange:A,open:c,...a,children:r})})}),Yh=(t,e)=>t||e===0?h.jsx(Hh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Sa=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:o}=Gh();return h.jsx(zh,{className:it("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...n,children:e??h.jsxs(h.Fragment,{children:[h.jsx(Q.BrainIcon,{className:"size-4"}),Yh(s,o),h.jsx(Q.ChevronDownIcon,{className:it("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Aa=m.memo(({className:t,children:e,...n})=>h.jsx(Uh,{className:it("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",t),...n,children:h.jsx(ai,{className:"grid gap-2",children:e})}));Ta.displayName="Reasoning";Sa.displayName="ReasoningTrigger";Aa.displayName="ReasoningContent";function Jh(t){const e=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,n=t.match(e),s=new Map;if(n&&n[1]){const u=n[1],l=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let d;for(;(d=l.exec(u))!==null;)if(d[1]&&d[2]){const f=parseInt(d[1],10),g=d[2].replace(/[.,;:!?]+$/,"");s.set(f,g)}}const i=[];let o=0;const r=/```[\s\S]*?```|`[^`]+`/g;let a;for(;(a=r.exec(t))!==null;)a.index>o&&i.push({type:"text",content:t.slice(o,a.index),start:o,end:a.index}),i.push({type:"code",content:a[0],start:a.index,end:a.index+a[0].length}),o=a.index+a[0].length;return o<t.length&&i.push({type:"text",content:t.slice(o),start:o,end:t.length}),i.map(u=>{if(u.type==="code")return u.content;let l=u.content;l=l.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(v,A,y)=>{const w=parseInt(A,10);return`<sup><a href="${y.replace(/"/g,"&quot;")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${w}]</a></sup>`});const d=/\[([^\]]+)\]\([^\)]+\)/g,f=[];let g;for(;(g=d.exec(l))!==null;)f.push({start:g.index,end:g.index+g[0].length});return l.replace(/\[(\d+)\]/g,(v,A,y)=>{if(f.some(j=>y>=j.start&&y<j.end))return v;const S=parseInt(A,10),D=s.get(S);return D?`<sup><a href="${D.replace(/"/g,"&quot;")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${S}]</a></sup>`:v})}).join("")}function Ke(t){if(typeof t=="string")try{const e=JSON.parse(t);return Ke(e)}catch{return t}if(Array.isArray(t))return t.map(Ke);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=Ke(s);return e}return t}function ts(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return Ke(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?Ke(t):{}}function Zh({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:o=void 0,defaultWidth:r=384,minWidth:a=300,maxWidth:c=800,initiallyExpanded:u=!1,tools:l=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:x="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:A,state:y,onStateChange:w,allowStateEdits:S=!0}){const[D,j]=m.useState(null),E=m.useRef(null),[O,R]=m.useState(null),[B,Y]=m.useState(null),tt=m.useRef(null),z=y!==void 0,[ue,Tt]=m.useState({}),rt=m.useRef({});z&&y?rt.current=y:z||(rt.current=ue);const[Bt,F]=m.useState(!1),[lt,ut]=m.useState(null),dt=m.useRef(!1),[ht,Vt]=m.useState(u),[yt,de]=m.useState(r),[Ht,Gt]=m.useState(600),[Mt,Rt]=m.useState(!1),[_,he]=m.useState(!1),[pt,Xt]=m.useState(!1),[gt,fe]=m.useState({x:100,y:100}),[St,Ne]=m.useState(!1),[qt,me]=m.useState({x:0,y:0}),[Dn,pe]=m.useState(!1),Yt=m.useRef(null),ge=m.useRef(null),[ye,Ie]=m.useState(""),[Le,Vn]=m.useState(null),[Rn,Nn]=m.useState("Thinking..."),[xe,P]=m.useState(new Set),[C,V]=m.useState(""),[I,U]=m.useState([]),[W,ot]=m.useState(!1),[Nt,Jt]=m.useState([]),[jt,Oe]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[ve,sn]=m.useState(!1),[ef,rn]=m.useState(!1),[nf,on]=m.useState([]),ci=m.useCallback(async(p,b=3)=>{if(!jt||!E.current)return;const M=async()=>{const k=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,N=await fetch(k,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:jt,updates:p},format:"json"})});if(!N.ok){if(N.status===404){console.warn("[ArctenAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const $=await N.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${N.status} ${$}`)}};for(let T=0;T<b;T++)try{await M(),ut(null);return}catch(k){if(T===b-1){const $=k instanceof Error?k:new Error(String(k));throw ut($),console.error("Failed to sync state to Convex after retries:",k),$}await new Promise($=>setTimeout($,Math.pow(2,T)*100))}},[jt,v,E]),li=m.useMemo(()=>function(){return rt.current},[]),ui=m.useMemo(()=>async function(b){const M={...rt.current,...b};rt.current=M,z||Tt(M),w&&w(M);try{await ci(b)}catch(T){throw T}},[ci,w,z]);m.useEffect(()=>{z&&y&&(rt.current=y)},[z,y]);const Zt=m.useMemo(()=>{const p=[...l,...d,li];return(!z||S)&&p.push(ui),p},[l,d,li,ui,z,S]),In=m.useMemo(()=>ba(Zt,f),[Zt,f]),It=m.useMemo(()=>{const p=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}];return(!z||S)&&p.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"]}}),[...In,...p]},[In,z,S]),di=m.useMemo(()=>new Set(It.map(p=>p.name)),[It]),an=m.useMemo(()=>It.filter(p=>p.name==="getState"?!0:p.name==="setState"?!z||S:di.has(p.name)),[It,di,z,S]),Ln=m.useMemo(()=>{const p=new Map,b=new Map(In.map(M=>[M.name,M]));return Zt.forEach(M=>{const T=M[kt];if(T){const N=b.get(T);if(N){p.set(N.name,M);return}}const k=It.find(N=>N.name===M.name);k&&p.set(k.name,M)}),p},[Zt,It]),Fe=m.useMemo(()=>{const p=new Set;p.add("getState"),p.add("setState");const b=new Map(It.map(M=>[M.name,M]));return d.forEach(M=>{const T=M[kt];if(T&&b.has(T))p.add(T);else{const k=It.find(N=>N.name===M.name);k&&p.add(k.name)}}),p},[d,It]),hi=["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..."];m.useEffect(()=>{if(typeof window<"u"){const p=localStorage.getItem("arcten-sidebar-expanded");p&&Vt(JSON.parse(p));const b=localStorage.getItem("arcten-sidebar-width");b&&de(parseInt(b));const M=localStorage.getItem("arcten-sidebar-height");M&&Gt(parseInt(M));const T=localStorage.getItem("arcten-sidebar-detached");T&&he(JSON.parse(T));const k=localStorage.getItem("arcten-sidebar-position");if(k){const $=JSON.parse(k),K=50,et=Math.max(K-r,Math.min($.x,window.innerWidth-K)),H=Math.max(0,Math.min($.y,window.innerHeight-K));fe({x:et,y:H})}const N=localStorage.getItem("arcten-sidebar-minimized");N&&Xt(JSON.parse(N)),pe(!0)}},[]);const $t=m.useMemo(()=>A,[A?.id]);m.useEffect(()=>((async()=>{try{const b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!b.ok)throw new Error("Failed to fetch token");const M=await b.json();j(M.clientToken),E.current=M.clientToken,Y(M.expiresAt),R(null)}catch(b){R(b instanceof Error?b.message:"Failed to fetch token")}})(),()=>{tt.current&&clearTimeout(tt.current)}),[x,$t]),m.useEffect(()=>{if(!B)return;tt.current&&clearTimeout(tt.current);const p=Math.floor(Date.now()/1e3),b=B-p,T=Math.max(0,b-5);return tt.current=setTimeout(async()=>{try{const k=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!k.ok)throw new Error("Failed to refresh token");const N=await k.json();j(N.clientToken),E.current=N.clientToken,Y(N.expiresAt),R(null)}catch(k){console.error("Token refresh failed:",k),R(k instanceof Error?k.message:"Failed to refresh token")}},T*1e3),()=>{tt.current&&clearTimeout(tt.current)}},[B,x,$t]),m.useEffect(()=>{(async()=>{if(Zt.length!==0)try{const b=Zt.map(T=>({name:T.name,code:T.toString()})),M=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:b})});if(M.ok){const T=await M.json();U(T.tools)}}catch(b){console.error("Failed to fetch tool descriptions:",b)}})()},[Zt]),m.useEffect(()=>{Promise.resolve().then(()=>Wh).then(p=>{Vn(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{V(window.location.pathname)};p(),window.addEventListener("popstate",p);const b=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(b)}},[]);const On=m.useCallback(async()=>{if(!(!$t?.id||!D)){rn(!0);try{const b=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${D}`}})).json();Jt(b.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{rn(!1)}}},[$t?.id,D,v]);m.useEffect(()=>{$t?.id&&D&&On()},[$t?.id,D,On]);function Pa(p){const b=Math.floor((Date.now()-p)/1e3);return b<60?"now":b<3600?`${Math.floor(b/60)}m`:b<86400?`${Math.floor(b/3600)}h`:`${Math.floor(b/86400)}d`}function Ca(){const p=crypto.randomUUID();Oe(p),ln([]),on([]),sn(!1);const b=z?y||{}:{};rt.current=b,z||Tt(b),w&&w(b),dt.current=!1}async function Ma(p){if(D)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${D}`}}),Jt(Nt.filter(b=>b._id!==p)),p===jt&&Ca()}catch(b){console.error("Failed to delete conversation:",b)}}async function ja(p){Oe(p.chatId),sn(!1),rn(!0);try{const b=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${E.current}`}});if(!b.ok)throw new Error(`Failed to fetch messages: ${b.statusText}`);const T=(await b.json()).messages||[];ln(T),on(T)}catch(b){console.error("Failed to load conversation messages:",b);const M=p.messages||[];ln(M),on(M)}finally{rn(!1)}}const Ea=async(p,b={})=>{const M=b.headers?new Headers(b.headers):new Headers;return M.delete("user-agent"),M.delete("User-Agent"),fetch(p,{...b,headers:M})},{messages:zt,sendMessage:ka,status:Et,error:fi,stop:cn,addToolResult:Qt,setMessages:ln}=Nr.useChat({id:jt||void 0,transport:new bn.DefaultChatTransport({api:`${v}/chat`,fetch:Ea,headers:()=>{const p={};return E.current&&(p.Authorization=`Bearer ${E.current}`),p},body:()=>({tools:an.map(b=>({name:b.name,description:b.description,inputSchema:b.jsonSchema})),systemPrompt:g,currentRoute:C,state:rt.current})}),sendAutomaticallyWhen:bn.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{const p=zt[zt.length-1];if(!p||p.role!=="assistant")return;const b=p.parts?.filter(M=>M.type?.startsWith("tool-")&&M.state==="input-available"&&typeof M.toolCallId=="string"&&M.input!==void 0)||[];for(const M of b){const T=M,k=T.type?.replace("tool-","")||"",N=T.toolCallId;Fe.has(k)&&!xe.has(N)&&(P($=>new Set($).add(N)),(async()=>{try{const $=Ln.get(k);if(!$){console.warn(`[ArctenAgent] Tool ${k} not found in toolsMap`),Qt({toolCallId:N,tool:k,output:`Error: Tool ${k} not found`}),P(nt=>{const at=new Set(nt);return at.delete(N),at});return}const K=ts(T.input),et=an.find(nt=>nt.name===k);let H;if(et&&et.jsonSchema?.properties){const at=Object.keys(et.jsonSchema.properties).map(Ba=>K[Ba]);console.log(`[ArctenAgent] Executing safe tool ${k} with args:`,at),H=await $(...at)}else if(k==="getState")H=$();else if(k==="setState"){const nt=K.updates||K;H=await $(nt)}else H=await $(...Object.values(K));console.log(`[ArctenAgent] Tool ${k} completed, result:`,H),Qt({toolCallId:N,tool:k,output:H}),P(nt=>{const at=new Set(nt);return at.delete(N),at})}catch($){console.error(`[ArctenAgent] Error executing safe tool ${k}:`,$),Qt({toolCallId:N,tool:k,output:`Error: ${$ instanceof Error?$.message:String($)}`}),P(K=>{const et=new Set(K);return et.delete(N),et})}})())}},[zt,Fe,Ln,an,xe,Qt]),m.useEffect(()=>{if(!jt||!E.current)return;(async()=>{F(!0),ut(null);try{const M=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,T=await fetch(M,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:jt},format:"json"})});if(!T.ok){if(T.status===404||T.status>=500){console.warn(`[ArctenAgent] Convex API endpoint not available (${T.status}), using empty state`);const H=z?y||{}:{};rt.current=H,z||Tt(H),w&&w(H),dt.current=!0,F(!1);return}const et=await T.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${T.status} ${et}`)}const N=(await T.json())?.value||{},$=!dt.current;let K;$?(K={...z?y||{}:{},...N},dt.current=!0):K=N,rt.current=K,z||Tt(K),w&&w(K)}catch(b){b instanceof TypeError&&b.message.includes("fetch")?console.warn("[ArctenAgent] Network error fetching state (likely Convex endpoint not available), using fallback state:",b):console.error("[ArctenAgent] Failed to fetch state:",b);const T=b instanceof Error?b:new Error(String(b));if(ut(T),!dt.current){const k=z?y||{}:{};rt.current=k,z||Tt(k),w&&w(k),dt.current=!0}}finally{F(!1)}})()},[jt,v,z,y,w]),m.useEffect(()=>{ht&&ge.current&&ge.current.focus()},[ht,zt]);function Da(){Vt(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Va(){Vt(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[ht]),m.useEffect(()=>{Yt.current&&Yt.current.scrollIntoView({behavior:"smooth"})},[zt]),m.useEffect(()=>{function p(b){b.key==="Escape"&&(Et==="streaming"||Et==="submitted")&&(b.preventDefault(),cn())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[Et,cn]);function Ra(){const p=crypto.randomUUID();Oe(p),ln([]),on([]),sn(!1)}function mi(p){if(p.preventDefault(),!ye.trim())return;(Et==="streaming"||Et==="submitted")&&cn();const b=hi[Math.floor(Math.random()*hi.length)]||"Thinking...";Nn(b),ka({text:ye}),Ie("")}function Na(p){const b=p.target.value;Ie(b)}m.useEffect(()=>{if(!Mt)return;function p(M){if(_){const T=M.clientX-gt.x,k=M.clientY-gt.y;T>=a&&T<=c&&de(T),k>=400&&k<=1e3&&Gt(k)}else{const T=window.innerWidth-M.clientX;T>=a&&T<=c&&de(T)}}function b(){Rt(!1),localStorage.setItem("arcten-sidebar-width",yt.toString()),localStorage.setItem("arcten-sidebar-height",Ht.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[Mt,yt,Ht,_,gt,a,c]);function Ia(p){p.preventDefault(),Rt(!0)}function La(){he(!0),Xt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Oa(){he(!1),Xt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function pi(){Xt(!pt),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!pt))}function Fa(p){_&&(Ne(!0),me({x:p.clientX-gt.x,y:p.clientY-gt.y}))}return m.useEffect(()=>{if(!_)return;function p(){fe(b=>{const T=window.innerWidth-50,k=window.innerHeight-50,N=50-yt,$=0,K=Math.max(N,Math.min(b.x,T)),et=Math.max($,Math.min(b.y,k));if(K!==b.x||et!==b.y){const H={x:K,y:et};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(H)),H}return b})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[_,yt]),m.useEffect(()=>{if(!St)return;function p(M){const T=M.clientX-qt.x,k=M.clientY-qt.y,N=50,$=window.innerWidth-N,K=window.innerHeight-N,et=N-yt,H=0,nt=Math.max(et,Math.min(T,$)),at=Math.max(H,Math.min(k,K));fe({x:nt,y:at})}function b(){Ne(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(gt))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[St,qt,gt,yt]),Dn?O?h.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:h.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",O]})}):D?h.jsx(iu,{features:Nh,children:h.jsx(mn,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:_?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:_?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
20
+ ${_?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
21
+ ${ht?"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"}
22
+ ${_?"border border-border":"border-l border-border"}
23
+ ${ht?"":"w-[30px]"}
24
+ `,style:ht?_?{width:`${yt}px`,height:pt?"auto":`${Ht}px`,left:`${gt.x}px`,top:`${gt.y}px`}:{width:`${yt}px`}:void 0,onClick:ht?void 0:Da,children:ht?h.jsxs(h.Fragment,{children:[!_&&h.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:Ia,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),_&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:p=>{p.preventDefault(),Rt(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:p=>{p.preventDefault(),p.stopPropagation(),Ne(!0),me({x:p.clientX-gt.x,y:p.clientY-gt.y})},children:h.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"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:p=>{p.preventDefault(),Rt(!0)}})]}),h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${_?"cursor-move":""}`,onMouseDown:_?Fa:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${_&&pt?"cursor-pointer":""}`,onClick:_&&pt?p=>{p.stopPropagation(),pi()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsx("button",{type:"button",className:it(ie({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Ra,"aria-label":"New chat",children:h.jsx(Q.Plus,{className:"h-4 w-4"})})}),h.jsx(ne,{children:"Start a new conversation"})]}),h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsx("button",{type:"button",className:it(ie({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:_?Oa:La,"aria-label":_?"Dock sidebar":"Float sidebar",children:_?h.jsx(Q.Dock,{className:"h-4 w-4"}):h.jsx(Q.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(ne,{children:_?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsx("button",{type:"button",className:it(ie({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:_?pi:Va,"aria-label":_?pt?"Maximize":"Minimize":"Close sidebar",children:_?pt?h.jsx(Q.Maximize2,{className:"h-4 w-4"}):h.jsx(Q.Minimize2,{className:"h-4 w-4"}):h.jsx(Q.X,{className:"h-4 w-4"})})}),h.jsx(ne,{children:_?pt?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!pt&&h.jsxs(h.Fragment,{children:[A&&Nt.length>0&&h.jsxs("div",{className:`border-b border-border ${ve?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(wn,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{ve||On(),sn(!ve)},children:ve?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${ve?"flex-1 overflow-y-auto":""}`,children:Nt.slice(0,ve?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:it(ie({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>ja(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:Pa(p.updatedAt)})})]}),h.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:b=>{b.stopPropagation(),Ma(p._id)},"aria-label":"Delete conversation",children:h.jsx(Q.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:zt.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&h.jsx("div",{className:"mb-6",children:o}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),I.length>0&&h.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:h.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[(W?I:I.slice(0,10)).map(p=>h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsx(Fn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Ie(p.sampleUsage),ge.current?.focus()},children:p.friendlyName})}),h.jsx(ne,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:p.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',p.sampleUsage,'"']}),p.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",p.params.join(", ")]})]})})]},p.name)),I.length>10&&!W&&h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsxs(Fn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>ot(!0),children:["+",I.length-10," more"]})}),h.jsx(ne,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),h.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:I.slice(10).map(p=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[p.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:p.description})]},p.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),W&&I.length>10&&h.jsx(Fn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>ot(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[zt.map(p=>{const M=p.parts.filter(T=>T.type==="text").map(T=>T.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(Ih,{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:M}):h.jsx("div",{className:"space-y-2",children:p.parts.map((T,k)=>{if(T.type?.startsWith("tool-")){const N=T.type?.replace("tool-","")||"",$=an.find(H=>H.name===N),K=T.state==="input-available",et=T.state==="output-available";if(K&&Fe.has(N),K){if(Fe.has(N))return null;const H=ts(T.input);return h.jsx(mn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(Fh,{toolName:N,description:$?.description||"",args:H,onApprove:async()=>{if(xe.has(T.toolCallId))return;P(at=>new Set(at).add(T.toolCallId));const nt=Ln.get(N);if(nt)try{const at=await nt(...Object.values(H));Qt({toolCallId:T.toolCallId,tool:N,output:at})}catch(at){Qt({toolCallId:T.toolCallId,tool:N,output:`Error: ${at}`})}},onDeny:async()=>{xe.has(T.toolCallId)||(P(nt=>new Set(nt).add(T.toolCallId)),Qt({toolCallId:T.toolCallId,tool:N,output:"User denied tool execution"}))}})},`${T.toolCallId}-${k}`)}else if(et){const H=T.output==="User denied tool execution",nt=ts(T.input);return h.jsx(Bh,{toolName:N,args:nt,isDenied:H,isSafe:Fe.has(N)},`${T.toolCallId}-${k}`)}return null}if(T.type==="text"&&T.text&&Le){const N=Jh(T.text);return h.jsx(Le,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:N},`${p.id}-${k}`)}return T.type==="reasoning"&&T.text?h.jsxs(Ta,{className:"w-full",isStreaming:Et==="streaming"&&k===p.parts.length-1&&p.id===zt.at(-1)?.id,children:[h.jsx(Sa,{}),h.jsx(Aa,{children:T.text})]},`${p.id}-${k}`):null})})})},p.id)}),h.jsx("div",{ref:Yt})]})}),fi&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",fi.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(su,{mode:"wait",children:(Et==="streaming"||Et==="submitted")&&h.jsxs(mn,{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:[h.jsx(mn,{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]}}),h.jsx("p",{className:"text-xs text-muted-foreground",children:Rn})]})}),h.jsxs("form",{onSubmit:mi,className:"relative",children:[h.jsx(Or,{ref:ge,value:ye,onChange:Na,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),mi(p))}}),Et==="streaming"||Et==="submitted"?h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsx("button",{type:"button",className:it(ie({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:cn,children:h.jsx(Q.Square,{className:"h-4 w-4"})})}),h.jsxs(ne,{children:[h.jsx(xi,{children:"Escape"})," to stop"]})]}):h.jsxs(te,{children:[h.jsx(ee,{asChild:!0,children:h.jsx("button",{type:"submit",className:it(ie({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!ye.trim(),children:h.jsx(Q.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(ne,{children:[h.jsx(xi,{children:"Enter"})," to send"]})]})]})]})]}),h.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:[h.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(Q.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),h.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):h.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:h.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function He(t){if(typeof t=="string")try{const e=JSON.parse(t);return He(e)}catch{return t}if(Array.isArray(t))return t.map(He);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=He(s);return e}return t}function Qh(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return He(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?He(t):{}}function tf({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:o=[],safeTools:r=[],toolMetadata:a,systemPrompt:c="",initialMessages:u=[],conversationId:l,initialState:d={},onToolCall:f,onFinish:g,ragFilters:x}={}){const[v,A]=m.useState(n||null),y=m.useRef(n||null),[w,S]=m.useState(null),[D,j]=m.useState(null),E=m.useRef(null),[O,R]=m.useState([]),[B,Y]=m.useState(l||(typeof window<"u"?crypto.randomUUID():null)),[tt,z]=m.useState(!1),[ue,Tt]=m.useState(new Set),[rt,Bt]=m.useState(d),F=m.useRef(d),[lt,ut]=m.useState(!1),[dt,ht]=m.useState(null),Vt=m.useRef(!1),yt=m.useCallback(async(P,C=3)=>{if(!B||!y.current)return;const V=async()=>{const I=await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:B,updates:P},format:"json"})});if(!I.ok){const U=await I.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${I.status} ${U}`)}};for(let I=0;I<C;I++)try{await V(),ht(null);return}catch(U){if(I===C-1){const ot=U instanceof Error?U:new Error(String(U));throw ht(ot),console.error("Failed to sync state to Convex after retries:",U),ot}await new Promise(ot=>setTimeout(ot,Math.pow(2,I)*100))}},[B,t,y]),de=m.useMemo(()=>function(){return F.current},[]),Ht=m.useMemo(()=>async function(C){const V={...F.current,...C};F.current=V,Bt(V);try{await yt(C)}catch(I){throw I}},[yt]),Gt=m.useMemo(()=>[...o,...r,de,Ht],[o,r,de,Ht]),Mt=m.useMemo(()=>ba(Gt,a),[Gt,a]),Rt=m.useMemo(()=>{const P=new Map,C=new Map(Mt.map(V=>[V.name,V]));return Gt.forEach(V=>{const I=V[kt];if(I){const W=C.get(I);if(W){P.set(W.name,V);return}}const U=Mt.find(W=>W.name===V.name);U&&P.set(U.name,V)}),P},[Gt,Mt]),_=m.useMemo(()=>new Set(Mt.map(P=>P.name)),[Mt]),he=m.useMemo(()=>{const P=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}},{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"]}}];return[...Mt,...P]},[Mt]),pt=m.useMemo(()=>he.filter(P=>P.name==="getState"||P.name==="setState"?!0:_.has(P.name)),[he,_]),Xt=m.useMemo(()=>{const P=new Set;return P.add("getState"),P.add("setState"),r.forEach(C=>{for(const[V,I]of Rt.entries())if(I===C){P.add(V);break}}),P},[r,Rt]);m.useEffect(()=>s||n?void 0:((async()=>{try{const C=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!C.ok)throw new Error("Failed to fetch token");const V=await C.json();A(V.clientToken),y.current=V.clientToken,j(V.expiresAt),S(null)}catch(C){console.error("[useAgent] Token fetch failed:",C),S(C instanceof Error?C.message:"Failed to fetch token")}})(),()=>{E.current&&clearTimeout(E.current)}),[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(!D||s||n)return;E.current&&clearTimeout(E.current);const P=Math.floor(Date.now()/1e3),C=D-P,I=Math.max(0,C-5);return E.current=setTimeout(async()=>{try{const U=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!U.ok)throw new Error("Failed to refresh token");const W=await U.json();A(W.clientToken),y.current=W.clientToken,j(W.expiresAt),S(null)}catch(U){console.error("[useAgent] Token refresh failed:",U),S(U instanceof Error?U.message:"Failed to refresh token")}},I*1e3),()=>{E.current&&clearTimeout(E.current)}},[D,e,JSON.stringify(i),s,n]);const gt=async(P,C={})=>{const V=C.headers?new Headers(C.headers):new Headers;V.delete("user-agent"),V.delete("User-Agent"),console.log("[useAgent] Making request to:",P),console.log("[useAgent] Method:",C.method||"GET"),console.log("[useAgent] Has Authorization header:",V.has("Authorization")),console.log("[useAgent] Client token available:",!!y.current);try{const I=await fetch(P,{...C,headers:V});if(!I.ok){console.error("[useAgent] Request failed:",I.status,I.statusText);const U=await I.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",U)}return I}catch(I){throw console.error("[useAgent] Fetch error:",I),I}},fe=`${t}/chat`;console.log("[useAgent] Chat API URL:",fe);const{messages:St,sendMessage:Ne,status:qt,error:me,stop:Dn,addToolResult:pe,setMessages:Yt}=Nr.useChat({id:B||void 0,messages:u,transport:new bn.DefaultChatTransport({api:fe,fetch:gt,headers:()=>{const P={};return y.current?(P.Authorization=`Bearer ${y.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),P},body:()=>{const P=pt.map(V=>({name:V.name,description:V.description,inputSchema:V.jsonSchema})),C=P.filter(V=>V.name==="getState"||V.name==="setState").map(V=>V.name);return C.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",C),{tools:P,systemPrompt:c,state:F.current,...x&&{ragFilters:x}}}}),sendAutomaticallyWhen:bn.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{St.forEach(P=>{P.role==="assistant"&&P.parts.forEach(C=>{if(!C.type?.startsWith("tool-")||C.state!=="input-available")return;const V=C.type.replace("tool-",""),I=C.toolCallId;if(ue.has(I))return;Tt(W=>new Set(W).add(I));const U=Qh(C.input);if(Xt.has(V)){const W=Rt.get(V);W?(async()=>{try{const ot=pt.find(Jt=>Jt.name===V);let Nt;if(ot&&ot.jsonSchema?.properties){const jt=Object.keys(ot.jsonSchema.properties).map(Oe=>U[Oe]);Nt=await W(...jt)}else if(V==="getState")Nt=W();else if(V==="setState"){const Jt=U.updates||U;Nt=await W(Jt)}else Nt=await W(...Object.values(U));pe({toolCallId:I,tool:V,output:Nt})}catch(ot){console.error(`[useAgent] Error executing tool ${V}:`,ot),pe({toolCallId:I,tool:V,output:`Error: ${ot}`})}})():console.warn(`[useAgent] Tool ${V} not found in toolsMap`)}else f&&f({toolCall:{toolCallId:I,toolName:V,args:U}})})})},[St,Xt,Rt,f,pe,ue,Ht,pt]),m.useEffect(()=>{if(qt==="ready"&&St.length>0&&g){const P=St[St.length-1];P&&P.role==="assistant"&&g({message:P,messages:St,isAbort:!1,isDisconnect:!1,isError:!!me})}},[qt,St,me,g]);async function ge(){if(!(!i?.id||!v)){z(!0);try{const C=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${v}`}})).json();R(C.conversations||[])}catch(P){console.error("Failed to fetch conversations:",P)}finally{z(!1)}}}m.useEffect(()=>{i?.id&&v&&ge()},[JSON.stringify(i),v,t]),m.useEffect(()=>{if(!B||!y.current)return;(async()=>{ut(!0),ht(null);try{const C=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:B},format:"json"})});if(!C.ok){const ot=await C.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${C.status} ${ot}`)}const I=(await C.json())?.value||{},U=!Vt.current;let W;U?(W={...d,...I},Vt.current=!0):W=I,F.current=W,Bt(W)}catch(C){console.error("Failed to fetch state:",C);const V=C instanceof Error?C:new Error(String(C));ht(V),Vt.current||(F.current=d,Bt(d),Vt.current=!0)}finally{ut(!1)}})()},[B,t]);async function ye(P){Y(P),z(!0);try{const C=await fetch(`${t}/conversations/${P}/messages`,{headers:{Authorization:`Bearer ${y.current}`}});if(!C.ok)throw new Error(`Failed to fetch messages: ${C.statusText}`);const I=(await C.json()).messages||[];Yt(I)}catch(C){console.error("Failed to load conversation messages:",C)}finally{z(!1)}}async function Ie(P){if(v)try{await fetch(`${t}/conversations/${P}`,{method:"DELETE",headers:{Authorization:`Bearer ${v}`}}),R(O.filter(C=>C._id!==P)),P===B&&Le()}catch(C){console.error("Failed to delete conversation:",C)}}function Le(){const P=crypto.randomUUID();Y(P),Yt([]),Tt(new Set),F.current=d,Bt(d),Vt.current=!1}function Vn(P){pe(P)}async function Rn(P){const C={...F.current,...P};F.current=C,Bt(C);try{await yt(P)}catch(V){throw V}}async function Nn(){if(!i?.id||!y.current)throw new Error("User authentication required to share state");const P=`shared_${crypto.randomUUID()}`;try{return await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:create",args:{stateId:P,state:F.current,projectId:"default",createdBy:i.id},format:"json"})}),P}catch(C){throw console.error("Failed to share state:",C),C}}async function xe(P){if(!y.current)throw new Error("Authentication required to import state");try{const C=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:getByStateId",args:{stateId:P},format:"json"})});if(!C.ok)throw new Error("Failed to fetch shared state");const I=(await C.json())?.value||{};F.current=I,Bt(I)}catch(C){throw console.error("Failed to import state:",C),C}}return{id:B,messages:St,status:qt,error:me,sendMessage:Ne,stop:Dn,addToolOutput:Vn,setMessages:Yt,conversations:O,loadConversation:ye,deleteConversation:Ie,startNewConversation:Le,isLoadingConversations:tt,clientToken:v,tokenError:w,state:rt,setState:Rn,shareState:Nn,importState:xe,isStateLoading:lt,stateError:dt}}exports.verifyToken=Ja.verifyToken;exports.ARCTEN_ORIGINAL_NAME=kt;exports.ArctenAgent=Zh;exports.preserveToolName=Lh;exports.useAgent=tf;