@arcteninc/core 0.0.55 → 0.0.56
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/components/ArctenAgent.d.ts.map +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.mjs +1630 -1605
- package/dist/lib/useAgent.d.ts.map +1 -1
- package/package.json +1 -1
- package/scripts/cli-extract-types-auto.js +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var va=Object.create;var Xs=Object.defineProperty;var ba=Object.getOwnPropertyDescriptor;var wa=Object.getOwnPropertyNames;var Ta=Object.getPrototypeOf,Sa=Object.prototype.hasOwnProperty;var Ca=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of wa(e))!Sa.call(t,i)&&i!==n&&Xs(t,i,{get:()=>e[i],enumerable:!(s=ba(e,i))||s.enumerable});return t};var Aa=(t,e,n)=>(n=t!=null?va(Ta(t)):{},Ca(e||!t||!t.__esModule?Xs(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"),ho=require("@ai-sdk/react"),qe=require("ai"),fo=require("@radix-ui/react-slot"),mo=require("class-variance-authority"),Pa=require("clsx"),Ma=require("tailwind-merge"),ja=require("@radix-ui/react-tooltip"),Gs=require("@radix-ui/react-use-controllable-state"),Ea=require("@radix-ui/react-collapsible"),Da=require("./server.cjs");function Jn(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 ft=Jn(m),ie=Jn(ja),Qn=Jn(Ea);function tt(...t){return Ma.twMerge(Pa.clsx(t))}const _t=mo.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",{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"}}),Ze=ft.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},r)=>{const o=s?fo.Slot:"button";return h.jsx(o,{ref:r,"data-slot":"button",className:tt(_t({variant:e,size:n,className:t})),...i})});Ze.displayName="Button";const Va=mo.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?fo.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:tt(Va({variant:e}),t),...s})}const ka=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,r]=ft.useState(!0);ft.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),r(!1)),a.style.height=`${s+6}px`;const l=a.scrollHeight;l>n?a.style.height=`${n}px`:a.style.height=`${l+6}px`}},[t.current,e])},po=ft.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...r},o)=>{const a=ft.useRef(null),[l,u]=ft.useState("");return ka({textAreaRef:a,triggerAutoSize:l,maxHeight:t,minHeight:e}),m.useImperativeHandle(o,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),ft.useEffect(()=>{u(i)},[r?.defaultValue,i]),h.jsx("textarea",{...r,value:i,ref:a,className:tt("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:c=>{u(c.target.value),s?.(c)}})});po.displayName="AutosizeTextarea";function Ra({delayDuration:t=0,...e}){return h.jsx(ie.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Bt({...t}){return h.jsx(Ra,{children:h.jsx(ie.Root,{"data-slot":"tooltip",...t})})}function $t({...t}){return h.jsx(ie.Trigger,{"data-slot":"tooltip-trigger",...t})}function zt({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(ie.Portal,{children:h.jsxs(ie.Content,{"data-slot":"tooltip-content",sideOffset:e,className:tt("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(ie.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Ys({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:tt("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 ts=m.createContext({});function es(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const ns=typeof window<"u",go=ns?m.useLayoutEffect:m.useEffect,sn=m.createContext(null);function ss(t,e){t.indexOf(e)===-1&&t.push(e)}function is(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const St=(t,e,n)=>n>e?e:n<t?t:n;function En(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let le=()=>{},Ct=()=>{};process.env.NODE_ENV!=="production"&&(le=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(En(e,n))},Ct=(t,e,n)=>{if(!t)throw new Error(En(e,n))});const At={},yo=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function xo(t){return typeof t=="object"&&t!==null}const vo=t=>/^0[^.\s]+$/u.test(t);function os(t){let e;return()=>(e===void 0&&(e=t()),e)}const ut=t=>t,Na=(t,e)=>n=>e(t(n)),Ve=(...t)=>t.reduce(Na),Ae=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class rs{constructor(){this.subscriptions=[]}add(e){return ss(this.subscriptions,e),()=>is(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 r=0;r<i;r++){const o=this.subscriptions[r];o&&o(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const mt=t=>t*1e3,ct=t=>t/1e3;function bo(t,e){return e?t*(1e3/e):0}const qs=new Set;function as(t,e,n){t||qs.has(e)||(console.warn(En(e,n)),qs.add(e))}const wo=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Ia=1e-7,La=12;function Oa(t,e,n,s,i){let r,o,a=0;do o=e+(n-e)/2,r=wo(o,s,i)-t,r>0?n=o:e=o;while(Math.abs(r)>Ia&&++a<La);return o}function ke(t,e,n,s){if(t===e&&n===s)return ut;const i=r=>Oa(r,0,1,t,n);return r=>r===0||r===1?r:wo(i(r),e,s)}const To=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,So=t=>e=>1-t(1-e),Co=ke(.33,1.53,.69,.99),ls=So(Co),Ao=To(ls),Po=t=>(t*=2)<1?.5*ls(t):.5*(2-Math.pow(2,-10*(t-1))),cs=t=>1-Math.sin(Math.acos(t)),Mo=So(cs),jo=To(cs),Fa=ke(.42,0,1,1),Ba=ke(0,0,.58,1),Eo=ke(.42,0,.58,1),$a=t=>Array.isArray(t)&&typeof t[0]!="number",Do=t=>Array.isArray(t)&&typeof t[0]=="number",Zs={linear:ut,easeIn:Fa,easeInOut:Eo,easeOut:Ba,circIn:cs,circInOut:jo,circOut:Mo,backIn:ls,backInOut:Ao,backOut:Co,anticipate:Po},za=t=>typeof t=="string",Js=t=>{if(Do(t)){Ct(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return ke(e,n,s,i)}else if(za(t))return Ct(Zs[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Zs[t];return t},$e=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Ua(t,e){let n=new Set,s=new Set,i=!1,r=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(c){o.has(c)&&(u.schedule(c),t()),c(a)}const u={schedule:(c,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&o.add(c),y.has(c)||y.add(c),c},cancel:c=>{s.delete(c),o.delete(c)},process:c=>{if(a=c,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,u.process(c))}};return u}const _a=40;function Vo(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=$e.reduce((b,k)=>(b[k]=Ua(r),b),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:c,update:d,preRender:f,render:g,postRender:y}=o,v=()=>{const b=At.useManualTiming?i.timestamp:performance.now();n=!1,At.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(b-i.timestamp,_a),1)),i.timestamp=b,i.isProcessing=!0,a.process(i),l.process(i),u.process(i),c.process(i),d.process(i),f.process(i),g.process(i),y.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},w=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:$e.reduce((b,k)=>{const A=o[k];return b[k]=(D,N=!1,P=!1)=>(n||w(),A.schedule(D,N,P)),b},{}),cancel:b=>{for(let k=0;k<$e.length;k++)o[$e[k]].cancel(b)},state:i,steps:o}}const{schedule:B,cancel:Vt,state:Q,steps:mn}=Vo(typeof requestAnimationFrame<"u"?requestAnimationFrame:ut,!0);let Ke;function Wa(){Ke=void 0}const it={now:()=>(Ke===void 0&&it.set(Q.isProcessing||At.useManualTiming?Q.timestamp:performance.now()),Ke),set:t=>{Ke=t,queueMicrotask(Wa)}},ko=t=>e=>typeof e=="string"&&e.startsWith(t),us=ko("--"),Ka=ko("var(--"),ds=t=>Ka(t)?Ha.test(t.split("/*")[0].trim()):!1,Ha=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ce={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Pe={...ce,transform:t=>St(0,1,t)},ze={...ce,default:1},we=t=>Math.round(t*1e5)/1e5,hs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Xa(t){return t==null}const Ga=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,fs=(t,e)=>n=>!!(typeof n=="string"&&Ga.test(n)&&n.startsWith(t)||e&&!Xa(n)&&Object.prototype.hasOwnProperty.call(n,e)),Ro=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(hs);return{[t]:parseFloat(i),[e]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Ya=t=>St(0,255,t),pn={...ce,transform:t=>Math.round(Ya(t))},Kt={test:fs("rgb","red"),parse:Ro("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+pn.transform(t)+", "+pn.transform(e)+", "+pn.transform(n)+", "+we(Pe.transform(s))+")"};function qa(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 Dn={test:fs("#"),parse:qa,transform:Kt.transform},Re=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Dt=Re("deg"),wt=Re("%"),E=Re("px"),Za=Re("vh"),Ja=Re("vw"),Qs={...wt,parse:t=>wt.parse(t)/100,transform:t=>wt.transform(t*100)},Jt={test:fs("hsl","hue"),parse:Ro("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+wt.transform(we(e))+", "+wt.transform(we(n))+", "+we(Pe.transform(s))+")"},G={test:t=>Kt.test(t)||Dn.test(t)||Jt.test(t),parse:t=>Kt.test(t)?Kt.parse(t):Jt.test(t)?Jt.parse(t):Dn.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Kt.transform(t):Jt.transform(t),getAnimatableNone:t=>{const e=G.parse(t);return e.alpha=0,G.transform(e)}},Qa=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function tl(t){return isNaN(t)&&typeof t=="string"&&(t.match(hs)?.length||0)+(t.match(Qa)?.length||0)>0}const No="number",Io="color",el="var",nl="var(",ti="${}",sl=/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 Me(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=e.replace(sl,l=>(G.test(l)?(s.color.push(r),i.push(Io),n.push(G.parse(l))):l.startsWith(nl)?(s.var.push(r),i.push(el),n.push(l)):(s.number.push(r),i.push(No),n.push(parseFloat(l))),++r,ti)).split(ti);return{values:n,split:a,indexes:s,types:i}}function Lo(t){return Me(t).values}function Oo(t){const{split:e,types:n}=Me(t),s=e.length;return i=>{let r="";for(let o=0;o<s;o++)if(r+=e[o],i[o]!==void 0){const a=n[o];a===No?r+=we(i[o]):a===Io?r+=G.transform(i[o]):r+=i[o]}return r}}const il=t=>typeof t=="number"?0:G.test(t)?G.getAnimatableNone(t):t;function ol(t){const e=Lo(t);return Oo(t)(e.map(il))}const kt={test:tl,parse:Lo,createTransformer:Oo,getAnimatableNone:ol};function gn(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 rl({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,r=0,o=0;if(!e)i=r=o=n;else{const a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;i=gn(l,a,t+1/3),r=gn(l,a,t),o=gn(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Je(t,e){return n=>n>0?e:t}const z=(t,e,n)=>t+(e-t)*n,yn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},al=[Dn,Kt,Jt],ll=t=>al.find(e=>e.test(t));function ei(t){const e=ll(t);if(le(!!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===Jt&&(n=rl(n)),n}const ni=(t,e)=>{const n=ei(t),s=ei(e);if(!n||!s)return Je(t,e);const i={...n};return r=>(i.red=yn(n.red,s.red,r),i.green=yn(n.green,s.green,r),i.blue=yn(n.blue,s.blue,r),i.alpha=z(n.alpha,s.alpha,r),Kt.transform(i))},Vn=new Set(["none","hidden"]);function cl(t,e){return Vn.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function ul(t,e){return n=>z(t,e,n)}function ms(t){return typeof t=="number"?ul:typeof t=="string"?ds(t)?Je:G.test(t)?ni:fl:Array.isArray(t)?Fo:typeof t=="object"?G.test(t)?ni:dl:Je}function Fo(t,e){const n=[...t],s=n.length,i=t.map((r,o)=>ms(r)(r,e[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function dl(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=ms(t[i])(t[i],e[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function hl(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const r=e.types[i],o=t.indexes[r][s[r]],a=t.values[o]??0;n[i]=a,s[r]++}return n}const fl=(t,e)=>{const n=kt.createTransformer(e),s=Me(t),i=Me(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?Vn.has(t)&&!i.values.length||Vn.has(e)&&!s.values.length?cl(t,e):Ve(Fo(hl(s,i),i.values),n):(le(!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"),Je(t,e))};function Bo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?z(t,e,n):ms(t)(t,e)}const ml=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>B.update(e,n),stop:()=>Vt(e),now:()=>Q.isProcessing?Q.timestamp:it.now()}},$o=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let r=0;r<i;r++)s+=Math.round(t(r/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Qe=2e4;function ps(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Qe;)e+=n,s=t.next(e);return e>=Qe?1/0:e}function pl(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(ps(s),Qe);return{type:"keyframes",ease:r=>s.next(i*r).value/e,duration:ct(i)}}const gl=5;function zo(t,e,n){const s=Math.max(e-gl,0);return bo(n-t(s),e-s)}const $={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},xn=.001;function yl({duration:t=$.duration,bounce:e=$.bounce,velocity:n=$.velocity,mass:s=$.mass}){let i,r;le(t<=mt($.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=St($.minDamping,$.maxDamping,o),t=St($.minDuration,$.maxDuration,ct(t)),o<1?(i=u=>{const c=u*o,d=c*t,f=c-n,g=kn(u,o),y=Math.exp(-d);return xn-f/g*y},r=u=>{const d=u*o*t,f=d*n+n,g=Math.pow(o,2)*Math.pow(u,2)*t,y=Math.exp(-d),v=kn(Math.pow(u,2),o);return(-i(u)+xn>0?-1:1)*((f-g)*y)/v}):(i=u=>{const c=Math.exp(-u*t),d=(u-n)*t+1;return-xn+c*d},r=u=>{const c=Math.exp(-u*t),d=(n-u)*(t*t);return c*d});const a=5/t,l=vl(i,r,a);if(t=mt(t),isNaN(l))return{stiffness:$.stiffness,damping:$.damping,duration:t};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:o*2*Math.sqrt(s*u),duration:t}}}const xl=12;function vl(t,e,n){let s=n;for(let i=1;i<xl;i++)s=s-t(s)/e(s);return s}function kn(t,e){return t*Math.sqrt(1-e*e)}const bl=["duration","bounce"],wl=["stiffness","damping","mass"];function si(t,e){return e.some(n=>t[n]!==void 0)}function Tl(t){let e={velocity:$.velocity,stiffness:$.stiffness,damping:$.damping,mass:$.mass,isResolvedFromDuration:!1,...t};if(!si(t,wl)&&si(t,bl))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*St(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:$.mass,stiffness:i,damping:r}}else{const n=yl(t);e={...e,...n,mass:$.mass},e.isResolvedFromDuration=!0}return e}function tn(t=$.visualDuration,e=$.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:l,damping:u,mass:c,duration:d,velocity:f,isResolvedFromDuration:g}=Tl({...n,velocity:-ct(n.velocity||0)}),y=f||0,v=u/(2*Math.sqrt(l*c)),w=o-r,x=ct(Math.sqrt(l/c)),C=Math.abs(w)<5;s||(s=C?$.restSpeed.granular:$.restSpeed.default),i||(i=C?$.restDelta.granular:$.restDelta.default);let b;if(v<1){const A=kn(x,v);b=D=>{const N=Math.exp(-v*x*D);return o-N*((y+v*x*w)/A*Math.sin(A*D)+w*Math.cos(A*D))}}else if(v===1)b=A=>o-Math.exp(-x*A)*(w+(y+x*w)*A);else{const A=x*Math.sqrt(v*v-1);b=D=>{const N=Math.exp(-v*x*D),P=Math.min(A*D,300);return o-N*((y+v*x*w)*Math.sinh(P)+A*w*Math.cosh(P))/A}}const k={calculatedDuration:g&&d||null,next:A=>{const D=b(A);if(g)a.done=A>=d;else{let N=A===0?y:0;v<1&&(N=A===0?mt(y):zo(b,A,D));const P=Math.abs(N)<=s,L=Math.abs(o-D)<=i;a.done=P&&L}return a.value=a.done?o:D,a},toString:()=>{const A=Math.min(ps(k),Qe),D=$o(N=>k.next(A*N).value,A,30);return A+"ms "+D},toTransition:()=>{}};return k}tn.applyToOptions=t=>{const e=pl(t,100,tn);return t.ease=e.ease,t.duration=mt(e.duration),t.type="keyframes",t};function Rn({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:u=.5,restSpeed:c}){const d=t[0],f={done:!1,value:d},g=P=>a!==void 0&&P<a||l!==void 0&&P>l,y=P=>a===void 0?l:l===void 0||Math.abs(a-P)<Math.abs(l-P)?a:l;let v=n*e;const w=d+v,x=o===void 0?w:o(w);x!==w&&(v=x-d);const C=P=>-v*Math.exp(-P/s),b=P=>x+C(P),k=P=>{const L=C(P),W=b(P);f.done=Math.abs(L)<=u,f.value=f.done?x:W};let A,D;const N=P=>{g(f.value)&&(A=P,D=tn({keyframes:[f.value,y(f.value)],velocity:zo(b,P,f.value),damping:i,stiffness:r,restDelta:u,restSpeed:c}))};return N(0),{calculatedDuration:null,next:P=>{let L=!1;return!D&&A===void 0&&(L=!0,k(P),N(P)),A!==void 0&&P>=A?D.next(P-A):(!L&&k(P),f)}}}function Sl(t,e,n){const s=[],i=n||At.mix||Bo,r=t.length-1;for(let o=0;o<r;o++){let a=i(t[o],t[o+1]);if(e){const l=Array.isArray(e)?e[o]||ut:e;a=Ve(l,a)}s.push(a)}return s}function Cl(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const r=t.length;if(Ct(r===e.length,"Both input and output ranges must be the same length","range-length"),r===1)return()=>e[0];if(r===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[r-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Sl(e,s,i),l=a.length,u=c=>{if(o&&c<t[0])return e[0];let d=0;if(l>1)for(;d<t.length-2&&!(c<t[d+1]);d++);const f=Ae(t[d],t[d+1],c);return a[d](f)};return n?c=>u(St(t[0],t[r-1],c)):u}function Al(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ae(0,e,s);t.push(z(n,1,i))}}function Pl(t){const e=[0];return Al(e,t.length-1),e}function Ml(t,e){return t.map(n=>n*e)}function jl(t,e){return t.map(()=>e||Eo).splice(0,t.length-1)}function Qt({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=$a(s)?s.map(Js):Js(s),r={done:!1,value:e[0]},o=Ml(n&&n.length===e.length?n:Pl(e),t),a=Cl(o,e,{ease:Array.isArray(i)?i:jl(e,i)});return{calculatedDuration:t,next:l=>(r.value=a(l),r.done=l>=t,r)}}const El=t=>t!==null;function gs(t,{repeat:e,repeatType:n="loop"},s,i=1){const r=t.filter(El),a=i<0||e&&n!=="loop"&&e%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const Dl={decay:Rn,inertia:Rn,tween:Qt,keyframes:Qt,spring:tn};function Uo(t){typeof t.type=="string"&&(t.type=Dl[t.type])}class ys{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 Vl=t=>t/100;class xs extends ys{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!==it.now()&&this.tick(it.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=Qt,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=e;let{keyframes:a}=e;const l=n||Qt;process.env.NODE_ENV!=="production"&&l!==Qt&&Ct(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Qt&&typeof a[0]!="number"&&(this.mixKeyframes=Ve(Vl,Bo(a[0],a[1])),a=[0,100]);const u=l({...e,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-o})),u.calculatedDuration===null&&(u.calculatedDuration=ps(u));const{calculatedDuration:c}=u;this.calculatedDuration=c,this.resolvedDuration=c+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:r,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:c,repeat:d,repeatType:f,repeatDelay:g,type:y,onUpdate:v,finalKeyframe:w}=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 x=this.currentTime-u*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?x<0:x>i;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let b=this.currentTime,k=s;if(d){const P=Math.min(this.currentTime,i)/a;let L=Math.floor(P),W=P%1;!W&&P>=1&&(W=1),W===1&&L--,L=Math.min(L,d+1),!!(L%2)&&(f==="reverse"?(W=1-W,g&&(W-=g/a)):f==="mirror"&&(k=o)),b=St(0,1,W)*a}const A=C?{done:!1,value:c[0]}:k.next(b);r&&(A.value=r(A.value));let{done:D}=A;!C&&l!==null&&(D=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const N=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&D);return N&&y!==Rn&&(A.value=gs(c,this.options,w,this.speed)),v&&v(A.value),N&&this.finish(),A}then(e,n){return this.finished.then(e,n)}get duration(){return ct(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ct(e)}get time(){return ct(this.currentTime)}set time(e){e=mt(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(it.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=ct(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=ml,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(it.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 kl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Ht=t=>t*180/Math.PI,Nn=t=>{const e=Ht(Math.atan2(t[1],t[0]));return In(e)},Rl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Nn,rotateZ:Nn,skewX:t=>Ht(Math.atan(t[1])),skewY:t=>Ht(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},In=t=>(t=t%360,t<0&&(t+=360),t),ii=Nn,oi=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),ri=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Nl={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:oi,scaleY:ri,scale:t=>(oi(t)+ri(t))/2,rotateX:t=>In(Ht(Math.atan2(t[6],t[5]))),rotateY:t=>In(Ht(Math.atan2(-t[2],t[0]))),rotateZ:ii,rotate:ii,skewX:t=>Ht(Math.atan(t[4])),skewY:t=>Ht(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Ln(t){return t.includes("scale")?1:0}function On(t,e){if(!t||t==="none")return Ln(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=Nl,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Rl,i=a}if(!i)return Ln(e);const r=s[e],o=i[1].split(",").map(Ll);return typeof r=="function"?r(o):o[r]}const Il=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return On(n,e)};function Ll(t){return parseFloat(t.trim())}const ue=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],de=new Set(ue),ai=t=>t===ce||t===E,Ol=new Set(["x","y","z"]),Fl=ue.filter(t=>!Ol.has(t));function Bl(t){const e=[];return Fl.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const Xt={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})=>On(e,"x"),y:(t,{transform:e})=>On(e,"y")};Xt.translateX=Xt.x;Xt.translateY=Xt.y;const Gt=new Set;let Fn=!1,Bn=!1,$n=!1;function _o(){if(Bn){const t=Array.from(Gt).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=Bl(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(([r,o])=>{s.getValue(r)?.set(o)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}Bn=!1,Fn=!1,Gt.forEach(t=>t.complete($n)),Gt.clear()}function Wo(){Gt.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Bn=!0)})}function $l(){$n=!0,Wo(),_o(),$n=!1}class vs{constructor(e,n,s,i,r,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=r,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Gt.add(this),Fn||(Fn=!0,B.read(Wo),B.resolveKeyframes(_o))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const r=i?.get(),o=e[e.length-1];if(r!==void 0)e[0]=r;else if(s&&n){const a=s.readValue(n,o);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=o),i&&r===void 0&&i.set(e[0])}kl(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Gt.delete(this)}cancel(){this.state==="scheduled"&&(Gt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const zl=t=>t.startsWith("--");function Ul(t,e,n){zl(e)?t.style.setProperty(e,n):t.style[e]=n}const _l=os(()=>window.ScrollTimeline!==void 0),Wl={};function Kl(t,e){const n=os(t);return()=>Wl[e]??n()}const Ko=Kl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),be=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,li={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:be([0,.65,.55,1]),circOut:be([.55,0,1,.45]),backIn:be([.31,.01,.66,-.59]),backOut:be([.33,1.53,.69,.99])};function Ho(t,e){if(t)return typeof t=="function"?Ko()?$o(t,e):"ease-out":Do(t)?be(t):Array.isArray(t)?t.map(n=>Ho(n,e)||li.easeOut):li[t]}function Hl(t,e,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},u=void 0){const c={[e]:n};l&&(c.offset=l);const d=Ho(a,i);Array.isArray(d)&&(c.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(c,f)}function Xo(t){return typeof t=="function"&&"applyToOptions"in t}function Xl({type:t,...e}){return Xo(t)&&Ko()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Gl extends ys{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:r,allowFlatten:o=!1,finalKeyframe:a,onComplete:l}=e;this.isPseudoElement=!!r,this.allowFlatten=o,this.options=e,Ct(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=Xl(e);this.animation=Hl(n,s,i,u,r),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const c=gs(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(c):Ul(n,s,c),this.animation.cancel()}l?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state: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 ct(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ct(e)}get time(){return ct(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=mt(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&&_l()?(this.animation.timeline=e,ut):n(this)}}const Go={anticipate:Po,backInOut:Ao,circInOut:jo};function Yl(t){return t in Go}function ql(t){typeof t.ease=="string"&&Yl(t.ease)&&(t.ease=Go[t.ease])}const ci=10;class Zl extends Gl{constructor(e){ql(e),Uo(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:r,...o}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new xs({...o,autoplay:!1}),l=mt(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-ci).value,a.sample(l).value,ci),a.stop()}}const ui=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(kt.test(t)||t==="0")&&!t.startsWith("url("));function Jl(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 Ql(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const r=t[t.length-1],o=ui(i,e),a=ui(r,e);return le(o===a,`You are trying to animate ${e} from "${i}" to "${r}". "${o?r:i}" is not an animatable value.`,"value-not-animatable"),!o||!a?!1:Jl(t)||(n==="spring"||Xo(n))&&s}function zn(t){t.duration=0,t.type="keyframes"}const tc=new Set(["opacity","clipPath","filter","transform"]),ec=os(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function nc(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:r,type:o}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=e.owner.getProps();return ec()&&n&&tc.has(n)&&(n!=="transform"||!u)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const sc=40;class ic extends ys{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:u,element:c,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=it.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,name:l,motionValue:u,element:c,...d},g=c?.KeyframeResolver||vs;this.keyframeResolver=new g(a,(y,v,w)=>this.onKeyframesResolved(y,v,f,!w),l,u,c),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:u,onUpdate:c}=s;this.resolvedAt=it.now(),Ql(e,r,o,a)||((At.instantAnimations||!l)&&c?.(gs(e,s,n)),e[0]=e[e.length-1],zn(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>sc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&nc(f)?new Zl({...f,element:f.motionValue.owner.current}):new xs(f);g.finished.then(()=>this.notifyFinished()).catch(ut),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(),$l()),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 oc=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function rc(t){const e=oc.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const ac=4;function Yo(t,e,n=1){Ct(n<=ac,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=rc(t);if(!s)return;const r=window.getComputedStyle(e).getPropertyValue(s);if(r){const o=r.trim();return yo(o)?parseFloat(o):o}return ds(i)?Yo(i,e,n+1):i}function bs(t,e){return t?.[e]??t?.default??t}const qo=new Set(["width","height","top","left","right","bottom",...ue]),lc={test:t=>t==="auto",parse:t=>t},Zo=t=>e=>e.test(t),Jo=[ce,E,wt,Dt,Ja,Za,lc],di=t=>Jo.find(Zo(t));function cc(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||vo(t):!0}const uc=new Set(["brightness","contrast","saturate","opacity"]);function dc(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(hs)||[];if(!s)return t;const i=n.replace(s,"");let r=uc.has(e)?1:0;return s!==n&&(r*=100),e+"("+r+i+")"}const hc=/\b([a-z-]*)\(.*?\)/gu,Un={...kt,getAnimatableNone:t=>{const e=t.match(hc);return e?e.map(dc).join(" "):t}},hi={...ce,transform:Math.round},fc={rotate:Dt,rotateX:Dt,rotateY:Dt,rotateZ:Dt,scale:ze,scaleX:ze,scaleY:ze,scaleZ:ze,skew:Dt,skewX:Dt,skewY:Dt,distance:E,translateX:E,translateY:E,translateZ:E,x:E,y:E,z:E,perspective:E,transformPerspective:E,opacity:Pe,originX:Qs,originY:Qs,originZ:E},ws={borderWidth:E,borderTopWidth:E,borderRightWidth:E,borderBottomWidth:E,borderLeftWidth:E,borderRadius:E,radius:E,borderTopLeftRadius:E,borderTopRightRadius:E,borderBottomRightRadius:E,borderBottomLeftRadius:E,width:E,maxWidth:E,height:E,maxHeight:E,top:E,right:E,bottom:E,left:E,padding:E,paddingTop:E,paddingRight:E,paddingBottom:E,paddingLeft:E,margin:E,marginTop:E,marginRight:E,marginBottom:E,marginLeft:E,backgroundPositionX:E,backgroundPositionY:E,...fc,zIndex:hi,fillOpacity:Pe,strokeOpacity:Pe,numOctaves:hi},mc={...ws,color:G,backgroundColor:G,outlineColor:G,fill:G,stroke:G,borderColor:G,borderTopColor:G,borderRightColor:G,borderBottomColor:G,borderLeftColor:G,filter:Un,WebkitFilter:Un},Qo=t=>mc[t];function tr(t,e){let n=Qo(t);return n!==Un&&(n=kt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const pc=new Set(["auto","none","0"]);function gc(t,e,n){let s=0,i;for(;s<t.length&&!i;){const r=t[s];typeof r=="string"&&!pc.has(r)&&Me(r).values.length&&(i=t[s]),s++}if(i&&n)for(const r of e)t[r]=tr(n,i)}class yc extends vs{constructor(e,n,s,i,r){super(e,n,s,i,r,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<e.length;l++){let u=e[l];if(typeof u=="string"&&(u=u.trim(),ds(u))){const c=Yo(u,n.current);c!==void 0&&(e[l]=c),l===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!qo.has(s)||e.length!==2)return;const[i,r]=e,o=di(i),a=di(r);if(o!==a)if(ai(o)&&ai(a))for(let l=0;l<e.length;l++){const u=e[l];typeof u=="string"&&(e[l]=parseFloat(u))}else Xt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||cc(e[i]))&&s.push(i);s.length&&gc(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=Xt[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 r=s.length-1,o=s[r];s[r]=Xt[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{e.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function xc(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 er=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function nr(t){return xo(t)&&"offsetHeight"in t}const fi=30,vc=t=>!isNaN(parseFloat(t));class bc{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=it.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 r of this.dependents)r.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=it.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=vc(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&as(!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 rs);const s=this.events[e].add(n);return e==="change"?()=>{s(),B.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=it.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>fi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,fi);return bo(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 re(t,e){return new bc(t,e)}const{schedule:Ts}=Vo(queueMicrotask,!1),ht={x:!1,y:!1};function sr(){return ht.x||ht.y}function wc(t){return t==="x"||t==="y"?ht[t]?null:(ht[t]=!0,()=>{ht[t]=!1}):ht.x||ht.y?null:(ht.x=ht.y=!0,()=>{ht.x=ht.y=!1})}function ir(t,e){const n=xc(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function mi(t){return!(t.pointerType==="touch"||sr())}function Tc(t,e,n={}){const[s,i,r]=ir(t,n),o=a=>{if(!mi(a))return;const{target:l}=a,u=e(l,a);if(typeof u!="function"||!l)return;const c=d=>{mi(d)&&(u(d),l.removeEventListener("pointerleave",c))};l.addEventListener("pointerleave",c,i)};return s.forEach(a=>{a.addEventListener("pointerenter",o,i)}),r}const or=(t,e)=>e?t===e?!0:or(t,e.parentElement):!1,Ss=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Sc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Cc(t){return Sc.has(t.tagName)||t.tabIndex!==-1}const He=new WeakSet;function pi(t){return e=>{e.key==="Enter"&&t(e)}}function vn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Ac=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=pi(()=>{if(He.has(n))return;vn(n,"down");const i=pi(()=>{vn(n,"up")}),r=()=>vn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",r,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function gi(t){return Ss(t)&&!sr()}function Pc(t,e,n={}){const[s,i,r]=ir(t,n),o=a=>{const l=a.currentTarget;if(!gi(a))return;He.add(l);const u=e(l,a),c=(g,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),He.has(l)&&He.delete(l),gi(g)&&typeof u=="function"&&u(g,{success:y})},d=g=>{c(g,l===window||l===document||n.useGlobalTarget||or(l,g.target))},f=g=>{c(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),nr(a)&&(a.addEventListener("focus",u=>Ac(u,i)),!Cc(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function rr(t){return xo(t)&&"ownerSVGElement"in t}function Mc(t){return rr(t)&&t.tagName==="svg"}const nt=t=>!!(t&&t.getVelocity),jc=[...Jo,G,kt],Ec=t=>jc.find(Zo(t)),Cs=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function yi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Dc(...t){return e=>{let n=!1;const s=t.map(i=>{const r=yi(i,e);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<s.length;i++){const r=s[i];typeof r=="function"?r():yi(t[i],null)}}}}function Vc(...t){return ft.useCallback(Dc(...t),t)}class kc extends ft.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=nr(s)&&s.offsetWidth||0,r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft,r.right=i-r.width-r.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Rc({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),r=m.useRef(null),o=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Cs),l=Vc(r,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:c,top:d,left:f,right:g}=o.current;if(e||!r.current||!u||!c)return;const y=n==="left"?`left: ${f}`:`right: ${g}`;r.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const w=s??document.head;return w.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
1
|
+
"use strict";var Ta=Object.create;var qs=Object.defineProperty;var Sa=Object.getOwnPropertyDescriptor;var Ca=Object.getOwnPropertyNames;var Aa=Object.getPrototypeOf,Pa=Object.prototype.hasOwnProperty;var Ma=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ca(e))!Pa.call(t,i)&&i!==n&&qs(t,i,{get:()=>e[i],enumerable:!(s=Sa(e,i))||s.enumerable});return t};var ja=(t,e,n)=>(n=t!=null?Ta(Aa(t)):{},Ma(e||!t||!t.__esModule?qs(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"),po=require("@ai-sdk/react"),Ze=require("ai"),go=require("@radix-ui/react-slot"),yo=require("class-variance-authority"),Ea=require("clsx"),Da=require("tailwind-merge"),Va=require("@radix-ui/react-tooltip"),Js=require("@radix-ui/react-use-controllable-state"),ka=require("@radix-ui/react-collapsible"),Ra=require("./server.cjs");function es(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 ft=es(m),ie=es(Va),ns=es(ka);function Q(...t){return Da.twMerge(Ea.clsx(t))}const _t=yo.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",{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"}}),Qe=ft.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},r)=>{const o=s?go.Slot:"button";return h.jsx(o,{ref:r,"data-slot":"button",className:Q(_t({variant:e,size:n,className:t})),...i})});Qe.displayName="Button";const Na=yo.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 pn({className:t,variant:e,asChild:n=!1,...s}){const i=n?go.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:Q(Na({variant:e}),t),...s})}const Ia=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,r]=ft.useState(!0);ft.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),r(!1)),a.style.height=`${s+6}px`;const l=a.scrollHeight;l>n?a.style.height=`${n}px`:a.style.height=`${l+6}px`}},[t.current,e])},xo=ft.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...r},o)=>{const a=ft.useRef(null),[l,u]=ft.useState("");return Ia({textAreaRef:a,triggerAutoSize:l,maxHeight:t,minHeight:e}),m.useImperativeHandle(o,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),ft.useEffect(()=>{u(i)},[r?.defaultValue,i]),h.jsx("textarea",{...r,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:c=>{u(c.target.value),s?.(c)}})});xo.displayName="AutosizeTextarea";function La({delayDuration:t=0,...e}){return h.jsx(ie.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Bt({...t}){return h.jsx(La,{children:h.jsx(ie.Root,{"data-slot":"tooltip",...t})})}function $t({...t}){return h.jsx(ie.Trigger,{"data-slot":"tooltip-trigger",...t})}function zt({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(ie.Portal,{children:h.jsxs(ie.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(ie.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Zs({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 ss=m.createContext({});function is(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const os=typeof window<"u",vo=os?m.useLayoutEffect:m.useEffect,rn=m.createContext(null);function rs(t,e){t.indexOf(e)===-1&&t.push(e)}function as(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Ct=(t,e,n)=>n>e?e:n<t?t:n;function kn(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let le=()=>{},At=()=>{};process.env.NODE_ENV!=="production"&&(le=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(kn(e,n))},At=(t,e,n)=>{if(!t)throw new Error(kn(e,n))});const Pt={},bo=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function wo(t){return typeof t=="object"&&t!==null}const To=t=>/^0[^.\s]+$/u.test(t);function ls(t){let e;return()=>(e===void 0&&(e=t()),e)}const ut=t=>t,Oa=(t,e)=>n=>e(t(n)),Re=(...t)=>t.reduce(Oa),Me=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class cs{constructor(){this.subscriptions=[]}add(e){return rs(this.subscriptions,e),()=>as(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 r=0;r<i;r++){const o=this.subscriptions[r];o&&o(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const mt=t=>t*1e3,ct=t=>t/1e3;function So(t,e){return e?t*(1e3/e):0}const Qs=new Set;function us(t,e,n){t||Qs.has(e)||(console.warn(kn(e,n)),Qs.add(e))}const Co=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Fa=1e-7,Ba=12;function $a(t,e,n,s,i){let r,o,a=0;do o=e+(n-e)/2,r=Co(o,s,i)-t,r>0?n=o:e=o;while(Math.abs(r)>Fa&&++a<Ba);return o}function Ne(t,e,n,s){if(t===e&&n===s)return ut;const i=r=>$a(r,0,1,t,n);return r=>r===0||r===1?r:Co(i(r),e,s)}const Ao=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Po=t=>e=>1-t(1-e),Mo=Ne(.33,1.53,.69,.99),ds=Po(Mo),jo=Ao(ds),Eo=t=>(t*=2)<1?.5*ds(t):.5*(2-Math.pow(2,-10*(t-1))),hs=t=>1-Math.sin(Math.acos(t)),Do=Po(hs),Vo=Ao(hs),za=Ne(.42,0,1,1),Ua=Ne(0,0,.58,1),ko=Ne(.42,0,.58,1),_a=t=>Array.isArray(t)&&typeof t[0]!="number",Ro=t=>Array.isArray(t)&&typeof t[0]=="number",ti={linear:ut,easeIn:za,easeInOut:ko,easeOut:Ua,circIn:hs,circInOut:Vo,circOut:Do,backIn:ds,backInOut:jo,backOut:Mo,anticipate:Eo},Wa=t=>typeof t=="string",ei=t=>{if(Ro(t)){At(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return Ne(e,n,s,i)}else if(Wa(t))return At(ti[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),ti[t];return t},Ue=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Ka(t,e){let n=new Set,s=new Set,i=!1,r=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(c){o.has(c)&&(u.schedule(c),t()),c(a)}const u={schedule:(c,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&o.add(c),y.has(c)||y.add(c),c},cancel:c=>{s.delete(c),o.delete(c)},process:c=>{if(a=c,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,u.process(c))}};return u}const Ha=40;function No(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Ue.reduce((b,k)=>(b[k]=Ka(r),b),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:c,update:d,preRender:f,render:g,postRender:y}=o,v=()=>{const b=Pt.useManualTiming?i.timestamp:performance.now();n=!1,Pt.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(b-i.timestamp,Ha),1)),i.timestamp=b,i.isProcessing=!0,a.process(i),l.process(i),u.process(i),c.process(i),d.process(i),f.process(i),g.process(i),y.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},w=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:Ue.reduce((b,k)=>{const A=o[k];return b[k]=(D,N=!1,P=!1)=>(n||w(),A.schedule(D,N,P)),b},{}),cancel:b=>{for(let k=0;k<Ue.length;k++)o[Ue[k]].cancel(b)},state:i,steps:o}}const{schedule:B,cancel:kt,state:Z,steps:gn}=No(typeof requestAnimationFrame<"u"?requestAnimationFrame:ut,!0);let Xe;function Xa(){Xe=void 0}const st={now:()=>(Xe===void 0&&st.set(Z.isProcessing||Pt.useManualTiming?Z.timestamp:performance.now()),Xe),set:t=>{Xe=t,queueMicrotask(Xa)}},Io=t=>e=>typeof e=="string"&&e.startsWith(t),fs=Io("--"),Ga=Io("var(--"),ms=t=>Ga(t)?Ya.test(t.split("/*")[0].trim()):!1,Ya=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ce={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},je={...ce,transform:t=>Ct(0,1,t)},_e={...ce,default:1},Se=t=>Math.round(t*1e5)/1e5,ps=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function qa(t){return t==null}const Ja=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,gs=(t,e)=>n=>!!(typeof n=="string"&&Ja.test(n)&&n.startsWith(t)||e&&!qa(n)&&Object.prototype.hasOwnProperty.call(n,e)),Lo=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(ps);return{[t]:parseFloat(i),[e]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Za=t=>Ct(0,255,t),yn={...ce,transform:t=>Math.round(Za(t))},Kt={test:gs("rgb","red"),parse:Lo("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+yn.transform(t)+", "+yn.transform(e)+", "+yn.transform(n)+", "+Se(je.transform(s))+")"};function Qa(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 Rn={test:gs("#"),parse:Qa,transform:Kt.transform},Ie=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Vt=Ie("deg"),wt=Ie("%"),j=Ie("px"),tl=Ie("vh"),el=Ie("vw"),ni={...wt,parse:t=>wt.parse(t)/100,transform:t=>wt.transform(t*100)},Zt={test:gs("hsl","hue"),parse:Lo("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+wt.transform(Se(e))+", "+wt.transform(Se(n))+", "+Se(je.transform(s))+")"},G={test:t=>Kt.test(t)||Rn.test(t)||Zt.test(t),parse:t=>Kt.test(t)?Kt.parse(t):Zt.test(t)?Zt.parse(t):Rn.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Kt.transform(t):Zt.transform(t),getAnimatableNone:t=>{const e=G.parse(t);return e.alpha=0,G.transform(e)}},nl=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function sl(t){return isNaN(t)&&typeof t=="string"&&(t.match(ps)?.length||0)+(t.match(nl)?.length||0)>0}const Oo="number",Fo="color",il="var",ol="var(",si="${}",rl=/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 Ee(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=e.replace(rl,l=>(G.test(l)?(s.color.push(r),i.push(Fo),n.push(G.parse(l))):l.startsWith(ol)?(s.var.push(r),i.push(il),n.push(l)):(s.number.push(r),i.push(Oo),n.push(parseFloat(l))),++r,si)).split(si);return{values:n,split:a,indexes:s,types:i}}function Bo(t){return Ee(t).values}function $o(t){const{split:e,types:n}=Ee(t),s=e.length;return i=>{let r="";for(let o=0;o<s;o++)if(r+=e[o],i[o]!==void 0){const a=n[o];a===Oo?r+=Se(i[o]):a===Fo?r+=G.transform(i[o]):r+=i[o]}return r}}const al=t=>typeof t=="number"?0:G.test(t)?G.getAnimatableNone(t):t;function ll(t){const e=Bo(t);return $o(t)(e.map(al))}const Rt={test:sl,parse:Bo,createTransformer:$o,getAnimatableNone:ll};function xn(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 cl({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,r=0,o=0;if(!e)i=r=o=n;else{const a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;i=xn(l,a,t+1/3),r=xn(l,a,t),o=xn(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function tn(t,e){return n=>n>0?e:t}const z=(t,e,n)=>t+(e-t)*n,vn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},ul=[Rn,Kt,Zt],dl=t=>ul.find(e=>e.test(t));function ii(t){const e=dl(t);if(le(!!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===Zt&&(n=cl(n)),n}const oi=(t,e)=>{const n=ii(t),s=ii(e);if(!n||!s)return tn(t,e);const i={...n};return r=>(i.red=vn(n.red,s.red,r),i.green=vn(n.green,s.green,r),i.blue=vn(n.blue,s.blue,r),i.alpha=z(n.alpha,s.alpha,r),Kt.transform(i))},Nn=new Set(["none","hidden"]);function hl(t,e){return Nn.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function fl(t,e){return n=>z(t,e,n)}function ys(t){return typeof t=="number"?fl:typeof t=="string"?ms(t)?tn:G.test(t)?oi:gl:Array.isArray(t)?zo:typeof t=="object"?G.test(t)?oi:ml:tn}function zo(t,e){const n=[...t],s=n.length,i=t.map((r,o)=>ys(r)(r,e[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function ml(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=ys(t[i])(t[i],e[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function pl(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const r=e.types[i],o=t.indexes[r][s[r]],a=t.values[o]??0;n[i]=a,s[r]++}return n}const gl=(t,e)=>{const n=Rt.createTransformer(e),s=Ee(t),i=Ee(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?Nn.has(t)&&!i.values.length||Nn.has(e)&&!s.values.length?hl(t,e):Re(zo(pl(s,i),i.values),n):(le(!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 Uo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?z(t,e,n):ys(t)(t,e)}const yl=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>B.update(e,n),stop:()=>kt(e),now:()=>Z.isProcessing?Z.timestamp:st.now()}},_o=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let r=0;r<i;r++)s+=Math.round(t(r/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},en=2e4;function xs(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<en;)e+=n,s=t.next(e);return e>=en?1/0:e}function xl(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(xs(s),en);return{type:"keyframes",ease:r=>s.next(i*r).value/e,duration:ct(i)}}const vl=5;function Wo(t,e,n){const s=Math.max(e-vl,0);return So(n-t(s),e-s)}const $={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},bn=.001;function bl({duration:t=$.duration,bounce:e=$.bounce,velocity:n=$.velocity,mass:s=$.mass}){let i,r;le(t<=mt($.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=Ct($.minDamping,$.maxDamping,o),t=Ct($.minDuration,$.maxDuration,ct(t)),o<1?(i=u=>{const c=u*o,d=c*t,f=c-n,g=In(u,o),y=Math.exp(-d);return bn-f/g*y},r=u=>{const d=u*o*t,f=d*n+n,g=Math.pow(o,2)*Math.pow(u,2)*t,y=Math.exp(-d),v=In(Math.pow(u,2),o);return(-i(u)+bn>0?-1:1)*((f-g)*y)/v}):(i=u=>{const c=Math.exp(-u*t),d=(u-n)*t+1;return-bn+c*d},r=u=>{const c=Math.exp(-u*t),d=(n-u)*(t*t);return c*d});const a=5/t,l=Tl(i,r,a);if(t=mt(t),isNaN(l))return{stiffness:$.stiffness,damping:$.damping,duration:t};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:o*2*Math.sqrt(s*u),duration:t}}}const wl=12;function Tl(t,e,n){let s=n;for(let i=1;i<wl;i++)s=s-t(s)/e(s);return s}function In(t,e){return t*Math.sqrt(1-e*e)}const Sl=["duration","bounce"],Cl=["stiffness","damping","mass"];function ri(t,e){return e.some(n=>t[n]!==void 0)}function Al(t){let e={velocity:$.velocity,stiffness:$.stiffness,damping:$.damping,mass:$.mass,isResolvedFromDuration:!1,...t};if(!ri(t,Cl)&&ri(t,Sl))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*Ct(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:$.mass,stiffness:i,damping:r}}else{const n=bl(t);e={...e,...n,mass:$.mass},e.isResolvedFromDuration=!0}return e}function nn(t=$.visualDuration,e=$.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:l,damping:u,mass:c,duration:d,velocity:f,isResolvedFromDuration:g}=Al({...n,velocity:-ct(n.velocity||0)}),y=f||0,v=u/(2*Math.sqrt(l*c)),w=o-r,x=ct(Math.sqrt(l/c)),C=Math.abs(w)<5;s||(s=C?$.restSpeed.granular:$.restSpeed.default),i||(i=C?$.restDelta.granular:$.restDelta.default);let b;if(v<1){const A=In(x,v);b=D=>{const N=Math.exp(-v*x*D);return o-N*((y+v*x*w)/A*Math.sin(A*D)+w*Math.cos(A*D))}}else if(v===1)b=A=>o-Math.exp(-x*A)*(w+(y+x*w)*A);else{const A=x*Math.sqrt(v*v-1);b=D=>{const N=Math.exp(-v*x*D),P=Math.min(A*D,300);return o-N*((y+v*x*w)*Math.sinh(P)+A*w*Math.cosh(P))/A}}const k={calculatedDuration:g&&d||null,next:A=>{const D=b(A);if(g)a.done=A>=d;else{let N=A===0?y:0;v<1&&(N=A===0?mt(y):Wo(b,A,D));const P=Math.abs(N)<=s,L=Math.abs(o-D)<=i;a.done=P&&L}return a.value=a.done?o:D,a},toString:()=>{const A=Math.min(xs(k),en),D=_o(N=>k.next(A*N).value,A,30);return A+"ms "+D},toTransition:()=>{}};return k}nn.applyToOptions=t=>{const e=xl(t,100,nn);return t.ease=e.ease,t.duration=mt(e.duration),t.type="keyframes",t};function Ln({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:u=.5,restSpeed:c}){const d=t[0],f={done:!1,value:d},g=P=>a!==void 0&&P<a||l!==void 0&&P>l,y=P=>a===void 0?l:l===void 0||Math.abs(a-P)<Math.abs(l-P)?a:l;let v=n*e;const w=d+v,x=o===void 0?w:o(w);x!==w&&(v=x-d);const C=P=>-v*Math.exp(-P/s),b=P=>x+C(P),k=P=>{const L=C(P),W=b(P);f.done=Math.abs(L)<=u,f.value=f.done?x:W};let A,D;const N=P=>{g(f.value)&&(A=P,D=nn({keyframes:[f.value,y(f.value)],velocity:Wo(b,P,f.value),damping:i,stiffness:r,restDelta:u,restSpeed:c}))};return N(0),{calculatedDuration:null,next:P=>{let L=!1;return!D&&A===void 0&&(L=!0,k(P),N(P)),A!==void 0&&P>=A?D.next(P-A):(!L&&k(P),f)}}}function Pl(t,e,n){const s=[],i=n||Pt.mix||Uo,r=t.length-1;for(let o=0;o<r;o++){let a=i(t[o],t[o+1]);if(e){const l=Array.isArray(e)?e[o]||ut:e;a=Re(l,a)}s.push(a)}return s}function Ml(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const r=t.length;if(At(r===e.length,"Both input and output ranges must be the same length","range-length"),r===1)return()=>e[0];if(r===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[r-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Pl(e,s,i),l=a.length,u=c=>{if(o&&c<t[0])return e[0];let d=0;if(l>1)for(;d<t.length-2&&!(c<t[d+1]);d++);const f=Me(t[d],t[d+1],c);return a[d](f)};return n?c=>u(Ct(t[0],t[r-1],c)):u}function jl(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Me(0,e,s);t.push(z(n,1,i))}}function El(t){const e=[0];return jl(e,t.length-1),e}function Dl(t,e){return t.map(n=>n*e)}function Vl(t,e){return t.map(()=>e||ko).splice(0,t.length-1)}function Qt({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=_a(s)?s.map(ei):ei(s),r={done:!1,value:e[0]},o=Dl(n&&n.length===e.length?n:El(e),t),a=Ml(o,e,{ease:Array.isArray(i)?i:Vl(e,i)});return{calculatedDuration:t,next:l=>(r.value=a(l),r.done=l>=t,r)}}const kl=t=>t!==null;function vs(t,{repeat:e,repeatType:n="loop"},s,i=1){const r=t.filter(kl),a=i<0||e&&n!=="loop"&&e%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const Rl={decay:Ln,inertia:Ln,tween:Qt,keyframes:Qt,spring:nn};function Ko(t){typeof t.type=="string"&&(t.type=Rl[t.type])}class bs{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 Nl=t=>t/100;class ws extends bs{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!==st.now()&&this.tick(st.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;Ko(e);const{type:n=Qt,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=e;let{keyframes:a}=e;const l=n||Qt;process.env.NODE_ENV!=="production"&&l!==Qt&&At(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Qt&&typeof a[0]!="number"&&(this.mixKeyframes=Re(Nl,Uo(a[0],a[1])),a=[0,100]);const u=l({...e,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-o})),u.calculatedDuration===null&&(u.calculatedDuration=xs(u));const{calculatedDuration:c}=u;this.calculatedDuration=c,this.resolvedDuration=c+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:r,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:c,repeat:d,repeatType:f,repeatDelay:g,type:y,onUpdate:v,finalKeyframe:w}=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 x=this.currentTime-u*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?x<0:x>i;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let b=this.currentTime,k=s;if(d){const P=Math.min(this.currentTime,i)/a;let L=Math.floor(P),W=P%1;!W&&P>=1&&(W=1),W===1&&L--,L=Math.min(L,d+1),!!(L%2)&&(f==="reverse"?(W=1-W,g&&(W-=g/a)):f==="mirror"&&(k=o)),b=Ct(0,1,W)*a}const A=C?{done:!1,value:c[0]}:k.next(b);r&&(A.value=r(A.value));let{done:D}=A;!C&&l!==null&&(D=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const N=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&D);return N&&y!==Ln&&(A.value=vs(c,this.options,w,this.speed)),v&&v(A.value),N&&this.finish(),A}then(e,n){return this.finished.then(e,n)}get duration(){return ct(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ct(e)}get time(){return ct(this.currentTime)}set time(e){e=mt(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(st.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=ct(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=yl,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(st.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 Il(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Ht=t=>t*180/Math.PI,On=t=>{const e=Ht(Math.atan2(t[1],t[0]));return Fn(e)},Ll={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:On,rotateZ:On,skewX:t=>Ht(Math.atan(t[1])),skewY:t=>Ht(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Fn=t=>(t=t%360,t<0&&(t+=360),t),ai=On,li=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),ci=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Ol={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:li,scaleY:ci,scale:t=>(li(t)+ci(t))/2,rotateX:t=>Fn(Ht(Math.atan2(t[6],t[5]))),rotateY:t=>Fn(Ht(Math.atan2(-t[2],t[0]))),rotateZ:ai,rotate:ai,skewX:t=>Ht(Math.atan(t[4])),skewY:t=>Ht(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Bn(t){return t.includes("scale")?1:0}function $n(t,e){if(!t||t==="none")return Bn(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=Ol,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Ll,i=a}if(!i)return Bn(e);const r=s[e],o=i[1].split(",").map(Bl);return typeof r=="function"?r(o):o[r]}const Fl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return $n(n,e)};function Bl(t){return parseFloat(t.trim())}const ue=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],de=new Set(ue),ui=t=>t===ce||t===j,$l=new Set(["x","y","z"]),zl=ue.filter(t=>!$l.has(t));function Ul(t){const e=[];return zl.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const Xt={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})=>$n(e,"x"),y:(t,{transform:e})=>$n(e,"y")};Xt.translateX=Xt.x;Xt.translateY=Xt.y;const Gt=new Set;let zn=!1,Un=!1,_n=!1;function Ho(){if(Un){const t=Array.from(Gt).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=Ul(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(([r,o])=>{s.getValue(r)?.set(o)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}Un=!1,zn=!1,Gt.forEach(t=>t.complete(_n)),Gt.clear()}function Xo(){Gt.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Un=!0)})}function _l(){_n=!0,Xo(),Ho(),_n=!1}class Ts{constructor(e,n,s,i,r,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=r,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Gt.add(this),zn||(zn=!0,B.read(Xo),B.resolveKeyframes(Ho))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const r=i?.get(),o=e[e.length-1];if(r!==void 0)e[0]=r;else if(s&&n){const a=s.readValue(n,o);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=o),i&&r===void 0&&i.set(e[0])}Il(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Gt.delete(this)}cancel(){this.state==="scheduled"&&(Gt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Wl=t=>t.startsWith("--");function Kl(t,e,n){Wl(e)?t.style.setProperty(e,n):t.style[e]=n}const Hl=ls(()=>window.ScrollTimeline!==void 0),Xl={};function Gl(t,e){const n=ls(t);return()=>Xl[e]??n()}const Go=Gl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Te=([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:Te([0,.65,.55,1]),circOut:Te([.55,0,1,.45]),backIn:Te([.31,.01,.66,-.59]),backOut:Te([.33,1.53,.69,.99])};function Yo(t,e){if(t)return typeof t=="function"?Go()?_o(t,e):"ease-out":Ro(t)?Te(t):Array.isArray(t)?t.map(n=>Yo(n,e)||di.easeOut):di[t]}function Yl(t,e,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},u=void 0){const c={[e]:n};l&&(c.offset=l);const d=Yo(a,i);Array.isArray(d)&&(c.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(c,f)}function qo(t){return typeof t=="function"&&"applyToOptions"in t}function ql({type:t,...e}){return qo(t)&&Go()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Jl extends bs{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:r,allowFlatten:o=!1,finalKeyframe:a,onComplete:l}=e;this.isPseudoElement=!!r,this.allowFlatten=o,this.options=e,At(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=ql(e);this.animation=Yl(n,s,i,u,r),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const c=vs(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(c):Kl(n,s,c),this.animation.cancel()}l?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state: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 ct(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ct(e)}get time(){return ct(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=mt(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&&Hl()?(this.animation.timeline=e,ut):n(this)}}const Jo={anticipate:Eo,backInOut:jo,circInOut:Vo};function Zl(t){return t in Jo}function Ql(t){typeof t.ease=="string"&&Zl(t.ease)&&(t.ease=Jo[t.ease])}const hi=10;class tc extends Jl{constructor(e){Ql(e),Ko(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:r,...o}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new ws({...o,autoplay:!1}),l=mt(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-hi).value,a.sample(l).value,hi),a.stop()}}const fi=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Rt.test(t)||t==="0")&&!t.startsWith("url("));function ec(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 nc(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const r=t[t.length-1],o=fi(i,e),a=fi(r,e);return le(o===a,`You are trying to animate ${e} from "${i}" to "${r}". "${o?r:i}" is not an animatable value.`,"value-not-animatable"),!o||!a?!1:ec(t)||(n==="spring"||qo(n))&&s}function Wn(t){t.duration=0,t.type="keyframes"}const sc=new Set(["opacity","clipPath","filter","transform"]),ic=ls(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function oc(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:r,type:o}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=e.owner.getProps();return ic()&&n&&sc.has(n)&&(n!=="transform"||!u)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const rc=40;class ac extends bs{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:u,element:c,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=st.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,name:l,motionValue:u,element:c,...d},g=c?.KeyframeResolver||Ts;this.keyframeResolver=new g(a,(y,v,w)=>this.onKeyframesResolved(y,v,f,!w),l,u,c),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:u,onUpdate:c}=s;this.resolvedAt=st.now(),nc(e,r,o,a)||((Pt.instantAnimations||!l)&&c?.(vs(e,s,n)),e[0]=e[e.length-1],Wn(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>rc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&oc(f)?new tc({...f,element:f.motionValue.owner.current}):new ws(f);g.finished.then(()=>this.notifyFinished()).catch(ut),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(),_l()),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 lc=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function cc(t){const e=lc.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const uc=4;function Zo(t,e,n=1){At(n<=uc,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=cc(t);if(!s)return;const r=window.getComputedStyle(e).getPropertyValue(s);if(r){const o=r.trim();return bo(o)?parseFloat(o):o}return ms(i)?Zo(i,e,n+1):i}function Ss(t,e){return t?.[e]??t?.default??t}const Qo=new Set(["width","height","top","left","right","bottom",...ue]),dc={test:t=>t==="auto",parse:t=>t},tr=t=>e=>e.test(t),er=[ce,j,wt,Vt,el,tl,dc],mi=t=>er.find(tr(t));function hc(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||To(t):!0}const fc=new Set(["brightness","contrast","saturate","opacity"]);function mc(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(ps)||[];if(!s)return t;const i=n.replace(s,"");let r=fc.has(e)?1:0;return s!==n&&(r*=100),e+"("+r+i+")"}const pc=/\b([a-z-]*)\(.*?\)/gu,Kn={...Rt,getAnimatableNone:t=>{const e=t.match(pc);return e?e.map(mc).join(" "):t}},pi={...ce,transform:Math.round},gc={rotate:Vt,rotateX:Vt,rotateY:Vt,rotateZ:Vt,scale:_e,scaleX:_e,scaleY:_e,scaleZ:_e,skew:Vt,skewX:Vt,skewY:Vt,distance:j,translateX:j,translateY:j,translateZ:j,x:j,y:j,z:j,perspective:j,transformPerspective:j,opacity:je,originX:ni,originY:ni,originZ:j},Cs={borderWidth:j,borderTopWidth:j,borderRightWidth:j,borderBottomWidth:j,borderLeftWidth:j,borderRadius:j,radius:j,borderTopLeftRadius:j,borderTopRightRadius:j,borderBottomRightRadius:j,borderBottomLeftRadius:j,width:j,maxWidth:j,height:j,maxHeight:j,top:j,right:j,bottom:j,left:j,padding:j,paddingTop:j,paddingRight:j,paddingBottom:j,paddingLeft:j,margin:j,marginTop:j,marginRight:j,marginBottom:j,marginLeft:j,backgroundPositionX:j,backgroundPositionY:j,...gc,zIndex:pi,fillOpacity:je,strokeOpacity:je,numOctaves:pi},yc={...Cs,color:G,backgroundColor:G,outlineColor:G,fill:G,stroke:G,borderColor:G,borderTopColor:G,borderRightColor:G,borderBottomColor:G,borderLeftColor:G,filter:Kn,WebkitFilter:Kn},nr=t=>yc[t];function sr(t,e){let n=nr(t);return n!==Kn&&(n=Rt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const xc=new Set(["auto","none","0"]);function vc(t,e,n){let s=0,i;for(;s<t.length&&!i;){const r=t[s];typeof r=="string"&&!xc.has(r)&&Ee(r).values.length&&(i=t[s]),s++}if(i&&n)for(const r of e)t[r]=sr(n,i)}class bc extends Ts{constructor(e,n,s,i,r){super(e,n,s,i,r,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<e.length;l++){let u=e[l];if(typeof u=="string"&&(u=u.trim(),ms(u))){const c=Zo(u,n.current);c!==void 0&&(e[l]=c),l===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!Qo.has(s)||e.length!==2)return;const[i,r]=e,o=mi(i),a=mi(r);if(o!==a)if(ui(o)&&ui(a))for(let l=0;l<e.length;l++){const u=e[l];typeof u=="string"&&(e[l]=parseFloat(u))}else Xt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||hc(e[i]))&&s.push(i);s.length&&vc(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=Xt[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 r=s.length-1,o=s[r];s[r]=Xt[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{e.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function wc(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 ir=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function or(t){return wo(t)&&"offsetHeight"in t}const gi=30,Tc=t=>!isNaN(parseFloat(t));class Sc{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=st.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 r of this.dependents)r.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=st.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Tc(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&us(!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 cs);const s=this.events[e].add(n);return e==="change"?()=>{s(),B.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=st.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>gi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,gi);return So(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 re(t,e){return new Sc(t,e)}const{schedule:As}=No(queueMicrotask,!1),ht={x:!1,y:!1};function rr(){return ht.x||ht.y}function Cc(t){return t==="x"||t==="y"?ht[t]?null:(ht[t]=!0,()=>{ht[t]=!1}):ht.x||ht.y?null:(ht.x=ht.y=!0,()=>{ht.x=ht.y=!1})}function ar(t,e){const n=wc(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function yi(t){return!(t.pointerType==="touch"||rr())}function Ac(t,e,n={}){const[s,i,r]=ar(t,n),o=a=>{if(!yi(a))return;const{target:l}=a,u=e(l,a);if(typeof u!="function"||!l)return;const c=d=>{yi(d)&&(u(d),l.removeEventListener("pointerleave",c))};l.addEventListener("pointerleave",c,i)};return s.forEach(a=>{a.addEventListener("pointerenter",o,i)}),r}const lr=(t,e)=>e?t===e?!0:lr(t,e.parentElement):!1,Ps=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Pc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Mc(t){return Pc.has(t.tagName)||t.tabIndex!==-1}const Ge=new WeakSet;function xi(t){return e=>{e.key==="Enter"&&t(e)}}function wn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const jc=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=xi(()=>{if(Ge.has(n))return;wn(n,"down");const i=xi(()=>{wn(n,"up")}),r=()=>wn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",r,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function vi(t){return Ps(t)&&!rr()}function Ec(t,e,n={}){const[s,i,r]=ar(t,n),o=a=>{const l=a.currentTarget;if(!vi(a))return;Ge.add(l);const u=e(l,a),c=(g,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),Ge.has(l)&&Ge.delete(l),vi(g)&&typeof u=="function"&&u(g,{success:y})},d=g=>{c(g,l===window||l===document||n.useGlobalTarget||lr(l,g.target))},f=g=>{c(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),or(a)&&(a.addEventListener("focus",u=>jc(u,i)),!Mc(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function cr(t){return wo(t)&&"ownerSVGElement"in t}function Dc(t){return cr(t)&&t.tagName==="svg"}const et=t=>!!(t&&t.getVelocity),Vc=[...er,G,Rt],kc=t=>Vc.find(tr(t)),Ms=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function bi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Rc(...t){return e=>{let n=!1;const s=t.map(i=>{const r=bi(i,e);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<s.length;i++){const r=s[i];typeof r=="function"?r():bi(t[i],null)}}}}function Nc(...t){return ft.useCallback(Rc(...t),t)}class Ic extends ft.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=or(s)&&s.offsetWidth||0,r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft,r.right=i-r.width-r.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Lc({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),r=m.useRef(null),o=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Ms),l=Nc(r,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:c,top:d,left:f,right:g}=o.current;if(e||!r.current||!u||!c)return;const y=n==="left"?`left: ${f}`:`right: ${g}`;r.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const w=s??document.head;return w.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
|
${y}px !important;
|
|
7
7
|
top: ${d}px !important;
|
|
8
8
|
}
|
|
9
|
-
`),()=>{w.contains(v)&&w.removeChild(v)}},[e]),h.jsx(kc,{isPresent:e,childRef:r,sizeRef:o,children:ft.cloneElement(t,{ref:l})})}const Nc=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,root:l})=>{const u=es(Ic),c=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:c,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const y of u.values())if(!y)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return r&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,y)=>u.set(y,!1))},[n]),ft.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),o==="popLayout"&&(t=h.jsx(Rc,{isPresent:n,anchorX:a,root:l,children:t})),h.jsx(sn.Provider,{value:f,children:t})};function Ic(){return new Map}function ar(t=!0){const e=m.useContext(sn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,r=m.useId();m.useEffect(()=>{if(t)return i(r)},[t]);const o=m.useCallback(()=>t&&s&&s(r),[r,s,t]);return!n&&s?[!1,o]:[!0]}const Ue=t=>t.key||"";function xi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Lc=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",root:l})=>{const[u,c]=ar(o),d=m.useMemo(()=>xi(t),[t]),f=o&&!u?[]:d.map(Ue),g=m.useRef(!0),y=m.useRef(d),v=es(()=>new Map),[w,x]=m.useState(d),[C,b]=m.useState(d);go(()=>{g.current=!1,y.current=d;for(let D=0;D<C.length;D++){const N=Ue(C[D]);f.includes(N)?v.delete(N):v.get(N)!==!0&&v.set(N,!1)}},[C,f.length,f.join("-")]);const k=[];if(d!==w){let D=[...d];for(let N=0;N<C.length;N++){const P=C[N],L=Ue(P);f.includes(L)||(D.splice(N,0,P),k.push(P))}return r==="wait"&&k.length&&(D=k),b(xi(D)),x(d),null}process.env.NODE_ENV!=="production"&&r==="wait"&&C.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:A}=m.useContext(ts);return h.jsx(h.Fragment,{children:C.map(D=>{const N=Ue(D),P=o&&!u?!1:d===C||f.includes(N),L=()=>{if(v.has(N))v.set(N,!0);else return;let W=!0;v.forEach(U=>{U||(W=!1)}),W&&(A?.(),b(y.current),o&&c?.(),s&&s())};return h.jsx(Nc,{isPresent:P,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:r,root:l,onExitComplete:P?void 0:L,anchorX:a,children:D},N)})})},As=m.createContext({strict:!1}),vi={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"]},ae={};for(const t in vi)ae[t]={isEnabled:e=>vi[t].some(n=>!!e[n])};function _n(t){for(const e in t)ae[e]={...ae[e],...t[e]}}function Oc({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!bn(e)),i=m.useRef(void 0);if(!bn(e)){const{renderer:r,...o}=e;i.current=r,_n(o)}return m.useEffect(()=>{bn(e)&&e().then(({renderer:r,...o})=>{_n(o),i.current=r,s(!0)})},[]),h.jsx(As.Provider,{value:{renderer:i.current,strict:n},children:t})}function bn(t){return typeof t=="function"}const Fc=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 en(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Fc.has(t)}let lr=t=>!en(t);function Bc(t){typeof t=="function"&&(lr=e=>e.startsWith("on")?!en(e):t(e))}try{Bc(require("@emotion/is-prop-valid").default)}catch{}function $c(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(lr(i)||n===!0&&en(i)||!e&&!en(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const on=m.createContext({});function rn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function je(t){return typeof t=="string"||Array.isArray(t)}const Ps=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Ms=["initial",...Ps];function an(t){return rn(t.animate)||Ms.some(e=>je(t[e]))}function cr(t){return!!(an(t)||t.variants)}function zc(t,e){if(an(t)){const{initial:n,animate:s}=t;return{initial:n===!1||je(n)?n:void 0,animate:je(s)?s:void 0}}return t.inherit!==!1?e:{}}function Uc(t){const{initial:e,animate:n}=zc(t,m.useContext(on));return m.useMemo(()=>({initial:e,animate:n}),[bi(e),bi(n)])}function bi(t){return Array.isArray(t)?t.join(" "):t}const Ee={};function _c(t){for(const e in t)Ee[e]=t[e],us(e)&&(Ee[e].isCSSVariable=!0)}function ur(t,{layout:e,layoutId:n}){return de.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Ee[t]||t==="opacity")}const Wc={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Kc=ue.length;function Hc(t,e,n){let s="",i=!0;for(let r=0;r<Kc;r++){const o=ue[r],a=t[o];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(o.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=er(a,ws[o]);if(!l){i=!1;const c=Wc[o]||o;s+=`${c}(${u}) `}n&&(e[o]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function js(t,e,n){const{style:s,vars:i,transformOrigin:r}=t;let o=!1,a=!1;for(const l in e){const u=e[l];if(de.has(l)){o=!0;continue}else if(us(l)){i[l]=u;continue}else{const c=er(u,ws[l]);l.startsWith("origin")?(a=!0,r[l]=c):s[l]=c}}if(e.transform||(o||n?s.transform=Hc(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:c=0}=r;s.transformOrigin=`${l} ${u} ${c}`}}const Es=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function dr(t,e,n){for(const s in e)!nt(e[s])&&!ur(s,n)&&(t[s]=e[s])}function Xc({transformTemplate:t},e){return m.useMemo(()=>{const n=Es();return js(n,e,t),Object.assign({},n.vars,n.style)},[e])}function Gc(t,e){const n=t.style||{},s={};return dr(s,n,t),Object.assign(s,Xc(t,e)),s}function Yc(t,e){const n={},s=Gc(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 qc={offset:"stroke-dashoffset",array:"stroke-dasharray"},Zc={offset:"strokeDashoffset",array:"strokeDasharray"};function Jc(t,e,n=1,s=0,i=!0){t.pathLength=1;const r=i?qc:Zc;t[r.offset]=E.transform(-s);const o=E.transform(e),a=E.transform(n);t[r.array]=`${o} ${a}`}function hr(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,u,c){if(js(t,a,u),l){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=c?.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&&Jc(d,i,r,o,!1)}const fr=()=>({...Es(),attrs:{}}),mr=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Qc(t,e,n,s){const i=m.useMemo(()=>{const r=fr();return hr(r,e,mr(s),t.transformTemplate,t.style),{...r.attrs,style:{...r.style}}},[e]);if(t.style){const r={};dr(r,t.style,t),i.style={...r,...i.style}}return i}const tu=["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 Ds(t){return typeof t!="string"||t.includes("-")?!1:!!(tu.indexOf(t)>-1||/[A-Z]/u.test(t))}function eu(t,e,n,{latestValues:s},i,r=!1){const a=(Ds(t)?Qc:Yc)(e,s,i,t),l=$c(e,typeof t=="string",r),u=t!==m.Fragment?{...l,...a,ref:n}:{},{children:c}=e,d=m.useMemo(()=>nt(c)?c.get():c,[c]);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 Vs(t,e,n,s){if(typeof e=="function"){const[i,r]=wi(s);e=e(n!==void 0?n:t.custom,i,r)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,r]=wi(s);e=e(n!==void 0?n:t.custom,i,r)}return e}function Xe(t){return nt(t)?t.get():t}function nu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:su(n,s,i,t),renderState:e()}}function su(t,e,n,s){const i={},r=s(t,{});for(const f in r)i[f]=Xe(r[f]);let{initial:o,animate:a}=t;const l=an(t),u=cr(t);e&&u&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let c=n?n.initial===!1:!1;c=c||o===!1;const d=c?a:o;if(d&&typeof d!="boolean"&&!rn(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const y=Vs(t,f[g]);if(y){const{transitionEnd:v,transition:w,...x}=y;for(const C in x){let b=x[C];if(Array.isArray(b)){const k=c?b.length-1:0;b=b[k]}b!==null&&(i[C]=b)}for(const C in v)i[C]=v[C]}}}return i}const pr=t=>(e,n)=>{const s=m.useContext(on),i=m.useContext(sn),r=()=>nu(t,e,s,i);return n?r():es(r)};function ks(t,e,n){const{style:s}=t,i={};for(const r in s)(nt(s[r])||e.style&&nt(e.style[r])||ur(r,t)||n?.getValue(r)?.liveStyle!==void 0)&&(i[r]=s[r]);return i}const iu=pr({scrapeMotionValuesFromProps:ks,createRenderState:Es});function gr(t,e,n){const s=ks(t,e,n);for(const i in t)if(nt(t[i])||nt(e[i])){const r=ue.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=t[i]}return s}const ou=pr({scrapeMotionValuesFromProps:gr,createRenderState:fr}),ru=Symbol.for("motionComponentSymbol");function te(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function au(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 Rs=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),lu="framerAppearId",yr="data-"+Rs(lu),xr=m.createContext({});function cu(t,e,n,s,i){const{visualElement:r}=m.useContext(on),o=m.useContext(As),a=m.useContext(sn),l=m.useContext(Cs).reducedMotion,u=m.useRef(null);s=s||o.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:r,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const c=u.current,d=m.useContext(xr);c&&!c.projection&&i&&(c.type==="html"||c.type==="svg")&&uu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{c&&f.current&&c.update(n,a)});const g=n[yr],y=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return go(()=>{c&&(f.current=!0,window.MotionIsMounted=!0,c.updateFeatures(),c.scheduleRenderMicrotask(),y.current&&c.animationState&&c.animationState.animateChanges())}),m.useEffect(()=>{c&&(!y.current&&c.animationState&&c.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),y.current=!1),c.enteringChildren=void 0)}),c}function uu(t,e,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:vr(t.parent)),t.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&te(a),visualElement:t,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u})}function vr(t){if(t)return t.options.allowProjection!==!1?t.projection:vr(t.parent)}function Ge(t,{forwardMotionProps:e=!1}={},n,s){n&&_n(n);const i=Ds(t)?ou:iu;function r(a,l){let u;const c={...m.useContext(Cs),...a,layoutId:du(a)},{isStatic:d}=c,f=Uc(a),g=i(a,d);if(!d&&ns){hu(c,n);const y=fu(c);u=y.MeasureLayout,f.visualElement=cu(t,g,c,s,y.ProjectionNode)}return h.jsxs(on.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...c}):null,eu(t,a,au(g,f.visualElement,l),g,d,e)]})}r.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const o=m.forwardRef(r);return o[ru]=t,o}function du({layoutId:t}){const e=m.useContext(ts).id;return e&&t!==void 0?e+"-"+t:t}function hu(t,e){const n=m.useContext(As).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?le(!1,s,"lazy-strict-mode"):Ct(!1,s,"lazy-strict-mode")}}function fu(t){const{drag:e,layout:n}=ae;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function mu(t,e){if(typeof Proxy>"u")return Ge;const n=new Map,s=(r,o)=>Ge(r,o,t,e),i=(r,o)=>(process.env.NODE_ENV!=="production"&&as(!1,"motion() is deprecated. Use motion.create() instead."),s(r,o));return new Proxy(i,{get:(r,o)=>o==="create"?s:(n.has(o)||n.set(o,Ge(o,void 0,t,e)),n.get(o))})}function br({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function pu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function gu(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 wn(t){return t===void 0||t===1}function Wn({scale:t,scaleX:e,scaleY:n}){return!wn(t)||!wn(e)||!wn(n)}function Wt(t){return Wn(t)||wr(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function wr(t){return Ti(t.x)||Ti(t.y)}function Ti(t){return t&&t!=="0%"}function nn(t,e,n){const s=t-n,i=e*s;return n+i}function Si(t,e,n,s,i){return i!==void 0&&(t=nn(t,i,s)),nn(t,n,s)+e}function Kn(t,e=0,n=1,s,i){t.min=Si(t.min,e,n,s,i),t.max=Si(t.max,e,n,s,i)}function Tr(t,{x:e,y:n}){Kn(t.x,e.translate,e.scale,e.originPoint),Kn(t.y,n.translate,n.scale,n.originPoint)}const Ci=.999999999999,Ai=1.0000000000001;function yu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let r,o;for(let a=0;a<i;a++){r=n[a],o=r.projectionDelta;const{visualElement:l}=r.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&ne(t,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,Tr(t,o)),s&&Wt(r.latestValues)&&ne(t,r.latestValues))}e.x<Ai&&e.x>Ci&&(e.x=1),e.y<Ai&&e.y>Ci&&(e.y=1)}function ee(t,e){t.min=t.min+e,t.max=t.max+e}function Pi(t,e,n,s,i=.5){const r=z(t.min,t.max,i);Kn(t,e,n,r,s)}function ne(t,e){Pi(t.x,e.x,e.scaleX,e.scale,e.originX),Pi(t.y,e.y,e.scaleY,e.scale,e.originY)}function Sr(t,e){return br(gu(t.getBoundingClientRect(),e))}function xu(t,e,n){const s=Sr(t,n),{scroll:i}=e;return i&&(ee(s.x,i.offset.x),ee(s.y,i.offset.y)),s}const Mi=()=>({translate:0,scale:1,origin:0,originPoint:0}),se=()=>({x:Mi(),y:Mi()}),ji=()=>({min:0,max:0}),K=()=>({x:ji(),y:ji()}),Hn={current:null},Cr={current:!1};function vu(){if(Cr.current=!0,!!ns)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Hn.current=t.matches;t.addEventListener("change",e),e()}else Hn.current=!1}const bu=new WeakMap;function wu(t,e,n){for(const s in e){const i=e[s],r=n[s];if(nt(i))t.addValue(s,i);else if(nt(r))t.addValue(s,re(i,{owner:t}));else if(r!==i)if(t.hasValue(s)){const o=t.getValue(s);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=t.getStaticValue(s);t.addValue(s,re(o!==void 0?o:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Ei=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Tu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:r,visualState:o},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=vs,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=it.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,B.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},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=!!r,this.isControllingVariants=an(n),this.isVariantNode=cr(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];l[f]!==void 0&&nt(g)&&g.set(l[f])}}mount(e){this.current=e,bu.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)),Cr.current||vu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Hn.current,process.env.NODE_ENV!=="production"&&as(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(),Vt(this.notifyUpdate),Vt(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",o=>{this.latestValues[e]=o,this.props.onUpdate&&B.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),r&&r(),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 ae){const n=ae[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 r=this.features[e];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):K()}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<Ei.length;s++){const i=Ei[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const r="on"+i,o=e[r];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=wu(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=re(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"&&(yo(s)||vo(s))?s=parseFloat(s):!Ec(s)&&kt.test(n)&&(s=tr(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 r=Vs(this.props,n,this.presenceContext?.custom);r&&(s=r[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 rs),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){Ts.render(this.render)}}class Ar extends Tu{constructor(){super(...arguments),this.KeyframeResolver=yc}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 Pr(t,{style:e,vars:n},s,i){const r=t.style;let o;for(o in e)r[o]=e[o];i?.applyProjectionStyles(r,s);for(o in n)r.setProperty(o,n[o])}function Su(t){return window.getComputedStyle(t)}class Cu extends Ar{constructor(){super(...arguments),this.type="html",this.renderInstance=Pr}readValueFromInstance(e,n){if(de.has(n))return this.projection?.isProjecting?Ln(n):Il(e,n);{const s=Su(e),i=(us(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Sr(e,n)}build(e,n,s){js(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return ks(e,n,s)}}const Mr=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 Au(t,e,n,s){Pr(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Mr.has(i)?i:Rs(i),e.attrs[i])}class Pu extends Ar{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=K}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(de.has(n)){const s=Qo(n);return s&&s.default||0}return n=Mr.has(n)?n:Rs(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return gr(e,n,s)}build(e,n,s){hr(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Au(e,n,s,i)}mount(e){this.isSVGTag=mr(e.tagName),super.mount(e)}}const jr=(t,e)=>Ds(t)?new Pu(e):new Cu(e,{allowProjection:t!==m.Fragment});function oe(t,e,n){const s=t.getProps();return Vs(s,e,n!==void 0?n:s.custom,t)}const Xn=t=>Array.isArray(t);function Mu(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,re(n))}function ju(t){return Xn(t)?t[t.length-1]||0:t}function Eu(t,e){const n=oe(t,e);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=ju(r[o]);Mu(t,o,a)}}function Du(t){return!!(nt(t)&&t.add)}function Gn(t,e){const n=t.getValue("willChange");if(Du(n))return n.add(e);if(!n&&At.WillChange){const s=new At.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Er(t){return t.props[yr]}const Vu=t=>t!==null;function ku(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Vu),r=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[r]}const Ru={type:"spring",stiffness:500,damping:25,restSpeed:10},Nu=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Iu={type:"keyframes",duration:.8},Lu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Ou=(t,{keyframes:e})=>e.length>2?Iu:de.has(t)?t.startsWith("scale")?Nu(e[1]):Ru:Lu;function Fu({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:u,...c}){return!!Object.keys(c).length}const Ns=(t,e,n,s={},i,r)=>o=>{const a=bs(s,t)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-mt(l);const c={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:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:r?void 0:i};Fu(a)||Object.assign(c,Ou(t,c)),c.duration&&(c.duration=mt(c.duration)),c.repeatDelay&&(c.repeatDelay=mt(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let d=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(zn(c),c.delay===0&&(d=!0)),(At.instantAnimations||At.skipAnimations)&&(d=!0,zn(c),c.delay=0),c.allowFlatten=!a.type&&!a.ease,d&&!r&&e.get()!==void 0){const f=ku(c.keyframes,a);if(f!==void 0){B.update(()=>{c.onUpdate(f),c.onComplete()});return}}return a.isSync?new xs(c):new ic(c)};function Bu({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Dr(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r=t.getDefaultTransition(),transitionEnd:o,...a}=e;s&&(r=s);const l=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const c in a){const d=t.getValue(c,t.latestValues[c]??null),f=a[c];if(f===void 0||u&&Bu(u,c))continue;const g={delay:n,...bs(r||{},c)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const x=Er(t);if(x){const C=window.MotionHandoffAnimation(x,c,B);C!==null&&(g.startTime=C,v=!0)}}Gn(t,c),d.start(Ns(c,d,f,t.shouldReduceMotion&&qo.has(c)?{type:!1}:g,t,v));const w=d.animation;w&&l.push(w)}return o&&Promise.all(l).then(()=>{B.update(()=>{o&&Eu(t,o)})}),l}function Vr(t,e,n,s=0,i=1){const r=Array.from(t).sort((u,c)=>u.sortNodePosition(c)).indexOf(e),o=t.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}function Yn(t,e,n={}){const s=oe(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const r=s?()=>Promise.all(Dr(t,s,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:c,staggerDirection:d}=i;return $u(t,e,l,u,c,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,u]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>u())}else return Promise.all([r(),o(n.delay)])}function $u(t,e,n=0,s=0,i=0,r=1,o){const a=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),a.push(Yn(l,e,{...o,delay:n+(typeof s=="function"?0:s)+Vr(t.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function zu(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(r=>Yn(t,r,n));s=Promise.all(i)}else if(typeof e=="string")s=Yn(t,e,n);else{const i=typeof e=="function"?oe(t,e,n.custom):e;s=Promise.all(Dr(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function kr(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 Uu=Ms.length;function Rr(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Rr(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Uu;n++){const s=Ms[n],i=t.props[s];(je(i)||i===!1)&&(e[s]=i)}return e}const _u=[...Ps].reverse(),Wu=Ps.length;function Ku(t){return e=>Promise.all(e.map(({animation:n,options:s})=>zu(t,n,s)))}function Hu(t){let e=Ku(t),n=Di(),s=!0;const i=l=>(u,c)=>{const d=oe(t,c,l==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...y}=d;u={...u,...y,...g}}return u};function r(l){e=l(t)}function o(l){const{props:u}=t,c=Rr(t.parent)||{},d=[],f=new Set;let g={},y=1/0;for(let w=0;w<Wu;w++){const x=_u[w],C=n[x],b=u[x]!==void 0?u[x]:c[x],k=je(b),A=x===l?C.isActive:null;A===!1&&(y=w);let D=b===c[x]&&b!==u[x]&&k;if(D&&s&&t.manuallyAnimateOnMount&&(D=!1),C.protectedKeys={...g},!C.isActive&&A===null||!b&&!C.prevProp||rn(b)||typeof b=="boolean")continue;const N=Xu(C.prevProp,b);let P=N||x===l&&C.isActive&&!D&&k||w>y&&k,L=!1;const W=Array.isArray(b)?b:[b];let U=W.reduce(i(x),{});A===!1&&(U={});const{prevResolvedValues:Tt={}}=C,Pt={...Tt,...U},dt=V=>{P=!0,f.has(V)&&(L=!0,f.delete(V)),C.needsAnimating[V]=!0;const Y=t.getValue(V);Y&&(Y.liveStyle=!1)};for(const V in Pt){const Y=U[V],H=Tt[V];if(g.hasOwnProperty(V))continue;let rt=!1;Xn(Y)&&Xn(H)?rt=!kr(Y,H):rt=Y!==H,rt?Y!=null?dt(V):f.add(V):Y!==void 0&&f.has(V)?dt(V):C.protectedKeys[V]=!0}C.prevProp=b,C.prevResolvedValues=U,C.isActive&&(g={...g,...U}),s&&t.blockInitialAnimation&&(P=!1);const ot=D&&N;P&&(!ot||L)&&d.push(...W.map(V=>{const Y={type:x};if(typeof V=="string"&&s&&!ot&&t.manuallyAnimateOnMount&&t.parent){const{parent:H}=t,rt=oe(H,V);if(H.enteringChildren&&rt){const{delayChildren:_}=rt.transition||{};Y.delay=Vr(H.enteringChildren,t,_)}}return{animation:V,options:Y}}))}if(f.size){const w={};if(typeof u.initial!="boolean"){const x=oe(t,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(w.transition=x.transition)}f.forEach(x=>{const C=t.getBaseTarget(x),b=t.getValue(x);b&&(b.liveStyle=!0),w[x]=C??null}),d.push({animation:w})}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(l,u){if(n[l].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(l,u)),n[l].isActive=u;const c=o(l);for(const d in n)n[d].protectedKeys={};return c}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Di()}}}function Xu(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!kr(e,t):!1}function Ut(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Di(){return{animate:Ut(!0),whileInView:Ut(),whileHover:Ut(),whileTap:Ut(),whileDrag:Ut(),whileFocus:Ut(),exit:Ut()}}class Rt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Gu extends Rt{constructor(e){super(e),e.animationState||(e.animationState=Hu(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();rn(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 Yu=0;class qu extends Rt{constructor(){super(...arguments),this.id=Yu++}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 Nr={animation:{Feature:Gu},exit:{Feature:qu}};function De(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function Ne(t){return{point:{x:t.pageX,y:t.pageY}}}const Zu=t=>e=>Ss(e)&&t(e,Ne(e));function Te(t,e,n,s){return De(t,e,Zu(n),s)}const Ir=1e-4,Ju=1-Ir,Qu=1+Ir,Lr=.01,td=0-Lr,ed=0+Lr;function st(t){return t.max-t.min}function nd(t,e,n){return Math.abs(t-e)<=n}function Vi(t,e,n,s=.5){t.origin=s,t.originPoint=z(e.min,e.max,t.origin),t.scale=st(n)/st(e),t.translate=z(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Ju&&t.scale<=Qu||isNaN(t.scale))&&(t.scale=1),(t.translate>=td&&t.translate<=ed||isNaN(t.translate))&&(t.translate=0)}function Se(t,e,n,s){Vi(t.x,e.x,n.x,s?s.originX:void 0),Vi(t.y,e.y,n.y,s?s.originY:void 0)}function ki(t,e,n){t.min=n.min+e.min,t.max=t.min+st(e)}function sd(t,e,n){ki(t.x,e.x,n.x),ki(t.y,e.y,n.y)}function Ri(t,e,n){t.min=e.min-n.min,t.max=t.min+st(e)}function Ce(t,e,n){Ri(t.x,e.x,n.x),Ri(t.y,e.y,n.y)}function lt(t){return[t("x"),t("y")]}const Or=({current:t})=>t?t.ownerDocument.defaultView:null,Ni=(t,e)=>Math.abs(t-e);function id(t,e){const n=Ni(t.x,e.x),s=Ni(t.y,e.y);return Math.sqrt(n**2+s**2)}class Fr{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:r=!1,distanceThreshold:o=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=Sn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=id(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:v}=f,{timestamp:w}=Q;this.history.push({...v,timestamp:w});const{onStart:x,onMove:C}=this.handlers;g||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),C&&C(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Tn(g,this.transformPagePoint),B.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:v,resumeAnimation:w}=this.handlers;if(this.dragSnapToOrigin&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=Sn(f.type==="pointercancel"?this.lastMoveEventInfo:Tn(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!Ss(e))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const a=Ne(e),l=Tn(a,this.transformPagePoint),{point:u}=l,{timestamp:c}=Q;this.history=[{...u,timestamp:c}];const{onSessionStart:d}=n;d&&d(e,Sn(l,this.history)),this.removeListeners=Ve(Te(this.contextWindow,"pointermove",this.handlePointerMove),Te(this.contextWindow,"pointerup",this.handlePointerUp),Te(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Vt(this.updatePoint)}}function Tn(t,e){return e?{point:e(t.point)}:t}function Ii(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Sn({point:t},e){return{point:t,delta:Ii(t,Br(e)),offset:Ii(t,od(e)),velocity:rd(e,.1)}}function od(t){return t[0]}function Br(t){return t[t.length-1]}function rd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Br(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>mt(e)));)n--;if(!s)return{x:0,y:0};const r=ct(i.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const o={x:(i.x-s.x)/r,y:(i.y-s.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function ad(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?z(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?z(n,t,s.max):Math.min(t,n)),t}function Li(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 ld(t,{top:e,left:n,bottom:s,right:i}){return{x:Li(t.x,n,i),y:Li(t.y,e,s)}}function Oi(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 cd(t,e){return{x:Oi(t.x,e.x),y:Oi(t.y,e.y)}}function ud(t,e){let n=.5;const s=st(t),i=st(e);return i>s?n=Ae(e.min,e.max-s,t.min):s>i&&(n=Ae(t.min,t.max-i,e.min)),St(0,1,n)}function dd(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 qn=.35;function hd(t=qn){return t===!1?t=0:t===!0&&(t=qn),{x:Fi(t,"left","right"),y:Fi(t,"top","bottom")}}function Fi(t,e,n){return{min:Bi(t,e),max:Bi(t,n)}}function Bi(t,e){return typeof t=="number"?t:t[e]||0}const fd=new WeakMap;class md{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=K(),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 r=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Ne(d).point)},o=(d,f)=>{const{drag:g,dragPropagation:y,onDragStart:v}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=wc(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),lt(x=>{let C=this.getAxisMotionValue(x).get()||0;if(wt.test(C)){const{projection:b}=this.visualElement;if(b&&b.layout){const k=b.layout.layoutBox[x];k&&(C=st(k)*(parseFloat(C)/100))}}this.originPoint[x]=C}),v&&B.postRender(()=>v(d,f)),Gn(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:v,onDrag:w}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:x}=f;if(y&&this.currentDirection===null){this.currentDirection=pd(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),w&&w(d,f)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>lt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new Fr(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:s,contextWindow:Or(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!i||!s)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&B.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||!_e(e,i,this.currentDirection))return;const r=this.getAxisMotionValue(e);let o=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(o=ad(o,this.constraints[e],this.elastic[e])),r.set(o)}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=ld(s.layoutBox,e):this.constraints=!1,this.elastic=hd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&<(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=dd(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!te(e))return!1;const s=e.current;Ct(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 r=xu(s,i.root,this.visualElement.getTransformPagePoint());let o=cd(i.layout.layoutBox,r);if(n){const a=n(pu(o));this.hasMutatedConstraints=!!a,a&&(o=br(a))}return o}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=lt(c=>{if(!_e(c,n,this.currentDirection))return;let d=l&&l[c]||{};o&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,y={type:"inertia",velocity:s?e[c]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...r,...d};return this.startAxisValueAnimation(c,y)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Gn(this.visualElement,e),s.start(Ns(e,s,0,n,this.visualElement,!1))}stopAnimation(){lt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){lt(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){lt(n=>{const{drag:s}=this.getProps();if(!_e(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,r=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n];r.set(e[n]-z(o,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};lt(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();i[o]=ud({min:l,max:l},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),lt(o=>{if(!_e(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:u}=this.constraints[o];a.set(z(l,u,i[o]))})}addListeners(){if(!this.visualElement.current)return;fd.set(this.visualElement,this);const e=this.visualElement.current,n=Te(e,"pointerdown",l=>{const{drag:u,dragListener:c=!0}=this.getProps();u&&c&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();te(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,r=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),B.read(s);const o=De(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(lt(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=l[c].translate,d.set(d.get()+l[c].translate))}),this.visualElement.render())});return()=>{o(),n(),r(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=qn,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function _e(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function pd(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class gd extends Rt{constructor(e){super(e),this.removeGroupControls=ut,this.removeListeners=ut,this.controls=new md(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ut}unmount(){this.removeGroupControls(),this.removeListeners()}}const $i=t=>(e,n)=>{t&&B.postRender(()=>t(e,n))};class yd extends Rt{constructor(){super(...arguments),this.removePointerDownListener=ut}onPointerDown(e){this.session=new Fr(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Or(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:$i(e),onStart:$i(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&B.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=Te(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 Ye={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function zi(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const ve={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(E.test(t))t=parseFloat(t);else return t;const n=zi(t,e.target.x),s=zi(t,e.target.y);return`${n}% ${s}%`}},xd={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=kt.parse(t);if(i.length>5)return s;const r=kt.createTransformer(t),o=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,l=n.y.scale*e.y;i[0+o]/=a,i[1+o]/=l;const u=z(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=u),typeof i[3+o]=="number"&&(i[3+o]/=u),r(i)}};let Cn=!1;class vd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=e;_c(bd),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),Cn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),Ye.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,Cn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==r?o.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?o.promote():o.relegate()||B.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Ts.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;Cn=!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 $r(t){const[e,n]=ar(),s=m.useContext(ts);return h.jsx(vd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(xr),isPresent:e,safeToRemove:n})}const bd={borderRadius:{...ve,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:ve,borderTopRightRadius:ve,borderBottomLeftRadius:ve,borderBottomRightRadius:ve,boxShadow:xd};function wd(t,e,n){const s=nt(t)?t:re(t);return s.start(Ns("",s,e,n)),s.animation}const Td=(t,e)=>t.depth-e.depth;class Sd{constructor(){this.children=[],this.isDirty=!1}add(e){ss(this.children,e),this.isDirty=!0}remove(e){is(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Td),this.isDirty=!1,this.children.forEach(e)}}function Cd(t,e){const n=it.now(),s=({timestamp:i})=>{const r=i-n;r>=e&&(Vt(s),t(r-e))};return B.setup(s,!0),()=>Vt(s)}const zr=["TopLeft","TopRight","BottomLeft","BottomRight"],Ad=zr.length,Ui=t=>typeof t=="string"?parseFloat(t):t,_i=t=>typeof t=="number"||E.test(t);function Pd(t,e,n,s,i,r){i?(t.opacity=z(0,n.opacity??1,Md(s)),t.opacityExit=z(e.opacity??1,0,jd(s))):r&&(t.opacity=z(e.opacity??1,n.opacity??1,s));for(let o=0;o<Ad;o++){const a=`border${zr[o]}Radius`;let l=Wi(e,a),u=Wi(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||_i(l)===_i(u)?(t[a]=Math.max(z(Ui(l),Ui(u),s),0),(wt.test(u)||wt.test(l))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=z(e.rotate||0,n.rotate||0,s))}function Wi(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Md=Ur(0,.5,Mo),jd=Ur(.5,.95,ut);function Ur(t,e,n){return s=>s<t?0:s>e?1:n(Ae(t,e,s))}function Ki(t,e){t.min=e.min,t.max=e.max}function at(t,e){Ki(t.x,e.x),Ki(t.y,e.y)}function Hi(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function Xi(t,e,n,s,i){return t-=e,t=nn(t,1/n,s),i!==void 0&&(t=nn(t,1/i,s)),t}function Ed(t,e=0,n=1,s=.5,i,r=t,o=t){if(wt.test(e)&&(e=parseFloat(e),e=z(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=z(r.min,r.max,s);t===r&&(a-=e),t.min=Xi(t.min,e,n,a,i),t.max=Xi(t.max,e,n,a,i)}function Gi(t,e,[n,s,i],r,o){Ed(t,e[n],e[s],e[i],e.scale,r,o)}const Dd=["x","scaleX","originX"],Vd=["y","scaleY","originY"];function Yi(t,e,n,s){Gi(t.x,e,Dd,n?n.x:void 0,s?s.x:void 0),Gi(t.y,e,Vd,n?n.y:void 0,s?s.y:void 0)}function qi(t){return t.translate===0&&t.scale===1}function _r(t){return qi(t.x)&&qi(t.y)}function Zi(t,e){return t.min===e.min&&t.max===e.max}function kd(t,e){return Zi(t.x,e.x)&&Zi(t.y,e.y)}function Ji(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function Wr(t,e){return Ji(t.x,e.x)&&Ji(t.y,e.y)}function Qi(t){return st(t.x)/st(t.y)}function to(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class Rd{constructor(){this.members=[]}add(e){ss(this.members,e),e.scheduleRender()}remove(e){if(is(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 r=this.members[i];if(r.isPresent!==!1){s=r;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 Nd(t,e,n){let s="";const i=t.x.translate/e.x,r=t.y.translate/e.y,o=n?.z||0;if((i||r||o)&&(s=`translate3d(${i}px, ${r}px, ${o}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:c,rotateX:d,rotateY:f,skewX:g,skewY:y}=n;u&&(s=`perspective(${u}px) ${s}`),c&&(s+=`rotate(${c}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),y&&(s+=`skewY(${y}deg) `)}const a=t.x.scale*e.x,l=t.y.scale*e.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const An=["","X","Y","Z"],Id=1e3;let Ld=0;function Pn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function Kr(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Er(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",B,!(i||r))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&Kr(s)}function Hr({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Ld++,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(Bd),this.nodes.forEach(_d),this.nodes.forEach(Wd),this.nodes.forEach($d)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Sd)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new rs),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const l=this.eventHandlers.get(o);l&&l.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=rr(o)&&!Mc(o),this.instance=o;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let c,d=0;const f=()=>this.root.updateBlockedByResize=!1;B.read(()=>{d=window.innerWidth}),t(o,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,c&&c(),c=Cd(f,250),Ye.hasAnimatedSinceResize&&(Ye.hasAnimatedSinceResize=!1,this.nodes.forEach(so)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||u.getDefaultTransition()||Yd,{onLayoutAnimationStart:v,onLayoutAnimationComplete:w}=u.getProps(),x=!this.targetLayout||!Wr(this.targetLayout,g),C=!d&&f;if(this.options.layoutRoot||this.resumeFrom||C||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...bs(y,"layout"),onPlay:v,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(c,C)}else d||so(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Vt(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(Kd),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Kr(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const d=this.path[c];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(eo);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(no);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Ud),this.nodes.forEach(Od),this.nodes.forEach(Fd)):this.nodes.forEach(no),this.clearAllSnapshots();const a=it.now();Q.delta=St(0,1e3/60,a-Q.timestamp),Q.timestamp=a,Q.isProcessing=!0,mn.update.process(Q),mn.preRender.process(Q),mn.render.process(Q),Q.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Ts.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(zd),this.sharedNodes.forEach(Hd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,B.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){B.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!st(this.snapshot.measuredBox.x)&&!st(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=K(),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,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!_r(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,c=u!==this.prevTransformTemplateValue;o&&this.instance&&(a||Wt(this.latestValues)||c)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),qd(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return K();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Zd))){const{scroll:u}=this.root;u&&(ee(a.x,u.offset.x),ee(a.y,u.offset.y))}return a}removeElementScroll(o){const a=K();if(at(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:c,options:d}=u;u!==this.root&&c&&d.layoutScroll&&(c.wasRoot&&at(a,o),ee(a.x,c.offset.x),ee(a.y,c.offset.y))}return a}applyTransform(o,a=!1){const l=K();at(l,o);for(let u=0;u<this.path.length;u++){const c=this.path[u];!a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&ne(l,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),Wt(c.latestValues)&&ne(l,c.latestValues)}return Wt(this.latestValues)&&ne(l,this.latestValues),l}removeTransform(o){const a=K();at(a,o);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Wt(u.latestValues))continue;Wn(u.latestValues)&&u.updateSnapshot();const c=K(),d=u.measurePageBox();at(c,d),Yi(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,c)}return Wt(this.latestValues)&&Yi(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.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!==Q.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:d}=this.options;if(!(!this.layout||!(c||d))){if(this.resolvedRelativeTargetAt=Q.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=K(),this.relativeTargetOrigin=K(),Ce(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),at(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=K(),this.targetWithTransforms=K()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),sd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):at(this.target,this.layout.layoutBox),Tr(this.target,this.targetDelta)):at(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=K(),this.relativeTargetOrigin=K(),Ce(this.relativeTargetOrigin,this.target,f.target),at(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||Wn(this.parent.latestValues)||wr(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 o=this.getLead(),a=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===Q.timestamp&&(l=!1),l)return;const{layout:u,layoutId:c}=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||c))return;at(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;yu(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=K());const{target:g}=o;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Hi(this.prevProjectionDelta.x,this.projectionDelta.x),Hi(this.prevProjectionDelta.y,this.projectionDelta.y)),Se(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!to(this.projectionDelta.x,this.prevProjectionDelta.x)||!to(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){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(o,a=!1){const l=this.snapshot,u=l?l.latestValues:{},c={...this.latestValues},d=se();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=K(),g=l?l.source:void 0,y=this.layout?this.layout.source:void 0,v=g!==y,w=this.getStack(),x=!w||w.members.length<=1,C=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(Gd));this.animationProgress=0;let b;this.mixTargetDelta=k=>{const A=k/1e3;io(d.x,o.x,A),io(d.y,o.y,A),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Ce(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Xd(this.relativeTarget,this.relativeTargetOrigin,f,A),b&&kd(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=K()),at(b,this.relativeTarget)),v&&(this.animationValues=c,Pd(c,u,this.latestValues,A,C,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=A},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Vt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=B.update(()=>{Ye.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=re(0)),this.currentAnimation=wd(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.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 o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Id),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:c}=o;if(!(!a||!l||!u)){if(this!==o&&this.layout&&u&&Xr(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||K();const d=st(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=st(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}at(a,l),ne(a,c),Se(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Rd),this.sharedNodes.get(o).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 o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&Pn("z",o,u,this.animationValues);for(let c=0;c<An.length;c++)Pn(`rotate${An[c]}`,o,u,this.animationValues),Pn(`skew${An[c]}`,o,u,this.animationValues);o.render();for(const c in u)o.setStaticValue(c,u[c]),this.animationValues&&(this.animationValues[c]=u[c]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Xe(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Xe(a?.pointerEvents)||""),this.hasProjected&&!Wt(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const c=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=Nd(this.projectionDeltaWithTransform,this.treeScale,c);l&&(d=l(c,d)),o.transform=d;const{x:f,y:g}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?o.opacity=u===this?c.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:c.opacityExit:o.opacity=u===this?c.opacity!==void 0?c.opacity:"":c.opacityExit!==void 0?c.opacityExit:0;for(const y in Ee){if(c[y]===void 0)continue;const{correct:v,applyTo:w,isCSSVariable:x}=Ee[y],C=d==="none"?c[y]:v(c[y],u);if(w){const b=w.length;for(let k=0;k<b;k++)o[w[k]]=C}else x?this.options.visualElement.renderState.vars[y]=C:o[y]=C}this.options.layoutId&&(o.pointerEvents=u===this?Xe(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(eo),this.root.sharedNodes.clear()}}}function Od(t){t.updateLayout()}function Fd(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,r=e.source!==t.layout.source;i==="size"?lt(c=>{const d=r?e.measuredBox[c]:e.layoutBox[c],f=st(d);d.min=n[c].min,d.max=d.min+f}):Xr(i,e.layoutBox,n)&<(c=>{const d=r?e.measuredBox[c]:e.layoutBox[c],f=st(n[c]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[c].max=t.relativeTarget[c].min+f)});const o=se();Se(o,n,e.layoutBox);const a=se();r?Se(a,t.applyTransform(s,!0),e.measuredBox):Se(a,n,e.layoutBox);const l=!_r(o);let u=!1;if(!t.resumeFrom){const c=t.getClosestProjectingParent();if(c&&!c.resumeFrom){const{snapshot:d,layout:f}=c;if(d&&f){const g=K();Ce(g,e.layoutBox,d.layoutBox);const y=K();Ce(y,n,f.layoutBox),Wr(g,y)||(u=!0),c.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=g,t.relativeParent=c)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Bd(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 $d(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function zd(t){t.clearSnapshot()}function eo(t){t.clearMeasurements()}function no(t){t.isLayoutDirty=!1}function Ud(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function so(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function _d(t){t.resolveTargetDelta()}function Wd(t){t.calcProjection()}function Kd(t){t.resetSkewAndRotation()}function Hd(t){t.removeLeadSnapshot()}function io(t,e,n){t.translate=z(e.translate,0,n),t.scale=z(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function oo(t,e,n,s){t.min=z(e.min,n.min,s),t.max=z(e.max,n.max,s)}function Xd(t,e,n,s){oo(t.x,e.x,n.x,s),oo(t.y,e.y,n.y,s)}function Gd(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Yd={duration:.45,ease:[.4,0,.1,1]},ro=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),ao=ro("applewebkit/")&&!ro("chrome/")?Math.round:ut;function lo(t){t.min=ao(t.min),t.max=ao(t.max)}function qd(t){lo(t.x),lo(t.y)}function Xr(t,e,n){return t==="position"||t==="preserve-aspect"&&!nd(Qi(e),Qi(n),.2)}function Zd(t){return t!==t.root&&t.scroll?.wasRoot}const Jd=Hr({attachResizeListener:(t,e)=>De(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Mn={current:void 0},Gr=Hr({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Mn.current){const t=new Jd({});t.mount(window),t.setOptions({layoutScroll:!0}),Mn.current=t}return Mn.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Qd={pan:{Feature:yd},drag:{Feature:gd,ProjectionNode:Gr,MeasureLayout:$r}};function co(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,r=s[i];r&&B.postRender(()=>r(e,Ne(e)))}class th extends Rt{mount(){const{current:e}=this.node;e&&(this.unmount=Tc(e,(n,s)=>(co(this.node,s,"Start"),i=>co(this.node,i,"End"))))}unmount(){}}class eh extends Rt{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=Ve(De(this.node.current,"focus",()=>this.onFocus()),De(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function uo(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),r=s[i];r&&B.postRender(()=>r(e,Ne(e)))}class nh extends Rt{mount(){const{current:e}=this.node;e&&(this.unmount=Pc(e,(n,s)=>(uo(this.node,s,"Start"),(i,{success:r})=>uo(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Zn=new WeakMap,jn=new WeakMap,sh=t=>{const e=Zn.get(t.target);e&&e(t)},ih=t=>{t.forEach(sh)};function oh({root:t,...e}){const n=t||document;jn.has(n)||jn.set(n,{});const s=jn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(ih,{root:t,...e})),s[i]}function rh(t,e,n){const s=oh(e);return Zn.set(t,n),s.observe(t),()=>{Zn.delete(t),s.unobserve(t)}}const ah={some:0,all:1};class lh extends Rt{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:r}=e,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:ah[i]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,r&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=u?c:d;f&&f(l)};return rh(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(ch(e,n))&&this.startObserver()}unmount(){}}function ch({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Yr={inView:{Feature:lh},tap:{Feature:nh},focus:{Feature:eh},hover:{Feature:th}},uh={layout:{ProjectionNode:Gr,MeasureLayout:$r}},dh={...Nr,...Yr,...Qd,...uh},hh=mu(dh,jr),fh={renderer:jr,...Nr,...Yr};function qr(t,e){return Ge(t,e)}const We=qr("div"),mh=qr("p"),bt=Symbol.for("@arcteninc/core:originalName");function ph(t,e){return t[bt]=e,t}function gh(t,e,n,s){if(typeof t!="function")return null;const i=t[bt];if(i){const a=e[i];if(a&&!n.has(a.name))return{fn:t,meta:a}}const r=t.name;let o;if(r&&(o=e[r],o&&!n.has(o.name)))return t[bt]=o.name,{fn:t,meta:o};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(o=e[a],o))return t[bt]=o.name,{fn:t,meta:o}}else if(o=Object.values(e).find(l=>!n.has(l.name)),o)return t[bt]=o.name,{fn:t,meta:o};return null}function Zr(t,e){let n,s;if(!e)throw new Error(`❌ toolMetadata is required!
|
|
9
|
+
`),()=>{w.contains(v)&&w.removeChild(v)}},[e]),h.jsx(Ic,{isPresent:e,childRef:r,sizeRef:o,children:ft.cloneElement(t,{ref:l})})}const Oc=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,root:l})=>{const u=is(Fc),c=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:c,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const y of u.values())if(!y)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return r&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,y)=>u.set(y,!1))},[n]),ft.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),o==="popLayout"&&(t=h.jsx(Lc,{isPresent:n,anchorX:a,root:l,children:t})),h.jsx(rn.Provider,{value:f,children:t})};function Fc(){return new Map}function ur(t=!0){const e=m.useContext(rn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,r=m.useId();m.useEffect(()=>{if(t)return i(r)},[t]);const o=m.useCallback(()=>t&&s&&s(r),[r,s,t]);return!n&&s?[!1,o]:[!0]}const We=t=>t.key||"";function wi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Bc=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",root:l})=>{const[u,c]=ur(o),d=m.useMemo(()=>wi(t),[t]),f=o&&!u?[]:d.map(We),g=m.useRef(!0),y=m.useRef(d),v=is(()=>new Map),[w,x]=m.useState(d),[C,b]=m.useState(d);vo(()=>{g.current=!1,y.current=d;for(let D=0;D<C.length;D++){const N=We(C[D]);f.includes(N)?v.delete(N):v.get(N)!==!0&&v.set(N,!1)}},[C,f.length,f.join("-")]);const k=[];if(d!==w){let D=[...d];for(let N=0;N<C.length;N++){const P=C[N],L=We(P);f.includes(L)||(D.splice(N,0,P),k.push(P))}return r==="wait"&&k.length&&(D=k),b(wi(D)),x(d),null}process.env.NODE_ENV!=="production"&&r==="wait"&&C.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:A}=m.useContext(ss);return h.jsx(h.Fragment,{children:C.map(D=>{const N=We(D),P=o&&!u?!1:d===C||f.includes(N),L=()=>{if(v.has(N))v.set(N,!0);else return;let W=!0;v.forEach(U=>{U||(W=!1)}),W&&(A?.(),b(y.current),o&&c?.(),s&&s())};return h.jsx(Oc,{isPresent:P,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:r,root:l,onExitComplete:P?void 0:L,anchorX:a,children:D},N)})})},js=m.createContext({strict:!1}),Ti={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"]},ae={};for(const t in Ti)ae[t]={isEnabled:e=>Ti[t].some(n=>!!e[n])};function Hn(t){for(const e in t)ae[e]={...ae[e],...t[e]}}function $c({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!Tn(e)),i=m.useRef(void 0);if(!Tn(e)){const{renderer:r,...o}=e;i.current=r,Hn(o)}return m.useEffect(()=>{Tn(e)&&e().then(({renderer:r,...o})=>{Hn(o),i.current=r,s(!0)})},[]),h.jsx(js.Provider,{value:{renderer:i.current,strict:n},children:t})}function Tn(t){return typeof t=="function"}const zc=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 sn(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||zc.has(t)}let dr=t=>!sn(t);function Uc(t){typeof t=="function"&&(dr=e=>e.startsWith("on")?!sn(e):t(e))}try{Uc(require("@emotion/is-prop-valid").default)}catch{}function _c(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(dr(i)||n===!0&&sn(i)||!e&&!sn(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const an=m.createContext({});function ln(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function De(t){return typeof t=="string"||Array.isArray(t)}const Es=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Ds=["initial",...Es];function cn(t){return ln(t.animate)||Ds.some(e=>De(t[e]))}function hr(t){return!!(cn(t)||t.variants)}function Wc(t,e){if(cn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||De(n)?n:void 0,animate:De(s)?s:void 0}}return t.inherit!==!1?e:{}}function Kc(t){const{initial:e,animate:n}=Wc(t,m.useContext(an));return m.useMemo(()=>({initial:e,animate:n}),[Si(e),Si(n)])}function Si(t){return Array.isArray(t)?t.join(" "):t}const Ve={};function Hc(t){for(const e in t)Ve[e]=t[e],fs(e)&&(Ve[e].isCSSVariable=!0)}function fr(t,{layout:e,layoutId:n}){return de.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Ve[t]||t==="opacity")}const Xc={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Gc=ue.length;function Yc(t,e,n){let s="",i=!0;for(let r=0;r<Gc;r++){const o=ue[r],a=t[o];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(o.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=ir(a,Cs[o]);if(!l){i=!1;const c=Xc[o]||o;s+=`${c}(${u}) `}n&&(e[o]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function Vs(t,e,n){const{style:s,vars:i,transformOrigin:r}=t;let o=!1,a=!1;for(const l in e){const u=e[l];if(de.has(l)){o=!0;continue}else if(fs(l)){i[l]=u;continue}else{const c=ir(u,Cs[l]);l.startsWith("origin")?(a=!0,r[l]=c):s[l]=c}}if(e.transform||(o||n?s.transform=Yc(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:c=0}=r;s.transformOrigin=`${l} ${u} ${c}`}}const ks=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function mr(t,e,n){for(const s in e)!et(e[s])&&!fr(s,n)&&(t[s]=e[s])}function qc({transformTemplate:t},e){return m.useMemo(()=>{const n=ks();return Vs(n,e,t),Object.assign({},n.vars,n.style)},[e])}function Jc(t,e){const n=t.style||{},s={};return mr(s,n,t),Object.assign(s,qc(t,e)),s}function Zc(t,e){const n={},s=Jc(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 Qc={offset:"stroke-dashoffset",array:"stroke-dasharray"},tu={offset:"strokeDashoffset",array:"strokeDasharray"};function eu(t,e,n=1,s=0,i=!0){t.pathLength=1;const r=i?Qc:tu;t[r.offset]=j.transform(-s);const o=j.transform(e),a=j.transform(n);t[r.array]=`${o} ${a}`}function pr(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,u,c){if(Vs(t,a,u),l){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=c?.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&&eu(d,i,r,o,!1)}const gr=()=>({...ks(),attrs:{}}),yr=t=>typeof t=="string"&&t.toLowerCase()==="svg";function nu(t,e,n,s){const i=m.useMemo(()=>{const r=gr();return pr(r,e,yr(s),t.transformTemplate,t.style),{...r.attrs,style:{...r.style}}},[e]);if(t.style){const r={};mr(r,t.style,t),i.style={...r,...i.style}}return i}const su=["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 Rs(t){return typeof t!="string"||t.includes("-")?!1:!!(su.indexOf(t)>-1||/[A-Z]/u.test(t))}function iu(t,e,n,{latestValues:s},i,r=!1){const a=(Rs(t)?nu:Zc)(e,s,i,t),l=_c(e,typeof t=="string",r),u=t!==m.Fragment?{...l,...a,ref:n}:{},{children:c}=e,d=m.useMemo(()=>et(c)?c.get():c,[c]);return m.createElement(t,{...u,children:d})}function Ci(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function Ns(t,e,n,s){if(typeof e=="function"){const[i,r]=Ci(s);e=e(n!==void 0?n:t.custom,i,r)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,r]=Ci(s);e=e(n!==void 0?n:t.custom,i,r)}return e}function Ye(t){return et(t)?t.get():t}function ou({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:ru(n,s,i,t),renderState:e()}}function ru(t,e,n,s){const i={},r=s(t,{});for(const f in r)i[f]=Ye(r[f]);let{initial:o,animate:a}=t;const l=cn(t),u=hr(t);e&&u&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let c=n?n.initial===!1:!1;c=c||o===!1;const d=c?a:o;if(d&&typeof d!="boolean"&&!ln(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const y=Ns(t,f[g]);if(y){const{transitionEnd:v,transition:w,...x}=y;for(const C in x){let b=x[C];if(Array.isArray(b)){const k=c?b.length-1:0;b=b[k]}b!==null&&(i[C]=b)}for(const C in v)i[C]=v[C]}}}return i}const xr=t=>(e,n)=>{const s=m.useContext(an),i=m.useContext(rn),r=()=>ou(t,e,s,i);return n?r():is(r)};function Is(t,e,n){const{style:s}=t,i={};for(const r in s)(et(s[r])||e.style&&et(e.style[r])||fr(r,t)||n?.getValue(r)?.liveStyle!==void 0)&&(i[r]=s[r]);return i}const au=xr({scrapeMotionValuesFromProps:Is,createRenderState:ks});function vr(t,e,n){const s=Is(t,e,n);for(const i in t)if(et(t[i])||et(e[i])){const r=ue.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=t[i]}return s}const lu=xr({scrapeMotionValuesFromProps:vr,createRenderState:gr}),cu=Symbol.for("motionComponentSymbol");function te(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function uu(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 Ls=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),du="framerAppearId",br="data-"+Ls(du),wr=m.createContext({});function hu(t,e,n,s,i){const{visualElement:r}=m.useContext(an),o=m.useContext(js),a=m.useContext(rn),l=m.useContext(Ms).reducedMotion,u=m.useRef(null);s=s||o.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:r,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const c=u.current,d=m.useContext(wr);c&&!c.projection&&i&&(c.type==="html"||c.type==="svg")&&fu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{c&&f.current&&c.update(n,a)});const g=n[br],y=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return vo(()=>{c&&(f.current=!0,window.MotionIsMounted=!0,c.updateFeatures(),c.scheduleRenderMicrotask(),y.current&&c.animationState&&c.animationState.animateChanges())}),m.useEffect(()=>{c&&(!y.current&&c.animationState&&c.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),y.current=!1),c.enteringChildren=void 0)}),c}function fu(t,e,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:Tr(t.parent)),t.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&te(a),visualElement:t,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u})}function Tr(t){if(t)return t.options.allowProjection!==!1?t.projection:Tr(t.parent)}function qe(t,{forwardMotionProps:e=!1}={},n,s){n&&Hn(n);const i=Rs(t)?lu:au;function r(a,l){let u;const c={...m.useContext(Ms),...a,layoutId:mu(a)},{isStatic:d}=c,f=Kc(a),g=i(a,d);if(!d&&os){pu(c,n);const y=gu(c);u=y.MeasureLayout,f.visualElement=hu(t,g,c,s,y.ProjectionNode)}return h.jsxs(an.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...c}):null,iu(t,a,uu(g,f.visualElement,l),g,d,e)]})}r.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const o=m.forwardRef(r);return o[cu]=t,o}function mu({layoutId:t}){const e=m.useContext(ss).id;return e&&t!==void 0?e+"-"+t:t}function pu(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?le(!1,s,"lazy-strict-mode"):At(!1,s,"lazy-strict-mode")}}function gu(t){const{drag:e,layout:n}=ae;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function yu(t,e){if(typeof Proxy>"u")return qe;const n=new Map,s=(r,o)=>qe(r,o,t,e),i=(r,o)=>(process.env.NODE_ENV!=="production"&&us(!1,"motion() is deprecated. Use motion.create() instead."),s(r,o));return new Proxy(i,{get:(r,o)=>o==="create"?s:(n.has(o)||n.set(o,qe(o,void 0,t,e)),n.get(o))})}function Sr({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function xu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function vu(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 Sn(t){return t===void 0||t===1}function Xn({scale:t,scaleX:e,scaleY:n}){return!Sn(t)||!Sn(e)||!Sn(n)}function Wt(t){return Xn(t)||Cr(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Cr(t){return Ai(t.x)||Ai(t.y)}function Ai(t){return t&&t!=="0%"}function on(t,e,n){const s=t-n,i=e*s;return n+i}function Pi(t,e,n,s,i){return i!==void 0&&(t=on(t,i,s)),on(t,n,s)+e}function Gn(t,e=0,n=1,s,i){t.min=Pi(t.min,e,n,s,i),t.max=Pi(t.max,e,n,s,i)}function Ar(t,{x:e,y:n}){Gn(t.x,e.translate,e.scale,e.originPoint),Gn(t.y,n.translate,n.scale,n.originPoint)}const Mi=.999999999999,ji=1.0000000000001;function bu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let r,o;for(let a=0;a<i;a++){r=n[a],o=r.projectionDelta;const{visualElement:l}=r.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&ne(t,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,Ar(t,o)),s&&Wt(r.latestValues)&&ne(t,r.latestValues))}e.x<ji&&e.x>Mi&&(e.x=1),e.y<ji&&e.y>Mi&&(e.y=1)}function ee(t,e){t.min=t.min+e,t.max=t.max+e}function Ei(t,e,n,s,i=.5){const r=z(t.min,t.max,i);Gn(t,e,n,r,s)}function ne(t,e){Ei(t.x,e.x,e.scaleX,e.scale,e.originX),Ei(t.y,e.y,e.scaleY,e.scale,e.originY)}function Pr(t,e){return Sr(vu(t.getBoundingClientRect(),e))}function wu(t,e,n){const s=Pr(t,n),{scroll:i}=e;return i&&(ee(s.x,i.offset.x),ee(s.y,i.offset.y)),s}const Di=()=>({translate:0,scale:1,origin:0,originPoint:0}),se=()=>({x:Di(),y:Di()}),Vi=()=>({min:0,max:0}),K=()=>({x:Vi(),y:Vi()}),Yn={current:null},Mr={current:!1};function Tu(){if(Mr.current=!0,!!os)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Yn.current=t.matches;t.addEventListener("change",e),e()}else Yn.current=!1}const Su=new WeakMap;function Cu(t,e,n){for(const s in e){const i=e[s],r=n[s];if(et(i))t.addValue(s,i);else if(et(r))t.addValue(s,re(i,{owner:t}));else if(r!==i)if(t.hasValue(s)){const o=t.getValue(s);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=t.getStaticValue(s);t.addValue(s,re(o!==void 0?o:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const ki=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Au{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:r,visualState:o},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Ts,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=st.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,B.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},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=!!r,this.isControllingVariants=cn(n),this.isVariantNode=hr(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];l[f]!==void 0&&et(g)&&g.set(l[f])}}mount(e){this.current=e,Su.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)),Mr.current||Tu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Yn.current,process.env.NODE_ENV!=="production"&&us(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(),kt(this.notifyUpdate),kt(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",o=>{this.latestValues[e]=o,this.props.onUpdate&&B.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),r&&r(),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 ae){const n=ae[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 r=this.features[e];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):K()}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<ki.length;s++){const i=ki[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const r="on"+i,o=e[r];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=Cu(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=re(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"&&(bo(s)||To(s))?s=parseFloat(s):!kc(s)&&Rt.test(n)&&(s=sr(e,n)),this.setBaseTarget(e,et(s)?s.get():s)),et(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 r=Ns(this.props,n,this.presenceContext?.custom);r&&(s=r[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!et(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 cs),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){As.render(this.render)}}class jr extends Au{constructor(){super(...arguments),this.KeyframeResolver=bc}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;et(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Er(t,{style:e,vars:n},s,i){const r=t.style;let o;for(o in e)r[o]=e[o];i?.applyProjectionStyles(r,s);for(o in n)r.setProperty(o,n[o])}function Pu(t){return window.getComputedStyle(t)}class Mu extends jr{constructor(){super(...arguments),this.type="html",this.renderInstance=Er}readValueFromInstance(e,n){if(de.has(n))return this.projection?.isProjecting?Bn(n):Fl(e,n);{const s=Pu(e),i=(fs(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Pr(e,n)}build(e,n,s){Vs(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return Is(e,n,s)}}const Dr=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 ju(t,e,n,s){Er(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Dr.has(i)?i:Ls(i),e.attrs[i])}class Eu extends jr{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=K}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(de.has(n)){const s=nr(n);return s&&s.default||0}return n=Dr.has(n)?n:Ls(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return vr(e,n,s)}build(e,n,s){pr(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){ju(e,n,s,i)}mount(e){this.isSVGTag=yr(e.tagName),super.mount(e)}}const Vr=(t,e)=>Rs(t)?new Eu(e):new Mu(e,{allowProjection:t!==m.Fragment});function oe(t,e,n){const s=t.getProps();return Ns(s,e,n!==void 0?n:s.custom,t)}const qn=t=>Array.isArray(t);function Du(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,re(n))}function Vu(t){return qn(t)?t[t.length-1]||0:t}function ku(t,e){const n=oe(t,e);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=Vu(r[o]);Du(t,o,a)}}function Ru(t){return!!(et(t)&&t.add)}function Jn(t,e){const n=t.getValue("willChange");if(Ru(n))return n.add(e);if(!n&&Pt.WillChange){const s=new Pt.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function kr(t){return t.props[br]}const Nu=t=>t!==null;function Iu(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Nu),r=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[r]}const Lu={type:"spring",stiffness:500,damping:25,restSpeed:10},Ou=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Fu={type:"keyframes",duration:.8},Bu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},$u=(t,{keyframes:e})=>e.length>2?Fu:de.has(t)?t.startsWith("scale")?Ou(e[1]):Lu:Bu;function zu({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:u,...c}){return!!Object.keys(c).length}const Os=(t,e,n,s={},i,r)=>o=>{const a=Ss(s,t)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-mt(l);const c={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:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:r?void 0:i};zu(a)||Object.assign(c,$u(t,c)),c.duration&&(c.duration=mt(c.duration)),c.repeatDelay&&(c.repeatDelay=mt(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let d=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(Wn(c),c.delay===0&&(d=!0)),(Pt.instantAnimations||Pt.skipAnimations)&&(d=!0,Wn(c),c.delay=0),c.allowFlatten=!a.type&&!a.ease,d&&!r&&e.get()!==void 0){const f=Iu(c.keyframes,a);if(f!==void 0){B.update(()=>{c.onUpdate(f),c.onComplete()});return}}return a.isSync?new ws(c):new ac(c)};function Uu({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Rr(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r=t.getDefaultTransition(),transitionEnd:o,...a}=e;s&&(r=s);const l=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const c in a){const d=t.getValue(c,t.latestValues[c]??null),f=a[c];if(f===void 0||u&&Uu(u,c))continue;const g={delay:n,...Ss(r||{},c)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const x=kr(t);if(x){const C=window.MotionHandoffAnimation(x,c,B);C!==null&&(g.startTime=C,v=!0)}}Jn(t,c),d.start(Os(c,d,f,t.shouldReduceMotion&&Qo.has(c)?{type:!1}:g,t,v));const w=d.animation;w&&l.push(w)}return o&&Promise.all(l).then(()=>{B.update(()=>{o&&ku(t,o)})}),l}function Nr(t,e,n,s=0,i=1){const r=Array.from(t).sort((u,c)=>u.sortNodePosition(c)).indexOf(e),o=t.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}function Zn(t,e,n={}){const s=oe(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const r=s?()=>Promise.all(Rr(t,s,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:c,staggerDirection:d}=i;return _u(t,e,l,u,c,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,u]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>u())}else return Promise.all([r(),o(n.delay)])}function _u(t,e,n=0,s=0,i=0,r=1,o){const a=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),a.push(Zn(l,e,{...o,delay:n+(typeof s=="function"?0:s)+Nr(t.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function Wu(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(r=>Zn(t,r,n));s=Promise.all(i)}else if(typeof e=="string")s=Zn(t,e,n);else{const i=typeof e=="function"?oe(t,e,n.custom):e;s=Promise.all(Rr(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function Ir(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 Ku=Ds.length;function Lr(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Lr(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Ku;n++){const s=Ds[n],i=t.props[s];(De(i)||i===!1)&&(e[s]=i)}return e}const Hu=[...Es].reverse(),Xu=Es.length;function Gu(t){return e=>Promise.all(e.map(({animation:n,options:s})=>Wu(t,n,s)))}function Yu(t){let e=Gu(t),n=Ri(),s=!0;const i=l=>(u,c)=>{const d=oe(t,c,l==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...y}=d;u={...u,...y,...g}}return u};function r(l){e=l(t)}function o(l){const{props:u}=t,c=Lr(t.parent)||{},d=[],f=new Set;let g={},y=1/0;for(let w=0;w<Xu;w++){const x=Hu[w],C=n[x],b=u[x]!==void 0?u[x]:c[x],k=De(b),A=x===l?C.isActive:null;A===!1&&(y=w);let D=b===c[x]&&b!==u[x]&&k;if(D&&s&&t.manuallyAnimateOnMount&&(D=!1),C.protectedKeys={...g},!C.isActive&&A===null||!b&&!C.prevProp||ln(b)||typeof b=="boolean")continue;const N=qu(C.prevProp,b);let P=N||x===l&&C.isActive&&!D&&k||w>y&&k,L=!1;const W=Array.isArray(b)?b:[b];let U=W.reduce(i(x),{});A===!1&&(U={});const{prevResolvedValues:Tt={}}=C,Mt={...Tt,...U},dt=V=>{P=!0,f.has(V)&&(L=!0,f.delete(V)),C.needsAnimating[V]=!0;const Y=t.getValue(V);Y&&(Y.liveStyle=!1)};for(const V in Mt){const Y=U[V],H=Tt[V];if(g.hasOwnProperty(V))continue;let ot=!1;qn(Y)&&qn(H)?ot=!Ir(Y,H):ot=Y!==H,ot?Y!=null?dt(V):f.add(V):Y!==void 0&&f.has(V)?dt(V):C.protectedKeys[V]=!0}C.prevProp=b,C.prevResolvedValues=U,C.isActive&&(g={...g,...U}),s&&t.blockInitialAnimation&&(P=!1);const it=D&&N;P&&(!it||L)&&d.push(...W.map(V=>{const Y={type:x};if(typeof V=="string"&&s&&!it&&t.manuallyAnimateOnMount&&t.parent){const{parent:H}=t,ot=oe(H,V);if(H.enteringChildren&&ot){const{delayChildren:_}=ot.transition||{};Y.delay=Nr(H.enteringChildren,t,_)}}return{animation:V,options:Y}}))}if(f.size){const w={};if(typeof u.initial!="boolean"){const x=oe(t,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(w.transition=x.transition)}f.forEach(x=>{const C=t.getBaseTarget(x),b=t.getValue(x);b&&(b.liveStyle=!0),w[x]=C??null}),d.push({animation:w})}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(l,u){if(n[l].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(l,u)),n[l].isActive=u;const c=o(l);for(const d in n)n[d].protectedKeys={};return c}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Ri()}}}function qu(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Ir(e,t):!1}function Ut(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Ri(){return{animate:Ut(!0),whileInView:Ut(),whileHover:Ut(),whileTap:Ut(),whileDrag:Ut(),whileFocus:Ut(),exit:Ut()}}class Nt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Ju extends Nt{constructor(e){super(e),e.animationState||(e.animationState=Yu(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();ln(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 Zu=0;class Qu extends Nt{constructor(){super(...arguments),this.id=Zu++}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 Or={animation:{Feature:Ju},exit:{Feature:Qu}};function ke(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function Le(t){return{point:{x:t.pageX,y:t.pageY}}}const td=t=>e=>Ps(e)&&t(e,Le(e));function Ce(t,e,n,s){return ke(t,e,td(n),s)}const Fr=1e-4,ed=1-Fr,nd=1+Fr,Br=.01,sd=0-Br,id=0+Br;function nt(t){return t.max-t.min}function od(t,e,n){return Math.abs(t-e)<=n}function Ni(t,e,n,s=.5){t.origin=s,t.originPoint=z(e.min,e.max,t.origin),t.scale=nt(n)/nt(e),t.translate=z(n.min,n.max,t.origin)-t.originPoint,(t.scale>=ed&&t.scale<=nd||isNaN(t.scale))&&(t.scale=1),(t.translate>=sd&&t.translate<=id||isNaN(t.translate))&&(t.translate=0)}function Ae(t,e,n,s){Ni(t.x,e.x,n.x,s?s.originX:void 0),Ni(t.y,e.y,n.y,s?s.originY:void 0)}function Ii(t,e,n){t.min=n.min+e.min,t.max=t.min+nt(e)}function rd(t,e,n){Ii(t.x,e.x,n.x),Ii(t.y,e.y,n.y)}function Li(t,e,n){t.min=e.min-n.min,t.max=t.min+nt(e)}function Pe(t,e,n){Li(t.x,e.x,n.x),Li(t.y,e.y,n.y)}function lt(t){return[t("x"),t("y")]}const $r=({current:t})=>t?t.ownerDocument.defaultView:null,Oi=(t,e)=>Math.abs(t-e);function ad(t,e){const n=Oi(t.x,e.x),s=Oi(t.y,e.y);return Math.sqrt(n**2+s**2)}class zr{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:r=!1,distanceThreshold:o=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=An(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=ad(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:v}=f,{timestamp:w}=Z;this.history.push({...v,timestamp:w});const{onStart:x,onMove:C}=this.handlers;g||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),C&&C(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Cn(g,this.transformPagePoint),B.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:v,resumeAnimation:w}=this.handlers;if(this.dragSnapToOrigin&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=An(f.type==="pointercancel"?this.lastMoveEventInfo:Cn(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!Ps(e))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const a=Le(e),l=Cn(a,this.transformPagePoint),{point:u}=l,{timestamp:c}=Z;this.history=[{...u,timestamp:c}];const{onSessionStart:d}=n;d&&d(e,An(l,this.history)),this.removeListeners=Re(Ce(this.contextWindow,"pointermove",this.handlePointerMove),Ce(this.contextWindow,"pointerup",this.handlePointerUp),Ce(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),kt(this.updatePoint)}}function Cn(t,e){return e?{point:e(t.point)}:t}function Fi(t,e){return{x:t.x-e.x,y:t.y-e.y}}function An({point:t},e){return{point:t,delta:Fi(t,Ur(e)),offset:Fi(t,ld(e)),velocity:cd(e,.1)}}function ld(t){return t[0]}function Ur(t){return t[t.length-1]}function cd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Ur(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>mt(e)));)n--;if(!s)return{x:0,y:0};const r=ct(i.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const o={x:(i.x-s.x)/r,y:(i.y-s.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function ud(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?z(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?z(n,t,s.max):Math.min(t,n)),t}function Bi(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 dd(t,{top:e,left:n,bottom:s,right:i}){return{x:Bi(t.x,n,i),y:Bi(t.y,e,s)}}function $i(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 hd(t,e){return{x:$i(t.x,e.x),y:$i(t.y,e.y)}}function fd(t,e){let n=.5;const s=nt(t),i=nt(e);return i>s?n=Me(e.min,e.max-s,t.min):s>i&&(n=Me(t.min,t.max-i,e.min)),Ct(0,1,n)}function md(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 Qn=.35;function pd(t=Qn){return t===!1?t=0:t===!0&&(t=Qn),{x:zi(t,"left","right"),y:zi(t,"top","bottom")}}function zi(t,e,n){return{min:Ui(t,e),max:Ui(t,n)}}function Ui(t,e){return typeof t=="number"?t:t[e]||0}const gd=new WeakMap;class yd{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=K(),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 r=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Le(d).point)},o=(d,f)=>{const{drag:g,dragPropagation:y,onDragStart:v}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Cc(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),lt(x=>{let C=this.getAxisMotionValue(x).get()||0;if(wt.test(C)){const{projection:b}=this.visualElement;if(b&&b.layout){const k=b.layout.layoutBox[x];k&&(C=nt(k)*(parseFloat(C)/100))}}this.originPoint[x]=C}),v&&B.postRender(()=>v(d,f)),Jn(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:v,onDrag:w}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:x}=f;if(y&&this.currentDirection===null){this.currentDirection=xd(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),w&&w(d,f)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>lt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new zr(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:s,contextWindow:$r(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!i||!s)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&B.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||!Ke(e,i,this.currentDirection))return;const r=this.getAxisMotionValue(e);let o=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(o=ud(o,this.constraints[e],this.elastic[e])),r.set(o)}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=dd(s.layoutBox,e):this.constraints=!1,this.elastic=pd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&<(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=md(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!te(e))return!1;const s=e.current;At(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const r=wu(s,i.root,this.visualElement.getTransformPagePoint());let o=hd(i.layout.layoutBox,r);if(n){const a=n(xu(o));this.hasMutatedConstraints=!!a,a&&(o=Sr(a))}return o}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=lt(c=>{if(!Ke(c,n,this.currentDirection))return;let d=l&&l[c]||{};o&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,y={type:"inertia",velocity:s?e[c]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...r,...d};return this.startAxisValueAnimation(c,y)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Jn(this.visualElement,e),s.start(Os(e,s,0,n,this.visualElement,!1))}stopAnimation(){lt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){lt(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){lt(n=>{const{drag:s}=this.getProps();if(!Ke(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,r=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n];r.set(e[n]-z(o,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};lt(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();i[o]=fd({min:l,max:l},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),lt(o=>{if(!Ke(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:u}=this.constraints[o];a.set(z(l,u,i[o]))})}addListeners(){if(!this.visualElement.current)return;gd.set(this.visualElement,this);const e=this.visualElement.current,n=Ce(e,"pointerdown",l=>{const{drag:u,dragListener:c=!0}=this.getProps();u&&c&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();te(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,r=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),B.read(s);const o=ke(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(lt(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=l[c].translate,d.set(d.get()+l[c].translate))}),this.visualElement.render())});return()=>{o(),n(),r(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=Qn,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function Ke(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function xd(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class vd extends Nt{constructor(e){super(e),this.removeGroupControls=ut,this.removeListeners=ut,this.controls=new yd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ut}unmount(){this.removeGroupControls(),this.removeListeners()}}const _i=t=>(e,n)=>{t&&B.postRender(()=>t(e,n))};class bd extends Nt{constructor(){super(...arguments),this.removePointerDownListener=ut}onPointerDown(e){this.session=new zr(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:$r(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:_i(e),onStart:_i(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&B.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=Ce(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 Je={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Wi(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const we={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(j.test(t))t=parseFloat(t);else return t;const n=Wi(t,e.target.x),s=Wi(t,e.target.y);return`${n}% ${s}%`}},wd={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Rt.parse(t);if(i.length>5)return s;const r=Rt.createTransformer(t),o=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,l=n.y.scale*e.y;i[0+o]/=a,i[1+o]/=l;const u=z(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=u),typeof i[3+o]=="number"&&(i[3+o]/=u),r(i)}};let Pn=!1;class Td extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=e;Hc(Sd),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),Pn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),Je.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,Pn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==r?o.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?o.promote():o.relegate()||B.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),As.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;Pn=!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 _r(t){const[e,n]=ur(),s=m.useContext(ss);return h.jsx(Td,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(wr),isPresent:e,safeToRemove:n})}const Sd={borderRadius:{...we,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:we,borderTopRightRadius:we,borderBottomLeftRadius:we,borderBottomRightRadius:we,boxShadow:wd};function Cd(t,e,n){const s=et(t)?t:re(t);return s.start(Os("",s,e,n)),s.animation}const Ad=(t,e)=>t.depth-e.depth;class Pd{constructor(){this.children=[],this.isDirty=!1}add(e){rs(this.children,e),this.isDirty=!0}remove(e){as(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Ad),this.isDirty=!1,this.children.forEach(e)}}function Md(t,e){const n=st.now(),s=({timestamp:i})=>{const r=i-n;r>=e&&(kt(s),t(r-e))};return B.setup(s,!0),()=>kt(s)}const Wr=["TopLeft","TopRight","BottomLeft","BottomRight"],jd=Wr.length,Ki=t=>typeof t=="string"?parseFloat(t):t,Hi=t=>typeof t=="number"||j.test(t);function Ed(t,e,n,s,i,r){i?(t.opacity=z(0,n.opacity??1,Dd(s)),t.opacityExit=z(e.opacity??1,0,Vd(s))):r&&(t.opacity=z(e.opacity??1,n.opacity??1,s));for(let o=0;o<jd;o++){const a=`border${Wr[o]}Radius`;let l=Xi(e,a),u=Xi(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Hi(l)===Hi(u)?(t[a]=Math.max(z(Ki(l),Ki(u),s),0),(wt.test(u)||wt.test(l))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=z(e.rotate||0,n.rotate||0,s))}function Xi(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Dd=Kr(0,.5,Do),Vd=Kr(.5,.95,ut);function Kr(t,e,n){return s=>s<t?0:s>e?1:n(Me(t,e,s))}function Gi(t,e){t.min=e.min,t.max=e.max}function at(t,e){Gi(t.x,e.x),Gi(t.y,e.y)}function Yi(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function qi(t,e,n,s,i){return t-=e,t=on(t,1/n,s),i!==void 0&&(t=on(t,1/i,s)),t}function kd(t,e=0,n=1,s=.5,i,r=t,o=t){if(wt.test(e)&&(e=parseFloat(e),e=z(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=z(r.min,r.max,s);t===r&&(a-=e),t.min=qi(t.min,e,n,a,i),t.max=qi(t.max,e,n,a,i)}function Ji(t,e,[n,s,i],r,o){kd(t,e[n],e[s],e[i],e.scale,r,o)}const Rd=["x","scaleX","originX"],Nd=["y","scaleY","originY"];function Zi(t,e,n,s){Ji(t.x,e,Rd,n?n.x:void 0,s?s.x:void 0),Ji(t.y,e,Nd,n?n.y:void 0,s?s.y:void 0)}function Qi(t){return t.translate===0&&t.scale===1}function Hr(t){return Qi(t.x)&&Qi(t.y)}function to(t,e){return t.min===e.min&&t.max===e.max}function Id(t,e){return to(t.x,e.x)&&to(t.y,e.y)}function eo(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function Xr(t,e){return eo(t.x,e.x)&&eo(t.y,e.y)}function no(t){return nt(t.x)/nt(t.y)}function so(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class Ld{constructor(){this.members=[]}add(e){rs(this.members,e),e.scheduleRender()}remove(e){if(as(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 r=this.members[i];if(r.isPresent!==!1){s=r;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 Od(t,e,n){let s="";const i=t.x.translate/e.x,r=t.y.translate/e.y,o=n?.z||0;if((i||r||o)&&(s=`translate3d(${i}px, ${r}px, ${o}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:c,rotateX:d,rotateY:f,skewX:g,skewY:y}=n;u&&(s=`perspective(${u}px) ${s}`),c&&(s+=`rotate(${c}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),y&&(s+=`skewY(${y}deg) `)}const a=t.x.scale*e.x,l=t.y.scale*e.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const Mn=["","X","Y","Z"],Fd=1e3;let Bd=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 Gr(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=kr(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",B,!(i||r))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&Gr(s)}function Yr({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Bd++,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(Ud),this.nodes.forEach(Hd),this.nodes.forEach(Xd),this.nodes.forEach(_d)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Pd)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new cs),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const l=this.eventHandlers.get(o);l&&l.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=cr(o)&&!Dc(o),this.instance=o;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let c,d=0;const f=()=>this.root.updateBlockedByResize=!1;B.read(()=>{d=window.innerWidth}),t(o,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,c&&c(),c=Md(f,250),Je.hasAnimatedSinceResize&&(Je.hasAnimatedSinceResize=!1,this.nodes.forEach(ro)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||u.getDefaultTransition()||Zd,{onLayoutAnimationStart:v,onLayoutAnimationComplete:w}=u.getProps(),x=!this.targetLayout||!Xr(this.targetLayout,g),C=!d&&f;if(this.options.layoutRoot||this.resumeFrom||C||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...Ss(y,"layout"),onPlay:v,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(c,C)}else d||ro(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),kt(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(Gd),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Gr(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const d=this.path[c];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(io);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(oo);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Kd),this.nodes.forEach($d),this.nodes.forEach(zd)):this.nodes.forEach(oo),this.clearAllSnapshots();const a=st.now();Z.delta=Ct(0,1e3/60,a-Z.timestamp),Z.timestamp=a,Z.isProcessing=!0,gn.update.process(Z),gn.preRender.process(Z),gn.render.process(Z),Z.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,As.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Wd),this.sharedNodes.forEach(Yd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,B.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){B.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!nt(this.snapshot.measuredBox.x)&&!nt(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=K(),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,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Hr(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,c=u!==this.prevTransformTemplateValue;o&&this.instance&&(a||Wt(this.latestValues)||c)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),Qd(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return K();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(th))){const{scroll:u}=this.root;u&&(ee(a.x,u.offset.x),ee(a.y,u.offset.y))}return a}removeElementScroll(o){const a=K();if(at(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:c,options:d}=u;u!==this.root&&c&&d.layoutScroll&&(c.wasRoot&&at(a,o),ee(a.x,c.offset.x),ee(a.y,c.offset.y))}return a}applyTransform(o,a=!1){const l=K();at(l,o);for(let u=0;u<this.path.length;u++){const c=this.path[u];!a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&ne(l,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),Wt(c.latestValues)&&ne(l,c.latestValues)}return Wt(this.latestValues)&&ne(l,this.latestValues),l}removeTransform(o){const a=K();at(a,o);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Wt(u.latestValues))continue;Xn(u.latestValues)&&u.updateSnapshot();const c=K(),d=u.measurePageBox();at(c,d),Zi(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,c)}return Wt(this.latestValues)&&Zi(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.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(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:d}=this.options;if(!(!this.layout||!(c||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=K(),this.relativeTargetOrigin=K(),Pe(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),at(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=K(),this.targetWithTransforms=K()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),rd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):at(this.target,this.layout.layoutBox),Ar(this.target,this.targetDelta)):at(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=K(),this.relativeTargetOrigin=K(),Pe(this.relativeTargetOrigin,this.target,f.target),at(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||Xn(this.parent.latestValues)||Cr(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 o=this.getLead(),a=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===Z.timestamp&&(l=!1),l)return;const{layout:u,layoutId:c}=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||c))return;at(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;bu(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=K());const{target:g}=o;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Yi(this.prevProjectionDelta.x,this.projectionDelta.x),Yi(this.prevProjectionDelta.y,this.projectionDelta.y)),Ae(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!so(this.projectionDelta.x,this.prevProjectionDelta.x)||!so(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){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(o,a=!1){const l=this.snapshot,u=l?l.latestValues:{},c={...this.latestValues},d=se();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=K(),g=l?l.source:void 0,y=this.layout?this.layout.source:void 0,v=g!==y,w=this.getStack(),x=!w||w.members.length<=1,C=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(Jd));this.animationProgress=0;let b;this.mixTargetDelta=k=>{const A=k/1e3;ao(d.x,o.x,A),ao(d.y,o.y,A),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Pe(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),qd(this.relativeTarget,this.relativeTargetOrigin,f,A),b&&Id(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=K()),at(b,this.relativeTarget)),v&&(this.animationValues=c,Ed(c,u,this.latestValues,A,C,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=A},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(kt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=B.update(()=>{Je.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=re(0)),this.currentAnimation=Cd(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.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 o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Fd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:c}=o;if(!(!a||!l||!u)){if(this!==o&&this.layout&&u&&qr(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||K();const d=nt(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=nt(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}at(a,l),ne(a,c),Ae(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Ld),this.sharedNodes.get(o).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 o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&jn("z",o,u,this.animationValues);for(let c=0;c<Mn.length;c++)jn(`rotate${Mn[c]}`,o,u,this.animationValues),jn(`skew${Mn[c]}`,o,u,this.animationValues);o.render();for(const c in u)o.setStaticValue(c,u[c]),this.animationValues&&(this.animationValues[c]=u[c]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Ye(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Ye(a?.pointerEvents)||""),this.hasProjected&&!Wt(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const c=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=Od(this.projectionDeltaWithTransform,this.treeScale,c);l&&(d=l(c,d)),o.transform=d;const{x:f,y:g}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?o.opacity=u===this?c.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:c.opacityExit:o.opacity=u===this?c.opacity!==void 0?c.opacity:"":c.opacityExit!==void 0?c.opacityExit:0;for(const y in Ve){if(c[y]===void 0)continue;const{correct:v,applyTo:w,isCSSVariable:x}=Ve[y],C=d==="none"?c[y]:v(c[y],u);if(w){const b=w.length;for(let k=0;k<b;k++)o[w[k]]=C}else x?this.options.visualElement.renderState.vars[y]=C:o[y]=C}this.options.layoutId&&(o.pointerEvents=u===this?Ye(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(io),this.root.sharedNodes.clear()}}}function $d(t){t.updateLayout()}function zd(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,r=e.source!==t.layout.source;i==="size"?lt(c=>{const d=r?e.measuredBox[c]:e.layoutBox[c],f=nt(d);d.min=n[c].min,d.max=d.min+f}):qr(i,e.layoutBox,n)&<(c=>{const d=r?e.measuredBox[c]:e.layoutBox[c],f=nt(n[c]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[c].max=t.relativeTarget[c].min+f)});const o=se();Ae(o,n,e.layoutBox);const a=se();r?Ae(a,t.applyTransform(s,!0),e.measuredBox):Ae(a,n,e.layoutBox);const l=!Hr(o);let u=!1;if(!t.resumeFrom){const c=t.getClosestProjectingParent();if(c&&!c.resumeFrom){const{snapshot:d,layout:f}=c;if(d&&f){const g=K();Pe(g,e.layoutBox,d.layoutBox);const y=K();Pe(y,n,f.layoutBox),Xr(g,y)||(u=!0),c.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=g,t.relativeParent=c)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Ud(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 _d(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Wd(t){t.clearSnapshot()}function io(t){t.clearMeasurements()}function oo(t){t.isLayoutDirty=!1}function Kd(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function ro(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Hd(t){t.resolveTargetDelta()}function Xd(t){t.calcProjection()}function Gd(t){t.resetSkewAndRotation()}function Yd(t){t.removeLeadSnapshot()}function ao(t,e,n){t.translate=z(e.translate,0,n),t.scale=z(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function lo(t,e,n,s){t.min=z(e.min,n.min,s),t.max=z(e.max,n.max,s)}function qd(t,e,n,s){lo(t.x,e.x,n.x,s),lo(t.y,e.y,n.y,s)}function Jd(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Zd={duration:.45,ease:[.4,0,.1,1]},co=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),uo=co("applewebkit/")&&!co("chrome/")?Math.round:ut;function ho(t){t.min=uo(t.min),t.max=uo(t.max)}function Qd(t){ho(t.x),ho(t.y)}function qr(t,e,n){return t==="position"||t==="preserve-aspect"&&!od(no(e),no(n),.2)}function th(t){return t!==t.root&&t.scroll?.wasRoot}const eh=Yr({attachResizeListener:(t,e)=>ke(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),En={current:void 0},Jr=Yr({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!En.current){const t=new eh({});t.mount(window),t.setOptions({layoutScroll:!0}),En.current=t}return En.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),nh={pan:{Feature:bd},drag:{Feature:vd,ProjectionNode:Jr,MeasureLayout:_r}};function fo(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,r=s[i];r&&B.postRender(()=>r(e,Le(e)))}class sh extends Nt{mount(){const{current:e}=this.node;e&&(this.unmount=Ac(e,(n,s)=>(fo(this.node,s,"Start"),i=>fo(this.node,i,"End"))))}unmount(){}}class ih extends Nt{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=Re(ke(this.node.current,"focus",()=>this.onFocus()),ke(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function mo(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),r=s[i];r&&B.postRender(()=>r(e,Le(e)))}class oh extends Nt{mount(){const{current:e}=this.node;e&&(this.unmount=Ec(e,(n,s)=>(mo(this.node,s,"Start"),(i,{success:r})=>mo(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const ts=new WeakMap,Dn=new WeakMap,rh=t=>{const e=ts.get(t.target);e&&e(t)},ah=t=>{t.forEach(rh)};function lh({root:t,...e}){const n=t||document;Dn.has(n)||Dn.set(n,{});const s=Dn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(ah,{root:t,...e})),s[i]}function ch(t,e,n){const s=lh(e);return ts.set(t,n),s.observe(t),()=>{ts.delete(t),s.unobserve(t)}}const uh={some:0,all:1};class dh extends Nt{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:r}=e,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:uh[i]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,r&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=u?c:d;f&&f(l)};return ch(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(hh(e,n))&&this.startObserver()}unmount(){}}function hh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Zr={inView:{Feature:dh},tap:{Feature:oh},focus:{Feature:ih},hover:{Feature:sh}},fh={layout:{ProjectionNode:Jr,MeasureLayout:_r}},mh={...Or,...Zr,...nh,...fh},ph=yu(mh,Vr),gh={renderer:Vr,...Or,...Zr};function Qr(t,e){return qe(t,e)}const He=Qr("div"),yh=Qr("p"),bt=Symbol.for("@arcteninc/core:originalName");function xh(t,e){return t[bt]=e,t}function vh(t,e,n,s){if(typeof t!="function")return null;const i=t[bt];if(i){const a=e[i];if(a&&!n.has(a.name))return{fn:t,meta:a}}const r=t.name;let o;if(r&&(o=e[r],o&&!n.has(o.name)))return t[bt]=o.name,{fn:t,meta:o};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(o=e[a],o))return t[bt]=o.name,{fn:t,meta:o}}else if(o=Object.values(e).find(l=>!n.has(l.name)),o)return t[bt]=o.name,{fn:t,meta:o};return null}function ta(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 r=e;n=r.functions,s=r.toolOrder}else n=e,s=void 0;const i=new Set;return t.map(r=>{const o=
|
|
19
|
-
To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return i.add(o.meta.name),{name:o.meta.name,description:o.meta.description,jsonSchema:o.meta.parameters}}).filter(r=>r!==null)}function yh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const r=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})}),r&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([o,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:[o,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},o))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(Ze,{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(Ze,{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 xh({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,r]=m.useState(!1);if(t==="fetchDocContent")return null;const o=["k","maxResults","_organizationId"];t==="searchDocs"&&o.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!o.includes(u))),l=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>l&&r(!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"} ${l?"cursor-pointer hover:bg-opacity-80":""}`,children:[l&&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&&l&&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,c])=>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 c=="string"?c:JSON.stringify(c)})]},u))})})]})}function vh({...t}){return h.jsx(Qn.Root,{"data-slot":"collapsible",...t})}function bh({...t}){return h.jsx(Qn.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function wh({...t}){return h.jsx(Qn.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const Th=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),Is=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Th,{className:tt("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);Is.displayName="Response";const Sh=Object.freeze(Object.defineProperty({__proto__:null,Response:Is},Symbol.toStringTag,{value:"Module"})),Ch=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const r=hh.create(e),o=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(r,{animate:{backgroundPosition:"0% center"},className:tt("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":`${o}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})},Ah=m.memo(Ch),Jr=m.createContext(null),Ph=()=>{const t=m.useContext(Jr);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Mh=1e3,jh=1e3,Qr=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:r,children:o,...a})=>{const[l,u]=Gs.useControllableState({prop:n,defaultProp:s,onChange:i}),[c,d]=Gs.useControllableState({prop:r,defaultProp:0}),[f,g]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{e?y===null&&v(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/jh)),v(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&l&&!f){const x=setTimeout(()=>{u(!1),g(!0)},Mh);return()=>clearTimeout(x)}},[e,l,s,u,f]);const w=x=>{u(x)};return h.jsx(Jr.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:u,duration:c},children:h.jsx(vh,{className:tt("not-prose mb-4",t),onOpenChange:w,open:l,...a,children:o})})}),Eh=(t,e)=>t||e===0?h.jsx(Ah,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),ta=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:r}=Ph();return h.jsx(bh,{className:tt("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"}),Eh(s,r),h.jsx(q.ChevronDownIcon,{className:tt("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),ea=m.memo(({className:t,children:e,...n})=>h.jsx(wh,{className:tt("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(Is,{className:"grid gap-2",children:e})}));Qr.displayName="Reasoning";ta.displayName="ReasoningTrigger";ea.displayName="ReasoningContent";function Dh({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:r=void 0,defaultWidth:o=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:c=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:y="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:w}){const[x,C]=m.useState(null),b=m.useRef(null),[k,A]=m.useState(null),[D,N]=m.useState(null),P=m.useRef(null),[L,W]=m.useState(u),[U,Tt]=m.useState(o),[Pt,dt]=m.useState(600),[ot,pt]=m.useState(!1),[V,Y]=m.useState(!1),[H,rt]=m.useState(!1),[_,he]=m.useState({x:100,y:100}),[Yt,Nt]=m.useState(!1),[fe,It]=m.useState({x:0,y:0}),[me,ln]=m.useState(!1),pe=m.useRef(null),qt=m.useRef(null),[Lt,ge]=m.useState(""),[M,j]=m.useState(null),[O,Z]=m.useState("Thinking..."),[X,J]=m.useState(new Set),[na,sa]=m.useState(""),[Ot,ia]=m.useState([]),[cn,Ls]=m.useState(!1),[un,Os]=m.useState([]),[Fs,dn]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Zt,Ie]=m.useState(!1),[kh,Le]=m.useState(!1),[Rh,Oe]=m.useState([]),Mt=m.useMemo(()=>[...c,...d],[c,d]),gt=m.useMemo(()=>Zr(Mt,f),[Mt,f]),Bs=m.useMemo(()=>new Set(gt.map(p=>p.name)),[gt]),hn=m.useMemo(()=>gt.filter(p=>Bs.has(p.name)),[gt,Bs]),$s=m.useMemo(()=>{const p=new Map,T=new Map(gt.map(R=>[R.name,R]));return Mt.forEach(R=>{const S=R[bt];if(S){const I=T.get(S);if(I){p.set(I.name,R);return}}const F=gt.find(I=>I.name===R.name);F&&p.set(F.name,R)}),p},[Mt,gt]),zs=m.useMemo(()=>{const p=new Set,T=new Map(gt.map(R=>[R.name,R]));return d.forEach(R=>{const S=R[bt];if(S&&T.has(S))p.add(S);else{const F=gt.find(I=>I.name===R.name);F&&p.add(F.name)}}),p},[d,gt]),Us=["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&&W(JSON.parse(p));const T=localStorage.getItem("arcten-sidebar-width");T&&Tt(parseInt(T));const R=localStorage.getItem("arcten-sidebar-height");R&&dt(parseInt(R));const S=localStorage.getItem("arcten-sidebar-detached");S&&Y(JSON.parse(S));const F=localStorage.getItem("arcten-sidebar-position");if(F){const jt=JSON.parse(F),xt=50,Et=Math.max(xt-o,Math.min(jt.x,window.innerWidth-xt)),et=Math.max(0,Math.min(jt.y,window.innerHeight-xt));he({x:Et,y:et})}const I=localStorage.getItem("arcten-sidebar-minimized");I&&rt(JSON.parse(I)),ln(!0)}},[]),m.useEffect(()=>((async()=>{try{const T=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:w})});if(!T.ok)throw new Error("Failed to fetch token");const R=await T.json();C(R.clientToken),b.current=R.clientToken,N(R.expiresAt),A(null)}catch(T){A(T instanceof Error?T.message:"Failed to fetch token")}})(),()=>{P.current&&clearTimeout(P.current)}),[y,w]),m.useEffect(()=>{if(!D)return;P.current&&clearTimeout(P.current);const p=Math.floor(Date.now()/1e3),T=D-p,S=Math.max(0,T-5);return console.log(`Token expires at ${new Date(D*1e3).toISOString()}`),console.log(`Scheduling token refresh in ${S} seconds`),P.current=setTimeout(async()=>{console.log("Refreshing token...");try{const F=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:w})});if(!F.ok)throw new Error("Failed to refresh token");const I=await F.json();C(I.clientToken),b.current=I.clientToken,N(I.expiresAt),A(null),console.log("Token refreshed successfully")}catch(F){console.error("Token refresh failed:",F),A(F instanceof Error?F.message:"Failed to refresh token")}},S*1e3),()=>{P.current&&clearTimeout(P.current)}},[D,y,w]),m.useEffect(()=>{(async()=>{if(Mt.length!==0)try{const T=Mt.map(S=>({name:S.name,code:S.toString()})),R=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:T})});if(R.ok){const S=await R.json();ia(S.tools)}}catch(T){console.error("Failed to fetch tool descriptions:",T)}})()},[Mt]),m.useEffect(()=>{Promise.resolve().then(()=>Sh).then(p=>{j(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{sa(window.location.pathname)};p(),window.addEventListener("popstate",p);const T=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(T)}},[]);async function _s(){if(!(!w?.id||!x)){Le(!0);try{const T=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${x}`}})).json();Os(T.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{Le(!1)}}}m.useEffect(()=>{w?.id&&x&&_s()},[w,x]);function oa(p){const T=Math.floor((Date.now()-p)/1e3);return T<60?"now":T<3600?`${Math.floor(T/60)}m`:T<86400?`${Math.floor(T/3600)}h`:`${Math.floor(T/86400)}d`}function ra(){const p=crypto.randomUUID();dn(p),Be([]),Oe([]),Ie(!1)}async function aa(p){if(x)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${x}`}}),Os(un.filter(T=>T._id!==p)),p===Fs&&ra()}catch(T){console.error("Failed to delete conversation:",T)}}async function la(p){dn(p.chatId),Ie(!1),Le(!0);try{const T=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${b.current}`}});if(!T.ok)throw new Error(`Failed to fetch messages: ${T.statusText}`);const S=(await T.json()).messages||[];Be(S),Oe(S)}catch(T){console.error("Failed to load conversation messages:",T);const R=p.messages||[];Be(R),Oe(R)}finally{Le(!1)}}const ca=async(p,T={})=>{const R=T.headers?new Headers(T.headers):new Headers;return R.delete("user-agent"),R.delete("User-Agent"),fetch(p,{...T,headers:R})},{messages:ye,sendMessage:ua,status:yt,error:Ws,stop:Fe,addToolResult:xe,setMessages:Be}=ho.useChat({id:Fs||void 0,transport:new qe.DefaultChatTransport({api:`${v}/chat`,fetch:ca,headers:()=>{const p={};return b.current&&(p.Authorization=`Bearer ${b.current}`),p},body:()=>{const p=hn.map(T=>({name:T.name,description:T.description,inputSchema:T.jsonSchema}));return process.env.NODE_ENV==="development"&&console.log("[ArctenAgent] Sending tools to API:",{totalTools:p.length,toolNames:p.map(T=>T.name),allToolNames:Mt.map(T=>T.name),filteredToolNames:hn.map(T=>T.name)}),{tools:p,systemPrompt:g,currentRoute:na}}}),sendAutomaticallyWhen:qe.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{L&&qt.current&&qt.current.focus()},[L,ye]);function da(){W(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function ha(){W(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[L]),m.useEffect(()=>{pe.current&&pe.current.scrollIntoView({behavior:"smooth"})},[ye]),m.useEffect(()=>{function p(T){T.key==="Escape"&&(yt==="streaming"||yt==="submitted")&&(T.preventDefault(),Fe())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[yt,Fe]);function fa(){const p=crypto.randomUUID();dn(p),Be([]),Oe([]),Ie(!1)}function Ks(p){if(p.preventDefault(),!Lt.trim())return;(yt==="streaming"||yt==="submitted")&&Fe();const T=Us[Math.floor(Math.random()*Us.length)]||"Thinking...";Z(T),ua({text:Lt}),ge("")}function ma(p){const T=p.target.value;ge(T)}m.useEffect(()=>{if(!ot)return;function p(R){if(V){const S=R.clientX-_.x,F=R.clientY-_.y;S>=a&&S<=l&&Tt(S),F>=400&&F<=1e3&&dt(F)}else{const S=window.innerWidth-R.clientX;S>=a&&S<=l&&Tt(S)}}function T(){pt(!1),localStorage.setItem("arcten-sidebar-width",U.toString()),localStorage.setItem("arcten-sidebar-height",Pt.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",T)}},[ot,U,Pt,V,_,a,l]);function pa(p){p.preventDefault(),pt(!0)}function ga(){Y(!0),rt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function ya(){Y(!1),rt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Hs(){rt(!H),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!H))}function xa(p){V&&(Nt(!0),It({x:p.clientX-_.x,y:p.clientY-_.y}))}return m.useEffect(()=>{if(!V)return;function p(){he(T=>{const S=window.innerWidth-50,F=window.innerHeight-50,I=50-U,jt=0,xt=Math.max(I,Math.min(T.x,S)),Et=Math.max(jt,Math.min(T.y,F));if(xt!==T.x||Et!==T.y){const et={x:xt,y:Et};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(et)),et}return T})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[V,U]),m.useEffect(()=>{if(!Yt)return;function p(R){const S=R.clientX-fe.x,F=R.clientY-fe.y,I=50,jt=window.innerWidth-I,xt=window.innerHeight-I,Et=I-U,et=0,vt=Math.max(Et,Math.min(S,jt)),Ft=Math.max(et,Math.min(F,xt));he({x:vt,y:Ft})}function T(){Nt(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(_))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",T)}},[Yt,fe,_,U]),me?k?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: ",k]})}):x?h.jsx(Oc,{features:fh,children:h.jsx(We,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:V?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:V?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
18
|
+
`);if("functions"in e&&typeof e.functions=="object"){const r=e;n=r.functions,s=r.toolOrder}else n=e,s=void 0;const i=new Set;return t.map(r=>{const o=vh(r,n,i,s);if(!o){const a=r.name,u=r[bt]||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(o.meta.name),{name:o.meta.name,description:o.meta.description,jsonSchema:o.meta.parameters}}).filter(r=>r!==null)}function bh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const r=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})}),r&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([o,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:[o,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},o))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(Qe,{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(Qe,{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 wh({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,r]=m.useState(!1);if(t==="fetchDocContent")return null;const o=["k","maxResults","_organizationId"];t==="searchDocs"&&o.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!o.includes(u))),l=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>l&&r(!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"} ${l?"cursor-pointer hover:bg-opacity-80":""}`,children:[l&&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&&l&&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,c])=>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 c=="string"?c:JSON.stringify(c)})]},u))})})]})}function Th({...t}){return h.jsx(ns.Root,{"data-slot":"collapsible",...t})}function Sh({...t}){return h.jsx(ns.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function Ch({...t}){return h.jsx(ns.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const Ah=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),Fs=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Ah,{className:Q("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);Fs.displayName="Response";const Ph=Object.freeze(Object.defineProperty({__proto__:null,Response:Fs},Symbol.toStringTag,{value:"Module"})),Mh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const r=ph.create(e),o=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(r,{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":`${o}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})},jh=m.memo(Mh),ea=m.createContext(null),Eh=()=>{const t=m.useContext(ea);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Dh=1e3,Vh=1e3,na=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:r,children:o,...a})=>{const[l,u]=Js.useControllableState({prop:n,defaultProp:s,onChange:i}),[c,d]=Js.useControllableState({prop:r,defaultProp:0}),[f,g]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{e?y===null&&v(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/Vh)),v(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&l&&!f){const x=setTimeout(()=>{u(!1),g(!0)},Dh);return()=>clearTimeout(x)}},[e,l,s,u,f]);const w=x=>{u(x)};return h.jsx(ea.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:u,duration:c},children:h.jsx(Th,{className:Q("not-prose mb-4",t),onOpenChange:w,open:l,...a,children:o})})}),kh=(t,e)=>t||e===0?h.jsx(jh,{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:r}=Eh();return h.jsx(Sh,{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(q.BrainIcon,{className:"size-4"}),kh(s,r),h.jsx(q.ChevronDownIcon,{className:Q("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),ia=m.memo(({className:t,children:e,...n})=>h.jsx(Ch,{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(Fs,{className:"grid gap-2",children:e})}));na.displayName="Reasoning";sa.displayName="ReasoningTrigger";ia.displayName="ReasoningContent";function Vn(t){if(t&&typeof t=="object"&&!Array.isArray(t))return t;if(typeof t=="string")try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}return{}}function Rh({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:r=void 0,defaultWidth:o=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:c=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:y="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:w}){const[x,C]=m.useState(null),b=m.useRef(null),[k,A]=m.useState(null),[D,N]=m.useState(null),P=m.useRef(null),[L,W]=m.useState(u),[U,Tt]=m.useState(o),[Mt,dt]=m.useState(600),[it,pt]=m.useState(!1),[V,Y]=m.useState(!1),[H,ot]=m.useState(!1),[_,he]=m.useState({x:100,y:100}),[Yt,It]=m.useState(!1),[fe,Lt]=m.useState({x:0,y:0}),[me,un]=m.useState(!1),pe=m.useRef(null),qt=m.useRef(null),[Ot,ge]=m.useState(""),[M,E]=m.useState(null),[O,J]=m.useState("Thinking..."),[tt,X]=m.useState(new Set),[ye,oa]=m.useState(""),[Ft,ra]=m.useState([]),[dn,Bs]=m.useState(!1),[hn,$s]=m.useState([]),[zs,fn]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Jt,Oe]=m.useState(!1),[Lh,Fe]=m.useState(!1),[Oh,Be]=m.useState([]),jt=m.useMemo(()=>[...c,...d],[c,d]),gt=m.useMemo(()=>ta(jt,f),[jt,f]),Us=m.useMemo(()=>new Set(gt.map(p=>p.name)),[gt]),mn=m.useMemo(()=>gt.filter(p=>Us.has(p.name)),[gt,Us]),_s=m.useMemo(()=>{const p=new Map,T=new Map(gt.map(R=>[R.name,R]));return jt.forEach(R=>{const S=R[bt];if(S){const I=T.get(S);if(I){p.set(I.name,R);return}}const F=gt.find(I=>I.name===R.name);F&&p.set(F.name,R)}),p},[jt,gt]),Ws=m.useMemo(()=>{const p=new Set,T=new Map(gt.map(R=>[R.name,R]));return d.forEach(R=>{const S=R[bt];if(S&&T.has(S))p.add(S);else{const F=gt.find(I=>I.name===R.name);F&&p.add(F.name)}}),p},[d,gt]),Ks=["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&&W(JSON.parse(p));const T=localStorage.getItem("arcten-sidebar-width");T&&Tt(parseInt(T));const R=localStorage.getItem("arcten-sidebar-height");R&&dt(parseInt(R));const S=localStorage.getItem("arcten-sidebar-detached");S&&Y(JSON.parse(S));const F=localStorage.getItem("arcten-sidebar-position");if(F){const Et=JSON.parse(F),xt=50,Dt=Math.max(xt-o,Math.min(Et.x,window.innerWidth-xt)),rt=Math.max(0,Math.min(Et.y,window.innerHeight-xt));he({x:Dt,y:rt})}const I=localStorage.getItem("arcten-sidebar-minimized");I&&ot(JSON.parse(I)),un(!0)}},[]),m.useEffect(()=>((async()=>{try{const T=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:w})});if(!T.ok)throw new Error("Failed to fetch token");const R=await T.json();C(R.clientToken),b.current=R.clientToken,N(R.expiresAt),A(null)}catch(T){A(T instanceof Error?T.message:"Failed to fetch token")}})(),()=>{P.current&&clearTimeout(P.current)}),[y,w]),m.useEffect(()=>{if(!D)return;P.current&&clearTimeout(P.current);const p=Math.floor(Date.now()/1e3),T=D-p,S=Math.max(0,T-5);return console.log(`Token expires at ${new Date(D*1e3).toISOString()}`),console.log(`Scheduling token refresh in ${S} seconds`),P.current=setTimeout(async()=>{console.log("Refreshing token...");try{const F=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:w})});if(!F.ok)throw new Error("Failed to refresh token");const I=await F.json();C(I.clientToken),b.current=I.clientToken,N(I.expiresAt),A(null),console.log("Token refreshed successfully")}catch(F){console.error("Token refresh failed:",F),A(F instanceof Error?F.message:"Failed to refresh token")}},S*1e3),()=>{P.current&&clearTimeout(P.current)}},[D,y,w]),m.useEffect(()=>{(async()=>{if(jt.length!==0)try{const T=jt.map(S=>({name:S.name,code:S.toString()})),R=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:T})});if(R.ok){const S=await R.json();ra(S.tools)}}catch(T){console.error("Failed to fetch tool descriptions:",T)}})()},[jt]),m.useEffect(()=>{Promise.resolve().then(()=>Ph).then(p=>{E(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{oa(window.location.pathname)};p(),window.addEventListener("popstate",p);const T=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(T)}},[]);async function Hs(){if(!(!w?.id||!x)){Fe(!0);try{const T=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${x}`}})).json();$s(T.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{Fe(!1)}}}m.useEffect(()=>{w?.id&&x&&Hs()},[w,x]);function aa(p){const T=Math.floor((Date.now()-p)/1e3);return T<60?"now":T<3600?`${Math.floor(T/60)}m`:T<86400?`${Math.floor(T/3600)}h`:`${Math.floor(T/86400)}d`}function la(){const p=crypto.randomUUID();fn(p),ze([]),Be([]),Oe(!1)}async function ca(p){if(x)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${x}`}}),$s(hn.filter(T=>T._id!==p)),p===zs&&la()}catch(T){console.error("Failed to delete conversation:",T)}}async function ua(p){fn(p.chatId),Oe(!1),Fe(!0);try{const T=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${b.current}`}});if(!T.ok)throw new Error(`Failed to fetch messages: ${T.statusText}`);const S=(await T.json()).messages||[];ze(S),Be(S)}catch(T){console.error("Failed to load conversation messages:",T);const R=p.messages||[];ze(R),Be(R)}finally{Fe(!1)}}const da=async(p,T={})=>{const R=T.headers?new Headers(T.headers):new Headers;return R.delete("user-agent"),R.delete("User-Agent"),fetch(p,{...T,headers:R})},{messages:xe,sendMessage:ha,status:yt,error:Xs,stop:$e,addToolResult:ve,setMessages:ze}=po.useChat({id:zs||void 0,transport:new Ze.DefaultChatTransport({api:`${v}/chat`,fetch:da,headers:()=>{const p={};return b.current&&(p.Authorization=`Bearer ${b.current}`),p},body:()=>{const p=mn.map(T=>({name:T.name,description:T.description,inputSchema:T.jsonSchema}));return process.env.NODE_ENV==="development"&&console.log("[ArctenAgent] Sending tools to API:",{totalTools:p.length,toolNames:p.map(T=>T.name),allToolNames:jt.map(T=>T.name),filteredToolNames:mn.map(T=>T.name)}),{tools:p,systemPrompt:g,currentRoute:ye}}}),sendAutomaticallyWhen:Ze.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{L&&qt.current&&qt.current.focus()},[L,xe]);function fa(){W(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function ma(){W(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[L]),m.useEffect(()=>{pe.current&&pe.current.scrollIntoView({behavior:"smooth"})},[xe]),m.useEffect(()=>{function p(T){T.key==="Escape"&&(yt==="streaming"||yt==="submitted")&&(T.preventDefault(),$e())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[yt,$e]);function pa(){const p=crypto.randomUUID();fn(p),ze([]),Be([]),Oe(!1)}function Gs(p){if(p.preventDefault(),!Ot.trim())return;(yt==="streaming"||yt==="submitted")&&$e();const T=Ks[Math.floor(Math.random()*Ks.length)]||"Thinking...";J(T),ha({text:Ot}),ge("")}function ga(p){const T=p.target.value;ge(T)}m.useEffect(()=>{if(!it)return;function p(R){if(V){const S=R.clientX-_.x,F=R.clientY-_.y;S>=a&&S<=l&&Tt(S),F>=400&&F<=1e3&&dt(F)}else{const S=window.innerWidth-R.clientX;S>=a&&S<=l&&Tt(S)}}function T(){pt(!1),localStorage.setItem("arcten-sidebar-width",U.toString()),localStorage.setItem("arcten-sidebar-height",Mt.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",T)}},[it,U,Mt,V,_,a,l]);function ya(p){p.preventDefault(),pt(!0)}function xa(){Y(!0),ot(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function va(){Y(!1),ot(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ys(){ot(!H),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!H))}function ba(p){V&&(It(!0),Lt({x:p.clientX-_.x,y:p.clientY-_.y}))}return m.useEffect(()=>{if(!V)return;function p(){he(T=>{const S=window.innerWidth-50,F=window.innerHeight-50,I=50-U,Et=0,xt=Math.max(I,Math.min(T.x,S)),Dt=Math.max(Et,Math.min(T.y,F));if(xt!==T.x||Dt!==T.y){const rt={x:xt,y:Dt};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(rt)),rt}return T})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[V,U]),m.useEffect(()=>{if(!Yt)return;function p(R){const S=R.clientX-fe.x,F=R.clientY-fe.y,I=50,Et=window.innerWidth-I,xt=window.innerHeight-I,Dt=I-U,rt=0,St=Math.max(Dt,Math.min(S,Et)),vt=Math.max(rt,Math.min(F,xt));he({x:St,y:vt})}function T(){It(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(_))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",T)}},[Yt,fe,_,U]),me?k?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: ",k]})}):x?h.jsx($c,{features:gh,children:h.jsx(He,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:V?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:V?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
20
20
|
${V?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
|
|
21
21
|
${L?"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
22
|
${V?"border border-border":"border-l border-border"}
|
|
23
23
|
${L?"":"w-[30px]"}
|
|
24
|
-
`,style:L?V?{width:`${U}px`,height:H?"auto":`${Pt}px`,left:`${_.x}px`,top:`${_.y}px`}:{width:`${U}px`}:void 0,onClick:L?void 0:da,children:L?h.jsxs(h.Fragment,{children:[!V&&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:pa,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),V&&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(),pt(!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(),Nt(!0),It({x:p.clientX-_.x,y:p.clientY-_.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(),pt(!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 ${V?"cursor-move":""}`,onMouseDown:V?xa:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${V&&H?"cursor-pointer":""}`,onClick:V&&H?p=>{p.stopPropagation(),Hs()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Bt,{children:[h.jsx($t,{asChild:!0,children:h.jsx("button",{type:"button",className:tt(_t({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:fa,"aria-label":"New chat",children:h.jsx(q.Plus,{className:"h-4 w-4"})})}),h.jsx(zt,{children:"Start a new conversation"})]}),h.jsxs(Bt,{children:[h.jsx($t,{asChild:!0,children:h.jsx("button",{type:"button",className:tt(_t({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:V?ya:ga,"aria-label":V?"Dock sidebar":"Float sidebar",children:V?h.jsx(q.Dock,{className:"h-4 w-4"}):h.jsx(q.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(zt,{children:V?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Bt,{children:[h.jsx($t,{asChild:!0,children:h.jsx("button",{type:"button",className:tt(_t({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:V?Hs:ha,"aria-label":V?H?"Maximize":"Minimize":"Close sidebar",children:V?H?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(zt,{children:V?H?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!H&&h.jsxs(h.Fragment,{children:[w&&un.length>0&&h.jsxs("div",{className:`border-b border-border ${Zt?"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(Ze,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Zt||_s(),Ie(!Zt)},children:Zt?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Zt?"flex-1 overflow-y-auto":""}`,children:un.slice(0,Zt?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:tt(_t({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>la(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:oa(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:T=>{T.stopPropagation(),aa(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:ye.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[r&&h.jsx("div",{className:"mb-6",children:r}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),Ot.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:[(cn?Ot:Ot.slice(0,10)).map(p=>h.jsxs(Bt,{children:[h.jsx($t,{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:()=>{ge(p.sampleUsage),qt.current?.focus()},children:p.friendlyName})}),h.jsx(zt,{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)),Ot.length>10&&!cn&&h.jsxs(Bt,{children:[h.jsx($t,{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:()=>Ls(!0),children:["+",Ot.length-10," more"]})}),h.jsx(zt,{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:Ot.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"})]})})]}),cn&&Ot.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:()=>Ls(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[ye.map(p=>{const R=p.parts.filter(S=>S.type==="text").map(S=>S.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(mh,{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:R}):h.jsx("div",{className:"space-y-2",children:p.parts.map((S,F)=>{if(S.type?.startsWith("tool-")){const I=S.type?.replace("tool-","")||"",jt=hn.find(et=>et.name===I),xt=S.state==="input-available",Et=S.state==="output-available";if(xt)return zs.has(I)?((async()=>{if(X.has(S.toolCallId))return;J(Ft=>new Set(Ft).add(S.toolCallId));const vt=$s.get(I);if(vt)try{console.log("Auto-executing safe tool:",I);const Ft=await vt(...Object.values(S.input||{}));xe({toolCallId:S.toolCallId,tool:I,output:Ft}),console.log("Safe tool result added:",S.toolCallId)}catch(Ft){xe({toolCallId:S.toolCallId,tool:I,output:`Error: ${Ft}`}),console.log("Safe tool error result added:",S.toolCallId)}})(),null):h.jsx(We,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(yh,{toolName:I,description:jt?.description||"",args:S.input||{},onApprove:async()=>{if(X.has(S.toolCallId)){console.log("Tool call already being processed:",S.toolCallId);return}J(vt=>new Set(vt).add(S.toolCallId));const et=$s.get(I);if(et)try{const vt=await et(...Object.values(S.input||{}));xe({toolCallId:S.toolCallId,tool:I,output:vt}),console.log("Tool result added:",S.toolCallId)}catch(vt){xe({toolCallId:S.toolCallId,tool:I,output:`Error: ${vt}`}),console.log("Tool error result added:",S.toolCallId)}},onDeny:async()=>{if(X.has(S.toolCallId)){console.log("Tool call already being processed:",S.toolCallId);return}J(et=>new Set(et).add(S.toolCallId)),xe({toolCallId:S.toolCallId,tool:I,output:"User denied tool execution"}),console.log("Tool denied:",S.toolCallId)}})},`${S.toolCallId}-${F}`);if(Et){const et=S.output==="User denied tool execution";return h.jsx(xh,{toolName:I,args:S.input||{},isDenied:et,isSafe:zs.has(I)},`${S.toolCallId}-${F}`)}return null}return S.type==="text"&&S.text&&M?h.jsx(M,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:S.text},`${p.id}-${F}`):S.type==="reasoning"&&S.text?h.jsxs(Qr,{className:"w-full",isStreaming:yt==="streaming"&&F===p.parts.length-1&&p.id===ye.at(-1)?.id,children:[h.jsx(ta,{}),h.jsx(ea,{children:S.text})]},`${p.id}-${F}`):null})})})},p.id)}),h.jsx("div",{ref:pe})]})}),Ws&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",Ws.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Lc,{mode:"wait",children:(yt==="streaming"||yt==="submitted")&&h.jsxs(We,{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(We,{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:O})]})}),h.jsxs("form",{onSubmit:Ks,className:"relative",children:[h.jsx(po,{ref:qt,value:Lt,onChange:ma,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(),Ks(p))}}),yt==="streaming"||yt==="submitted"?h.jsxs(Bt,{children:[h.jsx($t,{asChild:!0,children:h.jsx("button",{type:"button",className:tt(_t({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Fe,children:h.jsx(q.Square,{className:"h-4 w-4"})})}),h.jsxs(zt,{children:[h.jsx(Ys,{children:"Escape"})," to stop"]})]}):h.jsxs(Bt,{children:[h.jsx($t,{asChild:!0,children:h.jsx("button",{type:"submit",className:tt(_t({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!Lt.trim(),children:h.jsx(q.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(zt,{children:[h.jsx(Ys,{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 overflow-hidden",children:[h.jsx("span",{className:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 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:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 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 Vh({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:r=[],safeTools:o=[],toolMetadata:a,systemPrompt:l="",initialMessages:u=[],conversationId:c,onToolCall:d,onFinish:f,ragFilters:g}={}){console.log("[useAgent] Hook initialized",{apiBaseUrl:t,tokenEndpoint:e,hasProvidedToken:!!n,skipTokenFetch:s,userId:i?.id,toolsCount:r.length,safeToolsCount:o.length});const[y,v]=m.useState(n||null),w=m.useRef(n||null),[x,C]=m.useState(null),[b,k]=m.useState(null),A=m.useRef(null),[D,N]=m.useState([]),[P,L]=m.useState(c||(typeof window<"u"?crypto.randomUUID():null)),[W,U]=m.useState(!1),[Tt,Pt]=m.useState(new Set),dt=m.useMemo(()=>[...r,...o],[r,o]),ot=m.useMemo(()=>Zr(dt,a),[dt,a]),pt=m.useMemo(()=>{const M=new Map,j=new Map(ot.map(O=>[O.name,O]));return dt.forEach(O=>{const Z=O[bt];if(Z){const J=j.get(Z);if(J){M.set(J.name,O);return}}const X=ot.find(J=>J.name===O.name);X&&M.set(X.name,O)}),M},[dt,ot]),V=m.useMemo(()=>new Set(ot.map(M=>M.name)),[ot]),Y=m.useMemo(()=>ot.filter(M=>V.has(M.name)),[ot,V]),H=m.useMemo(()=>{const M=new Set;return o.forEach(j=>{for(const[O,Z]of pt.entries())if(Z===j){M.add(O);break}}),M},[o,pt]);m.useEffect(()=>{if(console.log("[useAgent] Token fetch effect running",{skipTokenFetch:s,hasProvidedToken:!!n,user:i?.id,tokenEndpoint:e}),s||n){console.log("[useAgent] Skipping token fetch",{reason:s?"skipTokenFetch=true":"token provided"});return}return(async()=>{console.log("[useAgent] Fetching initial token from",e);try{const j=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!j.ok)throw new Error("Failed to fetch token");const O=await j.json();console.log("[useAgent] Token fetched successfully",{expiresAt:O.expiresAt,expiresIn:O.expiresAt?`${O.expiresAt-Math.floor(Date.now()/1e3)}s`:"unknown"}),v(O.clientToken),w.current=O.clientToken,k(O.expiresAt),C(null)}catch(j){console.error("[useAgent] Token fetch failed:",j),C(j instanceof Error?j.message:"Failed to fetch token")}})(),()=>{console.log("[useAgent] Cleaning up token fetch effect"),A.current&&clearTimeout(A.current)}},[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(console.log("[useAgent] Token refresh effect running",{hasTokenExpiresAt:!!b,tokenExpiresAt:b,skipTokenFetch:s,hasProvidedToken:!!n}),!b||s||n){console.log("[useAgent] Skipping token refresh setup",{reason:b?s?"skipTokenFetch=true":"token provided":"no expiry"});return}A.current&&(console.log("[useAgent] Clearing existing token refresh timeout"),clearTimeout(A.current));const M=Math.floor(Date.now()/1e3),j=b-M,Z=Math.max(0,j-5);return console.log("[useAgent] Scheduling token refresh",{expiresAt:b,now:M,timeUntilExpiry:`${j}s`,timeUntilRefresh:`${Z}s`,refreshAt:new Date((M+Z)*1e3).toISOString()}),A.current=setTimeout(async()=>{console.log("[useAgent] Refreshing token...");try{const X=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!X.ok)throw new Error("Failed to refresh token");const J=await X.json();console.log("[useAgent] Token refreshed successfully",{newExpiresAt:J.expiresAt,expiresIn:`${J.expiresAt-Math.floor(Date.now()/1e3)}s`}),v(J.clientToken),w.current=J.clientToken,k(J.expiresAt),C(null)}catch(X){console.error("[useAgent] Token refresh failed:",X),C(X instanceof Error?X.message:"Failed to refresh token")}},Z*1e3),()=>{console.log("[useAgent] Cleaning up token refresh effect"),A.current&&clearTimeout(A.current)}},[b,e,JSON.stringify(i),s,n]);const rt=async(M,j={})=>{const O=j.headers?new Headers(j.headers):new Headers;return O.delete("user-agent"),O.delete("User-Agent"),fetch(M,{...j,headers:O})},{messages:_,sendMessage:he,status:Yt,error:Nt,stop:fe,addToolResult:It,setMessages:me}=ho.useChat({id:P||void 0,messages:u,transport:new qe.DefaultChatTransport({api:`${t}/chat`,fetch:rt,headers:()=>{const M={};return w.current&&(M.Authorization=`Bearer ${w.current}`),M},body:()=>{const M=Y.map(j=>({name:j.name,description:j.description,inputSchema:j.jsonSchema}));return process.env.NODE_ENV==="development"&&console.log("[useAgent] Sending tools to API:",{totalTools:M.length,toolNames:M.map(j=>j.name),allToolNames:dt.map(j=>j.name),filteredToolNames:Y.map(j=>j.name)}),{tools:M,systemPrompt:l,...g&&{ragFilters:g}}}}),sendAutomaticallyWhen:qe.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{_.forEach(M=>{M.role==="assistant"&&M.parts.forEach(j=>{if(!j.type?.startsWith("tool-")||j.state!=="input-available")return;const O=j.type.replace("tool-",""),Z=j.toolCallId;if(!Tt.has(Z)){if(Pt(X=>new Set(X).add(Z)),H.has(O)){const X=pt.get(O);X&&(async()=>{try{const J=await X(...Object.values(j.input||{}));It({toolCallId:Z,tool:O,output:J})}catch(J){It({toolCallId:Z,tool:O,output:`Error: ${J}`})}})()}else if(d){const X={toolCallId:Z,toolName:O,args:j.input||{}};d({toolCall:X})}}})})},[_,H,pt,d,It,Tt]),m.useEffect(()=>{if(Yt==="ready"&&_.length>0&&f){const M=_[_.length-1];M&&M.role==="assistant"&&f({message:M,messages:_,isAbort:!1,isDisconnect:!1,isError:!!Nt})}},[Yt,_,Nt,f]);async function ln(){if(!(!i?.id||!y)){console.log("[useAgent] Fetching conversations for user:",i?.id),U(!0);try{const j=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${y}`}})).json();N(j.conversations||[])}catch(M){console.error("Failed to fetch conversations:",M)}finally{U(!1)}}}m.useEffect(()=>{i?.id&&y&&ln()},[JSON.stringify(i),y,t]);async function pe(M){L(M),U(!0);try{const j=await fetch(`${t}/conversations/${M}/messages`,{headers:{Authorization:`Bearer ${w.current}`}});if(!j.ok)throw new Error(`Failed to fetch messages: ${j.statusText}`);const Z=(await j.json()).messages||[];me(Z)}catch(j){console.error("Failed to load conversation messages:",j)}finally{U(!1)}}async function qt(M){if(y)try{await fetch(`${t}/conversations/${M}`,{method:"DELETE",headers:{Authorization:`Bearer ${y}`}}),N(D.filter(j=>j._id!==M)),M===P&&Lt()}catch(j){console.error("Failed to delete conversation:",j)}}function Lt(){const M=crypto.randomUUID();L(M),me([]),Pt(new Set)}function ge(M){It(M)}return{id:P,messages:_,status:Yt,error:Nt,sendMessage:he,stop:fe,addToolOutput:ge,setMessages:me,conversations:D,loadConversation:pe,deleteConversation:qt,startNewConversation:Lt,isLoadingConversations:W,clientToken:y,tokenError:x}}exports.verifyToken=Da.verifyToken;exports.ARCTEN_ORIGINAL_NAME=bt;exports.ArctenAgent=Dh;exports.preserveToolName=ph;exports.useAgent=Vh;
|
|
24
|
+
`,style:L?V?{width:`${U}px`,height:H?"auto":`${Mt}px`,left:`${_.x}px`,top:`${_.y}px`}:{width:`${U}px`}:void 0,onClick:L?void 0:fa,children:L?h.jsxs(h.Fragment,{children:[!V&&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:ya,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),V&&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(),pt(!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(),It(!0),Lt({x:p.clientX-_.x,y:p.clientY-_.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(),pt(!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 ${V?"cursor-move":""}`,onMouseDown:V?ba:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${V&&H?"cursor-pointer":""}`,onClick:V&&H?p=>{p.stopPropagation(),Ys()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Bt,{children:[h.jsx($t,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(_t({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:pa,"aria-label":"New chat",children:h.jsx(q.Plus,{className:"h-4 w-4"})})}),h.jsx(zt,{children:"Start a new conversation"})]}),h.jsxs(Bt,{children:[h.jsx($t,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(_t({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:V?va:xa,"aria-label":V?"Dock sidebar":"Float sidebar",children:V?h.jsx(q.Dock,{className:"h-4 w-4"}):h.jsx(q.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(zt,{children:V?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Bt,{children:[h.jsx($t,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(_t({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:V?Ys:ma,"aria-label":V?H?"Maximize":"Minimize":"Close sidebar",children:V?H?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(zt,{children:V?H?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!H&&h.jsxs(h.Fragment,{children:[w&&hn.length>0&&h.jsxs("div",{className:`border-b border-border ${Jt?"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(Qe,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Jt||Hs(),Oe(!Jt)},children:Jt?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Jt?"flex-1 overflow-y-auto":""}`,children:hn.slice(0,Jt?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:Q(_t({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>ua(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:aa(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:T=>{T.stopPropagation(),ca(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:xe.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[r&&h.jsx("div",{className:"mb-6",children:r}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),Ft.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:[(dn?Ft:Ft.slice(0,10)).map(p=>h.jsxs(Bt,{children:[h.jsx($t,{asChild:!0,children:h.jsx(pn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{ge(p.sampleUsage),qt.current?.focus()},children:p.friendlyName})}),h.jsx(zt,{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)),Ft.length>10&&!dn&&h.jsxs(Bt,{children:[h.jsx($t,{asChild:!0,children:h.jsxs(pn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Bs(!0),children:["+",Ft.length-10," more"]})}),h.jsx(zt,{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:Ft.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"})]})})]}),dn&&Ft.length>10&&h.jsx(pn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Bs(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[xe.map(p=>{const R=p.parts.filter(S=>S.type==="text").map(S=>S.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(yh,{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:R}):h.jsx("div",{className:"space-y-2",children:p.parts.map((S,F)=>{if(S.type?.startsWith("tool-")){const I=S.type?.replace("tool-","")||"",Et=mn.find(rt=>rt.name===I),xt=S.state==="input-available",Dt=S.state==="output-available";if(xt){if(Ws.has(I))return(async()=>{if(tt.has(S.toolCallId))return;X(be=>new Set(be).add(S.toolCallId));const vt=_s.get(I);if(vt)try{console.log("Auto-executing safe tool:",I);const be=Vn(S.input),wa=await vt(...Object.values(be));ve({toolCallId:S.toolCallId,tool:I,output:wa}),console.log("Safe tool result added:",S.toolCallId)}catch(be){ve({toolCallId:S.toolCallId,tool:I,output:`Error: ${be}`}),console.log("Safe tool error result added:",S.toolCallId)}})(),null;const rt=Vn(S.input);return h.jsx(He,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(bh,{toolName:I,description:Et?.description||"",args:rt,onApprove:async()=>{if(tt.has(S.toolCallId)){console.log("Tool call already being processed:",S.toolCallId);return}X(vt=>new Set(vt).add(S.toolCallId));const St=_s.get(I);if(St)try{const vt=await St(...Object.values(rt));ve({toolCallId:S.toolCallId,tool:I,output:vt}),console.log("Tool result added:",S.toolCallId)}catch(vt){ve({toolCallId:S.toolCallId,tool:I,output:`Error: ${vt}`}),console.log("Tool error result added:",S.toolCallId)}},onDeny:async()=>{if(tt.has(S.toolCallId)){console.log("Tool call already being processed:",S.toolCallId);return}X(St=>new Set(St).add(S.toolCallId)),ve({toolCallId:S.toolCallId,tool:I,output:"User denied tool execution"}),console.log("Tool denied:",S.toolCallId)}})},`${S.toolCallId}-${F}`)}else if(Dt){const rt=S.output==="User denied tool execution",St=Vn(S.input);return h.jsx(wh,{toolName:I,args:St,isDenied:rt,isSafe:Ws.has(I)},`${S.toolCallId}-${F}`)}return null}return S.type==="text"&&S.text&&M?h.jsx(M,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:S.text},`${p.id}-${F}`):S.type==="reasoning"&&S.text?h.jsxs(na,{className:"w-full",isStreaming:yt==="streaming"&&F===p.parts.length-1&&p.id===xe.at(-1)?.id,children:[h.jsx(sa,{}),h.jsx(ia,{children:S.text})]},`${p.id}-${F}`):null})})})},p.id)}),h.jsx("div",{ref:pe})]})}),Xs&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",Xs.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Bc,{mode:"wait",children:(yt==="streaming"||yt==="submitted")&&h.jsxs(He,{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(He,{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:O})]})}),h.jsxs("form",{onSubmit:Gs,className:"relative",children:[h.jsx(xo,{ref:qt,value:Ot,onChange:ga,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(),Gs(p))}}),yt==="streaming"||yt==="submitted"?h.jsxs(Bt,{children:[h.jsx($t,{asChild:!0,children:h.jsx("button",{type:"button",className:Q(_t({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:$e,children:h.jsx(q.Square,{className:"h-4 w-4"})})}),h.jsxs(zt,{children:[h.jsx(Zs,{children:"Escape"})," to stop"]})]}):h.jsxs(Bt,{children:[h.jsx($t,{asChild:!0,children:h.jsx("button",{type:"submit",className:Q(_t({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!Ot.trim(),children:h.jsx(q.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(zt,{children:[h.jsx(Zs,{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 overflow-hidden",children:[h.jsx("span",{className:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 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:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 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 Nh(t){if(t&&typeof t=="object"&&!Array.isArray(t))return t;if(typeof t=="string")try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}return{}}function Ih({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:r=[],safeTools:o=[],toolMetadata:a,systemPrompt:l="",initialMessages:u=[],conversationId:c,onToolCall:d,onFinish:f,ragFilters:g}={}){console.log("[useAgent] Hook initialized",{apiBaseUrl:t,tokenEndpoint:e,hasProvidedToken:!!n,skipTokenFetch:s,userId:i?.id,toolsCount:r.length,safeToolsCount:o.length});const[y,v]=m.useState(n||null),w=m.useRef(n||null),[x,C]=m.useState(null),[b,k]=m.useState(null),A=m.useRef(null),[D,N]=m.useState([]),[P,L]=m.useState(c||(typeof window<"u"?crypto.randomUUID():null)),[W,U]=m.useState(!1),[Tt,Mt]=m.useState(new Set),dt=m.useMemo(()=>[...r,...o],[r,o]),it=m.useMemo(()=>ta(dt,a),[dt,a]),pt=m.useMemo(()=>{const M=new Map,E=new Map(it.map(O=>[O.name,O]));return dt.forEach(O=>{const J=O[bt];if(J){const X=E.get(J);if(X){M.set(X.name,O);return}}const tt=it.find(X=>X.name===O.name);tt&&M.set(tt.name,O)}),M},[dt,it]),V=m.useMemo(()=>new Set(it.map(M=>M.name)),[it]),Y=m.useMemo(()=>it.filter(M=>V.has(M.name)),[it,V]),H=m.useMemo(()=>{const M=new Set;return o.forEach(E=>{for(const[O,J]of pt.entries())if(J===E){M.add(O);break}}),M},[o,pt]);m.useEffect(()=>{if(console.log("[useAgent] Token fetch effect running",{skipTokenFetch:s,hasProvidedToken:!!n,user:i?.id,tokenEndpoint:e}),s||n){console.log("[useAgent] Skipping token fetch",{reason:s?"skipTokenFetch=true":"token provided"});return}return(async()=>{console.log("[useAgent] Fetching initial token from",e);try{const E=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!E.ok)throw new Error("Failed to fetch token");const O=await E.json();console.log("[useAgent] Token fetched successfully",{expiresAt:O.expiresAt,expiresIn:O.expiresAt?`${O.expiresAt-Math.floor(Date.now()/1e3)}s`:"unknown"}),v(O.clientToken),w.current=O.clientToken,k(O.expiresAt),C(null)}catch(E){console.error("[useAgent] Token fetch failed:",E),C(E instanceof Error?E.message:"Failed to fetch token")}})(),()=>{console.log("[useAgent] Cleaning up token fetch effect"),A.current&&clearTimeout(A.current)}},[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(console.log("[useAgent] Token refresh effect running",{hasTokenExpiresAt:!!b,tokenExpiresAt:b,skipTokenFetch:s,hasProvidedToken:!!n}),!b||s||n){console.log("[useAgent] Skipping token refresh setup",{reason:b?s?"skipTokenFetch=true":"token provided":"no expiry"});return}A.current&&(console.log("[useAgent] Clearing existing token refresh timeout"),clearTimeout(A.current));const M=Math.floor(Date.now()/1e3),E=b-M,J=Math.max(0,E-5);return console.log("[useAgent] Scheduling token refresh",{expiresAt:b,now:M,timeUntilExpiry:`${E}s`,timeUntilRefresh:`${J}s`,refreshAt:new Date((M+J)*1e3).toISOString()}),A.current=setTimeout(async()=>{console.log("[useAgent] Refreshing token...");try{const tt=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!tt.ok)throw new Error("Failed to refresh token");const X=await tt.json();console.log("[useAgent] Token refreshed successfully",{newExpiresAt:X.expiresAt,expiresIn:`${X.expiresAt-Math.floor(Date.now()/1e3)}s`}),v(X.clientToken),w.current=X.clientToken,k(X.expiresAt),C(null)}catch(tt){console.error("[useAgent] Token refresh failed:",tt),C(tt instanceof Error?tt.message:"Failed to refresh token")}},J*1e3),()=>{console.log("[useAgent] Cleaning up token refresh effect"),A.current&&clearTimeout(A.current)}},[b,e,JSON.stringify(i),s,n]);const ot=async(M,E={})=>{const O=E.headers?new Headers(E.headers):new Headers;return O.delete("user-agent"),O.delete("User-Agent"),fetch(M,{...E,headers:O})},{messages:_,sendMessage:he,status:Yt,error:It,stop:fe,addToolResult:Lt,setMessages:me}=po.useChat({id:P||void 0,messages:u,transport:new Ze.DefaultChatTransport({api:`${t}/chat`,fetch:ot,headers:()=>{const M={};return w.current&&(M.Authorization=`Bearer ${w.current}`),M},body:()=>{const M=Y.map(E=>({name:E.name,description:E.description,inputSchema:E.jsonSchema}));return process.env.NODE_ENV==="development"&&console.log("[useAgent] Sending tools to API:",{totalTools:M.length,toolNames:M.map(E=>E.name),allToolNames:dt.map(E=>E.name),filteredToolNames:Y.map(E=>E.name)}),{tools:M,systemPrompt:l,...g&&{ragFilters:g}}}}),sendAutomaticallyWhen:Ze.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{_.forEach(M=>{M.role==="assistant"&&M.parts.forEach(E=>{if(!E.type?.startsWith("tool-")||E.state!=="input-available")return;const O=E.type.replace("tool-",""),J=E.toolCallId;if(Tt.has(J))return;Mt(X=>new Set(X).add(J));const tt=Nh(E.input);if(H.has(O)){const X=pt.get(O);X&&(async()=>{try{const ye=await X(...Object.values(tt));Lt({toolCallId:J,tool:O,output:ye})}catch(ye){Lt({toolCallId:J,tool:O,output:`Error: ${ye}`})}})()}else d&&d({toolCall:{toolCallId:J,toolName:O,args:tt}})})})},[_,H,pt,d,Lt,Tt]),m.useEffect(()=>{if(Yt==="ready"&&_.length>0&&f){const M=_[_.length-1];M&&M.role==="assistant"&&f({message:M,messages:_,isAbort:!1,isDisconnect:!1,isError:!!It})}},[Yt,_,It,f]);async function un(){if(!(!i?.id||!y)){console.log("[useAgent] Fetching conversations for user:",i?.id),U(!0);try{const E=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${y}`}})).json();N(E.conversations||[])}catch(M){console.error("Failed to fetch conversations:",M)}finally{U(!1)}}}m.useEffect(()=>{i?.id&&y&&un()},[JSON.stringify(i),y,t]);async function pe(M){L(M),U(!0);try{const E=await fetch(`${t}/conversations/${M}/messages`,{headers:{Authorization:`Bearer ${w.current}`}});if(!E.ok)throw new Error(`Failed to fetch messages: ${E.statusText}`);const J=(await E.json()).messages||[];me(J)}catch(E){console.error("Failed to load conversation messages:",E)}finally{U(!1)}}async function qt(M){if(y)try{await fetch(`${t}/conversations/${M}`,{method:"DELETE",headers:{Authorization:`Bearer ${y}`}}),N(D.filter(E=>E._id!==M)),M===P&&Ot()}catch(E){console.error("Failed to delete conversation:",E)}}function Ot(){const M=crypto.randomUUID();L(M),me([]),Mt(new Set)}function ge(M){Lt(M)}return{id:P,messages:_,status:Yt,error:It,sendMessage:he,stop:fe,addToolOutput:ge,setMessages:me,conversations:D,loadConversation:pe,deleteConversation:qt,startNewConversation:Ot,isLoadingConversations:W,clientToken:y,tokenError:x}}exports.verifyToken=Ra.verifyToken;exports.ARCTEN_ORIGINAL_NAME=bt;exports.ArctenAgent=Rh;exports.preserveToolName=xh;exports.useAgent=Ih;
|