@arcteninc/core 0.0.74 → 0.0.75
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 +6 -6
- package/dist/index.mjs +283 -279
- package/dist/lib/useAgent.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var za=Object.create;var yi=Object.defineProperty;var Ua=Object.getOwnPropertyDescriptor;var _a=Object.getOwnPropertyNames;var Wa=Object.getPrototypeOf,Ka=Object.prototype.hasOwnProperty;var Ha=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _a(e))!Ka.call(t,i)&&i!==n&&yi(t,i,{get:()=>e[i],enumerable:!(s=Ua(e,i))||s.enumerable});return t};var Ga=(t,e,n)=>(n=t!=null?za(Wa(t)):{},Ha(e||!t||!t.__esModule?yi(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),Z=require("lucide-react"),Ir=require("@ai-sdk/react"),An=require("ai"),Lr=require("@radix-ui/react-slot"),Or=require("class-variance-authority"),Xa=require("clsx"),qa=require("tailwind-merge"),Ya=require("@radix-ui/react-tooltip"),xi=require("@radix-ui/react-use-controllable-state"),Ja=require("@radix-ui/react-collapsible"),Za=require("./server.cjs");function Ms(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Pt=Ms(m),Ce=Ms(Ya),js=Ms(Ja);function st(...t){return qa.twMerge(Xa.clsx(t))}const re=Or.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),Pn=Pt.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},o)=>{const r=s?Lr.Slot:"button";return h.jsx(r,{ref:o,"data-slot":"button",className:st(re({variant:e,size:n,className:t})),...i})});Pn.displayName="Button";const Qa=Or.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 zn({className:t,variant:e,asChild:n=!1,...s}){const i=n?Lr.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:st(Qa({variant:e}),t),...s})}const tc=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,o]=Pt.useState(!0);Pt.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const c=a.scrollHeight;c>n?a.style.height=`${n}px`:a.style.height=`${c+6}px`}},[t.current,e])},Fr=Pt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...o},r)=>{const a=Pt.useRef(null),[c,u]=Pt.useState("");return tc({textAreaRef:a,triggerAutoSize:c,maxHeight:t,minHeight:e}),m.useImperativeHandle(r,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),Pt.useEffect(()=>{u(i)},[o?.defaultValue,i]),h.jsx("textarea",{...o,value:i,ref:a,className:st("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:l=>{u(l.target.value),s?.(l)}})});Fr.displayName="AutosizeTextarea";function ec({delayDuration:t=0,...e}){return h.jsx(Ce.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function ee({...t}){return h.jsx(ec,{children:h.jsx(Ce.Root,{"data-slot":"tooltip",...t})})}function ne({...t}){return h.jsx(Ce.Trigger,{"data-slot":"tooltip-trigger",...t})}function se({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(Ce.Portal,{children:h.jsxs(Ce.Content,{"data-slot":"tooltip-content",sideOffset:e,className:st("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...s,children:[n,h.jsx(Ce.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function vi({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:st("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 Es=m.createContext({});function ks(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const Ds=typeof window<"u",Br=Ds?m.useLayoutEffect:m.useEffect,Dn=m.createContext(null);function Vs(t,e){t.indexOf(e)===-1&&t.push(e)}function Rs(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Lt=(t,e,n)=>n>e?e:n<t?t:n;function is(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let ke=()=>{},Ot=()=>{};process.env.NODE_ENV!=="production"&&(ke=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(is(e,n))},Ot=(t,e,n)=>{if(!t)throw new Error(is(e,n))});const Ft={},$r=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function zr(t){return typeof t=="object"&&t!==null}const Ur=t=>/^0[^.\s]+$/u.test(t);function Ns(t){let e;return()=>(e===void 0&&(e=t()),e)}const wt=t=>t,nc=(t,e)=>n=>e(t(n)),nn=(...t)=>t.reduce(nc),Ye=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Is{constructor(){this.subscriptions=[]}add(e){return Vs(this.subscriptions,e),()=>Rs(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Ct=t=>t*1e3,bt=t=>t/1e3;function _r(t,e){return e?t*(1e3/e):0}const bi=new Set;function Ls(t,e,n){t||bi.has(e)||(console.warn(is(e,n)),bi.add(e))}const Wr=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,sc=1e-7,ic=12;function rc(t,e,n,s,i){let o,r,a=0;do r=e+(n-e)/2,o=Wr(r,s,i)-t,o>0?n=r:e=r;while(Math.abs(o)>sc&&++a<ic);return r}function sn(t,e,n,s){if(t===e&&n===s)return wt;const i=o=>rc(o,0,1,t,n);return o=>o===0||o===1?o:Wr(i(o),e,s)}const Kr=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Hr=t=>e=>1-t(1-e),Gr=sn(.33,1.53,.69,.99),Os=Hr(Gr),Xr=Kr(Os),qr=t=>(t*=2)<1?.5*Os(t):.5*(2-Math.pow(2,-10*(t-1))),Fs=t=>1-Math.sin(Math.acos(t)),Yr=Hr(Fs),Jr=Kr(Fs),oc=sn(.42,0,1,1),ac=sn(0,0,.58,1),Zr=sn(.42,0,.58,1),cc=t=>Array.isArray(t)&&typeof t[0]!="number",Qr=t=>Array.isArray(t)&&typeof t[0]=="number",wi={linear:wt,easeIn:oc,easeInOut:Zr,easeOut:ac,circIn:Fs,circInOut:Jr,circOut:Yr,backIn:Os,backInOut:Xr,backOut:Gr,anticipate:qr},lc=t=>typeof t=="string",Ti=t=>{if(Qr(t)){Ot(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return sn(e,n,s,i)}else if(lc(t))return Ot(wi[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),wi[t];return t},mn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function uc(t,e){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(l){r.has(l)&&(u.schedule(l),t()),l(a)}const u={schedule:(l,d=!1,f=!1)=>{const x=f&&i?n:s;return d&&r.add(l),x.has(l)||x.add(l),l},cancel:l=>{s.delete(l),r.delete(l)},process:l=>{if(a=l,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(c),n.clear(),i=!1,o&&(o=!1,u.process(l))}};return u}const dc=40;function to(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=mn.reduce((T,D)=>(T[D]=uc(o),T),{}),{setup:a,read:c,resolveKeyframes:u,preUpdate:l,update:d,preRender:f,render:g,postRender:x}=r,v=()=>{const T=Ft.useManualTiming?i.timestamp:performance.now();n=!1,Ft.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(T-i.timestamp,dc),1)),i.timestamp=T,i.isProcessing=!0,a.process(i),c.process(i),u.process(i),l.process(i),d.process(i),f.process(i),g.process(i),x.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},A=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:mn.reduce((T,D)=>{const j=r[D];return T[D]=(E,O=!1,R=!1)=>(n||A(),j.schedule(E,O,R)),T},{}),cancel:T=>{for(let D=0;D<mn.length;D++)r[mn[D]].cancel(T)},state:i,steps:r}}const{schedule:H,cancel:Wt,state:nt,steps:Un}=to(typeof requestAnimationFrame<"u"?requestAnimationFrame:wt,!0);let vn;function hc(){vn=void 0}const mt={now:()=>(vn===void 0&&mt.set(nt.isProcessing||Ft.useManualTiming?nt.timestamp:performance.now()),vn),set:t=>{vn=t,queueMicrotask(hc)}},eo=t=>e=>typeof e=="string"&&e.startsWith(t),Bs=eo("--"),fc=eo("var(--"),$s=t=>fc(t)?mc.test(t.split("/*")[0].trim()):!1,mc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,De={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Je={...De,transform:t=>Lt(0,1,t)},pn={...De,default:1},We=t=>Math.round(t*1e5)/1e5,zs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function pc(t){return t==null}const gc=/^(?:#[\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"&&gc.test(n)&&n.startsWith(t)||e&&!pc(n)&&Object.prototype.hasOwnProperty.call(n,e)),no=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,a]=s.match(zs);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},yc=t=>Lt(0,255,t),_n={...De,transform:t=>Math.round(yc(t))},ae={test:Us("rgb","red"),parse:no("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+_n.transform(t)+", "+_n.transform(e)+", "+_n.transform(n)+", "+We(Je.transform(s))+")"};function xc(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 rs={test:Us("#"),parse:xc,transform:ae.transform},rn=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),_t=rn("deg"),Dt=rn("%"),L=rn("px"),vc=rn("vh"),bc=rn("vw"),Si={...Dt,parse:t=>Dt.parse(t)/100,transform:t=>Dt.transform(t*100)},be={test:Us("hsl","hue"),parse:no("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+Dt.transform(We(e))+", "+Dt.transform(We(n))+", "+We(Je.transform(s))+")"},J={test:t=>ae.test(t)||rs.test(t)||be.test(t),parse:t=>ae.test(t)?ae.parse(t):be.test(t)?be.parse(t):rs.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ae.transform(t):be.transform(t),getAnimatableNone:t=>{const e=J.parse(t);return e.alpha=0,J.transform(e)}},wc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Tc(t){return isNaN(t)&&typeof t=="string"&&(t.match(zs)?.length||0)+(t.match(wc)?.length||0)>0}const so="number",io="color",Sc="var",Ac="var(",Ai="${}",Pc=/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 Ze(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let o=0;const a=e.replace(Pc,c=>(J.test(c)?(s.color.push(o),i.push(io),n.push(J.parse(c))):c.startsWith(Ac)?(s.var.push(o),i.push(Sc),n.push(c)):(s.number.push(o),i.push(so),n.push(parseFloat(c))),++o,Ai)).split(Ai);return{values:n,split:a,indexes:s,types:i}}function ro(t){return Ze(t).values}function oo(t){const{split:e,types:n}=Ze(t),s=e.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=e[r],i[r]!==void 0){const a=n[r];a===so?o+=We(i[r]):a===io?o+=J.transform(i[r]):o+=i[r]}return o}}const Cc=t=>typeof t=="number"?0:J.test(t)?J.getAnimatableNone(t):t;function Mc(t){const e=ro(t);return oo(t)(e.map(Cc))}const Kt={test:Tc,parse:ro,createTransformer:oo,getAnimatableNone:Mc};function Wn(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 jc({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,o=0,r=0;if(!e)i=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=Wn(c,a,t+1/3),o=Wn(c,a,t),r=Wn(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function Cn(t,e){return n=>n>0?e:t}const X=(t,e,n)=>t+(e-t)*n,Kn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},Ec=[rs,ae,be],kc=t=>Ec.find(e=>e.test(t));function Pi(t){const e=kc(t);if(ke(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===be&&(n=jc(n)),n}const Ci=(t,e)=>{const n=Pi(t),s=Pi(e);if(!n||!s)return Cn(t,e);const i={...n};return o=>(i.red=Kn(n.red,s.red,o),i.green=Kn(n.green,s.green,o),i.blue=Kn(n.blue,s.blue,o),i.alpha=X(n.alpha,s.alpha,o),ae.transform(i))},os=new Set(["none","hidden"]);function Dc(t,e){return os.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function Vc(t,e){return n=>X(t,e,n)}function _s(t){return typeof t=="number"?Vc:typeof t=="string"?$s(t)?Cn:J.test(t)?Ci:Ic:Array.isArray(t)?ao:typeof t=="object"?J.test(t)?Ci:Rc:Cn}function ao(t,e){const n=[...t],s=n.length,i=t.map((o,r)=>_s(o)(o,e[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function Rc(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=_s(t[i])(t[i],e[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function Nc(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],r=t.indexes[o][s[o]],a=t.values[r]??0;n[i]=a,s[o]++}return n}const Ic=(t,e)=>{const n=Kt.createTransformer(e),s=Ze(t),i=Ze(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?os.has(t)&&!i.values.length||os.has(e)&&!s.values.length?Dc(t,e):nn(ao(Nc(s,i),i.values),n):(ke(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),Cn(t,e))};function co(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?X(t,e,n):_s(t)(t,e)}const Lc=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>H.update(e,n),stop:()=>Wt(e),now:()=>nt.isProcessing?nt.timestamp:mt.now()}},lo=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)s+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Mn=2e4;function Ws(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Mn;)e+=n,s=t.next(e);return e>=Mn?1/0:e}function Oc(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(Ws(s),Mn);return{type:"keyframes",ease:o=>s.next(i*o).value/e,duration:bt(i)}}const Fc=5;function uo(t,e,n){const s=Math.max(e-Fc,0);return _r(n-t(s),e-s)}const G={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},Hn=.001;function Bc({duration:t=G.duration,bounce:e=G.bounce,velocity:n=G.velocity,mass:s=G.mass}){let i,o;ke(t<=Ct(G.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let r=1-e;r=Lt(G.minDamping,G.maxDamping,r),t=Lt(G.minDuration,G.maxDuration,bt(t)),r<1?(i=u=>{const l=u*r,d=l*t,f=l-n,g=as(u,r),x=Math.exp(-d);return Hn-f/g*x},o=u=>{const d=u*r*t,f=d*n+n,g=Math.pow(r,2)*Math.pow(u,2)*t,x=Math.exp(-d),v=as(Math.pow(u,2),r);return(-i(u)+Hn>0?-1:1)*((f-g)*x)/v}):(i=u=>{const l=Math.exp(-u*t),d=(u-n)*t+1;return-Hn+l*d},o=u=>{const l=Math.exp(-u*t),d=(n-u)*(t*t);return l*d});const a=5/t,c=zc(i,o,a);if(t=Ct(t),isNaN(c))return{stiffness:G.stiffness,damping:G.damping,duration:t};{const u=Math.pow(c,2)*s;return{stiffness:u,damping:r*2*Math.sqrt(s*u),duration:t}}}const $c=12;function zc(t,e,n){let s=n;for(let i=1;i<$c;i++)s=s-t(s)/e(s);return s}function as(t,e){return t*Math.sqrt(1-e*e)}const Uc=["duration","bounce"],_c=["stiffness","damping","mass"];function Mi(t,e){return e.some(n=>t[n]!==void 0)}function Wc(t){let e={velocity:G.velocity,stiffness:G.stiffness,damping:G.damping,mass:G.mass,isResolvedFromDuration:!1,...t};if(!Mi(t,_c)&&Mi(t,Uc))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*Lt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:G.mass,stiffness:i,damping:o}}else{const n=Bc(t);e={...e,...n,mass:G.mass},e.isResolvedFromDuration=!0}return e}function jn(t=G.visualDuration,e=G.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:c,damping:u,mass:l,duration:d,velocity:f,isResolvedFromDuration:g}=Wc({...n,velocity:-bt(n.velocity||0)}),x=f||0,v=u/(2*Math.sqrt(c*l)),A=r-o,y=bt(Math.sqrt(c/l)),w=Math.abs(A)<5;s||(s=w?G.restSpeed.granular:G.restSpeed.default),i||(i=w?G.restDelta.granular:G.restDelta.default);let T;if(v<1){const j=as(y,v);T=E=>{const O=Math.exp(-v*y*E);return r-O*((x+v*y*A)/j*Math.sin(j*E)+A*Math.cos(j*E))}}else if(v===1)T=j=>r-Math.exp(-y*j)*(A+(x+y*A)*j);else{const j=y*Math.sqrt(v*v-1);T=E=>{const O=Math.exp(-v*y*E),R=Math.min(j*E,300);return r-O*((x+v*y*A)*Math.sinh(R)+j*A*Math.cosh(R))/j}}const D={calculatedDuration:g&&d||null,next:j=>{const E=T(j);if(g)a.done=j>=d;else{let O=j===0?x:0;v<1&&(O=j===0?Ct(x):uo(T,j,E));const R=Math.abs(O)<=s,$=Math.abs(r-E)<=i;a.done=R&&$}return a.value=a.done?r:E,a},toString:()=>{const j=Math.min(Ws(D),Mn),E=lo(O=>D.next(j*O).value,j,30);return j+"ms "+E},toTransition:()=>{}};return D}jn.applyToOptions=t=>{const e=Oc(t,100,jn);return t.ease=e.ease,t.duration=Ct(e.duration),t.type="keyframes",t};function cs({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:c,restDelta:u=.5,restSpeed:l}){const d=t[0],f={done:!1,value:d},g=R=>a!==void 0&&R<a||c!==void 0&&R>c,x=R=>a===void 0?c:c===void 0||Math.abs(a-R)<Math.abs(c-R)?a:c;let v=n*e;const A=d+v,y=r===void 0?A:r(A);y!==A&&(v=y-d);const w=R=>-v*Math.exp(-R/s),T=R=>y+w(R),D=R=>{const $=w(R),q=T(R);f.done=Math.abs($)<=u,f.value=f.done?y:q};let j,E;const O=R=>{g(f.value)&&(j=R,E=jn({keyframes:[f.value,x(f.value)],velocity:uo(T,R,f.value),damping:i,stiffness:o,restDelta:u,restSpeed:l}))};return O(0),{calculatedDuration:null,next:R=>{let $=!1;return!E&&j===void 0&&($=!0,D(R),O(R)),j!==void 0&&R>=j?E.next(R-j):(!$&&D(R),f)}}}function Kc(t,e,n){const s=[],i=n||Ft.mix||co,o=t.length-1;for(let r=0;r<o;r++){let a=i(t[r],t[r+1]);if(e){const c=Array.isArray(e)?e[r]||wt:e;a=nn(c,a)}s.push(a)}return s}function Hc(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const o=t.length;if(Ot(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const r=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Kc(e,s,i),c=a.length,u=l=>{if(r&&l<t[0])return e[0];let d=0;if(c>1)for(;d<t.length-2&&!(l<t[d+1]);d++);const f=Ye(t[d],t[d+1],l);return a[d](f)};return n?l=>u(Lt(t[0],t[o-1],l)):u}function Gc(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ye(0,e,s);t.push(X(n,1,i))}}function Xc(t){const e=[0];return Gc(e,t.length-1),e}function qc(t,e){return t.map(n=>n*e)}function Yc(t,e){return t.map(()=>e||Zr).splice(0,t.length-1)}function we({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=cc(s)?s.map(Ti):Ti(s),o={done:!1,value:e[0]},r=qc(n&&n.length===e.length?n:Xc(e),t),a=Hc(r,e,{ease:Array.isArray(i)?i:Yc(e,i)});return{calculatedDuration:t,next:c=>(o.value=a(c),o.done=c>=t,o)}}const Jc=t=>t!==null;function Ks(t,{repeat:e,repeatType:n="loop"},s,i=1){const o=t.filter(Jc),a=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Zc={decay:cs,inertia:cs,tween:we,keyframes:we,spring:jn};function ho(t){typeof t.type=="string"&&(t.type=Zc[t.type])}class Hs{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 Qc=t=>t/100;class Gs extends Hs{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==mt.now()&&this.tick(mt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;ho(e);const{type:n=we,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const c=n||we;process.env.NODE_ENV!=="production"&&c!==we&&Ot(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),c!==we&&typeof a[0]!="number"&&(this.mixKeyframes=nn(Qc,co(a[0],a[1])),a=[0,100]);const u=c({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-r})),u.calculatedDuration===null&&(u.calculatedDuration=Ws(u));const{calculatedDuration:l}=u;this.calculatedDuration=l,this.resolvedDuration=l+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:l,repeat:d,repeatType:f,repeatDelay:g,type:x,onUpdate:v,finalKeyframe:A}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const y=this.currentTime-u*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?y<0:y>i;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let T=this.currentTime,D=s;if(d){const R=Math.min(this.currentTime,i)/a;let $=Math.floor(R),q=R%1;!q&&R>=1&&(q=1),q===1&&$--,$=Math.min($,d+1),!!($%2)&&(f==="reverse"?(q=1-q,g&&(q-=g/a)):f==="mirror"&&(D=r)),T=Lt(0,1,q)*a}const j=w?{done:!1,value:l[0]}:D.next(T);o&&(j.value=o(j.value));let{done:E}=j;!w&&c!==null&&(E=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const O=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&E);return O&&x!==cs&&(j.value=Ks(l,this.options,A,this.speed)),v&&v(j.value),O&&this.finish(),j}then(e,n){return this.finished.then(e,n)}get duration(){return bt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(this.currentTime)}set time(e){e=Ct(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(mt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=bt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Lc,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(mt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function tl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const ce=t=>t*180/Math.PI,ls=t=>{const e=ce(Math.atan2(t[1],t[0]));return us(e)},el={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:ls,rotateZ:ls,skewX:t=>ce(Math.atan(t[1])),skewY:t=>ce(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},us=t=>(t=t%360,t<0&&(t+=360),t),ji=ls,Ei=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),ki=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),nl={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ei,scaleY:ki,scale:t=>(Ei(t)+ki(t))/2,rotateX:t=>us(ce(Math.atan2(t[6],t[5]))),rotateY:t=>us(ce(Math.atan2(-t[2],t[0]))),rotateZ:ji,rotate:ji,skewX:t=>ce(Math.atan(t[4])),skewY:t=>ce(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function ds(t){return t.includes("scale")?1:0}function hs(t,e){if(!t||t==="none")return ds(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=nl,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=el,i=a}if(!i)return ds(e);const o=s[e],r=i[1].split(",").map(il);return typeof o=="function"?o(r):r[o]}const sl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return hs(n,e)};function il(t){return parseFloat(t.trim())}const Ve=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Re=new Set(Ve),Di=t=>t===De||t===L,rl=new Set(["x","y","z"]),ol=Ve.filter(t=>!rl.has(t));function al(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 le={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})=>hs(e,"x"),y:(t,{transform:e})=>hs(e,"y")};le.translateX=le.x;le.translateY=le.y;const ue=new Set;let fs=!1,ms=!1,ps=!1;function fo(){if(ms){const t=Array.from(ue).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=al(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{s.getValue(o)?.set(r)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}ms=!1,fs=!1,ue.forEach(t=>t.complete(ps)),ue.clear()}function mo(){ue.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ms=!0)})}function cl(){ps=!0,mo(),fo(),ps=!1}class Xs{constructor(e,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(ue.add(this),fs||(fs=!0,H.read(mo),H.resolveKeyframes(fo))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const o=i?.get(),r=e[e.length-1];if(o!==void 0)e[0]=o;else if(s&&n){const a=s.readValue(n,r);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=r),i&&o===void 0&&i.set(e[0])}tl(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ue.delete(this)}cancel(){this.state==="scheduled"&&(ue.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const ll=t=>t.startsWith("--");function ul(t,e,n){ll(e)?t.style.setProperty(e,n):t.style[e]=n}const dl=Ns(()=>window.ScrollTimeline!==void 0),hl={};function fl(t,e){const n=Ns(t);return()=>hl[e]??n()}const po=fl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),_e=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,Vi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:_e([0,.65,.55,1]),circOut:_e([.55,0,1,.45]),backIn:_e([.31,.01,.66,-.59]),backOut:_e([.33,1.53,.69,.99])};function go(t,e){if(t)return typeof t=="function"?po()?lo(t,e):"ease-out":Qr(t)?_e(t):Array.isArray(t)?t.map(n=>go(n,e)||Vi.easeOut):Vi[t]}function ml(t,e,n,{delay:s=0,duration:i=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:c}={},u=void 0){const l={[e]:n};c&&(l.offset=c);const d=go(a,i);Array.isArray(d)&&(l.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(l,f)}function yo(t){return typeof t=="function"&&"applyToOptions"in t}function pl({type:t,...e}){return yo(t)&&po()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class gl extends Hs{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,Ot(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=pl(e);this.animation=ml(n,s,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const l=Ks(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(l):ul(n,s,l),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return bt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=Ct(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&dl()?(this.animation.timeline=e,wt):n(this)}}const xo={anticipate:qr,backInOut:Xr,circInOut:Jr};function yl(t){return t in xo}function xl(t){typeof t.ease=="string"&&yl(t.ease)&&(t.ease=xo[t.ease])}const Ri=10;class vl extends gl{constructor(e){xl(e),ho(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Gs({...r,autoplay:!1}),c=Ct(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-Ri).value,a.sample(c).value,Ri),a.stop()}}const Ni=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Kt.test(t)||t==="0")&&!t.startsWith("url("));function bl(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 wl(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],r=Ni(i,e),a=Ni(o,e);return ke(r===a,`You are trying to animate ${e} from "${i}" to "${o}". "${r?o:i}" is not an animatable value.`,"value-not-animatable"),!r||!a?!1:bl(t)||(n==="spring"||yo(n))&&s}function gs(t){t.duration=0,t.type="keyframes"}const Tl=new Set(["opacity","clipPath","filter","transform"]),Sl=Ns(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Al(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:o,type:r}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=e.owner.getProps();return Sl()&&n&&Tl.has(n)&&(n!=="transform"||!u)&&!c&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const Pl=40;class Cl extends Hs{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:c,motionValue:u,element:l,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=mt.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:c,motionValue:u,element:l,...d},g=l?.KeyframeResolver||Xs;this.keyframeResolver=new g(a,(x,v,A)=>this.onKeyframesResolved(x,v,f,!A),c,u,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:c,isHandoff:u,onUpdate:l}=s;this.resolvedAt=mt.now(),wl(e,o,r,a)||((Ft.instantAnimations||!c)&&l?.(Ks(e,s,n)),e[0]=e[e.length-1],gs(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>Pl?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&Al(f)?new vl({...f,element:f.motionValue.owner.current}):new Gs(f);g.finished.then(()=>this.notifyFinished()).catch(wt),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),cl()),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 Ml=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function jl(t){const e=Ml.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const El=4;function vo(t,e,n=1){Ot(n<=El,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=jl(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const r=o.trim();return $r(r)?parseFloat(r):r}return $s(i)?vo(i,e,n+1):i}function qs(t,e){return t?.[e]??t?.default??t}const bo=new Set(["width","height","top","left","right","bottom",...Ve]),kl={test:t=>t==="auto",parse:t=>t},wo=t=>e=>e.test(t),To=[De,L,Dt,_t,bc,vc,kl],Ii=t=>To.find(wo(t));function Dl(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Ur(t):!0}const Vl=new Set(["brightness","contrast","saturate","opacity"]);function Rl(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(zs)||[];if(!s)return t;const i=n.replace(s,"");let o=Vl.has(e)?1:0;return s!==n&&(o*=100),e+"("+o+i+")"}const Nl=/\b([a-z-]*)\(.*?\)/gu,ys={...Kt,getAnimatableNone:t=>{const e=t.match(Nl);return e?e.map(Rl).join(" "):t}},Li={...De,transform:Math.round},Il={rotate:_t,rotateX:_t,rotateY:_t,rotateZ:_t,scale:pn,scaleX:pn,scaleY:pn,scaleZ:pn,skew:_t,skewX:_t,skewY:_t,distance:L,translateX:L,translateY:L,translateZ:L,x:L,y:L,z:L,perspective:L,transformPerspective:L,opacity:Je,originX:Si,originY:Si,originZ:L},Ys={borderWidth:L,borderTopWidth:L,borderRightWidth:L,borderBottomWidth:L,borderLeftWidth:L,borderRadius:L,radius:L,borderTopLeftRadius:L,borderTopRightRadius:L,borderBottomRightRadius:L,borderBottomLeftRadius:L,width:L,maxWidth:L,height:L,maxHeight:L,top:L,right:L,bottom:L,left:L,padding:L,paddingTop:L,paddingRight:L,paddingBottom:L,paddingLeft:L,margin:L,marginTop:L,marginRight:L,marginBottom:L,marginLeft:L,backgroundPositionX:L,backgroundPositionY:L,...Il,zIndex:Li,fillOpacity:Je,strokeOpacity:Je,numOctaves:Li},Ll={...Ys,color:J,backgroundColor:J,outlineColor:J,fill:J,stroke:J,borderColor:J,borderTopColor:J,borderRightColor:J,borderBottomColor:J,borderLeftColor:J,filter:ys,WebkitFilter:ys},So=t=>Ll[t];function Ao(t,e){let n=So(t);return n!==ys&&(n=Kt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Ol=new Set(["auto","none","0"]);function Fl(t,e,n){let s=0,i;for(;s<t.length&&!i;){const o=t[s];typeof o=="string"&&!Ol.has(o)&&Ze(o).values.length&&(i=t[s]),s++}if(i&&n)for(const o of e)t[o]=Ao(n,i)}class Bl extends Xs{constructor(e,n,s,i,o){super(e,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let u=e[c];if(typeof u=="string"&&(u=u.trim(),$s(u))){const l=vo(u,n.current);l!==void 0&&(e[c]=l),c===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!bo.has(s)||e.length!==2)return;const[i,o]=e,r=Ii(i),a=Ii(o);if(r!==a)if(Di(r)&&Di(a))for(let c=0;c<e.length;c++){const u=e[c];typeof u=="string"&&(e[c]=parseFloat(u))}else le[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||Dl(e[i]))&&s.push(i);s.length&&Fl(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=le[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,r=s[o];s[o]=le[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,c])=>{e.getValue(a).set(c)}),this.resolveNoneKeyframes()}}function $l(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const Po=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Co(t){return zr(t)&&"offsetHeight"in t}const Oi=30,zl=t=>!isNaN(parseFloat(t));class Ul{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=mt.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=mt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=zl(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&Ls(!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 Is);const s=this.events[e].add(n);return e==="change"?()=>{s(),H.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=mt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Oi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Oi);return _r(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function je(t,e){return new Ul(t,e)}const{schedule:Js}=to(queueMicrotask,!1),At={x:!1,y:!1};function Mo(){return At.x||At.y}function _l(t){return t==="x"||t==="y"?At[t]?null:(At[t]=!0,()=>{At[t]=!1}):At.x||At.y?null:(At.x=At.y=!0,()=>{At.x=At.y=!1})}function jo(t,e){const n=$l(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function Fi(t){return!(t.pointerType==="touch"||Mo())}function Wl(t,e,n={}){const[s,i,o]=jo(t,n),r=a=>{if(!Fi(a))return;const{target:c}=a,u=e(c,a);if(typeof u!="function"||!c)return;const l=d=>{Fi(d)&&(u(d),c.removeEventListener("pointerleave",l))};c.addEventListener("pointerleave",l,i)};return s.forEach(a=>{a.addEventListener("pointerenter",r,i)}),o}const Eo=(t,e)=>e?t===e?!0:Eo(t,e.parentElement):!1,Zs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Kl=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Hl(t){return Kl.has(t.tagName)||t.tabIndex!==-1}const bn=new WeakSet;function Bi(t){return e=>{e.key==="Enter"&&t(e)}}function Gn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Gl=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=Bi(()=>{if(bn.has(n))return;Gn(n,"down");const i=Bi(()=>{Gn(n,"up")}),o=()=>Gn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function $i(t){return Zs(t)&&!Mo()}function Xl(t,e,n={}){const[s,i,o]=jo(t,n),r=a=>{const c=a.currentTarget;if(!$i(a))return;bn.add(c);const u=e(c,a),l=(g,x)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),bn.has(c)&&bn.delete(c),$i(g)&&typeof u=="function"&&u(g,{success:x})},d=g=>{l(g,c===window||c===document||n.useGlobalTarget||Eo(c,g.target))},f=g=>{l(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,i),Co(a)&&(a.addEventListener("focus",u=>Gl(u,i)),!Hl(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function ko(t){return zr(t)&&"ownerSVGElement"in t}function ql(t){return ko(t)&&t.tagName==="svg"}const at=t=>!!(t&&t.getVelocity),Yl=[...To,J,Kt],Jl=t=>Yl.find(wo(t)),Qs=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function zi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Zl(...t){return e=>{let n=!1;const s=t.map(i=>{const o=zi(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<s.length;i++){const o=s[i];typeof o=="function"?o():zi(t[i],null)}}}}function Ql(...t){return Pt.useCallback(Zl(...t),t)}class tu extends Pt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=Co(s)&&s.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=i-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function eu({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),o=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Qs),c=Ql(o,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:l,top:d,left:f,right:g}=r.current;if(e||!o.current||!u||!l)return;const x=n==="left"?`left: ${f}`:`right: ${g}`;o.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const A=s??document.head;return A.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
1
|
+
"use strict";var za=Object.create;var yi=Object.defineProperty;var Ua=Object.getOwnPropertyDescriptor;var _a=Object.getOwnPropertyNames;var Wa=Object.getPrototypeOf,Ka=Object.prototype.hasOwnProperty;var Ha=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _a(e))!Ka.call(t,i)&&i!==n&&yi(t,i,{get:()=>e[i],enumerable:!(s=Ua(e,i))||s.enumerable});return t};var Ga=(t,e,n)=>(n=t!=null?za(Wa(t)):{},Ha(e||!t||!t.__esModule?yi(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),Z=require("lucide-react"),Ir=require("@ai-sdk/react"),An=require("ai"),Lr=require("@radix-ui/react-slot"),Or=require("class-variance-authority"),Xa=require("clsx"),qa=require("tailwind-merge"),Ya=require("@radix-ui/react-tooltip"),xi=require("@radix-ui/react-use-controllable-state"),Ja=require("@radix-ui/react-collapsible"),Za=require("./server.cjs");function Ms(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Pt=Ms(m),Ce=Ms(Ya),js=Ms(Ja);function it(...t){return qa.twMerge(Xa.clsx(t))}const re=Or.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive active:scale-95",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),Pn=Pt.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},o)=>{const r=s?Lr.Slot:"button";return h.jsx(r,{ref:o,"data-slot":"button",className:it(re({variant:e,size:n,className:t})),...i})});Pn.displayName="Button";const Qa=Or.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 zn({className:t,variant:e,asChild:n=!1,...s}){const i=n?Lr.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:it(Qa({variant:e}),t),...s})}const tc=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,o]=Pt.useState(!0);Pt.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),o(!1)),a.style.height=`${s+6}px`;const c=a.scrollHeight;c>n?a.style.height=`${n}px`:a.style.height=`${c+6}px`}},[t.current,e])},Fr=Pt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...o},r)=>{const a=Pt.useRef(null),[c,u]=Pt.useState("");return tc({textAreaRef:a,triggerAutoSize:c,maxHeight:t,minHeight:e}),m.useImperativeHandle(r,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),Pt.useEffect(()=>{u(i)},[o?.defaultValue,i]),h.jsx("textarea",{...o,value:i,ref:a,className:it("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:l=>{u(l.target.value),s?.(l)}})});Fr.displayName="AutosizeTextarea";function ec({delayDuration:t=0,...e}){return h.jsx(Ce.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function ee({...t}){return h.jsx(ec,{children:h.jsx(Ce.Root,{"data-slot":"tooltip",...t})})}function ne({...t}){return h.jsx(Ce.Trigger,{"data-slot":"tooltip-trigger",...t})}function se({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(Ce.Portal,{children:h.jsxs(Ce.Content,{"data-slot":"tooltip-content",sideOffset:e,className:it("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...s,children:[n,h.jsx(Ce.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function vi({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:it("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",t),...e})}const Es=m.createContext({});function ks(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const Ds=typeof window<"u",Br=Ds?m.useLayoutEffect:m.useEffect,Dn=m.createContext(null);function Vs(t,e){t.indexOf(e)===-1&&t.push(e)}function Rs(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const Lt=(t,e,n)=>n>e?e:n<t?t:n;function is(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let ke=()=>{},Ot=()=>{};process.env.NODE_ENV!=="production"&&(ke=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(is(e,n))},Ot=(t,e,n)=>{if(!t)throw new Error(is(e,n))});const Ft={},$r=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function zr(t){return typeof t=="object"&&t!==null}const Ur=t=>/^0[^.\s]+$/u.test(t);function Ns(t){let e;return()=>(e===void 0&&(e=t()),e)}const wt=t=>t,nc=(t,e)=>n=>e(t(n)),nn=(...t)=>t.reduce(nc),Ye=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class Is{constructor(){this.subscriptions=[]}add(e){return Vs(this.subscriptions,e),()=>Rs(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let o=0;o<i;o++){const r=this.subscriptions[o];r&&r(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Ct=t=>t*1e3,bt=t=>t/1e3;function _r(t,e){return e?t*(1e3/e):0}const bi=new Set;function Ls(t,e,n){t||bi.has(e)||(console.warn(is(e,n)),bi.add(e))}const Wr=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,sc=1e-7,ic=12;function rc(t,e,n,s,i){let o,r,a=0;do r=e+(n-e)/2,o=Wr(r,s,i)-t,o>0?n=r:e=r;while(Math.abs(o)>sc&&++a<ic);return r}function sn(t,e,n,s){if(t===e&&n===s)return wt;const i=o=>rc(o,0,1,t,n);return o=>o===0||o===1?o:Wr(i(o),e,s)}const Kr=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Hr=t=>e=>1-t(1-e),Gr=sn(.33,1.53,.69,.99),Os=Hr(Gr),Xr=Kr(Os),qr=t=>(t*=2)<1?.5*Os(t):.5*(2-Math.pow(2,-10*(t-1))),Fs=t=>1-Math.sin(Math.acos(t)),Yr=Hr(Fs),Jr=Kr(Fs),oc=sn(.42,0,1,1),ac=sn(0,0,.58,1),Zr=sn(.42,0,.58,1),cc=t=>Array.isArray(t)&&typeof t[0]!="number",Qr=t=>Array.isArray(t)&&typeof t[0]=="number",wi={linear:wt,easeIn:oc,easeInOut:Zr,easeOut:ac,circIn:Fs,circInOut:Jr,circOut:Yr,backIn:Os,backInOut:Xr,backOut:Gr,anticipate:qr},lc=t=>typeof t=="string",Ti=t=>{if(Qr(t)){Ot(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return sn(e,n,s,i)}else if(lc(t))return Ot(wi[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),wi[t];return t},mn=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function uc(t,e){let n=new Set,s=new Set,i=!1,o=!1;const r=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function c(l){r.has(l)&&(u.schedule(l),t()),l(a)}const u={schedule:(l,d=!1,f=!1)=>{const x=f&&i?n:s;return d&&r.add(l),x.has(l)||x.add(l),l},cancel:l=>{s.delete(l),r.delete(l)},process:l=>{if(a=l,i){o=!0;return}i=!0,[n,s]=[s,n],n.forEach(c),n.clear(),i=!1,o&&(o=!1,u.process(l))}};return u}const dc=40;function to(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,r=mn.reduce((T,D)=>(T[D]=uc(o),T),{}),{setup:a,read:c,resolveKeyframes:u,preUpdate:l,update:d,preRender:f,render:g,postRender:x}=r,v=()=>{const T=Ft.useManualTiming?i.timestamp:performance.now();n=!1,Ft.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(T-i.timestamp,dc),1)),i.timestamp=T,i.isProcessing=!0,a.process(i),c.process(i),u.process(i),l.process(i),d.process(i),f.process(i),g.process(i),x.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},A=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:mn.reduce((T,D)=>{const j=r[D];return T[D]=(E,O=!1,R=!1)=>(n||A(),j.schedule(E,O,R)),T},{}),cancel:T=>{for(let D=0;D<mn.length;D++)r[mn[D]].cancel(T)},state:i,steps:r}}const{schedule:H,cancel:Wt,state:st,steps:Un}=to(typeof requestAnimationFrame<"u"?requestAnimationFrame:wt,!0);let vn;function hc(){vn=void 0}const mt={now:()=>(vn===void 0&&mt.set(st.isProcessing||Ft.useManualTiming?st.timestamp:performance.now()),vn),set:t=>{vn=t,queueMicrotask(hc)}},eo=t=>e=>typeof e=="string"&&e.startsWith(t),Bs=eo("--"),fc=eo("var(--"),$s=t=>fc(t)?mc.test(t.split("/*")[0].trim()):!1,mc=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,De={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Je={...De,transform:t=>Lt(0,1,t)},pn={...De,default:1},We=t=>Math.round(t*1e5)/1e5,zs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function pc(t){return t==null}const gc=/^(?:#[\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"&&gc.test(n)&&n.startsWith(t)||e&&!pc(n)&&Object.prototype.hasOwnProperty.call(n,e)),no=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,o,r,a]=s.match(zs);return{[t]:parseFloat(i),[e]:parseFloat(o),[n]:parseFloat(r),alpha:a!==void 0?parseFloat(a):1}},yc=t=>Lt(0,255,t),_n={...De,transform:t=>Math.round(yc(t))},ae={test:Us("rgb","red"),parse:no("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+_n.transform(t)+", "+_n.transform(e)+", "+_n.transform(n)+", "+We(Je.transform(s))+")"};function xc(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 rs={test:Us("#"),parse:xc,transform:ae.transform},rn=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),_t=rn("deg"),Dt=rn("%"),I=rn("px"),vc=rn("vh"),bc=rn("vw"),Si={...Dt,parse:t=>Dt.parse(t)/100,transform:t=>Dt.transform(t*100)},be={test:Us("hsl","hue"),parse:no("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+Dt.transform(We(e))+", "+Dt.transform(We(n))+", "+We(Je.transform(s))+")"},J={test:t=>ae.test(t)||rs.test(t)||be.test(t),parse:t=>ae.test(t)?ae.parse(t):be.test(t)?be.parse(t):rs.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ae.transform(t):be.transform(t),getAnimatableNone:t=>{const e=J.parse(t);return e.alpha=0,J.transform(e)}},wc=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Tc(t){return isNaN(t)&&typeof t=="string"&&(t.match(zs)?.length||0)+(t.match(wc)?.length||0)>0}const so="number",io="color",Sc="var",Ac="var(",Ai="${}",Pc=/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 Ze(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let o=0;const a=e.replace(Pc,c=>(J.test(c)?(s.color.push(o),i.push(io),n.push(J.parse(c))):c.startsWith(Ac)?(s.var.push(o),i.push(Sc),n.push(c)):(s.number.push(o),i.push(so),n.push(parseFloat(c))),++o,Ai)).split(Ai);return{values:n,split:a,indexes:s,types:i}}function ro(t){return Ze(t).values}function oo(t){const{split:e,types:n}=Ze(t),s=e.length;return i=>{let o="";for(let r=0;r<s;r++)if(o+=e[r],i[r]!==void 0){const a=n[r];a===so?o+=We(i[r]):a===io?o+=J.transform(i[r]):o+=i[r]}return o}}const Cc=t=>typeof t=="number"?0:J.test(t)?J.getAnimatableNone(t):t;function Mc(t){const e=ro(t);return oo(t)(e.map(Cc))}const Kt={test:Tc,parse:ro,createTransformer:oo,getAnimatableNone:Mc};function Wn(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 jc({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,o=0,r=0;if(!e)i=o=r=n;else{const a=n<.5?n*(1+e):n+e-n*e,c=2*n-a;i=Wn(c,a,t+1/3),o=Wn(c,a,t),r=Wn(c,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(r*255),alpha:s}}function Cn(t,e){return n=>n>0?e:t}const X=(t,e,n)=>t+(e-t)*n,Kn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},Ec=[rs,ae,be],kc=t=>Ec.find(e=>e.test(t));function Pi(t){const e=kc(t);if(ke(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===be&&(n=jc(n)),n}const Ci=(t,e)=>{const n=Pi(t),s=Pi(e);if(!n||!s)return Cn(t,e);const i={...n};return o=>(i.red=Kn(n.red,s.red,o),i.green=Kn(n.green,s.green,o),i.blue=Kn(n.blue,s.blue,o),i.alpha=X(n.alpha,s.alpha,o),ae.transform(i))},os=new Set(["none","hidden"]);function Dc(t,e){return os.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function Vc(t,e){return n=>X(t,e,n)}function _s(t){return typeof t=="number"?Vc:typeof t=="string"?$s(t)?Cn:J.test(t)?Ci:Ic:Array.isArray(t)?ao:typeof t=="object"?J.test(t)?Ci:Rc:Cn}function ao(t,e){const n=[...t],s=n.length,i=t.map((o,r)=>_s(o)(o,e[r]));return o=>{for(let r=0;r<s;r++)n[r]=i[r](o);return n}}function Rc(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=_s(t[i])(t[i],e[i]));return i=>{for(const o in s)n[o]=s[o](i);return n}}function Nc(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const o=e.types[i],r=t.indexes[o][s[o]],a=t.values[r]??0;n[i]=a,s[o]++}return n}const Ic=(t,e)=>{const n=Kt.createTransformer(e),s=Ze(t),i=Ze(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?os.has(t)&&!i.values.length||os.has(e)&&!s.values.length?Dc(t,e):nn(ao(Nc(s,i),i.values),n):(ke(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),Cn(t,e))};function co(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?X(t,e,n):_s(t)(t,e)}const Lc=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>H.update(e,n),stop:()=>Wt(e),now:()=>st.isProcessing?st.timestamp:mt.now()}},lo=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let o=0;o<i;o++)s+=Math.round(t(o/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Mn=2e4;function Ws(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Mn;)e+=n,s=t.next(e);return e>=Mn?1/0:e}function Oc(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(Ws(s),Mn);return{type:"keyframes",ease:o=>s.next(i*o).value/e,duration:bt(i)}}const Fc=5;function uo(t,e,n){const s=Math.max(e-Fc,0);return _r(n-t(s),e-s)}const G={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},Hn=.001;function Bc({duration:t=G.duration,bounce:e=G.bounce,velocity:n=G.velocity,mass:s=G.mass}){let i,o;ke(t<=Ct(G.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let r=1-e;r=Lt(G.minDamping,G.maxDamping,r),t=Lt(G.minDuration,G.maxDuration,bt(t)),r<1?(i=u=>{const l=u*r,d=l*t,f=l-n,g=as(u,r),x=Math.exp(-d);return Hn-f/g*x},o=u=>{const d=u*r*t,f=d*n+n,g=Math.pow(r,2)*Math.pow(u,2)*t,x=Math.exp(-d),v=as(Math.pow(u,2),r);return(-i(u)+Hn>0?-1:1)*((f-g)*x)/v}):(i=u=>{const l=Math.exp(-u*t),d=(u-n)*t+1;return-Hn+l*d},o=u=>{const l=Math.exp(-u*t),d=(n-u)*(t*t);return l*d});const a=5/t,c=zc(i,o,a);if(t=Ct(t),isNaN(c))return{stiffness:G.stiffness,damping:G.damping,duration:t};{const u=Math.pow(c,2)*s;return{stiffness:u,damping:r*2*Math.sqrt(s*u),duration:t}}}const $c=12;function zc(t,e,n){let s=n;for(let i=1;i<$c;i++)s=s-t(s)/e(s);return s}function as(t,e){return t*Math.sqrt(1-e*e)}const Uc=["duration","bounce"],_c=["stiffness","damping","mass"];function Mi(t,e){return e.some(n=>t[n]!==void 0)}function Wc(t){let e={velocity:G.velocity,stiffness:G.stiffness,damping:G.damping,mass:G.mass,isResolvedFromDuration:!1,...t};if(!Mi(t,_c)&&Mi(t,Uc))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,o=2*Lt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:G.mass,stiffness:i,damping:o}}else{const n=Bc(t);e={...e,...n,mass:G.mass},e.isResolvedFromDuration=!0}return e}function jn(t=G.visualDuration,e=G.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const o=n.keyframes[0],r=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:c,damping:u,mass:l,duration:d,velocity:f,isResolvedFromDuration:g}=Wc({...n,velocity:-bt(n.velocity||0)}),x=f||0,v=u/(2*Math.sqrt(c*l)),A=r-o,y=bt(Math.sqrt(c/l)),w=Math.abs(A)<5;s||(s=w?G.restSpeed.granular:G.restSpeed.default),i||(i=w?G.restDelta.granular:G.restDelta.default);let T;if(v<1){const j=as(y,v);T=E=>{const O=Math.exp(-v*y*E);return r-O*((x+v*y*A)/j*Math.sin(j*E)+A*Math.cos(j*E))}}else if(v===1)T=j=>r-Math.exp(-y*j)*(A+(x+y*A)*j);else{const j=y*Math.sqrt(v*v-1);T=E=>{const O=Math.exp(-v*y*E),R=Math.min(j*E,300);return r-O*((x+v*y*A)*Math.sinh(R)+j*A*Math.cosh(R))/j}}const D={calculatedDuration:g&&d||null,next:j=>{const E=T(j);if(g)a.done=j>=d;else{let O=j===0?x:0;v<1&&(O=j===0?Ct(x):uo(T,j,E));const R=Math.abs(O)<=s,$=Math.abs(r-E)<=i;a.done=R&&$}return a.value=a.done?r:E,a},toString:()=>{const j=Math.min(Ws(D),Mn),E=lo(O=>D.next(j*O).value,j,30);return j+"ms "+E},toTransition:()=>{}};return D}jn.applyToOptions=t=>{const e=Oc(t,100,jn);return t.ease=e.ease,t.duration=Ct(e.duration),t.type="keyframes",t};function cs({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:r,min:a,max:c,restDelta:u=.5,restSpeed:l}){const d=t[0],f={done:!1,value:d},g=R=>a!==void 0&&R<a||c!==void 0&&R>c,x=R=>a===void 0?c:c===void 0||Math.abs(a-R)<Math.abs(c-R)?a:c;let v=n*e;const A=d+v,y=r===void 0?A:r(A);y!==A&&(v=y-d);const w=R=>-v*Math.exp(-R/s),T=R=>y+w(R),D=R=>{const $=w(R),q=T(R);f.done=Math.abs($)<=u,f.value=f.done?y:q};let j,E;const O=R=>{g(f.value)&&(j=R,E=jn({keyframes:[f.value,x(f.value)],velocity:uo(T,R,f.value),damping:i,stiffness:o,restDelta:u,restSpeed:l}))};return O(0),{calculatedDuration:null,next:R=>{let $=!1;return!E&&j===void 0&&($=!0,D(R),O(R)),j!==void 0&&R>=j?E.next(R-j):(!$&&D(R),f)}}}function Kc(t,e,n){const s=[],i=n||Ft.mix||co,o=t.length-1;for(let r=0;r<o;r++){let a=i(t[r],t[r+1]);if(e){const c=Array.isArray(e)?e[r]||wt:e;a=nn(c,a)}s.push(a)}return s}function Hc(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const o=t.length;if(Ot(o===e.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>e[0];if(o===2&&e[0]===e[1])return()=>e[1];const r=t[0]===t[1];t[0]>t[o-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Kc(e,s,i),c=a.length,u=l=>{if(r&&l<t[0])return e[0];let d=0;if(c>1)for(;d<t.length-2&&!(l<t[d+1]);d++);const f=Ye(t[d],t[d+1],l);return a[d](f)};return n?l=>u(Lt(t[0],t[o-1],l)):u}function Gc(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Ye(0,e,s);t.push(X(n,1,i))}}function Xc(t){const e=[0];return Gc(e,t.length-1),e}function qc(t,e){return t.map(n=>n*e)}function Yc(t,e){return t.map(()=>e||Zr).splice(0,t.length-1)}function we({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=cc(s)?s.map(Ti):Ti(s),o={done:!1,value:e[0]},r=qc(n&&n.length===e.length?n:Xc(e),t),a=Hc(r,e,{ease:Array.isArray(i)?i:Yc(e,i)});return{calculatedDuration:t,next:c=>(o.value=a(c),o.done=c>=t,o)}}const Jc=t=>t!==null;function Ks(t,{repeat:e,repeatType:n="loop"},s,i=1){const o=t.filter(Jc),a=i<0||e&&n!=="loop"&&e%2===1?0:o.length-1;return!a||s===void 0?o[a]:s}const Zc={decay:cs,inertia:cs,tween:we,keyframes:we,spring:jn};function ho(t){typeof t.type=="string"&&(t.type=Zc[t.type])}class Hs{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 Qc=t=>t/100;class Gs extends Hs{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==mt.now()&&this.tick(mt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;ho(e);const{type:n=we,repeat:s=0,repeatDelay:i=0,repeatType:o,velocity:r=0}=e;let{keyframes:a}=e;const c=n||we;process.env.NODE_ENV!=="production"&&c!==we&&Ot(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),c!==we&&typeof a[0]!="number"&&(this.mixKeyframes=nn(Qc,co(a[0],a[1])),a=[0,100]);const u=c({...e,keyframes:a});o==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...a].reverse(),velocity:-r})),u.calculatedDuration===null&&(u.calculatedDuration=Ws(u));const{calculatedDuration:l}=u;this.calculatedDuration=l,this.resolvedDuration=l+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:o,mirroredGenerator:r,resolvedDuration:a,calculatedDuration:c}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:l,repeat:d,repeatType:f,repeatDelay:g,type:x,onUpdate:v,finalKeyframe:A}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const y=this.currentTime-u*(this.playbackSpeed>=0?1:-1),w=this.playbackSpeed>=0?y<0:y>i;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let T=this.currentTime,D=s;if(d){const R=Math.min(this.currentTime,i)/a;let $=Math.floor(R),q=R%1;!q&&R>=1&&(q=1),q===1&&$--,$=Math.min($,d+1),!!($%2)&&(f==="reverse"?(q=1-q,g&&(q-=g/a)):f==="mirror"&&(D=r)),T=Lt(0,1,q)*a}const j=w?{done:!1,value:l[0]}:D.next(T);o&&(j.value=o(j.value));let{done:E}=j;!w&&c!==null&&(E=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const O=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&E);return O&&x!==cs&&(j.value=Ks(l,this.options,A,this.speed)),v&&v(j.value),O&&this.finish(),j}then(e,n){return this.finished.then(e,n)}get duration(){return bt(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(this.currentTime)}set time(e){e=Ct(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(mt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=bt(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=Lc,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(mt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function tl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const ce=t=>t*180/Math.PI,ls=t=>{const e=ce(Math.atan2(t[1],t[0]));return us(e)},el={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:ls,rotateZ:ls,skewX:t=>ce(Math.atan(t[1])),skewY:t=>ce(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},us=t=>(t=t%360,t<0&&(t+=360),t),ji=ls,Ei=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),ki=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),nl={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Ei,scaleY:ki,scale:t=>(Ei(t)+ki(t))/2,rotateX:t=>us(ce(Math.atan2(t[6],t[5]))),rotateY:t=>us(ce(Math.atan2(-t[2],t[0]))),rotateZ:ji,rotate:ji,skewX:t=>ce(Math.atan(t[4])),skewY:t=>ce(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function ds(t){return t.includes("scale")?1:0}function hs(t,e){if(!t||t==="none")return ds(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=nl,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=el,i=a}if(!i)return ds(e);const o=s[e],r=i[1].split(",").map(il);return typeof o=="function"?o(r):r[o]}const sl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return hs(n,e)};function il(t){return parseFloat(t.trim())}const Ve=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Re=new Set(Ve),Di=t=>t===De||t===I,rl=new Set(["x","y","z"]),ol=Ve.filter(t=>!rl.has(t));function al(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 le={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})=>hs(e,"x"),y:(t,{transform:e})=>hs(e,"y")};le.translateX=le.x;le.translateY=le.y;const ue=new Set;let fs=!1,ms=!1,ps=!1;function fo(){if(ms){const t=Array.from(ue).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=al(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([o,r])=>{s.getValue(o)?.set(r)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}ms=!1,fs=!1,ue.forEach(t=>t.complete(ps)),ue.clear()}function mo(){ue.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(ms=!0)})}function cl(){ps=!0,mo(),fo(),ps=!1}class Xs{constructor(e,n,s,i,o,r=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=o,this.isAsync=r}scheduleResolve(){this.state="scheduled",this.isAsync?(ue.add(this),fs||(fs=!0,H.read(mo),H.resolveKeyframes(fo))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const o=i?.get(),r=e[e.length-1];if(o!==void 0)e[0]=o;else if(s&&n){const a=s.readValue(n,r);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=r),i&&o===void 0&&i.set(e[0])}tl(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),ue.delete(this)}cancel(){this.state==="scheduled"&&(ue.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const ll=t=>t.startsWith("--");function ul(t,e,n){ll(e)?t.style.setProperty(e,n):t.style[e]=n}const dl=Ns(()=>window.ScrollTimeline!==void 0),hl={};function fl(t,e){const n=Ns(t);return()=>hl[e]??n()}const po=fl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),_e=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,Vi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:_e([0,.65,.55,1]),circOut:_e([.55,0,1,.45]),backIn:_e([.31,.01,.66,-.59]),backOut:_e([.33,1.53,.69,.99])};function go(t,e){if(t)return typeof t=="function"?po()?lo(t,e):"ease-out":Qr(t)?_e(t):Array.isArray(t)?t.map(n=>go(n,e)||Vi.easeOut):Vi[t]}function ml(t,e,n,{delay:s=0,duration:i=300,repeat:o=0,repeatType:r="loop",ease:a="easeOut",times:c}={},u=void 0){const l={[e]:n};c&&(l.offset=c);const d=go(a,i);Array.isArray(d)&&(l.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:r==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(l,f)}function yo(t){return typeof t=="function"&&"applyToOptions"in t}function pl({type:t,...e}){return yo(t)&&po()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class gl extends Hs{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:o,allowFlatten:r=!1,finalKeyframe:a,onComplete:c}=e;this.isPseudoElement=!!o,this.allowFlatten=r,this.options=e,Ot(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=pl(e);this.animation=ml(n,s,i,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const l=Ks(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(l):ul(n,s,l),this.animation.cancel()}c?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return bt(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+bt(e)}get time(){return bt(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=Ct(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&dl()?(this.animation.timeline=e,wt):n(this)}}const xo={anticipate:qr,backInOut:Xr,circInOut:Jr};function yl(t){return t in xo}function xl(t){typeof t.ease=="string"&&yl(t.ease)&&(t.ease=xo[t.ease])}const Ri=10;class vl extends gl{constructor(e){xl(e),ho(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:o,...r}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new Gs({...r,autoplay:!1}),c=Ct(this.finishedTime??this.time);n.setWithVelocity(a.sample(c-Ri).value,a.sample(c).value,Ri),a.stop()}}const Ni=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Kt.test(t)||t==="0")&&!t.startsWith("url("));function bl(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 wl(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const o=t[t.length-1],r=Ni(i,e),a=Ni(o,e);return ke(r===a,`You are trying to animate ${e} from "${i}" to "${o}". "${r?o:i}" is not an animatable value.`,"value-not-animatable"),!r||!a?!1:bl(t)||(n==="spring"||yo(n))&&s}function gs(t){t.duration=0,t.type="keyframes"}const Tl=new Set(["opacity","clipPath","filter","transform"]),Sl=Ns(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Al(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:o,type:r}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=e.owner.getProps();return Sl()&&n&&Tl.has(n)&&(n!=="transform"||!u)&&!c&&!s&&i!=="mirror"&&o!==0&&r!=="inertia"}const Pl=40;class Cl extends Hs{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:r="loop",keyframes:a,name:c,motionValue:u,element:l,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=mt.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:o,repeatType:r,name:c,motionValue:u,element:l,...d},g=l?.KeyframeResolver||Xs;this.keyframeResolver=new g(a,(x,v,A)=>this.onKeyframesResolved(x,v,f,!A),c,u,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:o,type:r,velocity:a,delay:c,isHandoff:u,onUpdate:l}=s;this.resolvedAt=mt.now(),wl(e,o,r,a)||((Ft.instantAnimations||!c)&&l?.(Ks(e,s,n)),e[0]=e[e.length-1],gs(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>Pl?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&Al(f)?new vl({...f,element:f.motionValue.owner.current}):new Gs(f);g.finished.then(()=>this.notifyFinished()).catch(wt),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),cl()),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 Ml=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function jl(t){const e=Ml.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const El=4;function vo(t,e,n=1){Ot(n<=El,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=jl(t);if(!s)return;const o=window.getComputedStyle(e).getPropertyValue(s);if(o){const r=o.trim();return $r(r)?parseFloat(r):r}return $s(i)?vo(i,e,n+1):i}function qs(t,e){return t?.[e]??t?.default??t}const bo=new Set(["width","height","top","left","right","bottom",...Ve]),kl={test:t=>t==="auto",parse:t=>t},wo=t=>e=>e.test(t),To=[De,I,Dt,_t,bc,vc,kl],Ii=t=>To.find(wo(t));function Dl(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Ur(t):!0}const Vl=new Set(["brightness","contrast","saturate","opacity"]);function Rl(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(zs)||[];if(!s)return t;const i=n.replace(s,"");let o=Vl.has(e)?1:0;return s!==n&&(o*=100),e+"("+o+i+")"}const Nl=/\b([a-z-]*)\(.*?\)/gu,ys={...Kt,getAnimatableNone:t=>{const e=t.match(Nl);return e?e.map(Rl).join(" "):t}},Li={...De,transform:Math.round},Il={rotate:_t,rotateX:_t,rotateY:_t,rotateZ:_t,scale:pn,scaleX:pn,scaleY:pn,scaleZ:pn,skew:_t,skewX:_t,skewY:_t,distance:I,translateX:I,translateY:I,translateZ:I,x:I,y:I,z:I,perspective:I,transformPerspective:I,opacity:Je,originX:Si,originY:Si,originZ:I},Ys={borderWidth:I,borderTopWidth:I,borderRightWidth:I,borderBottomWidth:I,borderLeftWidth:I,borderRadius:I,radius:I,borderTopLeftRadius:I,borderTopRightRadius:I,borderBottomRightRadius:I,borderBottomLeftRadius:I,width:I,maxWidth:I,height:I,maxHeight:I,top:I,right:I,bottom:I,left:I,padding:I,paddingTop:I,paddingRight:I,paddingBottom:I,paddingLeft:I,margin:I,marginTop:I,marginRight:I,marginBottom:I,marginLeft:I,backgroundPositionX:I,backgroundPositionY:I,...Il,zIndex:Li,fillOpacity:Je,strokeOpacity:Je,numOctaves:Li},Ll={...Ys,color:J,backgroundColor:J,outlineColor:J,fill:J,stroke:J,borderColor:J,borderTopColor:J,borderRightColor:J,borderBottomColor:J,borderLeftColor:J,filter:ys,WebkitFilter:ys},So=t=>Ll[t];function Ao(t,e){let n=So(t);return n!==ys&&(n=Kt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const Ol=new Set(["auto","none","0"]);function Fl(t,e,n){let s=0,i;for(;s<t.length&&!i;){const o=t[s];typeof o=="string"&&!Ol.has(o)&&Ze(o).values.length&&(i=t[s]),s++}if(i&&n)for(const o of e)t[o]=Ao(n,i)}class Bl extends Xs{constructor(e,n,s,i,o){super(e,n,s,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let u=e[c];if(typeof u=="string"&&(u=u.trim(),$s(u))){const l=vo(u,n.current);l!==void 0&&(e[c]=l),c===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!bo.has(s)||e.length!==2)return;const[i,o]=e,r=Ii(i),a=Ii(o);if(r!==a)if(Di(r)&&Di(a))for(let c=0;c<e.length;c++){const u=e[c];typeof u=="string"&&(e[c]=parseFloat(u))}else le[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||Dl(e[i]))&&s.push(i);s.length&&Fl(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=le[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,r=s[o];s[o]=le[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=r),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,c])=>{e.getValue(a).set(c)}),this.resolveNoneKeyframes()}}function $l(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const Po=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Co(t){return zr(t)&&"offsetHeight"in t}const Oi=30,zl=t=>!isNaN(parseFloat(t));class Ul{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=mt.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=mt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=zl(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&Ls(!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 Is);const s=this.events[e].add(n);return e==="change"?()=>{s(),H.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=mt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Oi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Oi);return _r(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function je(t,e){return new Ul(t,e)}const{schedule:Js}=to(queueMicrotask,!1),At={x:!1,y:!1};function Mo(){return At.x||At.y}function _l(t){return t==="x"||t==="y"?At[t]?null:(At[t]=!0,()=>{At[t]=!1}):At.x||At.y?null:(At.x=At.y=!0,()=>{At.x=At.y=!1})}function jo(t,e){const n=$l(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function Fi(t){return!(t.pointerType==="touch"||Mo())}function Wl(t,e,n={}){const[s,i,o]=jo(t,n),r=a=>{if(!Fi(a))return;const{target:c}=a,u=e(c,a);if(typeof u!="function"||!c)return;const l=d=>{Fi(d)&&(u(d),c.removeEventListener("pointerleave",l))};c.addEventListener("pointerleave",l,i)};return s.forEach(a=>{a.addEventListener("pointerenter",r,i)}),o}const Eo=(t,e)=>e?t===e?!0:Eo(t,e.parentElement):!1,Zs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Kl=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Hl(t){return Kl.has(t.tagName)||t.tabIndex!==-1}const bn=new WeakSet;function Bi(t){return e=>{e.key==="Enter"&&t(e)}}function Gn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Gl=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=Bi(()=>{if(bn.has(n))return;Gn(n,"down");const i=Bi(()=>{Gn(n,"up")}),o=()=>Gn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",o,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function $i(t){return Zs(t)&&!Mo()}function Xl(t,e,n={}){const[s,i,o]=jo(t,n),r=a=>{const c=a.currentTarget;if(!$i(a))return;bn.add(c);const u=e(c,a),l=(g,x)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),bn.has(c)&&bn.delete(c),$i(g)&&typeof u=="function"&&u(g,{success:x})},d=g=>{l(g,c===window||c===document||n.useGlobalTarget||Eo(c,g.target))},f=g=>{l(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",r,i),Co(a)&&(a.addEventListener("focus",u=>Gl(u,i)),!Hl(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function ko(t){return zr(t)&&"ownerSVGElement"in t}function ql(t){return ko(t)&&t.tagName==="svg"}const at=t=>!!(t&&t.getVelocity),Yl=[...To,J,Kt],Jl=t=>Yl.find(wo(t)),Qs=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function zi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Zl(...t){return e=>{let n=!1;const s=t.map(i=>{const o=zi(i,e);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<s.length;i++){const o=s[i];typeof o=="function"?o():zi(t[i],null)}}}}function Ql(...t){return Pt.useCallback(Zl(...t),t)}class tu extends Pt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=Co(s)&&s.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=i-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function eu({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),o=m.useRef(null),r=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Qs),c=Ql(o,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:l,top:d,left:f,right:g}=r.current;if(e||!o.current||!u||!l)return;const x=n==="left"?`left: ${f}`:`right: ${g}`;o.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const A=s??document.head;return A.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
2
2
|
[data-motion-pop-id="${i}"] {
|
|
3
3
|
position: absolute !important;
|
|
4
4
|
width: ${u}px !important;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
${x}px !important;
|
|
7
7
|
top: ${d}px !important;
|
|
8
8
|
}
|
|
9
|
-
`),()=>{A.contains(v)&&A.removeChild(v)}},[e]),h.jsx(tu,{isPresent:e,childRef:o,sizeRef:r,children:Pt.cloneElement(t,{ref:c})})}const nu=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:r,anchorX:a,root:c})=>{const u=ks(su),l=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:l,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const x of u.values())if(!x)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return o&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,x)=>u.set(x,!1))},[n]),Pt.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),r==="popLayout"&&(t=h.jsx(eu,{isPresent:n,anchorX:a,root:c,children:t})),h.jsx(Dn.Provider,{value:f,children:t})};function su(){return new Map}function Do(t=!0){const e=m.useContext(Dn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,o=m.useId();m.useEffect(()=>{if(t)return i(o)},[t]);const r=m.useCallback(()=>t&&s&&s(o),[o,s,t]);return!n&&s?[!1,r]:[!0]}const gn=t=>t.key||"";function Ui(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const iu=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:a="left",root:c})=>{const[u,l]=Do(r),d=m.useMemo(()=>Ui(t),[t]),f=r&&!u?[]:d.map(gn),g=m.useRef(!0),x=m.useRef(d),v=ks(()=>new Map),[A,y]=m.useState(d),[w,T]=m.useState(d);Br(()=>{g.current=!1,x.current=d;for(let E=0;E<w.length;E++){const O=gn(w[E]);f.includes(O)?v.delete(O):v.get(O)!==!0&&v.set(O,!1)}},[w,f.length,f.join("-")]);const D=[];if(d!==A){let E=[...d];for(let O=0;O<w.length;O++){const R=w[O],$=gn(R);f.includes($)||(E.splice(O,0,R),D.push(R))}return o==="wait"&&D.length&&(E=D),T(Ui(E)),y(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&w.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:j}=m.useContext(Es);return h.jsx(h.Fragment,{children:w.map(E=>{const O=gn(E),R=r&&!u?!1:d===w||f.includes(O),$=()=>{if(v.has(O))v.set(O,!0);else return;let q=!0;v.forEach(Q=>{Q||(q=!1)}),q&&(j?.(),T(x.current),r&&l?.(),s&&s())};return h.jsx(nu,{isPresent:R,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:o,root:c,onExitComplete:R?void 0:$,anchorX:a,children:E},O)})})},ti=m.createContext({strict:!1}),_i={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Ee={};for(const t in _i)Ee[t]={isEnabled:e=>_i[t].some(n=>!!e[n])};function xs(t){for(const e in t)Ee[e]={...Ee[e],...t[e]}}function ru({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!Xn(e)),i=m.useRef(void 0);if(!Xn(e)){const{renderer:o,...r}=e;i.current=o,xs(r)}return m.useEffect(()=>{Xn(e)&&e().then(({renderer:o,...r})=>{xs(r),i.current=o,s(!0)})},[]),h.jsx(ti.Provider,{value:{renderer:i.current,strict:n},children:t})}function Xn(t){return typeof t=="function"}const ou=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function En(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||ou.has(t)}let Vo=t=>!En(t);function au(t){typeof t=="function"&&(Vo=e=>e.startsWith("on")?!En(e):t(e))}try{au(require("@emotion/is-prop-valid").default)}catch{}function cu(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(Vo(i)||n===!0&&En(i)||!e&&!En(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const Vn=m.createContext({});function Rn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Qe(t){return typeof t=="string"||Array.isArray(t)}const ei=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],ni=["initial",...ei];function Nn(t){return Rn(t.animate)||ni.some(e=>Qe(t[e]))}function Ro(t){return!!(Nn(t)||t.variants)}function lu(t,e){if(Nn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Qe(n)?n:void 0,animate:Qe(s)?s:void 0}}return t.inherit!==!1?e:{}}function uu(t){const{initial:e,animate:n}=lu(t,m.useContext(Vn));return m.useMemo(()=>({initial:e,animate:n}),[Wi(e),Wi(n)])}function Wi(t){return Array.isArray(t)?t.join(" "):t}const tn={};function du(t){for(const e in t)tn[e]=t[e],Bs(e)&&(tn[e].isCSSVariable=!0)}function No(t,{layout:e,layoutId:n}){return Re.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!tn[t]||t==="opacity")}const hu={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},fu=Ve.length;function mu(t,e,n){let s="",i=!0;for(let o=0;o<fu;o++){const r=Ve[o],a=t[r];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(r.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const u=Po(a,Ys[r]);if(!c){i=!1;const l=hu[r]||r;s+=`${l}(${u}) `}n&&(e[r]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function si(t,e,n){const{style:s,vars:i,transformOrigin:o}=t;let r=!1,a=!1;for(const c in e){const u=e[c];if(Re.has(c)){r=!0;continue}else if(Bs(c)){i[c]=u;continue}else{const l=Po(u,Ys[c]);c.startsWith("origin")?(a=!0,o[c]=l):s[c]=l}}if(e.transform||(r||n?s.transform=mu(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:c="50%",originY:u="50%",originZ:l=0}=o;s.transformOrigin=`${c} ${u} ${l}`}}const ii=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Io(t,e,n){for(const s in e)!at(e[s])&&!No(s,n)&&(t[s]=e[s])}function pu({transformTemplate:t},e){return m.useMemo(()=>{const n=ii();return si(n,e,t),Object.assign({},n.vars,n.style)},[e])}function gu(t,e){const n=t.style||{},s={};return Io(s,n,t),Object.assign(s,pu(t,e)),s}function yu(t,e){const n={},s=gu(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 xu={offset:"stroke-dashoffset",array:"stroke-dasharray"},vu={offset:"strokeDashoffset",array:"strokeDasharray"};function bu(t,e,n=1,s=0,i=!0){t.pathLength=1;const o=i?xu:vu;t[o.offset]=L.transform(-s);const r=L.transform(e),a=L.transform(n);t[o.array]=`${r} ${a}`}function Lo(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...a},c,u,l){if(si(t,a,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=l?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&bu(d,i,o,r,!1)}const Oo=()=>({...ii(),attrs:{}}),Fo=t=>typeof t=="string"&&t.toLowerCase()==="svg";function wu(t,e,n,s){const i=m.useMemo(()=>{const o=Oo();return Lo(o,e,Fo(s),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};Io(o,t.style,t),i.style={...o,...i.style}}return i}const Tu=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function ri(t){return typeof t!="string"||t.includes("-")?!1:!!(Tu.indexOf(t)>-1||/[A-Z]/u.test(t))}function Su(t,e,n,{latestValues:s},i,o=!1){const a=(ri(t)?wu:yu)(e,s,i,t),c=cu(e,typeof t=="string",o),u=t!==m.Fragment?{...c,...a,ref:n}:{},{children:l}=e,d=m.useMemo(()=>at(l)?l.get():l,[l]);return m.createElement(t,{...u,children:d})}function Ki(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function oi(t,e,n,s){if(typeof e=="function"){const[i,o]=Ki(s);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=Ki(s);e=e(n!==void 0?n:t.custom,i,o)}return e}function wn(t){return at(t)?t.get():t}function Au({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:Pu(n,s,i,t),renderState:e()}}function Pu(t,e,n,s){const i={},o=s(t,{});for(const f in o)i[f]=wn(o[f]);let{initial:r,animate:a}=t;const c=Nn(t),u=Ro(t);e&&u&&!c&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let l=n?n.initial===!1:!1;l=l||r===!1;const d=l?a:r;if(d&&typeof d!="boolean"&&!Rn(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const x=oi(t,f[g]);if(x){const{transitionEnd:v,transition:A,...y}=x;for(const w in y){let T=y[w];if(Array.isArray(T)){const D=l?T.length-1:0;T=T[D]}T!==null&&(i[w]=T)}for(const w in v)i[w]=v[w]}}}return i}const Bo=t=>(e,n)=>{const s=m.useContext(Vn),i=m.useContext(Dn),o=()=>Au(t,e,s,i);return n?o():ks(o)};function ai(t,e,n){const{style:s}=t,i={};for(const o in s)(at(s[o])||e.style&&at(e.style[o])||No(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}const Cu=Bo({scrapeMotionValuesFromProps:ai,createRenderState:ii});function $o(t,e,n){const s=ai(t,e,n);for(const i in t)if(at(t[i])||at(e[i])){const o=Ve.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=t[i]}return s}const Mu=Bo({scrapeMotionValuesFromProps:$o,createRenderState:Oo}),ju=Symbol.for("motionComponentSymbol");function Te(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Eu(t,e,n){return m.useCallback(s=>{s&&t.onMount&&t.onMount(s),e&&(s?e.mount(s):e.unmount()),n&&(typeof n=="function"?n(s):Te(n)&&(n.current=s))},[e])}const ci=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),ku="framerAppearId",zo="data-"+ci(ku),Uo=m.createContext({});function Du(t,e,n,s,i){const{visualElement:o}=m.useContext(Vn),r=m.useContext(ti),a=m.useContext(Dn),c=m.useContext(Qs).reducedMotion,u=m.useRef(null);s=s||r.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const l=u.current,d=m.useContext(Uo);l&&!l.projection&&i&&(l.type==="html"||l.type==="svg")&&Vu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{l&&f.current&&l.update(n,a)});const g=n[zo],x=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return Br(()=>{l&&(f.current=!0,window.MotionIsMounted=!0,l.updateFeatures(),l.scheduleRenderMicrotask(),x.current&&l.animationState&&l.animationState.animateChanges())}),m.useEffect(()=>{l&&(!x.current&&l.animationState&&l.animationState.animateChanges(),x.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),x.current=!1),l.enteringChildren=void 0)}),l}function Vu(t,e,n,s){const{layoutId:i,layout:o,drag:r,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutCrossfade:l}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:_o(t.parent)),t.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||a&&Te(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:l,layoutScroll:c,layoutRoot:u})}function _o(t){if(t)return t.options.allowProjection!==!1?t.projection:_o(t.parent)}function Tn(t,{forwardMotionProps:e=!1}={},n,s){n&&xs(n);const i=ri(t)?Mu:Cu;function o(a,c){let u;const l={...m.useContext(Qs),...a,layoutId:Ru(a)},{isStatic:d}=l,f=uu(a),g=i(a,d);if(!d&&Ds){Nu(l,n);const x=Iu(l);u=x.MeasureLayout,f.visualElement=Du(t,g,l,s,x.ProjectionNode)}return h.jsxs(Vn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...l}):null,Su(t,a,Eu(g,f.visualElement,c),g,d,e)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const r=m.forwardRef(o);return r[ju]=t,r}function Ru({layoutId:t}){const e=m.useContext(Es).id;return e&&t!==void 0?e+"-"+t:t}function Nu(t,e){const n=m.useContext(ti).strict;if(process.env.NODE_ENV!=="production"&&e&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?ke(!1,s,"lazy-strict-mode"):Ot(!1,s,"lazy-strict-mode")}}function Iu(t){const{drag:e,layout:n}=Ee;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Lu(t,e){if(typeof Proxy>"u")return Tn;const n=new Map,s=(o,r)=>Tn(o,r,t,e),i=(o,r)=>(process.env.NODE_ENV!=="production"&&Ls(!1,"motion() is deprecated. Use motion.create() instead."),s(o,r));return new Proxy(i,{get:(o,r)=>r==="create"?s:(n.has(r)||n.set(r,Tn(r,void 0,t,e)),n.get(r))})}function Wo({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function Ou({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 qn(t){return t===void 0||t===1}function vs({scale:t,scaleX:e,scaleY:n}){return!qn(t)||!qn(e)||!qn(n)}function oe(t){return vs(t)||Ko(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Ko(t){return Hi(t.x)||Hi(t.y)}function Hi(t){return t&&t!=="0%"}function kn(t,e,n){const s=t-n,i=e*s;return n+i}function Gi(t,e,n,s,i){return i!==void 0&&(t=kn(t,i,s)),kn(t,n,s)+e}function bs(t,e=0,n=1,s,i){t.min=Gi(t.min,e,n,s,i),t.max=Gi(t.max,e,n,s,i)}function Ho(t,{x:e,y:n}){bs(t.x,e.translate,e.scale,e.originPoint),bs(t.y,n.translate,n.scale,n.originPoint)}const Xi=.999999999999,qi=1.0000000000001;function Bu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,r;for(let a=0;a<i;a++){o=n[a],r=o.projectionDelta;const{visualElement:c}=o.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&Ae(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,Ho(t,r)),s&&oe(o.latestValues)&&Ae(t,o.latestValues))}e.x<qi&&e.x>Xi&&(e.x=1),e.y<qi&&e.y>Xi&&(e.y=1)}function Se(t,e){t.min=t.min+e,t.max=t.max+e}function Yi(t,e,n,s,i=.5){const o=X(t.min,t.max,i);bs(t,e,n,o,s)}function Ae(t,e){Yi(t.x,e.x,e.scaleX,e.scale,e.originX),Yi(t.y,e.y,e.scaleY,e.scale,e.originY)}function Go(t,e){return Wo(Fu(t.getBoundingClientRect(),e))}function $u(t,e,n){const s=Go(t,n),{scroll:i}=e;return i&&(Se(s.x,i.offset.x),Se(s.y,i.offset.y)),s}const Ji=()=>({translate:0,scale:1,origin:0,originPoint:0}),Pe=()=>({x:Ji(),y:Ji()}),Zi=()=>({min:0,max:0}),Y=()=>({x:Zi(),y:Zi()}),ws={current:null},Xo={current:!1};function zu(){if(Xo.current=!0,!!Ds)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>ws.current=t.matches;t.addEventListener("change",e),e()}else ws.current=!1}const Uu=new WeakMap;function _u(t,e,n){for(const s in e){const i=e[s],o=n[s];if(at(i))t.addValue(s,i);else if(at(o))t.addValue(s,je(i,{owner:t}));else if(o!==i)if(t.hasValue(s)){const r=t.getValue(s);r.liveStyle===!0?r.jump(i):r.hasAnimated||r.set(i)}else{const r=t.getStaticValue(s);t.addValue(s,je(r!==void 0?r:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Qi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Wu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Xs,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=mt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,H.render(this.render,!1,!0))};const{latestValues:c,renderState:u}=r;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=Nn(n),this.isVariantNode=Ro(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:l,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];c[f]!==void 0&&at(g)&&g.set(c[f])}}mount(e){this.current=e,Uu.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)),Xo.current||zu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:ws.current,process.env.NODE_ENV!=="production"&&Ls(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Wt(this.notifyUpdate),Wt(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=Re.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",r=>{this.latestValues[e]=r,this.props.onUpdate&&H.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Ee){const n=Ee[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Y()}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<Qi.length;s++){const i=Qi[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,r=e[o];r&&(this.propEventSubscriptions[i]=this.on(i,r))}this.prevMotionValues=_u(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=je(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&($r(s)||Ur(s))?s=parseFloat(s):!Jl(s)&&Kt.test(n)&&(s=Ao(e,n)),this.setBaseTarget(e,at(s)?s.get():s)),at(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=oi(this.props,n,this.presenceContext?.custom);o&&(s=o[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!at(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 Is),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){Js.render(this.render)}}class qo extends Wu{constructor(){super(...arguments),this.KeyframeResolver=Bl}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;at(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Yo(t,{style:e,vars:n},s,i){const o=t.style;let r;for(r in e)o[r]=e[r];i?.applyProjectionStyles(o,s);for(r in n)o.setProperty(r,n[r])}function Ku(t){return window.getComputedStyle(t)}class Hu extends qo{constructor(){super(...arguments),this.type="html",this.renderInstance=Yo}readValueFromInstance(e,n){if(Re.has(n))return this.projection?.isProjecting?ds(n):sl(e,n);{const s=Ku(e),i=(Bs(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Go(e,n)}build(e,n,s){si(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return ai(e,n,s)}}const Jo=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 Gu(t,e,n,s){Yo(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Jo.has(i)?i:ci(i),e.attrs[i])}class Xu extends qo{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Y}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Re.has(n)){const s=So(n);return s&&s.default||0}return n=Jo.has(n)?n:ci(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return $o(e,n,s)}build(e,n,s){Lo(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Gu(e,n,s,i)}mount(e){this.isSVGTag=Fo(e.tagName),super.mount(e)}}const Zo=(t,e)=>ri(t)?new Xu(e):new Hu(e,{allowProjection:t!==m.Fragment});function Me(t,e,n){const s=t.getProps();return oi(s,e,n!==void 0?n:s.custom,t)}const Ts=t=>Array.isArray(t);function qu(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,je(n))}function Yu(t){return Ts(t)?t[t.length-1]||0:t}function Ju(t,e){const n=Me(t,e);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const a=Yu(o[r]);qu(t,r,a)}}function Zu(t){return!!(at(t)&&t.add)}function Ss(t,e){const n=t.getValue("willChange");if(Zu(n))return n.add(e);if(!n&&Ft.WillChange){const s=new Ft.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Qo(t){return t.props[zo]}const Qu=t=>t!==null;function td(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Qu),o=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[o]}const ed={type:"spring",stiffness:500,damping:25,restSpeed:10},nd=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),sd={type:"keyframes",duration:.8},id={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},rd=(t,{keyframes:e})=>e.length>2?sd:Re.has(t)?t.startsWith("scale")?nd(e[1]):ed:id;function od({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:a,from:c,elapsed:u,...l}){return!!Object.keys(l).length}const li=(t,e,n,s={},i,o)=>r=>{const a=qs(s,t)||{},c=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-Ct(c);const l={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:i};od(a)||Object.assign(l,rd(t,l)),l.duration&&(l.duration=Ct(l.duration)),l.repeatDelay&&(l.repeatDelay=Ct(l.repeatDelay)),l.from!==void 0&&(l.keyframes[0]=l.from);let d=!1;if((l.type===!1||l.duration===0&&!l.repeatDelay)&&(gs(l),l.delay===0&&(d=!0)),(Ft.instantAnimations||Ft.skipAnimations)&&(d=!0,gs(l),l.delay=0),l.allowFlatten=!a.type&&!a.ease,d&&!o&&e.get()!==void 0){const f=td(l.keyframes,a);if(f!==void 0){H.update(()=>{l.onUpdate(f),l.onComplete()});return}}return a.isSync?new Gs(l):new Cl(l)};function ad({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function ta(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:o=t.getDefaultTransition(),transitionEnd:r,...a}=e;s&&(o=s);const c=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const l in a){const d=t.getValue(l,t.latestValues[l]??null),f=a[l];if(f===void 0||u&&ad(u,l))continue;const g={delay:n,...qs(o||{},l)},x=d.get();if(x!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===x&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const y=Qo(t);if(y){const w=window.MotionHandoffAnimation(y,l,H);w!==null&&(g.startTime=w,v=!0)}}Ss(t,l),d.start(li(l,d,f,t.shouldReduceMotion&&bo.has(l)?{type:!1}:g,t,v));const A=d.animation;A&&c.push(A)}return r&&Promise.all(c).then(()=>{H.update(()=>{r&&Ju(t,r)})}),c}function ea(t,e,n,s=0,i=1){const o=Array.from(t).sort((u,l)=>u.sortNodePosition(l)).indexOf(e),r=t.size,a=(r-1)*s;return typeof n=="function"?n(o,r):i===1?o*s:a-o*s}function As(t,e,n={}){const s=Me(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(ta(t,s,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:l,staggerDirection:d}=i;return cd(t,e,c,u,l,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,u]=a==="beforeChildren"?[o,r]:[r,o];return c().then(()=>u())}else return Promise.all([o(),r(n.delay)])}function cd(t,e,n=0,s=0,i=0,o=1,r){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(As(c,e,{...r,delay:n+(typeof s=="function"?0:s)+ea(t.variantChildren,c,s,i,o)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function ld(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(o=>As(t,o,n));s=Promise.all(i)}else if(typeof e=="string")s=As(t,e,n);else{const i=typeof e=="function"?Me(t,e,n.custom):e;s=Promise.all(ta(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function na(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 ud=ni.length;function sa(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?sa(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<ud;n++){const s=ni[n],i=t.props[s];(Qe(i)||i===!1)&&(e[s]=i)}return e}const dd=[...ei].reverse(),hd=ei.length;function fd(t){return e=>Promise.all(e.map(({animation:n,options:s})=>ld(t,n,s)))}function md(t){let e=fd(t),n=tr(),s=!0;const i=c=>(u,l)=>{const d=Me(t,l,c==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...x}=d;u={...u,...x,...g}}return u};function o(c){e=c(t)}function r(c){const{props:u}=t,l=sa(t.parent)||{},d=[],f=new Set;let g={},x=1/0;for(let A=0;A<hd;A++){const y=dd[A],w=n[y],T=u[y]!==void 0?u[y]:l[y],D=Qe(T),j=y===c?w.isActive:null;j===!1&&(x=A);let E=T===l[y]&&T!==u[y]&&D;if(E&&s&&t.manuallyAnimateOnMount&&(E=!1),w.protectedKeys={...g},!w.isActive&&j===null||!T&&!w.prevProp||Rn(T)||typeof T=="boolean")continue;const O=pd(w.prevProp,T);let R=O||y===c&&w.isActive&&!E&&D||A>x&&D,$=!1;const q=Array.isArray(T)?T:[T];let Q=q.reduce(i(y),{});j===!1&&(Q={});const{prevResolvedValues:z={}}=w,de={...z,...Q},Tt=F=>{R=!0,f.has(F)&&($=!0,f.delete(F)),w.needsAnimating[F]=!0;const ct=t.getValue(F);ct&&(ct.liveStyle=!1)};for(const F in de){const ct=Q[F],lt=z[F];if(g.hasOwnProperty(F))continue;let ut=!1;Ts(ct)&&Ts(lt)?ut=!na(ct,lt):ut=ct!==lt,ut?ct!=null?Tt(F):f.add(F):ct!==void 0&&f.has(F)?Tt(F):w.protectedKeys[F]=!0}w.prevProp=T,w.prevResolvedValues=Q,w.isActive&&(g={...g,...Q}),s&&t.blockInitialAnimation&&(R=!1);const it=E&&O;R&&(!it||$)&&d.push(...q.map(F=>{const ct={type:y};if(typeof F=="string"&&s&&!it&&t.manuallyAnimateOnMount&&t.parent){const{parent:lt}=t,ut=Me(lt,F);if(lt.enteringChildren&&ut){const{delayChildren:dt}=ut.transition||{};ct.delay=ea(lt.enteringChildren,t,dt)}}return{animation:F,options:ct}}))}if(f.size){const A={};if(typeof u.initial!="boolean"){const y=Me(t,Array.isArray(u.initial)?u.initial[0]:u.initial);y&&y.transition&&(A.transition=y.transition)}f.forEach(y=>{const w=t.getBaseTarget(y),T=t.getValue(y);T&&(T.liveStyle=!0),A[y]=w??null}),d.push({animation:A})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(c,u){if(n[c].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(c,u)),n[c].isActive=u;const l=r(c);for(const d in n)n[d].protectedKeys={};return l}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=tr()}}}function pd(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!na(e,t):!1}function ie(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function tr(){return{animate:ie(!0),whileInView:ie(),whileHover:ie(),whileTap:ie(),whileDrag:ie(),whileFocus:ie(),exit:ie()}}class Ht{constructor(e){this.isMounted=!1,this.node=e}update(){}}class gd extends Ht{constructor(e){super(e),e.animationState||(e.animationState=md(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Rn(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let yd=0;class xd extends Ht{constructor(){super(...arguments),this.id=yd++}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 ia={animation:{Feature:gd},exit:{Feature:xd}};function en(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function on(t){return{point:{x:t.pageX,y:t.pageY}}}const vd=t=>e=>Zs(e)&&t(e,on(e));function Ke(t,e,n,s){return en(t,e,vd(n),s)}const ra=1e-4,bd=1-ra,wd=1+ra,oa=.01,Td=0-oa,Sd=0+oa;function ft(t){return t.max-t.min}function Ad(t,e,n){return Math.abs(t-e)<=n}function er(t,e,n,s=.5){t.origin=s,t.originPoint=X(e.min,e.max,t.origin),t.scale=ft(n)/ft(e),t.translate=X(n.min,n.max,t.origin)-t.originPoint,(t.scale>=bd&&t.scale<=wd||isNaN(t.scale))&&(t.scale=1),(t.translate>=Td&&t.translate<=Sd||isNaN(t.translate))&&(t.translate=0)}function He(t,e,n,s){er(t.x,e.x,n.x,s?s.originX:void 0),er(t.y,e.y,n.y,s?s.originY:void 0)}function nr(t,e,n){t.min=n.min+e.min,t.max=t.min+ft(e)}function Pd(t,e,n){nr(t.x,e.x,n.x),nr(t.y,e.y,n.y)}function sr(t,e,n){t.min=e.min-n.min,t.max=t.min+ft(e)}function Ge(t,e,n){sr(t.x,e.x,n.x),sr(t.y,e.y,n.y)}function vt(t){return[t("x"),t("y")]}const aa=({current:t})=>t?t.ownerDocument.defaultView:null,ir=(t,e)=>Math.abs(t-e);function Cd(t,e){const n=ir(t.x,e.x),s=ir(t.y,e.y);return Math.sqrt(n**2+s**2)}class ca{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:r=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=Jn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,x=Cd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!x)return;const{point:v}=f,{timestamp:A}=nt;this.history.push({...v,timestamp:A});const{onStart:y,onMove:w}=this.handlers;g||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Yn(g,this.transformPagePoint),H.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:x,onSessionEnd:v,resumeAnimation:A}=this.handlers;if(this.dragSnapToOrigin&&A&&A(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=Jn(f.type==="pointercancel"?this.lastMoveEventInfo:Yn(g,this.transformPagePoint),this.history);this.startEvent&&x&&x(f,y),v&&v(f,y)},!Zs(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=i||window;const a=on(e),c=Yn(a,this.transformPagePoint),{point:u}=c,{timestamp:l}=nt;this.history=[{...u,timestamp:l}];const{onSessionStart:d}=n;d&&d(e,Jn(c,this.history)),this.removeListeners=nn(Ke(this.contextWindow,"pointermove",this.handlePointerMove),Ke(this.contextWindow,"pointerup",this.handlePointerUp),Ke(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Wt(this.updatePoint)}}function Yn(t,e){return e?{point:e(t.point)}:t}function rr(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Jn({point:t},e){return{point:t,delta:rr(t,la(e)),offset:rr(t,Md(e)),velocity:jd(e,.1)}}function Md(t){return t[0]}function la(t){return t[t.length-1]}function jd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=la(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>Ct(e)));)n--;if(!s)return{x:0,y:0};const o=bt(i.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const r={x:(i.x-s.x)/o,y:(i.y-s.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function Ed(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?X(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?X(n,t,s.max):Math.min(t,n)),t}function or(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 kd(t,{top:e,left:n,bottom:s,right:i}){return{x:or(t.x,n,i),y:or(t.y,e,s)}}function ar(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 Dd(t,e){return{x:ar(t.x,e.x),y:ar(t.y,e.y)}}function Vd(t,e){let n=.5;const s=ft(t),i=ft(e);return i>s?n=Ye(e.min,e.max-s,t.min):s>i&&(n=Ye(t.min,t.max-i,e.min)),Lt(0,1,n)}function Rd(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 Ps=.35;function Nd(t=Ps){return t===!1?t=0:t===!0&&(t=Ps),{x:cr(t,"left","right"),y:cr(t,"top","bottom")}}function cr(t,e,n){return{min:lr(t,e),max:lr(t,n)}}function lr(t,e){return typeof t=="number"?t:t[e]||0}const Id=new WeakMap;class Ld{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=Y(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(on(d).point)},r=(d,f)=>{const{drag:g,dragPropagation:x,onDragStart:v}=this.getProps();if(g&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=_l(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),vt(y=>{let w=this.getAxisMotionValue(y).get()||0;if(Dt.test(w)){const{projection:T}=this.visualElement;if(T&&T.layout){const D=T.layout.layoutBox[y];D&&(w=ft(D)*(parseFloat(w)/100))}}this.originPoint[y]=w}),v&&H.postRender(()=>v(d,f)),Ss(this.visualElement,"transform");const{animationState:A}=this.visualElement;A&&A.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:x,onDirectionLock:v,onDrag:A}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:y}=f;if(x&&this.currentDirection===null){this.currentDirection=Od(y),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),A&&A(d,f)},c=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>vt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:l}=this.getProps();this.panSession=new ca(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:s,contextWindow:aa(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:r}=i;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&H.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||!yn(e,i,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(r=Ed(r,this.constraints[e],this.elastic[e])),o.set(r)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&Te(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=kd(s.layoutBox,e):this.constraints=!1,this.elastic=Nd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&vt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Rd(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Te(e))return!1;const s=e.current;Ot(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=$u(s,i.root,this.visualElement.getTransformPagePoint());let r=Dd(i.layout.layoutBox,o);if(n){const a=n(Ou(r));this.hasMutatedConstraints=!!a,a&&(r=Wo(a))}return r}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=vt(l=>{if(!yn(l,n,this.currentDirection))return;let d=c&&c[l]||{};r&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,x={type:"inertia",velocity:s?e[l]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(l,x)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Ss(this.visualElement,e),s.start(li(e,s,0,n,this.visualElement,!1))}stopAnimation(){vt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){vt(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){vt(n=>{const{drag:s}=this.getProps();if(!yn(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:a}=i.layout.layoutBox[n];o.set(e[n]-X(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Te(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};vt(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const c=a.get();i[r]=Vd({min:c,max:c},this.constraints[r])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),vt(r=>{if(!yn(r,e,null))return;const a=this.getAxisMotionValue(r),{min:c,max:u}=this.constraints[r];a.set(X(c,u,i[r]))})}addListeners(){if(!this.visualElement.current)return;Id.set(this.visualElement,this);const e=this.visualElement.current,n=Ke(e,"pointerdown",c=>{const{drag:u,dragListener:l=!0}=this.getProps();u&&l&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();Te(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,o=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),H.read(s);const r=en(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(vt(l=>{const d=this.getAxisMotionValue(l);d&&(this.originPoint[l]+=c[l].translate,d.set(d.get()+c[l].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=Ps,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function yn(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Od(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 Ht{constructor(e){super(e),this.removeGroupControls=wt,this.removeListeners=wt,this.controls=new Ld(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||wt}unmount(){this.removeGroupControls(),this.removeListeners()}}const ur=t=>(e,n)=>{t&&H.postRender(()=>t(e,n))};class Bd extends Ht{constructor(){super(...arguments),this.removePointerDownListener=wt}onPointerDown(e){this.session=new ca(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:aa(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:ur(e),onStart:ur(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&H.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=Ke(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 Sn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function dr(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Ue={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(L.test(t))t=parseFloat(t);else return t;const n=dr(t,e.target.x),s=dr(t,e.target.y);return`${n}% ${s}%`}},$d={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Kt.parse(t);if(i.length>5)return s;const o=Kt.createTransformer(t),r=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+r]/=a,i[1+r]/=c;const u=X(a,c,.5);return typeof i[2+r]=="number"&&(i[2+r]/=u),typeof i[3+r]=="number"&&(i[3+r]/=u),o(i)}};let Zn=!1;class zd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=e;du(Ud),o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),Zn&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),Sn.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,Zn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||H.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Js.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;Zn=!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 ua(t){const[e,n]=Do(),s=m.useContext(Es);return h.jsx(zd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(Uo),isPresent:e,safeToRemove:n})}const Ud={borderRadius:{...Ue,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ue,borderTopRightRadius:Ue,borderBottomLeftRadius:Ue,borderBottomRightRadius:Ue,boxShadow:$d};function _d(t,e,n){const s=at(t)?t:je(t);return s.start(li("",s,e,n)),s.animation}const Wd=(t,e)=>t.depth-e.depth;class Kd{constructor(){this.children=[],this.isDirty=!1}add(e){Vs(this.children,e),this.isDirty=!0}remove(e){Rs(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Wd),this.isDirty=!1,this.children.forEach(e)}}function Hd(t,e){const n=mt.now(),s=({timestamp:i})=>{const o=i-n;o>=e&&(Wt(s),t(o-e))};return H.setup(s,!0),()=>Wt(s)}const da=["TopLeft","TopRight","BottomLeft","BottomRight"],Gd=da.length,hr=t=>typeof t=="string"?parseFloat(t):t,fr=t=>typeof t=="number"||L.test(t);function Xd(t,e,n,s,i,o){i?(t.opacity=X(0,n.opacity??1,qd(s)),t.opacityExit=X(e.opacity??1,0,Yd(s))):o&&(t.opacity=X(e.opacity??1,n.opacity??1,s));for(let r=0;r<Gd;r++){const a=`border${da[r]}Radius`;let c=mr(e,a),u=mr(n,a);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||fr(c)===fr(u)?(t[a]=Math.max(X(hr(c),hr(u),s),0),(Dt.test(u)||Dt.test(c))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=X(e.rotate||0,n.rotate||0,s))}function mr(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const qd=ha(0,.5,Yr),Yd=ha(.5,.95,wt);function ha(t,e,n){return s=>s<t?0:s>e?1:n(Ye(t,e,s))}function pr(t,e){t.min=e.min,t.max=e.max}function xt(t,e){pr(t.x,e.x),pr(t.y,e.y)}function gr(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function yr(t,e,n,s,i){return t-=e,t=kn(t,1/n,s),i!==void 0&&(t=kn(t,1/i,s)),t}function Jd(t,e=0,n=1,s=.5,i,o=t,r=t){if(Dt.test(e)&&(e=parseFloat(e),e=X(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=X(o.min,o.max,s);t===o&&(a-=e),t.min=yr(t.min,e,n,a,i),t.max=yr(t.max,e,n,a,i)}function xr(t,e,[n,s,i],o,r){Jd(t,e[n],e[s],e[i],e.scale,o,r)}const Zd=["x","scaleX","originX"],Qd=["y","scaleY","originY"];function vr(t,e,n,s){xr(t.x,e,Zd,n?n.x:void 0,s?s.x:void 0),xr(t.y,e,Qd,n?n.y:void 0,s?s.y:void 0)}function br(t){return t.translate===0&&t.scale===1}function fa(t){return br(t.x)&&br(t.y)}function wr(t,e){return t.min===e.min&&t.max===e.max}function th(t,e){return wr(t.x,e.x)&&wr(t.y,e.y)}function Tr(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function ma(t,e){return Tr(t.x,e.x)&&Tr(t.y,e.y)}function Sr(t){return ft(t.x)/ft(t.y)}function Ar(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class eh{constructor(){this.members=[]}add(e){Vs(this.members,e),e.scheduleRender()}remove(e){if(Rs(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function nh(t,e,n){let s="";const i=t.x.translate/e.x,o=t.y.translate/e.y,r=n?.z||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:l,rotateX:d,rotateY:f,skewX:g,skewY:x}=n;u&&(s=`perspective(${u}px) ${s}`),l&&(s+=`rotate(${l}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),x&&(s+=`skewY(${x}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(s+=`scale(${a}, ${c})`),s||"none"}const Qn=["","X","Y","Z"],sh=1e3;let ih=0;function ts(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function pa(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Qo(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",H,!(i||o))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&pa(s)}function ga({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},a=e?.()){this.id=ih++,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(ah),this.nodes.forEach(dh),this.nodes.forEach(hh),this.nodes.forEach(ch)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new Kd)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new Is),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const c=this.eventHandlers.get(r);c&&c.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=ko(r)&&!ql(r),this.instance=r;const{layoutId:a,layout:c,visualElement:u}=this.options;if(u&&!u.current&&u.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let l,d=0;const f=()=>this.root.updateBlockedByResize=!1;H.read(()=>{d=window.innerWidth}),t(r,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,l&&l(),l=Hd(f,250),Sn.hasAnimatedSinceResize&&(Sn.hasAnimatedSinceResize=!1,this.nodes.forEach(Mr)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||c)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||u.getDefaultTransition()||yh,{onLayoutAnimationStart:v,onLayoutAnimationComplete:A}=u.getProps(),y=!this.targetLayout||!ma(this.targetLayout,g),w=!d&&f;if(this.options.layoutRoot||this.resumeFrom||w||d&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const T={...qs(x,"layout"),onPlay:v,onComplete:A};(u.shouldReduceMotion||this.options.layoutRoot)&&(T.delay=0,T.type=!1),this.startAnimation(T),this.setAnimationOrigin(l,w)}else d||Mr(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Wt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(fh),this.animationId++)}getTransformTemplate(){const{visualElement:r}=this.options;return r&&r.getProps().transformTemplate}willUpdate(r=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&pa(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let l=0;l<this.path.length;l++){const d=this.path[l];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Pr);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Cr);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(uh),this.nodes.forEach(rh),this.nodes.forEach(oh)):this.nodes.forEach(Cr),this.clearAllSnapshots();const a=mt.now();nt.delta=Lt(0,1e3/60,a-nt.timestamp),nt.timestamp=a,nt.isProcessing=!0,Un.update.process(nt),Un.preRender.process(nt),Un.render.process(nt),nt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Js.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(lh),this.sharedNodes.forEach(mh)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,H.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){H.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ft(this.snapshot.measuredBox.x)&&!ft(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const r=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Y(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&this.instance){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:r,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const r=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!fa(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,l=u!==this.prevTransformTemplateValue;r&&this.instance&&(a||oe(this.latestValues)||l)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return r&&(c=this.removeTransform(c)),xh(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:r}=this.options;if(!r)return Y();const a=r.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(vh))){const{scroll:u}=this.root;u&&(Se(a.x,u.offset.x),Se(a.y,u.offset.y))}return a}removeElementScroll(r){const a=Y();if(xt(a,r),this.scroll?.wasRoot)return a;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:l,options:d}=u;u!==this.root&&l&&d.layoutScroll&&(l.wasRoot&&xt(a,r),Se(a.x,l.offset.x),Se(a.y,l.offset.y))}return a}applyTransform(r,a=!1){const c=Y();xt(c,r);for(let u=0;u<this.path.length;u++){const l=this.path[u];!a&&l.options.layoutScroll&&l.scroll&&l!==l.root&&Ae(c,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),oe(l.latestValues)&&Ae(c,l.latestValues)}return oe(this.latestValues)&&Ae(c,this.latestValues),c}removeTransform(r){const a=Y();xt(a,r);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!oe(u.latestValues))continue;vs(u.latestValues)&&u.updateSnapshot();const l=Y(),d=u.measurePageBox();xt(l,d),vr(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,l)}return oe(this.latestValues)&&vr(a,this.latestValues),a}setTargetDelta(r){this.targetDelta=r,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(r){this.options={...this.options,...r,crossfade:r.crossfade!==void 0?r.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==nt.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(r||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:l,layoutId:d}=this.options;if(!(!this.layout||!(l||d))){if(this.resolvedRelativeTargetAt=nt.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Y(),this.relativeTargetOrigin=Y(),Ge(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Y(),this.targetWithTransforms=Y()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Pd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):xt(this.target,this.layout.layoutBox),Ho(this.target,this.targetDelta)):xt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Y(),this.relativeTargetOrigin=Y(),Ge(this.relativeTargetOrigin,this.target,f.target),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||vs(this.parent.latestValues)||Ko(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const r=this.getLead(),a=!!this.resumingFrom||this!==r;let c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===nt.timestamp&&(c=!1),c)return;const{layout:u,layoutId:l}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||l))return;xt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;Bu(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=Y());const{target:g}=r;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(gr(this.prevProjectionDelta.x,this.projectionDelta.x),gr(this.prevProjectionDelta.y,this.projectionDelta.y)),He(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Ar(this.projectionDelta.x,this.prevProjectionDelta.x)||!Ar(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){if(this.options.visualElement?.scheduleRender(),r){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Pe(),this.projectionDelta=Pe(),this.projectionDeltaWithTransform=Pe()}setAnimationOrigin(r,a=!1){const c=this.snapshot,u=c?c.latestValues:{},l={...this.latestValues},d=Pe();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=Y(),g=c?c.source:void 0,x=this.layout?this.layout.source:void 0,v=g!==x,A=this.getStack(),y=!A||A.members.length<=1,w=!!(v&&!y&&this.options.crossfade===!0&&!this.path.some(gh));this.animationProgress=0;let T;this.mixTargetDelta=D=>{const j=D/1e3;jr(d.x,r.x,j),jr(d.y,r.y,j),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Ge(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),ph(this.relativeTarget,this.relativeTargetOrigin,f,j),T&&th(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=Y()),xt(T,this.relativeTarget)),v&&(this.animationValues=l,Xd(l,u,this.latestValues,j,w,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=j},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Wt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=H.update(()=>{Sn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=je(0)),this.currentAnimation=_d(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),r.onUpdate&&r.onUpdate(a)},onStop:()=>{},onComplete:()=>{r.onComplete&&r.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const r=this.getStack();r&&r.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(sh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:c,layout:u,latestValues:l}=r;if(!(!a||!c||!u)){if(this!==r&&this.layout&&u&&ya(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||Y();const d=ft(this.layout.layoutBox.x);c.x.min=r.target.x.min,c.x.max=c.x.min+d;const f=ft(this.layout.layoutBox.y);c.y.min=r.target.y.min,c.y.max=c.y.min+f}xt(a,c),Ae(a,l),He(this.projectionDeltaWithTransform,this.layoutCorrected,a,l)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new eh),this.sharedNodes.get(r).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){const{layoutId:r}=this.options;return r?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:r}=this.options;return r?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:c}=r;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const u={};c.z&&ts("z",r,u,this.animationValues);for(let l=0;l<Qn.length;l++)ts(`rotate${Qn[l]}`,r,u,this.animationValues),ts(`skew${Qn[l]}`,r,u,this.animationValues);r.render();for(const l in u)r.setStaticValue(l,u[l]),this.animationValues&&(this.animationValues[l]=u[l]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=wn(a?.pointerEvents)||"",r.transform=c?c(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=wn(a?.pointerEvents)||""),this.hasProjected&&!oe(this.latestValues)&&(r.transform=c?c({},""):"none",this.hasProjected=!1);return}r.visibility="";const l=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=nh(this.projectionDeltaWithTransform,this.treeScale,l);c&&(d=c(l,d)),r.transform=d;const{x:f,y:g}=this.projectionDelta;r.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?r.opacity=u===this?l.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:l.opacityExit:r.opacity=u===this?l.opacity!==void 0?l.opacity:"":l.opacityExit!==void 0?l.opacityExit:0;for(const x in tn){if(l[x]===void 0)continue;const{correct:v,applyTo:A,isCSSVariable:y}=tn[x],w=d==="none"?l[x]:v(l[x],u);if(A){const T=A.length;for(let D=0;D<T;D++)r[A[D]]=w}else y?this.options.visualElement.renderState.vars[x]=w:r[x]=w}this.options.layoutId&&(r.pointerEvents=u===this?wn(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>r.currentAnimation?.stop()),this.root.nodes.forEach(Pr),this.root.sharedNodes.clear()}}}function rh(t){t.updateLayout()}function oh(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(d);d.min=n[l].min,d.max=d.min+f}):ya(i,e.layoutBox,n)&&vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(n[l]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[l].max=t.relativeTarget[l].min+f)});const r=Pe();He(r,n,e.layoutBox);const a=Pe();o?He(a,t.applyTransform(s,!0),e.measuredBox):He(a,n,e.layoutBox);const c=!fa(r);let u=!1;if(!t.resumeFrom){const l=t.getClosestProjectingParent();if(l&&!l.resumeFrom){const{snapshot:d,layout:f}=l;if(d&&f){const g=Y();Ge(g,e.layoutBox,d.layoutBox);const x=Y();Ge(x,n,f.layoutBox),ma(g,x)||(u=!0),l.options.layoutRoot&&(t.relativeTarget=x,t.relativeTargetOrigin=g,t.relativeParent=l)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function ah(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 ch(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function lh(t){t.clearSnapshot()}function Pr(t){t.clearMeasurements()}function Cr(t){t.isLayoutDirty=!1}function uh(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Mr(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function dh(t){t.resolveTargetDelta()}function hh(t){t.calcProjection()}function fh(t){t.resetSkewAndRotation()}function mh(t){t.removeLeadSnapshot()}function jr(t,e,n){t.translate=X(e.translate,0,n),t.scale=X(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Er(t,e,n,s){t.min=X(e.min,n.min,s),t.max=X(e.max,n.max,s)}function ph(t,e,n,s){Er(t.x,e.x,n.x,s),Er(t.y,e.y,n.y,s)}function gh(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const yh={duration:.45,ease:[.4,0,.1,1]},kr=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Dr=kr("applewebkit/")&&!kr("chrome/")?Math.round:wt;function Vr(t){t.min=Dr(t.min),t.max=Dr(t.max)}function xh(t){Vr(t.x),Vr(t.y)}function ya(t,e,n){return t==="position"||t==="preserve-aspect"&&!Ad(Sr(e),Sr(n),.2)}function vh(t){return t!==t.root&&t.scroll?.wasRoot}const bh=ga({attachResizeListener:(t,e)=>en(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),es={current:void 0},xa=ga({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!es.current){const t=new bh({});t.mount(window),t.setOptions({layoutScroll:!0}),es.current=t}return es.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),wh={pan:{Feature:Bd},drag:{Feature:Fd,ProjectionNode:xa,MeasureLayout:ua}};function Rr(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&H.postRender(()=>o(e,on(e)))}class Th extends Ht{mount(){const{current:e}=this.node;e&&(this.unmount=Wl(e,(n,s)=>(Rr(this.node,s,"Start"),i=>Rr(this.node,i,"End"))))}unmount(){}}class Sh extends Ht{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=nn(en(this.node.current,"focus",()=>this.onFocus()),en(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Nr(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&H.postRender(()=>o(e,on(e)))}class Ah extends Ht{mount(){const{current:e}=this.node;e&&(this.unmount=Xl(e,(n,s)=>(Nr(this.node,s,"Start"),(i,{success:o})=>Nr(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Cs=new WeakMap,ns=new WeakMap,Ph=t=>{const e=Cs.get(t.target);e&&e(t)},Ch=t=>{t.forEach(Ph)};function Mh({root:t,...e}){const n=t||document;ns.has(n)||ns.set(n,{});const s=ns.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(Ch,{root:t,...e})),s[i]}function jh(t,e,n){const s=Mh(e);return Cs.set(t,n),s.observe(t),()=>{Cs.delete(t),s.unobserve(t)}}const Eh={some:0,all:1};class kh extends Ht{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Eh[i]},a=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:l,onViewportLeave:d}=this.node.getProps(),f=u?l:d;f&&f(c)};return jh(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(Dh(e,n))&&this.startObserver()}unmount(){}}function Dh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const va={inView:{Feature:kh},tap:{Feature:Ah},focus:{Feature:Sh},hover:{Feature:Th}},Vh={layout:{ProjectionNode:xa,MeasureLayout:ua}},Rh={...ia,...va,...wh,...Vh},Nh=Lu(Rh,Zo),Ih={renderer:Zo,...ia,...va};function ba(t,e){return Tn(t,e)}const xn=ba("div"),Lh=ba("p"),kt=Symbol.for("@arcteninc/core:originalName");function Oh(t,e){return t[kt]=e,t}function Fh(t,e,n,s){if(typeof t!="function")return null;const i=t[kt];if(i){const a=e[i];if(a&&!n.has(a.name))return{fn:t,meta:a}}const o=t.name;let r;if(o&&(r=e[o],r&&!n.has(r.name)))return t[kt]=r.name,{fn:t,meta:r};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(r=e[a],r))return t[kt]=r.name,{fn:t,meta:r}}else if(r=Object.values(e).find(c=>!n.has(c.name)),r)return t[kt]=r.name,{fn:t,meta:r};return null}function wa(t,e){let n,s;if(!e)throw new Error(`❌ toolMetadata is required!
|
|
9
|
+
`),()=>{A.contains(v)&&A.removeChild(v)}},[e]),h.jsx(tu,{isPresent:e,childRef:o,sizeRef:r,children:Pt.cloneElement(t,{ref:c})})}const nu=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:r,anchorX:a,root:c})=>{const u=ks(su),l=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:l,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const x of u.values())if(!x)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return o&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,x)=>u.set(x,!1))},[n]),Pt.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),r==="popLayout"&&(t=h.jsx(eu,{isPresent:n,anchorX:a,root:c,children:t})),h.jsx(Dn.Provider,{value:f,children:t})};function su(){return new Map}function Do(t=!0){const e=m.useContext(Dn);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,o=m.useId();m.useEffect(()=>{if(t)return i(o)},[t]);const r=m.useCallback(()=>t&&s&&s(o),[o,s,t]);return!n&&s?[!1,r]:[!0]}const gn=t=>t.key||"";function Ui(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const iu=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:r=!1,anchorX:a="left",root:c})=>{const[u,l]=Do(r),d=m.useMemo(()=>Ui(t),[t]),f=r&&!u?[]:d.map(gn),g=m.useRef(!0),x=m.useRef(d),v=ks(()=>new Map),[A,y]=m.useState(d),[w,T]=m.useState(d);Br(()=>{g.current=!1,x.current=d;for(let E=0;E<w.length;E++){const O=gn(w[E]);f.includes(O)?v.delete(O):v.get(O)!==!0&&v.set(O,!1)}},[w,f.length,f.join("-")]);const D=[];if(d!==A){let E=[...d];for(let O=0;O<w.length;O++){const R=w[O],$=gn(R);f.includes($)||(E.splice(O,0,R),D.push(R))}return o==="wait"&&D.length&&(E=D),T(Ui(E)),y(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&w.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:j}=m.useContext(Es);return h.jsx(h.Fragment,{children:w.map(E=>{const O=gn(E),R=r&&!u?!1:d===w||f.includes(O),$=()=>{if(v.has(O))v.set(O,!0);else return;let q=!0;v.forEach(Q=>{Q||(q=!1)}),q&&(j?.(),T(x.current),r&&l?.(),s&&s())};return h.jsx(nu,{isPresent:R,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:o,root:c,onExitComplete:R?void 0:$,anchorX:a,children:E},O)})})},ti=m.createContext({strict:!1}),_i={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},Ee={};for(const t in _i)Ee[t]={isEnabled:e=>_i[t].some(n=>!!e[n])};function xs(t){for(const e in t)Ee[e]={...Ee[e],...t[e]}}function ru({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!Xn(e)),i=m.useRef(void 0);if(!Xn(e)){const{renderer:o,...r}=e;i.current=o,xs(r)}return m.useEffect(()=>{Xn(e)&&e().then(({renderer:o,...r})=>{xs(r),i.current=o,s(!0)})},[]),h.jsx(ti.Provider,{value:{renderer:i.current,strict:n},children:t})}function Xn(t){return typeof t=="function"}const ou=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function En(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||ou.has(t)}let Vo=t=>!En(t);function au(t){typeof t=="function"&&(Vo=e=>e.startsWith("on")?!En(e):t(e))}try{au(require("@emotion/is-prop-valid").default)}catch{}function cu(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(Vo(i)||n===!0&&En(i)||!e&&!En(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const Vn=m.createContext({});function Rn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Qe(t){return typeof t=="string"||Array.isArray(t)}const ei=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],ni=["initial",...ei];function Nn(t){return Rn(t.animate)||ni.some(e=>Qe(t[e]))}function Ro(t){return!!(Nn(t)||t.variants)}function lu(t,e){if(Nn(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Qe(n)?n:void 0,animate:Qe(s)?s:void 0}}return t.inherit!==!1?e:{}}function uu(t){const{initial:e,animate:n}=lu(t,m.useContext(Vn));return m.useMemo(()=>({initial:e,animate:n}),[Wi(e),Wi(n)])}function Wi(t){return Array.isArray(t)?t.join(" "):t}const tn={};function du(t){for(const e in t)tn[e]=t[e],Bs(e)&&(tn[e].isCSSVariable=!0)}function No(t,{layout:e,layoutId:n}){return Re.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!tn[t]||t==="opacity")}const hu={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},fu=Ve.length;function mu(t,e,n){let s="",i=!0;for(let o=0;o<fu;o++){const r=Ve[o],a=t[r];if(a===void 0)continue;let c=!0;if(typeof a=="number"?c=a===(r.startsWith("scale")?1:0):c=parseFloat(a)===0,!c||n){const u=Po(a,Ys[r]);if(!c){i=!1;const l=hu[r]||r;s+=`${l}(${u}) `}n&&(e[r]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function si(t,e,n){const{style:s,vars:i,transformOrigin:o}=t;let r=!1,a=!1;for(const c in e){const u=e[c];if(Re.has(c)){r=!0;continue}else if(Bs(c)){i[c]=u;continue}else{const l=Po(u,Ys[c]);c.startsWith("origin")?(a=!0,o[c]=l):s[c]=l}}if(e.transform||(r||n?s.transform=mu(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:c="50%",originY:u="50%",originZ:l=0}=o;s.transformOrigin=`${c} ${u} ${l}`}}const ii=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Io(t,e,n){for(const s in e)!at(e[s])&&!No(s,n)&&(t[s]=e[s])}function pu({transformTemplate:t},e){return m.useMemo(()=>{const n=ii();return si(n,e,t),Object.assign({},n.vars,n.style)},[e])}function gu(t,e){const n=t.style||{},s={};return Io(s,n,t),Object.assign(s,pu(t,e)),s}function yu(t,e){const n={},s=gu(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 xu={offset:"stroke-dashoffset",array:"stroke-dasharray"},vu={offset:"strokeDashoffset",array:"strokeDasharray"};function bu(t,e,n=1,s=0,i=!0){t.pathLength=1;const o=i?xu:vu;t[o.offset]=I.transform(-s);const r=I.transform(e),a=I.transform(n);t[o.array]=`${r} ${a}`}function Lo(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:o=1,pathOffset:r=0,...a},c,u,l){if(si(t,a,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=l?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&bu(d,i,o,r,!1)}const Oo=()=>({...ii(),attrs:{}}),Fo=t=>typeof t=="string"&&t.toLowerCase()==="svg";function wu(t,e,n,s){const i=m.useMemo(()=>{const o=Oo();return Lo(o,e,Fo(s),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[e]);if(t.style){const o={};Io(o,t.style,t),i.style={...o,...i.style}}return i}const Tu=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function ri(t){return typeof t!="string"||t.includes("-")?!1:!!(Tu.indexOf(t)>-1||/[A-Z]/u.test(t))}function Su(t,e,n,{latestValues:s},i,o=!1){const a=(ri(t)?wu:yu)(e,s,i,t),c=cu(e,typeof t=="string",o),u=t!==m.Fragment?{...c,...a,ref:n}:{},{children:l}=e,d=m.useMemo(()=>at(l)?l.get():l,[l]);return m.createElement(t,{...u,children:d})}function Ki(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function oi(t,e,n,s){if(typeof e=="function"){const[i,o]=Ki(s);e=e(n!==void 0?n:t.custom,i,o)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,o]=Ki(s);e=e(n!==void 0?n:t.custom,i,o)}return e}function wn(t){return at(t)?t.get():t}function Au({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:Pu(n,s,i,t),renderState:e()}}function Pu(t,e,n,s){const i={},o=s(t,{});for(const f in o)i[f]=wn(o[f]);let{initial:r,animate:a}=t;const c=Nn(t),u=Ro(t);e&&u&&!c&&t.inherit!==!1&&(r===void 0&&(r=e.initial),a===void 0&&(a=e.animate));let l=n?n.initial===!1:!1;l=l||r===!1;const d=l?a:r;if(d&&typeof d!="boolean"&&!Rn(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const x=oi(t,f[g]);if(x){const{transitionEnd:v,transition:A,...y}=x;for(const w in y){let T=y[w];if(Array.isArray(T)){const D=l?T.length-1:0;T=T[D]}T!==null&&(i[w]=T)}for(const w in v)i[w]=v[w]}}}return i}const Bo=t=>(e,n)=>{const s=m.useContext(Vn),i=m.useContext(Dn),o=()=>Au(t,e,s,i);return n?o():ks(o)};function ai(t,e,n){const{style:s}=t,i={};for(const o in s)(at(s[o])||e.style&&at(e.style[o])||No(o,t)||n?.getValue(o)?.liveStyle!==void 0)&&(i[o]=s[o]);return i}const Cu=Bo({scrapeMotionValuesFromProps:ai,createRenderState:ii});function $o(t,e,n){const s=ai(t,e,n);for(const i in t)if(at(t[i])||at(e[i])){const o=Ve.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[o]=t[i]}return s}const Mu=Bo({scrapeMotionValuesFromProps:$o,createRenderState:Oo}),ju=Symbol.for("motionComponentSymbol");function Te(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function Eu(t,e,n){return m.useCallback(s=>{s&&t.onMount&&t.onMount(s),e&&(s?e.mount(s):e.unmount()),n&&(typeof n=="function"?n(s):Te(n)&&(n.current=s))},[e])}const ci=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),ku="framerAppearId",zo="data-"+ci(ku),Uo=m.createContext({});function Du(t,e,n,s,i){const{visualElement:o}=m.useContext(Vn),r=m.useContext(ti),a=m.useContext(Dn),c=m.useContext(Qs).reducedMotion,u=m.useRef(null);s=s||r.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:c}));const l=u.current,d=m.useContext(Uo);l&&!l.projection&&i&&(l.type==="html"||l.type==="svg")&&Vu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{l&&f.current&&l.update(n,a)});const g=n[zo],x=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return Br(()=>{l&&(f.current=!0,window.MotionIsMounted=!0,l.updateFeatures(),l.scheduleRenderMicrotask(),x.current&&l.animationState&&l.animationState.animateChanges())}),m.useEffect(()=>{l&&(!x.current&&l.animationState&&l.animationState.animateChanges(),x.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),x.current=!1),l.enteringChildren=void 0)}),l}function Vu(t,e,n,s){const{layoutId:i,layout:o,drag:r,dragConstraints:a,layoutScroll:c,layoutRoot:u,layoutCrossfade:l}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:_o(t.parent)),t.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!r||a&&Te(a),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:s,crossfade:l,layoutScroll:c,layoutRoot:u})}function _o(t){if(t)return t.options.allowProjection!==!1?t.projection:_o(t.parent)}function Tn(t,{forwardMotionProps:e=!1}={},n,s){n&&xs(n);const i=ri(t)?Mu:Cu;function o(a,c){let u;const l={...m.useContext(Qs),...a,layoutId:Ru(a)},{isStatic:d}=l,f=uu(a),g=i(a,d);if(!d&&Ds){Nu(l,n);const x=Iu(l);u=x.MeasureLayout,f.visualElement=Du(t,g,l,s,x.ProjectionNode)}return h.jsxs(Vn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...l}):null,Su(t,a,Eu(g,f.visualElement,c),g,d,e)]})}o.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const r=m.forwardRef(o);return r[ju]=t,r}function Ru({layoutId:t}){const e=m.useContext(Es).id;return e&&t!==void 0?e+"-"+t:t}function Nu(t,e){const n=m.useContext(ti).strict;if(process.env.NODE_ENV!=="production"&&e&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?ke(!1,s,"lazy-strict-mode"):Ot(!1,s,"lazy-strict-mode")}}function Iu(t){const{drag:e,layout:n}=Ee;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function Lu(t,e){if(typeof Proxy>"u")return Tn;const n=new Map,s=(o,r)=>Tn(o,r,t,e),i=(o,r)=>(process.env.NODE_ENV!=="production"&&Ls(!1,"motion() is deprecated. Use motion.create() instead."),s(o,r));return new Proxy(i,{get:(o,r)=>r==="create"?s:(n.has(r)||n.set(r,Tn(r,void 0,t,e)),n.get(r))})}function Wo({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function Ou({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 qn(t){return t===void 0||t===1}function vs({scale:t,scaleX:e,scaleY:n}){return!qn(t)||!qn(e)||!qn(n)}function oe(t){return vs(t)||Ko(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Ko(t){return Hi(t.x)||Hi(t.y)}function Hi(t){return t&&t!=="0%"}function kn(t,e,n){const s=t-n,i=e*s;return n+i}function Gi(t,e,n,s,i){return i!==void 0&&(t=kn(t,i,s)),kn(t,n,s)+e}function bs(t,e=0,n=1,s,i){t.min=Gi(t.min,e,n,s,i),t.max=Gi(t.max,e,n,s,i)}function Ho(t,{x:e,y:n}){bs(t.x,e.translate,e.scale,e.originPoint),bs(t.y,n.translate,n.scale,n.originPoint)}const Xi=.999999999999,qi=1.0000000000001;function Bu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let o,r;for(let a=0;a<i;a++){o=n[a],r=o.projectionDelta;const{visualElement:c}=o.options;c&&c.props.style&&c.props.style.display==="contents"||(s&&o.options.layoutScroll&&o.scroll&&o!==o.root&&Ae(t,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),r&&(e.x*=r.x.scale,e.y*=r.y.scale,Ho(t,r)),s&&oe(o.latestValues)&&Ae(t,o.latestValues))}e.x<qi&&e.x>Xi&&(e.x=1),e.y<qi&&e.y>Xi&&(e.y=1)}function Se(t,e){t.min=t.min+e,t.max=t.max+e}function Yi(t,e,n,s,i=.5){const o=X(t.min,t.max,i);bs(t,e,n,o,s)}function Ae(t,e){Yi(t.x,e.x,e.scaleX,e.scale,e.originX),Yi(t.y,e.y,e.scaleY,e.scale,e.originY)}function Go(t,e){return Wo(Fu(t.getBoundingClientRect(),e))}function $u(t,e,n){const s=Go(t,n),{scroll:i}=e;return i&&(Se(s.x,i.offset.x),Se(s.y,i.offset.y)),s}const Ji=()=>({translate:0,scale:1,origin:0,originPoint:0}),Pe=()=>({x:Ji(),y:Ji()}),Zi=()=>({min:0,max:0}),Y=()=>({x:Zi(),y:Zi()}),ws={current:null},Xo={current:!1};function zu(){if(Xo.current=!0,!!Ds)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>ws.current=t.matches;t.addEventListener("change",e),e()}else ws.current=!1}const Uu=new WeakMap;function _u(t,e,n){for(const s in e){const i=e[s],o=n[s];if(at(i))t.addValue(s,i);else if(at(o))t.addValue(s,je(i,{owner:t}));else if(o!==i)if(t.hasValue(s)){const r=t.getValue(s);r.liveStyle===!0?r.jump(i):r.hasAnimated||r.set(i)}else{const r=t.getStaticValue(s);t.addValue(s,je(r!==void 0?r:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Qi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Wu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:o,visualState:r},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Xs,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=mt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,H.render(this.render,!1,!0))};const{latestValues:c,renderState:u}=r;this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=Nn(n),this.isVariantNode=Ro(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:l,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];c[f]!==void 0&&at(g)&&g.set(c[f])}}mount(e){this.current=e,Uu.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)),Xo.current||zu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:ws.current,process.env.NODE_ENV!=="production"&&Ls(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Wt(this.notifyUpdate),Wt(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=Re.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",r=>{this.latestValues[e]=r,this.props.onUpdate&&H.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in Ee){const n=Ee[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const o=this.features[e];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Y()}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<Qi.length;s++){const i=Qi[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,r=e[o];r&&(this.propEventSubscriptions[i]=this.on(i,r))}this.prevMotionValues=_u(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=je(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&($r(s)||Ur(s))?s=parseFloat(s):!Jl(s)&&Kt.test(n)&&(s=Ao(e,n)),this.setBaseTarget(e,at(s)?s.get():s)),at(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const o=oi(this.props,n,this.presenceContext?.custom);o&&(s=o[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!at(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 Is),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){Js.render(this.render)}}class qo extends Wu{constructor(){super(...arguments),this.KeyframeResolver=Bl}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;at(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Yo(t,{style:e,vars:n},s,i){const o=t.style;let r;for(r in e)o[r]=e[r];i?.applyProjectionStyles(o,s);for(r in n)o.setProperty(r,n[r])}function Ku(t){return window.getComputedStyle(t)}class Hu extends qo{constructor(){super(...arguments),this.type="html",this.renderInstance=Yo}readValueFromInstance(e,n){if(Re.has(n))return this.projection?.isProjecting?ds(n):sl(e,n);{const s=Ku(e),i=(Bs(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Go(e,n)}build(e,n,s){si(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return ai(e,n,s)}}const Jo=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 Gu(t,e,n,s){Yo(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Jo.has(i)?i:ci(i),e.attrs[i])}class Xu extends qo{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Y}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(Re.has(n)){const s=So(n);return s&&s.default||0}return n=Jo.has(n)?n:ci(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return $o(e,n,s)}build(e,n,s){Lo(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Gu(e,n,s,i)}mount(e){this.isSVGTag=Fo(e.tagName),super.mount(e)}}const Zo=(t,e)=>ri(t)?new Xu(e):new Hu(e,{allowProjection:t!==m.Fragment});function Me(t,e,n){const s=t.getProps();return oi(s,e,n!==void 0?n:s.custom,t)}const Ts=t=>Array.isArray(t);function qu(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,je(n))}function Yu(t){return Ts(t)?t[t.length-1]||0:t}function Ju(t,e){const n=Me(t,e);let{transitionEnd:s={},transition:i={},...o}=n||{};o={...o,...s};for(const r in o){const a=Yu(o[r]);qu(t,r,a)}}function Zu(t){return!!(at(t)&&t.add)}function Ss(t,e){const n=t.getValue("willChange");if(Zu(n))return n.add(e);if(!n&&Ft.WillChange){const s=new Ft.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Qo(t){return t.props[zo]}const Qu=t=>t!==null;function td(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Qu),o=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[o]}const ed={type:"spring",stiffness:500,damping:25,restSpeed:10},nd=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),sd={type:"keyframes",duration:.8},id={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},rd=(t,{keyframes:e})=>e.length>2?sd:Re.has(t)?t.startsWith("scale")?nd(e[1]):ed:id;function od({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:o,repeatType:r,repeatDelay:a,from:c,elapsed:u,...l}){return!!Object.keys(l).length}const li=(t,e,n,s={},i,o)=>r=>{const a=qs(s,t)||{},c=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-Ct(c);const l={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{r(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:o?void 0:i};od(a)||Object.assign(l,rd(t,l)),l.duration&&(l.duration=Ct(l.duration)),l.repeatDelay&&(l.repeatDelay=Ct(l.repeatDelay)),l.from!==void 0&&(l.keyframes[0]=l.from);let d=!1;if((l.type===!1||l.duration===0&&!l.repeatDelay)&&(gs(l),l.delay===0&&(d=!0)),(Ft.instantAnimations||Ft.skipAnimations)&&(d=!0,gs(l),l.delay=0),l.allowFlatten=!a.type&&!a.ease,d&&!o&&e.get()!==void 0){const f=td(l.keyframes,a);if(f!==void 0){H.update(()=>{l.onUpdate(f),l.onComplete()});return}}return a.isSync?new Gs(l):new Cl(l)};function ad({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function ta(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:o=t.getDefaultTransition(),transitionEnd:r,...a}=e;s&&(o=s);const c=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const l in a){const d=t.getValue(l,t.latestValues[l]??null),f=a[l];if(f===void 0||u&&ad(u,l))continue;const g={delay:n,...qs(o||{},l)},x=d.get();if(x!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===x&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const y=Qo(t);if(y){const w=window.MotionHandoffAnimation(y,l,H);w!==null&&(g.startTime=w,v=!0)}}Ss(t,l),d.start(li(l,d,f,t.shouldReduceMotion&&bo.has(l)?{type:!1}:g,t,v));const A=d.animation;A&&c.push(A)}return r&&Promise.all(c).then(()=>{H.update(()=>{r&&Ju(t,r)})}),c}function ea(t,e,n,s=0,i=1){const o=Array.from(t).sort((u,l)=>u.sortNodePosition(l)).indexOf(e),r=t.size,a=(r-1)*s;return typeof n=="function"?n(o,r):i===1?o*s:a-o*s}function As(t,e,n={}){const s=Me(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(ta(t,s,n)):()=>Promise.resolve(),r=t.variantChildren&&t.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:l,staggerDirection:d}=i;return cd(t,e,c,u,l,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,u]=a==="beforeChildren"?[o,r]:[r,o];return c().then(()=>u())}else return Promise.all([o(),r(n.delay)])}function cd(t,e,n=0,s=0,i=0,o=1,r){const a=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),a.push(As(c,e,{...r,delay:n+(typeof s=="function"?0:s)+ea(t.variantChildren,c,s,i,o)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(a)}function ld(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(o=>As(t,o,n));s=Promise.all(i)}else if(typeof e=="string")s=As(t,e,n);else{const i=typeof e=="function"?Me(t,e,n.custom):e;s=Promise.all(ta(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function na(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 ud=ni.length;function sa(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?sa(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<ud;n++){const s=ni[n],i=t.props[s];(Qe(i)||i===!1)&&(e[s]=i)}return e}const dd=[...ei].reverse(),hd=ei.length;function fd(t){return e=>Promise.all(e.map(({animation:n,options:s})=>ld(t,n,s)))}function md(t){let e=fd(t),n=tr(),s=!0;const i=c=>(u,l)=>{const d=Me(t,l,c==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...x}=d;u={...u,...x,...g}}return u};function o(c){e=c(t)}function r(c){const{props:u}=t,l=sa(t.parent)||{},d=[],f=new Set;let g={},x=1/0;for(let A=0;A<hd;A++){const y=dd[A],w=n[y],T=u[y]!==void 0?u[y]:l[y],D=Qe(T),j=y===c?w.isActive:null;j===!1&&(x=A);let E=T===l[y]&&T!==u[y]&&D;if(E&&s&&t.manuallyAnimateOnMount&&(E=!1),w.protectedKeys={...g},!w.isActive&&j===null||!T&&!w.prevProp||Rn(T)||typeof T=="boolean")continue;const O=pd(w.prevProp,T);let R=O||y===c&&w.isActive&&!E&&D||A>x&&D,$=!1;const q=Array.isArray(T)?T:[T];let Q=q.reduce(i(y),{});j===!1&&(Q={});const{prevResolvedValues:U={}}=w,de={...U,...Q},Tt=F=>{R=!0,f.has(F)&&($=!0,f.delete(F)),w.needsAnimating[F]=!0;const ct=t.getValue(F);ct&&(ct.liveStyle=!1)};for(const F in de){const ct=Q[F],lt=U[F];if(g.hasOwnProperty(F))continue;let ut=!1;Ts(ct)&&Ts(lt)?ut=!na(ct,lt):ut=ct!==lt,ut?ct!=null?Tt(F):f.add(F):ct!==void 0&&f.has(F)?Tt(F):w.protectedKeys[F]=!0}w.prevProp=T,w.prevResolvedValues=Q,w.isActive&&(g={...g,...Q}),s&&t.blockInitialAnimation&&(R=!1);const rt=E&&O;R&&(!rt||$)&&d.push(...q.map(F=>{const ct={type:y};if(typeof F=="string"&&s&&!rt&&t.manuallyAnimateOnMount&&t.parent){const{parent:lt}=t,ut=Me(lt,F);if(lt.enteringChildren&&ut){const{delayChildren:dt}=ut.transition||{};ct.delay=ea(lt.enteringChildren,t,dt)}}return{animation:F,options:ct}}))}if(f.size){const A={};if(typeof u.initial!="boolean"){const y=Me(t,Array.isArray(u.initial)?u.initial[0]:u.initial);y&&y.transition&&(A.transition=y.transition)}f.forEach(y=>{const w=t.getBaseTarget(y),T=t.getValue(y);T&&(T.liveStyle=!0),A[y]=w??null}),d.push({animation:A})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(c,u){if(n[c].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(c,u)),n[c].isActive=u;const l=r(c);for(const d in n)n[d].protectedKeys={};return l}return{animateChanges:r,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=tr()}}}function pd(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!na(e,t):!1}function ie(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function tr(){return{animate:ie(!0),whileInView:ie(),whileHover:ie(),whileTap:ie(),whileDrag:ie(),whileFocus:ie(),exit:ie()}}class Ht{constructor(e){this.isMounted=!1,this.node=e}update(){}}class gd extends Ht{constructor(e){super(e),e.animationState||(e.animationState=md(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();Rn(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let yd=0;class xd extends Ht{constructor(){super(...arguments),this.id=yd++}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 ia={animation:{Feature:gd},exit:{Feature:xd}};function en(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function on(t){return{point:{x:t.pageX,y:t.pageY}}}const vd=t=>e=>Zs(e)&&t(e,on(e));function Ke(t,e,n,s){return en(t,e,vd(n),s)}const ra=1e-4,bd=1-ra,wd=1+ra,oa=.01,Td=0-oa,Sd=0+oa;function ft(t){return t.max-t.min}function Ad(t,e,n){return Math.abs(t-e)<=n}function er(t,e,n,s=.5){t.origin=s,t.originPoint=X(e.min,e.max,t.origin),t.scale=ft(n)/ft(e),t.translate=X(n.min,n.max,t.origin)-t.originPoint,(t.scale>=bd&&t.scale<=wd||isNaN(t.scale))&&(t.scale=1),(t.translate>=Td&&t.translate<=Sd||isNaN(t.translate))&&(t.translate=0)}function He(t,e,n,s){er(t.x,e.x,n.x,s?s.originX:void 0),er(t.y,e.y,n.y,s?s.originY:void 0)}function nr(t,e,n){t.min=n.min+e.min,t.max=t.min+ft(e)}function Pd(t,e,n){nr(t.x,e.x,n.x),nr(t.y,e.y,n.y)}function sr(t,e,n){t.min=e.min-n.min,t.max=t.min+ft(e)}function Ge(t,e,n){sr(t.x,e.x,n.x),sr(t.y,e.y,n.y)}function vt(t){return[t("x"),t("y")]}const aa=({current:t})=>t?t.ownerDocument.defaultView:null,ir=(t,e)=>Math.abs(t-e);function Cd(t,e){const n=ir(t.x,e.x),s=ir(t.y,e.y);return Math.sqrt(n**2+s**2)}class ca{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:r=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=Jn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,x=Cd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!x)return;const{point:v}=f,{timestamp:A}=st;this.history.push({...v,timestamp:A});const{onStart:y,onMove:w}=this.handlers;g||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=Yn(g,this.transformPagePoint),H.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:x,onSessionEnd:v,resumeAnimation:A}=this.handlers;if(this.dragSnapToOrigin&&A&&A(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=Jn(f.type==="pointercancel"?this.lastMoveEventInfo:Yn(g,this.transformPagePoint),this.history);this.startEvent&&x&&x(f,y),v&&v(f,y)},!Zs(e))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=i||window;const a=on(e),c=Yn(a,this.transformPagePoint),{point:u}=c,{timestamp:l}=st;this.history=[{...u,timestamp:l}];const{onSessionStart:d}=n;d&&d(e,Jn(c,this.history)),this.removeListeners=nn(Ke(this.contextWindow,"pointermove",this.handlePointerMove),Ke(this.contextWindow,"pointerup",this.handlePointerUp),Ke(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Wt(this.updatePoint)}}function Yn(t,e){return e?{point:e(t.point)}:t}function rr(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Jn({point:t},e){return{point:t,delta:rr(t,la(e)),offset:rr(t,Md(e)),velocity:jd(e,.1)}}function Md(t){return t[0]}function la(t){return t[t.length-1]}function jd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=la(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>Ct(e)));)n--;if(!s)return{x:0,y:0};const o=bt(i.timestamp-s.timestamp);if(o===0)return{x:0,y:0};const r={x:(i.x-s.x)/o,y:(i.y-s.y)/o};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function Ed(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?X(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?X(n,t,s.max):Math.min(t,n)),t}function or(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 kd(t,{top:e,left:n,bottom:s,right:i}){return{x:or(t.x,n,i),y:or(t.y,e,s)}}function ar(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 Dd(t,e){return{x:ar(t.x,e.x),y:ar(t.y,e.y)}}function Vd(t,e){let n=.5;const s=ft(t),i=ft(e);return i>s?n=Ye(e.min,e.max-s,t.min):s>i&&(n=Ye(t.min,t.max-i,e.min)),Lt(0,1,n)}function Rd(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 Ps=.35;function Nd(t=Ps){return t===!1?t=0:t===!0&&(t=Ps),{x:cr(t,"left","right"),y:cr(t,"top","bottom")}}function cr(t,e,n){return{min:lr(t,e),max:lr(t,n)}}function lr(t,e){return typeof t=="number"?t:t[e]||0}const Id=new WeakMap;class Ld{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=Y(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(on(d).point)},r=(d,f)=>{const{drag:g,dragPropagation:x,onDragStart:v}=this.getProps();if(g&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=_l(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),vt(y=>{let w=this.getAxisMotionValue(y).get()||0;if(Dt.test(w)){const{projection:T}=this.visualElement;if(T&&T.layout){const D=T.layout.layoutBox[y];D&&(w=ft(D)*(parseFloat(w)/100))}}this.originPoint[y]=w}),v&&H.postRender(()=>v(d,f)),Ss(this.visualElement,"transform");const{animationState:A}=this.visualElement;A&&A.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:x,onDirectionLock:v,onDrag:A}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:y}=f;if(x&&this.currentDirection===null){this.currentDirection=Od(y),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),A&&A(d,f)},c=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>vt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:l}=this.getProps();this.panSession=new ca(e,{onSessionStart:o,onStart:r,onMove:a,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:s,contextWindow:aa(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!s)return;const{velocity:r}=i;this.startAnimation(r);const{onDragEnd:a}=this.getProps();a&&H.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||!yn(e,i,this.currentDirection))return;const o=this.getAxisMotionValue(e);let r=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(r=Ed(r,this.constraints[e],this.elastic[e])),o.set(r)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&Te(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=kd(s.layoutBox,e):this.constraints=!1,this.elastic=Nd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&vt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=Rd(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Te(e))return!1;const s=e.current;Ot(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=$u(s,i.root,this.visualElement.getTransformPagePoint());let r=Dd(i.layout.layoutBox,o);if(n){const a=n(Ou(r));this.hasMutatedConstraints=!!a,a&&(r=Wo(a))}return r}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:o,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),c=this.constraints||{},u=vt(l=>{if(!yn(l,n,this.currentDirection))return;let d=c&&c[l]||{};r&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,x={type:"inertia",velocity:s?e[l]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(l,x)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Ss(this.visualElement,e),s.start(li(e,s,0,n,this.visualElement,!1))}stopAnimation(){vt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){vt(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){vt(n=>{const{drag:s}=this.getProps();if(!yn(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:r,max:a}=i.layout.layoutBox[n];o.set(e[n]-X(r,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Te(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};vt(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const c=a.get();i[r]=Vd({min:c,max:c},this.constraints[r])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),vt(r=>{if(!yn(r,e,null))return;const a=this.getAxisMotionValue(r),{min:c,max:u}=this.constraints[r];a.set(X(c,u,i[r]))})}addListeners(){if(!this.visualElement.current)return;Id.set(this.visualElement,this);const e=this.visualElement.current,n=Ke(e,"pointerdown",c=>{const{drag:u,dragListener:l=!0}=this.getProps();u&&l&&this.start(c)}),s=()=>{const{dragConstraints:c}=this.getProps();Te(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,o=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),H.read(s);const r=en(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(vt(l=>{const d=this.getAxisMotionValue(l);d&&(this.originPoint[l]+=c[l].translate,d.set(d.get()+c[l].translate))}),this.visualElement.render())});return()=>{r(),n(),o(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:r=Ps,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:o,dragElastic:r,dragMomentum:a}}}function yn(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function Od(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 Ht{constructor(e){super(e),this.removeGroupControls=wt,this.removeListeners=wt,this.controls=new Ld(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||wt}unmount(){this.removeGroupControls(),this.removeListeners()}}const ur=t=>(e,n)=>{t&&H.postRender(()=>t(e,n))};class Bd extends Ht{constructor(){super(...arguments),this.removePointerDownListener=wt}onPointerDown(e){this.session=new ca(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:aa(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:ur(e),onStart:ur(n),onMove:s,onEnd:(o,r)=>{delete this.session,i&&H.postRender(()=>i(o,r))}}}mount(){this.removePointerDownListener=Ke(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 Sn={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function dr(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Ue={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(I.test(t))t=parseFloat(t);else return t;const n=dr(t,e.target.x),s=dr(t,e.target.y);return`${n}% ${s}%`}},$d={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Kt.parse(t);if(i.length>5)return s;const o=Kt.createTransformer(t),r=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,c=n.y.scale*e.y;i[0+r]/=a,i[1+r]/=c;const u=X(a,c,.5);return typeof i[2+r]=="number"&&(i[2+r]/=u),typeof i[3+r]=="number"&&(i[3+r]/=u),o(i)}};let Zn=!1;class zd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:o}=e;du(Ud),o&&(n.group&&n.group.add(o),s&&s.register&&i&&s.register(o),Zn&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),Sn.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:o}=this.props,{projection:r}=s;return r&&(r.isPresent=o,Zn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==o?r.willUpdate():this.safeToRemove(),e.isPresent!==o&&(o?r.promote():r.relegate()||H.postRender(()=>{const a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Js.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;Zn=!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 ua(t){const[e,n]=Do(),s=m.useContext(Es);return h.jsx(zd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(Uo),isPresent:e,safeToRemove:n})}const Ud={borderRadius:{...Ue,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Ue,borderTopRightRadius:Ue,borderBottomLeftRadius:Ue,borderBottomRightRadius:Ue,boxShadow:$d};function _d(t,e,n){const s=at(t)?t:je(t);return s.start(li("",s,e,n)),s.animation}const Wd=(t,e)=>t.depth-e.depth;class Kd{constructor(){this.children=[],this.isDirty=!1}add(e){Vs(this.children,e),this.isDirty=!0}remove(e){Rs(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Wd),this.isDirty=!1,this.children.forEach(e)}}function Hd(t,e){const n=mt.now(),s=({timestamp:i})=>{const o=i-n;o>=e&&(Wt(s),t(o-e))};return H.setup(s,!0),()=>Wt(s)}const da=["TopLeft","TopRight","BottomLeft","BottomRight"],Gd=da.length,hr=t=>typeof t=="string"?parseFloat(t):t,fr=t=>typeof t=="number"||I.test(t);function Xd(t,e,n,s,i,o){i?(t.opacity=X(0,n.opacity??1,qd(s)),t.opacityExit=X(e.opacity??1,0,Yd(s))):o&&(t.opacity=X(e.opacity??1,n.opacity??1,s));for(let r=0;r<Gd;r++){const a=`border${da[r]}Radius`;let c=mr(e,a),u=mr(n,a);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||fr(c)===fr(u)?(t[a]=Math.max(X(hr(c),hr(u),s),0),(Dt.test(u)||Dt.test(c))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=X(e.rotate||0,n.rotate||0,s))}function mr(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const qd=ha(0,.5,Yr),Yd=ha(.5,.95,wt);function ha(t,e,n){return s=>s<t?0:s>e?1:n(Ye(t,e,s))}function pr(t,e){t.min=e.min,t.max=e.max}function xt(t,e){pr(t.x,e.x),pr(t.y,e.y)}function gr(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function yr(t,e,n,s,i){return t-=e,t=kn(t,1/n,s),i!==void 0&&(t=kn(t,1/i,s)),t}function Jd(t,e=0,n=1,s=.5,i,o=t,r=t){if(Dt.test(e)&&(e=parseFloat(e),e=X(r.min,r.max,e/100)-r.min),typeof e!="number")return;let a=X(o.min,o.max,s);t===o&&(a-=e),t.min=yr(t.min,e,n,a,i),t.max=yr(t.max,e,n,a,i)}function xr(t,e,[n,s,i],o,r){Jd(t,e[n],e[s],e[i],e.scale,o,r)}const Zd=["x","scaleX","originX"],Qd=["y","scaleY","originY"];function vr(t,e,n,s){xr(t.x,e,Zd,n?n.x:void 0,s?s.x:void 0),xr(t.y,e,Qd,n?n.y:void 0,s?s.y:void 0)}function br(t){return t.translate===0&&t.scale===1}function fa(t){return br(t.x)&&br(t.y)}function wr(t,e){return t.min===e.min&&t.max===e.max}function th(t,e){return wr(t.x,e.x)&&wr(t.y,e.y)}function Tr(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function ma(t,e){return Tr(t.x,e.x)&&Tr(t.y,e.y)}function Sr(t){return ft(t.x)/ft(t.y)}function Ar(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class eh{constructor(){this.members=[]}add(e){Vs(this.members,e),e.scheduleRender()}remove(e){if(Rs(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){s=o;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function nh(t,e,n){let s="";const i=t.x.translate/e.x,o=t.y.translate/e.y,r=n?.z||0;if((i||o||r)&&(s=`translate3d(${i}px, ${o}px, ${r}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:l,rotateX:d,rotateY:f,skewX:g,skewY:x}=n;u&&(s=`perspective(${u}px) ${s}`),l&&(s+=`rotate(${l}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),x&&(s+=`skewY(${x}deg) `)}const a=t.x.scale*e.x,c=t.y.scale*e.y;return(a!==1||c!==1)&&(s+=`scale(${a}, ${c})`),s||"none"}const Qn=["","X","Y","Z"],sh=1e3;let ih=0;function ts(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function pa(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Qo(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",H,!(i||o))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&pa(s)}function ga({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(r={},a=e?.()){this.id=ih++,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(ah),this.nodes.forEach(dh),this.nodes.forEach(hh),this.nodes.forEach(ch)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=r,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new Kd)}addEventListener(r,a){return this.eventHandlers.has(r)||this.eventHandlers.set(r,new Is),this.eventHandlers.get(r).add(a)}notifyListeners(r,...a){const c=this.eventHandlers.get(r);c&&c.notify(...a)}hasListeners(r){return this.eventHandlers.has(r)}mount(r){if(this.instance)return;this.isSVG=ko(r)&&!ql(r),this.instance=r;const{layoutId:a,layout:c,visualElement:u}=this.options;if(u&&!u.current&&u.mount(r),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||a)&&(this.isLayoutDirty=!0),t){let l,d=0;const f=()=>this.root.updateBlockedByResize=!1;H.read(()=>{d=window.innerWidth}),t(r,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,l&&l(),l=Hd(f,250),Sn.hasAnimatedSinceResize&&(Sn.hasAnimatedSinceResize=!1,this.nodes.forEach(Mr)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||c)&&this.addEventListener("didUpdate",({delta:l,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||u.getDefaultTransition()||yh,{onLayoutAnimationStart:v,onLayoutAnimationComplete:A}=u.getProps(),y=!this.targetLayout||!ma(this.targetLayout,g),w=!d&&f;if(this.options.layoutRoot||this.resumeFrom||w||d&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const T={...qs(x,"layout"),onPlay:v,onComplete:A};(u.shouldReduceMotion||this.options.layoutRoot)&&(T.delay=0,T.type=!1),this.startAnimation(T),this.setAnimationOrigin(l,w)}else d||Mr(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const r=this.getStack();r&&r.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Wt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(fh),this.animationId++)}getTransformTemplate(){const{visualElement:r}=this.options;return r&&r.getProps().transformTemplate}willUpdate(r=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&pa(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let l=0;l<this.path.length;l++){const d=this.path[l];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:c}=this.options;if(a===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),r&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Pr);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Cr);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(uh),this.nodes.forEach(rh),this.nodes.forEach(oh)):this.nodes.forEach(Cr),this.clearAllSnapshots();const a=mt.now();st.delta=Lt(0,1e3/60,a-st.timestamp),st.timestamp=a,st.isProcessing=!0,Un.update.process(st),Un.preRender.process(st),Un.render.process(st),st.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Js.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(lh),this.sharedNodes.forEach(mh)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,H.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){H.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ft(this.snapshot.measuredBox.x)&&!ft(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const r=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Y(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,r?r.layoutBox:void 0)}updateScroll(r="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===r&&(a=!1),a&&this.instance){const c=s(this.instance);this.scroll={animationId:this.root.animationId,phase:r,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!i)return;const r=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!fa(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,l=u!==this.prevTransformTemplateValue;r&&this.instance&&(a||oe(this.latestValues)||l)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(r=!0){const a=this.measurePageBox();let c=this.removeElementScroll(a);return r&&(c=this.removeTransform(c)),xh(c),{animationId:this.root.animationId,measuredBox:a,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:r}=this.options;if(!r)return Y();const a=r.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(vh))){const{scroll:u}=this.root;u&&(Se(a.x,u.offset.x),Se(a.y,u.offset.y))}return a}removeElementScroll(r){const a=Y();if(xt(a,r),this.scroll?.wasRoot)return a;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:l,options:d}=u;u!==this.root&&l&&d.layoutScroll&&(l.wasRoot&&xt(a,r),Se(a.x,l.offset.x),Se(a.y,l.offset.y))}return a}applyTransform(r,a=!1){const c=Y();xt(c,r);for(let u=0;u<this.path.length;u++){const l=this.path[u];!a&&l.options.layoutScroll&&l.scroll&&l!==l.root&&Ae(c,{x:-l.scroll.offset.x,y:-l.scroll.offset.y}),oe(l.latestValues)&&Ae(c,l.latestValues)}return oe(this.latestValues)&&Ae(c,this.latestValues),c}removeTransform(r){const a=Y();xt(a,r);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!oe(u.latestValues))continue;vs(u.latestValues)&&u.updateSnapshot();const l=Y(),d=u.measurePageBox();xt(l,d),vr(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,l)}return oe(this.latestValues)&&vr(a,this.latestValues),a}setTargetDelta(r){this.targetDelta=r,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(r){this.options={...this.options,...r,crossfade:r.crossfade!==void 0?r.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==st.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(r=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==a;if(!(r||c&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:l,layoutId:d}=this.options;if(!(!this.layout||!(l||d))){if(this.resolvedRelativeTargetAt=st.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Y(),this.relativeTargetOrigin=Y(),Ge(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Y(),this.targetWithTransforms=Y()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Pd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):xt(this.target,this.layout.layoutBox),Ho(this.target,this.targetDelta)):xt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Y(),this.relativeTargetOrigin=Y(),Ge(this.relativeTargetOrigin,this.target,f.target),xt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||vs(this.parent.latestValues)||Ko(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const r=this.getLead(),a=!!this.resumingFrom||this!==r;let c=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(c=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===st.timestamp&&(c=!1),c)return;const{layout:u,layoutId:l}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||l))return;xt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;Bu(this.layoutCorrected,this.treeScale,this.path,a),r.layout&&!r.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(r.target=r.layout.layoutBox,r.targetWithTransforms=Y());const{target:g}=r;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(gr(this.prevProjectionDelta.x,this.projectionDelta.x),gr(this.prevProjectionDelta.y,this.projectionDelta.y)),He(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Ar(this.projectionDelta.x,this.prevProjectionDelta.x)||!Ar(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(r=!0){if(this.options.visualElement?.scheduleRender(),r){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Pe(),this.projectionDelta=Pe(),this.projectionDeltaWithTransform=Pe()}setAnimationOrigin(r,a=!1){const c=this.snapshot,u=c?c.latestValues:{},l={...this.latestValues},d=Pe();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=Y(),g=c?c.source:void 0,x=this.layout?this.layout.source:void 0,v=g!==x,A=this.getStack(),y=!A||A.members.length<=1,w=!!(v&&!y&&this.options.crossfade===!0&&!this.path.some(gh));this.animationProgress=0;let T;this.mixTargetDelta=D=>{const j=D/1e3;jr(d.x,r.x,j),jr(d.y,r.y,j),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Ge(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),ph(this.relativeTarget,this.relativeTargetOrigin,f,j),T&&th(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=Y()),xt(T,this.relativeTarget)),v&&(this.animationValues=l,Xd(l,u,this.latestValues,j,w,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=j},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(r){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Wt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=H.update(()=>{Sn.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=je(0)),this.currentAnimation=_d(this.motionValue,[0,1e3],{...r,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),r.onUpdate&&r.onUpdate(a)},onStop:()=>{},onComplete:()=>{r.onComplete&&r.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const r=this.getStack();r&&r.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(sh),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const r=this.getLead();let{targetWithTransforms:a,target:c,layout:u,latestValues:l}=r;if(!(!a||!c||!u)){if(this!==r&&this.layout&&u&&ya(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||Y();const d=ft(this.layout.layoutBox.x);c.x.min=r.target.x.min,c.x.max=c.x.min+d;const f=ft(this.layout.layoutBox.y);c.y.min=r.target.y.min,c.y.max=c.y.min+f}xt(a,c),Ae(a,l),He(this.projectionDeltaWithTransform,this.layoutCorrected,a,l)}}registerSharedNode(r,a){this.sharedNodes.has(r)||this.sharedNodes.set(r,new eh),this.sharedNodes.get(r).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const r=this.getStack();return r?r.lead===this:!0}getLead(){const{layoutId:r}=this.options;return r?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:r}=this.options;return r?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:r}=this.options;if(r)return this.root.sharedNodes.get(r)}promote({needsReset:r,transition:a,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),r&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const r=this.getStack();return r?r.relegate(this):!1}resetSkewAndRotation(){const{visualElement:r}=this.options;if(!r)return;let a=!1;const{latestValues:c}=r;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(a=!0),!a)return;const u={};c.z&&ts("z",r,u,this.animationValues);for(let l=0;l<Qn.length;l++)ts(`rotate${Qn[l]}`,r,u,this.animationValues),ts(`skew${Qn[l]}`,r,u,this.animationValues);r.render();for(const l in u)r.setStaticValue(l,u[l]),this.animationValues&&(this.animationValues[l]=u[l]);r.scheduleRender()}applyProjectionStyles(r,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){r.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,r.visibility="",r.opacity="",r.pointerEvents=wn(a?.pointerEvents)||"",r.transform=c?c(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(r.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,r.pointerEvents=wn(a?.pointerEvents)||""),this.hasProjected&&!oe(this.latestValues)&&(r.transform=c?c({},""):"none",this.hasProjected=!1);return}r.visibility="";const l=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=nh(this.projectionDeltaWithTransform,this.treeScale,l);c&&(d=c(l,d)),r.transform=d;const{x:f,y:g}=this.projectionDelta;r.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?r.opacity=u===this?l.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:l.opacityExit:r.opacity=u===this?l.opacity!==void 0?l.opacity:"":l.opacityExit!==void 0?l.opacityExit:0;for(const x in tn){if(l[x]===void 0)continue;const{correct:v,applyTo:A,isCSSVariable:y}=tn[x],w=d==="none"?l[x]:v(l[x],u);if(A){const T=A.length;for(let D=0;D<T;D++)r[A[D]]=w}else y?this.options.visualElement.renderState.vars[x]=w:r[x]=w}this.options.layoutId&&(r.pointerEvents=u===this?wn(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(r=>r.currentAnimation?.stop()),this.root.nodes.forEach(Pr),this.root.sharedNodes.clear()}}}function rh(t){t.updateLayout()}function oh(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,o=e.source!==t.layout.source;i==="size"?vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(d);d.min=n[l].min,d.max=d.min+f}):ya(i,e.layoutBox,n)&&vt(l=>{const d=o?e.measuredBox[l]:e.layoutBox[l],f=ft(n[l]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[l].max=t.relativeTarget[l].min+f)});const r=Pe();He(r,n,e.layoutBox);const a=Pe();o?He(a,t.applyTransform(s,!0),e.measuredBox):He(a,n,e.layoutBox);const c=!fa(r);let u=!1;if(!t.resumeFrom){const l=t.getClosestProjectingParent();if(l&&!l.resumeFrom){const{snapshot:d,layout:f}=l;if(d&&f){const g=Y();Ge(g,e.layoutBox,d.layoutBox);const x=Y();Ge(x,n,f.layoutBox),ma(g,x)||(u=!0),l.options.layoutRoot&&(t.relativeTarget=x,t.relativeTargetOrigin=g,t.relativeParent=l)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:r,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function ah(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 ch(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function lh(t){t.clearSnapshot()}function Pr(t){t.clearMeasurements()}function Cr(t){t.isLayoutDirty=!1}function uh(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function Mr(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function dh(t){t.resolveTargetDelta()}function hh(t){t.calcProjection()}function fh(t){t.resetSkewAndRotation()}function mh(t){t.removeLeadSnapshot()}function jr(t,e,n){t.translate=X(e.translate,0,n),t.scale=X(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function Er(t,e,n,s){t.min=X(e.min,n.min,s),t.max=X(e.max,n.max,s)}function ph(t,e,n,s){Er(t.x,e.x,n.x,s),Er(t.y,e.y,n.y,s)}function gh(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const yh={duration:.45,ease:[.4,0,.1,1]},kr=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Dr=kr("applewebkit/")&&!kr("chrome/")?Math.round:wt;function Vr(t){t.min=Dr(t.min),t.max=Dr(t.max)}function xh(t){Vr(t.x),Vr(t.y)}function ya(t,e,n){return t==="position"||t==="preserve-aspect"&&!Ad(Sr(e),Sr(n),.2)}function vh(t){return t!==t.root&&t.scroll?.wasRoot}const bh=ga({attachResizeListener:(t,e)=>en(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),es={current:void 0},xa=ga({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!es.current){const t=new bh({});t.mount(window),t.setOptions({layoutScroll:!0}),es.current=t}return es.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),wh={pan:{Feature:Bd},drag:{Feature:Fd,ProjectionNode:xa,MeasureLayout:ua}};function Rr(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=s[i];o&&H.postRender(()=>o(e,on(e)))}class Th extends Ht{mount(){const{current:e}=this.node;e&&(this.unmount=Wl(e,(n,s)=>(Rr(this.node,s,"Start"),i=>Rr(this.node,i,"End"))))}unmount(){}}class Sh extends Ht{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=nn(en(this.node.current,"focus",()=>this.onFocus()),en(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Nr(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=s[i];o&&H.postRender(()=>o(e,on(e)))}class Ah extends Ht{mount(){const{current:e}=this.node;e&&(this.unmount=Xl(e,(n,s)=>(Nr(this.node,s,"Start"),(i,{success:o})=>Nr(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Cs=new WeakMap,ns=new WeakMap,Ph=t=>{const e=Cs.get(t.target);e&&e(t)},Ch=t=>{t.forEach(Ph)};function Mh({root:t,...e}){const n=t||document;ns.has(n)||ns.set(n,{});const s=ns.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(Ch,{root:t,...e})),s[i]}function jh(t,e,n){const s=Mh(e);return Cs.set(t,n),s.observe(t),()=>{Cs.delete(t),s.unobserve(t)}}const Eh={some:0,all:1};class kh extends Ht{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:o}=e,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:Eh[i]},a=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,o&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:l,onViewportLeave:d}=this.node.getProps(),f=u?l:d;f&&f(c)};return jh(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(Dh(e,n))&&this.startObserver()}unmount(){}}function Dh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const va={inView:{Feature:kh},tap:{Feature:Ah},focus:{Feature:Sh},hover:{Feature:Th}},Vh={layout:{ProjectionNode:xa,MeasureLayout:ua}},Rh={...ia,...va,...wh,...Vh},Nh=Lu(Rh,Zo),Ih={renderer:Zo,...ia,...va};function ba(t,e){return Tn(t,e)}const xn=ba("div"),Lh=ba("p"),kt=Symbol.for("@arcteninc/core:originalName");function Oh(t,e){return t[kt]=e,t}function Fh(t,e,n,s){if(typeof t!="function")return null;const i=t[kt];if(i){const a=e[i];if(a&&!n.has(a.name))return{fn:t,meta:a}}const o=t.name;let r;if(o&&(r=e[o],r&&!n.has(r.name)))return t[kt]=r.name,{fn:t,meta:r};if(s&&s.length>0){for(const a of s)if(!n.has(a)&&(r=e[a],r))return t[kt]=r.name,{fn:t,meta:r}}else if(r=Object.values(e).find(c=>!n.has(c.name)),r)return t[kt]=r.name,{fn:t,meta:r};return null}function wa(t,e){let n,s;if(!e)throw new Error(`❌ toolMetadata is required!
|
|
10
10
|
|
|
11
11
|
Please:
|
|
12
12
|
1. Run "arcten-extract-types ." before build (add to package.json scripts)
|
|
@@ -16,9 +16,9 @@ Please:
|
|
|
16
16
|
useAgent({ tools: [...], toolMetadata: toolMetadata })
|
|
17
17
|
(Pass the full object for better minification support, or toolMetadata.functions for backward compatibility)
|
|
18
18
|
`);if("functions"in e&&typeof e.functions=="object"){const o=e;n=o.functions,s=o.toolOrder}else n=e,s=void 0;const i=new Set;return t.map(o=>{const r=Fh(o,n,i,s);if(!r){const a=o.name,u=o[kt]||a||"unnamed";return typeof process<"u"&&(process.env.NODE_ENV==="development"||process.env.NODE_ENV!=="production")&&typeof console<"u"&&console.warn&&console.warn(`⚠️ [@arcteninc/core] No metadata found for tool "${u}". This tool will be excluded.
|
|
19
|
-
To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return i.add(r.meta.name),{name:r.meta.name,description:r.meta.description,jsonSchema:r.meta.parameters}}).filter(o=>o!==null)}function Bh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const o=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),o&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([r,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[r,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},r))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(Pn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(Z.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(Pn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(Z.X,{className:"h-3 w-3"})})]})]})})}function $h({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,o]=m.useState(!1);if(t==="fetchDocContent")return null;const r=["k","maxResults","_organizationId"];t==="searchDocs"&&r.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!r.includes(u))),c=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>c&&o(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${c?"cursor-pointer hover:bg-opacity-80":""}`,children:[c&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(Z.ChevronDown,{className:"h-3 w-3"}):h.jsx(Z.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(Z.X,{className:"h-3 w-3"}):s?h.jsx(Z.Zap,{className:"h-3 w-3"}):h.jsx(Z.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&c&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},u))})})]})}function zh({...t}){return h.jsx(js.Root,{"data-slot":"collapsible",...t})}function Uh({...t}){return h.jsx(js.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function _h({...t}){return h.jsx(js.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const Wh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),ui=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Wh,{className:st("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ui.displayName="Response";const Kh=Object.freeze(Object.defineProperty({__proto__:null,Response:ui},Symbol.toStringTag,{value:"Module"})),Hh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const o=Nh.create(e),r=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(o,{animate:{backgroundPosition:"0% center"},className:st("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${r}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},Gh=m.memo(Hh),Ta=m.createContext(null),Xh=()=>{const t=m.useContext(Ta);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},qh=1e3,Yh=1e3,Sa=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:o,children:r,...a})=>{const[c,u]=xi.useControllableState({prop:n,defaultProp:s,onChange:i}),[l,d]=xi.useControllableState({prop:o,defaultProp:0}),[f,g]=m.useState(!1),[x,v]=m.useState(null);m.useEffect(()=>{e?x===null&&v(Date.now()):x!==null&&(d(Math.ceil((Date.now()-x)/Yh)),v(null))},[e,x,d]),m.useEffect(()=>{if(s&&!e&&c&&!f){const y=setTimeout(()=>{u(!1),g(!0)},qh);return()=>clearTimeout(y)}},[e,c,s,u,f]);const A=y=>{u(y)};return h.jsx(Ta.Provider,{value:{isStreaming:e,isOpen:c,setIsOpen:u,duration:l},children:h.jsx(zh,{className:st("not-prose mb-4",t),onOpenChange:A,open:c,...a,children:r})})}),Jh=(t,e)=>t||e===0?h.jsx(Gh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Aa=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:o}=Xh();return h.jsx(Uh,{className:st("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(Z.BrainIcon,{className:"size-4"}),Jh(s,o),h.jsx(Z.ChevronDownIcon,{className:st("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Pa=m.memo(({className:t,children:e,...n})=>h.jsx(_h,{className:st("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(ui,{className:"grid gap-2",children:e})}));Sa.displayName="Reasoning";Aa.displayName="ReasoningTrigger";Pa.displayName="ReasoningContent";function Zh(t){const e=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,n=t.match(e),s=new Map;if(n&&n[1]){const u=n[1],l=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let d;for(;(d=l.exec(u))!==null;)if(d[1]&&d[2]){const f=parseInt(d[1],10),g=d[2].replace(/[.,;:!?]+$/,"");s.set(f,g)}}const i=[];let o=0;const r=/```[\s\S]*?```|`[^`]+`/g;let a;for(;(a=r.exec(t))!==null;)a.index>o&&i.push({type:"text",content:t.slice(o,a.index),start:o,end:a.index}),i.push({type:"code",content:a[0],start:a.index,end:a.index+a[0].length}),o=a.index+a[0].length;return o<t.length&&i.push({type:"text",content:t.slice(o),start:o,end:t.length}),i.map(u=>{if(u.type==="code")return u.content;let l=u.content;l=l.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(v,A,y)=>{const w=parseInt(A,10);return`<sup><a href="${y.replace(/"/g,""")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${w}]</a></sup>`});const d=/\[([^\]]+)\]\([^\)]+\)/g,f=[];let g;for(;(g=d.exec(l))!==null;)f.push({start:g.index,end:g.index+g[0].length});return l.replace(/\[(\d+)\]/g,(v,A,y)=>{if(f.some(j=>y>=j.start&&y<j.end))return v;const T=parseInt(A,10),D=s.get(T);return D?`<sup><a href="${D.replace(/"/g,""")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${T}]</a></sup>`:v})}).join("")}function Xe(t){if(typeof t=="string")try{const e=JSON.parse(t);return Xe(e)}catch{return t}if(Array.isArray(t))return t.map(Xe);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=Xe(s);return e}return t}function ss(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return Xe(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?Xe(t):{}}function Qh({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:o=void 0,defaultWidth:r=384,minWidth:a=300,maxWidth:c=800,initiallyExpanded:u=!1,tools:l=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:x="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:A,state:y,onStateChange:w,allowStateEdits:T=!0}){const[D,j]=m.useState(null),E=m.useRef(null),[O,R]=m.useState(null),[$,q]=m.useState(null),Q=m.useRef(null),z=y!==void 0,[de,Tt]=m.useState({}),it=m.useRef({});z&&y?it.current=y:z||(it.current=de);const[Bt,F]=m.useState(!1),[ct,lt]=m.useState(null),ut=m.useRef(!1),[dt,Vt]=m.useState(u),[yt,he]=m.useState(r),[Gt,Xt]=m.useState(600),[Mt,Rt]=m.useState(!1),[_,fe]=m.useState(!1),[pt,qt]=m.useState(!1),[gt,me]=m.useState({x:100,y:100}),[St,Ne]=m.useState(!1),[Yt,pe]=m.useState({x:0,y:0}),[In,ge]=m.useState(!1),Jt=m.useRef(null),ye=m.useRef(null),[xe,Ie]=m.useState(""),[Le,Ln]=m.useState(null),[On,Fn]=m.useState("Thinking..."),[Oe,P]=m.useState(new Set),[C,V]=m.useState(""),[I,U]=m.useState([]),[W,rt]=m.useState(!1),[Nt,Zt]=m.useState([]),[jt,Fe]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[ve,an]=m.useState(!1),[nf,cn]=m.useState(!1),[sf,ln]=m.useState([]),di=m.useCallback(async(p,b=3)=>{if(!jt||!E.current)return;const M=async()=>{const k=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,N=await fetch(k,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:jt,updates:p},format:"json"})});if(!N.ok){if(N.status===404){console.warn("[ArctenAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const tt=await N.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${N.status} ${tt}`)}};for(let S=0;S<b;S++)try{await M(),lt(null);return}catch(k){if(S===b-1){const tt=k instanceof Error?k:new Error(String(k));throw lt(tt),console.error("Failed to sync state to Convex after retries:",k),tt}await new Promise(tt=>setTimeout(tt,Math.pow(2,S)*100))}},[jt,v,E]),Be=m.useMemo(()=>function(){return it.current},[]),$e=m.useMemo(()=>async function(b){const M={...it.current,...b};it.current=M,z||Tt(M),w&&w(M);try{await di(b)}catch(S){throw S}},[di,w,z]);m.useEffect(()=>{z&&y&&(it.current=y)},[z,y]);const Qt=m.useMemo(()=>{const p=[...l,...d,Be];return(!z||T)&&p.push($e),p},[l,d,Be,$e,z,T]),Bn=m.useMemo(()=>wa(Qt,f),[Qt,f]),It=m.useMemo(()=>{const p=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}];return(!z||T)&&p.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}),[...Bn,...p]},[Bn,z,T]),hi=m.useMemo(()=>new Set(It.map(p=>p.name)),[It]),un=m.useMemo(()=>It.filter(p=>p.name==="getState"?!0:p.name==="setState"?!z||T:hi.has(p.name)),[It,hi,z,T]),dn=m.useMemo(()=>{const p=new Map,b=new Map(Bn.map(M=>[M.name,M]));return p.set("getState",Be),(!z||T)&&p.set("setState",$e),Qt.forEach(M=>{if(M===Be||M===$e)return;const S=M[kt];if(S){const N=b.get(S);if(N){p.set(N.name,M);return}}const k=It.find(N=>N.name===M.name);k&&p.set(k.name,M)}),p},[Qt,It,Be,$e,z,T]),ze=m.useMemo(()=>{const p=new Set;p.add("getState"),p.add("setState");const b=new Map(It.map(M=>[M.name,M]));return d.forEach(M=>{const S=M[kt];if(S&&b.has(S))p.add(S);else{const k=It.find(N=>N.name===M.name);k&&p.add(k.name)}}),p},[d,It]),fi=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];m.useEffect(()=>{if(typeof window<"u"){const p=localStorage.getItem("arcten-sidebar-expanded");p&&Vt(JSON.parse(p));const b=localStorage.getItem("arcten-sidebar-width");b&&he(parseInt(b));const M=localStorage.getItem("arcten-sidebar-height");M&&Xt(parseInt(M));const S=localStorage.getItem("arcten-sidebar-detached");S&&fe(JSON.parse(S));const k=localStorage.getItem("arcten-sidebar-position");if(k){const tt=JSON.parse(k),B=50,et=Math.max(B-r,Math.min(tt.x,window.innerWidth-B)),K=Math.max(0,Math.min(tt.y,window.innerHeight-B));me({x:et,y:K})}const N=localStorage.getItem("arcten-sidebar-minimized");N&&qt(JSON.parse(N)),ge(!0)}},[]);const $t=m.useMemo(()=>A,[A?.id]);m.useEffect(()=>((async()=>{try{const b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!b.ok)throw new Error("Failed to fetch token");const M=await b.json();j(M.clientToken),E.current=M.clientToken,q(M.expiresAt),R(null)}catch(b){R(b instanceof Error?b.message:"Failed to fetch token")}})(),()=>{Q.current&&clearTimeout(Q.current)}),[x,$t]),m.useEffect(()=>{if(!$)return;Q.current&&clearTimeout(Q.current);const p=Math.floor(Date.now()/1e3),b=$-p,S=Math.max(0,b-5);return Q.current=setTimeout(async()=>{try{const k=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!k.ok)throw new Error("Failed to refresh token");const N=await k.json();j(N.clientToken),E.current=N.clientToken,q(N.expiresAt),R(null)}catch(k){console.error("Token refresh failed:",k),R(k instanceof Error?k.message:"Failed to refresh token")}},S*1e3),()=>{Q.current&&clearTimeout(Q.current)}},[$,x,$t]),m.useEffect(()=>{(async()=>{if(Qt.length!==0)try{const b=Qt.map(S=>({name:S.name,code:S.toString()})),M=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:b})});if(M.ok){const S=await M.json();U(S.tools)}}catch(b){console.error("Failed to fetch tool descriptions:",b)}})()},[Qt]),m.useEffect(()=>{Promise.resolve().then(()=>Kh).then(p=>{Ln(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{V(window.location.pathname)};p(),window.addEventListener("popstate",p);const b=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(b)}},[]);const $n=m.useCallback(async()=>{if(!(!$t?.id||!D)){cn(!0);try{const b=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${D}`}})).json();Zt(b.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{cn(!1)}}},[$t?.id,D,v]);m.useEffect(()=>{$t?.id&&D&&$n()},[$t?.id,D,$n]);function Ca(p){const b=Math.floor((Date.now()-p)/1e3);return b<60?"now":b<3600?`${Math.floor(b/60)}m`:b<86400?`${Math.floor(b/3600)}h`:`${Math.floor(b/86400)}d`}function Ma(){const p=crypto.randomUUID();Fe(p),fn([]),ln([]),an(!1);const b=z?y||{}:{};it.current=b,z||Tt(b),w&&w(b),ut.current=!1}async function ja(p){if(D)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${D}`}}),Zt(Nt.filter(b=>b._id!==p)),p===jt&&Ma()}catch(b){console.error("Failed to delete conversation:",b)}}async function Ea(p){Fe(p.chatId),an(!1),cn(!0);try{const b=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${E.current}`}});if(!b.ok)throw new Error(`Failed to fetch messages: ${b.statusText}`);const S=(await b.json()).messages||[];fn(S),ln(S)}catch(b){console.error("Failed to load conversation messages:",b);const M=p.messages||[];fn(M),ln(M)}finally{cn(!1)}}const ka=async(p,b={})=>{const M=b.headers?new Headers(b.headers):new Headers;return M.delete("user-agent"),M.delete("User-Agent"),fetch(p,{...b,headers:M})},{messages:zt,sendMessage:Da,status:Et,error:mi,stop:hn,addToolResult:te,setMessages:fn}=Ir.useChat({id:jt||void 0,transport:new An.DefaultChatTransport({api:`${v}/chat`,fetch:ka,headers:()=>{const p={};return E.current&&(p.Authorization=`Bearer ${E.current}`),p},body:()=>({tools:un.map(b=>({name:b.name,description:b.description,inputSchema:b.jsonSchema})),systemPrompt:g,currentRoute:C,state:it.current})}),sendAutomaticallyWhen:An.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{const p=zt[zt.length-1];if(!p||p.role!=="assistant")return;const b=p.parts?.filter(M=>M.type?.startsWith("tool-")&&M.state==="input-available"&&typeof M.toolCallId=="string"&&M.input!==void 0)||[];for(const M of b){const S=M,k=S.type?.replace("tool-","")||"",N=S.toolCallId;if(ze.has(k)){if(Oe.has(N))continue;P(B=>B.has(N)?B:new Set(B).add(N)),(async()=>{try{const B=dn.get(k);if(!B){console.warn(`[ArctenAgent] Tool ${k} not found in toolsMap. Available tools:`,Array.from(dn.keys())),te({toolCallId:N,tool:k,output:`Error: Tool ${k} not found`}),P(ot=>{const Ut=new Set(ot);return Ut.delete(N),Ut});return}const et=ss(S.input),K=un.find(ot=>ot.name===k);let ht;if(K&&K.jsonSchema?.properties){const Ut=Object.keys(K.jsonSchema.properties).map($a=>et[$a]);console.log(`[ArctenAgent] Executing safe tool ${k} with args:`,Ut),ht=await B(...Ut)}else if(k==="getState")ht=B();else if(k==="setState"){const ot=et.updates||et;ht=await B(ot)}else ht=await B(...Object.values(et));console.log(`[ArctenAgent] Tool ${k} completed, result:`,ht),te({toolCallId:N,tool:k,output:ht}),P(ot=>{const Ut=new Set(ot);return Ut.delete(N),Ut})}catch(B){console.error(`[ArctenAgent] Error executing safe tool ${k}:`,B),te({toolCallId:N,tool:k,output:`Error: ${B instanceof Error?B.message:String(B)}`}),P(et=>{const K=new Set(et);return K.delete(N),K})}})()}}},[zt,ze,dn,un,te]),m.useEffect(()=>{if(!jt||!E.current)return;(async()=>{F(!0),lt(null);try{const M=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,S=await fetch(M,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:jt},format:"json"})});if(!S.ok){if(S.status===404||S.status>=500){console.warn(`[ArctenAgent] Convex API endpoint not available (${S.status}), using empty state`);const K=z?y||{}:{};it.current=K,z||Tt(K),w&&w(K),ut.current=!0,F(!1);return}const et=await S.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${S.status} ${et}`)}const N=(await S.json())?.value||{},tt=!ut.current;let B;tt?(B={...z?y||{}:{},...N},ut.current=!0):B=N,it.current=B,z||Tt(B),w&&w(B)}catch(b){b instanceof TypeError&&b.message.includes("fetch")?console.warn("[ArctenAgent] Network error fetching state (likely Convex endpoint not available), using fallback state:",b):console.error("[ArctenAgent] Failed to fetch state:",b);const S=b instanceof Error?b:new Error(String(b));if(lt(S),!ut.current){const k=z?y||{}:{};it.current=k,z||Tt(k),w&&w(k),ut.current=!0}}finally{F(!1)}})()},[jt,v,z,y,w]),m.useEffect(()=>{dt&&ye.current&&ye.current.focus()},[dt,zt]);function Va(){Vt(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Ra(){Vt(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[dt]),m.useEffect(()=>{Jt.current&&Jt.current.scrollIntoView({behavior:"smooth"})},[zt]),m.useEffect(()=>{function p(b){b.key==="Escape"&&(Et==="streaming"||Et==="submitted")&&(b.preventDefault(),hn())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[Et,hn]);function Na(){const p=crypto.randomUUID();Fe(p),fn([]),ln([]),an(!1)}function pi(p){if(p.preventDefault(),!xe.trim())return;(Et==="streaming"||Et==="submitted")&&hn();const b=fi[Math.floor(Math.random()*fi.length)]||"Thinking...";Fn(b),Da({text:xe}),Ie("")}function Ia(p){const b=p.target.value;Ie(b)}m.useEffect(()=>{if(!Mt)return;function p(M){if(_){const S=M.clientX-gt.x,k=M.clientY-gt.y;S>=a&&S<=c&&he(S),k>=400&&k<=1e3&&Xt(k)}else{const S=window.innerWidth-M.clientX;S>=a&&S<=c&&he(S)}}function b(){Rt(!1),localStorage.setItem("arcten-sidebar-width",yt.toString()),localStorage.setItem("arcten-sidebar-height",Gt.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[Mt,yt,Gt,_,gt,a,c]);function La(p){p.preventDefault(),Rt(!0)}function Oa(){fe(!0),qt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Fa(){fe(!1),qt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function gi(){qt(!pt),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!pt))}function Ba(p){_&&(Ne(!0),pe({x:p.clientX-gt.x,y:p.clientY-gt.y}))}return m.useEffect(()=>{if(!_)return;function p(){me(b=>{const S=window.innerWidth-50,k=window.innerHeight-50,N=50-yt,tt=0,B=Math.max(N,Math.min(b.x,S)),et=Math.max(tt,Math.min(b.y,k));if(B!==b.x||et!==b.y){const K={x:B,y:et};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(K)),K}return b})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[_,yt]),m.useEffect(()=>{if(!St)return;function p(M){const S=M.clientX-Yt.x,k=M.clientY-Yt.y,N=50,tt=window.innerWidth-N,B=window.innerHeight-N,et=N-yt,K=0,ht=Math.max(et,Math.min(S,tt)),ot=Math.max(K,Math.min(k,B));me({x:ht,y:ot})}function b(){Ne(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(gt))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[St,Yt,gt,yt]),In?O?h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",O]})}):D?h.jsx(ru,{features:Ih,children:h.jsx(xn,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:_?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:_?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
20
|
-
${
|
|
19
|
+
To fix: Run "arcten-extract-types ." and ensure "${u}" is used in ArctenAgent/useAgent.`),null}return i.add(r.meta.name),{name:r.meta.name,description:r.meta.description,jsonSchema:r.meta.parameters}}).filter(o=>o!==null)}function Bh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const o=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),o&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([r,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[r,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},r))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(Pn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(Z.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(Pn,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(Z.X,{className:"h-3 w-3"})})]})]})})}function $h({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,o]=m.useState(!1);if(t==="fetchDocContent")return null;const r=["k","maxResults","_organizationId"];t==="searchDocs"&&r.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!r.includes(u))),c=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>c&&o(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${c?"cursor-pointer hover:bg-opacity-80":""}`,children:[c&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(Z.ChevronDown,{className:"h-3 w-3"}):h.jsx(Z.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(Z.X,{className:"h-3 w-3"}):s?h.jsx(Z.Zap,{className:"h-3 w-3"}):h.jsx(Z.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&c&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,l])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof l=="string"?l:JSON.stringify(l)})]},u))})})]})}function zh({...t}){return h.jsx(js.Root,{"data-slot":"collapsible",...t})}function Uh({...t}){return h.jsx(js.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function _h({...t}){return h.jsx(js.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const Wh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),ui=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(Wh,{className:it("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ui.displayName="Response";const Kh=Object.freeze(Object.defineProperty({__proto__:null,Response:ui},Symbol.toStringTag,{value:"Module"})),Hh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const o=Nh.create(e),r=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(o,{animate:{backgroundPosition:"0% center"},className:it("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${r}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},Gh=m.memo(Hh),Ta=m.createContext(null),Xh=()=>{const t=m.useContext(Ta);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},qh=1e3,Yh=1e3,Sa=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:o,children:r,...a})=>{const[c,u]=xi.useControllableState({prop:n,defaultProp:s,onChange:i}),[l,d]=xi.useControllableState({prop:o,defaultProp:0}),[f,g]=m.useState(!1),[x,v]=m.useState(null);m.useEffect(()=>{e?x===null&&v(Date.now()):x!==null&&(d(Math.ceil((Date.now()-x)/Yh)),v(null))},[e,x,d]),m.useEffect(()=>{if(s&&!e&&c&&!f){const y=setTimeout(()=>{u(!1),g(!0)},qh);return()=>clearTimeout(y)}},[e,c,s,u,f]);const A=y=>{u(y)};return h.jsx(Ta.Provider,{value:{isStreaming:e,isOpen:c,setIsOpen:u,duration:l},children:h.jsx(zh,{className:it("not-prose mb-4",t),onOpenChange:A,open:c,...a,children:r})})}),Jh=(t,e)=>t||e===0?h.jsx(Gh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Aa=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:o}=Xh();return h.jsx(Uh,{className:it("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...n,children:e??h.jsxs(h.Fragment,{children:[h.jsx(Z.BrainIcon,{className:"size-4"}),Jh(s,o),h.jsx(Z.ChevronDownIcon,{className:it("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Pa=m.memo(({className:t,children:e,...n})=>h.jsx(_h,{className:it("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",t),...n,children:h.jsx(ui,{className:"grid gap-2",children:e})}));Sa.displayName="Reasoning";Aa.displayName="ReasoningTrigger";Pa.displayName="ReasoningContent";function Zh(t){const e=/(?:^|\n)(?:#+\s*)?(?:References|References:)(?:\*\*)?\s*\n?([\s\S]*?)(?=\n\n|\n#|$)/i,n=t.match(e),s=new Map;if(n&&n[1]){const u=n[1],l=/\[(\d+)\]\s*(https?:\/\/[^\s\)]+)/g;let d;for(;(d=l.exec(u))!==null;)if(d[1]&&d[2]){const f=parseInt(d[1],10),g=d[2].replace(/[.,;:!?]+$/,"");s.set(f,g)}}const i=[];let o=0;const r=/```[\s\S]*?```|`[^`]+`/g;let a;for(;(a=r.exec(t))!==null;)a.index>o&&i.push({type:"text",content:t.slice(o,a.index),start:o,end:a.index}),i.push({type:"code",content:a[0],start:a.index,end:a.index+a[0].length}),o=a.index+a[0].length;return o<t.length&&i.push({type:"text",content:t.slice(o),start:o,end:t.length}),i.map(u=>{if(u.type==="code")return u.content;let l=u.content;l=l.replace(/\[(\d+)\]\((https?:\/\/[^\)]+)\)/g,(v,A,y)=>{const w=parseInt(A,10);return`<sup><a href="${y.replace(/"/g,""")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${w}]</a></sup>`});const d=/\[([^\]]+)\]\([^\)]+\)/g,f=[];let g;for(;(g=d.exec(l))!==null;)f.push({start:g.index,end:g.index+g[0].length});return l.replace(/\[(\d+)\]/g,(v,A,y)=>{if(f.some(j=>y>=j.start&&y<j.end))return v;const T=parseInt(A,10),D=s.get(T);return D?`<sup><a href="${D.replace(/"/g,""")}" target="_blank" rel="noopener noreferrer" class="text-blue-600 dark:text-blue-400 hover:underline font-medium">[${T}]</a></sup>`:v})}).join("")}function Xe(t){if(typeof t=="string")try{const e=JSON.parse(t);return Xe(e)}catch{return t}if(Array.isArray(t))return t.map(Xe);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=Xe(s);return e}return t}function ss(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return Xe(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?Xe(t):{}}function Qh({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:o=void 0,defaultWidth:r=384,minWidth:a=300,maxWidth:c=800,initiallyExpanded:u=!1,tools:l=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:x="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:A,state:y,onStateChange:w,allowStateEdits:T=!0}){const[D,j]=m.useState(null),E=m.useRef(null),[O,R]=m.useState(null),[$,q]=m.useState(null),Q=m.useRef(null),U=y!==void 0,[de,Tt]=m.useState({}),rt=m.useRef({});U&&y?rt.current=y:U||(rt.current=de);const[Bt,F]=m.useState(!1),[ct,lt]=m.useState(null),ut=m.useRef(!1),[dt,Vt]=m.useState(u),[yt,he]=m.useState(r),[Gt,Xt]=m.useState(600),[Mt,Rt]=m.useState(!1),[W,fe]=m.useState(!1),[pt,qt]=m.useState(!1),[gt,me]=m.useState({x:100,y:100}),[St,Ne]=m.useState(!1),[Yt,pe]=m.useState({x:0,y:0}),[In,ge]=m.useState(!1),Jt=m.useRef(null),ye=m.useRef(null),[xe,Ie]=m.useState(""),[Le,Ln]=m.useState(null),[On,Fn]=m.useState("Thinking..."),[Oe,P]=m.useState(new Set),[C,V]=m.useState(""),[L,_]=m.useState([]),[z,tt]=m.useState(!1),[Nt,Zt]=m.useState([]),[jt,Fe]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[ve,an]=m.useState(!1),[nf,cn]=m.useState(!1),[sf,ln]=m.useState([]),di=m.useCallback(async(p,b=3)=>{if(!jt||!E.current)return;const M=async()=>{const k=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,N=await fetch(k,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:jt,updates:p},format:"json"})});if(!N.ok){if(N.status===404){console.warn("[ArctenAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const et=await N.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${N.status} ${et}`)}};for(let S=0;S<b;S++)try{await M(),lt(null);return}catch(k){if(S===b-1){const et=k instanceof Error?k:new Error(String(k));throw lt(et),console.error("Failed to sync state to Convex after retries:",k),et}await new Promise(et=>setTimeout(et,Math.pow(2,S)*100))}},[jt,v,E]),Be=m.useMemo(()=>function(){return rt.current},[]),$e=m.useMemo(()=>async function(b){const M={...rt.current,...b};rt.current=M,U||Tt(M),w&&w(M);try{await di(b)}catch(S){throw S}},[di,w,U]);m.useEffect(()=>{U&&y&&(rt.current=y)},[U,y]);const Qt=m.useMemo(()=>{const p=[...l,...d,Be];return(!U||T)&&p.push($e),p},[l,d,Be,$e,U,T]),Bn=m.useMemo(()=>wa(Qt,f),[Qt,f]),It=m.useMemo(()=>{const p=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}}];return(!U||T)&&p.push({name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}),[...Bn,...p]},[Bn,U,T]),hi=m.useMemo(()=>new Set(It.map(p=>p.name)),[It]),un=m.useMemo(()=>It.filter(p=>p.name==="getState"?!0:p.name==="setState"?!U||T:hi.has(p.name)),[It,hi,U,T]),dn=m.useMemo(()=>{const p=new Map,b=new Map(Bn.map(M=>[M.name,M]));return p.set("getState",Be),(!U||T)&&p.set("setState",$e),Qt.forEach(M=>{if(M===Be||M===$e)return;const S=M[kt];if(S){const N=b.get(S);if(N){p.set(N.name,M);return}}const k=It.find(N=>N.name===M.name);k&&p.set(k.name,M)}),p},[Qt,It,Be,$e,U,T]),ze=m.useMemo(()=>{const p=new Set;p.add("getState"),p.add("setState");const b=new Map(It.map(M=>[M.name,M]));return d.forEach(M=>{const S=M[kt];if(S&&b.has(S))p.add(S);else{const k=It.find(N=>N.name===M.name);k&&p.add(k.name)}}),p},[d,It]),fi=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];m.useEffect(()=>{if(typeof window<"u"){const p=localStorage.getItem("arcten-sidebar-expanded");p&&Vt(JSON.parse(p));const b=localStorage.getItem("arcten-sidebar-width");b&&he(parseInt(b));const M=localStorage.getItem("arcten-sidebar-height");M&&Xt(parseInt(M));const S=localStorage.getItem("arcten-sidebar-detached");S&&fe(JSON.parse(S));const k=localStorage.getItem("arcten-sidebar-position");if(k){const et=JSON.parse(k),B=50,nt=Math.max(B-r,Math.min(et.x,window.innerWidth-B)),K=Math.max(0,Math.min(et.y,window.innerHeight-B));me({x:nt,y:K})}const N=localStorage.getItem("arcten-sidebar-minimized");N&&qt(JSON.parse(N)),ge(!0)}},[]);const $t=m.useMemo(()=>A,[A?.id]);m.useEffect(()=>((async()=>{try{const b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!b.ok)throw new Error("Failed to fetch token");const M=await b.json();j(M.clientToken),E.current=M.clientToken,q(M.expiresAt),R(null)}catch(b){R(b instanceof Error?b.message:"Failed to fetch token")}})(),()=>{Q.current&&clearTimeout(Q.current)}),[x,$t]),m.useEffect(()=>{if(!$)return;Q.current&&clearTimeout(Q.current);const p=Math.floor(Date.now()/1e3),b=$-p,S=Math.max(0,b-5);return Q.current=setTimeout(async()=>{try{const k=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:$t})});if(!k.ok)throw new Error("Failed to refresh token");const N=await k.json();j(N.clientToken),E.current=N.clientToken,q(N.expiresAt),R(null)}catch(k){console.error("Token refresh failed:",k),R(k instanceof Error?k.message:"Failed to refresh token")}},S*1e3),()=>{Q.current&&clearTimeout(Q.current)}},[$,x,$t]),m.useEffect(()=>{(async()=>{if(Qt.length!==0)try{const b=Qt.map(S=>({name:S.name,code:S.toString()})),M=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:b})});if(M.ok){const S=await M.json();_(S.tools)}}catch(b){console.error("Failed to fetch tool descriptions:",b)}})()},[Qt]),m.useEffect(()=>{Promise.resolve().then(()=>Kh).then(p=>{Ln(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{V(window.location.pathname)};p(),window.addEventListener("popstate",p);const b=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(b)}},[]);const $n=m.useCallback(async()=>{if(!(!$t?.id||!D)){cn(!0);try{const b=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${D}`}})).json();Zt(b.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{cn(!1)}}},[$t?.id,D,v]);m.useEffect(()=>{$t?.id&&D&&$n()},[$t?.id,D,$n]);function Ca(p){const b=Math.floor((Date.now()-p)/1e3);return b<60?"now":b<3600?`${Math.floor(b/60)}m`:b<86400?`${Math.floor(b/3600)}h`:`${Math.floor(b/86400)}d`}function Ma(){const p=crypto.randomUUID();Fe(p),fn([]),ln([]),an(!1);const b=U?y||{}:{};rt.current=b,U||Tt(b),w&&w(b),ut.current=!1}async function ja(p){if(D)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${D}`}}),Zt(Nt.filter(b=>b._id!==p)),p===jt&&Ma()}catch(b){console.error("Failed to delete conversation:",b)}}async function Ea(p){Fe(p.chatId),an(!1),cn(!0);try{const b=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${E.current}`}});if(!b.ok)throw new Error(`Failed to fetch messages: ${b.statusText}`);const S=(await b.json()).messages||[];fn(S),ln(S)}catch(b){console.error("Failed to load conversation messages:",b);const M=p.messages||[];fn(M),ln(M)}finally{cn(!1)}}const ka=async(p,b={})=>{const M=b.headers?new Headers(b.headers):new Headers;return M.delete("user-agent"),M.delete("User-Agent"),fetch(p,{...b,headers:M})},{messages:zt,sendMessage:Da,status:Et,error:mi,stop:hn,addToolResult:te,setMessages:fn}=Ir.useChat({id:jt||void 0,transport:new An.DefaultChatTransport({api:`${v}/chat`,fetch:ka,headers:()=>{const p={};return E.current&&(p.Authorization=`Bearer ${E.current}`),p},body:()=>({tools:un.map(b=>({name:b.name,description:b.description,inputSchema:b.jsonSchema})),systemPrompt:g,currentRoute:C,state:rt.current})}),sendAutomaticallyWhen:An.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{const p=zt[zt.length-1];if(!p||p.role!=="assistant")return;const b=p.parts?.filter(M=>M.type?.startsWith("tool-")&&M.state==="input-available"&&typeof M.toolCallId=="string"&&M.input!==void 0)||[];for(const M of b){const S=M,k=S.type?.replace("tool-","")||"",N=S.toolCallId;if(ze.has(k)){if(Oe.has(N))continue;P(B=>B.has(N)?B:new Set(B).add(N)),(async()=>{try{const B=dn.get(k);if(!B){console.warn(`[ArctenAgent] Tool ${k} not found in toolsMap. Available tools:`,Array.from(dn.keys())),te({toolCallId:N,tool:k,output:`Error: Tool ${k} not found`}),P(ot=>{const Ut=new Set(ot);return Ut.delete(N),Ut});return}const nt=ss(S.input),K=un.find(ot=>ot.name===k);let ht;if(K&&K.jsonSchema?.properties){const Ut=Object.keys(K.jsonSchema.properties).map($a=>nt[$a]);console.log(`[ArctenAgent] Executing safe tool ${k} with args:`,Ut),ht=await B(...Ut)}else if(k==="getState")ht=B();else if(k==="setState"){const ot=nt.updates||nt;ht=await B(ot)}else ht=await B(...Object.values(nt));console.log(`[ArctenAgent] Tool ${k} completed, result:`,ht),te({toolCallId:N,tool:k,output:ht}),P(ot=>{const Ut=new Set(ot);return Ut.delete(N),Ut})}catch(B){console.error(`[ArctenAgent] Error executing safe tool ${k}:`,B),te({toolCallId:N,tool:k,output:`Error: ${B instanceof Error?B.message:String(B)}`}),P(nt=>{const K=new Set(nt);return K.delete(N),K})}})()}}},[zt,ze,dn,un,te]),m.useEffect(()=>{if(!jt||!E.current)return;(async()=>{F(!0),lt(null);try{const M=`${v.replace("/chat","").replace(/\/$/,"")}/convex/api/query`,S=await fetch(M,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:jt},format:"json"})});if(!S.ok){if(S.status===404||S.status>=500){console.warn(`[ArctenAgent] Convex API endpoint not available (${S.status}), using empty state`);const K=U?y||{}:{};rt.current=K,U||Tt(K),w&&w(K),ut.current=!0,F(!1);return}const nt=await S.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${S.status} ${nt}`)}const N=(await S.json())?.value||{},et=!ut.current;let B;et?(B={...U?y||{}:{},...N},ut.current=!0):B=N,rt.current=B,U||Tt(B),w&&w(B)}catch(b){b instanceof TypeError&&b.message.includes("fetch")?console.warn("[ArctenAgent] Network error fetching state (likely Convex endpoint not available), using fallback state:",b):console.error("[ArctenAgent] Failed to fetch state:",b);const S=b instanceof Error?b:new Error(String(b));if(lt(S),!ut.current){const k=U?y||{}:{};rt.current=k,U||Tt(k),w&&w(k),ut.current=!0}}finally{F(!1)}})()},[jt,v,U,y,w]),m.useEffect(()=>{dt&&ye.current&&ye.current.focus()},[dt,zt]);function Va(){Vt(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function Ra(){Vt(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[dt]),m.useEffect(()=>{Jt.current&&Jt.current.scrollIntoView({behavior:"smooth"})},[zt]),m.useEffect(()=>{function p(b){b.key==="Escape"&&(Et==="streaming"||Et==="submitted")&&(b.preventDefault(),hn())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[Et,hn]);function Na(){const p=crypto.randomUUID();Fe(p),fn([]),ln([]),an(!1)}function pi(p){if(p.preventDefault(),!xe.trim())return;(Et==="streaming"||Et==="submitted")&&hn();const b=fi[Math.floor(Math.random()*fi.length)]||"Thinking...";Fn(b),Da({text:xe}),Ie("")}function Ia(p){const b=p.target.value;Ie(b)}m.useEffect(()=>{if(!Mt)return;function p(M){if(W){const S=M.clientX-gt.x,k=M.clientY-gt.y;S>=a&&S<=c&&he(S),k>=400&&k<=1e3&&Xt(k)}else{const S=window.innerWidth-M.clientX;S>=a&&S<=c&&he(S)}}function b(){Rt(!1),localStorage.setItem("arcten-sidebar-width",yt.toString()),localStorage.setItem("arcten-sidebar-height",Gt.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[Mt,yt,Gt,W,gt,a,c]);function La(p){p.preventDefault(),Rt(!0)}function Oa(){fe(!0),qt(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function Fa(){fe(!1),qt(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function gi(){qt(!pt),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!pt))}function Ba(p){W&&(Ne(!0),pe({x:p.clientX-gt.x,y:p.clientY-gt.y}))}return m.useEffect(()=>{if(!W)return;function p(){me(b=>{const S=window.innerWidth-50,k=window.innerHeight-50,N=50-yt,et=0,B=Math.max(N,Math.min(b.x,S)),nt=Math.max(et,Math.min(b.y,k));if(B!==b.x||nt!==b.y){const K={x:B,y:nt};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(K)),K}return b})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[W,yt]),m.useEffect(()=>{if(!St)return;function p(M){const S=M.clientX-Yt.x,k=M.clientY-Yt.y,N=50,et=window.innerWidth-N,B=window.innerHeight-N,nt=N-yt,K=0,ht=Math.max(nt,Math.min(S,et)),ot=Math.max(K,Math.min(k,B));me({x:ht,y:ot})}function b(){Ne(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(gt))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",b)}},[St,Yt,gt,yt]),In?O?h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",O]})}):D?h.jsx(ru,{features:Ih,children:h.jsx(xn,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:W?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:W?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
20
|
+
${W?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
|
|
21
21
|
${dt?"bg-stone-50 dark:bg-stone-900":"bg-stone-100 dark:bg-stone-800 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors duration-200"}
|
|
22
|
-
${
|
|
22
|
+
${W?"border border-border":"border-l border-border"}
|
|
23
23
|
${dt?"":"w-[30px]"}
|
|
24
|
-
`,style:dt?_?{width:`${yt}px`,height:pt?"auto":`${Gt}px`,left:`${gt.x}px`,top:`${gt.y}px`}:{width:`${yt}px`}:void 0,onClick:dt?void 0:Va,children:dt?h.jsxs(h.Fragment,{children:[!_&&h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:La,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),_&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:p=>{p.preventDefault(),Rt(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:p=>{p.preventDefault(),p.stopPropagation(),Ne(!0),pe({x:p.clientX-gt.x,y:p.clientY-gt.y})},children:h.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:p=>{p.preventDefault(),Rt(!0)}})]}),h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${_?"cursor-move":""}`,onMouseDown:_?Ba:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${_&&pt?"cursor-pointer":""}`,onClick:_&&pt?p=>{p.stopPropagation(),gi()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"button",className:st(re({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Na,"aria-label":"New chat",children:h.jsx(Z.Plus,{className:"h-4 w-4"})})}),h.jsx(se,{children:"Start a new conversation"})]}),h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"button",className:st(re({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:_?Fa:Oa,"aria-label":_?"Dock sidebar":"Float sidebar",children:_?h.jsx(Z.Dock,{className:"h-4 w-4"}):h.jsx(Z.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(se,{children:_?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"button",className:st(re({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:_?gi:Ra,"aria-label":_?pt?"Maximize":"Minimize":"Close sidebar",children:_?pt?h.jsx(Z.Maximize2,{className:"h-4 w-4"}):h.jsx(Z.Minimize2,{className:"h-4 w-4"}):h.jsx(Z.X,{className:"h-4 w-4"})})}),h.jsx(se,{children:_?pt?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!pt&&h.jsxs(h.Fragment,{children:[A&&Nt.length>0&&h.jsxs("div",{className:`border-b border-border ${ve?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(Pn,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{ve||$n(),an(!ve)},children:ve?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${ve?"flex-1 overflow-y-auto":""}`,children:Nt.slice(0,ve?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:st(re({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>Ea(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:Ca(p.updatedAt)})})]}),h.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:b=>{b.stopPropagation(),ja(p._id)},"aria-label":"Delete conversation",children:h.jsx(Z.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:zt.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&h.jsx("div",{className:"mb-6",children:o}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),I.length>0&&h.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:h.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[(W?I:I.slice(0,10)).map(p=>h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Ie(p.sampleUsage),ye.current?.focus()},children:p.friendlyName})}),h.jsx(se,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:p.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',p.sampleUsage,'"']}),p.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",p.params.join(", ")]})]})})]},p.name)),I.length>10&&!W&&h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsxs(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>rt(!0),children:["+",I.length-10," more"]})}),h.jsx(se,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),h.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:I.slice(10).map(p=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[p.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:p.description})]},p.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),W&&I.length>10&&h.jsx(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>rt(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[zt.map(p=>{const M=p.parts.filter(S=>S.type==="text").map(S=>S.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(Lh,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:M}):h.jsx("div",{className:"space-y-2",children:p.parts.map((S,k)=>{if(S.type?.startsWith("tool-")){const N=S.type?.replace("tool-","")||"",tt=un.find(K=>K.name===N),B=S.state==="input-available",et=S.state==="output-available";if(B&&ze.has(N),B){if(ze.has(N))return null;const K=ss(S.input);return h.jsx(xn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(Bh,{toolName:N,description:tt?.description||"",args:K,onApprove:async()=>{if(Oe.has(S.toolCallId))return;P(ot=>new Set(ot).add(S.toolCallId));const ht=dn.get(N);if(ht)try{const ot=await ht(...Object.values(K));te({toolCallId:S.toolCallId,tool:N,output:ot})}catch(ot){te({toolCallId:S.toolCallId,tool:N,output:`Error: ${ot}`})}},onDeny:async()=>{Oe.has(S.toolCallId)||(P(ht=>new Set(ht).add(S.toolCallId)),te({toolCallId:S.toolCallId,tool:N,output:"User denied tool execution"}))}})},`${S.toolCallId}-${k}`)}else if(et){const K=S.output==="User denied tool execution",ht=ss(S.input);return h.jsx($h,{toolName:N,args:ht,isDenied:K,isSafe:ze.has(N)},`${S.toolCallId}-${k}`)}return null}if(S.type==="text"&&S.text&&Le){const N=Zh(S.text);return h.jsx(Le,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:N},`${p.id}-${k}`)}return S.type==="reasoning"&&S.text?h.jsxs(Sa,{className:"w-full",isStreaming:Et==="streaming"&&k===p.parts.length-1&&p.id===zt.at(-1)?.id,children:[h.jsx(Aa,{}),h.jsx(Pa,{children:S.text})]},`${p.id}-${k}`):null})})})},p.id)}),h.jsx("div",{ref:Jt})]})}),mi&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",mi.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(iu,{mode:"wait",children:(Et==="streaming"||Et==="submitted")&&h.jsxs(xn,{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(xn,{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:On})]})}),h.jsxs("form",{onSubmit:pi,className:"relative",children:[h.jsx(Fr,{ref:ye,value:xe,onChange:Ia,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(),pi(p))}}),Et==="streaming"||Et==="submitted"?h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"button",className:st(re({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:hn,children:h.jsx(Z.Square,{className:"h-4 w-4"})})}),h.jsxs(se,{children:[h.jsx(vi,{children:"Escape"})," to stop"]})]}):h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"submit",className:st(re({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!xe.trim(),children:h.jsx(Z.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(se,{children:[h.jsx(vi,{children:"Enter"})," to send"]})]})]})]})]}),h.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[h.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(Z.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 qe(t){if(typeof t=="string")try{const e=JSON.parse(t);return qe(e)}catch{return t}if(Array.isArray(t))return t.map(qe);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=qe(s);return e}return t}function tf(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return qe(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?qe(t):{}}function ef({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:o=[],safeTools:r=[],toolMetadata:a,systemPrompt:c="",initialMessages:u=[],conversationId:l,initialState:d={},onToolCall:f,onFinish:g,ragFilters:x}={}){const[v,A]=m.useState(n||null),y=m.useRef(n||null),[w,T]=m.useState(null),[D,j]=m.useState(null),E=m.useRef(null),[O,R]=m.useState([]),[$,q]=m.useState(l||(typeof window<"u"?crypto.randomUUID():null)),[Q,z]=m.useState(!1),[de,Tt]=m.useState(new Set),[it,Bt]=m.useState(d),F=m.useRef(d),[ct,lt]=m.useState(!1),[ut,dt]=m.useState(null),Vt=m.useRef(!1),yt=m.useCallback(async(P,C=3)=>{if(!$||!y.current)return;const V=async()=>{const I=await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:$,updates:P},format:"json"})});if(!I.ok){const U=await I.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${I.status} ${U}`)}};for(let I=0;I<C;I++)try{await V(),dt(null);return}catch(U){if(I===C-1){const rt=U instanceof Error?U:new Error(String(U));throw dt(rt),console.error("Failed to sync state to Convex after retries:",U),rt}await new Promise(rt=>setTimeout(rt,Math.pow(2,I)*100))}},[$,t,y]),he=m.useMemo(()=>function(){return F.current},[]),Gt=m.useMemo(()=>async function(C){const V={...F.current,...C};F.current=V,Bt(V);try{await yt(C)}catch(I){throw I}},[yt]),Xt=m.useMemo(()=>[...o,...r,he,Gt],[o,r,he,Gt]),Mt=m.useMemo(()=>wa(Xt,a),[Xt,a]),Rt=m.useMemo(()=>{const P=new Map,C=new Map(Mt.map(V=>[V.name,V]));return Xt.forEach(V=>{const I=V[kt];if(I){const W=C.get(I);if(W){P.set(W.name,V);return}}const U=Mt.find(W=>W.name===V.name);U&&P.set(U.name,V)}),P},[Xt,Mt]),_=m.useMemo(()=>new Set(Mt.map(P=>P.name)),[Mt]),fe=m.useMemo(()=>{const P=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}},{name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}];return[...Mt,...P]},[Mt]),pt=m.useMemo(()=>fe.filter(P=>P.name==="getState"||P.name==="setState"?!0:_.has(P.name)),[fe,_]),qt=m.useMemo(()=>{const P=new Set;return P.add("getState"),P.add("setState"),r.forEach(C=>{for(const[V,I]of Rt.entries())if(I===C){P.add(V);break}}),P},[r,Rt]);m.useEffect(()=>s||n?void 0:((async()=>{try{const C=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!C.ok)throw new Error("Failed to fetch token");const V=await C.json();A(V.clientToken),y.current=V.clientToken,j(V.expiresAt),T(null)}catch(C){console.error("[useAgent] Token fetch failed:",C),T(C instanceof Error?C.message:"Failed to fetch token")}})(),()=>{E.current&&clearTimeout(E.current)}),[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(!D||s||n)return;E.current&&clearTimeout(E.current);const P=Math.floor(Date.now()/1e3),C=D-P,I=Math.max(0,C-5);return E.current=setTimeout(async()=>{try{const U=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!U.ok)throw new Error("Failed to refresh token");const W=await U.json();A(W.clientToken),y.current=W.clientToken,j(W.expiresAt),T(null)}catch(U){console.error("[useAgent] Token refresh failed:",U),T(U instanceof Error?U.message:"Failed to refresh token")}},I*1e3),()=>{E.current&&clearTimeout(E.current)}},[D,e,JSON.stringify(i),s,n]);const gt=async(P,C={})=>{const V=C.headers?new Headers(C.headers):new Headers;V.delete("user-agent"),V.delete("User-Agent"),console.log("[useAgent] Making request to:",P),console.log("[useAgent] Method:",C.method||"GET"),console.log("[useAgent] Has Authorization header:",V.has("Authorization")),console.log("[useAgent] Client token available:",!!y.current);try{const I=await fetch(P,{...C,headers:V});if(!I.ok){console.error("[useAgent] Request failed:",I.status,I.statusText);const U=await I.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",U)}return I}catch(I){throw console.error("[useAgent] Fetch error:",I),I}},me=`${t}/chat`;console.log("[useAgent] Chat API URL:",me);const{messages:St,sendMessage:Ne,status:Yt,error:pe,stop:In,addToolResult:ge,setMessages:Jt}=Ir.useChat({id:$||void 0,messages:u,transport:new An.DefaultChatTransport({api:me,fetch:gt,headers:()=>{const P={};return y.current?(P.Authorization=`Bearer ${y.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),P},body:()=>{const P=pt.map(V=>({name:V.name,description:V.description,inputSchema:V.jsonSchema})),C=P.filter(V=>V.name==="getState"||V.name==="setState").map(V=>V.name);return C.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",C),{tools:P,systemPrompt:c,state:F.current,...x&&{ragFilters:x}}}}),sendAutomaticallyWhen:An.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{St.forEach(P=>{P.role==="assistant"&&P.parts.forEach(C=>{if(!C.type?.startsWith("tool-")||C.state!=="input-available")return;const V=C.type.replace("tool-",""),I=C.toolCallId;if(de.has(I))return;Tt(W=>new Set(W).add(I));const U=tf(C.input);if(qt.has(V)){const W=Rt.get(V);W?(async()=>{try{const rt=pt.find(Zt=>Zt.name===V);let Nt;if(rt&&rt.jsonSchema?.properties){const jt=Object.keys(rt.jsonSchema.properties).map(Fe=>U[Fe]);Nt=await W(...jt)}else if(V==="getState")Nt=W();else if(V==="setState"){const Zt=U.updates||U;Nt=await W(Zt)}else Nt=await W(...Object.values(U));ge({toolCallId:I,tool:V,output:Nt})}catch(rt){console.error(`[useAgent] Error executing tool ${V}:`,rt),ge({toolCallId:I,tool:V,output:`Error: ${rt}`})}})():console.warn(`[useAgent] Tool ${V} not found in toolsMap`)}else f&&f({toolCall:{toolCallId:I,toolName:V,args:U}})})})},[St,qt,Rt,f,ge,de,Gt,pt]),m.useEffect(()=>{if(Yt==="ready"&&St.length>0&&g){const P=St[St.length-1];P&&P.role==="assistant"&&g({message:P,messages:St,isAbort:!1,isDisconnect:!1,isError:!!pe})}},[Yt,St,pe,g]);async function ye(){if(!(!i?.id||!v)){z(!0);try{const C=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${v}`}})).json();R(C.conversations||[])}catch(P){console.error("Failed to fetch conversations:",P)}finally{z(!1)}}}m.useEffect(()=>{i?.id&&v&&ye()},[JSON.stringify(i),v,t]),m.useEffect(()=>{if(!$||!y.current)return;(async()=>{lt(!0),dt(null);try{const C=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:$},format:"json"})});if(!C.ok){const rt=await C.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${C.status} ${rt}`)}const I=(await C.json())?.value||{},U=!Vt.current;let W;U?(W={...d,...I},Vt.current=!0):W=I,F.current=W,Bt(W)}catch(C){console.error("Failed to fetch state:",C);const V=C instanceof Error?C:new Error(String(C));dt(V),Vt.current||(F.current=d,Bt(d),Vt.current=!0)}finally{lt(!1)}})()},[$,t]);async function xe(P){q(P),z(!0);try{const C=await fetch(`${t}/conversations/${P}/messages`,{headers:{Authorization:`Bearer ${y.current}`}});if(!C.ok)throw new Error(`Failed to fetch messages: ${C.statusText}`);const I=(await C.json()).messages||[];Jt(I)}catch(C){console.error("Failed to load conversation messages:",C)}finally{z(!1)}}async function Ie(P){if(v)try{await fetch(`${t}/conversations/${P}`,{method:"DELETE",headers:{Authorization:`Bearer ${v}`}}),R(O.filter(C=>C._id!==P)),P===$&&Le()}catch(C){console.error("Failed to delete conversation:",C)}}function Le(){const P=crypto.randomUUID();q(P),Jt([]),Tt(new Set),F.current=d,Bt(d),Vt.current=!1}function Ln(P){ge(P)}async function On(P){const C={...F.current,...P};F.current=C,Bt(C);try{await yt(P)}catch(V){throw V}}async function Fn(){if(!i?.id||!y.current)throw new Error("User authentication required to share state");const P=`shared_${crypto.randomUUID()}`;try{return await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:create",args:{stateId:P,state:F.current,projectId:"default",createdBy:i.id},format:"json"})}),P}catch(C){throw console.error("Failed to share state:",C),C}}async function Oe(P){if(!y.current)throw new Error("Authentication required to import state");try{const C=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:getByStateId",args:{stateId:P},format:"json"})});if(!C.ok)throw new Error("Failed to fetch shared state");const I=(await C.json())?.value||{};F.current=I,Bt(I)}catch(C){throw console.error("Failed to import state:",C),C}}return{id:$,messages:St,status:Yt,error:pe,sendMessage:Ne,stop:In,addToolOutput:Ln,setMessages:Jt,conversations:O,loadConversation:xe,deleteConversation:Ie,startNewConversation:Le,isLoadingConversations:Q,clientToken:v,tokenError:w,state:it,setState:On,shareState:Fn,importState:Oe,isStateLoading:ct,stateError:ut}}exports.verifyToken=Za.verifyToken;exports.ARCTEN_ORIGINAL_NAME=kt;exports.ArctenAgent=Qh;exports.preserveToolName=Oh;exports.useAgent=ef;
|
|
24
|
+
`,style:dt?W?{width:`${yt}px`,height:pt?"auto":`${Gt}px`,left:`${gt.x}px`,top:`${gt.y}px`}:{width:`${yt}px`}:void 0,onClick:dt?void 0:Va,children:dt?h.jsxs(h.Fragment,{children:[!W&&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:La,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),W&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:p=>{p.preventDefault(),Rt(!0)}}),h.jsx("div",{className:"absolute bottom-0 left-4 right-4 h-3 cursor-move hover:bg-blue-500/20 group",onMouseDown:p=>{p.preventDefault(),p.stopPropagation(),Ne(!0),pe({x:p.clientX-gt.x,y:p.clientY-gt.y})},children:h.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-8 h-1 rounded-full bg-stone-400/30 group-hover:bg-blue-500/40 transition-colors"})}),h.jsx("div",{className:"absolute top-0 right-0 bottom-0 w-1 cursor-ew-resize hover:bg-blue-500/40",onMouseDown:p=>{p.preventDefault(),Rt(!0)}})]}),h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${W?"cursor-move":""}`,onMouseDown:W?Ba:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${W&&pt?"cursor-pointer":""}`,onClick:W&&pt?p=>{p.stopPropagation(),gi()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"button",className:it(re({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:Na,"aria-label":"New chat",children:h.jsx(Z.Plus,{className:"h-4 w-4"})})}),h.jsx(se,{children:"Start a new conversation"})]}),h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"button",className:it(re({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:W?Fa:Oa,"aria-label":W?"Dock sidebar":"Float sidebar",children:W?h.jsx(Z.Dock,{className:"h-4 w-4"}):h.jsx(Z.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(se,{children:W?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"button",className:it(re({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:W?gi:Ra,"aria-label":W?pt?"Maximize":"Minimize":"Close sidebar",children:W?pt?h.jsx(Z.Maximize2,{className:"h-4 w-4"}):h.jsx(Z.Minimize2,{className:"h-4 w-4"}):h.jsx(Z.X,{className:"h-4 w-4"})})}),h.jsx(se,{children:W?pt?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!pt&&h.jsxs(h.Fragment,{children:[A&&Nt.length>0&&h.jsxs("div",{className:`border-b border-border ${ve?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(Pn,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{ve||$n(),an(!ve)},children:ve?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${ve?"flex-1 overflow-y-auto":""}`,children:Nt.slice(0,ve?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:it(re({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>Ea(p),children:[h.jsx("span",{className:"text-xs truncate",children:p.title}),h.jsx("div",{className:"ml-2 flex items-center",children:h.jsx("span",{className:"text-xs text-muted-foreground group-hover:hidden",children:Ca(p.updatedAt)})})]}),h.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:b=>{b.stopPropagation(),ja(p._id)},"aria-label":"Delete conversation",children:h.jsx(Z.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:zt.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[o&&h.jsx("div",{className:"mb-6",children:o}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),L.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:[(z?L:L.slice(0,10)).map(p=>h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{Ie(p.sampleUsage),ye.current?.focus()},children:p.friendlyName})}),h.jsx(se,{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)),L.length>10&&!z&&h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsxs(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>tt(!0),children:["+",L.length-10," more"]})}),h.jsx(se,{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:L.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"})]})})]}),z&&L.length>10&&h.jsx(zn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>tt(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[zt.map(p=>{const M=p.parts.filter(S=>S.type==="text").map(S=>S.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(Lh,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:M}):h.jsx("div",{className:"space-y-2",children:p.parts.map((S,k)=>{if(S.type?.startsWith("tool-")){const N=S.type?.replace("tool-","")||"",et=un.find(K=>K.name===N),B=S.state==="input-available",nt=S.state==="output-available";if(B&&ze.has(N),B){if(ze.has(N))return null;const K=ss(S.input);return h.jsx(xn,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(Bh,{toolName:N,description:et?.description||"",args:K,onApprove:async()=>{if(Oe.has(S.toolCallId))return;P(ot=>new Set(ot).add(S.toolCallId));const ht=dn.get(N);if(ht)try{const ot=await ht(...Object.values(K));te({toolCallId:S.toolCallId,tool:N,output:ot})}catch(ot){te({toolCallId:S.toolCallId,tool:N,output:`Error: ${ot}`})}},onDeny:async()=>{Oe.has(S.toolCallId)||(P(ht=>new Set(ht).add(S.toolCallId)),te({toolCallId:S.toolCallId,tool:N,output:"User denied tool execution"}))}})},`${S.toolCallId}-${k}`)}else if(nt){const K=S.output==="User denied tool execution",ht=ss(S.input);return h.jsx($h,{toolName:N,args:ht,isDenied:K,isSafe:ze.has(N)},`${S.toolCallId}-${k}`)}return null}if(S.type==="text"&&S.text&&Le){const N=Zh(S.text);return h.jsx(Le,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:N},`${p.id}-${k}`)}return S.type==="reasoning"&&S.text?h.jsxs(Sa,{className:"w-full",isStreaming:Et==="streaming"&&k===p.parts.length-1&&p.id===zt.at(-1)?.id,children:[h.jsx(Aa,{}),h.jsx(Pa,{children:S.text})]},`${p.id}-${k}`):null})})})},p.id)}),h.jsx("div",{ref:Jt})]})}),mi&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",mi.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(iu,{mode:"wait",children:(Et==="streaming"||Et==="submitted")&&h.jsxs(xn,{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(xn,{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:On})]})}),h.jsxs("form",{onSubmit:pi,className:"relative",children:[h.jsx(Fr,{ref:ye,value:xe,onChange:Ia,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(),pi(p))}}),Et==="streaming"||Et==="submitted"?h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"button",className:it(re({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:hn,children:h.jsx(Z.Square,{className:"h-4 w-4"})})}),h.jsxs(se,{children:[h.jsx(vi,{children:"Escape"})," to stop"]})]}):h.jsxs(ee,{children:[h.jsx(ne,{asChild:!0,children:h.jsx("button",{type:"submit",className:it(re({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!xe.trim(),children:h.jsx(Z.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(se,{children:[h.jsx(vi,{children:"Enter"})," to send"]})]})]})]})]}),h.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all",children:[h.jsx("span",{className:"whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(Z.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 qe(t){if(typeof t=="string")try{const e=JSON.parse(t);return qe(e)}catch{return t}if(Array.isArray(t))return t.map(qe);if(t&&typeof t=="object"){const e={};for(const[n,s]of Object.entries(t))e[n]=qe(s);return e}return t}function tf(t){if(typeof t=="string"){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return qe(e)}catch{}return{}}return t&&typeof t=="object"&&!Array.isArray(t)?qe(t):{}}function ef({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:o=[],safeTools:r=[],toolMetadata:a,systemPrompt:c="",initialMessages:u=[],conversationId:l,initialState:d={},onToolCall:f,onFinish:g,ragFilters:x}={}){const[v,A]=m.useState(n||null),y=m.useRef(n||null),[w,T]=m.useState(null),[D,j]=m.useState(null),E=m.useRef(null),[O,R]=m.useState([]),[$,q]=m.useState(l||(typeof window<"u"?crypto.randomUUID():null)),[Q,U]=m.useState(!1),[de,Tt]=m.useState(new Set),[rt,Bt]=m.useState(d),F=m.useRef(d),[ct,lt]=m.useState(!1),[ut,dt]=m.useState(null),Vt=m.useRef(!1),yt=m.useCallback(async(P,C=3)=>{if(!$||!y.current)return;const V=async()=>{const _=`${t.replace("/chat","").replace(/\/$/,"")}/convex/api/mutation`,z=await fetch(_,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:mergeStateByChatId",args:{chatId:$,updates:P},format:"json"})});if(!z.ok){if(z.status===404){console.warn("[useAgent] Convex API endpoint not available (404), state changes will not be persisted");return}const tt=await z.text().catch(()=>"Unknown error");throw new Error(`Failed to sync conversation state: ${z.status} ${tt}`)}};for(let L=0;L<C;L++)try{await V(),dt(null);return}catch(_){if(L===C-1){const tt=_ instanceof Error?_:new Error(String(_));throw dt(tt),console.error("Failed to sync state to Convex after retries:",_),tt}await new Promise(tt=>setTimeout(tt,Math.pow(2,L)*100))}},[$,t,y]),he=m.useMemo(()=>function(){return F.current},[]),Gt=m.useMemo(()=>async function(C){const V={...F.current,...C};F.current=V,Bt(V);try{await yt(C)}catch(L){throw L}},[yt]),Xt=m.useMemo(()=>[...o,...r,he,Gt],[o,r,he,Gt]),Mt=m.useMemo(()=>wa(Xt,a),[Xt,a]),Rt=m.useMemo(()=>{const P=new Map,C=new Map(Mt.map(V=>[V.name,V]));return Xt.forEach(V=>{const L=V[kt];if(L){const z=C.get(L);if(z){P.set(z.name,V);return}}const _=Mt.find(z=>z.name===V.name);_&&P.set(_.name,V)}),P},[Xt,Mt]),W=m.useMemo(()=>new Set(Mt.map(P=>P.name)),[Mt]),fe=m.useMemo(()=>{const P=[{name:"getState",description:"Get the current agent state. Returns IDs, workflow state, checklists, and other persistent data.",jsonSchema:{type:"object",properties:{},required:[]}},{name:"setState",description:"Update the agent state. Store IDs, workflow state, checklists, context, and other data that must persist across conversations. Merges with existing state.",jsonSchema:{type:"object",properties:{updates:{type:"object",description:"Partial state updates to merge with existing state"}},required:["updates"]}}];return[...Mt,...P]},[Mt]),pt=m.useMemo(()=>fe.filter(P=>P.name==="getState"||P.name==="setState"?!0:W.has(P.name)),[fe,W]),qt=m.useMemo(()=>{const P=new Set;return P.add("getState"),P.add("setState"),r.forEach(C=>{for(const[V,L]of Rt.entries())if(L===C){P.add(V);break}}),P},[r,Rt]);m.useEffect(()=>s||n?void 0:((async()=>{try{const C=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!C.ok)throw new Error("Failed to fetch token");const V=await C.json();A(V.clientToken),y.current=V.clientToken,j(V.expiresAt),T(null)}catch(C){console.error("[useAgent] Token fetch failed:",C),T(C instanceof Error?C.message:"Failed to fetch token")}})(),()=>{E.current&&clearTimeout(E.current)}),[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(!D||s||n)return;E.current&&clearTimeout(E.current);const P=Math.floor(Date.now()/1e3),C=D-P,L=Math.max(0,C-5);return E.current=setTimeout(async()=>{try{const _=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!_.ok)throw new Error("Failed to refresh token");const z=await _.json();A(z.clientToken),y.current=z.clientToken,j(z.expiresAt),T(null)}catch(_){console.error("[useAgent] Token refresh failed:",_),T(_ instanceof Error?_.message:"Failed to refresh token")}},L*1e3),()=>{E.current&&clearTimeout(E.current)}},[D,e,JSON.stringify(i),s,n]);const gt=async(P,C={})=>{const V=C.headers?new Headers(C.headers):new Headers;V.delete("user-agent"),V.delete("User-Agent"),console.log("[useAgent] Making request to:",P),console.log("[useAgent] Method:",C.method||"GET"),console.log("[useAgent] Has Authorization header:",V.has("Authorization")),console.log("[useAgent] Client token available:",!!y.current);try{const L=await fetch(P,{...C,headers:V});if(!L.ok){console.error("[useAgent] Request failed:",L.status,L.statusText);const _=await L.text().catch(()=>"Unable to read error response");console.error("[useAgent] Error response:",_)}return L}catch(L){throw console.error("[useAgent] Fetch error:",L),L}},me=`${t}/chat`;console.log("[useAgent] Chat API URL:",me);const{messages:St,sendMessage:Ne,status:Yt,error:pe,stop:In,addToolResult:ge,setMessages:Jt}=Ir.useChat({id:$||void 0,messages:u,transport:new An.DefaultChatTransport({api:me,fetch:gt,headers:()=>{const P={};return y.current?(P.Authorization=`Bearer ${y.current}`,console.log("[useAgent] Adding Authorization header with token")):console.warn("[useAgent] No client token available - request may fail"),P},body:()=>{const P=pt.map(V=>({name:V.name,description:V.description,inputSchema:V.jsonSchema})),C=P.filter(V=>V.name==="getState"||V.name==="setState").map(V=>V.name);return C.length>0&&console.log("[useAgent] State tools included in tools list sent to AI SDK:",C),{tools:P,systemPrompt:c,state:F.current,...x&&{ragFilters:x}}}}),sendAutomaticallyWhen:An.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{St.forEach(P=>{P.role==="assistant"&&P.parts.forEach(C=>{if(!C.type?.startsWith("tool-")||C.state!=="input-available")return;const V=C.type.replace("tool-",""),L=C.toolCallId;if(de.has(L))return;Tt(z=>new Set(z).add(L));const _=tf(C.input);if(qt.has(V)){const z=Rt.get(V);z?(async()=>{try{const tt=pt.find(Zt=>Zt.name===V);let Nt;if(tt&&tt.jsonSchema?.properties){const jt=Object.keys(tt.jsonSchema.properties).map(Fe=>_[Fe]);Nt=await z(...jt)}else if(V==="getState")Nt=z();else if(V==="setState"){const Zt=_.updates||_;Nt=await z(Zt)}else Nt=await z(...Object.values(_));ge({toolCallId:L,tool:V,output:Nt})}catch(tt){console.error(`[useAgent] Error executing tool ${V}:`,tt),ge({toolCallId:L,tool:V,output:`Error: ${tt}`})}})():console.warn(`[useAgent] Tool ${V} not found in toolsMap`)}else f&&f({toolCall:{toolCallId:L,toolName:V,args:_}})})})},[St,qt,Rt,f,ge,de,Gt,pt]),m.useEffect(()=>{if(Yt==="ready"&&St.length>0&&g){const P=St[St.length-1];P&&P.role==="assistant"&&g({message:P,messages:St,isAbort:!1,isDisconnect:!1,isError:!!pe})}},[Yt,St,pe,g]);async function ye(){if(!(!i?.id||!v)){U(!0);try{const C=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${v}`}})).json();R(C.conversations||[])}catch(P){console.error("Failed to fetch conversations:",P)}finally{U(!1)}}}m.useEffect(()=>{i?.id&&v&&ye()},[JSON.stringify(i),v,t]),m.useEffect(()=>{if(!$||!y.current)return;(async()=>{lt(!0),dt(null);try{const C=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"conversations:getStateByChatId",args:{chatId:$},format:"json"})});if(!C.ok){const tt=await C.text().catch(()=>"Unknown error");throw new Error(`Failed to fetch conversation state: ${C.status} ${tt}`)}const L=(await C.json())?.value||{},_=!Vt.current;let z;_?(z={...d,...L},Vt.current=!0):z=L,F.current=z,Bt(z)}catch(C){console.error("Failed to fetch state:",C);const V=C instanceof Error?C:new Error(String(C));dt(V),Vt.current||(F.current=d,Bt(d),Vt.current=!0)}finally{lt(!1)}})()},[$,t]);async function xe(P){q(P),U(!0);try{const C=await fetch(`${t}/conversations/${P}/messages`,{headers:{Authorization:`Bearer ${y.current}`}});if(!C.ok)throw new Error(`Failed to fetch messages: ${C.statusText}`);const L=(await C.json()).messages||[];Jt(L)}catch(C){console.error("Failed to load conversation messages:",C)}finally{U(!1)}}async function Ie(P){if(v)try{await fetch(`${t}/conversations/${P}`,{method:"DELETE",headers:{Authorization:`Bearer ${v}`}}),R(O.filter(C=>C._id!==P)),P===$&&Le()}catch(C){console.error("Failed to delete conversation:",C)}}function Le(){const P=crypto.randomUUID();q(P),Jt([]),Tt(new Set),F.current=d,Bt(d),Vt.current=!1}function Ln(P){ge(P)}async function On(P){const C={...F.current,...P};F.current=C,Bt(C);try{await yt(P)}catch(V){throw V}}async function Fn(){if(!i?.id||!y.current)throw new Error("User authentication required to share state");const P=`shared_${crypto.randomUUID()}`;try{return await fetch(`${t.replace("/chat","")}/convex/api/mutation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:create",args:{stateId:P,state:F.current,projectId:"default",createdBy:i.id},format:"json"})}),P}catch(C){throw console.error("Failed to share state:",C),C}}async function Oe(P){if(!y.current)throw new Error("Authentication required to import state");try{const C=await fetch(`${t.replace("/chat","")}/convex/api/query`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${y.current}`},body:JSON.stringify({path:"sharedStates:getByStateId",args:{stateId:P},format:"json"})});if(!C.ok)throw new Error("Failed to fetch shared state");const L=(await C.json())?.value||{};F.current=L,Bt(L)}catch(C){throw console.error("Failed to import state:",C),C}}return{id:$,messages:St,status:Yt,error:pe,sendMessage:Ne,stop:In,addToolOutput:Ln,setMessages:Jt,conversations:O,loadConversation:xe,deleteConversation:Ie,startNewConversation:Le,isLoadingConversations:Q,clientToken:v,tokenError:w,state:rt,setState:On,shareState:Fn,importState:Oe,isStateLoading:ct,stateError:ut}}exports.verifyToken=Za.verifyToken;exports.ARCTEN_ORIGINAL_NAME=kt;exports.ArctenAgent=Qh;exports.preserveToolName=Oh;exports.useAgent=ef;
|