@arcteninc/core 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var ya=Object.create;var _s=Object.defineProperty;var xa=Object.getOwnPropertyDescriptor;var va=Object.getOwnPropertyNames;var ba=Object.getPrototypeOf,wa=Object.prototype.hasOwnProperty;var Ta=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of va(e))!wa.call(t,i)&&i!==n&&_s(t,i,{get:()=>e[i],enumerable:!(s=xa(e,i))||s.enumerable});return t};var Sa=(t,e,n)=>(n=t!=null?ya(ba(t)):{},Ta(e||!t||!t.__esModule?_s(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),G=require("lucide-react"),lo=require("@ai-sdk/react"),He=require("ai"),co=require("@radix-ui/react-slot"),uo=require("class-variance-authority"),Ca=require("clsx"),Pa=require("tailwind-merge"),Aa=require("@radix-ui/react-tooltip"),Mt=require("zod"),Ks=require("@radix-ui/react-use-controllable-state"),Ma=require("@radix-ui/react-collapsible"),ja=require("./server.cjs");function Gn(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 xt=Gn(m),te=Gn(Aa),qn=Gn(Ma);function mt(...t){return Pa.twMerge(Ca.clsx(t))}const Da=uo.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"}});function yt({className:t,variant:e,size:n,asChild:s=!1,...i}){const r=s?co.Slot:"button";return h.jsx(r,{"data-slot":"button",className:mt(Da({variant:e,size:n,className:t})),...i})}const Va=uo.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 un({className:t,variant:e,asChild:n=!1,...s}){const i=n?co.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:mt(Va({variant:e}),t),...s})}const Ea=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,r]=xt.useState(!0);xt.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])},ho=xt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...r},o)=>{const a=xt.useRef(null),[l,c]=xt.useState("");return Ea({textAreaRef:a,triggerAutoSize:l,maxHeight:t,minHeight:e}),m.useImperativeHandle(o,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),xt.useEffect(()=>{c(i)},[r?.defaultValue,i]),h.jsx("textarea",{...r,value:i,ref:a,className:mt("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:u=>{c(u.target.value),s?.(u)}})});ho.displayName="AutosizeTextarea";function ka({delayDuration:t=0,...e}){return h.jsx(te.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Ot({...t}){return h.jsx(ka,{children:h.jsx(te.Root,{"data-slot":"tooltip",...t})})}function Ft({...t}){return h.jsx(te.Trigger,{"data-slot":"tooltip-trigger",...t})}function Bt({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(te.Portal,{children:h.jsxs(te.Content,{"data-slot":"tooltip-content",sideOffset:e,className:mt("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(te.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Hs({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:mt("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 Zn=m.createContext({});function Jn(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const Qn=typeof window<"u",fo=Qn?m.useLayoutEffect:m.useEffect,Je=m.createContext(null);function ts(t,e){t.indexOf(e)===-1&&t.push(e)}function es(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const bt=(t,e,n)=>n>e?e:n<t?t:n;function An(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let ie=()=>{},wt=()=>{};process.env.NODE_ENV!=="production"&&(ie=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(An(e,n))},wt=(t,e,n)=>{if(!t)throw new Error(An(e,n))});const Tt={},mo=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function po(t){return typeof t=="object"&&t!==null}const go=t=>/^0[^.\s]+$/u.test(t);function ns(t){let e;return()=>(e===void 0&&(e=t()),e)}const lt=t=>t,Ra=(t,e)=>n=>e(t(n)),Pe=(...t)=>t.reduce(Ra),ve=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class ss{constructor(){this.subscriptions=[]}add(e){return ts(this.subscriptions,e),()=>es(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 ft=t=>t*1e3,at=t=>t/1e3;function yo(t,e){return e?t*(1e3/e):0}const Xs=new Set;function is(t,e,n){t||Xs.has(e)||(console.warn(An(e,n)),Xs.add(e))}const xo=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Na=1e-7,Ia=12;function La(t,e,n,s,i){let r,o,a=0;do o=e+(n-e)/2,r=xo(o,s,i)-t,r>0?n=o:e=o;while(Math.abs(r)>Na&&++a<Ia);return o}function Ae(t,e,n,s){if(t===e&&n===s)return lt;const i=r=>La(r,0,1,t,n);return r=>r===0||r===1?r:xo(i(r),e,s)}const vo=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,bo=t=>e=>1-t(1-e),wo=Ae(.33,1.53,.69,.99),os=bo(wo),To=vo(os),So=t=>(t*=2)<1?.5*os(t):.5*(2-Math.pow(2,-10*(t-1))),rs=t=>1-Math.sin(Math.acos(t)),Co=bo(rs),Po=vo(rs),Oa=Ae(.42,0,1,1),Fa=Ae(0,0,.58,1),Ao=Ae(.42,0,.58,1),Ba=t=>Array.isArray(t)&&typeof t[0]!="number",Mo=t=>Array.isArray(t)&&typeof t[0]=="number",Ys={linear:lt,easeIn:Oa,easeInOut:Ao,easeOut:Fa,circIn:rs,circInOut:Po,circOut:Co,backIn:os,backInOut:To,backOut:wo,anticipate:So},$a=t=>typeof t=="string",Gs=t=>{if(Mo(t)){wt(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return Ae(e,n,s,i)}else if($a(t))return wt(Ys[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Ys[t];return t},Le=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function za(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(u){o.has(u)&&(c.schedule(u),t()),u(a)}const c={schedule:(u,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&o.add(u),y.has(u)||y.add(u),u},cancel:u=>{s.delete(u),o.delete(u)},process:u=>{if(a=u,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,c.process(u))}};return c}const Ua=40;function jo(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Le.reduce((b,j)=>(b[j]=za(r),b),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:u,update:d,preRender:f,render:g,postRender:y}=o,v=()=>{const b=Tt.useManualTiming?i.timestamp:performance.now();n=!1,Tt.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(b-i.timestamp,Ua),1)),i.timestamp=b,i.isProcessing=!0,a.process(i),l.process(i),c.process(i),u.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:Le.reduce((b,j)=>{const P=o[j];return b[j]=(V,D=!1,A=!1)=>(n||w(),P.schedule(V,D,A)),b},{}),cancel:b=>{for(let j=0;j<Le.length;j++)o[Le[j]].cancel(b)},state:i,steps:o}}const{schedule:$,cancel:Dt,state:q,steps:dn}=jo(typeof requestAnimationFrame<"u"?requestAnimationFrame:lt,!0);let ze;function Wa(){ze=void 0}const st={now:()=>(ze===void 0&&st.set(q.isProcessing||Tt.useManualTiming?q.timestamp:performance.now()),ze),set:t=>{ze=t,queueMicrotask(Wa)}},Do=t=>e=>typeof e=="string"&&e.startsWith(t),as=Do("--"),_a=Do("var(--"),ls=t=>_a(t)?Ka.test(t.split("/*")[0].trim()):!1,Ka=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,oe={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},be={...oe,transform:t=>bt(0,1,t)},Oe={...oe,default:1},pe=t=>Math.round(t*1e5)/1e5,cs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ha(t){return t==null}const Xa=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,us=(t,e)=>n=>!!(typeof n=="string"&&Xa.test(n)&&n.startsWith(t)||e&&!Ha(n)&&Object.prototype.hasOwnProperty.call(n,e)),Vo=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(cs);return{[t]:parseFloat(i),[e]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Ya=t=>bt(0,255,t),hn={...oe,transform:t=>Math.round(Ya(t))},Ut={test:us("rgb","red"),parse:Vo("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+hn.transform(t)+", "+hn.transform(e)+", "+hn.transform(n)+", "+pe(be.transform(s))+")"};function Ga(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 Mn={test:us("#"),parse:Ga,transform:Ut.transform},Me=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),jt=Me("deg"),vt=Me("%"),M=Me("px"),qa=Me("vh"),Za=Me("vw"),qs={...vt,parse:t=>vt.parse(t)/100,transform:t=>vt.transform(t*100)},Yt={test:us("hsl","hue"),parse:Vo("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+vt.transform(pe(e))+", "+vt.transform(pe(n))+", "+pe(be.transform(s))+")"},X={test:t=>Ut.test(t)||Mn.test(t)||Yt.test(t),parse:t=>Ut.test(t)?Ut.parse(t):Yt.test(t)?Yt.parse(t):Mn.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Ut.transform(t):Yt.transform(t),getAnimatableNone:t=>{const e=X.parse(t);return e.alpha=0,X.transform(e)}},Ja=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Qa(t){return isNaN(t)&&typeof t=="string"&&(t.match(cs)?.length||0)+(t.match(Ja)?.length||0)>0}const Eo="number",ko="color",tl="var",el="var(",Zs="${}",nl=/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 we(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=e.replace(nl,l=>(X.test(l)?(s.color.push(r),i.push(ko),n.push(X.parse(l))):l.startsWith(el)?(s.var.push(r),i.push(tl),n.push(l)):(s.number.push(r),i.push(Eo),n.push(parseFloat(l))),++r,Zs)).split(Zs);return{values:n,split:a,indexes:s,types:i}}function Ro(t){return we(t).values}function No(t){const{split:e,types:n}=we(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===Eo?r+=pe(i[o]):a===ko?r+=X.transform(i[o]):r+=i[o]}return r}}const sl=t=>typeof t=="number"?0:X.test(t)?X.getAnimatableNone(t):t;function il(t){const e=Ro(t);return No(t)(e.map(sl))}const Vt={test:Qa,parse:Ro,createTransformer:No,getAnimatableNone:il};function fn(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 ol({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=fn(l,a,t+1/3),r=fn(l,a,t),o=fn(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Xe(t,e){return n=>n>0?e:t}const U=(t,e,n)=>t+(e-t)*n,mn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},rl=[Mn,Ut,Yt],al=t=>rl.find(e=>e.test(t));function Js(t){const e=al(t);if(ie(!!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===Yt&&(n=ol(n)),n}const Qs=(t,e)=>{const n=Js(t),s=Js(e);if(!n||!s)return Xe(t,e);const i={...n};return r=>(i.red=mn(n.red,s.red,r),i.green=mn(n.green,s.green,r),i.blue=mn(n.blue,s.blue,r),i.alpha=U(n.alpha,s.alpha,r),Ut.transform(i))},jn=new Set(["none","hidden"]);function ll(t,e){return jn.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function cl(t,e){return n=>U(t,e,n)}function ds(t){return typeof t=="number"?cl:typeof t=="string"?ls(t)?Xe:X.test(t)?Qs:hl:Array.isArray(t)?Io:typeof t=="object"?X.test(t)?Qs:ul:Xe}function Io(t,e){const n=[...t],s=n.length,i=t.map((r,o)=>ds(r)(r,e[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function ul(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=ds(t[i])(t[i],e[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function dl(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 hl=(t,e)=>{const n=Vt.createTransformer(e),s=we(t),i=we(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?jn.has(t)&&!i.values.length||jn.has(e)&&!s.values.length?ll(t,e):Pe(Io(dl(s,i),i.values),n):(ie(!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"),Xe(t,e))};function Lo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?U(t,e,n):ds(t)(t,e)}const fl=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>$.update(e,n),stop:()=>Dt(e),now:()=>q.isProcessing?q.timestamp:st.now()}},Oo=(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)})`},Ye=2e4;function hs(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Ye;)e+=n,s=t.next(e);return e>=Ye?1/0:e}function ml(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(hs(s),Ye);return{type:"keyframes",ease:r=>s.next(i*r).value/e,duration:at(i)}}const pl=5;function Fo(t,e,n){const s=Math.max(e-pl,0);return yo(n-t(s),e-s)}const z={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},pn=.001;function gl({duration:t=z.duration,bounce:e=z.bounce,velocity:n=z.velocity,mass:s=z.mass}){let i,r;ie(t<=ft(z.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=bt(z.minDamping,z.maxDamping,o),t=bt(z.minDuration,z.maxDuration,at(t)),o<1?(i=c=>{const u=c*o,d=u*t,f=u-n,g=Dn(c,o),y=Math.exp(-d);return pn-f/g*y},r=c=>{const d=c*o*t,f=d*n+n,g=Math.pow(o,2)*Math.pow(c,2)*t,y=Math.exp(-d),v=Dn(Math.pow(c,2),o);return(-i(c)+pn>0?-1:1)*((f-g)*y)/v}):(i=c=>{const u=Math.exp(-c*t),d=(c-n)*t+1;return-pn+u*d},r=c=>{const u=Math.exp(-c*t),d=(n-c)*(t*t);return u*d});const a=5/t,l=xl(i,r,a);if(t=ft(t),isNaN(l))return{stiffness:z.stiffness,damping:z.damping,duration:t};{const c=Math.pow(l,2)*s;return{stiffness:c,damping:o*2*Math.sqrt(s*c),duration:t}}}const yl=12;function xl(t,e,n){let s=n;for(let i=1;i<yl;i++)s=s-t(s)/e(s);return s}function Dn(t,e){return t*Math.sqrt(1-e*e)}const vl=["duration","bounce"],bl=["stiffness","damping","mass"];function ti(t,e){return e.some(n=>t[n]!==void 0)}function wl(t){let e={velocity:z.velocity,stiffness:z.stiffness,damping:z.damping,mass:z.mass,isResolvedFromDuration:!1,...t};if(!ti(t,bl)&&ti(t,vl))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*bt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:z.mass,stiffness:i,damping:r}}else{const n=gl(t);e={...e,...n,mass:z.mass},e.isResolvedFromDuration=!0}return e}function Ge(t=z.visualDuration,e=z.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:c,mass:u,duration:d,velocity:f,isResolvedFromDuration:g}=wl({...n,velocity:-at(n.velocity||0)}),y=f||0,v=c/(2*Math.sqrt(l*u)),w=o-r,x=at(Math.sqrt(l/u)),T=Math.abs(w)<5;s||(s=T?z.restSpeed.granular:z.restSpeed.default),i||(i=T?z.restDelta.granular:z.restDelta.default);let b;if(v<1){const P=Dn(x,v);b=V=>{const D=Math.exp(-v*x*V);return o-D*((y+v*x*w)/P*Math.sin(P*V)+w*Math.cos(P*V))}}else if(v===1)b=P=>o-Math.exp(-x*P)*(w+(y+x*w)*P);else{const P=x*Math.sqrt(v*v-1);b=V=>{const D=Math.exp(-v*x*V),A=Math.min(P*V,300);return o-D*((y+v*x*w)*Math.sinh(A)+P*w*Math.cosh(A))/P}}const j={calculatedDuration:g&&d||null,next:P=>{const V=b(P);if(g)a.done=P>=d;else{let D=P===0?y:0;v<1&&(D=P===0?ft(y):Fo(b,P,V));const A=Math.abs(D)<=s,I=Math.abs(o-V)<=i;a.done=A&&I}return a.value=a.done?o:V,a},toString:()=>{const P=Math.min(hs(j),Ye),V=Oo(D=>j.next(P*D).value,P,30);return P+"ms "+V},toTransition:()=>{}};return j}Ge.applyToOptions=t=>{const e=ml(t,100,Ge);return t.ease=e.ease,t.duration=ft(e.duration),t.type="keyframes",t};function Vn({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:c=.5,restSpeed:u}){const d=t[0],f={done:!1,value:d},g=A=>a!==void 0&&A<a||l!==void 0&&A>l,y=A=>a===void 0?l:l===void 0||Math.abs(a-A)<Math.abs(l-A)?a:l;let v=n*e;const w=d+v,x=o===void 0?w:o(w);x!==w&&(v=x-d);const T=A=>-v*Math.exp(-A/s),b=A=>x+T(A),j=A=>{const I=T(A),L=b(A);f.done=Math.abs(I)<=c,f.value=f.done?x:L};let P,V;const D=A=>{g(f.value)&&(P=A,V=Ge({keyframes:[f.value,y(f.value)],velocity:Fo(b,A,f.value),damping:i,stiffness:r,restDelta:c,restSpeed:u}))};return D(0),{calculatedDuration:null,next:A=>{let I=!1;return!V&&P===void 0&&(I=!0,j(A),D(A)),P!==void 0&&A>=P?V.next(A-P):(!I&&j(A),f)}}}function Tl(t,e,n){const s=[],i=n||Tt.mix||Lo,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]||lt:e;a=Pe(l,a)}s.push(a)}return s}function Sl(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const r=t.length;if(wt(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=Tl(e,s,i),l=a.length,c=u=>{if(o&&u<t[0])return e[0];let d=0;if(l>1)for(;d<t.length-2&&!(u<t[d+1]);d++);const f=ve(t[d],t[d+1],u);return a[d](f)};return n?u=>c(bt(t[0],t[r-1],u)):c}function Cl(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=ve(0,e,s);t.push(U(n,1,i))}}function Pl(t){const e=[0];return Cl(e,t.length-1),e}function Al(t,e){return t.map(n=>n*e)}function Ml(t,e){return t.map(()=>e||Ao).splice(0,t.length-1)}function Gt({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=Ba(s)?s.map(Gs):Gs(s),r={done:!1,value:e[0]},o=Al(n&&n.length===e.length?n:Pl(e),t),a=Sl(o,e,{ease:Array.isArray(i)?i:Ml(e,i)});return{calculatedDuration:t,next:l=>(r.value=a(l),r.done=l>=t,r)}}const jl=t=>t!==null;function fs(t,{repeat:e,repeatType:n="loop"},s,i=1){const r=t.filter(jl),a=i<0||e&&n!=="loop"&&e%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const Dl={decay:Vn,inertia:Vn,tween:Gt,keyframes:Gt,spring:Ge};function Bo(t){typeof t.type=="string"&&(t.type=Dl[t.type])}class ms{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 ps extends ms{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;Bo(e);const{type:n=Gt,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=e;let{keyframes:a}=e;const l=n||Gt;process.env.NODE_ENV!=="production"&&l!==Gt&&wt(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Gt&&typeof a[0]!="number"&&(this.mixKeyframes=Pe(Vl,Lo(a[0],a[1])),a=[0,100]);const c=l({...e,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-o})),c.calculatedDuration===null&&(c.calculatedDuration=hs(c));const{calculatedDuration:u}=c;this.calculatedDuration=u,this.resolvedDuration=u+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=c}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:c=0,keyframes:u,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-c*(this.playbackSpeed>=0?1:-1),T=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,j=s;if(d){const A=Math.min(this.currentTime,i)/a;let I=Math.floor(A),L=A%1;!L&&A>=1&&(L=1),L===1&&I--,I=Math.min(I,d+1),!!(I%2)&&(f==="reverse"?(L=1-L,g&&(L-=g/a)):f==="mirror"&&(j=o)),b=bt(0,1,L)*a}const P=T?{done:!1,value:u[0]}:j.next(b);r&&(P.value=r(P.value));let{done:V}=P;!T&&l!==null&&(V=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const D=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&V);return D&&y!==Vn&&(P.value=fs(u,this.options,w,this.speed)),v&&v(P.value),D&&this.finish(),P}then(e,n){return this.finished.then(e,n)}get duration(){return at(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+at(e)}get time(){return at(this.currentTime)}set time(e){e=ft(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=at(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=fl,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 El(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Wt=t=>t*180/Math.PI,En=t=>{const e=Wt(Math.atan2(t[1],t[0]));return kn(e)},kl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:En,rotateZ:En,skewX:t=>Wt(Math.atan(t[1])),skewY:t=>Wt(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},kn=t=>(t=t%360,t<0&&(t+=360),t),ei=En,ni=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),si=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Rl={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ni,scaleY:si,scale:t=>(ni(t)+si(t))/2,rotateX:t=>kn(Wt(Math.atan2(t[6],t[5]))),rotateY:t=>kn(Wt(Math.atan2(-t[2],t[0]))),rotateZ:ei,rotate:ei,skewX:t=>Wt(Math.atan(t[4])),skewY:t=>Wt(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Rn(t){return t.includes("scale")?1:0}function Nn(t,e){if(!t||t==="none")return Rn(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=Rl,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=kl,i=a}if(!i)return Rn(e);const r=s[e],o=i[1].split(",").map(Il);return typeof r=="function"?r(o):o[r]}const Nl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return Nn(n,e)};function Il(t){return parseFloat(t.trim())}const re=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ae=new Set(re),ii=t=>t===oe||t===M,Ll=new Set(["x","y","z"]),Ol=re.filter(t=>!Ll.has(t));function Fl(t){const e=[];return Ol.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const _t={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})=>Nn(e,"x"),y:(t,{transform:e})=>Nn(e,"y")};_t.translateX=_t.x;_t.translateY=_t.y;const Kt=new Set;let In=!1,Ln=!1,On=!1;function $o(){if(Ln){const t=Array.from(Kt).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=Fl(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)})}Ln=!1,In=!1,Kt.forEach(t=>t.complete(On)),Kt.clear()}function zo(){Kt.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Ln=!0)})}function Bl(){On=!0,zo(),$o(),On=!1}class gs{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?(Kt.add(this),In||(In=!0,$.read(zo),$.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])}El(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Kt.delete(this)}cancel(){this.state==="scheduled"&&(Kt.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const $l=t=>t.startsWith("--");function zl(t,e,n){$l(e)?t.style.setProperty(e,n):t.style[e]=n}const Ul=ns(()=>window.ScrollTimeline!==void 0),Wl={};function _l(t,e){const n=ns(t);return()=>Wl[e]??n()}const Uo=_l(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),me=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,oi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:me([0,.65,.55,1]),circOut:me([.55,0,1,.45]),backIn:me([.31,.01,.66,-.59]),backOut:me([.33,1.53,.69,.99])};function Wo(t,e){if(t)return typeof t=="function"?Uo()?Oo(t,e):"ease-out":Mo(t)?me(t):Array.isArray(t)?t.map(n=>Wo(n,e)||oi.easeOut):oi[t]}function Kl(t,e,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},c=void 0){const u={[e]:n};l&&(u.offset=l);const d=Wo(a,i);Array.isArray(d)&&(u.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 c&&(f.pseudoElement=c),t.animate(u,f)}function _o(t){return typeof t=="function"&&"applyToOptions"in t}function Hl({type:t,...e}){return _o(t)&&Uo()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Xl extends ms{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,wt(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const c=Hl(e);this.animation=Kl(n,s,i,c,r),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const u=fs(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(u):zl(n,s,u),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 at(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+at(e)}get time(){return at(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=ft(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&Ul()?(this.animation.timeline=e,lt):n(this)}}const Ko={anticipate:So,backInOut:To,circInOut:Po};function Yl(t){return t in Ko}function Gl(t){typeof t.ease=="string"&&Yl(t.ease)&&(t.ease=Ko[t.ease])}const ri=10;class ql extends Xl{constructor(e){Gl(e),Bo(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 ps({...o,autoplay:!1}),l=ft(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-ri).value,a.sample(l).value,ri),a.stop()}}const ai=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Vt.test(t)||t==="0")&&!t.startsWith("url("));function Zl(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 Jl(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=ai(i,e),a=ai(r,e);return ie(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:Zl(t)||(n==="spring"||_o(n))&&s}function Fn(t){t.duration=0,t.type="keyframes"}const Ql=new Set(["opacity","clipPath","filter","transform"]),tc=ns(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function ec(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:c}=e.owner.getProps();return tc()&&n&&Ql.has(n)&&(n!=="transform"||!c)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const nc=40;class sc extends ms{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:c,element:u,...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:c,element:u,...d},g=u?.KeyframeResolver||gs;this.keyframeResolver=new g(a,(y,v,w)=>this.onKeyframesResolved(y,v,f,!w),l,c,u),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:c,onUpdate:u}=s;this.resolvedAt=st.now(),Jl(e,r,o,a)||((Tt.instantAnimations||!l)&&u?.(fs(e,s,n)),e[0]=e[e.length-1],Fn(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>nc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!c&&ec(f)?new ql({...f,element:f.motionValue.owner.current}):new ps(f);g.finished.then(()=>this.notifyFinished()).catch(lt),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(),Bl()),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 ic=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function oc(t){const e=ic.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const rc=4;function Ho(t,e,n=1){wt(n<=rc,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=oc(t);if(!s)return;const r=window.getComputedStyle(e).getPropertyValue(s);if(r){const o=r.trim();return mo(o)?parseFloat(o):o}return ls(i)?Ho(i,e,n+1):i}function ys(t,e){return t?.[e]??t?.default??t}const Xo=new Set(["width","height","top","left","right","bottom",...re]),ac={test:t=>t==="auto",parse:t=>t},Yo=t=>e=>e.test(t),Go=[oe,M,vt,jt,Za,qa,ac],li=t=>Go.find(Yo(t));function lc(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||go(t):!0}const cc=new Set(["brightness","contrast","saturate","opacity"]);function uc(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(cs)||[];if(!s)return t;const i=n.replace(s,"");let r=cc.has(e)?1:0;return s!==n&&(r*=100),e+"("+r+i+")"}const dc=/\b([a-z-]*)\(.*?\)/gu,Bn={...Vt,getAnimatableNone:t=>{const e=t.match(dc);return e?e.map(uc).join(" "):t}},ci={...oe,transform:Math.round},hc={rotate:jt,rotateX:jt,rotateY:jt,rotateZ:jt,scale:Oe,scaleX:Oe,scaleY:Oe,scaleZ:Oe,skew:jt,skewX:jt,skewY:jt,distance:M,translateX:M,translateY:M,translateZ:M,x:M,y:M,z:M,perspective:M,transformPerspective:M,opacity:be,originX:qs,originY:qs,originZ:M},xs={borderWidth:M,borderTopWidth:M,borderRightWidth:M,borderBottomWidth:M,borderLeftWidth:M,borderRadius:M,radius:M,borderTopLeftRadius:M,borderTopRightRadius:M,borderBottomRightRadius:M,borderBottomLeftRadius:M,width:M,maxWidth:M,height:M,maxHeight:M,top:M,right:M,bottom:M,left:M,padding:M,paddingTop:M,paddingRight:M,paddingBottom:M,paddingLeft:M,margin:M,marginTop:M,marginRight:M,marginBottom:M,marginLeft:M,backgroundPositionX:M,backgroundPositionY:M,...hc,zIndex:ci,fillOpacity:be,strokeOpacity:be,numOctaves:ci},fc={...xs,color:X,backgroundColor:X,outlineColor:X,fill:X,stroke:X,borderColor:X,borderTopColor:X,borderRightColor:X,borderBottomColor:X,borderLeftColor:X,filter:Bn,WebkitFilter:Bn},qo=t=>fc[t];function Zo(t,e){let n=qo(t);return n!==Bn&&(n=Vt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const mc=new Set(["auto","none","0"]);function pc(t,e,n){let s=0,i;for(;s<t.length&&!i;){const r=t[s];typeof r=="string"&&!mc.has(r)&&we(r).values.length&&(i=t[s]),s++}if(i&&n)for(const r of e)t[r]=Zo(n,i)}class gc extends gs{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 c=e[l];if(typeof c=="string"&&(c=c.trim(),ls(c))){const u=Ho(c,n.current);u!==void 0&&(e[l]=u),l===e.length-1&&(this.finalKeyframe=c)}}if(this.resolveNoneKeyframes(),!Xo.has(s)||e.length!==2)return;const[i,r]=e,o=li(i),a=li(r);if(o!==a)if(ii(o)&&ii(a))for(let l=0;l<e.length;l++){const c=e[l];typeof c=="string"&&(e[l]=parseFloat(c))}else _t[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||lc(e[i]))&&s.push(i);s.length&&pc(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=_t[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]=_t[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 yc(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 Jo=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Qo(t){return po(t)&&"offsetHeight"in t}const ui=30,xc=t=>!isNaN(parseFloat(t));class vc{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=xc(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&is(!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 ss);const s=this.events[e].add(n);return e==="change"?()=>{s(),$.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>ui)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,ui);return yo(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 ne(t,e){return new vc(t,e)}const{schedule:vs}=jo(queueMicrotask,!1),ht={x:!1,y:!1};function tr(){return ht.x||ht.y}function bc(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 er(t,e){const n=yc(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function di(t){return!(t.pointerType==="touch"||tr())}function wc(t,e,n={}){const[s,i,r]=er(t,n),o=a=>{if(!di(a))return;const{target:l}=a,c=e(l,a);if(typeof c!="function"||!l)return;const u=d=>{di(d)&&(c(d),l.removeEventListener("pointerleave",u))};l.addEventListener("pointerleave",u,i)};return s.forEach(a=>{a.addEventListener("pointerenter",o,i)}),r}const nr=(t,e)=>e?t===e?!0:nr(t,e.parentElement):!1,bs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Tc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Sc(t){return Tc.has(t.tagName)||t.tabIndex!==-1}const Ue=new WeakSet;function hi(t){return e=>{e.key==="Enter"&&t(e)}}function gn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Cc=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=hi(()=>{if(Ue.has(n))return;gn(n,"down");const i=hi(()=>{gn(n,"up")}),r=()=>gn(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 fi(t){return bs(t)&&!tr()}function Pc(t,e,n={}){const[s,i,r]=er(t,n),o=a=>{const l=a.currentTarget;if(!fi(a))return;Ue.add(l);const c=e(l,a),u=(g,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),Ue.has(l)&&Ue.delete(l),fi(g)&&typeof c=="function"&&c(g,{success:y})},d=g=>{u(g,l===window||l===document||n.useGlobalTarget||nr(l,g.target))},f=g=>{u(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),Qo(a)&&(a.addEventListener("focus",c=>Cc(c,i)),!Sc(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function sr(t){return po(t)&&"ownerSVGElement"in t}function Ac(t){return sr(t)&&t.tagName==="svg"}const J=t=>!!(t&&t.getVelocity),Mc=[...Go,X,Vt],jc=t=>Mc.find(Yo(t)),ws=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function mi(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=mi(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():mi(t[i],null)}}}}function Vc(...t){return xt.useCallback(Dc(...t),t)}class Ec extends xt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=Qo(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 kc({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(ws),l=Vc(r,t?.ref);return m.useInsertionEffect(()=>{const{width:c,height:u,top:d,left:f,right:g}=o.current;if(e||!r.current||!c||!u)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 pa=Object.create;var Ws=Object.defineProperty;var ga=Object.getOwnPropertyDescriptor;var ya=Object.getOwnPropertyNames;var xa=Object.getPrototypeOf,va=Object.prototype.hasOwnProperty;var ba=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ya(e))!va.call(t,i)&&i!==n&&Ws(t,i,{get:()=>e[i],enumerable:!(s=ga(e,i))||s.enumerable});return t};var wa=(t,e,n)=>(n=t!=null?pa(xa(t)):{},ba(e||!t||!t.__esModule?Ws(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),Y=require("lucide-react"),ao=require("@ai-sdk/react"),Ke=require("ai"),lo=require("@radix-ui/react-slot"),co=require("class-variance-authority"),Ta=require("clsx"),Sa=require("tailwind-merge"),Ca=require("@radix-ui/react-tooltip"),jt=require("zod"),_s=require("@radix-ui/react-use-controllable-state"),Pa=require("@radix-ui/react-collapsible"),Aa=require("./server.cjs");function Yn(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 yt=Yn(m),ne=Yn(Ca),Gn=Yn(Pa);function dt(...t){return Sa.twMerge(Ta.clsx(t))}const Ma=co.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{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"}});function gt({className:t,variant:e,size:n,asChild:s=!1,...i}){const r=s?lo.Slot:"button";return h.jsx(r,{"data-slot":"button",className:dt(Ma({variant:e,size:n,className:t})),...i})}const ja=co.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function cn({className:t,variant:e,asChild:n=!1,...s}){const i=n?lo.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:dt(ja({variant:e}),t),...s})}const Da=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,r]=yt.useState(!0);yt.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])},uo=yt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...r},o)=>{const a=yt.useRef(null),[l,c]=yt.useState("");return Da({textAreaRef:a,triggerAutoSize:l,maxHeight:t,minHeight:e}),m.useImperativeHandle(o,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),yt.useEffect(()=>{c(i)},[r?.defaultValue,i]),h.jsx("textarea",{...r,value:i,ref:a,className:dt("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:u=>{c(u.target.value),s?.(u)}})});uo.displayName="AutosizeTextarea";function Va({delayDuration:t=0,...e}){return h.jsx(ne.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Ft({...t}){return h.jsx(Va,{children:h.jsx(ne.Root,{"data-slot":"tooltip",...t})})}function Bt({...t}){return h.jsx(ne.Trigger,{"data-slot":"tooltip-trigger",...t})}function $t({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(ne.Portal,{children:h.jsxs(ne.Content,{"data-slot":"tooltip-content",sideOffset:e,className:dt("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(ne.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Ks({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:dt("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 qn=m.createContext({});function Zn(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const Jn=typeof window<"u",ho=Jn?m.useLayoutEffect:m.useEffect,Ze=m.createContext(null);function Qn(t,e){t.indexOf(e)===-1&&t.push(e)}function ts(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Tt=(t,e,n)=>n>e?e:n<t?t:n;function Pn(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let re=()=>{},St=()=>{};process.env.NODE_ENV!=="production"&&(re=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(Pn(e,n))},St=(t,e,n)=>{if(!t)throw new Error(Pn(e,n))});const Ct={},fo=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function mo(t){return typeof t=="object"&&t!==null}const po=t=>/^0[^.\s]+$/u.test(t);function es(t){let e;return()=>(e===void 0&&(e=t()),e)}const at=t=>t,Ea=(t,e)=>n=>e(t(n)),Ce=(...t)=>t.reduce(Ea),xe=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class ns{constructor(){this.subscriptions=[]}add(e){return Qn(this.subscriptions,e),()=>ts(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 ut=t=>t*1e3,rt=t=>t/1e3;function go(t,e){return e?t*(1e3/e):0}const Hs=new Set;function ss(t,e,n){t||Hs.has(e)||(console.warn(Pn(e,n)),Hs.add(e))}const yo=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,ka=1e-7,Ra=12;function Na(t,e,n,s,i){let r,o,a=0;do o=e+(n-e)/2,r=yo(o,s,i)-t,r>0?n=o:e=o;while(Math.abs(r)>ka&&++a<Ra);return o}function Pe(t,e,n,s){if(t===e&&n===s)return at;const i=r=>Na(r,0,1,t,n);return r=>r===0||r===1?r:yo(i(r),e,s)}const xo=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,vo=t=>e=>1-t(1-e),bo=Pe(.33,1.53,.69,.99),is=vo(bo),wo=xo(is),To=t=>(t*=2)<1?.5*is(t):.5*(2-Math.pow(2,-10*(t-1))),os=t=>1-Math.sin(Math.acos(t)),So=vo(os),Co=xo(os),Ia=Pe(.42,0,1,1),La=Pe(0,0,.58,1),Po=Pe(.42,0,.58,1),Oa=t=>Array.isArray(t)&&typeof t[0]!="number",Ao=t=>Array.isArray(t)&&typeof t[0]=="number",Xs={linear:at,easeIn:Ia,easeInOut:Po,easeOut:La,circIn:os,circInOut:Co,circOut:So,backIn:is,backInOut:wo,backOut:bo,anticipate:To},Fa=t=>typeof t=="string",Ys=t=>{if(Ao(t)){St(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return Pe(e,n,s,i)}else if(Fa(t))return St(Xs[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Xs[t];return t},Ie=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Ba(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(u){o.has(u)&&(c.schedule(u),t()),u(a)}const c={schedule:(u,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&o.add(u),y.has(u)||y.add(u),u},cancel:u=>{s.delete(u),o.delete(u)},process:u=>{if(a=u,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,c.process(u))}};return c}const $a=40;function Mo(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Ie.reduce((T,M)=>(T[M]=Ba(r),T),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:u,update:d,preRender:f,render:p,postRender:y}=o,x=()=>{const T=Ct.useManualTiming?i.timestamp:performance.now();n=!1,Ct.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(T-i.timestamp,$a),1)),i.timestamp=T,i.isProcessing=!0,a.process(i),l.process(i),c.process(i),u.process(i),d.process(i),f.process(i),p.process(i),y.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(x))},w=()=>{n=!0,s=!0,i.isProcessing||t(x)};return{schedule:Ie.reduce((T,M)=>{const P=o[M];return T[M]=(E,D=!1,A=!1)=>(n||w(),P.schedule(E,D,A)),T},{}),cancel:T=>{for(let M=0;M<Ie.length;M++)o[Ie[M]].cancel(T)},state:i,steps:o}}const{schedule:B,cancel:Vt,state:G,steps:un}=Mo(typeof requestAnimationFrame<"u"?requestAnimationFrame:at,!0);let $e;function za(){$e=void 0}const nt={now:()=>($e===void 0&&nt.set(G.isProcessing||Ct.useManualTiming?G.timestamp:performance.now()),$e),set:t=>{$e=t,queueMicrotask(za)}},jo=t=>e=>typeof e=="string"&&e.startsWith(t),rs=jo("--"),Ua=jo("var(--"),as=t=>Ua(t)?Wa.test(t.split("/*")[0].trim()):!1,Wa=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ae={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},ve={...ae,transform:t=>Tt(0,1,t)},Le={...ae,default:1},me=t=>Math.round(t*1e5)/1e5,ls=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function _a(t){return t==null}const Ka=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,cs=(t,e)=>n=>!!(typeof n=="string"&&Ka.test(n)&&n.startsWith(t)||e&&!_a(n)&&Object.prototype.hasOwnProperty.call(n,e)),Do=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(ls);return{[t]:parseFloat(i),[e]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Ha=t=>Tt(0,255,t),dn={...ae,transform:t=>Math.round(Ha(t))},Wt={test:cs("rgb","red"),parse:Do("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+dn.transform(t)+", "+dn.transform(e)+", "+dn.transform(n)+", "+me(ve.transform(s))+")"};function Xa(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 An={test:cs("#"),parse:Xa,transform:Wt.transform},Ae=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Dt=Ae("deg"),xt=Ae("%"),j=Ae("px"),Ya=Ae("vh"),Ga=Ae("vw"),Gs={...xt,parse:t=>xt.parse(t)/100,transform:t=>xt.transform(t*100)},qt={test:cs("hsl","hue"),parse:Do("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+xt.transform(me(e))+", "+xt.transform(me(n))+", "+me(ve.transform(s))+")"},X={test:t=>Wt.test(t)||An.test(t)||qt.test(t),parse:t=>Wt.test(t)?Wt.parse(t):qt.test(t)?qt.parse(t):An.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Wt.transform(t):qt.transform(t),getAnimatableNone:t=>{const e=X.parse(t);return e.alpha=0,X.transform(e)}},qa=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Za(t){return isNaN(t)&&typeof t=="string"&&(t.match(ls)?.length||0)+(t.match(qa)?.length||0)>0}const Vo="number",Eo="color",Ja="var",Qa="var(",qs="${}",tl=/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 be(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=e.replace(tl,l=>(X.test(l)?(s.color.push(r),i.push(Eo),n.push(X.parse(l))):l.startsWith(Qa)?(s.var.push(r),i.push(Ja),n.push(l)):(s.number.push(r),i.push(Vo),n.push(parseFloat(l))),++r,qs)).split(qs);return{values:n,split:a,indexes:s,types:i}}function ko(t){return be(t).values}function Ro(t){const{split:e,types:n}=be(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===Vo?r+=me(i[o]):a===Eo?r+=X.transform(i[o]):r+=i[o]}return r}}const el=t=>typeof t=="number"?0:X.test(t)?X.getAnimatableNone(t):t;function nl(t){const e=ko(t);return Ro(t)(e.map(el))}const Et={test:Za,parse:ko,createTransformer:Ro,getAnimatableNone:nl};function hn(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 sl({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=hn(l,a,t+1/3),r=hn(l,a,t),o=hn(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function He(t,e){return n=>n>0?e:t}const W=(t,e,n)=>t+(e-t)*n,fn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},il=[An,Wt,qt],ol=t=>il.find(e=>e.test(t));function Zs(t){const e=ol(t);if(re(!!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===qt&&(n=sl(n)),n}const Js=(t,e)=>{const n=Zs(t),s=Zs(e);if(!n||!s)return He(t,e);const i={...n};return r=>(i.red=fn(n.red,s.red,r),i.green=fn(n.green,s.green,r),i.blue=fn(n.blue,s.blue,r),i.alpha=W(n.alpha,s.alpha,r),Wt.transform(i))},Mn=new Set(["none","hidden"]);function rl(t,e){return Mn.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function al(t,e){return n=>W(t,e,n)}function us(t){return typeof t=="number"?al:typeof t=="string"?as(t)?He:X.test(t)?Js:ul:Array.isArray(t)?No:typeof t=="object"?X.test(t)?Js:ll:He}function No(t,e){const n=[...t],s=n.length,i=t.map((r,o)=>us(r)(r,e[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function ll(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=us(t[i])(t[i],e[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function cl(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 ul=(t,e)=>{const n=Et.createTransformer(e),s=be(t),i=be(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?Mn.has(t)&&!i.values.length||Mn.has(e)&&!s.values.length?rl(t,e):Ce(No(cl(s,i),i.values),n):(re(!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"),He(t,e))};function Io(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?W(t,e,n):us(t)(t,e)}const dl=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>B.update(e,n),stop:()=>Vt(e),now:()=>G.isProcessing?G.timestamp:nt.now()}},Lo=(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)})`},Xe=2e4;function ds(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Xe;)e+=n,s=t.next(e);return e>=Xe?1/0:e}function hl(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(ds(s),Xe);return{type:"keyframes",ease:r=>s.next(i*r).value/e,duration:rt(i)}}const fl=5;function Oo(t,e,n){const s=Math.max(e-fl,0);return go(n-t(s),e-s)}const U={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},mn=.001;function ml({duration:t=U.duration,bounce:e=U.bounce,velocity:n=U.velocity,mass:s=U.mass}){let i,r;re(t<=ut(U.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=Tt(U.minDamping,U.maxDamping,o),t=Tt(U.minDuration,U.maxDuration,rt(t)),o<1?(i=c=>{const u=c*o,d=u*t,f=u-n,p=jn(c,o),y=Math.exp(-d);return mn-f/p*y},r=c=>{const d=c*o*t,f=d*n+n,p=Math.pow(o,2)*Math.pow(c,2)*t,y=Math.exp(-d),x=jn(Math.pow(c,2),o);return(-i(c)+mn>0?-1:1)*((f-p)*y)/x}):(i=c=>{const u=Math.exp(-c*t),d=(c-n)*t+1;return-mn+u*d},r=c=>{const u=Math.exp(-c*t),d=(n-c)*(t*t);return u*d});const a=5/t,l=gl(i,r,a);if(t=ut(t),isNaN(l))return{stiffness:U.stiffness,damping:U.damping,duration:t};{const c=Math.pow(l,2)*s;return{stiffness:c,damping:o*2*Math.sqrt(s*c),duration:t}}}const pl=12;function gl(t,e,n){let s=n;for(let i=1;i<pl;i++)s=s-t(s)/e(s);return s}function jn(t,e){return t*Math.sqrt(1-e*e)}const yl=["duration","bounce"],xl=["stiffness","damping","mass"];function Qs(t,e){return e.some(n=>t[n]!==void 0)}function vl(t){let e={velocity:U.velocity,stiffness:U.stiffness,damping:U.damping,mass:U.mass,isResolvedFromDuration:!1,...t};if(!Qs(t,xl)&&Qs(t,yl))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*Tt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:U.mass,stiffness:i,damping:r}}else{const n=ml(t);e={...e,...n,mass:U.mass},e.isResolvedFromDuration=!0}return e}function Ye(t=U.visualDuration,e=U.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:c,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=vl({...n,velocity:-rt(n.velocity||0)}),y=f||0,x=c/(2*Math.sqrt(l*u)),w=o-r,v=rt(Math.sqrt(l/u)),b=Math.abs(w)<5;s||(s=b?U.restSpeed.granular:U.restSpeed.default),i||(i=b?U.restDelta.granular:U.restDelta.default);let T;if(x<1){const P=jn(v,x);T=E=>{const D=Math.exp(-x*v*E);return o-D*((y+x*v*w)/P*Math.sin(P*E)+w*Math.cos(P*E))}}else if(x===1)T=P=>o-Math.exp(-v*P)*(w+(y+v*w)*P);else{const P=v*Math.sqrt(x*x-1);T=E=>{const D=Math.exp(-x*v*E),A=Math.min(P*E,300);return o-D*((y+x*v*w)*Math.sinh(A)+P*w*Math.cosh(A))/P}}const M={calculatedDuration:p&&d||null,next:P=>{const E=T(P);if(p)a.done=P>=d;else{let D=P===0?y:0;x<1&&(D=P===0?ut(y):Oo(T,P,E));const A=Math.abs(D)<=s,F=Math.abs(o-E)<=i;a.done=A&&F}return a.value=a.done?o:E,a},toString:()=>{const P=Math.min(ds(M),Xe),E=Lo(D=>M.next(P*D).value,P,30);return P+"ms "+E},toTransition:()=>{}};return M}Ye.applyToOptions=t=>{const e=hl(t,100,Ye);return t.ease=e.ease,t.duration=ut(e.duration),t.type="keyframes",t};function Dn({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:c=.5,restSpeed:u}){const d=t[0],f={done:!1,value:d},p=A=>a!==void 0&&A<a||l!==void 0&&A>l,y=A=>a===void 0?l:l===void 0||Math.abs(a-A)<Math.abs(l-A)?a:l;let x=n*e;const w=d+x,v=o===void 0?w:o(w);v!==w&&(x=v-d);const b=A=>-x*Math.exp(-A/s),T=A=>v+b(A),M=A=>{const F=b(A),N=T(A);f.done=Math.abs(F)<=c,f.value=f.done?v:N};let P,E;const D=A=>{p(f.value)&&(P=A,E=Ye({keyframes:[f.value,y(f.value)],velocity:Oo(T,A,f.value),damping:i,stiffness:r,restDelta:c,restSpeed:u}))};return D(0),{calculatedDuration:null,next:A=>{let F=!1;return!E&&P===void 0&&(F=!0,M(A),D(A)),P!==void 0&&A>=P?E.next(A-P):(!F&&M(A),f)}}}function bl(t,e,n){const s=[],i=n||Ct.mix||Io,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]||at:e;a=Ce(l,a)}s.push(a)}return s}function wl(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const r=t.length;if(St(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=bl(e,s,i),l=a.length,c=u=>{if(o&&u<t[0])return e[0];let d=0;if(l>1)for(;d<t.length-2&&!(u<t[d+1]);d++);const f=xe(t[d],t[d+1],u);return a[d](f)};return n?u=>c(Tt(t[0],t[r-1],u)):c}function Tl(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=xe(0,e,s);t.push(W(n,1,i))}}function Sl(t){const e=[0];return Tl(e,t.length-1),e}function Cl(t,e){return t.map(n=>n*e)}function Pl(t,e){return t.map(()=>e||Po).splice(0,t.length-1)}function Zt({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=Oa(s)?s.map(Ys):Ys(s),r={done:!1,value:e[0]},o=Cl(n&&n.length===e.length?n:Sl(e),t),a=wl(o,e,{ease:Array.isArray(i)?i:Pl(e,i)});return{calculatedDuration:t,next:l=>(r.value=a(l),r.done=l>=t,r)}}const Al=t=>t!==null;function hs(t,{repeat:e,repeatType:n="loop"},s,i=1){const r=t.filter(Al),a=i<0||e&&n!=="loop"&&e%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const Ml={decay:Dn,inertia:Dn,tween:Zt,keyframes:Zt,spring:Ye};function Fo(t){typeof t.type=="string"&&(t.type=Ml[t.type])}class fs{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 jl=t=>t/100;class ms extends fs{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!==nt.now()&&this.tick(nt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;Fo(e);const{type:n=Zt,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=e;let{keyframes:a}=e;const l=n||Zt;process.env.NODE_ENV!=="production"&&l!==Zt&&St(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Zt&&typeof a[0]!="number"&&(this.mixKeyframes=Ce(jl,Io(a[0],a[1])),a=[0,100]);const c=l({...e,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-o})),c.calculatedDuration===null&&(c.calculatedDuration=ds(c));const{calculatedDuration:u}=c;this.calculatedDuration=u,this.resolvedDuration=u+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=c}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:c=0,keyframes:u,repeat:d,repeatType:f,repeatDelay:p,type:y,onUpdate:x,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 v=this.currentTime-c*(this.playbackSpeed>=0?1:-1),b=this.playbackSpeed>=0?v<0:v>i;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let T=this.currentTime,M=s;if(d){const A=Math.min(this.currentTime,i)/a;let F=Math.floor(A),N=A%1;!N&&A>=1&&(N=1),N===1&&F--,F=Math.min(F,d+1),!!(F%2)&&(f==="reverse"?(N=1-N,p&&(N-=p/a)):f==="mirror"&&(M=o)),T=Tt(0,1,N)*a}const P=b?{done:!1,value:u[0]}:M.next(T);r&&(P.value=r(P.value));let{done:E}=P;!b&&l!==null&&(E=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const D=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&E);return D&&y!==Dn&&(P.value=hs(u,this.options,w,this.speed)),x&&x(P.value),D&&this.finish(),P}then(e,n){return this.finished.then(e,n)}get duration(){return rt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+rt(e)}get time(){return rt(this.currentTime)}set time(e){e=ut(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(nt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=rt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=dl,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(nt.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 Dl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const _t=t=>t*180/Math.PI,Vn=t=>{const e=_t(Math.atan2(t[1],t[0]));return En(e)},Vl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:Vn,rotateZ:Vn,skewX:t=>_t(Math.atan(t[1])),skewY:t=>_t(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},En=t=>(t=t%360,t<0&&(t+=360),t),ti=Vn,ei=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),ni=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),El={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ei,scaleY:ni,scale:t=>(ei(t)+ni(t))/2,rotateX:t=>En(_t(Math.atan2(t[6],t[5]))),rotateY:t=>En(_t(Math.atan2(-t[2],t[0]))),rotateZ:ti,rotate:ti,skewX:t=>_t(Math.atan(t[4])),skewY:t=>_t(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function kn(t){return t.includes("scale")?1:0}function Rn(t,e){if(!t||t==="none")return kn(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=El,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Vl,i=a}if(!i)return kn(e);const r=s[e],o=i[1].split(",").map(Rl);return typeof r=="function"?r(o):o[r]}const kl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return Rn(n,e)};function Rl(t){return parseFloat(t.trim())}const le=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ce=new Set(le),si=t=>t===ae||t===j,Nl=new Set(["x","y","z"]),Il=le.filter(t=>!Nl.has(t));function Ll(t){const e=[];return Il.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const Kt={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})=>Rn(e,"x"),y:(t,{transform:e})=>Rn(e,"y")};Kt.translateX=Kt.x;Kt.translateY=Kt.y;const Ht=new Set;let Nn=!1,In=!1,Ln=!1;function Bo(){if(In){const t=Array.from(Ht).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=Ll(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([r,o])=>{s.getValue(r)?.set(o)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}In=!1,Nn=!1,Ht.forEach(t=>t.complete(Ln)),Ht.clear()}function $o(){Ht.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(In=!0)})}function Ol(){Ln=!0,$o(),Bo(),Ln=!1}class ps{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?(Ht.add(this),Nn||(Nn=!0,B.read($o),B.resolveKeyframes(Bo))):(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])}Dl(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ht.delete(this)}cancel(){this.state==="scheduled"&&(Ht.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Fl=t=>t.startsWith("--");function Bl(t,e,n){Fl(e)?t.style.setProperty(e,n):t.style[e]=n}const $l=es(()=>window.ScrollTimeline!==void 0),zl={};function Ul(t,e){const n=es(t);return()=>zl[e]??n()}const zo=Ul(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),fe=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,ii={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:fe([0,.65,.55,1]),circOut:fe([.55,0,1,.45]),backIn:fe([.31,.01,.66,-.59]),backOut:fe([.33,1.53,.69,.99])};function Uo(t,e){if(t)return typeof t=="function"?zo()?Lo(t,e):"ease-out":Ao(t)?fe(t):Array.isArray(t)?t.map(n=>Uo(n,e)||ii.easeOut):ii[t]}function Wl(t,e,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},c=void 0){const u={[e]:n};l&&(u.offset=l);const d=Uo(a,i);Array.isArray(d)&&(u.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 c&&(f.pseudoElement=c),t.animate(u,f)}function Wo(t){return typeof t=="function"&&"applyToOptions"in t}function _l({type:t,...e}){return Wo(t)&&zo()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Kl extends fs{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,St(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const c=_l(e);this.animation=Wl(n,s,i,c,r),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const u=hs(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(u):Bl(n,s,u),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 rt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+rt(e)}get time(){return rt(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=ut(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,at):n(this)}}const _o={anticipate:To,backInOut:wo,circInOut:Co};function Hl(t){return t in _o}function Xl(t){typeof t.ease=="string"&&Hl(t.ease)&&(t.ease=_o[t.ease])}const oi=10;class Yl extends Kl{constructor(e){Xl(e),Fo(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 ms({...o,autoplay:!1}),l=ut(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-oi).value,a.sample(l).value,oi),a.stop()}}const ri=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Et.test(t)||t==="0")&&!t.startsWith("url("));function Gl(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=ri(i,e),a=ri(r,e);return re(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:Gl(t)||(n==="spring"||Wo(n))&&s}function On(t){t.duration=0,t.type="keyframes"}const Zl=new Set(["opacity","clipPath","filter","transform"]),Jl=es(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Ql(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:c}=e.owner.getProps();return Jl()&&n&&Zl.has(n)&&(n!=="transform"||!c)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const tc=40;class ec extends fs{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:c,element:u,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=nt.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,name:l,motionValue:c,element:u,...d},p=u?.KeyframeResolver||ps;this.keyframeResolver=new p(a,(y,x,w)=>this.onKeyframesResolved(y,x,f,!w),l,c,u),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:c,onUpdate:u}=s;this.resolvedAt=nt.now(),ql(e,r,o,a)||((Ct.instantAnimations||!l)&&u?.(hs(e,s,n)),e[0]=e[e.length-1],On(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>tc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},p=!c&&Ql(f)?new Yl({...f,element:f.motionValue.owner.current}):new ms(f);p.finished.then(()=>this.notifyFinished()).catch(at),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Ol()),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 nc=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function sc(t){const e=nc.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const ic=4;function Ko(t,e,n=1){St(n<=ic,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=sc(t);if(!s)return;const r=window.getComputedStyle(e).getPropertyValue(s);if(r){const o=r.trim();return fo(o)?parseFloat(o):o}return as(i)?Ko(i,e,n+1):i}function gs(t,e){return t?.[e]??t?.default??t}const Ho=new Set(["width","height","top","left","right","bottom",...le]),oc={test:t=>t==="auto",parse:t=>t},Xo=t=>e=>e.test(t),Yo=[ae,j,xt,Dt,Ga,Ya,oc],ai=t=>Yo.find(Xo(t));function rc(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||po(t):!0}const ac=new Set(["brightness","contrast","saturate","opacity"]);function lc(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(ls)||[];if(!s)return t;const i=n.replace(s,"");let r=ac.has(e)?1:0;return s!==n&&(r*=100),e+"("+r+i+")"}const cc=/\b([a-z-]*)\(.*?\)/gu,Fn={...Et,getAnimatableNone:t=>{const e=t.match(cc);return e?e.map(lc).join(" "):t}},li={...ae,transform:Math.round},uc={rotate:Dt,rotateX:Dt,rotateY:Dt,rotateZ:Dt,scale:Le,scaleX:Le,scaleY:Le,scaleZ:Le,skew:Dt,skewX:Dt,skewY:Dt,distance:j,translateX:j,translateY:j,translateZ:j,x:j,y:j,z:j,perspective:j,transformPerspective:j,opacity:ve,originX:Gs,originY:Gs,originZ:j},ys={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,...uc,zIndex:li,fillOpacity:ve,strokeOpacity:ve,numOctaves:li},dc={...ys,color:X,backgroundColor:X,outlineColor:X,fill:X,stroke:X,borderColor:X,borderTopColor:X,borderRightColor:X,borderBottomColor:X,borderLeftColor:X,filter:Fn,WebkitFilter:Fn},Go=t=>dc[t];function qo(t,e){let n=Go(t);return n!==Fn&&(n=Et),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const hc=new Set(["auto","none","0"]);function fc(t,e,n){let s=0,i;for(;s<t.length&&!i;){const r=t[s];typeof r=="string"&&!hc.has(r)&&be(r).values.length&&(i=t[s]),s++}if(i&&n)for(const r of e)t[r]=qo(n,i)}class mc extends ps{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 c=e[l];if(typeof c=="string"&&(c=c.trim(),as(c))){const u=Ko(c,n.current);u!==void 0&&(e[l]=u),l===e.length-1&&(this.finalKeyframe=c)}}if(this.resolveNoneKeyframes(),!Ho.has(s)||e.length!==2)return;const[i,r]=e,o=ai(i),a=ai(r);if(o!==a)if(si(o)&&si(a))for(let l=0;l<e.length;l++){const c=e[l];typeof c=="string"&&(e[l]=parseFloat(c))}else Kt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||rc(e[i]))&&s.push(i);s.length&&fc(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=Kt[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]=Kt[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 pc(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 Zo=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Jo(t){return mo(t)&&"offsetHeight"in t}const ci=30,gc=t=>!isNaN(parseFloat(t));class yc{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=nt.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=nt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=gc(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&ss(!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 ns);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=nt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>ci)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,ci);return go(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 ie(t,e){return new yc(t,e)}const{schedule:xs}=Mo(queueMicrotask,!1),ct={x:!1,y:!1};function Qo(){return ct.x||ct.y}function xc(t){return t==="x"||t==="y"?ct[t]?null:(ct[t]=!0,()=>{ct[t]=!1}):ct.x||ct.y?null:(ct.x=ct.y=!0,()=>{ct.x=ct.y=!1})}function tr(t,e){const n=pc(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function ui(t){return!(t.pointerType==="touch"||Qo())}function vc(t,e,n={}){const[s,i,r]=tr(t,n),o=a=>{if(!ui(a))return;const{target:l}=a,c=e(l,a);if(typeof c!="function"||!l)return;const u=d=>{ui(d)&&(c(d),l.removeEventListener("pointerleave",u))};l.addEventListener("pointerleave",u,i)};return s.forEach(a=>{a.addEventListener("pointerenter",o,i)}),r}const er=(t,e)=>e?t===e?!0:er(t,e.parentElement):!1,vs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,bc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function wc(t){return bc.has(t.tagName)||t.tabIndex!==-1}const ze=new WeakSet;function di(t){return e=>{e.key==="Enter"&&t(e)}}function pn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Tc=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=di(()=>{if(ze.has(n))return;pn(n,"down");const i=di(()=>{pn(n,"up")}),r=()=>pn(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 hi(t){return vs(t)&&!Qo()}function Sc(t,e,n={}){const[s,i,r]=tr(t,n),o=a=>{const l=a.currentTarget;if(!hi(a))return;ze.add(l);const c=e(l,a),u=(p,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),ze.has(l)&&ze.delete(l),hi(p)&&typeof c=="function"&&c(p,{success:y})},d=p=>{u(p,l===window||l===document||n.useGlobalTarget||er(l,p.target))},f=p=>{u(p,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),Jo(a)&&(a.addEventListener("focus",c=>Tc(c,i)),!wc(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function nr(t){return mo(t)&&"ownerSVGElement"in t}function Cc(t){return nr(t)&&t.tagName==="svg"}const Z=t=>!!(t&&t.getVelocity),Pc=[...Yo,X,Et],Ac=t=>Pc.find(Xo(t)),bs=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function fi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Mc(...t){return e=>{let n=!1;const s=t.map(i=>{const r=fi(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():fi(t[i],null)}}}}function jc(...t){return yt.useCallback(Mc(...t),t)}class Dc extends yt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=Jo(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 Vc({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(bs),l=jc(r,t?.ref);return m.useInsertionEffect(()=>{const{width:c,height:u,top:d,left:f,right:p}=o.current;if(e||!r.current||!c||!u)return;const y=n==="left"?`left: ${f}`:`right: ${p}`;r.current.dataset.motionPopId=i;const x=document.createElement("style");a&&(x.nonce=a);const w=s??document.head;return w.appendChild(x),x.sheet&&x.sheet.insertRule(`
2
2
  [data-motion-pop-id="${i}"] {
3
3
  position: absolute !important;
4
4
  width: ${c}px !important;
@@ -6,9 +6,9 @@
6
6
  ${y}px !important;
7
7
  top: ${d}px !important;
8
8
  }
9
- `),()=>{w.contains(v)&&w.removeChild(v)}},[e]),h.jsx(Ec,{isPresent:e,childRef:r,sizeRef:o,children:xt.cloneElement(t,{ref:l})})}const Rc=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,root:l})=>{const c=Jn(Nc),u=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:u,initial:e,isPresent:n,custom:i,onExitComplete:g=>{c.set(g,!0);for(const y of c.values())if(!y)return;s&&s()},register:g=>(c.set(g,!1),()=>c.delete(g))}),[n,c,s]);return r&&d&&(f={...f}),m.useMemo(()=>{c.forEach((g,y)=>c.set(y,!1))},[n]),xt.useEffect(()=>{!n&&!c.size&&s&&s()},[n]),o==="popLayout"&&(t=h.jsx(kc,{isPresent:n,anchorX:a,root:l,children:t})),h.jsx(Je.Provider,{value:f,children:t})};function Nc(){return new Map}function ir(t=!0){const e=m.useContext(Je);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 Fe=t=>t.key||"";function pi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Ic=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",root:l})=>{const[c,u]=ir(o),d=m.useMemo(()=>pi(t),[t]),f=o&&!c?[]:d.map(Fe),g=m.useRef(!0),y=m.useRef(d),v=Jn(()=>new Map),[w,x]=m.useState(d),[T,b]=m.useState(d);fo(()=>{g.current=!1,y.current=d;for(let V=0;V<T.length;V++){const D=Fe(T[V]);f.includes(D)?v.delete(D):v.get(D)!==!0&&v.set(D,!1)}},[T,f.length,f.join("-")]);const j=[];if(d!==w){let V=[...d];for(let D=0;D<T.length;D++){const A=T[D],I=Fe(A);f.includes(I)||(V.splice(D,0,A),j.push(A))}return r==="wait"&&j.length&&(V=j),b(pi(V)),x(d),null}process.env.NODE_ENV!=="production"&&r==="wait"&&T.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:P}=m.useContext(Zn);return h.jsx(h.Fragment,{children:T.map(V=>{const D=Fe(V),A=o&&!c?!1:d===T||f.includes(D),I=()=>{if(v.has(D))v.set(D,!0);else return;let L=!0;v.forEach(Q=>{Q||(L=!1)}),L&&(P?.(),b(y.current),o&&u?.(),s&&s())};return h.jsx(Rc,{isPresent:A,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:r,root:l,onExitComplete:A?void 0:I,anchorX:a,children:V},D)})})},Ts=m.createContext({strict:!1}),gi={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"]},se={};for(const t in gi)se[t]={isEnabled:e=>gi[t].some(n=>!!e[n])};function $n(t){for(const e in t)se[e]={...se[e],...t[e]}}function Lc({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!yn(e)),i=m.useRef(void 0);if(!yn(e)){const{renderer:r,...o}=e;i.current=r,$n(o)}return m.useEffect(()=>{yn(e)&&e().then(({renderer:r,...o})=>{$n(o),i.current=r,s(!0)})},[]),h.jsx(Ts.Provider,{value:{renderer:i.current,strict:n},children:t})}function yn(t){return typeof t=="function"}const Oc=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 qe(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Oc.has(t)}let or=t=>!qe(t);function Fc(t){typeof t=="function"&&(or=e=>e.startsWith("on")?!qe(e):t(e))}try{Fc(require("@emotion/is-prop-valid").default)}catch{}function Bc(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(or(i)||n===!0&&qe(i)||!e&&!qe(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const Qe=m.createContext({});function tn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Te(t){return typeof t=="string"||Array.isArray(t)}const Ss=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Cs=["initial",...Ss];function en(t){return tn(t.animate)||Cs.some(e=>Te(t[e]))}function rr(t){return!!(en(t)||t.variants)}function $c(t,e){if(en(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Te(n)?n:void 0,animate:Te(s)?s:void 0}}return t.inherit!==!1?e:{}}function zc(t){const{initial:e,animate:n}=$c(t,m.useContext(Qe));return m.useMemo(()=>({initial:e,animate:n}),[yi(e),yi(n)])}function yi(t){return Array.isArray(t)?t.join(" "):t}const Se={};function Uc(t){for(const e in t)Se[e]=t[e],as(e)&&(Se[e].isCSSVariable=!0)}function ar(t,{layout:e,layoutId:n}){return ae.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Se[t]||t==="opacity")}const Wc={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},_c=re.length;function Kc(t,e,n){let s="",i=!0;for(let r=0;r<_c;r++){const o=re[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 c=Jo(a,xs[o]);if(!l){i=!1;const u=Wc[o]||o;s+=`${u}(${c}) `}n&&(e[o]=c)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function Ps(t,e,n){const{style:s,vars:i,transformOrigin:r}=t;let o=!1,a=!1;for(const l in e){const c=e[l];if(ae.has(l)){o=!0;continue}else if(as(l)){i[l]=c;continue}else{const u=Jo(c,xs[l]);l.startsWith("origin")?(a=!0,r[l]=u):s[l]=u}}if(e.transform||(o||n?s.transform=Kc(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:c="50%",originZ:u=0}=r;s.transformOrigin=`${l} ${c} ${u}`}}const As=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function lr(t,e,n){for(const s in e)!J(e[s])&&!ar(s,n)&&(t[s]=e[s])}function Hc({transformTemplate:t},e){return m.useMemo(()=>{const n=As();return Ps(n,e,t),Object.assign({},n.vars,n.style)},[e])}function Xc(t,e){const n=t.style||{},s={};return lr(s,n,t),Object.assign(s,Hc(t,e)),s}function Yc(t,e){const n={},s=Xc(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 Gc={offset:"stroke-dashoffset",array:"stroke-dasharray"},qc={offset:"strokeDashoffset",array:"strokeDasharray"};function Zc(t,e,n=1,s=0,i=!0){t.pathLength=1;const r=i?Gc:qc;t[r.offset]=M.transform(-s);const o=M.transform(e),a=M.transform(n);t[r.array]=`${o} ${a}`}function cr(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,c,u){if(Ps(t,a,c),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=u?.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&&Zc(d,i,r,o,!1)}const ur=()=>({...As(),attrs:{}}),dr=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Jc(t,e,n,s){const i=m.useMemo(()=>{const r=ur();return cr(r,e,dr(s),t.transformTemplate,t.style),{...r.attrs,style:{...r.style}}},[e]);if(t.style){const r={};lr(r,t.style,t),i.style={...r,...i.style}}return i}const Qc=["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 Ms(t){return typeof t!="string"||t.includes("-")?!1:!!(Qc.indexOf(t)>-1||/[A-Z]/u.test(t))}function tu(t,e,n,{latestValues:s},i,r=!1){const a=(Ms(t)?Jc:Yc)(e,s,i,t),l=Bc(e,typeof t=="string",r),c=t!==m.Fragment?{...l,...a,ref:n}:{},{children:u}=e,d=m.useMemo(()=>J(u)?u.get():u,[u]);return m.createElement(t,{...c,children:d})}function xi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function js(t,e,n,s){if(typeof e=="function"){const[i,r]=xi(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]=xi(s);e=e(n!==void 0?n:t.custom,i,r)}return e}function We(t){return J(t)?t.get():t}function eu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:nu(n,s,i,t),renderState:e()}}function nu(t,e,n,s){const i={},r=s(t,{});for(const f in r)i[f]=We(r[f]);let{initial:o,animate:a}=t;const l=en(t),c=rr(t);e&&c&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let u=n?n.initial===!1:!1;u=u||o===!1;const d=u?a:o;if(d&&typeof d!="boolean"&&!tn(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const y=js(t,f[g]);if(y){const{transitionEnd:v,transition:w,...x}=y;for(const T in x){let b=x[T];if(Array.isArray(b)){const j=u?b.length-1:0;b=b[j]}b!==null&&(i[T]=b)}for(const T in v)i[T]=v[T]}}}return i}const hr=t=>(e,n)=>{const s=m.useContext(Qe),i=m.useContext(Je),r=()=>eu(t,e,s,i);return n?r():Jn(r)};function Ds(t,e,n){const{style:s}=t,i={};for(const r in s)(J(s[r])||e.style&&J(e.style[r])||ar(r,t)||n?.getValue(r)?.liveStyle!==void 0)&&(i[r]=s[r]);return i}const su=hr({scrapeMotionValuesFromProps:Ds,createRenderState:As});function fr(t,e,n){const s=Ds(t,e,n);for(const i in t)if(J(t[i])||J(e[i])){const r=re.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=t[i]}return s}const iu=hr({scrapeMotionValuesFromProps:fr,createRenderState:ur}),ou=Symbol.for("motionComponentSymbol");function qt(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function ru(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):qt(n)&&(n.current=s))},[e])}const Vs=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),au="framerAppearId",mr="data-"+Vs(au),pr=m.createContext({});function lu(t,e,n,s,i){const{visualElement:r}=m.useContext(Qe),o=m.useContext(Ts),a=m.useContext(Je),l=m.useContext(ws).reducedMotion,c=m.useRef(null);s=s||o.renderer,!c.current&&s&&(c.current=s(t,{visualState:e,parent:r,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const u=c.current,d=m.useContext(pr);u&&!u.projection&&i&&(u.type==="html"||u.type==="svg")&&cu(c.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{u&&f.current&&u.update(n,a)});const g=n[mr],y=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return fo(()=>{u&&(f.current=!0,window.MotionIsMounted=!0,u.updateFeatures(),u.scheduleRenderMicrotask(),y.current&&u.animationState&&u.animationState.animateChanges())}),m.useEffect(()=>{u&&(!y.current&&u.animationState&&u.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),y.current=!1),u.enteringChildren=void 0)}),u}function cu(t,e,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:c,layoutCrossfade:u}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:gr(t.parent)),t.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&qt(a),visualElement:t,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:u,layoutScroll:l,layoutRoot:c})}function gr(t){if(t)return t.options.allowProjection!==!1?t.projection:gr(t.parent)}function _e(t,{forwardMotionProps:e=!1}={},n,s){n&&$n(n);const i=Ms(t)?iu:su;function r(a,l){let c;const u={...m.useContext(ws),...a,layoutId:uu(a)},{isStatic:d}=u,f=zc(a),g=i(a,d);if(!d&&Qn){du(u,n);const y=hu(u);c=y.MeasureLayout,f.visualElement=lu(t,g,u,s,y.ProjectionNode)}return h.jsxs(Qe.Provider,{value:f,children:[c&&f.visualElement?h.jsx(c,{visualElement:f.visualElement,...u}):null,tu(t,a,ru(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[ou]=t,o}function uu({layoutId:t}){const e=m.useContext(Zn).id;return e&&t!==void 0?e+"-"+t:t}function du(t,e){const n=m.useContext(Ts).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?ie(!1,s,"lazy-strict-mode"):wt(!1,s,"lazy-strict-mode")}}function hu(t){const{drag:e,layout:n}=se;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function fu(t,e){if(typeof Proxy>"u")return _e;const n=new Map,s=(r,o)=>_e(r,o,t,e),i=(r,o)=>(process.env.NODE_ENV!=="production"&&is(!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,_e(o,void 0,t,e)),n.get(o))})}function yr({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function mu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function pu(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 xn(t){return t===void 0||t===1}function zn({scale:t,scaleX:e,scaleY:n}){return!xn(t)||!xn(e)||!xn(n)}function zt(t){return zn(t)||xr(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function xr(t){return vi(t.x)||vi(t.y)}function vi(t){return t&&t!=="0%"}function Ze(t,e,n){const s=t-n,i=e*s;return n+i}function bi(t,e,n,s,i){return i!==void 0&&(t=Ze(t,i,s)),Ze(t,n,s)+e}function Un(t,e=0,n=1,s,i){t.min=bi(t.min,e,n,s,i),t.max=bi(t.max,e,n,s,i)}function vr(t,{x:e,y:n}){Un(t.x,e.translate,e.scale,e.originPoint),Un(t.y,n.translate,n.scale,n.originPoint)}const wi=.999999999999,Ti=1.0000000000001;function gu(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&&Jt(t,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,vr(t,o)),s&&zt(r.latestValues)&&Jt(t,r.latestValues))}e.x<Ti&&e.x>wi&&(e.x=1),e.y<Ti&&e.y>wi&&(e.y=1)}function Zt(t,e){t.min=t.min+e,t.max=t.max+e}function Si(t,e,n,s,i=.5){const r=U(t.min,t.max,i);Un(t,e,n,r,s)}function Jt(t,e){Si(t.x,e.x,e.scaleX,e.scale,e.originX),Si(t.y,e.y,e.scaleY,e.scale,e.originY)}function br(t,e){return yr(pu(t.getBoundingClientRect(),e))}function yu(t,e,n){const s=br(t,n),{scroll:i}=e;return i&&(Zt(s.x,i.offset.x),Zt(s.y,i.offset.y)),s}const Ci=()=>({translate:0,scale:1,origin:0,originPoint:0}),Qt=()=>({x:Ci(),y:Ci()}),Pi=()=>({min:0,max:0}),H=()=>({x:Pi(),y:Pi()}),Wn={current:null},wr={current:!1};function xu(){if(wr.current=!0,!!Qn)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Wn.current=t.matches;t.addEventListener("change",e),e()}else Wn.current=!1}const vu=new WeakMap;function bu(t,e,n){for(const s in e){const i=e[s],r=n[s];if(J(i))t.addValue(s,i);else if(J(r))t.addValue(s,ne(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,ne(o!==void 0?o:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Ai=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class wu{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=gs,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,$.render(this.render,!1,!0))};const{latestValues:l,renderState:c}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=c,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=en(n),this.isVariantNode=rr(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:u,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];l[f]!==void 0&&J(g)&&g.set(l[f])}}mount(e){this.current=e,vu.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)),wr.current||xu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Wn.current,process.env.NODE_ENV!=="production"&&is(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(),Dt(this.notifyUpdate),Dt(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=ae.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&$.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 se){const n=se[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):H()}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<Ai.length;s++){const i=Ai[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=bu(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=ne(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"&&(mo(s)||go(s))?s=parseFloat(s):!jc(s)&&Vt.test(n)&&(s=Zo(e,n)),this.setBaseTarget(e,J(s)?s.get():s)),J(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=js(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&&!J(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 ss),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){vs.render(this.render)}}class Tr extends wu{constructor(){super(...arguments),this.KeyframeResolver=gc}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;J(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Sr(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 Tu(t){return window.getComputedStyle(t)}class Su extends Tr{constructor(){super(...arguments),this.type="html",this.renderInstance=Sr}readValueFromInstance(e,n){if(ae.has(n))return this.projection?.isProjecting?Rn(n):Nl(e,n);{const s=Tu(e),i=(as(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return br(e,n)}build(e,n,s){Ps(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return Ds(e,n,s)}}const Cr=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 Cu(t,e,n,s){Sr(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Cr.has(i)?i:Vs(i),e.attrs[i])}class Pu extends Tr{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=H}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(ae.has(n)){const s=qo(n);return s&&s.default||0}return n=Cr.has(n)?n:Vs(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return fr(e,n,s)}build(e,n,s){cr(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Cu(e,n,s,i)}mount(e){this.isSVGTag=dr(e.tagName),super.mount(e)}}const Pr=(t,e)=>Ms(t)?new Pu(e):new Su(e,{allowProjection:t!==m.Fragment});function ee(t,e,n){const s=t.getProps();return js(s,e,n!==void 0?n:s.custom,t)}const _n=t=>Array.isArray(t);function Au(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,ne(n))}function Mu(t){return _n(t)?t[t.length-1]||0:t}function ju(t,e){const n=ee(t,e);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=Mu(r[o]);Au(t,o,a)}}function Du(t){return!!(J(t)&&t.add)}function Kn(t,e){const n=t.getValue("willChange");if(Du(n))return n.add(e);if(!n&&Tt.WillChange){const s=new Tt.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Ar(t){return t.props[mr]}const Vu=t=>t!==null;function Eu(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 ku={type:"spring",stiffness:500,damping:25,restSpeed:10},Ru=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Nu={type:"keyframes",duration:.8},Iu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Lu=(t,{keyframes:e})=>e.length>2?Nu:ae.has(t)?t.startsWith("scale")?Ru(e[1]):ku:Iu;function Ou({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:c,...u}){return!!Object.keys(u).length}const Es=(t,e,n,s={},i,r)=>o=>{const a=ys(s,t)||{},l=a.delay||s.delay||0;let{elapsed:c=0}=s;c=c-ft(l);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-c,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};Ou(a)||Object.assign(u,Lu(t,u)),u.duration&&(u.duration=ft(u.duration)),u.repeatDelay&&(u.repeatDelay=ft(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Fn(u),u.delay===0&&(d=!0)),(Tt.instantAnimations||Tt.skipAnimations)&&(d=!0,Fn(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,d&&!r&&e.get()!==void 0){const f=Eu(u.keyframes,a);if(f!==void 0){$.update(()=>{u.onUpdate(f),u.onComplete()});return}}return a.isSync?new ps(u):new sc(u)};function Fu({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Mr(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r=t.getDefaultTransition(),transitionEnd:o,...a}=e;s&&(r=s);const l=[],c=i&&t.animationState&&t.animationState.getState()[i];for(const u in a){const d=t.getValue(u,t.latestValues[u]??null),f=a[u];if(f===void 0||c&&Fu(c,u))continue;const g={delay:n,...ys(r||{},u)},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=Ar(t);if(x){const T=window.MotionHandoffAnimation(x,u,$);T!==null&&(g.startTime=T,v=!0)}}Kn(t,u),d.start(Es(u,d,f,t.shouldReduceMotion&&Xo.has(u)?{type:!1}:g,t,v));const w=d.animation;w&&l.push(w)}return o&&Promise.all(l).then(()=>{$.update(()=>{o&&ju(t,o)})}),l}function jr(t,e,n,s=0,i=1){const r=Array.from(t).sort((c,u)=>c.sortNodePosition(u)).indexOf(e),o=t.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}function Hn(t,e,n={}){const s=ee(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(Mr(t,s,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:c=0,staggerChildren:u,staggerDirection:d}=i;return Bu(t,e,l,c,u,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,c]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>c())}else return Promise.all([r(),o(n.delay)])}function Bu(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(Hn(l,e,{...o,delay:n+(typeof s=="function"?0:s)+jr(t.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function $u(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(r=>Hn(t,r,n));s=Promise.all(i)}else if(typeof e=="string")s=Hn(t,e,n);else{const i=typeof e=="function"?ee(t,e,n.custom):e;s=Promise.all(Mr(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function Dr(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 zu=Cs.length;function Vr(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Vr(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<zu;n++){const s=Cs[n],i=t.props[s];(Te(i)||i===!1)&&(e[s]=i)}return e}const Uu=[...Ss].reverse(),Wu=Ss.length;function _u(t){return e=>Promise.all(e.map(({animation:n,options:s})=>$u(t,n,s)))}function Ku(t){let e=_u(t),n=Mi(),s=!0;const i=l=>(c,u)=>{const d=ee(t,u,l==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...y}=d;c={...c,...y,...g}}return c};function r(l){e=l(t)}function o(l){const{props:c}=t,u=Vr(t.parent)||{},d=[],f=new Set;let g={},y=1/0;for(let w=0;w<Wu;w++){const x=Uu[w],T=n[x],b=c[x]!==void 0?c[x]:u[x],j=Te(b),P=x===l?T.isActive:null;P===!1&&(y=w);let V=b===u[x]&&b!==c[x]&&j;if(V&&s&&t.manuallyAnimateOnMount&&(V=!1),T.protectedKeys={...g},!T.isActive&&P===null||!b&&!T.prevProp||tn(b)||typeof b=="boolean")continue;const D=Hu(T.prevProp,b);let A=D||x===l&&T.isActive&&!V&&j||w>y&&j,I=!1;const L=Array.isArray(b)?b:[b];let Q=L.reduce(i(x),{});P===!1&&(Q={});const{prevResolvedValues:ct={}}=T,Ht={...ct,...Q},St=R=>{A=!0,f.has(R)&&(I=!0,f.delete(R)),T.needsAnimating[R]=!0;const B=t.getValue(R);B&&(B.liveStyle=!1)};for(const R in Ht){const B=Q[R],Z=ct[R];if(g.hasOwnProperty(R))continue;let W=!1;_n(B)&&_n(Z)?W=!Dr(B,Z):W=B!==Z,W?B!=null?St(R):f.add(R):B!==void 0&&f.has(R)?St(R):T.protectedKeys[R]=!0}T.prevProp=b,T.prevResolvedValues=Q,T.isActive&&(g={...g,...Q}),s&&t.blockInitialAnimation&&(A=!1);const pt=V&&D;A&&(!pt||I)&&d.push(...L.map(R=>{const B={type:x};if(typeof R=="string"&&s&&!pt&&t.manuallyAnimateOnMount&&t.parent){const{parent:Z}=t,W=ee(Z,R);if(Z.enteringChildren&&W){const{delayChildren:kt}=W.transition||{};B.delay=jr(Z.enteringChildren,t,kt)}}return{animation:R,options:B}}))}if(f.size){const w={};if(typeof c.initial!="boolean"){const x=ee(t,Array.isArray(c.initial)?c.initial[0]:c.initial);x&&x.transition&&(w.transition=x.transition)}f.forEach(x=>{const T=t.getBaseTarget(x),b=t.getValue(x);b&&(b.liveStyle=!0),w[x]=T??null}),d.push({animation:w})}let v=!!d.length;return s&&(c.initial===!1||c.initial===c.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(l,c){if(n[l].isActive===c)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(l,c)),n[l].isActive=c;const u=o(l);for(const d in n)n[d].protectedKeys={};return u}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Mi()}}}function Hu(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Dr(e,t):!1}function $t(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Mi(){return{animate:$t(!0),whileInView:$t(),whileHover:$t(),whileTap:$t(),whileDrag:$t(),whileFocus:$t(),exit:$t()}}class Et{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Xu extends Et{constructor(e){super(e),e.animationState||(e.animationState=Ku(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();tn(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 Gu extends Et{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 Er={animation:{Feature:Xu},exit:{Feature:Gu}};function Ce(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function je(t){return{point:{x:t.pageX,y:t.pageY}}}const qu=t=>e=>bs(e)&&t(e,je(e));function ge(t,e,n,s){return Ce(t,e,qu(n),s)}const kr=1e-4,Zu=1-kr,Ju=1+kr,Rr=.01,Qu=0-Rr,td=0+Rr;function et(t){return t.max-t.min}function ed(t,e,n){return Math.abs(t-e)<=n}function ji(t,e,n,s=.5){t.origin=s,t.originPoint=U(e.min,e.max,t.origin),t.scale=et(n)/et(e),t.translate=U(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Zu&&t.scale<=Ju||isNaN(t.scale))&&(t.scale=1),(t.translate>=Qu&&t.translate<=td||isNaN(t.translate))&&(t.translate=0)}function ye(t,e,n,s){ji(t.x,e.x,n.x,s?s.originX:void 0),ji(t.y,e.y,n.y,s?s.originY:void 0)}function Di(t,e,n){t.min=n.min+e.min,t.max=t.min+et(e)}function nd(t,e,n){Di(t.x,e.x,n.x),Di(t.y,e.y,n.y)}function Vi(t,e,n){t.min=e.min-n.min,t.max=t.min+et(e)}function xe(t,e,n){Vi(t.x,e.x,n.x),Vi(t.y,e.y,n.y)}function rt(t){return[t("x"),t("y")]}const Nr=({current:t})=>t?t.ownerDocument.defaultView:null,Ei=(t,e)=>Math.abs(t-e);function sd(t,e){const n=Ei(t.x,e.x),s=Ei(t.y,e.y);return Math.sqrt(n**2+s**2)}class Ir{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=bn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=sd(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:T}=this.handlers;g||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=vn(g,this.transformPagePoint),$.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=bn(f.type==="pointercancel"?this.lastMoveEventInfo:vn(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!bs(e))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const a=je(e),l=vn(a,this.transformPagePoint),{point:c}=l,{timestamp:u}=q;this.history=[{...c,timestamp:u}];const{onSessionStart:d}=n;d&&d(e,bn(l,this.history)),this.removeListeners=Pe(ge(this.contextWindow,"pointermove",this.handlePointerMove),ge(this.contextWindow,"pointerup",this.handlePointerUp),ge(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Dt(this.updatePoint)}}function vn(t,e){return e?{point:e(t.point)}:t}function ki(t,e){return{x:t.x-e.x,y:t.y-e.y}}function bn({point:t},e){return{point:t,delta:ki(t,Lr(e)),offset:ki(t,id(e)),velocity:od(e,.1)}}function id(t){return t[0]}function Lr(t){return t[t.length-1]}function od(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Lr(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>ft(e)));)n--;if(!s)return{x:0,y:0};const r=at(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 rd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?U(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?U(n,t,s.max):Math.min(t,n)),t}function Ri(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 ad(t,{top:e,left:n,bottom:s,right:i}){return{x:Ri(t.x,n,i),y:Ri(t.y,e,s)}}function Ni(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 ld(t,e){return{x:Ni(t.x,e.x),y:Ni(t.y,e.y)}}function cd(t,e){let n=.5;const s=et(t),i=et(e);return i>s?n=ve(e.min,e.max-s,t.min):s>i&&(n=ve(t.min,t.max-i,e.min)),bt(0,1,n)}function ud(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 Xn=.35;function dd(t=Xn){return t===!1?t=0:t===!0&&(t=Xn),{x:Ii(t,"left","right"),y:Ii(t,"top","bottom")}}function Ii(t,e,n){return{min:Li(t,e),max:Li(t,n)}}function Li(t,e){return typeof t=="number"?t:t[e]||0}const hd=new WeakMap;class fd{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=H(),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(je(d).point)},o=(d,f)=>{const{drag:g,dragPropagation:y,onDragStart:v}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=bc(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),rt(x=>{let T=this.getAxisMotionValue(x).get()||0;if(vt.test(T)){const{projection:b}=this.visualElement;if(b&&b.layout){const j=b.layout.layoutBox[x];j&&(T=et(j)*(parseFloat(T)/100))}}this.originPoint[x]=T}),v&&$.postRender(()=>v(d,f)),Kn(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=md(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},c=()=>rt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:u}=this.getProps();this.panSession=new Ir(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:s,contextWindow:Nr(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&&$.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||!Be(e,i,this.currentDirection))return;const r=this.getAxisMotionValue(e);let o=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(o=rd(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&&qt(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=ad(s.layoutBox,e):this.constraints=!1,this.elastic=dd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&rt(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=ud(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!qt(e))return!1;const s=e.current;wt(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=yu(s,i.root,this.visualElement.getTransformPagePoint());let o=ld(i.layout.layoutBox,r);if(n){const a=n(mu(o));this.hasMutatedConstraints=!!a,a&&(o=yr(a))}return o}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},c=rt(u=>{if(!Be(u,n,this.currentDirection))return;let d=l&&l[u]||{};o&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,y={type:"inertia",velocity:s?e[u]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...r,...d};return this.startAxisValueAnimation(u,y)});return Promise.all(c).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Kn(this.visualElement,e),s.start(Es(e,s,0,n,this.visualElement,!1))}stopAnimation(){rt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){rt(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){rt(n=>{const{drag:s}=this.getProps();if(!Be(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]-U(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!qt(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};rt(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();i[o]=cd({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(),rt(o=>{if(!Be(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:c}=this.constraints[o];a.set(U(l,c,i[o]))})}addListeners(){if(!this.visualElement.current)return;hd.set(this.visualElement,this);const e=this.visualElement.current,n=ge(e,"pointerdown",l=>{const{drag:c,dragListener:u=!0}=this.getProps();c&&u&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();qt(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()),$.read(s);const o=Ce(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(rt(u=>{const d=this.getAxisMotionValue(u);d&&(this.originPoint[u]+=l[u].translate,d.set(d.get()+l[u].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=Xn,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function Be(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function md(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class pd extends Et{constructor(e){super(e),this.removeGroupControls=lt,this.removeListeners=lt,this.controls=new fd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||lt}unmount(){this.removeGroupControls(),this.removeListeners()}}const Oi=t=>(e,n)=>{t&&$.postRender(()=>t(e,n))};class gd extends Et{constructor(){super(...arguments),this.removePointerDownListener=lt}onPointerDown(e){this.session=new Ir(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Nr(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:Oi(e),onStart:Oi(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&$.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=ge(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 Ke={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Fi(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const fe={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(M.test(t))t=parseFloat(t);else return t;const n=Fi(t,e.target.x),s=Fi(t,e.target.y);return`${n}% ${s}%`}},yd={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Vt.parse(t);if(i.length>5)return s;const r=Vt.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 c=U(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=c),typeof i[3+o]=="number"&&(i[3+o]/=c),r(i)}};let wn=!1;class xd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=e;Uc(vd),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),wn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),Ke.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,wn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==r?o.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?o.promote():o.relegate()||$.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),vs.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;wn=!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 Or(t){const[e,n]=ir(),s=m.useContext(Zn);return h.jsx(xd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(pr),isPresent:e,safeToRemove:n})}const vd={borderRadius:{...fe,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:fe,borderTopRightRadius:fe,borderBottomLeftRadius:fe,borderBottomRightRadius:fe,boxShadow:yd};function bd(t,e,n){const s=J(t)?t:ne(t);return s.start(Es("",s,e,n)),s.animation}const wd=(t,e)=>t.depth-e.depth;class Td{constructor(){this.children=[],this.isDirty=!1}add(e){ts(this.children,e),this.isDirty=!0}remove(e){es(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(wd),this.isDirty=!1,this.children.forEach(e)}}function Sd(t,e){const n=st.now(),s=({timestamp:i})=>{const r=i-n;r>=e&&(Dt(s),t(r-e))};return $.setup(s,!0),()=>Dt(s)}const Fr=["TopLeft","TopRight","BottomLeft","BottomRight"],Cd=Fr.length,Bi=t=>typeof t=="string"?parseFloat(t):t,$i=t=>typeof t=="number"||M.test(t);function Pd(t,e,n,s,i,r){i?(t.opacity=U(0,n.opacity??1,Ad(s)),t.opacityExit=U(e.opacity??1,0,Md(s))):r&&(t.opacity=U(e.opacity??1,n.opacity??1,s));for(let o=0;o<Cd;o++){const a=`border${Fr[o]}Radius`;let l=zi(e,a),c=zi(n,a);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||$i(l)===$i(c)?(t[a]=Math.max(U(Bi(l),Bi(c),s),0),(vt.test(c)||vt.test(l))&&(t[a]+="%")):t[a]=c}(e.rotate||n.rotate)&&(t.rotate=U(e.rotate||0,n.rotate||0,s))}function zi(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Ad=Br(0,.5,Co),Md=Br(.5,.95,lt);function Br(t,e,n){return s=>s<t?0:s>e?1:n(ve(t,e,s))}function Ui(t,e){t.min=e.min,t.max=e.max}function ot(t,e){Ui(t.x,e.x),Ui(t.y,e.y)}function Wi(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function _i(t,e,n,s,i){return t-=e,t=Ze(t,1/n,s),i!==void 0&&(t=Ze(t,1/i,s)),t}function jd(t,e=0,n=1,s=.5,i,r=t,o=t){if(vt.test(e)&&(e=parseFloat(e),e=U(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=U(r.min,r.max,s);t===r&&(a-=e),t.min=_i(t.min,e,n,a,i),t.max=_i(t.max,e,n,a,i)}function Ki(t,e,[n,s,i],r,o){jd(t,e[n],e[s],e[i],e.scale,r,o)}const Dd=["x","scaleX","originX"],Vd=["y","scaleY","originY"];function Hi(t,e,n,s){Ki(t.x,e,Dd,n?n.x:void 0,s?s.x:void 0),Ki(t.y,e,Vd,n?n.y:void 0,s?s.y:void 0)}function Xi(t){return t.translate===0&&t.scale===1}function $r(t){return Xi(t.x)&&Xi(t.y)}function Yi(t,e){return t.min===e.min&&t.max===e.max}function Ed(t,e){return Yi(t.x,e.x)&&Yi(t.y,e.y)}function Gi(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function zr(t,e){return Gi(t.x,e.x)&&Gi(t.y,e.y)}function qi(t){return et(t.x)/et(t.y)}function Zi(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class kd{constructor(){this.members=[]}add(e){ts(this.members,e),e.scheduleRender()}remove(e){if(es(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 Rd(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:c,rotate:u,rotateX:d,rotateY:f,skewX:g,skewY:y}=n;c&&(s=`perspective(${c}px) ${s}`),u&&(s+=`rotate(${u}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 Tn=["","X","Y","Z"],Nd=1e3;let Id=0;function Sn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function Ur(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Ar(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",$,!(i||r))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&Ur(s)}function Wr({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Id++,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(Fd),this.nodes.forEach(Ud),this.nodes.forEach(Wd),this.nodes.forEach(Bd)},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 Td)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new ss),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=sr(o)&&!Ac(o),this.instance=o;const{layoutId:a,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let u,d=0;const f=()=>this.root.updateBlockedByResize=!1;$.read(()=>{d=window.innerWidth}),t(o,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,u&&u(),u=Sd(f,250),Ke.hasAnimatedSinceResize&&(Ke.hasAnimatedSinceResize=!1,this.nodes.forEach(to)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||c.getDefaultTransition()||Yd,{onLayoutAnimationStart:v,onLayoutAnimationComplete:w}=c.getProps(),x=!this.targetLayout||!zr(this.targetLayout,g),T=!d&&f;if(this.options.layoutRoot||this.resumeFrom||T||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...ys(y,"layout"),onPlay:v,onComplete:w};(c.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(u,T)}else d||to(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(),Dt(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(_d),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&&Ur(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const d=this.path[u];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 c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Ji);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Qi);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(zd),this.nodes.forEach(Ld),this.nodes.forEach(Od)):this.nodes.forEach(Qi),this.clearAllSnapshots();const a=st.now();q.delta=bt(0,1e3/60,a-q.timestamp),q.timestamp=a,q.isProcessing=!0,dn.update.process(q),dn.preRender.process(q),dn.render.process(q),q.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,vs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach($d),this.sharedNodes.forEach(Kd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,$.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){$.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!et(this.snapshot.measuredBox.x)&&!et(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=H(),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(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;o&&this.instance&&(a||zt(this.latestValues)||u)&&(i(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),Gd(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return H();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(qd))){const{scroll:c}=this.root;c&&(Zt(a.x,c.offset.x),Zt(a.y,c.offset.y))}return a}removeElementScroll(o){const a=H();if(ot(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const c=this.path[l],{scroll:u,options:d}=c;c!==this.root&&u&&d.layoutScroll&&(u.wasRoot&&ot(a,o),Zt(a.x,u.offset.x),Zt(a.y,u.offset.y))}return a}applyTransform(o,a=!1){const l=H();ot(l,o);for(let c=0;c<this.path.length;c++){const u=this.path[c];!a&&u.options.layoutScroll&&u.scroll&&u!==u.root&&Jt(l,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),zt(u.latestValues)&&Jt(l,u.latestValues)}return zt(this.latestValues)&&Jt(l,this.latestValues),l}removeTransform(o){const a=H();ot(a,o);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!c.instance||!zt(c.latestValues))continue;zn(c.latestValues)&&c.updateSnapshot();const u=H(),d=c.measurePageBox();ot(u,d),Hi(a,c.latestValues,c.snapshot?c.snapshot.layoutBox:void 0,u)}return zt(this.latestValues)&&Hi(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:u,layoutId:d}=this.options;if(!(!this.layout||!(u||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=H(),this.relativeTargetOrigin=H(),xe(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),ot(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=H(),this.targetWithTransforms=H()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),nd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):ot(this.target,this.layout.layoutBox),vr(this.target,this.targetDelta)):ot(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=H(),this.relativeTargetOrigin=H(),xe(this.relativeTargetOrigin,this.target,f.target),ot(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||zn(this.parent.latestValues)||xr(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:c,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||u))return;ot(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;gu(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=H());const{target:g}=o;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Wi(this.prevProjectionDelta.x,this.projectionDelta.x),Wi(this.prevProjectionDelta.y,this.projectionDelta.y)),ye(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Zi(this.projectionDelta.x,this.prevProjectionDelta.x)||!Zi(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=Qt(),this.projectionDelta=Qt(),this.projectionDeltaWithTransform=Qt()}setAnimationOrigin(o,a=!1){const l=this.snapshot,c=l?l.latestValues:{},u={...this.latestValues},d=Qt();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=H(),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,T=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(Xd));this.animationProgress=0;let b;this.mixTargetDelta=j=>{const P=j/1e3;eo(d.x,o.x,P),eo(d.y,o.y,P),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(xe(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Hd(this.relativeTarget,this.relativeTargetOrigin,f,P),b&&Ed(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=H()),ot(b,this.relativeTarget)),v&&(this.animationValues=u,Pd(u,c,this.latestValues,P,T,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Dt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=$.update(()=>{Ke.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=ne(0)),this.currentAnimation=bd(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(Nd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:c,latestValues:u}=o;if(!(!a||!l||!c)){if(this!==o&&this.layout&&c&&_r(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||H();const d=et(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=et(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}ot(a,l),Jt(a,u),ye(this.projectionDeltaWithTransform,this.layoutCorrected,a,u)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new kd),this.sharedNodes.get(o).add(a);const c=a.options.initialPromotionConfig;a.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.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 c=this.getStack();c&&c.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 c={};l.z&&Sn("z",o,c,this.animationValues);for(let u=0;u<Tn.length;u++)Sn(`rotate${Tn[u]}`,o,c,this.animationValues),Sn(`skew${Tn[u]}`,o,c,this.animationValues);o.render();for(const u in c)o.setStaticValue(u,c[u]),this.animationValues&&(this.animationValues[u]=c[u]);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=We(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=We(a?.pointerEvents)||""),this.hasProjected&&!zt(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let d=Rd(this.projectionDeltaWithTransform,this.treeScale,u);l&&(d=l(u,d)),o.transform=d;const{x:f,y:g}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,c.animationValues?o.opacity=c===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:o.opacity=c===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const y in Se){if(u[y]===void 0)continue;const{correct:v,applyTo:w,isCSSVariable:x}=Se[y],T=d==="none"?u[y]:v(u[y],c);if(w){const b=w.length;for(let j=0;j<b;j++)o[w[j]]=T}else x?this.options.visualElement.renderState.vars[y]=T:o[y]=T}this.options.layoutId&&(o.pointerEvents=c===this?We(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(Ji),this.root.sharedNodes.clear()}}}function Ld(t){t.updateLayout()}function Od(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"?rt(u=>{const d=r?e.measuredBox[u]:e.layoutBox[u],f=et(d);d.min=n[u].min,d.max=d.min+f}):_r(i,e.layoutBox,n)&&rt(u=>{const d=r?e.measuredBox[u]:e.layoutBox[u],f=et(n[u]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[u].max=t.relativeTarget[u].min+f)});const o=Qt();ye(o,n,e.layoutBox);const a=Qt();r?ye(a,t.applyTransform(s,!0),e.measuredBox):ye(a,n,e.layoutBox);const l=!$r(o);let c=!1;if(!t.resumeFrom){const u=t.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:d,layout:f}=u;if(d&&f){const g=H();xe(g,e.layoutBox,d.layoutBox);const y=H();xe(y,n,f.layoutBox),zr(g,y)||(c=!0),u.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=g,t.relativeParent=u)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Fd(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 Bd(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function $d(t){t.clearSnapshot()}function Ji(t){t.clearMeasurements()}function Qi(t){t.isLayoutDirty=!1}function zd(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function to(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Ud(t){t.resolveTargetDelta()}function Wd(t){t.calcProjection()}function _d(t){t.resetSkewAndRotation()}function Kd(t){t.removeLeadSnapshot()}function eo(t,e,n){t.translate=U(e.translate,0,n),t.scale=U(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function no(t,e,n,s){t.min=U(e.min,n.min,s),t.max=U(e.max,n.max,s)}function Hd(t,e,n,s){no(t.x,e.x,n.x,s),no(t.y,e.y,n.y,s)}function Xd(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Yd={duration:.45,ease:[.4,0,.1,1]},so=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),io=so("applewebkit/")&&!so("chrome/")?Math.round:lt;function oo(t){t.min=io(t.min),t.max=io(t.max)}function Gd(t){oo(t.x),oo(t.y)}function _r(t,e,n){return t==="position"||t==="preserve-aspect"&&!ed(qi(e),qi(n),.2)}function qd(t){return t!==t.root&&t.scroll?.wasRoot}const Zd=Wr({attachResizeListener:(t,e)=>Ce(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Cn={current:void 0},Kr=Wr({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Cn.current){const t=new Zd({});t.mount(window),t.setOptions({layoutScroll:!0}),Cn.current=t}return Cn.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Jd={pan:{Feature:gd},drag:{Feature:pd,ProjectionNode:Kr,MeasureLayout:Or}};function ro(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&&$.postRender(()=>r(e,je(e)))}class Qd extends Et{mount(){const{current:e}=this.node;e&&(this.unmount=wc(e,(n,s)=>(ro(this.node,s,"Start"),i=>ro(this.node,i,"End"))))}unmount(){}}class th extends Et{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=Pe(Ce(this.node.current,"focus",()=>this.onFocus()),Ce(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function ao(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&&$.postRender(()=>r(e,je(e)))}class eh extends Et{mount(){const{current:e}=this.node;e&&(this.unmount=Pc(e,(n,s)=>(ao(this.node,s,"Start"),(i,{success:r})=>ao(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Yn=new WeakMap,Pn=new WeakMap,nh=t=>{const e=Yn.get(t.target);e&&e(t)},sh=t=>{t.forEach(nh)};function ih({root:t,...e}){const n=t||document;Pn.has(n)||Pn.set(n,{});const s=Pn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(sh,{root:t,...e})),s[i]}function oh(t,e,n){const s=ih(e);return Yn.set(t,n),s.observe(t),()=>{Yn.delete(t),s.unobserve(t)}}const rh={some:0,all:1};class ah extends Et{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:rh[i]},a=l=>{const{isIntersecting:c}=l;if(this.isInView===c||(this.isInView=c,r&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:u,onViewportLeave:d}=this.node.getProps(),f=c?u:d;f&&f(l)};return oh(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(lh(e,n))&&this.startObserver()}unmount(){}}function lh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Hr={inView:{Feature:ah},tap:{Feature:eh},focus:{Feature:th},hover:{Feature:Qd}},ch={layout:{ProjectionNode:Kr,MeasureLayout:Or}},uh={...Er,...Hr,...Jd,...ch},dh=fu(uh,Pr),hh={renderer:Pr,...Er,...Hr};function Xr(t,e){return _e(t,e)}const $e=Xr("div"),fh=Xr("p");function mh(t){const e=t.name||"unnamed",n=ph(t),{schema:s,def:i}=gh(t);return{name:e,description:n,parameters:s,parametersDef:i}}function ph(t){const n=t.toString().match(/\/\*\*\s*\n([^*]|\*[^/])*\*\//);if(n){const i=n[0].match(/\/\*\*\s*\n\s*\*\s*([^\n@]+)/);if(i&&i[1])return i[1].trim()}return`Execute ${t.name||"function"}`}function gh(t){const n=t.toString().match(/\(([^)]*)\)/);if(!n||!n[1]||!n[1].trim())return{schema:Mt.z.object({}),def:{}};const i=n[1].split(",").map(a=>a.trim()),r={},o={};for(const a of i){const l=a.match(/(\w+)\s*:\s*(\w+)/);if(l&&l[1]&&l[2]){const c=l[1];switch(l[2].toLowerCase()){case"string":r[c]=Mt.z.string().describe(c),o[c]={type:"string",description:c};break;case"number":r[c]=Mt.z.number().describe(c),o[c]={type:"number",description:c};break;case"boolean":r[c]=Mt.z.boolean().describe(c),o[c]={type:"boolean",description:c};break;case"any":r[c]=Mt.z.any().describe(c),o[c]={type:"any",description:c};break;default:r[c]=Mt.z.string().describe(c),o[c]={type:"string",description:c}}}else{const c=a.match(/(\w+)/);if(c&&c[1]){const u=c[1];r[u]=Mt.z.string().describe(u),o[u]={type:"string",description:u}}}}return{schema:Mt.z.object(r),def:o}}function Yr(t){return t.map(mh)}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(yt,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(G.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(yt,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(G.X,{className:"h-3 w-3"})})]})]})})}function xh({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,r]=m.useState(!1),o=Object.keys(e).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>o&&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"} ${o?"cursor-pointer hover:bg-opacity-80":""}`,children:[o&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(G.ChevronDown,{className:"h-3 w-3"}):h.jsx(G.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(G.X,{className:"h-3 w-3"}):s?h.jsx(G.Zap,{className:"h-3 w-3"}):h.jsx(G.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&o&&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(e).map(([a,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[a,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},a))})})]})}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}))),ks=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Th,{className:mt("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ks.displayName="Response";const Sh=Object.freeze(Object.defineProperty({__proto__:null,Response:ks},Symbol.toStringTag,{value:"Module"})),Ch=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const r=dh.create(e),o=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(r,{animate:{backgroundPosition:"0% center"},className:mt("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})},Ph=m.memo(Ch),Gr=m.createContext(null),Ah=()=>{const t=m.useContext(Gr);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,c]=Ks.useControllableState({prop:n,defaultProp:s,onChange:i}),[u,d]=Ks.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(()=>{c(!1),g(!0)},Mh);return()=>clearTimeout(x)}},[e,l,s,c,f]);const w=x=>{c(x)};return h.jsx(Gr.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:c,duration:u},children:h.jsx(vh,{className:mt("not-prose mb-4",t),onOpenChange:w,open:l,...a,children:o})})}),Dh=(t,e)=>t||e===0?h.jsx(Ph,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Zr=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:r}=Ah();return h.jsx(bh,{className:mt("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(G.BrainIcon,{className:"size-4"}),Dh(s,r),h.jsx(G.ChevronDownIcon,{className:mt("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Jr=m.memo(({className:t,children:e,...n})=>h.jsx(wh,{className:mt("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(ks,{className:"grid gap-2",children:e})}));qr.displayName="Reasoning";Zr.displayName="ReasoningTrigger";Jr.displayName="ReasoningContent";function Vh({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:c=!1,tools:u=[],safeTools:d=[],systemPrompt:f="",tokenEndpoint:g="/api/arcten/token",apiBaseUrl:y="https://api.arcten.com",user:v}){const[w,x]=m.useState(null),T=m.useRef(null),[b,j]=m.useState(null),[P,V]=m.useState(null),D=m.useRef(null),[A,I]=m.useState(c),[L,Q]=m.useState(o),[ct,Ht]=m.useState(600),[St,pt]=m.useState(!1),[O,R]=m.useState(!1),[B,Z]=m.useState(!1),[W,kt]=m.useState({x:100,y:100}),[Rt,Nt]=m.useState(!1),[le,De]=m.useState({x:0,y:0}),[nn,Ve]=m.useState(!1),ce=m.useRef(null),E=m.useRef(null),[k,_]=m.useState(""),[nt,tt]=m.useState(null),[ut,Qr]=m.useState("Thinking..."),[sn,on]=m.useState(new Set),[ta,ea]=m.useState(""),[It,na]=m.useState([]),[rn,Rs]=m.useState(!1),[an,Ns]=m.useState([]),[Is,ln]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Xt,Ee]=m.useState(!1),[kh,ke]=m.useState(!1),[Rh,Re]=m.useState([]),Lt=m.useMemo(()=>[...u,...d],[u,d]),Ls=m.useMemo(()=>Yr(Lt),[Lt]),Os=m.useMemo(()=>{const p=new Map;return Lt.forEach(S=>p.set(S.name,S)),p},[Lt]),Fs=m.useMemo(()=>new Set(d.map(p=>p.name)),[d]),Bs=["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&&I(JSON.parse(p));const S=localStorage.getItem("arcten-sidebar-width");S&&Q(parseInt(S));const N=localStorage.getItem("arcten-sidebar-height");N&&Ht(parseInt(N));const F=localStorage.getItem("arcten-sidebar-detached");F&&R(JSON.parse(F));const Y=localStorage.getItem("arcten-sidebar-position");if(Y){const it=JSON.parse(Y),K=50,Ct=Math.max(K-o,Math.min(it.x,window.innerWidth-K)),Pt=Math.max(0,Math.min(it.y,window.innerHeight-K));kt({x:Ct,y:Pt})}const C=localStorage.getItem("arcten-sidebar-minimized");C&&Z(JSON.parse(C)),Ve(!0)}},[]),m.useEffect(()=>((async()=>{try{const S=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:v})});if(!S.ok)throw new Error("Failed to fetch token");const N=await S.json();x(N.clientToken),T.current=N.clientToken,V(N.expiresAt),j(null)}catch(S){j(S instanceof Error?S.message:"Failed to fetch token")}})(),()=>{D.current&&clearTimeout(D.current)}),[g,v]),m.useEffect(()=>{if(!P)return;D.current&&clearTimeout(D.current);const p=Math.floor(Date.now()/1e3),S=P-p,F=Math.max(0,S-5);return console.log(`Token expires at ${new Date(P*1e3).toISOString()}`),console.log(`Scheduling token refresh in ${F} seconds`),D.current=setTimeout(async()=>{console.log("Refreshing token...");try{const Y=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:v})});if(!Y.ok)throw new Error("Failed to refresh token");const C=await Y.json();x(C.clientToken),T.current=C.clientToken,V(C.expiresAt),j(null),console.log("Token refreshed successfully")}catch(Y){console.error("Token refresh failed:",Y),j(Y instanceof Error?Y.message:"Failed to refresh token")}},F*1e3),()=>{D.current&&clearTimeout(D.current)}},[P,g,v]),m.useEffect(()=>{(async()=>{if(Lt.length!==0)try{const S=Lt.map(F=>({name:F.name,code:F.toString()})),N=await fetch(`${y}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:S})});if(N.ok){const F=await N.json();na(F.tools)}}catch(S){console.error("Failed to fetch tool descriptions:",S)}})()},[Lt]),m.useEffect(()=>{Promise.resolve().then(()=>Sh).then(p=>{tt(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{ea(window.location.pathname)};p(),window.addEventListener("popstate",p);const S=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(S)}},[]);async function $s(){if(!(!v?.id||!w)){ke(!0);try{const S=await(await fetch(`${y}/conversations`,{headers:{Authorization:`Bearer ${w}`}})).json();Ns(S.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{ke(!1)}}}m.useEffect(()=>{v?.id&&w&&$s()},[v,w]);function sa(p){const S=Math.floor((Date.now()-p)/1e3);return S<60?"now":S<3600?`${Math.floor(S/60)}m`:S<86400?`${Math.floor(S/3600)}h`:`${Math.floor(S/86400)}d`}function ia(){const p=crypto.randomUUID();ln(p),Ie([]),Re([]),Ee(!1)}async function oa(p){if(w)try{await fetch(`${y}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${w}`}}),Ns(an.filter(S=>S._id!==p)),p===Is&&ia()}catch(S){console.error("Failed to delete conversation:",S)}}async function ra(p){ln(p.chatId),Ee(!1),ke(!0);try{const S=await fetch(`${y}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${T.current}`}});if(!S.ok)throw new Error(`Failed to fetch messages: ${S.statusText}`);const F=(await S.json()).messages||[];Ie(F),Re(F)}catch(S){console.error("Failed to load conversation messages:",S);const N=p.messages||[];Ie(N),Re(N)}finally{ke(!1)}}const aa=(async(p,S={})=>{const N=S.headers?new Headers(S.headers):new Headers;return N.delete("user-agent"),N.delete("User-Agent"),fetch(p,{...S,headers:N})}),{messages:ue,sendMessage:la,status:gt,error:zs,stop:Ne,addToolResult:de,setMessages:Ie}=lo.useChat({id:Is||void 0,transport:new He.DefaultChatTransport({api:`${y}/chat`,fetch:aa,headers:()=>{const p={};return T.current&&(p.Authorization=`Bearer ${T.current}`),p},body:()=>({tools:Ls.map(p=>({name:p.name,description:p.description,parameters:p.parametersDef})),systemPrompt:f,currentRoute:ta})}),sendAutomaticallyWhen:He.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{A&&E.current&&E.current.focus()},[A,ue]);function ca(){I(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function ua(){I(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[A]),m.useEffect(()=>{ce.current&&ce.current.scrollIntoView({behavior:"smooth"})},[ue]),m.useEffect(()=>{function p(S){S.key==="Escape"&&(gt==="streaming"||gt==="submitted")&&(S.preventDefault(),Ne())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[gt,Ne]);function da(){const p=crypto.randomUUID();ln(p),Ie([]),Re([]),Ee(!1)}function Us(p){if(p.preventDefault(),!k.trim())return;(gt==="streaming"||gt==="submitted")&&Ne();const S=Bs[Math.floor(Math.random()*Bs.length)]||"Thinking...";Qr(S),la({text:k}),_("")}function ha(p){const S=p.target.value;_(S)}m.useEffect(()=>{if(!St)return;function p(N){if(O){const F=N.clientX-W.x,Y=N.clientY-W.y;F>=a&&F<=l&&Q(F),Y>=400&&Y<=1e3&&Ht(Y)}else{const F=window.innerWidth-N.clientX;F>=a&&F<=l&&Q(F)}}function S(){pt(!1),localStorage.setItem("arcten-sidebar-width",L.toString()),localStorage.setItem("arcten-sidebar-height",ct.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",S)}},[St,L,ct,O,W,a,l]);function fa(p){p.preventDefault(),pt(!0)}function ma(){R(!0),Z(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function pa(){R(!1),Z(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ws(){Z(!B),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!B))}function ga(p){O&&(Nt(!0),De({x:p.clientX-W.x,y:p.clientY-W.y}))}return m.useEffect(()=>{if(!O)return;function p(){kt(S=>{const F=window.innerWidth-50,Y=window.innerHeight-50,C=50-L,it=0,K=Math.max(C,Math.min(S.x,F)),Ct=Math.max(it,Math.min(S.y,Y));if(K!==S.x||Ct!==S.y){const Pt={x:K,y:Ct};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(Pt)),Pt}return S})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[O,L]),m.useEffect(()=>{if(!Rt)return;function p(N){const F=N.clientX-le.x,Y=N.clientY-le.y,C=50,it=window.innerWidth-C,K=window.innerHeight-C,Ct=C-L,Pt=0,cn=Math.max(Ct,Math.min(F,it)),dt=Math.max(Pt,Math.min(Y,K));kt({x:cn,y:dt})}function S(){Nt(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(W))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",S)}},[Rt,le,W,L]),nn?b?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: ",b]})}):w?h.jsx(Lc,{features:hh,children:h.jsx($e,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:O?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:O?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
10
- ${O?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
9
+ `),()=>{w.contains(x)&&w.removeChild(x)}},[e]),h.jsx(Dc,{isPresent:e,childRef:r,sizeRef:o,children:yt.cloneElement(t,{ref:l})})}const Ec=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,root:l})=>{const c=Zn(kc),u=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:u,initial:e,isPresent:n,custom:i,onExitComplete:p=>{c.set(p,!0);for(const y of c.values())if(!y)return;s&&s()},register:p=>(c.set(p,!1),()=>c.delete(p))}),[n,c,s]);return r&&d&&(f={...f}),m.useMemo(()=>{c.forEach((p,y)=>c.set(y,!1))},[n]),yt.useEffect(()=>{!n&&!c.size&&s&&s()},[n]),o==="popLayout"&&(t=h.jsx(Vc,{isPresent:n,anchorX:a,root:l,children:t})),h.jsx(Ze.Provider,{value:f,children:t})};function kc(){return new Map}function sr(t=!0){const e=m.useContext(Ze);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 Oe=t=>t.key||"";function mi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Rc=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",root:l})=>{const[c,u]=sr(o),d=m.useMemo(()=>mi(t),[t]),f=o&&!c?[]:d.map(Oe),p=m.useRef(!0),y=m.useRef(d),x=Zn(()=>new Map),[w,v]=m.useState(d),[b,T]=m.useState(d);ho(()=>{p.current=!1,y.current=d;for(let E=0;E<b.length;E++){const D=Oe(b[E]);f.includes(D)?x.delete(D):x.get(D)!==!0&&x.set(D,!1)}},[b,f.length,f.join("-")]);const M=[];if(d!==w){let E=[...d];for(let D=0;D<b.length;D++){const A=b[D],F=Oe(A);f.includes(F)||(E.splice(D,0,A),M.push(A))}return r==="wait"&&M.length&&(E=M),T(mi(E)),v(d),null}process.env.NODE_ENV!=="production"&&r==="wait"&&b.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:P}=m.useContext(qn);return h.jsx(h.Fragment,{children:b.map(E=>{const D=Oe(E),A=o&&!c?!1:d===b||f.includes(D),F=()=>{if(x.has(D))x.set(D,!0);else return;let N=!0;x.forEach(J=>{J||(N=!1)}),N&&(P?.(),T(y.current),o&&u?.(),s&&s())};return h.jsx(Ec,{isPresent:A,initial:!p.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:r,root:l,onExitComplete:A?void 0:F,anchorX:a,children:E},D)})})},ws=m.createContext({strict:!1}),pi={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},oe={};for(const t in pi)oe[t]={isEnabled:e=>pi[t].some(n=>!!e[n])};function Bn(t){for(const e in t)oe[e]={...oe[e],...t[e]}}function Nc({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!gn(e)),i=m.useRef(void 0);if(!gn(e)){const{renderer:r,...o}=e;i.current=r,Bn(o)}return m.useEffect(()=>{gn(e)&&e().then(({renderer:r,...o})=>{Bn(o),i.current=r,s(!0)})},[]),h.jsx(ws.Provider,{value:{renderer:i.current,strict:n},children:t})}function gn(t){return typeof t=="function"}const Ic=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 Ge(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Ic.has(t)}let ir=t=>!Ge(t);function Lc(t){typeof t=="function"&&(ir=e=>e.startsWith("on")?!Ge(e):t(e))}try{Lc(require("@emotion/is-prop-valid").default)}catch{}function Oc(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(ir(i)||n===!0&&Ge(i)||!e&&!Ge(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const Je=m.createContext({});function Qe(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function we(t){return typeof t=="string"||Array.isArray(t)}const Ts=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Ss=["initial",...Ts];function tn(t){return Qe(t.animate)||Ss.some(e=>we(t[e]))}function or(t){return!!(tn(t)||t.variants)}function Fc(t,e){if(tn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||we(n)?n:void 0,animate:we(s)?s:void 0}}return t.inherit!==!1?e:{}}function Bc(t){const{initial:e,animate:n}=Fc(t,m.useContext(Je));return m.useMemo(()=>({initial:e,animate:n}),[gi(e),gi(n)])}function gi(t){return Array.isArray(t)?t.join(" "):t}const Te={};function $c(t){for(const e in t)Te[e]=t[e],rs(e)&&(Te[e].isCSSVariable=!0)}function rr(t,{layout:e,layoutId:n}){return ce.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Te[t]||t==="opacity")}const zc={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Uc=le.length;function Wc(t,e,n){let s="",i=!0;for(let r=0;r<Uc;r++){const o=le[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 c=Zo(a,ys[o]);if(!l){i=!1;const u=zc[o]||o;s+=`${u}(${c}) `}n&&(e[o]=c)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function Cs(t,e,n){const{style:s,vars:i,transformOrigin:r}=t;let o=!1,a=!1;for(const l in e){const c=e[l];if(ce.has(l)){o=!0;continue}else if(rs(l)){i[l]=c;continue}else{const u=Zo(c,ys[l]);l.startsWith("origin")?(a=!0,r[l]=u):s[l]=u}}if(e.transform||(o||n?s.transform=Wc(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:c="50%",originZ:u=0}=r;s.transformOrigin=`${l} ${c} ${u}`}}const Ps=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ar(t,e,n){for(const s in e)!Z(e[s])&&!rr(s,n)&&(t[s]=e[s])}function _c({transformTemplate:t},e){return m.useMemo(()=>{const n=Ps();return Cs(n,e,t),Object.assign({},n.vars,n.style)},[e])}function Kc(t,e){const n=t.style||{},s={};return ar(s,n,t),Object.assign(s,_c(t,e)),s}function Hc(t,e){const n={},s=Kc(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 Xc={offset:"stroke-dashoffset",array:"stroke-dasharray"},Yc={offset:"strokeDashoffset",array:"strokeDasharray"};function Gc(t,e,n=1,s=0,i=!0){t.pathLength=1;const r=i?Xc:Yc;t[r.offset]=j.transform(-s);const o=j.transform(e),a=j.transform(n);t[r.array]=`${o} ${a}`}function lr(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,c,u){if(Cs(t,a,c),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=u?.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&&Gc(d,i,r,o,!1)}const cr=()=>({...Ps(),attrs:{}}),ur=t=>typeof t=="string"&&t.toLowerCase()==="svg";function qc(t,e,n,s){const i=m.useMemo(()=>{const r=cr();return lr(r,e,ur(s),t.transformTemplate,t.style),{...r.attrs,style:{...r.style}}},[e]);if(t.style){const r={};ar(r,t.style,t),i.style={...r,...i.style}}return i}const Zc=["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 As(t){return typeof t!="string"||t.includes("-")?!1:!!(Zc.indexOf(t)>-1||/[A-Z]/u.test(t))}function Jc(t,e,n,{latestValues:s},i,r=!1){const a=(As(t)?qc:Hc)(e,s,i,t),l=Oc(e,typeof t=="string",r),c=t!==m.Fragment?{...l,...a,ref:n}:{},{children:u}=e,d=m.useMemo(()=>Z(u)?u.get():u,[u]);return m.createElement(t,{...c,children:d})}function yi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function Ms(t,e,n,s){if(typeof e=="function"){const[i,r]=yi(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]=yi(s);e=e(n!==void 0?n:t.custom,i,r)}return e}function Ue(t){return Z(t)?t.get():t}function Qc({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:tu(n,s,i,t),renderState:e()}}function tu(t,e,n,s){const i={},r=s(t,{});for(const f in r)i[f]=Ue(r[f]);let{initial:o,animate:a}=t;const l=tn(t),c=or(t);e&&c&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let u=n?n.initial===!1:!1;u=u||o===!1;const d=u?a:o;if(d&&typeof d!="boolean"&&!Qe(d)){const f=Array.isArray(d)?d:[d];for(let p=0;p<f.length;p++){const y=Ms(t,f[p]);if(y){const{transitionEnd:x,transition:w,...v}=y;for(const b in v){let T=v[b];if(Array.isArray(T)){const M=u?T.length-1:0;T=T[M]}T!==null&&(i[b]=T)}for(const b in x)i[b]=x[b]}}}return i}const dr=t=>(e,n)=>{const s=m.useContext(Je),i=m.useContext(Ze),r=()=>Qc(t,e,s,i);return n?r():Zn(r)};function js(t,e,n){const{style:s}=t,i={};for(const r in s)(Z(s[r])||e.style&&Z(e.style[r])||rr(r,t)||n?.getValue(r)?.liveStyle!==void 0)&&(i[r]=s[r]);return i}const eu=dr({scrapeMotionValuesFromProps:js,createRenderState:Ps});function hr(t,e,n){const s=js(t,e,n);for(const i in t)if(Z(t[i])||Z(e[i])){const r=le.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=t[i]}return s}const nu=dr({scrapeMotionValuesFromProps:hr,createRenderState:cr}),su=Symbol.for("motionComponentSymbol");function Jt(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function iu(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):Jt(n)&&(n.current=s))},[e])}const Ds=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),ou="framerAppearId",fr="data-"+Ds(ou),mr=m.createContext({});function ru(t,e,n,s,i){const{visualElement:r}=m.useContext(Je),o=m.useContext(ws),a=m.useContext(Ze),l=m.useContext(bs).reducedMotion,c=m.useRef(null);s=s||o.renderer,!c.current&&s&&(c.current=s(t,{visualState:e,parent:r,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const u=c.current,d=m.useContext(mr);u&&!u.projection&&i&&(u.type==="html"||u.type==="svg")&&au(c.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{u&&f.current&&u.update(n,a)});const p=n[fr],y=m.useRef(!!p&&!window.MotionHandoffIsComplete?.(p)&&window.MotionHasOptimisedAnimation?.(p));return ho(()=>{u&&(f.current=!0,window.MotionIsMounted=!0,u.updateFeatures(),u.scheduleRenderMicrotask(),y.current&&u.animationState&&u.animationState.animateChanges())}),m.useEffect(()=>{u&&(!y.current&&u.animationState&&u.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(p)}),y.current=!1),u.enteringChildren=void 0)}),u}function au(t,e,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:c,layoutCrossfade:u}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:pr(t.parent)),t.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&Jt(a),visualElement:t,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:u,layoutScroll:l,layoutRoot:c})}function pr(t){if(t)return t.options.allowProjection!==!1?t.projection:pr(t.parent)}function We(t,{forwardMotionProps:e=!1}={},n,s){n&&Bn(n);const i=As(t)?nu:eu;function r(a,l){let c;const u={...m.useContext(bs),...a,layoutId:lu(a)},{isStatic:d}=u,f=Bc(a),p=i(a,d);if(!d&&Jn){cu(u,n);const y=uu(u);c=y.MeasureLayout,f.visualElement=ru(t,p,u,s,y.ProjectionNode)}return h.jsxs(Je.Provider,{value:f,children:[c&&f.visualElement?h.jsx(c,{visualElement:f.visualElement,...u}):null,Jc(t,a,iu(p,f.visualElement,l),p,d,e)]})}r.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const o=m.forwardRef(r);return o[su]=t,o}function lu({layoutId:t}){const e=m.useContext(qn).id;return e&&t!==void 0?e+"-"+t:t}function cu(t,e){const n=m.useContext(ws).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?re(!1,s,"lazy-strict-mode"):St(!1,s,"lazy-strict-mode")}}function uu(t){const{drag:e,layout:n}=oe;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function du(t,e){if(typeof Proxy>"u")return We;const n=new Map,s=(r,o)=>We(r,o,t,e),i=(r,o)=>(process.env.NODE_ENV!=="production"&&ss(!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,We(o,void 0,t,e)),n.get(o))})}function gr({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function hu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function fu(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 yn(t){return t===void 0||t===1}function $n({scale:t,scaleX:e,scaleY:n}){return!yn(t)||!yn(e)||!yn(n)}function Ut(t){return $n(t)||yr(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function yr(t){return xi(t.x)||xi(t.y)}function xi(t){return t&&t!=="0%"}function qe(t,e,n){const s=t-n,i=e*s;return n+i}function vi(t,e,n,s,i){return i!==void 0&&(t=qe(t,i,s)),qe(t,n,s)+e}function zn(t,e=0,n=1,s,i){t.min=vi(t.min,e,n,s,i),t.max=vi(t.max,e,n,s,i)}function xr(t,{x:e,y:n}){zn(t.x,e.translate,e.scale,e.originPoint),zn(t.y,n.translate,n.scale,n.originPoint)}const bi=.999999999999,wi=1.0000000000001;function mu(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&&te(t,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,xr(t,o)),s&&Ut(r.latestValues)&&te(t,r.latestValues))}e.x<wi&&e.x>bi&&(e.x=1),e.y<wi&&e.y>bi&&(e.y=1)}function Qt(t,e){t.min=t.min+e,t.max=t.max+e}function Ti(t,e,n,s,i=.5){const r=W(t.min,t.max,i);zn(t,e,n,r,s)}function te(t,e){Ti(t.x,e.x,e.scaleX,e.scale,e.originX),Ti(t.y,e.y,e.scaleY,e.scale,e.originY)}function vr(t,e){return gr(fu(t.getBoundingClientRect(),e))}function pu(t,e,n){const s=vr(t,n),{scroll:i}=e;return i&&(Qt(s.x,i.offset.x),Qt(s.y,i.offset.y)),s}const Si=()=>({translate:0,scale:1,origin:0,originPoint:0}),ee=()=>({x:Si(),y:Si()}),Ci=()=>({min:0,max:0}),H=()=>({x:Ci(),y:Ci()}),Un={current:null},br={current:!1};function gu(){if(br.current=!0,!!Jn)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Un.current=t.matches;t.addEventListener("change",e),e()}else Un.current=!1}const yu=new WeakMap;function xu(t,e,n){for(const s in e){const i=e[s],r=n[s];if(Z(i))t.addValue(s,i);else if(Z(r))t.addValue(s,ie(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,ie(o!==void 0?o:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Pi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class vu{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=ps,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=nt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,B.render(this.render,!1,!0))};const{latestValues:l,renderState:c}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=c,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=tn(n),this.isVariantNode=or(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:u,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const p=d[f];l[f]!==void 0&&Z(p)&&p.set(l[f])}}mount(e){this.current=e,yu.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)),br.current||gu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Un.current,process.env.NODE_ENV!=="production"&&ss(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=ce.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 oe){const n=oe[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):H()}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<Pi.length;s++){const i=Pi[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=xu(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=ie(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"&&(fo(s)||po(s))?s=parseFloat(s):!Ac(s)&&Et.test(n)&&(s=qo(e,n)),this.setBaseTarget(e,Z(s)?s.get():s)),Z(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=Ms(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&&!Z(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 ns),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){xs.render(this.render)}}class wr extends vu{constructor(){super(...arguments),this.KeyframeResolver=mc}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;Z(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Tr(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 bu(t){return window.getComputedStyle(t)}class wu extends wr{constructor(){super(...arguments),this.type="html",this.renderInstance=Tr}readValueFromInstance(e,n){if(ce.has(n))return this.projection?.isProjecting?kn(n):kl(e,n);{const s=bu(e),i=(rs(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return vr(e,n)}build(e,n,s){Cs(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return js(e,n,s)}}const Sr=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 Tu(t,e,n,s){Tr(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Sr.has(i)?i:Ds(i),e.attrs[i])}class Su extends wr{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=H}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(ce.has(n)){const s=Go(n);return s&&s.default||0}return n=Sr.has(n)?n:Ds(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return hr(e,n,s)}build(e,n,s){lr(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Tu(e,n,s,i)}mount(e){this.isSVGTag=ur(e.tagName),super.mount(e)}}const Cr=(t,e)=>As(t)?new Su(e):new wu(e,{allowProjection:t!==m.Fragment});function se(t,e,n){const s=t.getProps();return Ms(s,e,n!==void 0?n:s.custom,t)}const Wn=t=>Array.isArray(t);function Cu(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,ie(n))}function Pu(t){return Wn(t)?t[t.length-1]||0:t}function Au(t,e){const n=se(t,e);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=Pu(r[o]);Cu(t,o,a)}}function Mu(t){return!!(Z(t)&&t.add)}function _n(t,e){const n=t.getValue("willChange");if(Mu(n))return n.add(e);if(!n&&Ct.WillChange){const s=new Ct.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Pr(t){return t.props[fr]}const ju=t=>t!==null;function Du(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(ju),r=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[r]}const Vu={type:"spring",stiffness:500,damping:25,restSpeed:10},Eu=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),ku={type:"keyframes",duration:.8},Ru={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Nu=(t,{keyframes:e})=>e.length>2?ku:ce.has(t)?t.startsWith("scale")?Eu(e[1]):Vu:Ru;function Iu({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:c,...u}){return!!Object.keys(u).length}const Vs=(t,e,n,s={},i,r)=>o=>{const a=gs(s,t)||{},l=a.delay||s.delay||0;let{elapsed:c=0}=s;c=c-ut(l);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-c,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};Iu(a)||Object.assign(u,Nu(t,u)),u.duration&&(u.duration=ut(u.duration)),u.repeatDelay&&(u.repeatDelay=ut(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(On(u),u.delay===0&&(d=!0)),(Ct.instantAnimations||Ct.skipAnimations)&&(d=!0,On(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,d&&!r&&e.get()!==void 0){const f=Du(u.keyframes,a);if(f!==void 0){B.update(()=>{u.onUpdate(f),u.onComplete()});return}}return a.isSync?new ms(u):new ec(u)};function Lu({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Ar(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r=t.getDefaultTransition(),transitionEnd:o,...a}=e;s&&(r=s);const l=[],c=i&&t.animationState&&t.animationState.getState()[i];for(const u in a){const d=t.getValue(u,t.latestValues[u]??null),f=a[u];if(f===void 0||c&&Lu(c,u))continue;const p={delay:n,...gs(r||{},u)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!p.velocity)continue;let x=!1;if(window.MotionHandoffAnimation){const v=Pr(t);if(v){const b=window.MotionHandoffAnimation(v,u,B);b!==null&&(p.startTime=b,x=!0)}}_n(t,u),d.start(Vs(u,d,f,t.shouldReduceMotion&&Ho.has(u)?{type:!1}:p,t,x));const w=d.animation;w&&l.push(w)}return o&&Promise.all(l).then(()=>{B.update(()=>{o&&Au(t,o)})}),l}function Mr(t,e,n,s=0,i=1){const r=Array.from(t).sort((c,u)=>c.sortNodePosition(u)).indexOf(e),o=t.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}function Kn(t,e,n={}){const s=se(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(Ar(t,s,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:c=0,staggerChildren:u,staggerDirection:d}=i;return Ou(t,e,l,c,u,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,c]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>c())}else return Promise.all([r(),o(n.delay)])}function Ou(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(Kn(l,e,{...o,delay:n+(typeof s=="function"?0:s)+Mr(t.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function Fu(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(r=>Kn(t,r,n));s=Promise.all(i)}else if(typeof e=="string")s=Kn(t,e,n);else{const i=typeof e=="function"?se(t,e,n.custom):e;s=Promise.all(Ar(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function jr(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 Bu=Ss.length;function Dr(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Dr(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Bu;n++){const s=Ss[n],i=t.props[s];(we(i)||i===!1)&&(e[s]=i)}return e}const $u=[...Ts].reverse(),zu=Ts.length;function Uu(t){return e=>Promise.all(e.map(({animation:n,options:s})=>Fu(t,n,s)))}function Wu(t){let e=Uu(t),n=Ai(),s=!0;const i=l=>(c,u)=>{const d=se(t,u,l==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:p,...y}=d;c={...c,...y,...p}}return c};function r(l){e=l(t)}function o(l){const{props:c}=t,u=Dr(t.parent)||{},d=[],f=new Set;let p={},y=1/0;for(let w=0;w<zu;w++){const v=$u[w],b=n[v],T=c[v]!==void 0?c[v]:u[v],M=we(T),P=v===l?b.isActive:null;P===!1&&(y=w);let E=T===u[v]&&T!==c[v]&&M;if(E&&s&&t.manuallyAnimateOnMount&&(E=!1),b.protectedKeys={...p},!b.isActive&&P===null||!T&&!b.prevProp||Qe(T)||typeof T=="boolean")continue;const D=_u(b.prevProp,T);let A=D||v===l&&b.isActive&&!E&&M||w>y&&M,F=!1;const N=Array.isArray(T)?T:[T];let J=N.reduce(i(v),{});P===!1&&(J={});const{prevResolvedValues:vt={}}=b,bt={...vt,...J},Rt=$=>{A=!0,f.has($)&&(F=!0,f.delete($)),b.needsAnimating[$]=!0;const R=t.getValue($);R&&(R.liveStyle=!1)};for(const $ in bt){const R=J[$],et=vt[$];if(p.hasOwnProperty($))continue;let _=!1;Wn(R)&&Wn(et)?_=!jr(R,et):_=R!==et,_?R!=null?Rt($):f.add($):R!==void 0&&f.has($)?Rt($):b.protectedKeys[$]=!0}b.prevProp=T,b.prevResolvedValues=J,b.isActive&&(p={...p,...J}),s&&t.blockInitialAnimation&&(A=!1);const ht=E&&D;A&&(!ht||F)&&d.push(...N.map($=>{const R={type:v};if(typeof $=="string"&&s&&!ht&&t.manuallyAnimateOnMount&&t.parent){const{parent:et}=t,_=se(et,$);if(et.enteringChildren&&_){const{delayChildren:wt}=_.transition||{};R.delay=Mr(et.enteringChildren,t,wt)}}return{animation:$,options:R}}))}if(f.size){const w={};if(typeof c.initial!="boolean"){const v=se(t,Array.isArray(c.initial)?c.initial[0]:c.initial);v&&v.transition&&(w.transition=v.transition)}f.forEach(v=>{const b=t.getBaseTarget(v),T=t.getValue(v);T&&(T.liveStyle=!0),w[v]=b??null}),d.push({animation:w})}let x=!!d.length;return s&&(c.initial===!1||c.initial===c.animate)&&!t.manuallyAnimateOnMount&&(x=!1),s=!1,x?e(d):Promise.resolve()}function a(l,c){if(n[l].isActive===c)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(l,c)),n[l].isActive=c;const u=o(l);for(const d in n)n[d].protectedKeys={};return u}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Ai()}}}function _u(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!jr(e,t):!1}function zt(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Ai(){return{animate:zt(!0),whileInView:zt(),whileHover:zt(),whileTap:zt(),whileDrag:zt(),whileFocus:zt(),exit:zt()}}class kt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Ku extends kt{constructor(e){super(e),e.animationState||(e.animationState=Wu(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Qe(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 Hu=0;class Xu extends kt{constructor(){super(...arguments),this.id=Hu++}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 Vr={animation:{Feature:Ku},exit:{Feature:Xu}};function Se(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function Me(t){return{point:{x:t.pageX,y:t.pageY}}}const Yu=t=>e=>vs(e)&&t(e,Me(e));function pe(t,e,n,s){return Se(t,e,Yu(n),s)}const Er=1e-4,Gu=1-Er,qu=1+Er,kr=.01,Zu=0-kr,Ju=0+kr;function tt(t){return t.max-t.min}function Qu(t,e,n){return Math.abs(t-e)<=n}function Mi(t,e,n,s=.5){t.origin=s,t.originPoint=W(e.min,e.max,t.origin),t.scale=tt(n)/tt(e),t.translate=W(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Gu&&t.scale<=qu||isNaN(t.scale))&&(t.scale=1),(t.translate>=Zu&&t.translate<=Ju||isNaN(t.translate))&&(t.translate=0)}function ge(t,e,n,s){Mi(t.x,e.x,n.x,s?s.originX:void 0),Mi(t.y,e.y,n.y,s?s.originY:void 0)}function ji(t,e,n){t.min=n.min+e.min,t.max=t.min+tt(e)}function td(t,e,n){ji(t.x,e.x,n.x),ji(t.y,e.y,n.y)}function Di(t,e,n){t.min=e.min-n.min,t.max=t.min+tt(e)}function ye(t,e,n){Di(t.x,e.x,n.x),Di(t.y,e.y,n.y)}function ot(t){return[t("x"),t("y")]}const Rr=({current:t})=>t?t.ownerDocument.defaultView:null,Vi=(t,e)=>Math.abs(t-e);function ed(t,e){const n=Vi(t.x,e.x),s=Vi(t.y,e.y);return Math.sqrt(n**2+s**2)}class Nr{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=vn(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,y=ed(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!y)return;const{point:x}=f,{timestamp:w}=G;this.history.push({...x,timestamp:w});const{onStart:v,onMove:b}=this.handlers;p||(v&&v(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),b&&b(this.lastMoveEvent,f)},this.handlePointerMove=(f,p)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=xn(p,this.transformPagePoint),B.update(this.updatePoint,!0)},this.handlePointerUp=(f,p)=>{this.end();const{onEnd:y,onSessionEnd:x,resumeAnimation:w}=this.handlers;if(this.dragSnapToOrigin&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const v=vn(f.type==="pointercancel"?this.lastMoveEventInfo:xn(p,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,v),x&&x(f,v)},!vs(e))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const a=Me(e),l=xn(a,this.transformPagePoint),{point:c}=l,{timestamp:u}=G;this.history=[{...c,timestamp:u}];const{onSessionStart:d}=n;d&&d(e,vn(l,this.history)),this.removeListeners=Ce(pe(this.contextWindow,"pointermove",this.handlePointerMove),pe(this.contextWindow,"pointerup",this.handlePointerUp),pe(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Vt(this.updatePoint)}}function xn(t,e){return e?{point:e(t.point)}:t}function Ei(t,e){return{x:t.x-e.x,y:t.y-e.y}}function vn({point:t},e){return{point:t,delta:Ei(t,Ir(e)),offset:Ei(t,nd(e)),velocity:sd(e,.1)}}function nd(t){return t[0]}function Ir(t){return t[t.length-1]}function sd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Ir(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>ut(e)));)n--;if(!s)return{x:0,y:0};const r=rt(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 id(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?W(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?W(n,t,s.max):Math.min(t,n)),t}function ki(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 od(t,{top:e,left:n,bottom:s,right:i}){return{x:ki(t.x,n,i),y:ki(t.y,e,s)}}function Ri(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function rd(t,e){return{x:Ri(t.x,e.x),y:Ri(t.y,e.y)}}function ad(t,e){let n=.5;const s=tt(t),i=tt(e);return i>s?n=xe(e.min,e.max-s,t.min):s>i&&(n=xe(t.min,t.max-i,e.min)),Tt(0,1,n)}function ld(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 Hn=.35;function cd(t=Hn){return t===!1?t=0:t===!0&&(t=Hn),{x:Ni(t,"left","right"),y:Ni(t,"top","bottom")}}function Ni(t,e,n){return{min:Ii(t,e),max:Ii(t,n)}}function Ii(t,e){return typeof t=="number"?t:t[e]||0}const ud=new WeakMap;class dd{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=H(),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(Me(d).point)},o=(d,f)=>{const{drag:p,dragPropagation:y,onDragStart:x}=this.getProps();if(p&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=xc(p),!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),ot(v=>{let b=this.getAxisMotionValue(v).get()||0;if(xt.test(b)){const{projection:T}=this.visualElement;if(T&&T.layout){const M=T.layout.layoutBox[v];M&&(b=tt(M)*(parseFloat(b)/100))}}this.originPoint[v]=b}),x&&B.postRender(()=>x(d,f)),_n(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:p,dragDirectionLock:y,onDirectionLock:x,onDrag:w}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:v}=f;if(y&&this.currentDirection===null){this.currentDirection=hd(v),this.currentDirection!==null&&x&&x(this.currentDirection);return}this.updateAxis("x",f.point,v),this.updateAxis("y",f.point,v),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},c=()=>ot(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:u}=this.getProps();this.panSession=new Nr(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:s,contextWindow:Rr(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||!Fe(e,i,this.currentDirection))return;const r=this.getAxisMotionValue(e);let o=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(o=id(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&&Jt(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=od(s.layoutBox,e):this.constraints=!1,this.elastic=cd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&ot(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=ld(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Jt(e))return!1;const s=e.current;St(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const r=pu(s,i.root,this.visualElement.getTransformPagePoint());let o=rd(i.layout.layoutBox,r);if(n){const a=n(hu(o));this.hasMutatedConstraints=!!a,a&&(o=gr(a))}return o}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},c=ot(u=>{if(!Fe(u,n,this.currentDirection))return;let d=l&&l[u]||{};o&&(d={min:0,max:0});const f=i?200:1e6,p=i?40:1e7,y={type:"inertia",velocity:s?e[u]:0,bounceStiffness:f,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...r,...d};return this.startAxisValueAnimation(u,y)});return Promise.all(c).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return _n(this.visualElement,e),s.start(Vs(e,s,0,n,this.visualElement,!1))}stopAnimation(){ot(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){ot(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){ot(n=>{const{drag:s}=this.getProps();if(!Fe(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]-W(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Jt(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};ot(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();i[o]=ad({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(),ot(o=>{if(!Fe(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:c}=this.constraints[o];a.set(W(l,c,i[o]))})}addListeners(){if(!this.visualElement.current)return;ud.set(this.visualElement,this);const e=this.visualElement.current,n=pe(e,"pointerdown",l=>{const{drag:c,dragListener:u=!0}=this.getProps();c&&u&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();Jt(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=Se(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(ot(u=>{const d=this.getAxisMotionValue(u);d&&(this.originPoint[u]+=l[u].translate,d.set(d.get()+l[u].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=Hn,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function Fe(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function hd(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class fd extends kt{constructor(e){super(e),this.removeGroupControls=at,this.removeListeners=at,this.controls=new dd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||at}unmount(){this.removeGroupControls(),this.removeListeners()}}const Li=t=>(e,n)=>{t&&B.postRender(()=>t(e,n))};class md extends kt{constructor(){super(...arguments),this.removePointerDownListener=at}onPointerDown(e){this.session=new Nr(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Rr(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:Li(e),onStart:Li(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&B.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=pe(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 _e={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Oi(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const he={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(j.test(t))t=parseFloat(t);else return t;const n=Oi(t,e.target.x),s=Oi(t,e.target.y);return`${n}% ${s}%`}},pd={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Et.parse(t);if(i.length>5)return s;const r=Et.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 c=W(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=c),typeof i[3+o]=="number"&&(i[3+o]/=c),r(i)}};let bn=!1;class gd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=e;$c(yd),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),bn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),_e.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,bn=!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(),xs.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;bn=!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 Lr(t){const[e,n]=sr(),s=m.useContext(qn);return h.jsx(gd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(mr),isPresent:e,safeToRemove:n})}const yd={borderRadius:{...he,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:he,borderTopRightRadius:he,borderBottomLeftRadius:he,borderBottomRightRadius:he,boxShadow:pd};function xd(t,e,n){const s=Z(t)?t:ie(t);return s.start(Vs("",s,e,n)),s.animation}const vd=(t,e)=>t.depth-e.depth;class bd{constructor(){this.children=[],this.isDirty=!1}add(e){Qn(this.children,e),this.isDirty=!0}remove(e){ts(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(vd),this.isDirty=!1,this.children.forEach(e)}}function wd(t,e){const n=nt.now(),s=({timestamp:i})=>{const r=i-n;r>=e&&(Vt(s),t(r-e))};return B.setup(s,!0),()=>Vt(s)}const Or=["TopLeft","TopRight","BottomLeft","BottomRight"],Td=Or.length,Fi=t=>typeof t=="string"?parseFloat(t):t,Bi=t=>typeof t=="number"||j.test(t);function Sd(t,e,n,s,i,r){i?(t.opacity=W(0,n.opacity??1,Cd(s)),t.opacityExit=W(e.opacity??1,0,Pd(s))):r&&(t.opacity=W(e.opacity??1,n.opacity??1,s));for(let o=0;o<Td;o++){const a=`border${Or[o]}Radius`;let l=$i(e,a),c=$i(n,a);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||Bi(l)===Bi(c)?(t[a]=Math.max(W(Fi(l),Fi(c),s),0),(xt.test(c)||xt.test(l))&&(t[a]+="%")):t[a]=c}(e.rotate||n.rotate)&&(t.rotate=W(e.rotate||0,n.rotate||0,s))}function $i(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Cd=Fr(0,.5,So),Pd=Fr(.5,.95,at);function Fr(t,e,n){return s=>s<t?0:s>e?1:n(xe(t,e,s))}function zi(t,e){t.min=e.min,t.max=e.max}function it(t,e){zi(t.x,e.x),zi(t.y,e.y)}function Ui(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function Wi(t,e,n,s,i){return t-=e,t=qe(t,1/n,s),i!==void 0&&(t=qe(t,1/i,s)),t}function Ad(t,e=0,n=1,s=.5,i,r=t,o=t){if(xt.test(e)&&(e=parseFloat(e),e=W(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=W(r.min,r.max,s);t===r&&(a-=e),t.min=Wi(t.min,e,n,a,i),t.max=Wi(t.max,e,n,a,i)}function _i(t,e,[n,s,i],r,o){Ad(t,e[n],e[s],e[i],e.scale,r,o)}const Md=["x","scaleX","originX"],jd=["y","scaleY","originY"];function Ki(t,e,n,s){_i(t.x,e,Md,n?n.x:void 0,s?s.x:void 0),_i(t.y,e,jd,n?n.y:void 0,s?s.y:void 0)}function Hi(t){return t.translate===0&&t.scale===1}function Br(t){return Hi(t.x)&&Hi(t.y)}function Xi(t,e){return t.min===e.min&&t.max===e.max}function Dd(t,e){return Xi(t.x,e.x)&&Xi(t.y,e.y)}function Yi(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function $r(t,e){return Yi(t.x,e.x)&&Yi(t.y,e.y)}function Gi(t){return tt(t.x)/tt(t.y)}function qi(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class Vd{constructor(){this.members=[]}add(e){Qn(this.members,e),e.scheduleRender()}remove(e){if(ts(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 Ed(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:c,rotate:u,rotateX:d,rotateY:f,skewX:p,skewY:y}=n;c&&(s=`perspective(${c}px) ${s}`),u&&(s+=`rotate(${u}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),p&&(s+=`skewX(${p}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 wn=["","X","Y","Z"],kd=1e3;let Rd=0;function Tn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function zr(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Pr(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&&zr(s)}function Ur({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Rd++,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(Ld),this.nodes.forEach($d),this.nodes.forEach(zd),this.nodes.forEach(Od)},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 bd)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new ns),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=nr(o)&&!Cc(o),this.instance=o;const{layoutId:a,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let u,d=0;const f=()=>this.root.updateBlockedByResize=!1;B.read(()=>{d=window.innerWidth}),t(o,()=>{const p=window.innerWidth;p!==d&&(d=p,this.root.updateBlockedByResize=!0,u&&u(),u=wd(f,250),_e.hasAnimatedSinceResize&&(_e.hasAnimatedSinceResize=!1,this.nodes.forEach(Qi)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||c.getDefaultTransition()||Hd,{onLayoutAnimationStart:x,onLayoutAnimationComplete:w}=c.getProps(),v=!this.targetLayout||!$r(this.targetLayout,p),b=!d&&f;if(this.options.layoutRoot||this.resumeFrom||b||d&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const T={...gs(y,"layout"),onPlay:x,onComplete:w};(c.shouldReduceMotion||this.options.layoutRoot)&&(T.delay=0,T.type=!1),this.startAnimation(T),this.setAnimationOrigin(u,b)}else d||Qi(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}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(Ud),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&&zr(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const d=this.path[u];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 c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Zi);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Ji);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Bd),this.nodes.forEach(Nd),this.nodes.forEach(Id)):this.nodes.forEach(Ji),this.clearAllSnapshots();const a=nt.now();G.delta=Tt(0,1e3/60,a-G.timestamp),G.timestamp=a,G.isProcessing=!0,un.update.process(G),un.preRender.process(G),un.render.process(G),G.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,xs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Fd),this.sharedNodes.forEach(Wd)}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&&!tt(this.snapshot.measuredBox.x)&&!tt(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=H(),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&&!Br(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;o&&this.instance&&(a||Ut(this.latestValues)||u)&&(i(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),Xd(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return H();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Yd))){const{scroll:c}=this.root;c&&(Qt(a.x,c.offset.x),Qt(a.y,c.offset.y))}return a}removeElementScroll(o){const a=H();if(it(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const c=this.path[l],{scroll:u,options:d}=c;c!==this.root&&u&&d.layoutScroll&&(u.wasRoot&&it(a,o),Qt(a.x,u.offset.x),Qt(a.y,u.offset.y))}return a}applyTransform(o,a=!1){const l=H();it(l,o);for(let c=0;c<this.path.length;c++){const u=this.path[c];!a&&u.options.layoutScroll&&u.scroll&&u!==u.root&&te(l,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),Ut(u.latestValues)&&te(l,u.latestValues)}return Ut(this.latestValues)&&te(l,this.latestValues),l}removeTransform(o){const a=H();it(a,o);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!c.instance||!Ut(c.latestValues))continue;$n(c.latestValues)&&c.updateSnapshot();const u=H(),d=c.measurePageBox();it(u,d),Ki(a,c.latestValues,c.snapshot?c.snapshot.layoutBox:void 0,u)}return Ut(this.latestValues)&&Ki(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!==G.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:u,layoutId:d}=this.options;if(!(!this.layout||!(u||d))){if(this.resolvedRelativeTargetAt=G.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=H(),this.relativeTargetOrigin=H(),ye(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),it(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=H(),this.targetWithTransforms=H()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),td(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):it(this.target,this.layout.layoutBox),xr(this.target,this.targetDelta)):it(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=H(),this.relativeTargetOrigin=H(),ye(this.relativeTargetOrigin,this.target,f.target),it(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||$n(this.parent.latestValues)||yr(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===G.timestamp&&(l=!1),l)return;const{layout:c,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||u))return;it(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;mu(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=H());const{target:p}=o;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Ui(this.prevProjectionDelta.x,this.projectionDelta.x),Ui(this.prevProjectionDelta.y,this.projectionDelta.y)),ge(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!qi(this.projectionDelta.x,this.prevProjectionDelta.x)||!qi(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}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=ee(),this.projectionDelta=ee(),this.projectionDeltaWithTransform=ee()}setAnimationOrigin(o,a=!1){const l=this.snapshot,c=l?l.latestValues:{},u={...this.latestValues},d=ee();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=H(),p=l?l.source:void 0,y=this.layout?this.layout.source:void 0,x=p!==y,w=this.getStack(),v=!w||w.members.length<=1,b=!!(x&&!v&&this.options.crossfade===!0&&!this.path.some(Kd));this.animationProgress=0;let T;this.mixTargetDelta=M=>{const P=M/1e3;to(d.x,o.x,P),to(d.y,o.y,P),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(ye(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),_d(this.relativeTarget,this.relativeTargetOrigin,f,P),T&&Dd(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=H()),it(T,this.relativeTarget)),x&&(this.animationValues=u,Sd(u,c,this.latestValues,P,b,v)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=P},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(()=>{_e.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=ie(0)),this.currentAnimation=xd(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(kd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:c,latestValues:u}=o;if(!(!a||!l||!c)){if(this!==o&&this.layout&&c&&Wr(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||H();const d=tt(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=tt(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}it(a,l),te(a,u),ge(this.projectionDeltaWithTransform,this.layoutCorrected,a,u)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Vd),this.sharedNodes.get(o).add(a);const c=a.options.initialPromotionConfig;a.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.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 c=this.getStack();c&&c.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 c={};l.z&&Tn("z",o,c,this.animationValues);for(let u=0;u<wn.length;u++)Tn(`rotate${wn[u]}`,o,c,this.animationValues),Tn(`skew${wn[u]}`,o,c,this.animationValues);o.render();for(const u in c)o.setStaticValue(u,c[u]),this.animationValues&&(this.animationValues[u]=c[u]);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=Ue(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Ue(a?.pointerEvents)||""),this.hasProjected&&!Ut(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let d=Ed(this.projectionDeltaWithTransform,this.treeScale,u);l&&(d=l(u,d)),o.transform=d;const{x:f,y:p}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${p.origin*100}% 0`,c.animationValues?o.opacity=c===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:o.opacity=c===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const y in Te){if(u[y]===void 0)continue;const{correct:x,applyTo:w,isCSSVariable:v}=Te[y],b=d==="none"?u[y]:x(u[y],c);if(w){const T=w.length;for(let M=0;M<T;M++)o[w[M]]=b}else v?this.options.visualElement.renderState.vars[y]=b:o[y]=b}this.options.layoutId&&(o.pointerEvents=c===this?Ue(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(Zi),this.root.sharedNodes.clear()}}}function Nd(t){t.updateLayout()}function Id(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"?ot(u=>{const d=r?e.measuredBox[u]:e.layoutBox[u],f=tt(d);d.min=n[u].min,d.max=d.min+f}):Wr(i,e.layoutBox,n)&&ot(u=>{const d=r?e.measuredBox[u]:e.layoutBox[u],f=tt(n[u]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[u].max=t.relativeTarget[u].min+f)});const o=ee();ge(o,n,e.layoutBox);const a=ee();r?ge(a,t.applyTransform(s,!0),e.measuredBox):ge(a,n,e.layoutBox);const l=!Br(o);let c=!1;if(!t.resumeFrom){const u=t.getClosestProjectingParent();if(u&&!u.resumeFrom){const{snapshot:d,layout:f}=u;if(d&&f){const p=H();ye(p,e.layoutBox,d.layoutBox);const y=H();ye(y,n,f.layoutBox),$r(p,y)||(c=!0),u.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=p,t.relativeParent=u)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Ld(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 Od(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Fd(t){t.clearSnapshot()}function Zi(t){t.clearMeasurements()}function Ji(t){t.isLayoutDirty=!1}function Bd(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Qi(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function $d(t){t.resolveTargetDelta()}function zd(t){t.calcProjection()}function Ud(t){t.resetSkewAndRotation()}function Wd(t){t.removeLeadSnapshot()}function to(t,e,n){t.translate=W(e.translate,0,n),t.scale=W(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function eo(t,e,n,s){t.min=W(e.min,n.min,s),t.max=W(e.max,n.max,s)}function _d(t,e,n,s){eo(t.x,e.x,n.x,s),eo(t.y,e.y,n.y,s)}function Kd(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Hd={duration:.45,ease:[.4,0,.1,1]},no=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),so=no("applewebkit/")&&!no("chrome/")?Math.round:at;function io(t){t.min=so(t.min),t.max=so(t.max)}function Xd(t){io(t.x),io(t.y)}function Wr(t,e,n){return t==="position"||t==="preserve-aspect"&&!Qu(Gi(e),Gi(n),.2)}function Yd(t){return t!==t.root&&t.scroll?.wasRoot}const Gd=Ur({attachResizeListener:(t,e)=>Se(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Sn={current:void 0},_r=Ur({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Sn.current){const t=new Gd({});t.mount(window),t.setOptions({layoutScroll:!0}),Sn.current=t}return Sn.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),qd={pan:{Feature:md},drag:{Feature:fd,ProjectionNode:_r,MeasureLayout:Lr}};function oo(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,Me(e)))}class Zd extends kt{mount(){const{current:e}=this.node;e&&(this.unmount=vc(e,(n,s)=>(oo(this.node,s,"Start"),i=>oo(this.node,i,"End"))))}unmount(){}}class Jd extends kt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Ce(Se(this.node.current,"focus",()=>this.onFocus()),Se(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function ro(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,Me(e)))}class Qd extends kt{mount(){const{current:e}=this.node;e&&(this.unmount=Sc(e,(n,s)=>(ro(this.node,s,"Start"),(i,{success:r})=>ro(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Xn=new WeakMap,Cn=new WeakMap,th=t=>{const e=Xn.get(t.target);e&&e(t)},eh=t=>{t.forEach(th)};function nh({root:t,...e}){const n=t||document;Cn.has(n)||Cn.set(n,{});const s=Cn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(eh,{root:t,...e})),s[i]}function sh(t,e,n){const s=nh(e);return Xn.set(t,n),s.observe(t),()=>{Xn.delete(t),s.unobserve(t)}}const ih={some:0,all:1};class oh extends kt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:r}=e,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:ih[i]},a=l=>{const{isIntersecting:c}=l;if(this.isInView===c||(this.isInView=c,r&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:u,onViewportLeave:d}=this.node.getProps(),f=c?u:d;f&&f(l)};return sh(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(rh(e,n))&&this.startObserver()}unmount(){}}function rh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Kr={inView:{Feature:oh},tap:{Feature:Qd},focus:{Feature:Jd},hover:{Feature:Zd}},ah={layout:{ProjectionNode:_r,MeasureLayout:Lr}},lh={...Vr,...Kr,...qd,...ah},ch=du(lh,Cr),uh={renderer:Cr,...Vr,...Kr};function Hr(t,e){return We(t,e)}const Be=Hr("div"),dh=Hr("p");function hh(t){const e=t.name||"unnamed",n=fh(t),{schema:s,def:i}=mh(t);return{name:e,description:n,parameters:s,parametersDef:i}}function fh(t){const n=t.toString().match(/\/\*\*\s*\n([^*]|\*[^/])*\*\//);if(n){const i=n[0].match(/\/\*\*\s*\n\s*\*\s*([^\n@]+)/);if(i&&i[1])return i[1].trim()}return`Execute ${t.name||"function"}`}function mh(t){const n=t.toString().match(/\(([^)]*)\)/);if(!n||!n[1]||!n[1].trim())return{schema:jt.z.object({}),def:{}};const i=n[1].split(",").map(a=>a.trim()),r={},o={};for(const a of i){const l=a.match(/(\w+)\s*:\s*(\w+)/);if(l&&l[1]&&l[2]){const c=l[1];switch(l[2].toLowerCase()){case"string":r[c]=jt.z.string().describe(c),o[c]={type:"string",description:c};break;case"number":r[c]=jt.z.number().describe(c),o[c]={type:"number",description:c};break;case"boolean":r[c]=jt.z.boolean().describe(c),o[c]={type:"boolean",description:c};break;case"any":r[c]=jt.z.any().describe(c),o[c]={type:"any",description:c};break;default:r[c]=jt.z.string().describe(c),o[c]={type:"string",description:c}}}else{const c=a.match(/(\w+)/);if(c&&c[1]){const u=c[1];r[u]=jt.z.string().describe(u),o[u]={type:"string",description:u}}}}return{schema:jt.z.object(r),def:o}}function Xr(t){return t.map(hh)}function ph({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(gt,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(Y.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(gt,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(Y.X,{className:"h-3 w-3"})})]})]})})}function gh({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(([c])=>!o.includes(c))),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(Y.ChevronDown,{className:"h-3 w-3"}):h.jsx(Y.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(Y.X,{className:"h-3 w-3"}):s?h.jsx(Y.Zap,{className:"h-3 w-3"}):h.jsx(Y.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&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(([c,u])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[c,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof u=="string"?u:JSON.stringify(u)})]},c))})})]})}function yh({...t}){return h.jsx(Gn.Root,{"data-slot":"collapsible",...t})}function xh({...t}){return h.jsx(Gn.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function vh({...t}){return h.jsx(Gn.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const bh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),Es=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(bh,{className:dt("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);Es.displayName="Response";const wh=Object.freeze(Object.defineProperty({__proto__:null,Response:Es},Symbol.toStringTag,{value:"Module"})),Th=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const r=ch.create(e),o=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(r,{animate:{backgroundPosition:"0% center"},className:dt("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})},Sh=m.memo(Th),Yr=m.createContext(null),Ch=()=>{const t=m.useContext(Yr);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Ph=1e3,Ah=1e3,Gr=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:r,children:o,...a})=>{const[l,c]=_s.useControllableState({prop:n,defaultProp:s,onChange:i}),[u,d]=_s.useControllableState({prop:r,defaultProp:0}),[f,p]=m.useState(!1),[y,x]=m.useState(null);m.useEffect(()=>{e?y===null&&x(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/Ah)),x(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&l&&!f){const v=setTimeout(()=>{c(!1),p(!0)},Ph);return()=>clearTimeout(v)}},[e,l,s,c,f]);const w=v=>{c(v)};return h.jsx(Yr.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:c,duration:u},children:h.jsx(yh,{className:dt("not-prose mb-4",t),onOpenChange:w,open:l,...a,children:o})})}),Mh=(t,e)=>t||e===0?h.jsx(Sh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),qr=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:r}=Ch();return h.jsx(xh,{className:dt("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...n,children:e??h.jsxs(h.Fragment,{children:[h.jsx(Y.BrainIcon,{className:"size-4"}),Mh(s,r),h.jsx(Y.ChevronDownIcon,{className:dt("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Zr=m.memo(({className:t,children:e,...n})=>h.jsx(vh,{className:dt("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(Es,{className:"grid gap-2",children:e})}));Gr.displayName="Reasoning";qr.displayName="ReasoningTrigger";Zr.displayName="ReasoningContent";function jh({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:c=!1,tools:u=[],safeTools:d=[],systemPrompt:f="",tokenEndpoint:p="/api/arcten/token",apiBaseUrl:y="https://api.arcten.com",user:x}){const[w,v]=m.useState(null),b=m.useRef(null),[T,M]=m.useState(null),[P,E]=m.useState(null),D=m.useRef(null),[A,F]=m.useState(c),[N,J]=m.useState(o),[vt,bt]=m.useState(600),[Rt,ht]=m.useState(!1),[I,$]=m.useState(!1),[R,et]=m.useState(!1),[_,wt]=m.useState({x:100,y:100}),[je,Pt]=m.useState(!1),[Nt,De]=m.useState({x:0,y:0}),[en,nn]=m.useState(!1),Xt=m.useRef(null),Yt=m.useRef(null),[V,k]=m.useState(""),[K,st]=m.useState(null),[Q,lt]=m.useState("Thinking..."),[sn,on]=m.useState(new Set),[Jr,Qr]=m.useState(""),[It,ta]=m.useState([]),[rn,ks]=m.useState(!1),[an,Rs]=m.useState([]),[Ns,ln]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Gt,Ve]=m.useState(!1),[Vh,Ee]=m.useState(!1),[Eh,ke]=m.useState([]),Lt=m.useMemo(()=>[...u,...d],[u,d]),Is=m.useMemo(()=>Xr(Lt),[Lt]),Ls=m.useMemo(()=>{const g=new Map;return Lt.forEach(C=>g.set(C.name,C)),g},[Lt]),Os=m.useMemo(()=>new Set(d.map(g=>g.name)),[d]),Fs=["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 g=localStorage.getItem("arcten-sidebar-expanded");g&&F(JSON.parse(g));const C=localStorage.getItem("arcten-sidebar-width");C&&J(parseInt(C));const L=localStorage.getItem("arcten-sidebar-height");L&&bt(parseInt(L));const S=localStorage.getItem("arcten-sidebar-detached");S&&$(JSON.parse(S));const z=localStorage.getItem("arcten-sidebar-position");if(z){const At=JSON.parse(z),mt=50,Mt=Math.max(mt-o,Math.min(At.x,window.innerWidth-mt)),q=Math.max(0,Math.min(At.y,window.innerHeight-mt));wt({x:Mt,y:q})}const O=localStorage.getItem("arcten-sidebar-minimized");O&&et(JSON.parse(O)),nn(!0)}},[]),m.useEffect(()=>((async()=>{try{const C=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:x})});if(!C.ok)throw new Error("Failed to fetch token");const L=await C.json();v(L.clientToken),b.current=L.clientToken,E(L.expiresAt),M(null)}catch(C){M(C instanceof Error?C.message:"Failed to fetch token")}})(),()=>{D.current&&clearTimeout(D.current)}),[p,x]),m.useEffect(()=>{if(!P)return;D.current&&clearTimeout(D.current);const g=Math.floor(Date.now()/1e3),C=P-g,S=Math.max(0,C-5);return console.log(`Token expires at ${new Date(P*1e3).toISOString()}`),console.log(`Scheduling token refresh in ${S} seconds`),D.current=setTimeout(async()=>{console.log("Refreshing token...");try{const z=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:x})});if(!z.ok)throw new Error("Failed to refresh token");const O=await z.json();v(O.clientToken),b.current=O.clientToken,E(O.expiresAt),M(null),console.log("Token refreshed successfully")}catch(z){console.error("Token refresh failed:",z),M(z instanceof Error?z.message:"Failed to refresh token")}},S*1e3),()=>{D.current&&clearTimeout(D.current)}},[P,p,x]),m.useEffect(()=>{(async()=>{if(Lt.length!==0)try{const C=Lt.map(S=>({name:S.name,code:S.toString()})),L=await fetch(`${y}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:C})});if(L.ok){const S=await L.json();ta(S.tools)}}catch(C){console.error("Failed to fetch tool descriptions:",C)}})()},[Lt]),m.useEffect(()=>{Promise.resolve().then(()=>wh).then(g=>{st(()=>g.Response)})},[]),m.useEffect(()=>{const g=()=>{Qr(window.location.pathname)};g(),window.addEventListener("popstate",g);const C=setInterval(g,500);return()=>{window.removeEventListener("popstate",g),clearInterval(C)}},[]);async function Bs(){if(!(!x?.id||!w)){Ee(!0);try{const C=await(await fetch(`${y}/conversations`,{headers:{Authorization:`Bearer ${w}`}})).json();Rs(C.conversations||[])}catch(g){console.error("Failed to fetch conversations:",g)}finally{Ee(!1)}}}m.useEffect(()=>{x?.id&&w&&Bs()},[x,w]);function ea(g){const C=Math.floor((Date.now()-g)/1e3);return C<60?"now":C<3600?`${Math.floor(C/60)}m`:C<86400?`${Math.floor(C/3600)}h`:`${Math.floor(C/86400)}d`}function na(){const g=crypto.randomUUID();ln(g),Ne([]),ke([]),Ve(!1)}async function sa(g){if(w)try{await fetch(`${y}/conversations/${g}`,{method:"DELETE",headers:{Authorization:`Bearer ${w}`}}),Rs(an.filter(C=>C._id!==g)),g===Ns&&na()}catch(C){console.error("Failed to delete conversation:",C)}}async function ia(g){ln(g.chatId),Ve(!1),Ee(!0);try{const C=await fetch(`${y}/conversations/${g.chatId}/messages`,{headers:{Authorization:`Bearer ${b.current}`}});if(!C.ok)throw new Error(`Failed to fetch messages: ${C.statusText}`);const S=(await C.json()).messages||[];Ne(S),ke(S)}catch(C){console.error("Failed to load conversation messages:",C);const L=g.messages||[];Ne(L),ke(L)}finally{Ee(!1)}}const oa=(async(g,C={})=>{const L=C.headers?new Headers(C.headers):new Headers;return L.delete("user-agent"),L.delete("User-Agent"),fetch(g,{...C,headers:L})}),{messages:ue,sendMessage:ra,status:ft,error:$s,stop:Re,addToolResult:de,setMessages:Ne}=ao.useChat({id:Ns||void 0,transport:new Ke.DefaultChatTransport({api:`${y}/chat`,fetch:oa,headers:()=>{const g={};return b.current&&(g.Authorization=`Bearer ${b.current}`),g},body:()=>({tools:Is.map(g=>({name:g.name,description:g.description,parameters:g.parametersDef})),systemPrompt:f,currentRoute:Jr})}),sendAutomaticallyWhen:Ke.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{A&&Yt.current&&Yt.current.focus()},[A,ue]);function aa(){F(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function la(){F(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[A]),m.useEffect(()=>{Xt.current&&Xt.current.scrollIntoView({behavior:"smooth"})},[ue]),m.useEffect(()=>{function g(C){C.key==="Escape"&&(ft==="streaming"||ft==="submitted")&&(C.preventDefault(),Re())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[ft,Re]);function ca(){const g=crypto.randomUUID();ln(g),Ne([]),ke([]),Ve(!1)}function zs(g){if(g.preventDefault(),!V.trim())return;(ft==="streaming"||ft==="submitted")&&Re();const C=Fs[Math.floor(Math.random()*Fs.length)]||"Thinking...";lt(C),ra({text:V}),k("")}function ua(g){const C=g.target.value;k(C)}m.useEffect(()=>{if(!Rt)return;function g(L){if(I){const S=L.clientX-_.x,z=L.clientY-_.y;S>=a&&S<=l&&J(S),z>=400&&z<=1e3&&bt(z)}else{const S=window.innerWidth-L.clientX;S>=a&&S<=l&&J(S)}}function C(){ht(!1),localStorage.setItem("arcten-sidebar-width",N.toString()),localStorage.setItem("arcten-sidebar-height",vt.toString())}return window.addEventListener("mousemove",g),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",C)}},[Rt,N,vt,I,_,a,l]);function da(g){g.preventDefault(),ht(!0)}function ha(){$(!0),et(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function fa(){$(!1),et(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Us(){et(!R),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!R))}function ma(g){I&&(Pt(!0),De({x:g.clientX-_.x,y:g.clientY-_.y}))}return m.useEffect(()=>{if(!I)return;function g(){wt(C=>{const S=window.innerWidth-50,z=window.innerHeight-50,O=50-N,At=0,mt=Math.max(O,Math.min(C.x,S)),Mt=Math.max(At,Math.min(C.y,z));if(mt!==C.x||Mt!==C.y){const q={x:mt,y:Mt};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(q)),q}return C})}return window.addEventListener("resize",g),()=>window.removeEventListener("resize",g)},[I,N]),m.useEffect(()=>{if(!je)return;function g(L){const S=L.clientX-Nt.x,z=L.clientY-Nt.y,O=50,At=window.innerWidth-O,mt=window.innerHeight-O,Mt=O-N,q=0,pt=Math.max(Mt,Math.min(S,At)),Ot=Math.max(q,Math.min(z,mt));wt({x:pt,y:Ot})}function C(){Pt(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(_))}return window.addEventListener("mousemove",g),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",C)}},[je,Nt,_,N]),en?T?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: ",T]})}):w?h.jsx(Nc,{features:uh,children:h.jsx(Be,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:I?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:I?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
10
+ ${I?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
11
11
  ${A?"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"}
12
- ${O?"border border-border":"border-l border-border"}
12
+ ${I?"border border-border":"border-l border-border"}
13
13
  ${A?"":"w-[30px]"}
14
- `,style:A?O?{width:`${L}px`,height:B?"auto":`${ct}px`,left:`${W.x}px`,top:`${W.y}px`}:{width:`${L}px`}:void 0,onClick:A?void 0:ca,children:A?h.jsxs(h.Fragment,{children:[!O&&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:fa,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),O&&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),De({x:p.clientX-W.x,y:p.clientY-W.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 ${O?"cursor-move":""}`,onMouseDown:O?ga:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${O&&B?"cursor-pointer":""}`,onClick:O&&B?p=>{p.stopPropagation(),Ws()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(yt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:da,"aria-label":"New chat",children:h.jsx(G.Plus,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:"Start a new conversation"})]}),h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(yt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:O?pa:ma,"aria-label":O?"Dock sidebar":"Float sidebar",children:O?h.jsx(G.Dock,{className:"h-4 w-4"}):h.jsx(G.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:O?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(yt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:O?Ws:ua,"aria-label":O?B?"Maximize":"Minimize":"Close sidebar",children:O?B?h.jsx(G.Maximize2,{className:"h-4 w-4"}):h.jsx(G.Minimize2,{className:"h-4 w-4"}):h.jsx(G.X,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:O?B?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!B&&h.jsxs(h.Fragment,{children:[v&&an.length>0&&h.jsxs("div",{className:`border-b border-border ${Xt?"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(yt,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Xt||$s(),Ee(!Xt)},children:Xt?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Xt?"flex-1 overflow-y-auto":""}`,children:an.slice(0,Xt?void 0:3).map(p=>h.jsx("div",{className:"group",children:h.jsxs(yt,{variant:"ghost",className:"w-full justify-between h-auto py-1 px-3 font-normal",onClick:()=>ra(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsxs("div",{className:"ml-2 flex items-center",children:[h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:sa(p.updatedAt)}),h.jsx(yt,{variant:"ghost",size:"icon",className:"h-2 w-2 p-0 hidden group-hover:flex text-muted-foreground hover:text-foreground",onClick:S=>{S.stopPropagation(),oa(p._id)},children:h.jsx(G.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:ue.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?"}),It.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:[(rn?It:It.slice(0,10)).map(p=>h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(un,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{_(p.sampleUsage),E.current?.focus()},children:p.friendlyName})}),h.jsx(Bt,{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)),It.length>10&&!rn&&h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsxs(un,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Rs(!0),children:["+",It.length-10," more"]})}),h.jsx(Bt,{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:It.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"})]})})]}),rn&&It.length>10&&h.jsx(un,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Rs(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[ue.map(p=>{const S=p.parts.filter(C=>C.type==="text");p.parts.filter(C=>C.type==="reasoning");const N=p.parts.filter(C=>C.type?.startsWith("tool-")),F=p.parts.filter(C=>C.type==="text"||C.type==="reasoning"),Y=S.map(C=>C.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(fh,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:Y}):h.jsxs("div",{className:"space-y-2",children:[N.map((C,it)=>{const K=C.type?.replace("tool-","")||"",Ct=Ls.find(dt=>dt.name===K),Pt=C.state==="input-available",cn=C.state==="output-available";if(Pt)return Fs.has(K)?((async()=>{if(sn.has(C.toolCallId))return;on(he=>new Set(he).add(C.toolCallId));const At=Os.get(K);if(At)try{console.log("Auto-executing safe tool:",K);const he=await At(...Object.values(C.input||{}));de({toolCallId:C.toolCallId,tool:K,output:he}),console.log("Safe tool result added:",C.toolCallId)}catch(he){de({toolCallId:C.toolCallId,tool:K,output:`Error: ${he}`}),console.log("Safe tool error result added:",C.toolCallId)}})(),null):h.jsx($e,{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:K,description:Ct?.description||"",args:C.input||{},onApprove:async()=>{if(sn.has(C.toolCallId)){console.log("Tool call already being processed:",C.toolCallId);return}on(At=>new Set(At).add(C.toolCallId));const dt=Os.get(K);if(dt)try{const At=await dt(...Object.values(C.input||{}));de({toolCallId:C.toolCallId,tool:K,output:At}),console.log("Tool result added:",C.toolCallId)}catch(At){de({toolCallId:C.toolCallId,tool:K,output:`Error: ${At}`}),console.log("Tool error result added:",C.toolCallId)}},onDeny:async()=>{if(sn.has(C.toolCallId)){console.log("Tool call already being processed:",C.toolCallId);return}on(dt=>new Set(dt).add(C.toolCallId)),de({toolCallId:C.toolCallId,tool:K,output:"User denied tool execution"}),console.log("Tool denied:",C.toolCallId)}})},`${C.toolCallId}-${it}`);if(cn){const dt=C.output==="User denied tool execution";return h.jsx(xh,{toolName:K,args:C.input||{},isDenied:dt,isSafe:Fs.has(K)},`${C.toolCallId}-${it}`)}return null}),F.map((C,it)=>C.type==="text"&&C.text&&nt?h.jsx(nt,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:C.text},`${p.id}-${it}`):C.type==="reasoning"&&C.text?h.jsxs(qr,{className:"w-full",isStreaming:gt==="streaming"&&it===p.parts.length-1&&p.id===ue.at(-1)?.id,children:[h.jsx(Zr,{}),h.jsx(Jr,{children:C.text})]},`${p.id}-${it}`):null)]})})},p.id)}),h.jsx("div",{ref:ce})]})}),zs&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",zs.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Ic,{mode:"wait",children:(gt==="streaming"||gt==="submitted")&&h.jsxs($e,{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($e,{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:ut})]})}),h.jsxs("form",{onSubmit:Us,className:"relative",children:[h.jsx(ho,{ref:E,value:k,onChange:ha,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(),Us(p))}}),gt==="streaming"||gt==="submitted"?h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(yt,{type:"button",size:"icon",variant:"ghost",className:"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8",onClick:Ne,children:h.jsx(G.Square,{className:"h-4 w-4"})})}),h.jsxs(Bt,{children:[h.jsx(Hs,{children:"Escape"})," to stop"]})]}):h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(yt,{type:"submit",size:"icon",variant:"ghost",className:"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8",disabled:!k.trim(),children:h.jsx(G.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(Bt,{children:[h.jsx(Hs,{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(G.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 Eh({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:r=[],safeTools:o=[],systemPrompt:a="",initialMessages:l=[],conversationId:c,onToolCall:u,onFinish:d}={}){console.log("[useAgent] Hook initialized",{apiBaseUrl:t,tokenEndpoint:e,hasProvidedToken:!!n,skipTokenFetch:s,userId:i?.id,toolsCount:r.length,safeToolsCount:o.length});const[f,g]=m.useState(n||null),y=m.useRef(n||null),[v,w]=m.useState(null),[x,T]=m.useState(null),b=m.useRef(null),[j,P]=m.useState([]),[V,D]=m.useState(c||(typeof window<"u"?crypto.randomUUID():null)),[A,I]=m.useState(!1),[L,Q]=m.useState(new Set),ct=m.useMemo(()=>[...r,...o],[r,o]),Ht=m.useMemo(()=>Yr(ct),[ct]),St=m.useMemo(()=>{const E=new Map;return ct.forEach(k=>E.set(k.name,k)),E},[ct]),pt=m.useMemo(()=>new Set(o.map(E=>E.name)),[o]);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 k=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!k.ok)throw new Error("Failed to fetch token");const _=await k.json();console.log("[useAgent] Token fetched successfully",{expiresAt:_.expiresAt,expiresIn:_.expiresAt?`${_.expiresAt-Math.floor(Date.now()/1e3)}s`:"unknown"}),g(_.clientToken),y.current=_.clientToken,T(_.expiresAt),w(null)}catch(k){console.error("[useAgent] Token fetch failed:",k),w(k instanceof Error?k.message:"Failed to fetch token")}})(),()=>{console.log("[useAgent] Cleaning up token fetch effect"),b.current&&clearTimeout(b.current)}},[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(console.log("[useAgent] Token refresh effect running",{hasTokenExpiresAt:!!x,tokenExpiresAt:x,skipTokenFetch:s,hasProvidedToken:!!n}),!x||s||n){console.log("[useAgent] Skipping token refresh setup",{reason:x?s?"skipTokenFetch=true":"token provided":"no expiry"});return}b.current&&(console.log("[useAgent] Clearing existing token refresh timeout"),clearTimeout(b.current));const E=Math.floor(Date.now()/1e3),k=x-E,nt=Math.max(0,k-5);return console.log("[useAgent] Scheduling token refresh",{expiresAt:x,now:E,timeUntilExpiry:`${k}s`,timeUntilRefresh:`${nt}s`,refreshAt:new Date((E+nt)*1e3).toISOString()}),b.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 ut=await tt.json();console.log("[useAgent] Token refreshed successfully",{newExpiresAt:ut.expiresAt,expiresIn:`${ut.expiresAt-Math.floor(Date.now()/1e3)}s`}),g(ut.clientToken),y.current=ut.clientToken,T(ut.expiresAt),w(null)}catch(tt){console.error("[useAgent] Token refresh failed:",tt),w(tt instanceof Error?tt.message:"Failed to refresh token")}},nt*1e3),()=>{console.log("[useAgent] Cleaning up token refresh effect"),b.current&&clearTimeout(b.current)}},[x,e,JSON.stringify(i),s,n]);const O=(async(E,k={})=>{const _=k.headers?new Headers(k.headers):new Headers;return _.delete("user-agent"),_.delete("User-Agent"),fetch(E,{...k,headers:_})}),{messages:R,sendMessage:B,status:Z,error:W,stop:kt,addToolResult:Rt,setMessages:Nt}=lo.useChat({id:V||void 0,messages:l,transport:new He.DefaultChatTransport({api:`${t}/chat`,fetch:O,headers:()=>{const E={};return y.current&&(E.Authorization=`Bearer ${y.current}`),E},body:()=>({tools:Ht.map(E=>({name:E.name,description:E.description,parameters:E.parametersDef})),systemPrompt:a})}),sendAutomaticallyWhen:He.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{R.forEach(E=>{E.role==="assistant"&&E.parts.forEach(k=>{if(!k.type?.startsWith("tool-")||k.state!=="input-available")return;const _=k.type.replace("tool-",""),nt=k.toolCallId;if(!L.has(nt)){if(Q(tt=>new Set(tt).add(nt)),pt.has(_)){const tt=St.get(_);tt&&(async()=>{try{const ut=await tt(...Object.values(k.input||{}));Rt({toolCallId:nt,tool:_,output:ut})}catch(ut){Rt({toolCallId:nt,tool:_,output:`Error: ${ut}`})}})()}else if(u){const tt={toolCallId:nt,toolName:_,args:k.input||{}};u({toolCall:tt})}}})})},[R,pt,St,u,Rt,L]),m.useEffect(()=>{if(Z==="ready"&&R.length>0&&d){const E=R[R.length-1];E&&E.role==="assistant"&&d({message:E,messages:R,isAbort:!1,isDisconnect:!1,isError:!!W})}},[Z,R,W,d]);async function le(){if(!(!i?.id||!f)){console.log("[useAgent] Fetching conversations for user:",i?.id),I(!0);try{const k=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${f}`}})).json();P(k.conversations||[])}catch(E){console.error("Failed to fetch conversations:",E)}finally{I(!1)}}}m.useEffect(()=>{i?.id&&f&&le()},[JSON.stringify(i),f,t]);async function De(E){D(E),I(!0);try{const k=await fetch(`${t}/conversations/${E}/messages`,{headers:{Authorization:`Bearer ${y.current}`}});if(!k.ok)throw new Error(`Failed to fetch messages: ${k.statusText}`);const nt=(await k.json()).messages||[];Nt(nt)}catch(k){console.error("Failed to load conversation messages:",k)}finally{I(!1)}}async function nn(E){if(f)try{await fetch(`${t}/conversations/${E}`,{method:"DELETE",headers:{Authorization:`Bearer ${f}`}}),P(j.filter(k=>k._id!==E)),E===V&&Ve()}catch(k){console.error("Failed to delete conversation:",k)}}function Ve(){const E=crypto.randomUUID();D(E),Nt([]),Q(new Set)}function ce(E){Rt(E)}return{id:V,messages:R,status:Z,error:W,sendMessage:B,stop:kt,addToolOutput:ce,setMessages:Nt,conversations:j,loadConversation:De,deleteConversation:nn,startNewConversation:Ve,isLoadingConversations:A,clientToken:f,tokenError:v}}exports.verifyToken=ja.verifyToken;exports.ArctenAgent=Vh;exports.useAgent=Eh;
14
+ `,style:A?I?{width:`${N}px`,height:R?"auto":`${vt}px`,left:`${_.x}px`,top:`${_.y}px`}:{width:`${N}px`}:void 0,onClick:A?void 0:aa,children:A?h.jsxs(h.Fragment,{children:[!I&&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:da,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),I&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:g=>{g.preventDefault(),ht(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:g=>{g.preventDefault(),g.stopPropagation(),Pt(!0),De({x:g.clientX-_.x,y:g.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:g=>{g.preventDefault(),ht(!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 ${I?"cursor-move":""}`,onMouseDown:I?ma:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${I&&R?"cursor-pointer":""}`,onClick:I&&R?g=>{g.stopPropagation(),Us()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:g=>g.stopPropagation(),children:[h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsx(gt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:ca,"aria-label":"New chat",children:h.jsx(Y.Plus,{className:"h-4 w-4"})})}),h.jsx($t,{children:"Start a new conversation"})]}),h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsx(gt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I?fa:ha,"aria-label":I?"Dock sidebar":"Float sidebar",children:I?h.jsx(Y.Dock,{className:"h-4 w-4"}):h.jsx(Y.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx($t,{children:I?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsx(gt,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I?Us:la,"aria-label":I?R?"Maximize":"Minimize":"Close sidebar",children:I?R?h.jsx(Y.Maximize2,{className:"h-4 w-4"}):h.jsx(Y.Minimize2,{className:"h-4 w-4"}):h.jsx(Y.X,{className:"h-4 w-4"})})}),h.jsx($t,{children:I?R?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!R&&h.jsxs(h.Fragment,{children:[x&&an.length>0&&h.jsxs("div",{className:`border-b border-border ${Gt?"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(gt,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Gt||Bs(),Ve(!Gt)},children:Gt?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Gt?"flex-1 overflow-y-auto":""}`,children:an.slice(0,Gt?void 0:3).map(g=>h.jsx("div",{className:"group",children:h.jsxs(gt,{variant:"ghost",className:"w-full justify-between h-auto py-1 px-3 font-normal",onClick:()=>ia(g),children:[h.jsx("span",{className:"text-xs truncate",children:g.title}),h.jsxs("div",{className:"ml-2 flex items-center",children:[h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:ea(g.updatedAt)}),h.jsx(gt,{variant:"ghost",size:"icon",className:"h-2 w-2 p-0 hidden group-hover:flex text-muted-foreground hover:text-foreground",onClick:C=>{C.stopPropagation(),sa(g._id)},children:h.jsx(Y.X,{className:"h-3 w-3"})})]})]})},g._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:ue.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?"}),It.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:[(rn?It:It.slice(0,10)).map(g=>h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsx(cn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{k(g.sampleUsage),Yt.current?.focus()},children:g.friendlyName})}),h.jsx($t,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:g.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',g.sampleUsage,'"']}),g.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",g.params.join(", ")]})]})})]},g.name)),It.length>10&&!rn&&h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsxs(cn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>ks(!0),children:["+",It.length-10," more"]})}),h.jsx($t,{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:It.slice(10).map(g=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[g.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:g.description})]},g.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),rn&&It.length>10&&h.jsx(cn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>ks(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[ue.map(g=>{const L=g.parts.filter(S=>S.type==="text").map(S=>S.text).join("");return h.jsx("div",{className:`${g.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${g.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:g.role==="user"?h.jsx(dh,{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:L}):h.jsx("div",{className:"space-y-2",children:g.parts.map((S,z)=>{if(S.type?.startsWith("tool-")){const O=S.type?.replace("tool-","")||"",At=Is.find(q=>q.name===O),mt=S.state==="input-available",Mt=S.state==="output-available";if(mt)return Os.has(O)?((async()=>{if(sn.has(S.toolCallId))return;on(Ot=>new Set(Ot).add(S.toolCallId));const pt=Ls.get(O);if(pt)try{console.log("Auto-executing safe tool:",O);const Ot=await pt(...Object.values(S.input||{}));de({toolCallId:S.toolCallId,tool:O,output:Ot}),console.log("Safe tool result added:",S.toolCallId)}catch(Ot){de({toolCallId:S.toolCallId,tool:O,output:`Error: ${Ot}`}),console.log("Safe tool error result added:",S.toolCallId)}})(),null):h.jsx(Be,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(ph,{toolName:O,description:At?.description||"",args:S.input||{},onApprove:async()=>{if(sn.has(S.toolCallId)){console.log("Tool call already being processed:",S.toolCallId);return}on(pt=>new Set(pt).add(S.toolCallId));const q=Ls.get(O);if(q)try{const pt=await q(...Object.values(S.input||{}));de({toolCallId:S.toolCallId,tool:O,output:pt}),console.log("Tool result added:",S.toolCallId)}catch(pt){de({toolCallId:S.toolCallId,tool:O,output:`Error: ${pt}`}),console.log("Tool error result added:",S.toolCallId)}},onDeny:async()=>{if(sn.has(S.toolCallId)){console.log("Tool call already being processed:",S.toolCallId);return}on(q=>new Set(q).add(S.toolCallId)),de({toolCallId:S.toolCallId,tool:O,output:"User denied tool execution"}),console.log("Tool denied:",S.toolCallId)}})},`${S.toolCallId}-${z}`);if(Mt){const q=S.output==="User denied tool execution";return h.jsx(gh,{toolName:O,args:S.input||{},isDenied:q,isSafe:Os.has(O)},`${S.toolCallId}-${z}`)}return null}return S.type==="text"&&S.text&&K?h.jsx(K,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:S.text},`${g.id}-${z}`):S.type==="reasoning"&&S.text?h.jsxs(Gr,{className:"w-full",isStreaming:ft==="streaming"&&z===g.parts.length-1&&g.id===ue.at(-1)?.id,children:[h.jsx(qr,{}),h.jsx(Zr,{children:S.text})]},`${g.id}-${z}`):null})})})},g.id)}),h.jsx("div",{ref:Xt})]})}),$s&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",$s.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Rc,{mode:"wait",children:(ft==="streaming"||ft==="submitted")&&h.jsxs(Be,{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(Be,{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:Q})]})}),h.jsxs("form",{onSubmit:zs,className:"relative",children:[h.jsx(uo,{ref:Yt,value:V,onChange:ua,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),zs(g))}}),ft==="streaming"||ft==="submitted"?h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsx(gt,{type:"button",size:"icon",variant:"ghost",className:"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8",onClick:Re,children:h.jsx(Y.Square,{className:"h-4 w-4"})})}),h.jsxs($t,{children:[h.jsx(Ks,{children:"Escape"})," to stop"]})]}):h.jsxs(Ft,{children:[h.jsx(Bt,{asChild:!0,children:h.jsx(gt,{type:"submit",size:"icon",variant:"ghost",className:"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8",disabled:!V.trim(),children:h.jsx(Y.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs($t,{children:[h.jsx(Ks,{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(Y.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),h.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function Dh({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:r=[],safeTools:o=[],systemPrompt:a="",initialMessages:l=[],conversationId:c,onToolCall:u,onFinish:d,ragFilters:f}={}){console.log("[useAgent] Hook initialized",{apiBaseUrl:t,tokenEndpoint:e,hasProvidedToken:!!n,skipTokenFetch:s,userId:i?.id,toolsCount:r.length,safeToolsCount:o.length});const[p,y]=m.useState(n||null),x=m.useRef(n||null),[w,v]=m.useState(null),[b,T]=m.useState(null),M=m.useRef(null),[P,E]=m.useState([]),[D,A]=m.useState(c||(typeof window<"u"?crypto.randomUUID():null)),[F,N]=m.useState(!1),[J,vt]=m.useState(new Set),bt=m.useMemo(()=>[...r,...o],[r,o]),Rt=m.useMemo(()=>Xr(bt),[bt]),ht=m.useMemo(()=>{const V=new Map;return bt.forEach(k=>V.set(k.name,k)),V},[bt]),I=m.useMemo(()=>new Set(o.map(V=>V.name)),[o]);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 k=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!k.ok)throw new Error("Failed to fetch token");const K=await k.json();console.log("[useAgent] Token fetched successfully",{expiresAt:K.expiresAt,expiresIn:K.expiresAt?`${K.expiresAt-Math.floor(Date.now()/1e3)}s`:"unknown"}),y(K.clientToken),x.current=K.clientToken,T(K.expiresAt),v(null)}catch(k){console.error("[useAgent] Token fetch failed:",k),v(k instanceof Error?k.message:"Failed to fetch token")}})(),()=>{console.log("[useAgent] Cleaning up token fetch effect"),M.current&&clearTimeout(M.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}M.current&&(console.log("[useAgent] Clearing existing token refresh timeout"),clearTimeout(M.current));const V=Math.floor(Date.now()/1e3),k=b-V,st=Math.max(0,k-5);return console.log("[useAgent] Scheduling token refresh",{expiresAt:b,now:V,timeUntilExpiry:`${k}s`,timeUntilRefresh:`${st}s`,refreshAt:new Date((V+st)*1e3).toISOString()}),M.current=setTimeout(async()=>{console.log("[useAgent] Refreshing token...");try{const Q=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!Q.ok)throw new Error("Failed to refresh token");const lt=await Q.json();console.log("[useAgent] Token refreshed successfully",{newExpiresAt:lt.expiresAt,expiresIn:`${lt.expiresAt-Math.floor(Date.now()/1e3)}s`}),y(lt.clientToken),x.current=lt.clientToken,T(lt.expiresAt),v(null)}catch(Q){console.error("[useAgent] Token refresh failed:",Q),v(Q instanceof Error?Q.message:"Failed to refresh token")}},st*1e3),()=>{console.log("[useAgent] Cleaning up token refresh effect"),M.current&&clearTimeout(M.current)}},[b,e,JSON.stringify(i),s,n]);const $=(async(V,k={})=>{const K=k.headers?new Headers(k.headers):new Headers;return K.delete("user-agent"),K.delete("User-Agent"),fetch(V,{...k,headers:K})}),{messages:R,sendMessage:et,status:_,error:wt,stop:je,addToolResult:Pt,setMessages:Nt}=ao.useChat({id:D||void 0,messages:l,transport:new Ke.DefaultChatTransport({api:`${t}/chat`,fetch:$,headers:()=>{const V={};return x.current&&(V.Authorization=`Bearer ${x.current}`),V},body:()=>({tools:Rt.map(V=>({name:V.name,description:V.description,parameters:V.parametersDef})),systemPrompt:a,...f&&{ragFilters:f}})}),sendAutomaticallyWhen:Ke.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{R.forEach(V=>{V.role==="assistant"&&V.parts.forEach(k=>{if(!k.type?.startsWith("tool-")||k.state!=="input-available")return;const K=k.type.replace("tool-",""),st=k.toolCallId;if(!J.has(st)){if(vt(Q=>new Set(Q).add(st)),I.has(K)){const Q=ht.get(K);Q&&(async()=>{try{const lt=await Q(...Object.values(k.input||{}));Pt({toolCallId:st,tool:K,output:lt})}catch(lt){Pt({toolCallId:st,tool:K,output:`Error: ${lt}`})}})()}else if(u){const Q={toolCallId:st,toolName:K,args:k.input||{}};u({toolCall:Q})}}})})},[R,I,ht,u,Pt,J]),m.useEffect(()=>{if(_==="ready"&&R.length>0&&d){const V=R[R.length-1];V&&V.role==="assistant"&&d({message:V,messages:R,isAbort:!1,isDisconnect:!1,isError:!!wt})}},[_,R,wt,d]);async function De(){if(!(!i?.id||!p)){console.log("[useAgent] Fetching conversations for user:",i?.id),N(!0);try{const k=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${p}`}})).json();E(k.conversations||[])}catch(V){console.error("Failed to fetch conversations:",V)}finally{N(!1)}}}m.useEffect(()=>{i?.id&&p&&De()},[JSON.stringify(i),p,t]);async function en(V){A(V),N(!0);try{const k=await fetch(`${t}/conversations/${V}/messages`,{headers:{Authorization:`Bearer ${x.current}`}});if(!k.ok)throw new Error(`Failed to fetch messages: ${k.statusText}`);const st=(await k.json()).messages||[];Nt(st)}catch(k){console.error("Failed to load conversation messages:",k)}finally{N(!1)}}async function nn(V){if(p)try{await fetch(`${t}/conversations/${V}`,{method:"DELETE",headers:{Authorization:`Bearer ${p}`}}),E(P.filter(k=>k._id!==V)),V===D&&Xt()}catch(k){console.error("Failed to delete conversation:",k)}}function Xt(){const V=crypto.randomUUID();A(V),Nt([]),vt(new Set)}function Yt(V){Pt(V)}return{id:D,messages:R,status:_,error:wt,sendMessage:et,stop:je,addToolOutput:Yt,setMessages:Nt,conversations:P,loadConversation:en,deleteConversation:nn,startNewConversation:Xt,isLoadingConversations:F,clientToken:p,tokenError:w}}exports.verifyToken=Aa.verifyToken;exports.ArctenAgent=jh;exports.useAgent=Dh;