@arcteninc/core 0.0.30 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ArctenAgent.d.ts.map +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.mjs +1872 -1856
- package/dist/lib/useAgent.d.ts.map +1 -1
- package/package.json +1 -1
- package/scripts/cli-extract-types-auto.ts +125 -13
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ga=Object.create;var _s=Object.defineProperty;var ya=Object.getOwnPropertyDescriptor;var xa=Object.getOwnPropertyNames;var va=Object.getPrototypeOf,ba=Object.prototype.hasOwnProperty;var wa=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of xa(e))!ba.call(t,i)&&i!==n&&_s(t,i,{get:()=>e[i],enumerable:!(s=ya(e,i))||s.enumerable});return t};var Ta=(t,e,n)=>(n=t!=null?ga(va(t)):{},wa(e||!t||!t.__esModule?_s(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),X=require("lucide-react"),lo=require("@ai-sdk/react"),Ke=require("ai"),co=require("@radix-ui/react-slot"),uo=require("class-variance-authority"),Sa=require("clsx"),Ca=require("tailwind-merge"),Aa=require("@radix-ui/react-tooltip"),Ks=require("@radix-ui/react-use-controllable-state"),Pa=require("@radix-ui/react-collapsible"),Ma=require("./server.cjs");function Gn(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const dt=Gn(m),ne=Gn(Aa),qn=Gn(Pa);function Z(...t){return Ca.twMerge(Sa.clsx(t))}const zt=uo.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),He=dt.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},r)=>{const o=s?co.Slot:"button";return h.jsx(o,{ref:r,"data-slot":"button",className:Z(zt({variant:e,size:n,className:t})),...i})});He.displayName="Button";const ja=uo.cva("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function un({className:t,variant:e,asChild:n=!1,...s}){const i=n?co.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:Z(ja({variant:e}),t),...s})}const Va=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,r]=dt.useState(!0);dt.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),r(!1)),a.style.height=`${s+6}px`;const l=a.scrollHeight;l>n?a.style.height=`${n}px`:a.style.height=`${l+6}px`}},[t.current,e])},ho=dt.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...r},o)=>{const a=dt.useRef(null),[l,u]=dt.useState("");return Va({textAreaRef:a,triggerAutoSize:l,maxHeight:t,minHeight:e}),m.useImperativeHandle(o,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),dt.useEffect(()=>{u(i)},[r?.defaultValue,i]),h.jsx("textarea",{...r,value:i,ref:a,className:Z("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:c=>{u(c.target.value),s?.(c)}})});ho.displayName="AutosizeTextarea";function Da({delayDuration:t=0,...e}){return h.jsx(ne.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Ot({...t}){return h.jsx(Da,{children:h.jsx(ne.Root,{"data-slot":"tooltip",...t})})}function Ft({...t}){return h.jsx(ne.Trigger,{"data-slot":"tooltip-trigger",...t})}function Bt({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(ne.Portal,{children:h.jsxs(ne.Content,{"data-slot":"tooltip-content",sideOffset:e,className:Z("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...s,children:[n,h.jsx(ne.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Hs({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:Z("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",t),...e})}const Zn=m.createContext({});function Jn(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const Qn=typeof window<"u",fo=Qn?m.useLayoutEffect:m.useEffect,Je=m.createContext(null);function ts(t,e){t.indexOf(e)===-1&&t.push(e)}function es(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const vt=(t,e,n)=>n>e?e:n<t?t:n;function Pn(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let re=()=>{},bt=()=>{};process.env.NODE_ENV!=="production"&&(re=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(Pn(e,n))},bt=(t,e,n)=>{if(!t)throw new Error(Pn(e,n))});const wt={},mo=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function po(t){return typeof t=="object"&&t!==null}const go=t=>/^0[^.\s]+$/u.test(t);function ns(t){let e;return()=>(e===void 0&&(e=t()),e)}const lt=t=>t,Ea=(t,e)=>n=>e(t(n)),Ce=(...t)=>t.reduce(Ea),xe=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class ss{constructor(){this.subscriptions=[]}add(e){return ts(this.subscriptions,e),()=>es(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let r=0;r<i;r++){const o=this.subscriptions[r];o&&o(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const ht=t=>t*1e3,at=t=>t/1e3;function yo(t,e){return e?t*(1e3/e):0}const Xs=new Set;function is(t,e,n){t||Xs.has(e)||(console.warn(Pn(e,n)),Xs.add(e))}const xo=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,ka=1e-7,Ra=12;function Na(t,e,n,s,i){let r,o,a=0;do o=e+(n-e)/2,r=xo(o,s,i)-t,r>0?n=o:e=o;while(Math.abs(r)>ka&&++a<Ra);return o}function Ae(t,e,n,s){if(t===e&&n===s)return lt;const i=r=>Na(r,0,1,t,n);return r=>r===0||r===1?r:xo(i(r),e,s)}const vo=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,bo=t=>e=>1-t(1-e),wo=Ae(.33,1.53,.69,.99),os=bo(wo),To=vo(os),So=t=>(t*=2)<1?.5*os(t):.5*(2-Math.pow(2,-10*(t-1))),rs=t=>1-Math.sin(Math.acos(t)),Co=bo(rs),Ao=vo(rs),Ia=Ae(.42,0,1,1),La=Ae(0,0,.58,1),Po=Ae(.42,0,.58,1),Oa=t=>Array.isArray(t)&&typeof t[0]!="number",Mo=t=>Array.isArray(t)&&typeof t[0]=="number",Ys={linear:lt,easeIn:Ia,easeInOut:Po,easeOut:La,circIn:rs,circInOut:Ao,circOut:Co,backIn:os,backInOut:To,backOut:wo,anticipate:So},Fa=t=>typeof t=="string",Gs=t=>{if(Mo(t)){bt(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return Ae(e,n,s,i)}else if(Fa(t))return bt(Ys[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),Ys[t];return t},Ie=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function Ba(t,e){let n=new Set,s=new Set,i=!1,r=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(c){o.has(c)&&(u.schedule(c),t()),c(a)}const u={schedule:(c,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&o.add(c),y.has(c)||y.add(c),c},cancel:c=>{s.delete(c),o.delete(c)},process:c=>{if(a=c,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,u.process(c))}};return u}const $a=40;function jo(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Ie.reduce((b,E)=>(b[E]=Ba(r),b),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:c,update:d,preRender:f,render:g,postRender:y}=o,v=()=>{const b=wt.useManualTiming?i.timestamp:performance.now();n=!1,wt.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(b-i.timestamp,$a),1)),i.timestamp=b,i.isProcessing=!0,a.process(i),l.process(i),u.process(i),c.process(i),d.process(i),f.process(i),g.process(i),y.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},w=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:Ie.reduce((b,E)=>{const A=o[E];return b[E]=(j,k=!1,P=!1)=>(n||w(),A.schedule(j,k,P)),b},{}),cancel:b=>{for(let E=0;E<Ie.length;E++)o[Ie[E]].cancel(b)},state:i,steps:o}}const{schedule:F,cancel:jt,state:q,steps:dn}=jo(typeof requestAnimationFrame<"u"?requestAnimationFrame:lt,!0);let $e;function za(){$e=void 0}const nt={now:()=>($e===void 0&&nt.set(q.isProcessing||wt.useManualTiming?q.timestamp:performance.now()),$e),set:t=>{$e=t,queueMicrotask(za)}},Vo=t=>e=>typeof e=="string"&&e.startsWith(t),as=Vo("--"),Ua=Vo("var(--"),ls=t=>Ua(t)?Wa.test(t.split("/*")[0].trim()):!1,Wa=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ae={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},ve={...ae,transform:t=>vt(0,1,t)},Le={...ae,default:1},me=t=>Math.round(t*1e5)/1e5,cs=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function _a(t){return t==null}const Ka=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,us=(t,e)=>n=>!!(typeof n=="string"&&Ka.test(n)&&n.startsWith(t)||e&&!_a(n)&&Object.prototype.hasOwnProperty.call(n,e)),Do=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(cs);return{[t]:parseFloat(i),[e]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Ha=t=>vt(0,255,t),hn={...ae,transform:t=>Math.round(Ha(t))},Wt={test:us("rgb","red"),parse:Do("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+hn.transform(t)+", "+hn.transform(e)+", "+hn.transform(n)+", "+me(ve.transform(s))+")"};function Xa(t){let e="",n="",s="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,s+=s,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const Mn={test:us("#"),parse:Xa,transform:Wt.transform},Pe=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Mt=Pe("deg"),yt=Pe("%"),M=Pe("px"),Ya=Pe("vh"),Ga=Pe("vw"),qs={...yt,parse:t=>yt.parse(t)/100,transform:t=>yt.transform(t*100)},qt={test:us("hsl","hue"),parse:Do("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+yt.transform(me(e))+", "+yt.transform(me(n))+", "+me(ve.transform(s))+")"},H={test:t=>Wt.test(t)||Mn.test(t)||qt.test(t),parse:t=>Wt.test(t)?Wt.parse(t):qt.test(t)?qt.parse(t):Mn.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Wt.transform(t):qt.transform(t),getAnimatableNone:t=>{const e=H.parse(t);return e.alpha=0,H.transform(e)}},qa=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Za(t){return isNaN(t)&&typeof t=="string"&&(t.match(cs)?.length||0)+(t.match(qa)?.length||0)>0}const Eo="number",ko="color",Ja="var",Qa="var(",Zs="${}",tl=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function be(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=e.replace(tl,l=>(H.test(l)?(s.color.push(r),i.push(ko),n.push(H.parse(l))):l.startsWith(Qa)?(s.var.push(r),i.push(Ja),n.push(l)):(s.number.push(r),i.push(Eo),n.push(parseFloat(l))),++r,Zs)).split(Zs);return{values:n,split:a,indexes:s,types:i}}function Ro(t){return be(t).values}function No(t){const{split:e,types:n}=be(t),s=e.length;return i=>{let r="";for(let o=0;o<s;o++)if(r+=e[o],i[o]!==void 0){const a=n[o];a===Eo?r+=me(i[o]):a===ko?r+=H.transform(i[o]):r+=i[o]}return r}}const el=t=>typeof t=="number"?0:H.test(t)?H.getAnimatableNone(t):t;function nl(t){const e=Ro(t);return No(t)(e.map(el))}const Vt={test:Za,parse:Ro,createTransformer:No,getAnimatableNone:nl};function fn(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function sl({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,r=0,o=0;if(!e)i=r=o=n;else{const a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;i=fn(l,a,t+1/3),r=fn(l,a,t),o=fn(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function Xe(t,e){return n=>n>0?e:t}const z=(t,e,n)=>t+(e-t)*n,mn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},il=[Mn,Wt,qt],ol=t=>il.find(e=>e.test(t));function Js(t){const e=ol(t);if(re(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===qt&&(n=sl(n)),n}const Qs=(t,e)=>{const n=Js(t),s=Js(e);if(!n||!s)return Xe(t,e);const i={...n};return r=>(i.red=mn(n.red,s.red,r),i.green=mn(n.green,s.green,r),i.blue=mn(n.blue,s.blue,r),i.alpha=z(n.alpha,s.alpha,r),Wt.transform(i))},jn=new Set(["none","hidden"]);function rl(t,e){return jn.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function al(t,e){return n=>z(t,e,n)}function ds(t){return typeof t=="number"?al:typeof t=="string"?ls(t)?Xe:H.test(t)?Qs:ul:Array.isArray(t)?Io:typeof t=="object"?H.test(t)?Qs:ll:Xe}function Io(t,e){const n=[...t],s=n.length,i=t.map((r,o)=>ds(r)(r,e[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function ll(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=ds(t[i])(t[i],e[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function cl(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const r=e.types[i],o=t.indexes[r][s[r]],a=t.values[o]??0;n[i]=a,s[r]++}return n}const ul=(t,e)=>{const n=Vt.createTransformer(e),s=be(t),i=be(e);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?jn.has(t)&&!i.values.length||jn.has(e)&&!s.values.length?rl(t,e):Ce(Io(cl(s,i),i.values),n):(re(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),Xe(t,e))};function Lo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?z(t,e,n):ds(t)(t,e)}const dl=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>F.update(e,n),stop:()=>jt(e),now:()=>q.isProcessing?q.timestamp:nt.now()}},Oo=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let r=0;r<i;r++)s+=Math.round(t(r/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Ye=2e4;function hs(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Ye;)e+=n,s=t.next(e);return e>=Ye?1/0:e}function hl(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(hs(s),Ye);return{type:"keyframes",ease:r=>s.next(i*r).value/e,duration:at(i)}}const fl=5;function Fo(t,e,n){const s=Math.max(e-fl,0);return yo(n-t(s),e-s)}const $={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},pn=.001;function ml({duration:t=$.duration,bounce:e=$.bounce,velocity:n=$.velocity,mass:s=$.mass}){let i,r;re(t<=ht($.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=vt($.minDamping,$.maxDamping,o),t=vt($.minDuration,$.maxDuration,at(t)),o<1?(i=u=>{const c=u*o,d=c*t,f=c-n,g=Vn(u,o),y=Math.exp(-d);return pn-f/g*y},r=u=>{const d=u*o*t,f=d*n+n,g=Math.pow(o,2)*Math.pow(u,2)*t,y=Math.exp(-d),v=Vn(Math.pow(u,2),o);return(-i(u)+pn>0?-1:1)*((f-g)*y)/v}):(i=u=>{const c=Math.exp(-u*t),d=(u-n)*t+1;return-pn+c*d},r=u=>{const c=Math.exp(-u*t),d=(n-u)*(t*t);return c*d});const a=5/t,l=gl(i,r,a);if(t=ht(t),isNaN(l))return{stiffness:$.stiffness,damping:$.damping,duration:t};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:o*2*Math.sqrt(s*u),duration:t}}}const pl=12;function gl(t,e,n){let s=n;for(let i=1;i<pl;i++)s=s-t(s)/e(s);return s}function Vn(t,e){return t*Math.sqrt(1-e*e)}const yl=["duration","bounce"],xl=["stiffness","damping","mass"];function ti(t,e){return e.some(n=>t[n]!==void 0)}function vl(t){let e={velocity:$.velocity,stiffness:$.stiffness,damping:$.damping,mass:$.mass,isResolvedFromDuration:!1,...t};if(!ti(t,xl)&&ti(t,yl))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*vt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:$.mass,stiffness:i,damping:r}}else{const n=ml(t);e={...e,...n,mass:$.mass},e.isResolvedFromDuration=!0}return e}function Ge(t=$.visualDuration,e=$.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:l,damping:u,mass:c,duration:d,velocity:f,isResolvedFromDuration:g}=vl({...n,velocity:-at(n.velocity||0)}),y=f||0,v=u/(2*Math.sqrt(l*c)),w=o-r,x=at(Math.sqrt(l/c)),T=Math.abs(w)<5;s||(s=T?$.restSpeed.granular:$.restSpeed.default),i||(i=T?$.restDelta.granular:$.restDelta.default);let b;if(v<1){const A=Vn(x,v);b=j=>{const k=Math.exp(-v*x*j);return o-k*((y+v*x*w)/A*Math.sin(A*j)+w*Math.cos(A*j))}}else if(v===1)b=A=>o-Math.exp(-x*A)*(w+(y+x*w)*A);else{const A=x*Math.sqrt(v*v-1);b=j=>{const k=Math.exp(-v*x*j),P=Math.min(A*j,300);return o-k*((y+v*x*w)*Math.sinh(P)+A*w*Math.cosh(P))/A}}const E={calculatedDuration:g&&d||null,next:A=>{const j=b(A);if(g)a.done=A>=d;else{let k=A===0?y:0;v<1&&(k=A===0?ht(y):Fo(b,A,j));const P=Math.abs(k)<=s,N=Math.abs(o-j)<=i;a.done=P&&N}return a.value=a.done?o:j,a},toString:()=>{const A=Math.min(hs(E),Ye),j=Oo(k=>E.next(A*k).value,A,30);return A+"ms "+j},toTransition:()=>{}};return E}Ge.applyToOptions=t=>{const e=hl(t,100,Ge);return t.ease=e.ease,t.duration=ht(e.duration),t.type="keyframes",t};function Dn({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:u=.5,restSpeed:c}){const d=t[0],f={done:!1,value:d},g=P=>a!==void 0&&P<a||l!==void 0&&P>l,y=P=>a===void 0?l:l===void 0||Math.abs(a-P)<Math.abs(l-P)?a:l;let v=n*e;const w=d+v,x=o===void 0?w:o(w);x!==w&&(v=x-d);const T=P=>-v*Math.exp(-P/s),b=P=>x+T(P),E=P=>{const N=T(P),W=b(P);f.done=Math.abs(N)<=u,f.value=f.done?x:W};let A,j;const k=P=>{g(f.value)&&(A=P,j=Ge({keyframes:[f.value,y(f.value)],velocity:Fo(b,P,f.value),damping:i,stiffness:r,restDelta:u,restSpeed:c}))};return k(0),{calculatedDuration:null,next:P=>{let N=!1;return!j&&A===void 0&&(N=!0,E(P),k(P)),A!==void 0&&P>=A?j.next(P-A):(!N&&E(P),f)}}}function bl(t,e,n){const s=[],i=n||wt.mix||Lo,r=t.length-1;for(let o=0;o<r;o++){let a=i(t[o],t[o+1]);if(e){const l=Array.isArray(e)?e[o]||lt:e;a=Ce(l,a)}s.push(a)}return s}function wl(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const r=t.length;if(bt(r===e.length,"Both input and output ranges must be the same length","range-length"),r===1)return()=>e[0];if(r===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[r-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=bl(e,s,i),l=a.length,u=c=>{if(o&&c<t[0])return e[0];let d=0;if(l>1)for(;d<t.length-2&&!(c<t[d+1]);d++);const f=xe(t[d],t[d+1],c);return a[d](f)};return n?c=>u(vt(t[0],t[r-1],c)):u}function Tl(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=xe(0,e,s);t.push(z(n,1,i))}}function Sl(t){const e=[0];return Tl(e,t.length-1),e}function Cl(t,e){return t.map(n=>n*e)}function Al(t,e){return t.map(()=>e||Po).splice(0,t.length-1)}function Zt({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=Oa(s)?s.map(Gs):Gs(s),r={done:!1,value:e[0]},o=Cl(n&&n.length===e.length?n:Sl(e),t),a=wl(o,e,{ease:Array.isArray(i)?i:Al(e,i)});return{calculatedDuration:t,next:l=>(r.value=a(l),r.done=l>=t,r)}}const Pl=t=>t!==null;function fs(t,{repeat:e,repeatType:n="loop"},s,i=1){const r=t.filter(Pl),a=i<0||e&&n!=="loop"&&e%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const Ml={decay:Dn,inertia:Dn,tween:Zt,keyframes:Zt,spring:Ge};function Bo(t){typeof t.type=="string"&&(t.type=Ml[t.type])}class ms{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,n){return this.finished.then(e,n)}}const jl=t=>t/100;class ps extends ms{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==nt.now()&&this.tick(nt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;Bo(e);const{type:n=Zt,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=e;let{keyframes:a}=e;const l=n||Zt;process.env.NODE_ENV!=="production"&&l!==Zt&&bt(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Zt&&typeof a[0]!="number"&&(this.mixKeyframes=Ce(jl,Lo(a[0],a[1])),a=[0,100]);const u=l({...e,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-o})),u.calculatedDuration===null&&(u.calculatedDuration=hs(u));const{calculatedDuration:c}=u;this.calculatedDuration=c,this.resolvedDuration=c+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:r,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:c,repeat:d,repeatType:f,repeatDelay:g,type:y,onUpdate:v,finalKeyframe:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const x=this.currentTime-u*(this.playbackSpeed>=0?1:-1),T=this.playbackSpeed>=0?x<0:x>i;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let b=this.currentTime,E=s;if(d){const P=Math.min(this.currentTime,i)/a;let N=Math.floor(P),W=P%1;!W&&P>=1&&(W=1),W===1&&N--,N=Math.min(N,d+1),!!(N%2)&&(f==="reverse"?(W=1-W,g&&(W-=g/a)):f==="mirror"&&(E=o)),b=vt(0,1,W)*a}const A=T?{done:!1,value:c[0]}:E.next(b);r&&(A.value=r(A.value));let{done:j}=A;!T&&l!==null&&(j=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const k=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&j);return k&&y!==Dn&&(A.value=fs(c,this.options,w,this.speed)),v&&v(A.value),k&&this.finish(),A}then(e,n){return this.finished.then(e,n)}get duration(){return at(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+at(e)}get time(){return at(this.currentTime)}set time(e){e=ht(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(nt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=at(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=dl,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(nt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function Vl(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const _t=t=>t*180/Math.PI,En=t=>{const e=_t(Math.atan2(t[1],t[0]));return kn(e)},Dl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:En,rotateZ:En,skewX:t=>_t(Math.atan(t[1])),skewY:t=>_t(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},kn=t=>(t=t%360,t<0&&(t+=360),t),ei=En,ni=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),si=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),El={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ni,scaleY:si,scale:t=>(ni(t)+si(t))/2,rotateX:t=>kn(_t(Math.atan2(t[6],t[5]))),rotateY:t=>kn(_t(Math.atan2(-t[2],t[0]))),rotateZ:ei,rotate:ei,skewX:t=>_t(Math.atan(t[4])),skewY:t=>_t(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Rn(t){return t.includes("scale")?1:0}function Nn(t,e){if(!t||t==="none")return Rn(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=El,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=Dl,i=a}if(!i)return Rn(e);const r=s[e],o=i[1].split(",").map(Rl);return typeof r=="function"?r(o):o[r]}const kl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return Nn(n,e)};function Rl(t){return parseFloat(t.trim())}const le=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ce=new Set(le),ii=t=>t===ae||t===M,Nl=new Set(["x","y","z"]),Il=le.filter(t=>!Nl.has(t));function Ll(t){const e=[];return Il.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const Kt={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>Nn(e,"x"),y:(t,{transform:e})=>Nn(e,"y")};Kt.translateX=Kt.x;Kt.translateY=Kt.y;const Ht=new Set;let In=!1,Ln=!1,On=!1;function $o(){if(Ln){const t=Array.from(Ht).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=Ll(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([r,o])=>{s.getValue(r)?.set(o)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}Ln=!1,In=!1,Ht.forEach(t=>t.complete(On)),Ht.clear()}function zo(){Ht.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Ln=!0)})}function Ol(){On=!0,zo(),$o(),On=!1}class gs{constructor(e,n,s,i,r,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=r,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Ht.add(this),In||(In=!0,F.read(zo),F.resolveKeyframes($o))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const r=i?.get(),o=e[e.length-1];if(r!==void 0)e[0]=r;else if(s&&n){const a=s.readValue(n,o);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=o),i&&r===void 0&&i.set(e[0])}Vl(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ht.delete(this)}cancel(){this.state==="scheduled"&&(Ht.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const Fl=t=>t.startsWith("--");function Bl(t,e,n){Fl(e)?t.style.setProperty(e,n):t.style[e]=n}const $l=ns(()=>window.ScrollTimeline!==void 0),zl={};function Ul(t,e){const n=ns(t);return()=>zl[e]??n()}const Uo=Ul(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),fe=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,oi={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:fe([0,.65,.55,1]),circOut:fe([.55,0,1,.45]),backIn:fe([.31,.01,.66,-.59]),backOut:fe([.33,1.53,.69,.99])};function Wo(t,e){if(t)return typeof t=="function"?Uo()?Oo(t,e):"ease-out":Mo(t)?fe(t):Array.isArray(t)?t.map(n=>Wo(n,e)||oi.easeOut):oi[t]}function Wl(t,e,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},u=void 0){const c={[e]:n};l&&(c.offset=l);const d=Wo(a,i);Array.isArray(d)&&(c.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(c,f)}function _o(t){return typeof t=="function"&&"applyToOptions"in t}function _l({type:t,...e}){return _o(t)&&Uo()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Kl extends ms{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:r,allowFlatten:o=!1,finalKeyframe:a,onComplete:l}=e;this.isPseudoElement=!!r,this.allowFlatten=o,this.options=e,bt(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=_l(e);this.animation=Wl(n,s,i,u,r),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const c=fs(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(c):Bl(n,s,c),this.animation.cancel()}l?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return at(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+at(e)}get time(){return at(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=ht(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&$l()?(this.animation.timeline=e,lt):n(this)}}const Ko={anticipate:So,backInOut:To,circInOut:Ao};function Hl(t){return t in Ko}function Xl(t){typeof t.ease=="string"&&Hl(t.ease)&&(t.ease=Ko[t.ease])}const ri=10;class Yl extends Kl{constructor(e){Xl(e),Bo(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:r,...o}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new ps({...o,autoplay:!1}),l=ht(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-ri).value,a.sample(l).value,ri),a.stop()}}const ai=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Vt.test(t)||t==="0")&&!t.startsWith("url("));function Gl(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function ql(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const r=t[t.length-1],o=ai(i,e),a=ai(r,e);return re(o===a,`You are trying to animate ${e} from "${i}" to "${r}". "${o?r:i}" is not an animatable value.`,"value-not-animatable"),!o||!a?!1:Gl(t)||(n==="spring"||_o(n))&&s}function Fn(t){t.duration=0,t.type="keyframes"}const Zl=new Set(["opacity","clipPath","filter","transform"]),Jl=ns(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function Ql(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:r,type:o}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=e.owner.getProps();return Jl()&&n&&Zl.has(n)&&(n!=="transform"||!u)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const tc=40;class ec extends ms{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:u,element:c,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=nt.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,name:l,motionValue:u,element:c,...d},g=c?.KeyframeResolver||gs;this.keyframeResolver=new g(a,(y,v,w)=>this.onKeyframesResolved(y,v,f,!w),l,u,c),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:u,onUpdate:c}=s;this.resolvedAt=nt.now(),ql(e,r,o,a)||((wt.instantAnimations||!l)&&c?.(fs(e,s,n)),e[0]=e[e.length-1],Fn(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>tc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&Ql(f)?new Yl({...f,element:f.motionValue.owner.current}):new ps(f);g.finished.then(()=>this.notifyFinished()).catch(lt),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Ol()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const nc=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function sc(t){const e=nc.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const ic=4;function Ho(t,e,n=1){bt(n<=ic,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=sc(t);if(!s)return;const r=window.getComputedStyle(e).getPropertyValue(s);if(r){const o=r.trim();return mo(o)?parseFloat(o):o}return ls(i)?Ho(i,e,n+1):i}function ys(t,e){return t?.[e]??t?.default??t}const Xo=new Set(["width","height","top","left","right","bottom",...le]),oc={test:t=>t==="auto",parse:t=>t},Yo=t=>e=>e.test(t),Go=[ae,M,yt,Mt,Ga,Ya,oc],li=t=>Go.find(Yo(t));function rc(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||go(t):!0}const ac=new Set(["brightness","contrast","saturate","opacity"]);function lc(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(cs)||[];if(!s)return t;const i=n.replace(s,"");let r=ac.has(e)?1:0;return s!==n&&(r*=100),e+"("+r+i+")"}const cc=/\b([a-z-]*)\(.*?\)/gu,Bn={...Vt,getAnimatableNone:t=>{const e=t.match(cc);return e?e.map(lc).join(" "):t}},ci={...ae,transform:Math.round},uc={rotate:Mt,rotateX:Mt,rotateY:Mt,rotateZ:Mt,scale:Le,scaleX:Le,scaleY:Le,scaleZ:Le,skew:Mt,skewX:Mt,skewY:Mt,distance:M,translateX:M,translateY:M,translateZ:M,x:M,y:M,z:M,perspective:M,transformPerspective:M,opacity:ve,originX:qs,originY:qs,originZ:M},xs={borderWidth:M,borderTopWidth:M,borderRightWidth:M,borderBottomWidth:M,borderLeftWidth:M,borderRadius:M,radius:M,borderTopLeftRadius:M,borderTopRightRadius:M,borderBottomRightRadius:M,borderBottomLeftRadius:M,width:M,maxWidth:M,height:M,maxHeight:M,top:M,right:M,bottom:M,left:M,padding:M,paddingTop:M,paddingRight:M,paddingBottom:M,paddingLeft:M,margin:M,marginTop:M,marginRight:M,marginBottom:M,marginLeft:M,backgroundPositionX:M,backgroundPositionY:M,...uc,zIndex:ci,fillOpacity:ve,strokeOpacity:ve,numOctaves:ci},dc={...xs,color:H,backgroundColor:H,outlineColor:H,fill:H,stroke:H,borderColor:H,borderTopColor:H,borderRightColor:H,borderBottomColor:H,borderLeftColor:H,filter:Bn,WebkitFilter:Bn},qo=t=>dc[t];function Zo(t,e){let n=qo(t);return n!==Bn&&(n=Vt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const hc=new Set(["auto","none","0"]);function fc(t,e,n){let s=0,i;for(;s<t.length&&!i;){const r=t[s];typeof r=="string"&&!hc.has(r)&&be(r).values.length&&(i=t[s]),s++}if(i&&n)for(const r of e)t[r]=Zo(n,i)}class mc extends gs{constructor(e,n,s,i,r){super(e,n,s,i,r,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<e.length;l++){let u=e[l];if(typeof u=="string"&&(u=u.trim(),ls(u))){const c=Ho(u,n.current);c!==void 0&&(e[l]=c),l===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!Xo.has(s)||e.length!==2)return;const[i,r]=e,o=li(i),a=li(r);if(o!==a)if(ii(o)&&ii(a))for(let l=0;l<e.length;l++){const u=e[l];typeof u=="string"&&(e[l]=parseFloat(u))}else Kt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||rc(e[i]))&&s.push(i);s.length&&fc(e,s,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Kt[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const r=s.length-1,o=s[r];s[r]=Kt[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{e.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function pc(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const Jo=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function Qo(t){return po(t)&&"offsetHeight"in t}const ui=30,gc=t=>!isNaN(parseFloat(t));class yc{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=nt.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const r of this.dependents)r.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=nt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=gc(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&is(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,n){this.events[e]||(this.events[e]=new ss);const s=this.events[e].add(n);return e==="change"?()=>{s(),F.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=nt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>ui)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,ui);return yo(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function ie(t,e){return new yc(t,e)}const{schedule:vs}=jo(queueMicrotask,!1),ut={x:!1,y:!1};function tr(){return ut.x||ut.y}function xc(t){return t==="x"||t==="y"?ut[t]?null:(ut[t]=!0,()=>{ut[t]=!1}):ut.x||ut.y?null:(ut.x=ut.y=!0,()=>{ut.x=ut.y=!1})}function er(t,e){const n=pc(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function di(t){return!(t.pointerType==="touch"||tr())}function vc(t,e,n={}){const[s,i,r]=er(t,n),o=a=>{if(!di(a))return;const{target:l}=a,u=e(l,a);if(typeof u!="function"||!l)return;const c=d=>{di(d)&&(u(d),l.removeEventListener("pointerleave",c))};l.addEventListener("pointerleave",c,i)};return s.forEach(a=>{a.addEventListener("pointerenter",o,i)}),r}const nr=(t,e)=>e?t===e?!0:nr(t,e.parentElement):!1,bs=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,bc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function wc(t){return bc.has(t.tagName)||t.tabIndex!==-1}const ze=new WeakSet;function hi(t){return e=>{e.key==="Enter"&&t(e)}}function gn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Tc=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=hi(()=>{if(ze.has(n))return;gn(n,"down");const i=hi(()=>{gn(n,"up")}),r=()=>gn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",r,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function fi(t){return bs(t)&&!tr()}function Sc(t,e,n={}){const[s,i,r]=er(t,n),o=a=>{const l=a.currentTarget;if(!fi(a))return;ze.add(l);const u=e(l,a),c=(g,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),ze.has(l)&&ze.delete(l),fi(g)&&typeof u=="function"&&u(g,{success:y})},d=g=>{c(g,l===window||l===document||n.useGlobalTarget||nr(l,g.target))},f=g=>{c(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),Qo(a)&&(a.addEventListener("focus",u=>Tc(u,i)),!wc(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function sr(t){return po(t)&&"ownerSVGElement"in t}function Cc(t){return sr(t)&&t.tagName==="svg"}const Q=t=>!!(t&&t.getVelocity),Ac=[...Go,H,Vt],Pc=t=>Ac.find(Yo(t)),ws=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function mi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Mc(...t){return e=>{let n=!1;const s=t.map(i=>{const r=mi(i,e);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<s.length;i++){const r=s[i];typeof r=="function"?r():mi(t[i],null)}}}}function jc(...t){return dt.useCallback(Mc(...t),t)}class Vc extends dt.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=Qo(s)&&s.offsetWidth||0,r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft,r.right=i-r.width-r.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Dc({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),r=m.useRef(null),o=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(ws),l=jc(r,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:c,top:d,left:f,right:g}=o.current;if(e||!r.current||!u||!c)return;const y=n==="left"?`left: ${f}`:`right: ${g}`;r.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const w=s??document.head;return w.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
1
|
+
"use strict";var xa=Object.create;var Hs=Object.defineProperty;var va=Object.getOwnPropertyDescriptor;var ba=Object.getOwnPropertyNames;var wa=Object.getPrototypeOf,Ta=Object.prototype.hasOwnProperty;var Sa=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ba(e))!Ta.call(t,i)&&i!==n&&Hs(t,i,{get:()=>e[i],enumerable:!(s=va(e,i))||s.enumerable});return t};var Ca=(t,e,n)=>(n=t!=null?xa(wa(t)):{},Sa(e||!t||!t.__esModule?Hs(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),m=require("react"),G=require("lucide-react"),uo=require("@ai-sdk/react"),Ye=require("ai"),ho=require("@radix-ui/react-slot"),fo=require("class-variance-authority"),Aa=require("clsx"),Pa=require("tailwind-merge"),Ma=require("@radix-ui/react-tooltip"),Xs=require("@radix-ui/react-use-controllable-state"),ja=require("@radix-ui/react-collapsible"),Va=require("./server.cjs");function qn(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 ht=qn(m),ne=qn(Ma),Zn=qn(ja);function J(...t){return Pa.twMerge(Aa.clsx(t))}const zt=fo.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),Ge=ht.forwardRef(({className:t,variant:e,size:n,asChild:s=!1,...i},r)=>{const o=s?ho.Slot:"button";return h.jsx(o,{ref:r,"data-slot":"button",className:J(zt({variant:e,size:n,className:t})),...i})});Ge.displayName="Button";const Da=fo.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 dn({className:t,variant:e,asChild:n=!1,...s}){const i=n?ho.Slot:"span";return h.jsx(i,{"data-slot":"badge",className:J(Da({variant:e}),t),...s})}const Ea=({textAreaRef:t,triggerAutoSize:e,maxHeight:n=Number.MAX_SAFE_INTEGER,minHeight:s=0})=>{const[i,r]=ht.useState(!0);ht.useEffect(()=>{const a=t.current;if(a){i&&(a.style.minHeight=`${s+6}px`,n>s&&(a.style.maxHeight=`${n}px`),r(!1)),a.style.height=`${s+6}px`;const l=a.scrollHeight;l>n?a.style.height=`${n}px`:a.style.height=`${l+6}px`}},[t.current,e])},mo=ht.forwardRef(({maxHeight:t=Number.MAX_SAFE_INTEGER,minHeight:e=52,className:n,onChange:s,value:i,...r},o)=>{const a=ht.useRef(null),[l,u]=ht.useState("");return Ea({textAreaRef:a,triggerAutoSize:l,maxHeight:t,minHeight:e}),m.useImperativeHandle(o,()=>({textArea:a.current,focus:()=>a?.current?.focus(),maxHeight:t,minHeight:e})),ht.useEffect(()=>{u(i)},[r?.defaultValue,i]),h.jsx("textarea",{...r,value:i,ref:a,className:J("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",n),onChange:c=>{u(c.target.value),s?.(c)}})});mo.displayName="AutosizeTextarea";function ka({delayDuration:t=0,...e}){return h.jsx(ne.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function Ot({...t}){return h.jsx(ka,{children:h.jsx(ne.Root,{"data-slot":"tooltip",...t})})}function Ft({...t}){return h.jsx(ne.Trigger,{"data-slot":"tooltip-trigger",...t})}function Bt({className:t,sideOffset:e=0,children:n,...s}){return h.jsx(ne.Portal,{children:h.jsxs(ne.Content,{"data-slot":"tooltip-content",sideOffset:e,className:J("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...s,children:[n,h.jsx(ne.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Ys({className:t,...e}){return h.jsx("kbd",{"data-slot":"kbd",className:J("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 Jn=m.createContext({});function Qn(t){const e=m.useRef(null);return e.current===null&&(e.current=t()),e.current}const ts=typeof window<"u",po=ts?m.useLayoutEffect:m.useEffect,en=m.createContext(null);function es(t,e){t.indexOf(e)===-1&&t.push(e)}function ns(t,e){const n=t.indexOf(e);n>-1&&t.splice(n,1)}const bt=(t,e,n)=>n>e?e:n<t?t:n;function Mn(t,e){return e?`${t}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${e}`:t}let re=()=>{},wt=()=>{};process.env.NODE_ENV!=="production"&&(re=(t,e,n)=>{!t&&typeof console<"u"&&console.warn(Mn(e,n))},wt=(t,e,n)=>{if(!t)throw new Error(Mn(e,n))});const Tt={},go=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function yo(t){return typeof t=="object"&&t!==null}const xo=t=>/^0[^.\s]+$/u.test(t);function ss(t){let e;return()=>(e===void 0&&(e=t()),e)}const ut=t=>t,Ra=(t,e)=>n=>e(t(n)),Ve=(...t)=>t.reduce(Ra),Se=(t,e,n)=>{const s=e-t;return s===0?1:(n-t)/s};class is{constructor(){this.subscriptions=[]}add(e){return es(this.subscriptions,e),()=>ns(this.subscriptions,e)}notify(e,n,s){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,n,s);else for(let r=0;r<i;r++){const o=this.subscriptions[r];o&&o(e,n,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const ft=t=>t*1e3,ct=t=>t/1e3;function vo(t,e){return e?t*(1e3/e):0}const Gs=new Set;function os(t,e,n){t||Gs.has(e)||(console.warn(Mn(e,n)),Gs.add(e))}const bo=(t,e,n)=>(((1-3*n+3*e)*t+(3*n-6*e))*t+3*e)*t,Na=1e-7,Ia=12;function La(t,e,n,s,i){let r,o,a=0;do o=e+(n-e)/2,r=bo(o,s,i)-t,r>0?n=o:e=o;while(Math.abs(r)>Na&&++a<Ia);return o}function De(t,e,n,s){if(t===e&&n===s)return ut;const i=r=>La(r,0,1,t,n);return r=>r===0||r===1?r:bo(i(r),e,s)}const wo=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,To=t=>e=>1-t(1-e),So=De(.33,1.53,.69,.99),rs=To(So),Co=wo(rs),Ao=t=>(t*=2)<1?.5*rs(t):.5*(2-Math.pow(2,-10*(t-1))),as=t=>1-Math.sin(Math.acos(t)),Po=To(as),Mo=wo(as),Oa=De(.42,0,1,1),Fa=De(0,0,.58,1),jo=De(.42,0,.58,1),Ba=t=>Array.isArray(t)&&typeof t[0]!="number",Vo=t=>Array.isArray(t)&&typeof t[0]=="number",qs={linear:ut,easeIn:Oa,easeInOut:jo,easeOut:Fa,circIn:as,circInOut:Mo,circOut:Po,backIn:rs,backInOut:Co,backOut:So,anticipate:Ao},$a=t=>typeof t=="string",Zs=t=>{if(Vo(t)){wt(t.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[e,n,s,i]=t;return De(e,n,s,i)}else if($a(t))return wt(qs[t]!==void 0,`Invalid easing type '${t}'`,"invalid-easing-type"),qs[t];return t},Fe=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function za(t,e){let n=new Set,s=new Set,i=!1,r=!1;const o=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(c){o.has(c)&&(u.schedule(c),t()),c(a)}const u={schedule:(c,d=!1,f=!1)=>{const y=f&&i?n:s;return d&&o.add(c),y.has(c)||y.add(c),c},cancel:c=>{s.delete(c),o.delete(c)},process:c=>{if(a=c,i){r=!0;return}i=!0,[n,s]=[s,n],n.forEach(l),n.clear(),i=!1,r&&(r=!1,u.process(c))}};return u}const Ua=40;function Do(t,e){let n=!1,s=!0;const i={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=Fe.reduce((b,k)=>(b[k]=za(r),b),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:c,update:d,preRender:f,render:g,postRender:y}=o,v=()=>{const b=Tt.useManualTiming?i.timestamp:performance.now();n=!1,Tt.useManualTiming||(i.delta=s?1e3/60:Math.max(Math.min(b-i.timestamp,Ua),1)),i.timestamp=b,i.isProcessing=!0,a.process(i),l.process(i),u.process(i),c.process(i),d.process(i),f.process(i),g.process(i),y.process(i),i.isProcessing=!1,n&&e&&(s=!1,t(v))},w=()=>{n=!0,s=!0,i.isProcessing||t(v)};return{schedule:Fe.reduce((b,k)=>{const A=o[k];return b[k]=(D,R=!1,P=!1)=>(n||w(),A.schedule(D,R,P)),b},{}),cancel:b=>{for(let k=0;k<Fe.length;k++)o[Fe[k]].cancel(b)},state:i,steps:o}}const{schedule:O,cancel:Vt,state:Z,steps:hn}=Do(typeof requestAnimationFrame<"u"?requestAnimationFrame:ut,!0);let _e;function _a(){_e=void 0}const nt={now:()=>(_e===void 0&&nt.set(Z.isProcessing||Tt.useManualTiming?Z.timestamp:performance.now()),_e),set:t=>{_e=t,queueMicrotask(_a)}},Eo=t=>e=>typeof e=="string"&&e.startsWith(t),ls=Eo("--"),Wa=Eo("var(--"),cs=t=>Wa(t)?Ka.test(t.split("/*")[0].trim()):!1,Ka=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,ae={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Ce={...ae,transform:t=>bt(0,1,t)},Be={...ae,default:1},ve=t=>Math.round(t*1e5)/1e5,us=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ha(t){return t==null}const Xa=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,ds=(t,e)=>n=>!!(typeof n=="string"&&Xa.test(n)&&n.startsWith(t)||e&&!Ha(n)&&Object.prototype.hasOwnProperty.call(n,e)),ko=(t,e,n)=>s=>{if(typeof s!="string")return s;const[i,r,o,a]=s.match(us);return{[t]:parseFloat(i),[e]:parseFloat(r),[n]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},Ya=t=>bt(0,255,t),fn={...ae,transform:t=>Math.round(Ya(t))},_t={test:ds("rgb","red"),parse:ko("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:s=1})=>"rgba("+fn.transform(t)+", "+fn.transform(e)+", "+fn.transform(n)+", "+ve(Ce.transform(s))+")"};function Ga(t){let e="",n="",s="",i="";return t.length>5?(e=t.substring(1,3),n=t.substring(3,5),s=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),n=t.substring(2,3),s=t.substring(3,4),i=t.substring(4,5),e+=e,n+=n,s+=s,i+=i),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(s,16),alpha:i?parseInt(i,16)/255:1}}const jn={test:ds("#"),parse:Ga,transform:_t.transform},Ee=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),jt=Ee("deg"),xt=Ee("%"),M=Ee("px"),qa=Ee("vh"),Za=Ee("vw"),Js={...xt,parse:t=>xt.parse(t)/100,transform:t=>xt.transform(t*100)},qt={test:ds("hsl","hue"),parse:ko("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:s=1})=>"hsla("+Math.round(t)+", "+xt.transform(ve(e))+", "+xt.transform(ve(n))+", "+ve(Ce.transform(s))+")"},X={test:t=>_t.test(t)||jn.test(t)||qt.test(t),parse:t=>_t.test(t)?_t.parse(t):qt.test(t)?qt.parse(t):jn.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?_t.transform(t):qt.transform(t),getAnimatableNone:t=>{const e=X.parse(t);return e.alpha=0,X.transform(e)}},Ja=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Qa(t){return isNaN(t)&&typeof t=="string"&&(t.match(us)?.length||0)+(t.match(Ja)?.length||0)>0}const Ro="number",No="color",tl="var",el="var(",Qs="${}",nl=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Ae(t){const e=t.toString(),n=[],s={color:[],number:[],var:[]},i=[];let r=0;const a=e.replace(nl,l=>(X.test(l)?(s.color.push(r),i.push(No),n.push(X.parse(l))):l.startsWith(el)?(s.var.push(r),i.push(tl),n.push(l)):(s.number.push(r),i.push(Ro),n.push(parseFloat(l))),++r,Qs)).split(Qs);return{values:n,split:a,indexes:s,types:i}}function Io(t){return Ae(t).values}function Lo(t){const{split:e,types:n}=Ae(t),s=e.length;return i=>{let r="";for(let o=0;o<s;o++)if(r+=e[o],i[o]!==void 0){const a=n[o];a===Ro?r+=ve(i[o]):a===No?r+=X.transform(i[o]):r+=i[o]}return r}}const sl=t=>typeof t=="number"?0:X.test(t)?X.getAnimatableNone(t):t;function il(t){const e=Io(t);return Lo(t)(e.map(sl))}const Dt={test:Qa,parse:Io,createTransformer:Lo,getAnimatableNone:il};function mn(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function ol({hue:t,saturation:e,lightness:n,alpha:s}){t/=360,e/=100,n/=100;let i=0,r=0,o=0;if(!e)i=r=o=n;else{const a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;i=mn(l,a,t+1/3),r=mn(l,a,t),o=mn(l,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:s}}function qe(t,e){return n=>n>0?e:t}const $=(t,e,n)=>t+(e-t)*n,pn=(t,e,n)=>{const s=t*t,i=n*(e*e-s)+s;return i<0?0:Math.sqrt(i)},rl=[jn,_t,qt],al=t=>rl.find(e=>e.test(t));function ti(t){const e=al(t);if(re(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!e)return!1;let n=e.parse(t);return e===qt&&(n=ol(n)),n}const ei=(t,e)=>{const n=ti(t),s=ti(e);if(!n||!s)return qe(t,e);const i={...n};return r=>(i.red=pn(n.red,s.red,r),i.green=pn(n.green,s.green,r),i.blue=pn(n.blue,s.blue,r),i.alpha=$(n.alpha,s.alpha,r),_t.transform(i))},Vn=new Set(["none","hidden"]);function ll(t,e){return Vn.has(t)?n=>n<=0?t:e:n=>n>=1?e:t}function cl(t,e){return n=>$(t,e,n)}function hs(t){return typeof t=="number"?cl:typeof t=="string"?cs(t)?qe:X.test(t)?ei:hl:Array.isArray(t)?Oo:typeof t=="object"?X.test(t)?ei:ul:qe}function Oo(t,e){const n=[...t],s=n.length,i=t.map((r,o)=>hs(r)(r,e[o]));return r=>{for(let o=0;o<s;o++)n[o]=i[o](r);return n}}function ul(t,e){const n={...t,...e},s={};for(const i in n)t[i]!==void 0&&e[i]!==void 0&&(s[i]=hs(t[i])(t[i],e[i]));return i=>{for(const r in s)n[r]=s[r](i);return n}}function dl(t,e){const n=[],s={color:0,var:0,number:0};for(let i=0;i<e.values.length;i++){const r=e.types[i],o=t.indexes[r][s[r]],a=t.values[o]??0;n[i]=a,s[r]++}return n}const hl=(t,e)=>{const n=Dt.createTransformer(e),s=Ae(t),i=Ae(e);return s.indexes.var.length===i.indexes.var.length&&s.indexes.color.length===i.indexes.color.length&&s.indexes.number.length>=i.indexes.number.length?Vn.has(t)&&!i.values.length||Vn.has(e)&&!s.values.length?ll(t,e):Ve(Oo(dl(s,i),i.values),n):(re(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),qe(t,e))};function Fo(t,e,n){return typeof t=="number"&&typeof e=="number"&&typeof n=="number"?$(t,e,n):hs(t)(t,e)}const fl=t=>{const e=({timestamp:n})=>t(n);return{start:(n=!0)=>O.update(e,n),stop:()=>Vt(e),now:()=>Z.isProcessing?Z.timestamp:nt.now()}},Bo=(t,e,n=10)=>{let s="";const i=Math.max(Math.round(e/n),2);for(let r=0;r<i;r++)s+=Math.round(t(r/(i-1))*1e4)/1e4+", ";return`linear(${s.substring(0,s.length-2)})`},Ze=2e4;function fs(t){let e=0;const n=50;let s=t.next(e);for(;!s.done&&e<Ze;)e+=n,s=t.next(e);return e>=Ze?1/0:e}function ml(t,e=100,n){const s=n({...t,keyframes:[0,e]}),i=Math.min(fs(s),Ze);return{type:"keyframes",ease:r=>s.next(i*r).value/e,duration:ct(i)}}const pl=5;function $o(t,e,n){const s=Math.max(e-pl,0);return vo(n-t(s),e-s)}const B={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},gn=.001;function gl({duration:t=B.duration,bounce:e=B.bounce,velocity:n=B.velocity,mass:s=B.mass}){let i,r;re(t<=ft(B.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let o=1-e;o=bt(B.minDamping,B.maxDamping,o),t=bt(B.minDuration,B.maxDuration,ct(t)),o<1?(i=u=>{const c=u*o,d=c*t,f=c-n,g=Dn(u,o),y=Math.exp(-d);return gn-f/g*y},r=u=>{const d=u*o*t,f=d*n+n,g=Math.pow(o,2)*Math.pow(u,2)*t,y=Math.exp(-d),v=Dn(Math.pow(u,2),o);return(-i(u)+gn>0?-1:1)*((f-g)*y)/v}):(i=u=>{const c=Math.exp(-u*t),d=(u-n)*t+1;return-gn+c*d},r=u=>{const c=Math.exp(-u*t),d=(n-u)*(t*t);return c*d});const a=5/t,l=xl(i,r,a);if(t=ft(t),isNaN(l))return{stiffness:B.stiffness,damping:B.damping,duration:t};{const u=Math.pow(l,2)*s;return{stiffness:u,damping:o*2*Math.sqrt(s*u),duration:t}}}const yl=12;function xl(t,e,n){let s=n;for(let i=1;i<yl;i++)s=s-t(s)/e(s);return s}function Dn(t,e){return t*Math.sqrt(1-e*e)}const vl=["duration","bounce"],bl=["stiffness","damping","mass"];function ni(t,e){return e.some(n=>t[n]!==void 0)}function wl(t){let e={velocity:B.velocity,stiffness:B.stiffness,damping:B.damping,mass:B.mass,isResolvedFromDuration:!1,...t};if(!ni(t,bl)&&ni(t,vl))if(t.visualDuration){const n=t.visualDuration,s=2*Math.PI/(n*1.2),i=s*s,r=2*bt(.05,1,1-(t.bounce||0))*Math.sqrt(i);e={...e,mass:B.mass,stiffness:i,damping:r}}else{const n=gl(t);e={...e,...n,mass:B.mass},e.isResolvedFromDuration=!0}return e}function Je(t=B.visualDuration,e=B.bounce){const n=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:s,restDelta:i}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],a={done:!1,value:r},{stiffness:l,damping:u,mass:c,duration:d,velocity:f,isResolvedFromDuration:g}=wl({...n,velocity:-ct(n.velocity||0)}),y=f||0,v=u/(2*Math.sqrt(l*c)),w=o-r,x=ct(Math.sqrt(l/c)),S=Math.abs(w)<5;s||(s=S?B.restSpeed.granular:B.restSpeed.default),i||(i=S?B.restDelta.granular:B.restDelta.default);let b;if(v<1){const A=Dn(x,v);b=D=>{const R=Math.exp(-v*x*D);return o-R*((y+v*x*w)/A*Math.sin(A*D)+w*Math.cos(A*D))}}else if(v===1)b=A=>o-Math.exp(-x*A)*(w+(y+x*w)*A);else{const A=x*Math.sqrt(v*v-1);b=D=>{const R=Math.exp(-v*x*D),P=Math.min(A*D,300);return o-R*((y+v*x*w)*Math.sinh(P)+A*w*Math.cosh(P))/A}}const k={calculatedDuration:g&&d||null,next:A=>{const D=b(A);if(g)a.done=A>=d;else{let R=A===0?y:0;v<1&&(R=A===0?ft(y):$o(b,A,D));const P=Math.abs(R)<=s,N=Math.abs(o-D)<=i;a.done=P&&N}return a.value=a.done?o:D,a},toString:()=>{const A=Math.min(fs(k),Ze),D=Bo(R=>k.next(A*R).value,A,30);return A+"ms "+D},toTransition:()=>{}};return k}Je.applyToOptions=t=>{const e=ml(t,100,Je);return t.ease=e.ease,t.duration=ft(e.duration),t.type="keyframes",t};function En({keyframes:t,velocity:e=0,power:n=.8,timeConstant:s=325,bounceDamping:i=10,bounceStiffness:r=500,modifyTarget:o,min:a,max:l,restDelta:u=.5,restSpeed:c}){const d=t[0],f={done:!1,value:d},g=P=>a!==void 0&&P<a||l!==void 0&&P>l,y=P=>a===void 0?l:l===void 0||Math.abs(a-P)<Math.abs(l-P)?a:l;let v=n*e;const w=d+v,x=o===void 0?w:o(w);x!==w&&(v=x-d);const S=P=>-v*Math.exp(-P/s),b=P=>x+S(P),k=P=>{const N=S(P),_=b(P);f.done=Math.abs(N)<=u,f.value=f.done?x:_};let A,D;const R=P=>{g(f.value)&&(A=P,D=Je({keyframes:[f.value,y(f.value)],velocity:$o(b,P,f.value),damping:i,stiffness:r,restDelta:u,restSpeed:c}))};return R(0),{calculatedDuration:null,next:P=>{let N=!1;return!D&&A===void 0&&(N=!0,k(P),R(P)),A!==void 0&&P>=A?D.next(P-A):(!N&&k(P),f)}}}function Tl(t,e,n){const s=[],i=n||Tt.mix||Fo,r=t.length-1;for(let o=0;o<r;o++){let a=i(t[o],t[o+1]);if(e){const l=Array.isArray(e)?e[o]||ut:e;a=Ve(l,a)}s.push(a)}return s}function Sl(t,e,{clamp:n=!0,ease:s,mixer:i}={}){const r=t.length;if(wt(r===e.length,"Both input and output ranges must be the same length","range-length"),r===1)return()=>e[0];if(r===2&&e[0]===e[1])return()=>e[1];const o=t[0]===t[1];t[0]>t[r-1]&&(t=[...t].reverse(),e=[...e].reverse());const a=Tl(e,s,i),l=a.length,u=c=>{if(o&&c<t[0])return e[0];let d=0;if(l>1)for(;d<t.length-2&&!(c<t[d+1]);d++);const f=Se(t[d],t[d+1],c);return a[d](f)};return n?c=>u(bt(t[0],t[r-1],c)):u}function Cl(t,e){const n=t[t.length-1];for(let s=1;s<=e;s++){const i=Se(0,e,s);t.push($(n,1,i))}}function Al(t){const e=[0];return Cl(e,t.length-1),e}function Pl(t,e){return t.map(n=>n*e)}function Ml(t,e){return t.map(()=>e||jo).splice(0,t.length-1)}function Zt({duration:t=300,keyframes:e,times:n,ease:s="easeInOut"}){const i=Ba(s)?s.map(Zs):Zs(s),r={done:!1,value:e[0]},o=Pl(n&&n.length===e.length?n:Al(e),t),a=Sl(o,e,{ease:Array.isArray(i)?i:Ml(e,i)});return{calculatedDuration:t,next:l=>(r.value=a(l),r.done=l>=t,r)}}const jl=t=>t!==null;function ms(t,{repeat:e,repeatType:n="loop"},s,i=1){const r=t.filter(jl),a=i<0||e&&n!=="loop"&&e%2===1?0:r.length-1;return!a||s===void 0?r[a]:s}const Vl={decay:En,inertia:En,tween:Zt,keyframes:Zt,spring:Je};function zo(t){typeof t.type=="string"&&(t.type=Vl[t.type])}class ps{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 Dl=t=>t/100;class gs extends ps{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:n}=this.options;n&&n.updatedAt!==nt.now()&&this.tick(nt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;zo(e);const{type:n=Zt,repeat:s=0,repeatDelay:i=0,repeatType:r,velocity:o=0}=e;let{keyframes:a}=e;const l=n||Zt;process.env.NODE_ENV!=="production"&&l!==Zt&&wt(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==Zt&&typeof a[0]!="number"&&(this.mixKeyframes=Ve(Dl,Fo(a[0],a[1])),a=[0,100]);const u=l({...e,keyframes:a});r==="mirror"&&(this.mirroredGenerator=l({...e,keyframes:[...a].reverse(),velocity:-o})),u.calculatedDuration===null&&(u.calculatedDuration=fs(u));const{calculatedDuration:c}=u;this.calculatedDuration=c,this.resolvedDuration=c+i,this.totalDuration=this.resolvedDuration*(s+1)-i,this.generator=u}updateTime(e){const n=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(e,n=!1){const{generator:s,totalDuration:i,mixKeyframes:r,mirroredGenerator:o,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return s.next(0);const{delay:u=0,keyframes:c,repeat:d,repeatType:f,repeatDelay:g,type:y,onUpdate:v,finalKeyframe:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-i/this.speed,this.startTime)),n?this.currentTime=e:this.updateTime(e);const x=this.currentTime-u*(this.playbackSpeed>=0?1:-1),S=this.playbackSpeed>=0?x<0:x>i;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let b=this.currentTime,k=s;if(d){const P=Math.min(this.currentTime,i)/a;let N=Math.floor(P),_=P%1;!_&&P>=1&&(_=1),_===1&&N--,N=Math.min(N,d+1),!!(N%2)&&(f==="reverse"?(_=1-_,g&&(_-=g/a)):f==="mirror"&&(k=o)),b=bt(0,1,_)*a}const A=S?{done:!1,value:c[0]}:k.next(b);r&&(A.value=r(A.value));let{done:D}=A;!S&&l!==null&&(D=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const R=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&D);return R&&y!==En&&(A.value=ms(c,this.options,w,this.speed)),v&&v(A.value),R&&this.finish(),A}then(e,n){return this.finished.then(e,n)}get duration(){return ct(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ct(e)}get time(){return ct(this.currentTime)}set time(e){e=ft(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(nt.now());const n=this.playbackSpeed!==e;this.playbackSpeed=e,n&&(this.time=ct(this.currentTime))}play(){if(this.isStopped)return;const{driver:e=fl,startTime:n}=this.options;this.driver||(this.driver=e(i=>this.tick(i))),this.options.onPlay?.();const s=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=s):this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime||(this.startTime=n??s),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(nt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}}function El(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const Wt=t=>t*180/Math.PI,kn=t=>{const e=Wt(Math.atan2(t[1],t[0]));return Rn(e)},kl={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:kn,rotateZ:kn,skewX:t=>Wt(Math.atan(t[1])),skewY:t=>Wt(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Rn=t=>(t=t%360,t<0&&(t+=360),t),si=kn,ii=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),oi=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),Rl={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ii,scaleY:oi,scale:t=>(ii(t)+oi(t))/2,rotateX:t=>Rn(Wt(Math.atan2(t[6],t[5]))),rotateY:t=>Rn(Wt(Math.atan2(-t[2],t[0]))),rotateZ:si,rotate:si,skewX:t=>Wt(Math.atan(t[4])),skewY:t=>Wt(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Nn(t){return t.includes("scale")?1:0}function In(t,e){if(!t||t==="none")return Nn(e);const n=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let s,i;if(n)s=Rl,i=n;else{const a=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);s=kl,i=a}if(!i)return Nn(e);const r=s[e],o=i[1].split(",").map(Il);return typeof r=="function"?r(o):o[r]}const Nl=(t,e)=>{const{transform:n="none"}=getComputedStyle(t);return In(n,e)};function Il(t){return parseFloat(t.trim())}const le=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ce=new Set(le),ri=t=>t===ae||t===M,Ll=new Set(["x","y","z"]),Ol=le.filter(t=>!Ll.has(t));function Fl(t){const e=[];return Ol.forEach(n=>{const s=t.getValue(n);s!==void 0&&(e.push([n,s.get()]),s.set(n.startsWith("scale")?1:0))}),e}const Kt={width:({x:t},{paddingLeft:e="0",paddingRight:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),height:({y:t},{paddingTop:e="0",paddingBottom:n="0"})=>t.max-t.min-parseFloat(e)-parseFloat(n),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>In(e,"x"),y:(t,{transform:e})=>In(e,"y")};Kt.translateX=Kt.x;Kt.translateY=Kt.y;const Ht=new Set;let Ln=!1,On=!1,Fn=!1;function Uo(){if(On){const t=Array.from(Ht).filter(s=>s.needsMeasurement),e=new Set(t.map(s=>s.element)),n=new Map;e.forEach(s=>{const i=Fl(s);i.length&&(n.set(s,i),s.render())}),t.forEach(s=>s.measureInitialState()),e.forEach(s=>{s.render();const i=n.get(s);i&&i.forEach(([r,o])=>{s.getValue(r)?.set(o)})}),t.forEach(s=>s.measureEndState()),t.forEach(s=>{s.suspendedScrollY!==void 0&&window.scrollTo(0,s.suspendedScrollY)})}On=!1,Ln=!1,Ht.forEach(t=>t.complete(Fn)),Ht.clear()}function _o(){Ht.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(On=!0)})}function Bl(){Fn=!0,_o(),Uo(),Fn=!1}class ys{constructor(e,n,s,i,r,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=n,this.name=s,this.motionValue=i,this.element=r,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Ht.add(this),Ln||(Ln=!0,O.read(_o),O.resolveKeyframes(Uo))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:n,element:s,motionValue:i}=this;if(e[0]===null){const r=i?.get(),o=e[e.length-1];if(r!==void 0)e[0]=r;else if(s&&n){const a=s.readValue(n,o);a!=null&&(e[0]=a)}e[0]===void 0&&(e[0]=o),i&&r===void 0&&i.set(e[0])}El(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ht.delete(this)}cancel(){this.state==="scheduled"&&(Ht.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const $l=t=>t.startsWith("--");function zl(t,e,n){$l(e)?t.style.setProperty(e,n):t.style[e]=n}const Ul=ss(()=>window.ScrollTimeline!==void 0),_l={};function Wl(t,e){const n=ss(t);return()=>_l[e]??n()}const Wo=Wl(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),xe=([t,e,n,s])=>`cubic-bezier(${t}, ${e}, ${n}, ${s})`,ai={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:xe([0,.65,.55,1]),circOut:xe([.55,0,1,.45]),backIn:xe([.31,.01,.66,-.59]),backOut:xe([.33,1.53,.69,.99])};function Ko(t,e){if(t)return typeof t=="function"?Wo()?Bo(t,e):"ease-out":Vo(t)?xe(t):Array.isArray(t)?t.map(n=>Ko(n,e)||ai.easeOut):ai[t]}function Kl(t,e,n,{delay:s=0,duration:i=300,repeat:r=0,repeatType:o="loop",ease:a="easeOut",times:l}={},u=void 0){const c={[e]:n};l&&(c.offset=l);const d=Ko(a,i);Array.isArray(d)&&(c.easing=d);const f={delay:s,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(c,f)}function Ho(t){return typeof t=="function"&&"applyToOptions"in t}function Hl({type:t,...e}){return Ho(t)&&Wo()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class Xl extends ps{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:n,name:s,keyframes:i,pseudoElement:r,allowFlatten:o=!1,finalKeyframe:a,onComplete:l}=e;this.isPseudoElement=!!r,this.allowFlatten=o,this.options=e,wt(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const u=Hl(e);this.animation=Kl(n,s,i,u,r),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const c=ms(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(c):zl(n,s,c),this.animation.cancel()}l?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const e=this.animation.effect?.getComputedTiming?.().duration||0;return ct(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+ct(e)}get time(){return ct(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=ft(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:n}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&Ul()?(this.animation.timeline=e,ut):n(this)}}const Xo={anticipate:Ao,backInOut:Co,circInOut:Mo};function Yl(t){return t in Xo}function Gl(t){typeof t.ease=="string"&&Yl(t.ease)&&(t.ease=Xo[t.ease])}const li=10;class ql extends Xl{constructor(e){Gl(e),zo(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:n,onUpdate:s,onComplete:i,element:r,...o}=this.options;if(!n)return;if(e!==void 0){n.set(e);return}const a=new gs({...o,autoplay:!1}),l=ft(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-li).value,a.sample(l).value,li),a.stop()}}const ci=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Dt.test(t)||t==="0")&&!t.startsWith("url("));function Zl(t){const e=t[0];if(t.length===1)return!0;for(let n=0;n<t.length;n++)if(t[n]!==e)return!0}function Jl(t,e,n,s){const i=t[0];if(i===null)return!1;if(e==="display"||e==="visibility")return!0;const r=t[t.length-1],o=ci(i,e),a=ci(r,e);return re(o===a,`You are trying to animate ${e} from "${i}" to "${r}". "${o?r:i}" is not an animatable value.`,"value-not-animatable"),!o||!a?!1:Zl(t)||(n==="spring"||Ho(n))&&s}function Bn(t){t.duration=0,t.type="keyframes"}const Ql=new Set(["opacity","clipPath","filter","transform"]),tc=ss(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function ec(t){const{motionValue:e,name:n,repeatDelay:s,repeatType:i,damping:r,type:o}=t;if(!(e?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:u}=e.owner.getProps();return tc()&&n&&Ql.has(n)&&(n!=="transform"||!u)&&!l&&!s&&i!=="mirror"&&r!==0&&o!=="inertia"}const nc=40;class sc extends ps{constructor({autoplay:e=!0,delay:n=0,type:s="keyframes",repeat:i=0,repeatDelay:r=0,repeatType:o="loop",keyframes:a,name:l,motionValue:u,element:c,...d}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=nt.now();const f={autoplay:e,delay:n,type:s,repeat:i,repeatDelay:r,repeatType:o,name:l,motionValue:u,element:c,...d},g=c?.KeyframeResolver||ys;this.keyframeResolver=new g(a,(y,v,w)=>this.onKeyframesResolved(y,v,f,!w),l,u,c),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,n,s,i){this.keyframeResolver=void 0;const{name:r,type:o,velocity:a,delay:l,isHandoff:u,onUpdate:c}=s;this.resolvedAt=nt.now(),Jl(e,r,o,a)||((Tt.instantAnimations||!l)&&c?.(ms(e,s,n)),e[0]=e[e.length-1],Bn(s),s.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>nc?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...s,keyframes:e},g=!u&&ec(f)?new ql({...f,element:f.motionValue.owner.current}):new gs(f);g.finished.then(()=>this.notifyFinished()).catch(ut),this.pendingTimeline&&(this.stopTimeline=g.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=g}get finished(){return this._animation?this.animation.finished:this._finished}then(e,n){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Bl()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const ic=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function oc(t){const e=ic.exec(t);if(!e)return[,];const[,n,s,i]=e;return[`--${n??s}`,i]}const rc=4;function Yo(t,e,n=1){wt(n<=rc,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[s,i]=oc(t);if(!s)return;const r=window.getComputedStyle(e).getPropertyValue(s);if(r){const o=r.trim();return go(o)?parseFloat(o):o}return cs(i)?Yo(i,e,n+1):i}function xs(t,e){return t?.[e]??t?.default??t}const Go=new Set(["width","height","top","left","right","bottom",...le]),ac={test:t=>t==="auto",parse:t=>t},qo=t=>e=>e.test(t),Zo=[ae,M,xt,jt,Za,qa,ac],ui=t=>Zo.find(qo(t));function lc(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||xo(t):!0}const cc=new Set(["brightness","contrast","saturate","opacity"]);function uc(t){const[e,n]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[s]=n.match(us)||[];if(!s)return t;const i=n.replace(s,"");let r=cc.has(e)?1:0;return s!==n&&(r*=100),e+"("+r+i+")"}const dc=/\b([a-z-]*)\(.*?\)/gu,$n={...Dt,getAnimatableNone:t=>{const e=t.match(dc);return e?e.map(uc).join(" "):t}},di={...ae,transform:Math.round},hc={rotate:jt,rotateX:jt,rotateY:jt,rotateZ:jt,scale:Be,scaleX:Be,scaleY:Be,scaleZ:Be,skew:jt,skewX:jt,skewY:jt,distance:M,translateX:M,translateY:M,translateZ:M,x:M,y:M,z:M,perspective:M,transformPerspective:M,opacity:Ce,originX:Js,originY:Js,originZ:M},vs={borderWidth:M,borderTopWidth:M,borderRightWidth:M,borderBottomWidth:M,borderLeftWidth:M,borderRadius:M,radius:M,borderTopLeftRadius:M,borderTopRightRadius:M,borderBottomRightRadius:M,borderBottomLeftRadius:M,width:M,maxWidth:M,height:M,maxHeight:M,top:M,right:M,bottom:M,left:M,padding:M,paddingTop:M,paddingRight:M,paddingBottom:M,paddingLeft:M,margin:M,marginTop:M,marginRight:M,marginBottom:M,marginLeft:M,backgroundPositionX:M,backgroundPositionY:M,...hc,zIndex:di,fillOpacity:Ce,strokeOpacity:Ce,numOctaves:di},fc={...vs,color:X,backgroundColor:X,outlineColor:X,fill:X,stroke:X,borderColor:X,borderTopColor:X,borderRightColor:X,borderBottomColor:X,borderLeftColor:X,filter:$n,WebkitFilter:$n},Jo=t=>fc[t];function Qo(t,e){let n=Jo(t);return n!==$n&&(n=Dt),n.getAnimatableNone?n.getAnimatableNone(e):void 0}const mc=new Set(["auto","none","0"]);function pc(t,e,n){let s=0,i;for(;s<t.length&&!i;){const r=t[s];typeof r=="string"&&!mc.has(r)&&Ae(r).values.length&&(i=t[s]),s++}if(i&&n)for(const r of e)t[r]=Qo(n,i)}class gc extends ys{constructor(e,n,s,i,r){super(e,n,s,i,r,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:n,name:s}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<e.length;l++){let u=e[l];if(typeof u=="string"&&(u=u.trim(),cs(u))){const c=Yo(u,n.current);c!==void 0&&(e[l]=c),l===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!Go.has(s)||e.length!==2)return;const[i,r]=e,o=ui(i),a=ui(r);if(o!==a)if(ri(o)&&ri(a))for(let l=0;l<e.length;l++){const u=e[l];typeof u=="string"&&(e[l]=parseFloat(u))}else Kt[s]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:n}=this,s=[];for(let i=0;i<e.length;i++)(e[i]===null||lc(e[i]))&&s.push(i);s.length&&pc(e,s,n)}measureInitialState(){const{element:e,unresolvedKeyframes:n,name:s}=this;if(!e||!e.current)return;s==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Kt[s](e.measureViewportBox(),window.getComputedStyle(e.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&e.getValue(s,i).jump(i,!1)}measureEndState(){const{element:e,name:n,unresolvedKeyframes:s}=this;if(!e||!e.current)return;const i=e.getValue(n);i&&i.jump(this.measuredOrigin,!1);const r=s.length-1,o=s[r];s[r]=Kt[n](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([a,l])=>{e.getValue(a).set(l)}),this.resolveNoneKeyframes()}}function yc(t,e,n){if(t instanceof EventTarget)return[t];if(typeof t=="string"){let s=document;const i=n?.[t]??s.querySelectorAll(t);return i?Array.from(i):[]}return Array.from(t)}const tr=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function er(t){return yo(t)&&"offsetHeight"in t}const hi=30,xc=t=>!isNaN(parseFloat(t));class vc{constructor(e,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=s=>{const i=nt.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(s),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const r of this.dependents)r.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){this.current=e,this.updatedAt=nt.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=xc(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&os(!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(),O.read(()=>{this.events.change.getSize()||this.stop()})}:s}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,n){this.passiveEffect=e,this.stopPassiveEffect=n}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,n,s){this.set(n),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,n=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=nt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>hi)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,hi);return vo(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(e){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=e(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function ie(t,e){return new vc(t,e)}const{schedule:bs}=Do(queueMicrotask,!1),dt={x:!1,y:!1};function nr(){return dt.x||dt.y}function bc(t){return t==="x"||t==="y"?dt[t]?null:(dt[t]=!0,()=>{dt[t]=!1}):dt.x||dt.y?null:(dt.x=dt.y=!0,()=>{dt.x=dt.y=!1})}function sr(t,e){const n=yc(t),s=new AbortController,i={passive:!0,...e,signal:s.signal};return[n,i,()=>s.abort()]}function fi(t){return!(t.pointerType==="touch"||nr())}function wc(t,e,n={}){const[s,i,r]=sr(t,n),o=a=>{if(!fi(a))return;const{target:l}=a,u=e(l,a);if(typeof u!="function"||!l)return;const c=d=>{fi(d)&&(u(d),l.removeEventListener("pointerleave",c))};l.addEventListener("pointerleave",c,i)};return s.forEach(a=>{a.addEventListener("pointerenter",o,i)}),r}const ir=(t,e)=>e?t===e?!0:ir(t,e.parentElement):!1,ws=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Tc=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Sc(t){return Tc.has(t.tagName)||t.tabIndex!==-1}const We=new WeakSet;function mi(t){return e=>{e.key==="Enter"&&t(e)}}function yn(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const Cc=(t,e)=>{const n=t.currentTarget;if(!n)return;const s=mi(()=>{if(We.has(n))return;yn(n,"down");const i=mi(()=>{yn(n,"up")}),r=()=>yn(n,"cancel");n.addEventListener("keyup",i,e),n.addEventListener("blur",r,e)});n.addEventListener("keydown",s,e),n.addEventListener("blur",()=>n.removeEventListener("keydown",s),e)};function pi(t){return ws(t)&&!nr()}function Ac(t,e,n={}){const[s,i,r]=sr(t,n),o=a=>{const l=a.currentTarget;if(!pi(a))return;We.add(l);const u=e(l,a),c=(g,y)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),We.has(l)&&We.delete(l),pi(g)&&typeof u=="function"&&u(g,{success:y})},d=g=>{c(g,l===window||l===document||n.useGlobalTarget||ir(l,g.target))},f=g=>{c(g,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return s.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",o,i),er(a)&&(a.addEventListener("focus",u=>Cc(u,i)),!Sc(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),r}function or(t){return yo(t)&&"ownerSVGElement"in t}function Pc(t){return or(t)&&t.tagName==="svg"}const tt=t=>!!(t&&t.getVelocity),Mc=[...Zo,X,Dt],jc=t=>Mc.find(qo(t)),Ts=m.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function gi(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Vc(...t){return e=>{let n=!1;const s=t.map(i=>{const r=gi(i,e);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let i=0;i<s.length;i++){const r=s[i];typeof r=="function"?r():gi(t[i],null)}}}}function Dc(...t){return ht.useCallback(Vc(...t),t)}class Ec extends ht.Component{getSnapshotBeforeUpdate(e){const n=this.props.childRef.current;if(n&&e.isPresent&&!this.props.isPresent){const s=n.offsetParent,i=er(s)&&s.offsetWidth||0,r=this.props.sizeRef.current;r.height=n.offsetHeight||0,r.width=n.offsetWidth||0,r.top=n.offsetTop,r.left=n.offsetLeft,r.right=i-r.width-r.left}return null}componentDidUpdate(){}render(){return this.props.children}}function kc({children:t,isPresent:e,anchorX:n,root:s}){const i=m.useId(),r=m.useRef(null),o=m.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=m.useContext(Ts),l=Dc(r,t?.ref);return m.useInsertionEffect(()=>{const{width:u,height:c,top:d,left:f,right:g}=o.current;if(e||!r.current||!u||!c)return;const y=n==="left"?`left: ${f}`:`right: ${g}`;r.current.dataset.motionPopId=i;const v=document.createElement("style");a&&(v.nonce=a);const w=s??document.head;return w.appendChild(v),v.sheet&&v.sheet.insertRule(`
|
|
2
2
|
[data-motion-pop-id="${i}"] {
|
|
3
3
|
position: absolute !important;
|
|
4
4
|
width: ${u}px !important;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
${y}px !important;
|
|
7
7
|
top: ${d}px !important;
|
|
8
8
|
}
|
|
9
|
-
`),()=>{w.contains(v)&&w.removeChild(v)}},[e]),h.jsx(Vc,{isPresent:e,childRef:r,sizeRef:o,children:dt.cloneElement(t,{ref:l})})}const Ec=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,root:l})=>{const u=Jn(kc),c=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:c,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const y of u.values())if(!y)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return r&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,y)=>u.set(y,!1))},[n]),dt.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),o==="popLayout"&&(t=h.jsx(Dc,{isPresent:n,anchorX:a,root:l,children:t})),h.jsx(Je.Provider,{value:f,children:t})};function kc(){return new Map}function ir(t=!0){const e=m.useContext(Je);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,r=m.useId();m.useEffect(()=>{if(t)return i(r)},[t]);const o=m.useCallback(()=>t&&s&&s(r),[r,s,t]);return!n&&s?[!1,o]:[!0]}const Oe=t=>t.key||"";function pi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Rc=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",root:l})=>{const[u,c]=ir(o),d=m.useMemo(()=>pi(t),[t]),f=o&&!u?[]:d.map(Oe),g=m.useRef(!0),y=m.useRef(d),v=Jn(()=>new Map),[w,x]=m.useState(d),[T,b]=m.useState(d);fo(()=>{g.current=!1,y.current=d;for(let j=0;j<T.length;j++){const k=Oe(T[j]);f.includes(k)?v.delete(k):v.get(k)!==!0&&v.set(k,!1)}},[T,f.length,f.join("-")]);const E=[];if(d!==w){let j=[...d];for(let k=0;k<T.length;k++){const P=T[k],N=Oe(P);f.includes(N)||(j.splice(k,0,P),E.push(P))}return r==="wait"&&E.length&&(j=E),b(pi(j)),x(d),null}process.env.NODE_ENV!=="production"&&r==="wait"&&T.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:A}=m.useContext(Zn);return h.jsx(h.Fragment,{children:T.map(j=>{const k=Oe(j),P=o&&!u?!1:d===T||f.includes(k),N=()=>{if(v.has(k))v.set(k,!0);else return;let W=!0;v.forEach(U=>{U||(W=!1)}),W&&(A?.(),b(y.current),o&&c?.(),s&&s())};return h.jsx(Ec,{isPresent:P,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:r,root:l,onExitComplete:P?void 0:N,anchorX:a,children:j},k)})})},Ts=m.createContext({strict:!1}),gi={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},oe={};for(const t in gi)oe[t]={isEnabled:e=>gi[t].some(n=>!!e[n])};function $n(t){for(const e in t)oe[e]={...oe[e],...t[e]}}function Nc({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!yn(e)),i=m.useRef(void 0);if(!yn(e)){const{renderer:r,...o}=e;i.current=r,$n(o)}return m.useEffect(()=>{yn(e)&&e().then(({renderer:r,...o})=>{$n(o),i.current=r,s(!0)})},[]),h.jsx(Ts.Provider,{value:{renderer:i.current,strict:n},children:t})}function yn(t){return typeof t=="function"}const Ic=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function qe(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Ic.has(t)}let or=t=>!qe(t);function Lc(t){typeof t=="function"&&(or=e=>e.startsWith("on")?!qe(e):t(e))}try{Lc(require("@emotion/is-prop-valid").default)}catch{}function Oc(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(or(i)||n===!0&&qe(i)||!e&&!qe(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const Qe=m.createContext({});function tn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function we(t){return typeof t=="string"||Array.isArray(t)}const Ss=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Cs=["initial",...Ss];function en(t){return tn(t.animate)||Cs.some(e=>we(t[e]))}function rr(t){return!!(en(t)||t.variants)}function Fc(t,e){if(en(t)){const{initial:n,animate:s}=t;return{initial:n===!1||we(n)?n:void 0,animate:we(s)?s:void 0}}return t.inherit!==!1?e:{}}function Bc(t){const{initial:e,animate:n}=Fc(t,m.useContext(Qe));return m.useMemo(()=>({initial:e,animate:n}),[yi(e),yi(n)])}function yi(t){return Array.isArray(t)?t.join(" "):t}const Te={};function $c(t){for(const e in t)Te[e]=t[e],as(e)&&(Te[e].isCSSVariable=!0)}function ar(t,{layout:e,layoutId:n}){return ce.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Te[t]||t==="opacity")}const zc={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Uc=le.length;function Wc(t,e,n){let s="",i=!0;for(let r=0;r<Uc;r++){const o=le[r],a=t[o];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(o.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=Jo(a,xs[o]);if(!l){i=!1;const c=zc[o]||o;s+=`${c}(${u}) `}n&&(e[o]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function As(t,e,n){const{style:s,vars:i,transformOrigin:r}=t;let o=!1,a=!1;for(const l in e){const u=e[l];if(ce.has(l)){o=!0;continue}else if(as(l)){i[l]=u;continue}else{const c=Jo(u,xs[l]);l.startsWith("origin")?(a=!0,r[l]=c):s[l]=c}}if(e.transform||(o||n?s.transform=Wc(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:c=0}=r;s.transformOrigin=`${l} ${u} ${c}`}}const Ps=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function lr(t,e,n){for(const s in e)!Q(e[s])&&!ar(s,n)&&(t[s]=e[s])}function _c({transformTemplate:t},e){return m.useMemo(()=>{const n=Ps();return As(n,e,t),Object.assign({},n.vars,n.style)},[e])}function Kc(t,e){const n=t.style||{},s={};return lr(s,n,t),Object.assign(s,_c(t,e)),s}function Hc(t,e){const n={},s=Kc(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const Xc={offset:"stroke-dashoffset",array:"stroke-dasharray"},Yc={offset:"strokeDashoffset",array:"strokeDasharray"};function Gc(t,e,n=1,s=0,i=!0){t.pathLength=1;const r=i?Xc:Yc;t[r.offset]=M.transform(-s);const o=M.transform(e),a=M.transform(n);t[r.array]=`${o} ${a}`}function cr(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,u,c){if(As(t,a,u),l){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=c?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&Gc(d,i,r,o,!1)}const ur=()=>({...Ps(),attrs:{}}),dr=t=>typeof t=="string"&&t.toLowerCase()==="svg";function qc(t,e,n,s){const i=m.useMemo(()=>{const r=ur();return cr(r,e,dr(s),t.transformTemplate,t.style),{...r.attrs,style:{...r.style}}},[e]);if(t.style){const r={};lr(r,t.style,t),i.style={...r,...i.style}}return i}const Zc=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Ms(t){return typeof t!="string"||t.includes("-")?!1:!!(Zc.indexOf(t)>-1||/[A-Z]/u.test(t))}function Jc(t,e,n,{latestValues:s},i,r=!1){const a=(Ms(t)?qc:Hc)(e,s,i,t),l=Oc(e,typeof t=="string",r),u=t!==m.Fragment?{...l,...a,ref:n}:{},{children:c}=e,d=m.useMemo(()=>Q(c)?c.get():c,[c]);return m.createElement(t,{...u,children:d})}function xi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function js(t,e,n,s){if(typeof e=="function"){const[i,r]=xi(s);e=e(n!==void 0?n:t.custom,i,r)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,r]=xi(s);e=e(n!==void 0?n:t.custom,i,r)}return e}function Ue(t){return Q(t)?t.get():t}function Qc({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:tu(n,s,i,t),renderState:e()}}function tu(t,e,n,s){const i={},r=s(t,{});for(const f in r)i[f]=Ue(r[f]);let{initial:o,animate:a}=t;const l=en(t),u=rr(t);e&&u&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let c=n?n.initial===!1:!1;c=c||o===!1;const d=c?a:o;if(d&&typeof d!="boolean"&&!tn(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const y=js(t,f[g]);if(y){const{transitionEnd:v,transition:w,...x}=y;for(const T in x){let b=x[T];if(Array.isArray(b)){const E=c?b.length-1:0;b=b[E]}b!==null&&(i[T]=b)}for(const T in v)i[T]=v[T]}}}return i}const hr=t=>(e,n)=>{const s=m.useContext(Qe),i=m.useContext(Je),r=()=>Qc(t,e,s,i);return n?r():Jn(r)};function Vs(t,e,n){const{style:s}=t,i={};for(const r in s)(Q(s[r])||e.style&&Q(e.style[r])||ar(r,t)||n?.getValue(r)?.liveStyle!==void 0)&&(i[r]=s[r]);return i}const eu=hr({scrapeMotionValuesFromProps:Vs,createRenderState:Ps});function fr(t,e,n){const s=Vs(t,e,n);for(const i in t)if(Q(t[i])||Q(e[i])){const r=le.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=t[i]}return s}const nu=hr({scrapeMotionValuesFromProps:fr,createRenderState:ur}),su=Symbol.for("motionComponentSymbol");function Jt(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function iu(t,e,n){return m.useCallback(s=>{s&&t.onMount&&t.onMount(s),e&&(s?e.mount(s):e.unmount()),n&&(typeof n=="function"?n(s):Jt(n)&&(n.current=s))},[e])}const Ds=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),ou="framerAppearId",mr="data-"+Ds(ou),pr=m.createContext({});function ru(t,e,n,s,i){const{visualElement:r}=m.useContext(Qe),o=m.useContext(Ts),a=m.useContext(Je),l=m.useContext(ws).reducedMotion,u=m.useRef(null);s=s||o.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:r,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const c=u.current,d=m.useContext(pr);c&&!c.projection&&i&&(c.type==="html"||c.type==="svg")&&au(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{c&&f.current&&c.update(n,a)});const g=n[mr],y=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return fo(()=>{c&&(f.current=!0,window.MotionIsMounted=!0,c.updateFeatures(),c.scheduleRenderMicrotask(),y.current&&c.animationState&&c.animationState.animateChanges())}),m.useEffect(()=>{c&&(!y.current&&c.animationState&&c.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),y.current=!1),c.enteringChildren=void 0)}),c}function au(t,e,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:gr(t.parent)),t.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&Jt(a),visualElement:t,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u})}function gr(t){if(t)return t.options.allowProjection!==!1?t.projection:gr(t.parent)}function We(t,{forwardMotionProps:e=!1}={},n,s){n&&$n(n);const i=Ms(t)?nu:eu;function r(a,l){let u;const c={...m.useContext(ws),...a,layoutId:lu(a)},{isStatic:d}=c,f=Bc(a),g=i(a,d);if(!d&&Qn){cu(c,n);const y=uu(c);u=y.MeasureLayout,f.visualElement=ru(t,g,c,s,y.ProjectionNode)}return h.jsxs(Qe.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...c}):null,Jc(t,a,iu(g,f.visualElement,l),g,d,e)]})}r.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const o=m.forwardRef(r);return o[su]=t,o}function lu({layoutId:t}){const e=m.useContext(Zn).id;return e&&t!==void 0?e+"-"+t:t}function cu(t,e){const n=m.useContext(Ts).strict;if(process.env.NODE_ENV!=="production"&&e&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?re(!1,s,"lazy-strict-mode"):bt(!1,s,"lazy-strict-mode")}}function uu(t){const{drag:e,layout:n}=oe;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function du(t,e){if(typeof Proxy>"u")return We;const n=new Map,s=(r,o)=>We(r,o,t,e),i=(r,o)=>(process.env.NODE_ENV!=="production"&&is(!1,"motion() is deprecated. Use motion.create() instead."),s(r,o));return new Proxy(i,{get:(r,o)=>o==="create"?s:(n.has(o)||n.set(o,We(o,void 0,t,e)),n.get(o))})}function yr({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function hu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function fu(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function xn(t){return t===void 0||t===1}function zn({scale:t,scaleX:e,scaleY:n}){return!xn(t)||!xn(e)||!xn(n)}function Ut(t){return zn(t)||xr(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function xr(t){return vi(t.x)||vi(t.y)}function vi(t){return t&&t!=="0%"}function Ze(t,e,n){const s=t-n,i=e*s;return n+i}function bi(t,e,n,s,i){return i!==void 0&&(t=Ze(t,i,s)),Ze(t,n,s)+e}function Un(t,e=0,n=1,s,i){t.min=bi(t.min,e,n,s,i),t.max=bi(t.max,e,n,s,i)}function vr(t,{x:e,y:n}){Un(t.x,e.translate,e.scale,e.originPoint),Un(t.y,n.translate,n.scale,n.originPoint)}const wi=.999999999999,Ti=1.0000000000001;function mu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let r,o;for(let a=0;a<i;a++){r=n[a],o=r.projectionDelta;const{visualElement:l}=r.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&te(t,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,vr(t,o)),s&&Ut(r.latestValues)&&te(t,r.latestValues))}e.x<Ti&&e.x>wi&&(e.x=1),e.y<Ti&&e.y>wi&&(e.y=1)}function Qt(t,e){t.min=t.min+e,t.max=t.max+e}function Si(t,e,n,s,i=.5){const r=z(t.min,t.max,i);Un(t,e,n,r,s)}function te(t,e){Si(t.x,e.x,e.scaleX,e.scale,e.originX),Si(t.y,e.y,e.scaleY,e.scale,e.originY)}function br(t,e){return yr(fu(t.getBoundingClientRect(),e))}function pu(t,e,n){const s=br(t,n),{scroll:i}=e;return i&&(Qt(s.x,i.offset.x),Qt(s.y,i.offset.y)),s}const Ci=()=>({translate:0,scale:1,origin:0,originPoint:0}),ee=()=>({x:Ci(),y:Ci()}),Ai=()=>({min:0,max:0}),K=()=>({x:Ai(),y:Ai()}),Wn={current:null},wr={current:!1};function gu(){if(wr.current=!0,!!Qn)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Wn.current=t.matches;t.addEventListener("change",e),e()}else Wn.current=!1}const yu=new WeakMap;function xu(t,e,n){for(const s in e){const i=e[s],r=n[s];if(Q(i))t.addValue(s,i);else if(Q(r))t.addValue(s,ie(i,{owner:t}));else if(r!==i)if(t.hasValue(s)){const o=t.getValue(s);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=t.getStaticValue(s);t.addValue(s,ie(o!==void 0?o:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const Pi=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class vu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:r,visualState:o},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=gs,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=nt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,F.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!r,this.isControllingVariants=en(n),this.isVariantNode=rr(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];l[f]!==void 0&&Q(g)&&g.set(l[f])}}mount(e){this.current=e,yu.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),wr.current||gu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Wn.current,process.env.NODE_ENV!=="production"&&is(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),jt(this.notifyUpdate),jt(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=ce.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&F.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),r&&r(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in oe){const n=oe[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const r=this.features[e];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):K()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,n){this.latestValues[e]=n}update(e,n){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let s=0;s<Pi.length;s++){const i=Pi[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const r="on"+i,o=e[r];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=xu(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=ie(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(mo(s)||go(s))?s=parseFloat(s):!Pc(s)&&Vt.test(n)&&(s=Zo(e,n)),this.setBaseTarget(e,Q(s)?s.get():s)),Q(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const r=js(this.props,n,this.presenceContext?.custom);r&&(s=r[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!Q(i)?i:this.initialValues[e]!==void 0&&s===void 0?void 0:this.baseTarget[e]}on(e,n){return this.events[e]||(this.events[e]=new ss),this.events[e].add(n)}notify(e,...n){this.events[e]&&this.events[e].notify(...n)}scheduleRenderMicrotask(){vs.render(this.render)}}class Tr extends vu{constructor(){super(...arguments),this.KeyframeResolver=mc}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Q(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Sr(t,{style:e,vars:n},s,i){const r=t.style;let o;for(o in e)r[o]=e[o];i?.applyProjectionStyles(r,s);for(o in n)r.setProperty(o,n[o])}function bu(t){return window.getComputedStyle(t)}class wu extends Tr{constructor(){super(...arguments),this.type="html",this.renderInstance=Sr}readValueFromInstance(e,n){if(ce.has(n))return this.projection?.isProjecting?Rn(n):kl(e,n);{const s=bu(e),i=(as(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return br(e,n)}build(e,n,s){As(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return Vs(e,n,s)}}const Cr=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function Tu(t,e,n,s){Sr(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Cr.has(i)?i:Ds(i),e.attrs[i])}class Su extends Tr{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=K}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(ce.has(n)){const s=qo(n);return s&&s.default||0}return n=Cr.has(n)?n:Ds(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return fr(e,n,s)}build(e,n,s){cr(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Tu(e,n,s,i)}mount(e){this.isSVGTag=dr(e.tagName),super.mount(e)}}const Ar=(t,e)=>Ms(t)?new Su(e):new wu(e,{allowProjection:t!==m.Fragment});function se(t,e,n){const s=t.getProps();return js(s,e,n!==void 0?n:s.custom,t)}const _n=t=>Array.isArray(t);function Cu(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,ie(n))}function Au(t){return _n(t)?t[t.length-1]||0:t}function Pu(t,e){const n=se(t,e);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=Au(r[o]);Cu(t,o,a)}}function Mu(t){return!!(Q(t)&&t.add)}function Kn(t,e){const n=t.getValue("willChange");if(Mu(n))return n.add(e);if(!n&&wt.WillChange){const s=new wt.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function Pr(t){return t.props[mr]}const ju=t=>t!==null;function Vu(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(ju),r=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[r]}const Du={type:"spring",stiffness:500,damping:25,restSpeed:10},Eu=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),ku={type:"keyframes",duration:.8},Ru={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Nu=(t,{keyframes:e})=>e.length>2?ku:ce.has(t)?t.startsWith("scale")?Eu(e[1]):Du:Ru;function Iu({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:u,...c}){return!!Object.keys(c).length}const Es=(t,e,n,s={},i,r)=>o=>{const a=ys(s,t)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-ht(l);const c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:r?void 0:i};Iu(a)||Object.assign(c,Nu(t,c)),c.duration&&(c.duration=ht(c.duration)),c.repeatDelay&&(c.repeatDelay=ht(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let d=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(Fn(c),c.delay===0&&(d=!0)),(wt.instantAnimations||wt.skipAnimations)&&(d=!0,Fn(c),c.delay=0),c.allowFlatten=!a.type&&!a.ease,d&&!r&&e.get()!==void 0){const f=Vu(c.keyframes,a);if(f!==void 0){F.update(()=>{c.onUpdate(f),c.onComplete()});return}}return a.isSync?new ps(c):new ec(c)};function Lu({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Mr(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r=t.getDefaultTransition(),transitionEnd:o,...a}=e;s&&(r=s);const l=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const c in a){const d=t.getValue(c,t.latestValues[c]??null),f=a[c];if(f===void 0||u&&Lu(u,c))continue;const g={delay:n,...ys(r||{},c)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const x=Pr(t);if(x){const T=window.MotionHandoffAnimation(x,c,F);T!==null&&(g.startTime=T,v=!0)}}Kn(t,c),d.start(Es(c,d,f,t.shouldReduceMotion&&Xo.has(c)?{type:!1}:g,t,v));const w=d.animation;w&&l.push(w)}return o&&Promise.all(l).then(()=>{F.update(()=>{o&&Pu(t,o)})}),l}function jr(t,e,n,s=0,i=1){const r=Array.from(t).sort((u,c)=>u.sortNodePosition(c)).indexOf(e),o=t.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}function Hn(t,e,n={}){const s=se(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const r=s?()=>Promise.all(Mr(t,s,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:c,staggerDirection:d}=i;return Ou(t,e,l,u,c,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,u]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>u())}else return Promise.all([r(),o(n.delay)])}function Ou(t,e,n=0,s=0,i=0,r=1,o){const a=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),a.push(Hn(l,e,{...o,delay:n+(typeof s=="function"?0:s)+jr(t.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function Fu(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(r=>Hn(t,r,n));s=Promise.all(i)}else if(typeof e=="string")s=Hn(t,e,n);else{const i=typeof e=="function"?se(t,e,n.custom):e;s=Promise.all(Mr(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function Vr(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}const Bu=Cs.length;function Dr(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?Dr(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<Bu;n++){const s=Cs[n],i=t.props[s];(we(i)||i===!1)&&(e[s]=i)}return e}const $u=[...Ss].reverse(),zu=Ss.length;function Uu(t){return e=>Promise.all(e.map(({animation:n,options:s})=>Fu(t,n,s)))}function Wu(t){let e=Uu(t),n=Mi(),s=!0;const i=l=>(u,c)=>{const d=se(t,c,l==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...y}=d;u={...u,...y,...g}}return u};function r(l){e=l(t)}function o(l){const{props:u}=t,c=Dr(t.parent)||{},d=[],f=new Set;let g={},y=1/0;for(let w=0;w<zu;w++){const x=$u[w],T=n[x],b=u[x]!==void 0?u[x]:c[x],E=we(b),A=x===l?T.isActive:null;A===!1&&(y=w);let j=b===c[x]&&b!==u[x]&&E;if(j&&s&&t.manuallyAnimateOnMount&&(j=!1),T.protectedKeys={...g},!T.isActive&&A===null||!b&&!T.prevProp||tn(b)||typeof b=="boolean")continue;const k=_u(T.prevProp,b);let P=k||x===l&&T.isActive&&!j&&E||w>y&&E,N=!1;const W=Array.isArray(b)?b:[b];let U=W.reduce(i(x),{});A===!1&&(U={});const{prevResolvedValues:xt={}}=T,Tt={...xt,...U},ft=V=>{P=!0,f.has(V)&&(N=!0,f.delete(V)),T.needsAnimating[V]=!0;const Y=t.getValue(V);Y&&(Y.liveStyle=!1)};for(const V in Tt){const Y=U[V],L=xt[V];if(g.hasOwnProperty(V))continue;let st=!1;_n(Y)&&_n(L)?st=!Vr(Y,L):st=Y!==L,st?Y!=null?ft(V):f.add(V):Y!==void 0&&f.has(V)?ft(V):T.protectedKeys[V]=!0}T.prevProp=b,T.prevResolvedValues=U,T.isActive&&(g={...g,...U}),s&&t.blockInitialAnimation&&(P=!1);const Et=j&&k;P&&(!Et||N)&&d.push(...W.map(V=>{const Y={type:x};if(typeof V=="string"&&s&&!Et&&t.manuallyAnimateOnMount&&t.parent){const{parent:L}=t,st=se(L,V);if(L.enteringChildren&&st){const{delayChildren:G}=st.transition||{};Y.delay=jr(L.enteringChildren,t,G)}}return{animation:V,options:Y}}))}if(f.size){const w={};if(typeof u.initial!="boolean"){const x=se(t,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(w.transition=x.transition)}f.forEach(x=>{const T=t.getBaseTarget(x),b=t.getValue(x);b&&(b.liveStyle=!0),w[x]=T??null}),d.push({animation:w})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(l,u)),n[l].isActive=u;const c=o(l);for(const d in n)n[d].protectedKeys={};return c}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Mi()}}}function _u(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Vr(e,t):!1}function $t(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Mi(){return{animate:$t(!0),whileInView:$t(),whileHover:$t(),whileTap:$t(),whileDrag:$t(),whileFocus:$t(),exit:$t()}}class Dt{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Ku extends Dt{constructor(e){super(e),e.animationState||(e.animationState=Wu(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();tn(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Hu=0;class Xu extends Dt{constructor(){super(...arguments),this.id=Hu++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const Er={animation:{Feature:Ku},exit:{Feature:Xu}};function Se(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function Me(t){return{point:{x:t.pageX,y:t.pageY}}}const Yu=t=>e=>bs(e)&&t(e,Me(e));function pe(t,e,n,s){return Se(t,e,Yu(n),s)}const kr=1e-4,Gu=1-kr,qu=1+kr,Rr=.01,Zu=0-Rr,Ju=0+Rr;function et(t){return t.max-t.min}function Qu(t,e,n){return Math.abs(t-e)<=n}function ji(t,e,n,s=.5){t.origin=s,t.originPoint=z(e.min,e.max,t.origin),t.scale=et(n)/et(e),t.translate=z(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Gu&&t.scale<=qu||isNaN(t.scale))&&(t.scale=1),(t.translate>=Zu&&t.translate<=Ju||isNaN(t.translate))&&(t.translate=0)}function ge(t,e,n,s){ji(t.x,e.x,n.x,s?s.originX:void 0),ji(t.y,e.y,n.y,s?s.originY:void 0)}function Vi(t,e,n){t.min=n.min+e.min,t.max=t.min+et(e)}function td(t,e,n){Vi(t.x,e.x,n.x),Vi(t.y,e.y,n.y)}function Di(t,e,n){t.min=e.min-n.min,t.max=t.min+et(e)}function ye(t,e,n){Di(t.x,e.x,n.x),Di(t.y,e.y,n.y)}function rt(t){return[t("x"),t("y")]}const Nr=({current:t})=>t?t.ownerDocument.defaultView:null,Ei=(t,e)=>Math.abs(t-e);function ed(t,e){const n=Ei(t.x,e.x),s=Ei(t.y,e.y);return Math.sqrt(n**2+s**2)}class Ir{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:r=!1,distanceThreshold:o=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=bn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=ed(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:v}=f,{timestamp:w}=q;this.history.push({...v,timestamp:w});const{onStart:x,onMove:T}=this.handlers;g||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=vn(g,this.transformPagePoint),F.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:v,resumeAnimation:w}=this.handlers;if(this.dragSnapToOrigin&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=bn(f.type==="pointercancel"?this.lastMoveEventInfo:vn(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!bs(e))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const a=Me(e),l=vn(a,this.transformPagePoint),{point:u}=l,{timestamp:c}=q;this.history=[{...u,timestamp:c}];const{onSessionStart:d}=n;d&&d(e,bn(l,this.history)),this.removeListeners=Ce(pe(this.contextWindow,"pointermove",this.handlePointerMove),pe(this.contextWindow,"pointerup",this.handlePointerUp),pe(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),jt(this.updatePoint)}}function vn(t,e){return e?{point:e(t.point)}:t}function ki(t,e){return{x:t.x-e.x,y:t.y-e.y}}function bn({point:t},e){return{point:t,delta:ki(t,Lr(e)),offset:ki(t,nd(e)),velocity:sd(e,.1)}}function nd(t){return t[0]}function Lr(t){return t[t.length-1]}function sd(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Lr(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>ht(e)));)n--;if(!s)return{x:0,y:0};const r=at(i.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const o={x:(i.x-s.x)/r,y:(i.y-s.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function id(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?z(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?z(n,t,s.max):Math.min(t,n)),t}function Ri(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function od(t,{top:e,left:n,bottom:s,right:i}){return{x:Ri(t.x,n,i),y:Ri(t.y,e,s)}}function Ni(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function rd(t,e){return{x:Ni(t.x,e.x),y:Ni(t.y,e.y)}}function ad(t,e){let n=.5;const s=et(t),i=et(e);return i>s?n=xe(e.min,e.max-s,t.min):s>i&&(n=xe(t.min,t.max-i,e.min)),vt(0,1,n)}function ld(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Xn=.35;function cd(t=Xn){return t===!1?t=0:t===!0&&(t=Xn),{x:Ii(t,"left","right"),y:Ii(t,"top","bottom")}}function Ii(t,e,n){return{min:Li(t,e),max:Li(t,n)}}function Li(t,e){return typeof t=="number"?t:t[e]||0}const ud=new WeakMap;class dd{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=K(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const r=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Me(d).point)},o=(d,f)=>{const{drag:g,dragPropagation:y,onDragStart:v}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=xc(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),rt(x=>{let T=this.getAxisMotionValue(x).get()||0;if(yt.test(T)){const{projection:b}=this.visualElement;if(b&&b.layout){const E=b.layout.layoutBox[x];E&&(T=et(E)*(parseFloat(T)/100))}}this.originPoint[x]=T}),v&&F.postRender(()=>v(d,f)),Kn(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:v,onDrag:w}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:x}=f;if(y&&this.currentDirection===null){this.currentDirection=hd(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),w&&w(d,f)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>rt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new Ir(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:s,contextWindow:Nr(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!i||!s)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&F.postRender(()=>a(s,i))}cancel(){this.isDragging=!1;const{projection:e,animationState:n}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(e,n,s){const{drag:i}=this.getProps();if(!s||!Fe(e,i,this.currentDirection))return;const r=this.getAxisMotionValue(e);let o=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(o=id(o,this.constraints[e],this.elastic[e])),r.set(o)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&Jt(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=od(s.layoutBox,e):this.constraints=!1,this.elastic=cd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&rt(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=ld(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Jt(e))return!1;const s=e.current;bt(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const r=pu(s,i.root,this.visualElement.getTransformPagePoint());let o=rd(i.layout.layoutBox,r);if(n){const a=n(hu(o));this.hasMutatedConstraints=!!a,a&&(o=yr(a))}return o}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=rt(c=>{if(!Fe(c,n,this.currentDirection))return;let d=l&&l[c]||{};o&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,y={type:"inertia",velocity:s?e[c]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...r,...d};return this.startAxisValueAnimation(c,y)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Kn(this.visualElement,e),s.start(Es(e,s,0,n,this.visualElement,!1))}stopAnimation(){rt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){rt(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){rt(n=>{const{drag:s}=this.getProps();if(!Fe(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,r=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n];r.set(e[n]-z(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Jt(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};rt(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();i[o]=ad({min:l,max:l},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),rt(o=>{if(!Fe(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:u}=this.constraints[o];a.set(z(l,u,i[o]))})}addListeners(){if(!this.visualElement.current)return;ud.set(this.visualElement,this);const e=this.visualElement.current,n=pe(e,"pointerdown",l=>{const{drag:u,dragListener:c=!0}=this.getProps();u&&c&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();Jt(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,r=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),F.read(s);const o=Se(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(rt(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=l[c].translate,d.set(d.get()+l[c].translate))}),this.visualElement.render())});return()=>{o(),n(),r(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=Xn,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function Fe(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function hd(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class fd extends Dt{constructor(e){super(e),this.removeGroupControls=lt,this.removeListeners=lt,this.controls=new dd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||lt}unmount(){this.removeGroupControls(),this.removeListeners()}}const Oi=t=>(e,n)=>{t&&F.postRender(()=>t(e,n))};class md extends Dt{constructor(){super(...arguments),this.removePointerDownListener=lt}onPointerDown(e){this.session=new Ir(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Nr(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:Oi(e),onStart:Oi(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&F.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=pe(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const _e={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function Fi(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const he={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(M.test(t))t=parseFloat(t);else return t;const n=Fi(t,e.target.x),s=Fi(t,e.target.y);return`${n}% ${s}%`}},pd={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Vt.parse(t);if(i.length>5)return s;const r=Vt.createTransformer(t),o=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,l=n.y.scale*e.y;i[0+o]/=a,i[1+o]/=l;const u=z(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=u),typeof i[3+o]=="number"&&(i[3+o]/=u),r(i)}};let wn=!1;class gd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=e;$c(yd),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),wn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),_e.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,wn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==r?o.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?o.promote():o.relegate()||F.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),vs.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;wn=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),s&&s.deregister&&s.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Or(t){const[e,n]=ir(),s=m.useContext(Zn);return h.jsx(gd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(pr),isPresent:e,safeToRemove:n})}const yd={borderRadius:{...he,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:he,borderTopRightRadius:he,borderBottomLeftRadius:he,borderBottomRightRadius:he,boxShadow:pd};function xd(t,e,n){const s=Q(t)?t:ie(t);return s.start(Es("",s,e,n)),s.animation}const vd=(t,e)=>t.depth-e.depth;class bd{constructor(){this.children=[],this.isDirty=!1}add(e){ts(this.children,e),this.isDirty=!0}remove(e){es(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(vd),this.isDirty=!1,this.children.forEach(e)}}function wd(t,e){const n=nt.now(),s=({timestamp:i})=>{const r=i-n;r>=e&&(jt(s),t(r-e))};return F.setup(s,!0),()=>jt(s)}const Fr=["TopLeft","TopRight","BottomLeft","BottomRight"],Td=Fr.length,Bi=t=>typeof t=="string"?parseFloat(t):t,$i=t=>typeof t=="number"||M.test(t);function Sd(t,e,n,s,i,r){i?(t.opacity=z(0,n.opacity??1,Cd(s)),t.opacityExit=z(e.opacity??1,0,Ad(s))):r&&(t.opacity=z(e.opacity??1,n.opacity??1,s));for(let o=0;o<Td;o++){const a=`border${Fr[o]}Radius`;let l=zi(e,a),u=zi(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||$i(l)===$i(u)?(t[a]=Math.max(z(Bi(l),Bi(u),s),0),(yt.test(u)||yt.test(l))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=z(e.rotate||0,n.rotate||0,s))}function zi(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Cd=Br(0,.5,Co),Ad=Br(.5,.95,lt);function Br(t,e,n){return s=>s<t?0:s>e?1:n(xe(t,e,s))}function Ui(t,e){t.min=e.min,t.max=e.max}function ot(t,e){Ui(t.x,e.x),Ui(t.y,e.y)}function Wi(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function _i(t,e,n,s,i){return t-=e,t=Ze(t,1/n,s),i!==void 0&&(t=Ze(t,1/i,s)),t}function Pd(t,e=0,n=1,s=.5,i,r=t,o=t){if(yt.test(e)&&(e=parseFloat(e),e=z(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=z(r.min,r.max,s);t===r&&(a-=e),t.min=_i(t.min,e,n,a,i),t.max=_i(t.max,e,n,a,i)}function Ki(t,e,[n,s,i],r,o){Pd(t,e[n],e[s],e[i],e.scale,r,o)}const Md=["x","scaleX","originX"],jd=["y","scaleY","originY"];function Hi(t,e,n,s){Ki(t.x,e,Md,n?n.x:void 0,s?s.x:void 0),Ki(t.y,e,jd,n?n.y:void 0,s?s.y:void 0)}function Xi(t){return t.translate===0&&t.scale===1}function $r(t){return Xi(t.x)&&Xi(t.y)}function Yi(t,e){return t.min===e.min&&t.max===e.max}function Vd(t,e){return Yi(t.x,e.x)&&Yi(t.y,e.y)}function Gi(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function zr(t,e){return Gi(t.x,e.x)&&Gi(t.y,e.y)}function qi(t){return et(t.x)/et(t.y)}function Zi(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class Dd{constructor(){this.members=[]}add(e){ts(this.members,e),e.scheduleRender()}remove(e){if(es(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const r=this.members[i];if(r.isPresent!==!1){s=r;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Ed(t,e,n){let s="";const i=t.x.translate/e.x,r=t.y.translate/e.y,o=n?.z||0;if((i||r||o)&&(s=`translate3d(${i}px, ${r}px, ${o}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:c,rotateX:d,rotateY:f,skewX:g,skewY:y}=n;u&&(s=`perspective(${u}px) ${s}`),c&&(s+=`rotate(${c}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),y&&(s+=`skewY(${y}deg) `)}const a=t.x.scale*e.x,l=t.y.scale*e.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const Tn=["","X","Y","Z"],kd=1e3;let Rd=0;function Sn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function Ur(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=Pr(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",F,!(i||r))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&Ur(s)}function Wr({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Rd++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Ld),this.nodes.forEach($d),this.nodes.forEach(zd),this.nodes.forEach(Od)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new bd)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new ss),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const l=this.eventHandlers.get(o);l&&l.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=sr(o)&&!Cc(o),this.instance=o;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let c,d=0;const f=()=>this.root.updateBlockedByResize=!1;F.read(()=>{d=window.innerWidth}),t(o,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,c&&c(),c=wd(f,250),_e.hasAnimatedSinceResize&&(_e.hasAnimatedSinceResize=!1,this.nodes.forEach(to)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||u.getDefaultTransition()||Hd,{onLayoutAnimationStart:v,onLayoutAnimationComplete:w}=u.getProps(),x=!this.targetLayout||!zr(this.targetLayout,g),T=!d&&f;if(this.options.layoutRoot||this.resumeFrom||T||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...ys(y,"layout"),onPlay:v,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(c,T)}else d||to(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),jt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Ud),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Ur(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const d=this.path[c];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Ji);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Qi);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Bd),this.nodes.forEach(Nd),this.nodes.forEach(Id)):this.nodes.forEach(Qi),this.clearAllSnapshots();const a=nt.now();q.delta=vt(0,1e3/60,a-q.timestamp),q.timestamp=a,q.isProcessing=!0,dn.update.process(q),dn.preRender.process(q),dn.render.process(q),q.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,vs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Fd),this.sharedNodes.forEach(Wd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,F.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){F.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!et(this.snapshot.measuredBox.x)&&!et(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=K(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!$r(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,c=u!==this.prevTransformTemplateValue;o&&this.instance&&(a||Ut(this.latestValues)||c)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),Xd(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return K();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(Yd))){const{scroll:u}=this.root;u&&(Qt(a.x,u.offset.x),Qt(a.y,u.offset.y))}return a}removeElementScroll(o){const a=K();if(ot(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:c,options:d}=u;u!==this.root&&c&&d.layoutScroll&&(c.wasRoot&&ot(a,o),Qt(a.x,c.offset.x),Qt(a.y,c.offset.y))}return a}applyTransform(o,a=!1){const l=K();ot(l,o);for(let u=0;u<this.path.length;u++){const c=this.path[u];!a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&te(l,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),Ut(c.latestValues)&&te(l,c.latestValues)}return Ut(this.latestValues)&&te(l,this.latestValues),l}removeTransform(o){const a=K();ot(a,o);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Ut(u.latestValues))continue;zn(u.latestValues)&&u.updateSnapshot();const c=K(),d=u.measurePageBox();ot(c,d),Hi(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,c)}return Ut(this.latestValues)&&Hi(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==q.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:d}=this.options;if(!(!this.layout||!(c||d))){if(this.resolvedRelativeTargetAt=q.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=K(),this.relativeTargetOrigin=K(),ye(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),ot(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=K(),this.targetWithTransforms=K()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),td(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):ot(this.target,this.layout.layoutBox),vr(this.target,this.targetDelta)):ot(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=K(),this.relativeTargetOrigin=K(),ye(this.relativeTargetOrigin,this.target,f.target),ot(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||zn(this.parent.latestValues)||xr(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const o=this.getLead(),a=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===q.timestamp&&(l=!1),l)return;const{layout:u,layoutId:c}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||c))return;ot(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;mu(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=K());const{target:g}=o;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Wi(this.prevProjectionDelta.x,this.projectionDelta.x),Wi(this.prevProjectionDelta.y,this.projectionDelta.y)),ge(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Zi(this.projectionDelta.x,this.prevProjectionDelta.x)||!Zi(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ee(),this.projectionDelta=ee(),this.projectionDeltaWithTransform=ee()}setAnimationOrigin(o,a=!1){const l=this.snapshot,u=l?l.latestValues:{},c={...this.latestValues},d=ee();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=K(),g=l?l.source:void 0,y=this.layout?this.layout.source:void 0,v=g!==y,w=this.getStack(),x=!w||w.members.length<=1,T=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(Kd));this.animationProgress=0;let b;this.mixTargetDelta=E=>{const A=E/1e3;eo(d.x,o.x,A),eo(d.y,o.y,A),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(ye(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),_d(this.relativeTarget,this.relativeTargetOrigin,f,A),b&&Vd(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=K()),ot(b,this.relativeTarget)),v&&(this.animationValues=c,Sd(c,u,this.latestValues,A,T,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=A},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(jt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=F.update(()=>{_e.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=ie(0)),this.currentAnimation=xd(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(kd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:c}=o;if(!(!a||!l||!u)){if(this!==o&&this.layout&&u&&_r(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||K();const d=et(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=et(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}ot(a,l),te(a,c),ge(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new Dd),this.sharedNodes.get(o).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&Sn("z",o,u,this.animationValues);for(let c=0;c<Tn.length;c++)Sn(`rotate${Tn[c]}`,o,u,this.animationValues),Sn(`skew${Tn[c]}`,o,u,this.animationValues);o.render();for(const c in u)o.setStaticValue(c,u[c]),this.animationValues&&(this.animationValues[c]=u[c]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Ue(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Ue(a?.pointerEvents)||""),this.hasProjected&&!Ut(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const c=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=Ed(this.projectionDeltaWithTransform,this.treeScale,c);l&&(d=l(c,d)),o.transform=d;const{x:f,y:g}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?o.opacity=u===this?c.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:c.opacityExit:o.opacity=u===this?c.opacity!==void 0?c.opacity:"":c.opacityExit!==void 0?c.opacityExit:0;for(const y in Te){if(c[y]===void 0)continue;const{correct:v,applyTo:w,isCSSVariable:x}=Te[y],T=d==="none"?c[y]:v(c[y],u);if(w){const b=w.length;for(let E=0;E<b;E++)o[w[E]]=T}else x?this.options.visualElement.renderState.vars[y]=T:o[y]=T}this.options.layoutId&&(o.pointerEvents=u===this?Ue(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(Ji),this.root.sharedNodes.clear()}}}function Nd(t){t.updateLayout()}function Id(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,r=e.source!==t.layout.source;i==="size"?rt(c=>{const d=r?e.measuredBox[c]:e.layoutBox[c],f=et(d);d.min=n[c].min,d.max=d.min+f}):_r(i,e.layoutBox,n)&&rt(c=>{const d=r?e.measuredBox[c]:e.layoutBox[c],f=et(n[c]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[c].max=t.relativeTarget[c].min+f)});const o=ee();ge(o,n,e.layoutBox);const a=ee();r?ge(a,t.applyTransform(s,!0),e.measuredBox):ge(a,n,e.layoutBox);const l=!$r(o);let u=!1;if(!t.resumeFrom){const c=t.getClosestProjectingParent();if(c&&!c.resumeFrom){const{snapshot:d,layout:f}=c;if(d&&f){const g=K();ye(g,e.layoutBox,d.layoutBox);const y=K();ye(y,n,f.layoutBox),zr(g,y)||(u=!0),c.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=g,t.relativeParent=c)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Ld(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function Od(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function Fd(t){t.clearSnapshot()}function Ji(t){t.clearMeasurements()}function Qi(t){t.isLayoutDirty=!1}function Bd(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function to(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function $d(t){t.resolveTargetDelta()}function zd(t){t.calcProjection()}function Ud(t){t.resetSkewAndRotation()}function Wd(t){t.removeLeadSnapshot()}function eo(t,e,n){t.translate=z(e.translate,0,n),t.scale=z(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function no(t,e,n,s){t.min=z(e.min,n.min,s),t.max=z(e.max,n.max,s)}function _d(t,e,n,s){no(t.x,e.x,n.x,s),no(t.y,e.y,n.y,s)}function Kd(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Hd={duration:.45,ease:[.4,0,.1,1]},so=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),io=so("applewebkit/")&&!so("chrome/")?Math.round:lt;function oo(t){t.min=io(t.min),t.max=io(t.max)}function Xd(t){oo(t.x),oo(t.y)}function _r(t,e,n){return t==="position"||t==="preserve-aspect"&&!Qu(qi(e),qi(n),.2)}function Yd(t){return t!==t.root&&t.scroll?.wasRoot}const Gd=Wr({attachResizeListener:(t,e)=>Se(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Cn={current:void 0},Kr=Wr({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Cn.current){const t=new Gd({});t.mount(window),t.setOptions({layoutScroll:!0}),Cn.current=t}return Cn.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),qd={pan:{Feature:md},drag:{Feature:fd,ProjectionNode:Kr,MeasureLayout:Or}};function ro(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,r=s[i];r&&F.postRender(()=>r(e,Me(e)))}class Zd extends Dt{mount(){const{current:e}=this.node;e&&(this.unmount=vc(e,(n,s)=>(ro(this.node,s,"Start"),i=>ro(this.node,i,"End"))))}unmount(){}}class Jd extends Dt{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Ce(Se(this.node.current,"focus",()=>this.onFocus()),Se(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function ao(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),r=s[i];r&&F.postRender(()=>r(e,Me(e)))}class Qd extends Dt{mount(){const{current:e}=this.node;e&&(this.unmount=Sc(e,(n,s)=>(ao(this.node,s,"Start"),(i,{success:r})=>ao(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Yn=new WeakMap,An=new WeakMap,th=t=>{const e=Yn.get(t.target);e&&e(t)},eh=t=>{t.forEach(th)};function nh({root:t,...e}){const n=t||document;An.has(n)||An.set(n,{});const s=An.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(eh,{root:t,...e})),s[i]}function sh(t,e,n){const s=nh(e);return Yn.set(t,n),s.observe(t),()=>{Yn.delete(t),s.unobserve(t)}}const ih={some:0,all:1};class oh extends Dt{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:r}=e,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:ih[i]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,r&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=u?c:d;f&&f(l)};return sh(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(rh(e,n))&&this.startObserver()}unmount(){}}function rh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Hr={inView:{Feature:oh},tap:{Feature:Qd},focus:{Feature:Jd},hover:{Feature:Zd}},ah={layout:{ProjectionNode:Kr,MeasureLayout:Or}},lh={...Er,...Hr,...qd,...ah},ch=du(lh,Ar),uh={renderer:Ar,...Er,...Hr};function Xr(t,e){return We(t,e)}const Be=Xr("div"),dh=Xr("p");function Yr(t,e){if(!e)throw new Error(`❌ toolMetadata is required!
|
|
9
|
+
`),()=>{w.contains(v)&&w.removeChild(v)}},[e]),h.jsx(Ec,{isPresent:e,childRef:r,sizeRef:o,children:ht.cloneElement(t,{ref:l})})}const Rc=({children:t,initial:e,isPresent:n,onExitComplete:s,custom:i,presenceAffectsLayout:r,mode:o,anchorX:a,root:l})=>{const u=Qn(Nc),c=m.useId();let d=!0,f=m.useMemo(()=>(d=!1,{id:c,initial:e,isPresent:n,custom:i,onExitComplete:g=>{u.set(g,!0);for(const y of u.values())if(!y)return;s&&s()},register:g=>(u.set(g,!1),()=>u.delete(g))}),[n,u,s]);return r&&d&&(f={...f}),m.useMemo(()=>{u.forEach((g,y)=>u.set(y,!1))},[n]),ht.useEffect(()=>{!n&&!u.size&&s&&s()},[n]),o==="popLayout"&&(t=h.jsx(kc,{isPresent:n,anchorX:a,root:l,children:t})),h.jsx(en.Provider,{value:f,children:t})};function Nc(){return new Map}function rr(t=!0){const e=m.useContext(en);if(e===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:i}=e,r=m.useId();m.useEffect(()=>{if(t)return i(r)},[t]);const o=m.useCallback(()=>t&&s&&s(r),[r,s,t]);return!n&&s?[!1,o]:[!0]}const $e=t=>t.key||"";function yi(t){const e=[];return m.Children.forEach(t,n=>{m.isValidElement(n)&&e.push(n)}),e}const Ic=({children:t,custom:e,initial:n=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:r="sync",propagate:o=!1,anchorX:a="left",root:l})=>{const[u,c]=rr(o),d=m.useMemo(()=>yi(t),[t]),f=o&&!u?[]:d.map($e),g=m.useRef(!0),y=m.useRef(d),v=Qn(()=>new Map),[w,x]=m.useState(d),[S,b]=m.useState(d);po(()=>{g.current=!1,y.current=d;for(let D=0;D<S.length;D++){const R=$e(S[D]);f.includes(R)?v.delete(R):v.get(R)!==!0&&v.set(R,!1)}},[S,f.length,f.join("-")]);const k=[];if(d!==w){let D=[...d];for(let R=0;R<S.length;R++){const P=S[R],N=$e(P);f.includes(N)||(D.splice(R,0,P),k.push(P))}return r==="wait"&&k.length&&(D=k),b(yi(D)),x(d),null}process.env.NODE_ENV!=="production"&&r==="wait"&&S.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:A}=m.useContext(Jn);return h.jsx(h.Fragment,{children:S.map(D=>{const R=$e(D),P=o&&!u?!1:d===S||f.includes(R),N=()=>{if(v.has(R))v.set(R,!0);else return;let _=!0;v.forEach(z=>{z||(_=!1)}),_&&(A?.(),b(y.current),o&&c?.(),s&&s())};return h.jsx(Rc,{isPresent:P,initial:!g.current||n?void 0:!1,custom:e,presenceAffectsLayout:i,mode:r,root:l,onExitComplete:P?void 0:N,anchorX:a,children:D},R)})})},Ss=m.createContext({strict:!1}),xi={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},oe={};for(const t in xi)oe[t]={isEnabled:e=>xi[t].some(n=>!!e[n])};function zn(t){for(const e in t)oe[e]={...oe[e],...t[e]}}function Lc({children:t,features:e,strict:n=!1}){const[,s]=m.useState(!xn(e)),i=m.useRef(void 0);if(!xn(e)){const{renderer:r,...o}=e;i.current=r,zn(o)}return m.useEffect(()=>{xn(e)&&e().then(({renderer:r,...o})=>{zn(o),i.current=r,s(!0)})},[]),h.jsx(Ss.Provider,{value:{renderer:i.current,strict:n},children:t})}function xn(t){return typeof t=="function"}const Oc=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function Qe(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||Oc.has(t)}let ar=t=>!Qe(t);function Fc(t){typeof t=="function"&&(ar=e=>e.startsWith("on")?!Qe(e):t(e))}try{Fc(require("@emotion/is-prop-valid").default)}catch{}function Bc(t,e,n){const s={};for(const i in t)i==="values"&&typeof t.values=="object"||(ar(i)||n===!0&&Qe(i)||!e&&!Qe(i)||t.draggable&&i.startsWith("onDrag"))&&(s[i]=t[i]);return s}const nn=m.createContext({});function sn(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function Pe(t){return typeof t=="string"||Array.isArray(t)}const Cs=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],As=["initial",...Cs];function on(t){return sn(t.animate)||As.some(e=>Pe(t[e]))}function lr(t){return!!(on(t)||t.variants)}function $c(t,e){if(on(t)){const{initial:n,animate:s}=t;return{initial:n===!1||Pe(n)?n:void 0,animate:Pe(s)?s:void 0}}return t.inherit!==!1?e:{}}function zc(t){const{initial:e,animate:n}=$c(t,m.useContext(nn));return m.useMemo(()=>({initial:e,animate:n}),[vi(e),vi(n)])}function vi(t){return Array.isArray(t)?t.join(" "):t}const Me={};function Uc(t){for(const e in t)Me[e]=t[e],ls(e)&&(Me[e].isCSSVariable=!0)}function cr(t,{layout:e,layoutId:n}){return ce.has(t)||t.startsWith("origin")||(e||n!==void 0)&&(!!Me[t]||t==="opacity")}const _c={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},Wc=le.length;function Kc(t,e,n){let s="",i=!0;for(let r=0;r<Wc;r++){const o=le[r],a=t[o];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(o.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const u=tr(a,vs[o]);if(!l){i=!1;const c=_c[o]||o;s+=`${c}(${u}) `}n&&(e[o]=u)}}return s=s.trim(),n?s=n(e,i?"":s):i&&(s="none"),s}function Ps(t,e,n){const{style:s,vars:i,transformOrigin:r}=t;let o=!1,a=!1;for(const l in e){const u=e[l];if(ce.has(l)){o=!0;continue}else if(ls(l)){i[l]=u;continue}else{const c=tr(u,vs[l]);l.startsWith("origin")?(a=!0,r[l]=c):s[l]=c}}if(e.transform||(o||n?s.transform=Kc(e,t.transform,n):s.transform&&(s.transform="none")),a){const{originX:l="50%",originY:u="50%",originZ:c=0}=r;s.transformOrigin=`${l} ${u} ${c}`}}const Ms=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ur(t,e,n){for(const s in e)!tt(e[s])&&!cr(s,n)&&(t[s]=e[s])}function Hc({transformTemplate:t},e){return m.useMemo(()=>{const n=Ms();return Ps(n,e,t),Object.assign({},n.vars,n.style)},[e])}function Xc(t,e){const n=t.style||{},s={};return ur(s,n,t),Object.assign(s,Hc(t,e)),s}function Yc(t,e){const n={},s=Xc(t,e);return t.drag&&t.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(n.tabIndex=0),n.style=s,n}const Gc={offset:"stroke-dashoffset",array:"stroke-dasharray"},qc={offset:"strokeDashoffset",array:"strokeDasharray"};function Zc(t,e,n=1,s=0,i=!0){t.pathLength=1;const r=i?Gc:qc;t[r.offset]=M.transform(-s);const o=M.transform(e),a=M.transform(n);t[r.array]=`${o} ${a}`}function dr(t,{attrX:e,attrY:n,attrScale:s,pathLength:i,pathSpacing:r=1,pathOffset:o=0,...a},l,u,c){if(Ps(t,a,u),l){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:d,style:f}=t;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),f.transform&&(f.transformBox=c?.transformBox??"fill-box",delete d.transformBox),e!==void 0&&(d.x=e),n!==void 0&&(d.y=n),s!==void 0&&(d.scale=s),i!==void 0&&Zc(d,i,r,o,!1)}const hr=()=>({...Ms(),attrs:{}}),fr=t=>typeof t=="string"&&t.toLowerCase()==="svg";function Jc(t,e,n,s){const i=m.useMemo(()=>{const r=hr();return dr(r,e,fr(s),t.transformTemplate,t.style),{...r.attrs,style:{...r.style}}},[e]);if(t.style){const r={};ur(r,t.style,t),i.style={...r,...i.style}}return i}const Qc=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function js(t){return typeof t!="string"||t.includes("-")?!1:!!(Qc.indexOf(t)>-1||/[A-Z]/u.test(t))}function tu(t,e,n,{latestValues:s},i,r=!1){const a=(js(t)?Jc:Yc)(e,s,i,t),l=Bc(e,typeof t=="string",r),u=t!==m.Fragment?{...l,...a,ref:n}:{},{children:c}=e,d=m.useMemo(()=>tt(c)?c.get():c,[c]);return m.createElement(t,{...u,children:d})}function bi(t){const e=[{},{}];return t?.values.forEach((n,s)=>{e[0][s]=n.get(),e[1][s]=n.getVelocity()}),e}function Vs(t,e,n,s){if(typeof e=="function"){const[i,r]=bi(s);e=e(n!==void 0?n:t.custom,i,r)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,r]=bi(s);e=e(n!==void 0?n:t.custom,i,r)}return e}function Ke(t){return tt(t)?t.get():t}function eu({scrapeMotionValuesFromProps:t,createRenderState:e},n,s,i){return{latestValues:nu(n,s,i,t),renderState:e()}}function nu(t,e,n,s){const i={},r=s(t,{});for(const f in r)i[f]=Ke(r[f]);let{initial:o,animate:a}=t;const l=on(t),u=lr(t);e&&u&&!l&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let c=n?n.initial===!1:!1;c=c||o===!1;const d=c?a:o;if(d&&typeof d!="boolean"&&!sn(d)){const f=Array.isArray(d)?d:[d];for(let g=0;g<f.length;g++){const y=Vs(t,f[g]);if(y){const{transitionEnd:v,transition:w,...x}=y;for(const S in x){let b=x[S];if(Array.isArray(b)){const k=c?b.length-1:0;b=b[k]}b!==null&&(i[S]=b)}for(const S in v)i[S]=v[S]}}}return i}const mr=t=>(e,n)=>{const s=m.useContext(nn),i=m.useContext(en),r=()=>eu(t,e,s,i);return n?r():Qn(r)};function Ds(t,e,n){const{style:s}=t,i={};for(const r in s)(tt(s[r])||e.style&&tt(e.style[r])||cr(r,t)||n?.getValue(r)?.liveStyle!==void 0)&&(i[r]=s[r]);return i}const su=mr({scrapeMotionValuesFromProps:Ds,createRenderState:Ms});function pr(t,e,n){const s=Ds(t,e,n);for(const i in t)if(tt(t[i])||tt(e[i])){const r=le.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;s[r]=t[i]}return s}const iu=mr({scrapeMotionValuesFromProps:pr,createRenderState:hr}),ou=Symbol.for("motionComponentSymbol");function Jt(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function ru(t,e,n){return m.useCallback(s=>{s&&t.onMount&&t.onMount(s),e&&(s?e.mount(s):e.unmount()),n&&(typeof n=="function"?n(s):Jt(n)&&(n.current=s))},[e])}const Es=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),au="framerAppearId",gr="data-"+Es(au),yr=m.createContext({});function lu(t,e,n,s,i){const{visualElement:r}=m.useContext(nn),o=m.useContext(Ss),a=m.useContext(en),l=m.useContext(Ts).reducedMotion,u=m.useRef(null);s=s||o.renderer,!u.current&&s&&(u.current=s(t,{visualState:e,parent:r,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const c=u.current,d=m.useContext(yr);c&&!c.projection&&i&&(c.type==="html"||c.type==="svg")&&cu(u.current,n,i,d);const f=m.useRef(!1);m.useInsertionEffect(()=>{c&&f.current&&c.update(n,a)});const g=n[gr],y=m.useRef(!!g&&!window.MotionHandoffIsComplete?.(g)&&window.MotionHasOptimisedAnimation?.(g));return po(()=>{c&&(f.current=!0,window.MotionIsMounted=!0,c.updateFeatures(),c.scheduleRenderMicrotask(),y.current&&c.animationState&&c.animationState.animateChanges())}),m.useEffect(()=>{c&&(!y.current&&c.animationState&&c.animationState.animateChanges(),y.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(g)}),y.current=!1),c.enteringChildren=void 0)}),c}function cu(t,e,n,s){const{layoutId:i,layout:r,drag:o,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=e;t.projection=new n(t.latestValues,e["data-framer-portal-id"]?void 0:xr(t.parent)),t.projection.setOptions({layoutId:i,layout:r,alwaysMeasureLayout:!!o||a&&Jt(a),visualElement:t,animationType:typeof r=="string"?r:"both",initialPromotionConfig:s,crossfade:c,layoutScroll:l,layoutRoot:u})}function xr(t){if(t)return t.options.allowProjection!==!1?t.projection:xr(t.parent)}function He(t,{forwardMotionProps:e=!1}={},n,s){n&&zn(n);const i=js(t)?iu:su;function r(a,l){let u;const c={...m.useContext(Ts),...a,layoutId:uu(a)},{isStatic:d}=c,f=zc(a),g=i(a,d);if(!d&&ts){du(c,n);const y=hu(c);u=y.MeasureLayout,f.visualElement=lu(t,g,c,s,y.ProjectionNode)}return h.jsxs(nn.Provider,{value:f,children:[u&&f.visualElement?h.jsx(u,{visualElement:f.visualElement,...c}):null,tu(t,a,ru(g,f.visualElement,l),g,d,e)]})}r.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const o=m.forwardRef(r);return o[ou]=t,o}function uu({layoutId:t}){const e=m.useContext(Jn).id;return e&&t!==void 0?e+"-"+t:t}function du(t,e){const n=m.useContext(Ss).strict;if(process.env.NODE_ENV!=="production"&&e&&n){const s="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?re(!1,s,"lazy-strict-mode"):wt(!1,s,"lazy-strict-mode")}}function hu(t){const{drag:e,layout:n}=oe;if(!e&&!n)return{};const s={...e,...n};return{MeasureLayout:e?.isEnabled(t)||n?.isEnabled(t)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function fu(t,e){if(typeof Proxy>"u")return He;const n=new Map,s=(r,o)=>He(r,o,t,e),i=(r,o)=>(process.env.NODE_ENV!=="production"&&os(!1,"motion() is deprecated. Use motion.create() instead."),s(r,o));return new Proxy(i,{get:(r,o)=>o==="create"?s:(n.has(o)||n.set(o,He(o,void 0,t,e)),n.get(o))})}function vr({top:t,left:e,right:n,bottom:s}){return{x:{min:e,max:n},y:{min:t,max:s}}}function mu({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function pu(t,e){if(!e)return t;const n=e({x:t.left,y:t.top}),s=e({x:t.right,y:t.bottom});return{top:n.y,left:n.x,bottom:s.y,right:s.x}}function vn(t){return t===void 0||t===1}function Un({scale:t,scaleX:e,scaleY:n}){return!vn(t)||!vn(e)||!vn(n)}function Ut(t){return Un(t)||br(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function br(t){return wi(t.x)||wi(t.y)}function wi(t){return t&&t!=="0%"}function tn(t,e,n){const s=t-n,i=e*s;return n+i}function Ti(t,e,n,s,i){return i!==void 0&&(t=tn(t,i,s)),tn(t,n,s)+e}function _n(t,e=0,n=1,s,i){t.min=Ti(t.min,e,n,s,i),t.max=Ti(t.max,e,n,s,i)}function wr(t,{x:e,y:n}){_n(t.x,e.translate,e.scale,e.originPoint),_n(t.y,n.translate,n.scale,n.originPoint)}const Si=.999999999999,Ci=1.0000000000001;function gu(t,e,n,s=!1){const i=n.length;if(!i)return;e.x=e.y=1;let r,o;for(let a=0;a<i;a++){r=n[a],o=r.projectionDelta;const{visualElement:l}=r.options;l&&l.props.style&&l.props.style.display==="contents"||(s&&r.options.layoutScroll&&r.scroll&&r!==r.root&&te(t,{x:-r.scroll.offset.x,y:-r.scroll.offset.y}),o&&(e.x*=o.x.scale,e.y*=o.y.scale,wr(t,o)),s&&Ut(r.latestValues)&&te(t,r.latestValues))}e.x<Ci&&e.x>Si&&(e.x=1),e.y<Ci&&e.y>Si&&(e.y=1)}function Qt(t,e){t.min=t.min+e,t.max=t.max+e}function Ai(t,e,n,s,i=.5){const r=$(t.min,t.max,i);_n(t,e,n,r,s)}function te(t,e){Ai(t.x,e.x,e.scaleX,e.scale,e.originX),Ai(t.y,e.y,e.scaleY,e.scale,e.originY)}function Tr(t,e){return vr(pu(t.getBoundingClientRect(),e))}function yu(t,e,n){const s=Tr(t,n),{scroll:i}=e;return i&&(Qt(s.x,i.offset.x),Qt(s.y,i.offset.y)),s}const Pi=()=>({translate:0,scale:1,origin:0,originPoint:0}),ee=()=>({x:Pi(),y:Pi()}),Mi=()=>({min:0,max:0}),W=()=>({x:Mi(),y:Mi()}),Wn={current:null},Sr={current:!1};function xu(){if(Sr.current=!0,!!ts)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>Wn.current=t.matches;t.addEventListener("change",e),e()}else Wn.current=!1}const vu=new WeakMap;function bu(t,e,n){for(const s in e){const i=e[s],r=n[s];if(tt(i))t.addValue(s,i);else if(tt(r))t.addValue(s,ie(i,{owner:t}));else if(r!==i)if(t.hasValue(s)){const o=t.getValue(s);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=t.getStaticValue(s);t.addValue(s,ie(o!==void 0?o:i,{owner:t}))}}for(const s in n)e[s]===void 0&&t.removeValue(s);return e}const ji=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class wu{scrapeMotionValuesFromProps(e,n,s){return{}}constructor({parent:e,props:n,presenceContext:s,reducedMotionConfig:i,blockInitialAnimation:r,visualState:o},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=ys,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=nt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,O.render(this.render,!1,!0))};const{latestValues:l,renderState:u}=o;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=u,this.parent=e,this.props=n,this.presenceContext=s,this.depth=e?e.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!r,this.isControllingVariants=on(n),this.isVariantNode=lr(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:c,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const g=d[f];l[f]!==void 0&&tt(g)&&g.set(l[f])}}mount(e){this.current=e,vu.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Sr.current||xu(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Wn.current,process.env.NODE_ENV!=="production"&&os(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.parent?.addChild(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),Vt(this.notifyUpdate),Vt(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const n=this.features[e];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,n){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const s=ce.has(e);s&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&O.preRender(this.notifyUpdate),s&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,e,n)),this.valueSubscriptions.set(e,()=>{i(),r&&r(),n.owner&&n.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in oe){const n=oe[e];if(!n)continue;const{isEnabled:s,Feature:i}=n;if(!this.features[e]&&i&&s(this.props)&&(this.features[e]=new i(this)),this.features[e]){const r=this.features[e];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):W()}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<ji.length;s++){const i=ji[s];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const r="on"+i,o=e[r];o&&(this.propEventSubscriptions[i]=this.on(i,o))}this.prevMotionValues=bu(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(e),()=>n.variantChildren.delete(e)}addValue(e,n){const s=this.values.get(e);n!==s&&(s&&this.removeValue(e),this.bindToMotionValue(e,n),this.values.set(e,n),this.latestValues[e]=n.get())}removeValue(e){this.values.delete(e);const n=this.valueSubscriptions.get(e);n&&(n(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,n){if(this.props.values&&this.props.values[e])return this.props.values[e];let s=this.values.get(e);return s===void 0&&n!==void 0&&(s=ie(n===null?void 0:n,{owner:this}),this.addValue(e,s)),s}readValue(e,n){let s=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return s!=null&&(typeof s=="string"&&(go(s)||xo(s))?s=parseFloat(s):!jc(s)&&Dt.test(n)&&(s=Qo(e,n)),this.setBaseTarget(e,tt(s)?s.get():s)),tt(s)?s.get():s}setBaseTarget(e,n){this.baseTarget[e]=n}getBaseTarget(e){const{initial:n}=this.props;let s;if(typeof n=="string"||typeof n=="object"){const r=Vs(this.props,n,this.presenceContext?.custom);r&&(s=r[e])}if(n&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,e);return i!==void 0&&!tt(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(){bs.render(this.render)}}class Cr extends wu{constructor(){super(...arguments),this.KeyframeResolver=gc}sortInstanceNodePosition(e,n){return e.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(e,n){return e.style?e.style[n]:void 0}removeValueFromRenderState(e,{vars:n,style:s}){delete n[e],delete s[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;tt(e)&&(this.childSubscription=e.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Ar(t,{style:e,vars:n},s,i){const r=t.style;let o;for(o in e)r[o]=e[o];i?.applyProjectionStyles(r,s);for(o in n)r.setProperty(o,n[o])}function Tu(t){return window.getComputedStyle(t)}class Su extends Cr{constructor(){super(...arguments),this.type="html",this.renderInstance=Ar}readValueFromInstance(e,n){if(ce.has(n))return this.projection?.isProjecting?Nn(n):Nl(e,n);{const s=Tu(e),i=(ls(n)?s.getPropertyValue(n):s[n])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:n}){return Tr(e,n)}build(e,n,s){Ps(e,n,s.transformTemplate)}scrapeMotionValuesFromProps(e,n,s){return Ds(e,n,s)}}const Pr=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function Cu(t,e,n,s){Ar(t,e,void 0,s);for(const i in e.attrs)t.setAttribute(Pr.has(i)?i:Es(i),e.attrs[i])}class Au extends Cr{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=W}getBaseTargetFromProps(e,n){return e[n]}readValueFromInstance(e,n){if(ce.has(n)){const s=Jo(n);return s&&s.default||0}return n=Pr.has(n)?n:Es(n),e.getAttribute(n)}scrapeMotionValuesFromProps(e,n,s){return pr(e,n,s)}build(e,n,s){dr(e,n,this.isSVGTag,s.transformTemplate,s.style)}renderInstance(e,n,s,i){Cu(e,n,s,i)}mount(e){this.isSVGTag=fr(e.tagName),super.mount(e)}}const Mr=(t,e)=>js(t)?new Au(e):new Su(e,{allowProjection:t!==m.Fragment});function se(t,e,n){const s=t.getProps();return Vs(s,e,n!==void 0?n:s.custom,t)}const Kn=t=>Array.isArray(t);function Pu(t,e,n){t.hasValue(e)?t.getValue(e).set(n):t.addValue(e,ie(n))}function Mu(t){return Kn(t)?t[t.length-1]||0:t}function ju(t,e){const n=se(t,e);let{transitionEnd:s={},transition:i={},...r}=n||{};r={...r,...s};for(const o in r){const a=Mu(r[o]);Pu(t,o,a)}}function Vu(t){return!!(tt(t)&&t.add)}function Hn(t,e){const n=t.getValue("willChange");if(Vu(n))return n.add(e);if(!n&&Tt.WillChange){const s=new Tt.WillChange("auto");t.addValue("willChange",s),s.add(e)}}function jr(t){return t.props[gr]}const Du=t=>t!==null;function Eu(t,{repeat:e,repeatType:n="loop"},s){const i=t.filter(Du),r=e&&n!=="loop"&&e%2===1?0:i.length-1;return i[r]}const ku={type:"spring",stiffness:500,damping:25,restSpeed:10},Ru=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Nu={type:"keyframes",duration:.8},Iu={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Lu=(t,{keyframes:e})=>e.length>2?Nu:ce.has(t)?t.startsWith("scale")?Ru(e[1]):ku:Iu;function Ou({when:t,delay:e,delayChildren:n,staggerChildren:s,staggerDirection:i,repeat:r,repeatType:o,repeatDelay:a,from:l,elapsed:u,...c}){return!!Object.keys(c).length}const ks=(t,e,n,s={},i,r)=>o=>{const a=xs(s,t)||{},l=a.delay||s.delay||0;let{elapsed:u=0}=s;u=u-ft(l);const c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:f=>{e.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:r?void 0:i};Ou(a)||Object.assign(c,Lu(t,c)),c.duration&&(c.duration=ft(c.duration)),c.repeatDelay&&(c.repeatDelay=ft(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let d=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(Bn(c),c.delay===0&&(d=!0)),(Tt.instantAnimations||Tt.skipAnimations)&&(d=!0,Bn(c),c.delay=0),c.allowFlatten=!a.type&&!a.ease,d&&!r&&e.get()!==void 0){const f=Eu(c.keyframes,a);if(f!==void 0){O.update(()=>{c.onUpdate(f),c.onComplete()});return}}return a.isSync?new gs(c):new sc(c)};function Fu({protectedKeys:t,needsAnimating:e},n){const s=t.hasOwnProperty(n)&&e[n]!==!0;return e[n]=!1,s}function Vr(t,e,{delay:n=0,transitionOverride:s,type:i}={}){let{transition:r=t.getDefaultTransition(),transitionEnd:o,...a}=e;s&&(r=s);const l=[],u=i&&t.animationState&&t.animationState.getState()[i];for(const c in a){const d=t.getValue(c,t.latestValues[c]??null),f=a[c];if(f===void 0||u&&Fu(u,c))continue;const g={delay:n,...xs(r||{},c)},y=d.get();if(y!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===y&&!g.velocity)continue;let v=!1;if(window.MotionHandoffAnimation){const x=jr(t);if(x){const S=window.MotionHandoffAnimation(x,c,O);S!==null&&(g.startTime=S,v=!0)}}Hn(t,c),d.start(ks(c,d,f,t.shouldReduceMotion&&Go.has(c)?{type:!1}:g,t,v));const w=d.animation;w&&l.push(w)}return o&&Promise.all(l).then(()=>{O.update(()=>{o&&ju(t,o)})}),l}function Dr(t,e,n,s=0,i=1){const r=Array.from(t).sort((u,c)=>u.sortNodePosition(c)).indexOf(e),o=t.size,a=(o-1)*s;return typeof n=="function"?n(r,o):i===1?r*s:a-r*s}function Xn(t,e,n={}){const s=se(t,e,n.type==="exit"?t.presenceContext?.custom:void 0);let{transition:i=t.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const r=s?()=>Promise.all(Vr(t,s,n)):()=>Promise.resolve(),o=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:u=0,staggerChildren:c,staggerDirection:d}=i;return Bu(t,e,l,u,c,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[l,u]=a==="beforeChildren"?[r,o]:[o,r];return l().then(()=>u())}else return Promise.all([r(),o(n.delay)])}function Bu(t,e,n=0,s=0,i=0,r=1,o){const a=[];for(const l of t.variantChildren)l.notify("AnimationStart",e),a.push(Xn(l,e,{...o,delay:n+(typeof s=="function"?0:s)+Dr(t.variantChildren,l,s,i,r)}).then(()=>l.notify("AnimationComplete",e)));return Promise.all(a)}function $u(t,e,n={}){t.notify("AnimationStart",e);let s;if(Array.isArray(e)){const i=e.map(r=>Xn(t,r,n));s=Promise.all(i)}else if(typeof e=="string")s=Xn(t,e,n);else{const i=typeof e=="function"?se(t,e,n.custom):e;s=Promise.all(Vr(t,i,n))}return s.then(()=>{t.notify("AnimationComplete",e)})}function Er(t,e){if(!Array.isArray(e))return!1;const n=e.length;if(n!==t.length)return!1;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}const zu=As.length;function kr(t){if(!t)return;if(!t.isControllingVariants){const n=t.parent?kr(t.parent)||{}:{};return t.props.initial!==void 0&&(n.initial=t.props.initial),n}const e={};for(let n=0;n<zu;n++){const s=As[n],i=t.props[s];(Pe(i)||i===!1)&&(e[s]=i)}return e}const Uu=[...Cs].reverse(),_u=Cs.length;function Wu(t){return e=>Promise.all(e.map(({animation:n,options:s})=>$u(t,n,s)))}function Ku(t){let e=Wu(t),n=Vi(),s=!0;const i=l=>(u,c)=>{const d=se(t,c,l==="exit"?t.presenceContext?.custom:void 0);if(d){const{transition:f,transitionEnd:g,...y}=d;u={...u,...y,...g}}return u};function r(l){e=l(t)}function o(l){const{props:u}=t,c=kr(t.parent)||{},d=[],f=new Set;let g={},y=1/0;for(let w=0;w<_u;w++){const x=Uu[w],S=n[x],b=u[x]!==void 0?u[x]:c[x],k=Pe(b),A=x===l?S.isActive:null;A===!1&&(y=w);let D=b===c[x]&&b!==u[x]&&k;if(D&&s&&t.manuallyAnimateOnMount&&(D=!1),S.protectedKeys={...g},!S.isActive&&A===null||!b&&!S.prevProp||sn(b)||typeof b=="boolean")continue;const R=Hu(S.prevProp,b);let P=R||x===l&&S.isActive&&!D&&k||w>y&&k,N=!1;const _=Array.isArray(b)?b:[b];let z=_.reduce(i(x),{});A===!1&&(z={});const{prevResolvedValues:vt={}}=S,St={...vt,...z},st=E=>{P=!0,f.has(E)&&(N=!0,f.delete(E)),S.needsAnimating[E]=!0;const Y=t.getValue(E);Y&&(Y.liveStyle=!1)};for(const E in St){const Y=z[E],K=vt[E];if(g.hasOwnProperty(E))continue;let it=!1;Kn(Y)&&Kn(K)?it=!Er(Y,K):it=Y!==K,it?Y!=null?st(E):f.add(E):Y!==void 0&&f.has(E)?st(E):S.protectedKeys[E]=!0}S.prevProp=b,S.prevResolvedValues=z,S.isActive&&(g={...g,...z}),s&&t.blockInitialAnimation&&(P=!1);const Ct=D&&R;P&&(!Ct||N)&&d.push(..._.map(E=>{const Y={type:x};if(typeof E=="string"&&s&&!Ct&&t.manuallyAnimateOnMount&&t.parent){const{parent:K}=t,it=se(K,E);if(K.enteringChildren&&it){const{delayChildren:U}=it.transition||{};Y.delay=Dr(K.enteringChildren,t,U)}}return{animation:E,options:Y}}))}if(f.size){const w={};if(typeof u.initial!="boolean"){const x=se(t,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(w.transition=x.transition)}f.forEach(x=>{const S=t.getBaseTarget(x),b=t.getValue(x);b&&(b.liveStyle=!0),w[x]=S??null}),d.push({animation:w})}let v=!!d.length;return s&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(v=!1),s=!1,v?e(d):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();t.variantChildren?.forEach(d=>d.animationState?.setActive(l,u)),n[l].isActive=u;const c=o(l);for(const d in n)n[d].protectedKeys={};return c}return{animateChanges:o,setActive:a,setAnimateFunction:r,getState:()=>n,reset:()=>{n=Vi()}}}function Hu(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Er(e,t):!1}function $t(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Vi(){return{animate:$t(!0),whileInView:$t(),whileHover:$t(),whileTap:$t(),whileDrag:$t(),whileFocus:$t(),exit:$t()}}class Et{constructor(e){this.isMounted=!1,this.node=e}update(){}}class Xu extends Et{constructor(e){super(e),e.animationState||(e.animationState=Ku(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();sn(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:n}=this.node.prevProps||{};e!==n&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}}let Yu=0;class Gu extends Et{constructor(){super(...arguments),this.id=Yu++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===s)return;const i=this.node.animationState.setActive("exit",!e);n&&!e&&i.then(()=>{n(this.id)})}mount(){const{register:e,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const Rr={animation:{Feature:Xu},exit:{Feature:Gu}};function je(t,e,n,s={passive:!0}){return t.addEventListener(e,n,s),()=>t.removeEventListener(e,n)}function ke(t){return{point:{x:t.pageX,y:t.pageY}}}const qu=t=>e=>ws(e)&&t(e,ke(e));function be(t,e,n,s){return je(t,e,qu(n),s)}const Nr=1e-4,Zu=1-Nr,Ju=1+Nr,Ir=.01,Qu=0-Ir,td=0+Ir;function et(t){return t.max-t.min}function ed(t,e,n){return Math.abs(t-e)<=n}function Di(t,e,n,s=.5){t.origin=s,t.originPoint=$(e.min,e.max,t.origin),t.scale=et(n)/et(e),t.translate=$(n.min,n.max,t.origin)-t.originPoint,(t.scale>=Zu&&t.scale<=Ju||isNaN(t.scale))&&(t.scale=1),(t.translate>=Qu&&t.translate<=td||isNaN(t.translate))&&(t.translate=0)}function we(t,e,n,s){Di(t.x,e.x,n.x,s?s.originX:void 0),Di(t.y,e.y,n.y,s?s.originY:void 0)}function Ei(t,e,n){t.min=n.min+e.min,t.max=t.min+et(e)}function nd(t,e,n){Ei(t.x,e.x,n.x),Ei(t.y,e.y,n.y)}function ki(t,e,n){t.min=e.min-n.min,t.max=t.min+et(e)}function Te(t,e,n){ki(t.x,e.x,n.x),ki(t.y,e.y,n.y)}function lt(t){return[t("x"),t("y")]}const Lr=({current:t})=>t?t.ownerDocument.defaultView:null,Ri=(t,e)=>Math.abs(t-e);function sd(t,e){const n=Ri(t.x,e.x),s=Ri(t.y,e.y);return Math.sqrt(n**2+s**2)}class Or{constructor(e,n,{transformPagePoint:s,contextWindow:i=window,dragSnapToOrigin:r=!1,distanceThreshold:o=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=wn(this.lastMoveEventInfo,this.history),g=this.startEvent!==null,y=sd(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!g&&!y)return;const{point:v}=f,{timestamp:w}=Z;this.history.push({...v,timestamp:w});const{onStart:x,onMove:S}=this.handlers;g||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),S&&S(this.lastMoveEvent,f)},this.handlePointerMove=(f,g)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=bn(g,this.transformPagePoint),O.update(this.updatePoint,!0)},this.handlePointerUp=(f,g)=>{this.end();const{onEnd:y,onSessionEnd:v,resumeAnimation:w}=this.handlers;if(this.dragSnapToOrigin&&w&&w(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=wn(f.type==="pointercancel"?this.lastMoveEventInfo:bn(g,this.transformPagePoint),this.history);this.startEvent&&y&&y(f,x),v&&v(f,x)},!ws(e))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=o,this.contextWindow=i||window;const a=ke(e),l=bn(a,this.transformPagePoint),{point:u}=l,{timestamp:c}=Z;this.history=[{...u,timestamp:c}];const{onSessionStart:d}=n;d&&d(e,wn(l,this.history)),this.removeListeners=Ve(be(this.contextWindow,"pointermove",this.handlePointerMove),be(this.contextWindow,"pointerup",this.handlePointerUp),be(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Vt(this.updatePoint)}}function bn(t,e){return e?{point:e(t.point)}:t}function Ni(t,e){return{x:t.x-e.x,y:t.y-e.y}}function wn({point:t},e){return{point:t,delta:Ni(t,Fr(e)),offset:Ni(t,id(e)),velocity:od(e,.1)}}function id(t){return t[0]}function Fr(t){return t[t.length-1]}function od(t,e){if(t.length<2)return{x:0,y:0};let n=t.length-1,s=null;const i=Fr(t);for(;n>=0&&(s=t[n],!(i.timestamp-s.timestamp>ft(e)));)n--;if(!s)return{x:0,y:0};const r=ct(i.timestamp-s.timestamp);if(r===0)return{x:0,y:0};const o={x:(i.x-s.x)/r,y:(i.y-s.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function rd(t,{min:e,max:n},s){return e!==void 0&&t<e?t=s?$(e,t,s.min):Math.max(t,e):n!==void 0&&t>n&&(t=s?$(n,t,s.max):Math.min(t,n)),t}function Ii(t,e,n){return{min:e!==void 0?t.min+e:void 0,max:n!==void 0?t.max+n-(t.max-t.min):void 0}}function ad(t,{top:e,left:n,bottom:s,right:i}){return{x:Ii(t.x,n,i),y:Ii(t.y,e,s)}}function Li(t,e){let n=e.min-t.min,s=e.max-t.max;return e.max-e.min<t.max-t.min&&([n,s]=[s,n]),{min:n,max:s}}function ld(t,e){return{x:Li(t.x,e.x),y:Li(t.y,e.y)}}function cd(t,e){let n=.5;const s=et(t),i=et(e);return i>s?n=Se(e.min,e.max-s,t.min):s>i&&(n=Se(t.min,t.max-i,e.min)),bt(0,1,n)}function ud(t,e){const n={};return e.min!==void 0&&(n.min=e.min-t.min),e.max!==void 0&&(n.max=e.max-t.min),n}const Yn=.35;function dd(t=Yn){return t===!1?t=0:t===!0&&(t=Yn),{x:Oi(t,"left","right"),y:Oi(t,"top","bottom")}}function Oi(t,e,n){return{min:Fi(t,e),max:Fi(t,n)}}function Fi(t,e){return typeof t=="number"?t:t[e]||0}const hd=new WeakMap;class fd{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=W(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const r=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(ke(d).point)},o=(d,f)=>{const{drag:g,dragPropagation:y,onDragStart:v}=this.getProps();if(g&&!y&&(this.openDragLock&&this.openDragLock(),this.openDragLock=bc(g),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),lt(x=>{let S=this.getAxisMotionValue(x).get()||0;if(xt.test(S)){const{projection:b}=this.visualElement;if(b&&b.layout){const k=b.layout.layoutBox[x];k&&(S=et(k)*(parseFloat(S)/100))}}this.originPoint[x]=S}),v&&O.postRender(()=>v(d,f)),Hn(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:g,dragDirectionLock:y,onDirectionLock:v,onDrag:w}=this.getProps();if(!g&&!this.openDragLock)return;const{offset:x}=f;if(y&&this.currentDirection===null){this.currentDirection=md(x),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),w&&w(d,f)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>lt(d=>this.getAnimationState(d)==="paused"&&this.getAxisMotionValue(d).animation?.play()),{dragSnapToOrigin:c}=this.getProps();this.panSession=new Or(e,{onSessionStart:r,onStart:o,onMove:a,onSessionEnd:l,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,distanceThreshold:s,contextWindow:Lr(this.visualElement)})}stop(e,n){const s=e||this.latestPointerEvent,i=n||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!i||!s)return;const{velocity:o}=i;this.startAnimation(o);const{onDragEnd:a}=this.getProps();a&&O.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||!ze(e,i,this.currentDirection))return;const r=this.getAxisMotionValue(e);let o=this.originPoint[e]+s[e];this.constraints&&this.constraints[e]&&(o=rd(o,this.constraints[e],this.elastic[e])),r.set(o)}resolveConstraints(){const{dragConstraints:e,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,i=this.constraints;e&&Jt(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&s?this.constraints=ad(s.layoutBox,e):this.constraints=!1,this.elastic=dd(n),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&<(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=ud(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:n}=this.getProps();if(!e||!Jt(e))return!1;const s=e.current;wt(s!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const r=yu(s,i.root,this.visualElement.getTransformPagePoint());let o=ld(i.layout.layoutBox,r);if(n){const a=n(mu(o));this.hasMutatedConstraints=!!a,a&&(o=vr(a))}return o}startAnimation(e){const{drag:n,dragMomentum:s,dragElastic:i,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},u=lt(c=>{if(!ze(c,n,this.currentDirection))return;let d=l&&l[c]||{};o&&(d={min:0,max:0});const f=i?200:1e6,g=i?40:1e7,y={type:"inertia",velocity:s?e[c]:0,bounceStiffness:f,bounceDamping:g,timeConstant:750,restDelta:1,restSpeed:10,...r,...d};return this.startAxisValueAnimation(c,y)});return Promise.all(u).then(a)}startAxisValueAnimation(e,n){const s=this.getAxisMotionValue(e);return Hn(this.visualElement,e),s.start(ks(e,s,0,n,this.visualElement,!1))}stopAnimation(){lt(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){lt(e=>this.getAxisMotionValue(e).animation?.pause())}getAnimationState(e){return this.getAxisMotionValue(e).animation?.state}getAxisMotionValue(e){const n=`_drag${e.toUpperCase()}`,s=this.visualElement.getProps(),i=s[n];return i||this.visualElement.getValue(e,(s.initial?s.initial[e]:void 0)||0)}snapToCursor(e){lt(n=>{const{drag:s}=this.getProps();if(!ze(n,s,this.currentDirection))return;const{projection:i}=this.visualElement,r=this.getAxisMotionValue(n);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[n];r.set(e[n]-$(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!Jt(n)||!s||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};lt(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const l=a.get();i[o]=cd({min:l,max:l},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.resolveConstraints(),lt(o=>{if(!ze(o,e,null))return;const a=this.getAxisMotionValue(o),{min:l,max:u}=this.constraints[o];a.set($(l,u,i[o]))})}addListeners(){if(!this.visualElement.current)return;hd.set(this.visualElement,this);const e=this.visualElement.current,n=be(e,"pointerdown",l=>{const{drag:u,dragListener:c=!0}=this.getProps();u&&c&&this.start(l)}),s=()=>{const{dragConstraints:l}=this.getProps();Jt(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,r=i.addEventListener("measure",s);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),O.read(s);const o=je(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(lt(c=>{const d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=l[c].translate,d.set(d.get()+l[c].translate))}),this.visualElement.render())});return()=>{o(),n(),r(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:i=!1,dragConstraints:r=!1,dragElastic:o=Yn,dragMomentum:a=!0}=e;return{...e,drag:n,dragDirectionLock:s,dragPropagation:i,dragConstraints:r,dragElastic:o,dragMomentum:a}}}function ze(t,e,n){return(e===!0||e===t)&&(n===null||n===t)}function md(t,e=10){let n=null;return Math.abs(t.y)>e?n="y":Math.abs(t.x)>e&&(n="x"),n}class pd extends Et{constructor(e){super(e),this.removeGroupControls=ut,this.removeListeners=ut,this.controls=new fd(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ut}unmount(){this.removeGroupControls(),this.removeListeners()}}const Bi=t=>(e,n)=>{t&&O.postRender(()=>t(e,n))};class gd extends Et{constructor(){super(...arguments),this.removePointerDownListener=ut}onPointerDown(e){this.session=new Or(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Lr(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:n,onPan:s,onPanEnd:i}=this.node.getProps();return{onSessionStart:Bi(e),onStart:Bi(n),onMove:s,onEnd:(r,o)=>{delete this.session,i&&O.postRender(()=>i(r,o))}}}mount(){this.removePointerDownListener=be(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 Xe={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function $i(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const ye={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(M.test(t))t=parseFloat(t);else return t;const n=$i(t,e.target.x),s=$i(t,e.target.y);return`${n}% ${s}%`}},yd={correct:(t,{treeScale:e,projectionDelta:n})=>{const s=t,i=Dt.parse(t);if(i.length>5)return s;const r=Dt.createTransformer(t),o=typeof i[0]!="number"?1:0,a=n.x.scale*e.x,l=n.y.scale*e.y;i[0+o]/=a,i[1+o]/=l;const u=$(a,l,.5);return typeof i[2+o]=="number"&&(i[2+o]/=u),typeof i[3+o]=="number"&&(i[3+o]/=u),r(i)}};let Tn=!1;class xd extends m.Component{componentDidMount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s,layoutId:i}=this.props,{projection:r}=e;Uc(vd),r&&(n.group&&n.group.add(r),s&&s.register&&i&&s.register(r),Tn&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,onExitComplete:()=>this.safeToRemove()})),Xe.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:n,visualElement:s,drag:i,isPresent:r}=this.props,{projection:o}=s;return o&&(o.isPresent=r,Tn=!0,i||e.layoutDependency!==n||n===void 0||e.isPresent!==r?o.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?o.promote():o.relegate()||O.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),bs.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:i}=e;Tn=!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 Br(t){const[e,n]=rr(),s=m.useContext(Jn);return h.jsx(xd,{...t,layoutGroup:s,switchLayoutGroup:m.useContext(yr),isPresent:e,safeToRemove:n})}const vd={borderRadius:{...ye,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:ye,borderTopRightRadius:ye,borderBottomLeftRadius:ye,borderBottomRightRadius:ye,boxShadow:yd};function bd(t,e,n){const s=tt(t)?t:ie(t);return s.start(ks("",s,e,n)),s.animation}const wd=(t,e)=>t.depth-e.depth;class Td{constructor(){this.children=[],this.isDirty=!1}add(e){es(this.children,e),this.isDirty=!0}remove(e){ns(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(wd),this.isDirty=!1,this.children.forEach(e)}}function Sd(t,e){const n=nt.now(),s=({timestamp:i})=>{const r=i-n;r>=e&&(Vt(s),t(r-e))};return O.setup(s,!0),()=>Vt(s)}const $r=["TopLeft","TopRight","BottomLeft","BottomRight"],Cd=$r.length,zi=t=>typeof t=="string"?parseFloat(t):t,Ui=t=>typeof t=="number"||M.test(t);function Ad(t,e,n,s,i,r){i?(t.opacity=$(0,n.opacity??1,Pd(s)),t.opacityExit=$(e.opacity??1,0,Md(s))):r&&(t.opacity=$(e.opacity??1,n.opacity??1,s));for(let o=0;o<Cd;o++){const a=`border${$r[o]}Radius`;let l=_i(e,a),u=_i(n,a);if(l===void 0&&u===void 0)continue;l||(l=0),u||(u=0),l===0||u===0||Ui(l)===Ui(u)?(t[a]=Math.max($(zi(l),zi(u),s),0),(xt.test(u)||xt.test(l))&&(t[a]+="%")):t[a]=u}(e.rotate||n.rotate)&&(t.rotate=$(e.rotate||0,n.rotate||0,s))}function _i(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Pd=zr(0,.5,Po),Md=zr(.5,.95,ut);function zr(t,e,n){return s=>s<t?0:s>e?1:n(Se(t,e,s))}function Wi(t,e){t.min=e.min,t.max=e.max}function at(t,e){Wi(t.x,e.x),Wi(t.y,e.y)}function Ki(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function Hi(t,e,n,s,i){return t-=e,t=tn(t,1/n,s),i!==void 0&&(t=tn(t,1/i,s)),t}function jd(t,e=0,n=1,s=.5,i,r=t,o=t){if(xt.test(e)&&(e=parseFloat(e),e=$(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=$(r.min,r.max,s);t===r&&(a-=e),t.min=Hi(t.min,e,n,a,i),t.max=Hi(t.max,e,n,a,i)}function Xi(t,e,[n,s,i],r,o){jd(t,e[n],e[s],e[i],e.scale,r,o)}const Vd=["x","scaleX","originX"],Dd=["y","scaleY","originY"];function Yi(t,e,n,s){Xi(t.x,e,Vd,n?n.x:void 0,s?s.x:void 0),Xi(t.y,e,Dd,n?n.y:void 0,s?s.y:void 0)}function Gi(t){return t.translate===0&&t.scale===1}function Ur(t){return Gi(t.x)&&Gi(t.y)}function qi(t,e){return t.min===e.min&&t.max===e.max}function Ed(t,e){return qi(t.x,e.x)&&qi(t.y,e.y)}function Zi(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function _r(t,e){return Zi(t.x,e.x)&&Zi(t.y,e.y)}function Ji(t){return et(t.x)/et(t.y)}function Qi(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class kd{constructor(){this.members=[]}add(e){es(this.members,e),e.scheduleRender()}remove(e){if(ns(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(e){const n=this.members.findIndex(i=>e===i);if(n===0)return!1;let s;for(let i=n;i>=0;i--){const r=this.members[i];if(r.isPresent!==!1){s=r;break}}return s?(this.promote(s),!0):!1}promote(e,n){const s=this.lead;if(e!==s&&(this.prevLead=s,this.lead=e,e.show(),s)){s.instance&&s.scheduleRender(),e.scheduleRender(),e.resumeFrom=s,n&&(e.resumeFrom.preserveOpacity=!0),s.snapshot&&(e.snapshot=s.snapshot,e.snapshot.latestValues=s.animationValues||s.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&s.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:n,resumingFrom:s}=e;n.onExitComplete&&n.onExitComplete(),s&&s.options.onExitComplete&&s.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function Rd(t,e,n){let s="";const i=t.x.translate/e.x,r=t.y.translate/e.y,o=n?.z||0;if((i||r||o)&&(s=`translate3d(${i}px, ${r}px, ${o}px) `),(e.x!==1||e.y!==1)&&(s+=`scale(${1/e.x}, ${1/e.y}) `),n){const{transformPerspective:u,rotate:c,rotateX:d,rotateY:f,skewX:g,skewY:y}=n;u&&(s=`perspective(${u}px) ${s}`),c&&(s+=`rotate(${c}deg) `),d&&(s+=`rotateX(${d}deg) `),f&&(s+=`rotateY(${f}deg) `),g&&(s+=`skewX(${g}deg) `),y&&(s+=`skewY(${y}deg) `)}const a=t.x.scale*e.x,l=t.y.scale*e.y;return(a!==1||l!==1)&&(s+=`scale(${a}, ${l})`),s||"none"}const Sn=["","X","Y","Z"],Nd=1e3;let Id=0;function Cn(t,e,n,s){const{latestValues:i}=e;i[t]&&(n[t]=i[t],e.setStaticValue(t,0),s&&(s[t]=0))}function Wr(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const n=jr(e);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:r}=t.options;window.MotionCancelOptimisedAnimation(n,"transform",O,!(i||r))}const{parent:s}=t;s&&!s.hasCheckedOptimisedAppear&&Wr(s)}function Kr({attachResizeListener:t,defaultParent:e,measureScroll:n,checkIsScrollRoot:s,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=Id++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(Fd),this.nodes.forEach(Ud),this.nodes.forEach(_d),this.nodes.forEach(Bd)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new Td)}addEventListener(o,a){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new is),this.eventHandlers.get(o).add(a)}notifyListeners(o,...a){const l=this.eventHandlers.get(o);l&&l.notify(...a)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=or(o)&&!Pc(o),this.instance=o;const{layoutId:a,layout:l,visualElement:u}=this.options;if(u&&!u.current&&u.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),t){let c,d=0;const f=()=>this.root.updateBlockedByResize=!1;O.read(()=>{d=window.innerWidth}),t(o,()=>{const g=window.innerWidth;g!==d&&(d=g,this.root.updateBlockedByResize=!0,c&&c(),c=Sd(f,250),Xe.hasAnimatedSinceResize&&(Xe.hasAnimatedSinceResize=!1,this.nodes.forEach(no)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&u&&(a||l)&&this.addEventListener("didUpdate",({delta:c,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const y=this.options.transition||u.getDefaultTransition()||Yd,{onLayoutAnimationStart:v,onLayoutAnimationComplete:w}=u.getProps(),x=!this.targetLayout||!_r(this.targetLayout,g),S=!d&&f;if(this.options.layoutRoot||this.resumeFrom||S||d&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...xs(y,"layout"),onPlay:v,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(c,S)}else d||no(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Vt(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Wd),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Wr(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let c=0;c<this.path.length;c++){const d=this.path[c];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(to);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(eo);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(zd),this.nodes.forEach(Ld),this.nodes.forEach(Od)):this.nodes.forEach(eo),this.clearAllSnapshots();const a=nt.now();Z.delta=bt(0,1e3/60,a-Z.timestamp),Z.timestamp=a,Z.isProcessing=!0,hn.update.process(Z),hn.preRender.process(Z),hn.render.process(Z),Z.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,bs.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach($d),this.sharedNodes.forEach(Kd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,O.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){O.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!et(this.snapshot.measuredBox.x)&&!et(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l<this.path.length;l++)this.path[l].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=W(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(a=!1),a&&this.instance){const l=s(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Ur(this.projectionDelta),l=this.getTransformTemplate(),u=l?l(this.latestValues,""):void 0,c=u!==this.prevTransformTemplateValue;o&&this.instance&&(a||Ut(this.latestValues)||c)&&(i(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return o&&(l=this.removeTransform(l)),Gd(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){const{visualElement:o}=this.options;if(!o)return W();const a=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(qd))){const{scroll:u}=this.root;u&&(Qt(a.x,u.offset.x),Qt(a.y,u.offset.y))}return a}removeElementScroll(o){const a=W();if(at(a,o),this.scroll?.wasRoot)return a;for(let l=0;l<this.path.length;l++){const u=this.path[l],{scroll:c,options:d}=u;u!==this.root&&c&&d.layoutScroll&&(c.wasRoot&&at(a,o),Qt(a.x,c.offset.x),Qt(a.y,c.offset.y))}return a}applyTransform(o,a=!1){const l=W();at(l,o);for(let u=0;u<this.path.length;u++){const c=this.path[u];!a&&c.options.layoutScroll&&c.scroll&&c!==c.root&&te(l,{x:-c.scroll.offset.x,y:-c.scroll.offset.y}),Ut(c.latestValues)&&te(l,c.latestValues)}return Ut(this.latestValues)&&te(l,this.latestValues),l}removeTransform(o){const a=W();at(a,o);for(let l=0;l<this.path.length;l++){const u=this.path[l];if(!u.instance||!Ut(u.latestValues))continue;Un(u.latestValues)&&u.updateSnapshot();const c=W(),d=u.measurePageBox();at(c,d),Yi(a,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,c)}return Ut(this.latestValues)&&Yi(a,this.latestValues),a}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Z.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(o||l&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:c,layoutId:d}=this.options;if(!(!this.layout||!(c||d))){if(this.resolvedRelativeTargetAt=Z.timestamp,!this.targetDelta&&!this.relativeTarget){const f=this.getClosestProjectingParent();f&&f.layout&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=W(),this.relativeTargetOrigin=W(),Te(this.relativeTargetOrigin,this.layout.layoutBox,f.layout.layoutBox),at(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=W(),this.targetWithTransforms=W()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),nd(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):at(this.target,this.layout.layoutBox),wr(this.target,this.targetDelta)):at(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const f=this.getClosestProjectingParent();f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?(this.relativeParent=f,this.forceRelativeParentToResolveTarget(),this.relativeTarget=W(),this.relativeTargetOrigin=W(),Te(this.relativeTargetOrigin,this.target,f.target),at(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||Un(this.parent.latestValues)||br(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){const o=this.getLead(),a=!!this.resumingFrom||this!==o;let l=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===Z.timestamp&&(l=!1),l)return;const{layout:u,layoutId:c}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||c))return;at(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;gu(this.layoutCorrected,this.treeScale,this.path,a),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=W());const{target:g}=o;if(!g){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Ki(this.prevProjectionDelta.x,this.projectionDelta.x),Ki(this.prevProjectionDelta.y,this.projectionDelta.y)),we(this.projectionDelta,this.layoutCorrected,g,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!Qi(this.projectionDelta.x,this.prevProjectionDelta.x)||!Qi(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",g))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){const a=this.getStack();a&&a.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=ee(),this.projectionDelta=ee(),this.projectionDeltaWithTransform=ee()}setAnimationOrigin(o,a=!1){const l=this.snapshot,u=l?l.latestValues:{},c={...this.latestValues},d=ee();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=W(),g=l?l.source:void 0,y=this.layout?this.layout.source:void 0,v=g!==y,w=this.getStack(),x=!w||w.members.length<=1,S=!!(v&&!x&&this.options.crossfade===!0&&!this.path.some(Xd));this.animationProgress=0;let b;this.mixTargetDelta=k=>{const A=k/1e3;so(d.x,o.x,A),so(d.y,o.y,A),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Te(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),Hd(this.relativeTarget,this.relativeTargetOrigin,f,A),b&&Ed(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=W()),at(b,this.relativeTarget)),v&&(this.animationValues=c,Ad(c,u,this.latestValues,A,S,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=A},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Vt(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=O.update(()=>{Xe.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=ie(0)),this.currentAnimation=bd(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onStop:()=>{},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Nd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:l,layout:u,latestValues:c}=o;if(!(!a||!l||!u)){if(this!==o&&this.layout&&u&&Hr(this.options.animationType,this.layout.layoutBox,u.layoutBox)){l=this.target||W();const d=et(this.layout.layoutBox.x);l.x.min=o.target.x.min,l.x.max=l.x.min+d;const f=et(this.layout.layoutBox.y);l.y.min=o.target.y.min,l.y.max=l.y.min+f}at(a,l),te(a,c),we(this.projectionDeltaWithTransform,this.layoutCorrected,a,c)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new kd),this.sharedNodes.get(o).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){const{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){const{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:l}={}){const u=this.getStack();u&&u.promote(this,l),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:l}=o;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const u={};l.z&&Cn("z",o,u,this.animationValues);for(let c=0;c<Sn.length;c++)Cn(`rotate${Sn[c]}`,o,u,this.animationValues),Cn(`skew${Sn[c]}`,o,u,this.animationValues);o.render();for(const c in u)o.setStaticValue(c,u[c]),this.animationValues&&(this.animationValues[c]=u[c]);o.scheduleRender()}applyProjectionStyles(o,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Ke(a?.pointerEvents)||"",o.transform=l?l(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Ke(a?.pointerEvents)||""),this.hasProjected&&!Ut(this.latestValues)&&(o.transform=l?l({},""):"none",this.hasProjected=!1);return}o.visibility="";const c=u.animationValues||u.latestValues;this.applyTransformsToTarget();let d=Rd(this.projectionDeltaWithTransform,this.treeScale,c);l&&(d=l(c,d)),o.transform=d;const{x:f,y:g}=this.projectionDelta;o.transformOrigin=`${f.origin*100}% ${g.origin*100}% 0`,u.animationValues?o.opacity=u===this?c.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:c.opacityExit:o.opacity=u===this?c.opacity!==void 0?c.opacity:"":c.opacityExit!==void 0?c.opacityExit:0;for(const y in Me){if(c[y]===void 0)continue;const{correct:v,applyTo:w,isCSSVariable:x}=Me[y],S=d==="none"?c[y]:v(c[y],u);if(w){const b=w.length;for(let k=0;k<b;k++)o[w[k]]=S}else x?this.options.visualElement.renderState.vars[y]=S:o[y]=S}this.options.layoutId&&(o.pointerEvents=u===this?Ke(a?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(to),this.root.sharedNodes.clear()}}}function Ld(t){t.updateLayout()}function Od(t){const e=t.resumeFrom?.snapshot||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,r=e.source!==t.layout.source;i==="size"?lt(c=>{const d=r?e.measuredBox[c]:e.layoutBox[c],f=et(d);d.min=n[c].min,d.max=d.min+f}):Hr(i,e.layoutBox,n)&<(c=>{const d=r?e.measuredBox[c]:e.layoutBox[c],f=et(n[c]);d.max=d.min+f,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[c].max=t.relativeTarget[c].min+f)});const o=ee();we(o,n,e.layoutBox);const a=ee();r?we(a,t.applyTransform(s,!0),e.measuredBox):we(a,n,e.layoutBox);const l=!Ur(o);let u=!1;if(!t.resumeFrom){const c=t.getClosestProjectingParent();if(c&&!c.resumeFrom){const{snapshot:d,layout:f}=c;if(d&&f){const g=W();Te(g,e.layoutBox,d.layoutBox);const y=W();Te(y,n,f.layoutBox),_r(g,y)||(u=!0),c.options.layoutRoot&&(t.relativeTarget=y,t.relativeTargetOrigin=g,t.relativeParent=c)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:a,layoutDelta:o,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function Fd(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function Bd(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function $d(t){t.clearSnapshot()}function to(t){t.clearMeasurements()}function eo(t){t.isLayoutDirty=!1}function zd(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function no(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function Ud(t){t.resolveTargetDelta()}function _d(t){t.calcProjection()}function Wd(t){t.resetSkewAndRotation()}function Kd(t){t.removeLeadSnapshot()}function so(t,e,n){t.translate=$(e.translate,0,n),t.scale=$(e.scale,1,n),t.origin=e.origin,t.originPoint=e.originPoint}function io(t,e,n,s){t.min=$(e.min,n.min,s),t.max=$(e.max,n.max,s)}function Hd(t,e,n,s){io(t.x,e.x,n.x,s),io(t.y,e.y,n.y,s)}function Xd(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const Yd={duration:.45,ease:[.4,0,.1,1]},oo=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),ro=oo("applewebkit/")&&!oo("chrome/")?Math.round:ut;function ao(t){t.min=ro(t.min),t.max=ro(t.max)}function Gd(t){ao(t.x),ao(t.y)}function Hr(t,e,n){return t==="position"||t==="preserve-aspect"&&!ed(Ji(e),Ji(n),.2)}function qd(t){return t!==t.root&&t.scroll?.wasRoot}const Zd=Kr({attachResizeListener:(t,e)=>je(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),An={current:void 0},Xr=Kr({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!An.current){const t=new Zd({});t.mount(window),t.setOptions({layoutScroll:!0}),An.current=t}return An.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Jd={pan:{Feature:gd},drag:{Feature:pd,ProjectionNode:Xr,MeasureLayout:Br}};function lo(t,e,n){const{props:s}=t;t.animationState&&s.whileHover&&t.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,r=s[i];r&&O.postRender(()=>r(e,ke(e)))}class Qd extends Et{mount(){const{current:e}=this.node;e&&(this.unmount=wc(e,(n,s)=>(lo(this.node,s,"Start"),i=>lo(this.node,i,"End"))))}unmount(){}}class th extends Et{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Ve(je(this.node.current,"focus",()=>this.onFocus()),je(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function co(t,e,n){const{props:s}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&s.whileTap&&t.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),r=s[i];r&&O.postRender(()=>r(e,ke(e)))}class eh extends Et{mount(){const{current:e}=this.node;e&&(this.unmount=Ac(e,(n,s)=>(co(this.node,s,"Start"),(i,{success:r})=>co(this.node,i,r?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const Gn=new WeakMap,Pn=new WeakMap,nh=t=>{const e=Gn.get(t.target);e&&e(t)},sh=t=>{t.forEach(nh)};function ih({root:t,...e}){const n=t||document;Pn.has(n)||Pn.set(n,{});const s=Pn.get(n),i=JSON.stringify(e);return s[i]||(s[i]=new IntersectionObserver(sh,{root:t,...e})),s[i]}function oh(t,e,n){const s=ih(e);return Gn.set(t,n),s.observe(t),()=>{Gn.delete(t),s.unobserve(t)}}const rh={some:0,all:1};class ah extends Et{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:n,margin:s,amount:i="some",once:r}=e,o={root:n?n.current:void 0,rootMargin:s,threshold:typeof i=="number"?i:rh[i]},a=l=>{const{isIntersecting:u}=l;if(this.isInView===u||(this.isInView=u,r&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:c,onViewportLeave:d}=this.node.getProps(),f=u?c:d;f&&f(l)};return oh(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:n}=this.node;["amount","margin","root"].some(lh(e,n))&&this.startObserver()}unmount(){}}function lh({viewport:t={}},{viewport:e={}}={}){return n=>t[n]!==e[n]}const Yr={inView:{Feature:ah},tap:{Feature:eh},focus:{Feature:th},hover:{Feature:Qd}},ch={layout:{ProjectionNode:Xr,MeasureLayout:Br}},uh={...Rr,...Yr,...Jd,...ch},dh=fu(uh,Mr),hh={renderer:Mr,...Rr,...Yr};function Gr(t,e){return He(t,e)}const Ue=Gr("div"),fh=Gr("p");function qr(t,e){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)
|
|
@@ -39,9 +39,9 @@ To fix this:
|
|
|
39
39
|
import { toolMetadata } from './.arcten/tool-metadata';
|
|
40
40
|
useAgent({ tools: [${s}], toolMetadata: toolMetadata.functions })
|
|
41
41
|
|
|
42
|
-
💡 Tip: ${i?"The script can only extract types from functions with explicit TypeScript type annotations on parameters.":"Functions with no parameters work fine - just make sure they're used in ArctenAgent or useAgent."}`)}return{name:s,description:e[s].description,jsonSchema:e[s].parameters}})}function hh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const r=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),r&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([o,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[o,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},o))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(He,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(X.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(He,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(X.X,{className:"h-3 w-3"})})]})]})})}function fh({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,r]=m.useState(!1);if(t==="fetchDocContent")return null;const o=["k","maxResults","_organizationId"];t==="searchDocs"&&o.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!o.includes(u))),l=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>l&&r(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${l?"cursor-pointer hover:bg-opacity-80":""}`,children:[l&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(X.ChevronDown,{className:"h-3 w-3"}):h.jsx(X.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(X.X,{className:"h-3 w-3"}):s?h.jsx(X.Zap,{className:"h-3 w-3"}):h.jsx(X.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&l&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,c])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof c=="string"?c:JSON.stringify(c)})]},u))})})]})}function mh({...t}){return h.jsx(qn.Root,{"data-slot":"collapsible",...t})}function ph({...t}){return h.jsx(qn.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function gh({...t}){return h.jsx(qn.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const yh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),ks=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(yh,{className:Z("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);ks.displayName="Response";const xh=Object.freeze(Object.defineProperty({__proto__:null,Response:ks},Symbol.toStringTag,{value:"Module"})),vh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const r=ch.create(e),o=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(r,{animate:{backgroundPosition:"0% center"},className:Z("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${o}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},bh=m.memo(vh),Gr=m.createContext(null),wh=()=>{const t=m.useContext(Gr);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Th=1e3,Sh=1e3,qr=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:r,children:o,...a})=>{const[l,u]=Ks.useControllableState({prop:n,defaultProp:s,onChange:i}),[c,d]=Ks.useControllableState({prop:r,defaultProp:0}),[f,g]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{e?y===null&&v(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/Sh)),v(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&l&&!f){const x=setTimeout(()=>{u(!1),g(!0)},Th);return()=>clearTimeout(x)}},[e,l,s,u,f]);const w=x=>{u(x)};return h.jsx(Gr.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:u,duration:c},children:h.jsx(mh,{className:Z("not-prose mb-4",t),onOpenChange:w,open:l,...a,children:o})})}),Ch=(t,e)=>t||e===0?h.jsx(bh,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Zr=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:r}=wh();return h.jsx(ph,{className:Z("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(X.BrainIcon,{className:"size-4"}),Ch(s,r),h.jsx(X.ChevronDownIcon,{className:Z("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),Jr=m.memo(({className:t,children:e,...n})=>h.jsx(gh,{className:Z("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",t),...n,children:h.jsx(ks,{className:"grid gap-2",children:e})}));qr.displayName="Reasoning";Zr.displayName="ReasoningTrigger";Jr.displayName="ReasoningContent";function Ah({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:r=void 0,defaultWidth:o=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:c=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:y="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:w}){const[x,T]=m.useState(null),b=m.useRef(null),[E,A]=m.useState(null),[j,k]=m.useState(null),P=m.useRef(null),[N,W]=m.useState(u),[U,xt]=m.useState(o),[Tt,ft]=m.useState(600),[Et,St]=m.useState(!1),[V,Y]=m.useState(!1),[L,st]=m.useState(!1),[G,kt]=m.useState({x:100,y:100}),[je,Ct]=m.useState(!1),[Rt,Ve]=m.useState({x:0,y:0}),[nn,sn]=m.useState(!1),Xt=m.useRef(null),Yt=m.useRef(null),[D,R]=m.useState(""),[_,it]=m.useState(null),[tt,ct]=m.useState("Thinking..."),[on,rn]=m.useState(new Set),[Qr,ta]=m.useState(""),[Nt,ea]=m.useState([]),[an,Rs]=m.useState(!1),[ln,Ns]=m.useState([]),[Is,cn]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Gt,De]=m.useState(!1),[Mh,Ee]=m.useState(!1),[jh,ke]=m.useState([]),It=m.useMemo(()=>[...c,...d],[c,d]),Ls=m.useMemo(()=>Yr(It,f),[It,f]),Os=m.useMemo(()=>{const p=new Map;return It.forEach(C=>p.set(C.name,C)),p},[It]),Fs=m.useMemo(()=>new Set(d.map(p=>p.name)),[d]),Bs=["Thinking...","Pondering...","Contemplating...","Considering...","Analyzing...","Processing...","Reasoning...","Mulling it over...","Computing...","Cooking up a response...","Brewing ideas...","Connecting the dots...","Piecing it together...","Spinning up thoughts...","Loading brain cells...","Sharpening pencils...","Herding ideas...","Warming up neurons...","Stirring the think-pot...","Plotting a plan...","Wiggling the logic wires...","Rolling ideas around...","Charging the brainstorm...","Booting the brain...","Dusting off the cortex...","Running mental diagnostics...","Fetching cleverness...","Whisking up notions...","Tuning the idea radio...","Juggling possibilities...","Breathing in inspiration...","Squeezing the thought sponge...","Tickling the gray matter...","Bubbling up insights...","Spicing the soup of thought...","Lacing up hypotheses...","Winding the idea clock...","Casting the net for clues...","Polishing the crystal ball...","Mapping the maze...","Crunching the brain-biscuits...","Cueing the eureka moment...","Summoning the muse...","Knocking on insight’s door...","Combing the noodle...","Sailing the think-ship...","Scooping brain gelato...","Testing wild hunches...","Tick-tocking the neurons...","Planting idea seeds...","Shaking the thought snow globe...","Unlocking the mental toolbox...","Nudging the puzzle pieces...","Lighting the idea bulb...","Preheating the oven of insight...","Mixing the mental trail mix...","Spooling up reasoning reels...","Skimming the mind-palace index...","Surfing the thought waves...","Kicking the tires on ideas...","Rattling the idea can...","Waving the logic wand..."];m.useEffect(()=>{if(typeof window<"u"){const p=localStorage.getItem("arcten-sidebar-expanded");p&&W(JSON.parse(p));const C=localStorage.getItem("arcten-sidebar-width");C&&xt(parseInt(C));const I=localStorage.getItem("arcten-sidebar-height");I&&ft(parseInt(I));const S=localStorage.getItem("arcten-sidebar-detached");S&&Y(JSON.parse(S));const B=localStorage.getItem("arcten-sidebar-position");if(B){const At=JSON.parse(B),pt=50,Pt=Math.max(pt-o,Math.min(At.x,window.innerWidth-pt)),J=Math.max(0,Math.min(At.y,window.innerHeight-pt));kt({x:Pt,y:J})}const O=localStorage.getItem("arcten-sidebar-minimized");O&&st(JSON.parse(O)),sn(!0)}},[]),m.useEffect(()=>((async()=>{try{const C=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:w})});if(!C.ok)throw new Error("Failed to fetch token");const I=await C.json();T(I.clientToken),b.current=I.clientToken,k(I.expiresAt),A(null)}catch(C){A(C instanceof Error?C.message:"Failed to fetch token")}})(),()=>{P.current&&clearTimeout(P.current)}),[y,w]),m.useEffect(()=>{if(!j)return;P.current&&clearTimeout(P.current);const p=Math.floor(Date.now()/1e3),C=j-p,S=Math.max(0,C-5);return console.log(`Token expires at ${new Date(j*1e3).toISOString()}`),console.log(`Scheduling token refresh in ${S} seconds`),P.current=setTimeout(async()=>{console.log("Refreshing token...");try{const B=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:w})});if(!B.ok)throw new Error("Failed to refresh token");const O=await B.json();T(O.clientToken),b.current=O.clientToken,k(O.expiresAt),A(null),console.log("Token refreshed successfully")}catch(B){console.error("Token refresh failed:",B),A(B instanceof Error?B.message:"Failed to refresh token")}},S*1e3),()=>{P.current&&clearTimeout(P.current)}},[j,y,w]),m.useEffect(()=>{(async()=>{if(It.length!==0)try{const C=It.map(S=>({name:S.name,code:S.toString()})),I=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:C})});if(I.ok){const S=await I.json();ea(S.tools)}}catch(C){console.error("Failed to fetch tool descriptions:",C)}})()},[It]),m.useEffect(()=>{Promise.resolve().then(()=>xh).then(p=>{it(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{ta(window.location.pathname)};p(),window.addEventListener("popstate",p);const C=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(C)}},[]);async function $s(){if(!(!w?.id||!x)){Ee(!0);try{const C=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${x}`}})).json();Ns(C.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{Ee(!1)}}}m.useEffect(()=>{w?.id&&x&&$s()},[w,x]);function na(p){const C=Math.floor((Date.now()-p)/1e3);return C<60?"now":C<3600?`${Math.floor(C/60)}m`:C<86400?`${Math.floor(C/3600)}h`:`${Math.floor(C/86400)}d`}function sa(){const p=crypto.randomUUID();cn(p),Ne([]),ke([]),De(!1)}async function ia(p){if(x)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${x}`}}),Ns(ln.filter(C=>C._id!==p)),p===Is&&sa()}catch(C){console.error("Failed to delete conversation:",C)}}async function oa(p){cn(p.chatId),De(!1),Ee(!0);try{const C=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${b.current}`}});if(!C.ok)throw new Error(`Failed to fetch messages: ${C.statusText}`);const S=(await C.json()).messages||[];Ne(S),ke(S)}catch(C){console.error("Failed to load conversation messages:",C);const I=p.messages||[];Ne(I),ke(I)}finally{Ee(!1)}}const ra=async(p,C={})=>{const I=C.headers?new Headers(C.headers):new Headers;return I.delete("user-agent"),I.delete("User-Agent"),fetch(p,{...C,headers:I})},{messages:ue,sendMessage:aa,status:mt,error:zs,stop:Re,addToolResult:de,setMessages:Ne}=lo.useChat({id:Is||void 0,transport:new Ke.DefaultChatTransport({api:`${v}/chat`,fetch:ra,headers:()=>{const p={};return b.current&&(p.Authorization=`Bearer ${b.current}`),p},body:()=>({tools:Ls.map(p=>({name:p.name,description:p.description,inputSchema:p.jsonSchema})),systemPrompt:g,currentRoute:Qr})}),sendAutomaticallyWhen:Ke.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{N&&Yt.current&&Yt.current.focus()},[N,ue]);function la(){W(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function ca(){W(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[N]),m.useEffect(()=>{Xt.current&&Xt.current.scrollIntoView({behavior:"smooth"})},[ue]),m.useEffect(()=>{function p(C){C.key==="Escape"&&(mt==="streaming"||mt==="submitted")&&(C.preventDefault(),Re())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[mt,Re]);function ua(){const p=crypto.randomUUID();cn(p),Ne([]),ke([]),De(!1)}function Us(p){if(p.preventDefault(),!D.trim())return;(mt==="streaming"||mt==="submitted")&&Re();const C=Bs[Math.floor(Math.random()*Bs.length)]||"Thinking...";ct(C),aa({text:D}),R("")}function da(p){const C=p.target.value;R(C)}m.useEffect(()=>{if(!Et)return;function p(I){if(V){const S=I.clientX-G.x,B=I.clientY-G.y;S>=a&&S<=l&&xt(S),B>=400&&B<=1e3&&ft(B)}else{const S=window.innerWidth-I.clientX;S>=a&&S<=l&&xt(S)}}function C(){St(!1),localStorage.setItem("arcten-sidebar-width",U.toString()),localStorage.setItem("arcten-sidebar-height",Tt.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",C)}},[Et,U,Tt,V,G,a,l]);function ha(p){p.preventDefault(),St(!0)}function fa(){Y(!0),st(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function ma(){Y(!1),st(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ws(){st(!L),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!L))}function pa(p){V&&(Ct(!0),Ve({x:p.clientX-G.x,y:p.clientY-G.y}))}return m.useEffect(()=>{if(!V)return;function p(){kt(C=>{const S=window.innerWidth-50,B=window.innerHeight-50,O=50-U,At=0,pt=Math.max(O,Math.min(C.x,S)),Pt=Math.max(At,Math.min(C.y,B));if(pt!==C.x||Pt!==C.y){const J={x:pt,y:Pt};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(J)),J}return C})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[V,U]),m.useEffect(()=>{if(!je)return;function p(I){const S=I.clientX-Rt.x,B=I.clientY-Rt.y,O=50,At=window.innerWidth-O,pt=window.innerHeight-O,Pt=O-U,J=0,gt=Math.max(Pt,Math.min(S,At)),Lt=Math.max(J,Math.min(B,pt));kt({x:gt,y:Lt})}function C(){Ct(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(G))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",C)}},[je,Rt,G,U]),nn?E?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: ",E]})}):x?h.jsx(Nc,{features:uh,children:h.jsx(Be,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:V?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:V?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
43
|
-
${
|
|
42
|
+
💡 Tip: ${i?"The script can only extract types from functions with explicit TypeScript type annotations on parameters.":"Functions with no parameters work fine - just make sure they're used in ArctenAgent or useAgent."}`)}return{name:s,description:e[s].description,jsonSchema:e[s].parameters}})}function mh({toolName:t,description:e,args:n,onApprove:s,onDeny:i}){const r=Object.keys(n).length>0;return h.jsx("div",{className:"bg-stone-100 dark:bg-stone-800 border border-border rounded-lg px-3 py-2.5 my-1.5",children:h.jsxs("div",{className:"flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"flex items-center gap-1.5 mb-1",children:h.jsx("span",{className:"text-sm font-medium text-foreground",children:t})}),r&&h.jsx("div",{className:"space-y-0.5 mb-1.5",children:Object.entries(n).map(([o,a])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[o,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof a=="string"?a:JSON.stringify(a)})]},o))})]}),h.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[h.jsxs(Ge,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs",onClick:s,children:[h.jsx(G.Check,{className:"h-3 w-3 mr-1"}),"Approve"]}),h.jsx(Ge,{size:"sm",variant:"ghost",className:"h-6 px-2 text-xs text-muted-foreground",onClick:i,children:h.jsx(G.X,{className:"h-3 w-3"})})]})]})})}function ph({toolName:t,args:e,isDenied:n,isSafe:s}){const[i,r]=m.useState(!1);if(t==="fetchDocContent")return null;const o=["k","maxResults","_organizationId"];t==="searchDocs"&&o.push("filters");const a=Object.fromEntries(Object.entries(e).filter(([u])=>!o.includes(u))),l=Object.keys(a).length>0;return h.jsxs("div",{className:"my-1",children:[h.jsxs("button",{onClick:()=>l&&r(!i),className:`inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors ${n?"bg-red-100 dark:bg-red-950/30 text-red-700 dark:text-red-400":"bg-green-100 dark:bg-green-950/30 text-green-700 dark:text-green-400"} ${l?"cursor-pointer hover:bg-opacity-80":""}`,children:[l&&h.jsx("span",{className:"transition-transform duration-200",children:i?h.jsx(G.ChevronDown,{className:"h-3 w-3"}):h.jsx(G.ChevronRight,{className:"h-3 w-3"})}),n?h.jsx(G.X,{className:"h-3 w-3"}):s?h.jsx(G.Zap,{className:"h-3 w-3"}):h.jsx(G.Check,{className:"h-3 w-3"}),h.jsxs("span",{className:"font-medium",children:[n?"Denied":s?"Auto-executed":"Executed"," ",t]})]}),i&&l&&h.jsx("div",{className:"mt-1 ml-6 p-2 bg-stone-50 dark:bg-stone-900 rounded-md border border-border",children:h.jsx("div",{className:"space-y-0.5",children:Object.entries(a).map(([u,c])=>h.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[h.jsxs("span",{className:"text-muted-foreground min-w-[60px]",children:[u,":"]}),h.jsx("span",{className:"font-mono text-foreground",children:typeof c=="string"?c:JSON.stringify(c)})]},u))})})]})}function gh({...t}){return h.jsx(Zn.Root,{"data-slot":"collapsible",...t})}function yh({...t}){return h.jsx(Zn.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...t})}function xh({...t}){return h.jsx(Zn.CollapsibleContent,{"data-slot":"collapsible-content",...t})}const vh=m.lazy(()=>import("streamdown").then(t=>({default:t.Streamdown}))),Rs=m.memo(({className:t,...e})=>typeof window>"u"?null:h.jsx(m.Suspense,{fallback:null,children:h.jsx(vh,{className:J("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",t),...e})}),(t,e)=>t.children===e.children);Rs.displayName="Response";const bh=Object.freeze(Object.defineProperty({__proto__:null,Response:Rs},Symbol.toStringTag,{value:"Module"})),wh=({children:t,as:e="p",className:n,duration:s=2,spread:i=2})=>{const r=dh.create(e),o=m.useMemo(()=>(t?.length??0)*i,[t,i]);return h.jsx(r,{animate:{backgroundPosition:"0% center"},className:J("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${o}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:Number.POSITIVE_INFINITY,duration:s,ease:"linear"},children:t})},Th=m.memo(wh),Zr=m.createContext(null),Sh=()=>{const t=m.useContext(Zr);if(!t)throw new Error("Reasoning components must be used within Reasoning");return t},Ch=1e3,Ah=1e3,Jr=m.memo(({className:t,isStreaming:e=!1,open:n,defaultOpen:s=!0,onOpenChange:i,duration:r,children:o,...a})=>{const[l,u]=Xs.useControllableState({prop:n,defaultProp:s,onChange:i}),[c,d]=Xs.useControllableState({prop:r,defaultProp:0}),[f,g]=m.useState(!1),[y,v]=m.useState(null);m.useEffect(()=>{e?y===null&&v(Date.now()):y!==null&&(d(Math.ceil((Date.now()-y)/Ah)),v(null))},[e,y,d]),m.useEffect(()=>{if(s&&!e&&l&&!f){const x=setTimeout(()=>{u(!1),g(!0)},Ch);return()=>clearTimeout(x)}},[e,l,s,u,f]);const w=x=>{u(x)};return h.jsx(Zr.Provider,{value:{isStreaming:e,isOpen:l,setIsOpen:u,duration:c},children:h.jsx(gh,{className:J("not-prose mb-4",t),onOpenChange:w,open:l,...a,children:o})})}),Ph=(t,e)=>t||e===0?h.jsx(Th,{duration:1,children:"Thinking..."}):e===void 0?h.jsx("p",{children:"Thought for a few seconds"}):h.jsxs("p",{children:["Thought for ",e," seconds"]}),Qr=m.memo(({className:t,children:e,...n})=>{const{isStreaming:s,isOpen:i,duration:r}=Sh();return h.jsx(yh,{className:J("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",t),...n,children:e??h.jsxs(h.Fragment,{children:[h.jsx(G.BrainIcon,{className:"size-4"}),Ph(s,r),h.jsx(G.ChevronDownIcon,{className:J("size-4 transition-transform",i?"rotate-180":"rotate-0")})]})})}),ta=m.memo(({className:t,children:e,...n})=>h.jsx(xh,{className:J("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(Rs,{className:"grid gap-2",children:e})}));Jr.displayName="Reasoning";Qr.displayName="ReasoningTrigger";ta.displayName="ReasoningContent";function Mh({theme:t="auto",layout:e="sidebar",model:n="auto",animated:s=!0,title:i="Chat",logo:r=void 0,defaultWidth:o=384,minWidth:a=300,maxWidth:l=800,initiallyExpanded:u=!1,tools:c=[],safeTools:d=[],toolMetadata:f,systemPrompt:g="",tokenEndpoint:y="/api/arcten/token",apiBaseUrl:v="https://api.arcten.com",user:w}){const[x,S]=m.useState(null),b=m.useRef(null),[k,A]=m.useState(null),[D,R]=m.useState(null),P=m.useRef(null),[N,_]=m.useState(u),[z,vt]=m.useState(o),[St,st]=m.useState(600),[Ct,At]=m.useState(!1),[E,Y]=m.useState(!1),[K,it]=m.useState(!1),[U,ue]=m.useState({x:100,y:100}),[Xt,kt]=m.useState(!1),[de,Rt]=m.useState({x:0,y:0}),[he,rn]=m.useState(!1),fe=m.useRef(null),Yt=m.useRef(null),[Nt,me]=m.useState(""),[V,j]=m.useState(null),[H,ot]=m.useState("Thinking..."),[q,rt]=m.useState(new Set),[ea,na]=m.useState(""),[It,sa]=m.useState([]),[an,Ns]=m.useState(!1),[ln,Is]=m.useState([]),[Ls,cn]=m.useState(()=>typeof window<"u"?crypto.randomUUID():null),[Gt,Re]=m.useState(!1),[Vh,Ne]=m.useState(!1),[Dh,Ie]=m.useState([]),mt=m.useMemo(()=>[...c,...d],[c,d]),Os=m.useMemo(()=>qr(mt,f),[mt,f]),Fs=m.useMemo(()=>new Set(mt.map(p=>p.name)),[mt]),un=m.useMemo(()=>Os.filter(p=>Fs.has(p.name)),[Os,Fs]),Bs=m.useMemo(()=>{const p=new Map;return mt.forEach(T=>p.set(T.name,T)),p},[mt]),$s=m.useMemo(()=>new Set(d.map(p=>p.name)),[d]),zs=["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&&_(JSON.parse(p));const T=localStorage.getItem("arcten-sidebar-width");T&&vt(parseInt(T));const I=localStorage.getItem("arcten-sidebar-height");I&&st(parseInt(I));const C=localStorage.getItem("arcten-sidebar-detached");C&&Y(JSON.parse(C));const F=localStorage.getItem("arcten-sidebar-position");if(F){const Pt=JSON.parse(F),gt=50,Mt=Math.max(gt-o,Math.min(Pt.x,window.innerWidth-gt)),Q=Math.max(0,Math.min(Pt.y,window.innerHeight-gt));ue({x:Mt,y:Q})}const L=localStorage.getItem("arcten-sidebar-minimized");L&&it(JSON.parse(L)),rn(!0)}},[]),m.useEffect(()=>((async()=>{try{const T=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:w})});if(!T.ok)throw new Error("Failed to fetch token");const I=await T.json();S(I.clientToken),b.current=I.clientToken,R(I.expiresAt),A(null)}catch(T){A(T instanceof Error?T.message:"Failed to fetch token")}})(),()=>{P.current&&clearTimeout(P.current)}),[y,w]),m.useEffect(()=>{if(!D)return;P.current&&clearTimeout(P.current);const p=Math.floor(Date.now()/1e3),T=D-p,C=Math.max(0,T-5);return console.log(`Token expires at ${new Date(D*1e3).toISOString()}`),console.log(`Scheduling token refresh in ${C} seconds`),P.current=setTimeout(async()=>{console.log("Refreshing token...");try{const F=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:w})});if(!F.ok)throw new Error("Failed to refresh token");const L=await F.json();S(L.clientToken),b.current=L.clientToken,R(L.expiresAt),A(null),console.log("Token refreshed successfully")}catch(F){console.error("Token refresh failed:",F),A(F instanceof Error?F.message:"Failed to refresh token")}},C*1e3),()=>{P.current&&clearTimeout(P.current)}},[D,y,w]),m.useEffect(()=>{(async()=>{if(mt.length!==0)try{const T=mt.map(C=>({name:C.name,code:C.toString()})),I=await fetch(`${v}/tools/describe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tools:T})});if(I.ok){const C=await I.json();sa(C.tools)}}catch(T){console.error("Failed to fetch tool descriptions:",T)}})()},[mt]),m.useEffect(()=>{Promise.resolve().then(()=>bh).then(p=>{j(()=>p.Response)})},[]),m.useEffect(()=>{const p=()=>{na(window.location.pathname)};p(),window.addEventListener("popstate",p);const T=setInterval(p,500);return()=>{window.removeEventListener("popstate",p),clearInterval(T)}},[]);async function Us(){if(!(!w?.id||!x)){Ne(!0);try{const T=await(await fetch(`${v}/conversations`,{headers:{Authorization:`Bearer ${x}`}})).json();Is(T.conversations||[])}catch(p){console.error("Failed to fetch conversations:",p)}finally{Ne(!1)}}}m.useEffect(()=>{w?.id&&x&&Us()},[w,x]);function ia(p){const T=Math.floor((Date.now()-p)/1e3);return T<60?"now":T<3600?`${Math.floor(T/60)}m`:T<86400?`${Math.floor(T/3600)}h`:`${Math.floor(T/86400)}d`}function oa(){const p=crypto.randomUUID();cn(p),Oe([]),Ie([]),Re(!1)}async function ra(p){if(x)try{await fetch(`${v}/conversations/${p}`,{method:"DELETE",headers:{Authorization:`Bearer ${x}`}}),Is(ln.filter(T=>T._id!==p)),p===Ls&&oa()}catch(T){console.error("Failed to delete conversation:",T)}}async function aa(p){cn(p.chatId),Re(!1),Ne(!0);try{const T=await fetch(`${v}/conversations/${p.chatId}/messages`,{headers:{Authorization:`Bearer ${b.current}`}});if(!T.ok)throw new Error(`Failed to fetch messages: ${T.statusText}`);const C=(await T.json()).messages||[];Oe(C),Ie(C)}catch(T){console.error("Failed to load conversation messages:",T);const I=p.messages||[];Oe(I),Ie(I)}finally{Ne(!1)}}const la=async(p,T={})=>{const I=T.headers?new Headers(T.headers):new Headers;return I.delete("user-agent"),I.delete("User-Agent"),fetch(p,{...T,headers:I})},{messages:pe,sendMessage:ca,status:pt,error:_s,stop:Le,addToolResult:ge,setMessages:Oe}=uo.useChat({id:Ls||void 0,transport:new Ye.DefaultChatTransport({api:`${v}/chat`,fetch:la,headers:()=>{const p={};return b.current&&(p.Authorization=`Bearer ${b.current}`),p},body:()=>{const p=un.map(T=>({name:T.name,description:T.description,inputSchema:T.jsonSchema}));return process.env.NODE_ENV==="development"&&console.log("[ArctenAgent] Sending tools to API:",{totalTools:p.length,toolNames:p.map(T=>T.name),allToolNames:mt.map(T=>T.name),filteredToolNames:un.map(T=>T.name)}),{tools:p,systemPrompt:g,currentRoute:ea}}}),sendAutomaticallyWhen:Ye.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{N&&Yt.current&&Yt.current.focus()},[N,pe]);function ua(){_(!0),localStorage.setItem("arcten-sidebar-expanded","true")}function da(){_(!1),localStorage.setItem("arcten-sidebar-expanded","false")}m.useEffect(()=>{},[N]),m.useEffect(()=>{fe.current&&fe.current.scrollIntoView({behavior:"smooth"})},[pe]),m.useEffect(()=>{function p(T){T.key==="Escape"&&(pt==="streaming"||pt==="submitted")&&(T.preventDefault(),Le())}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[pt,Le]);function ha(){const p=crypto.randomUUID();cn(p),Oe([]),Ie([]),Re(!1)}function Ws(p){if(p.preventDefault(),!Nt.trim())return;(pt==="streaming"||pt==="submitted")&&Le();const T=zs[Math.floor(Math.random()*zs.length)]||"Thinking...";ot(T),ca({text:Nt}),me("")}function fa(p){const T=p.target.value;me(T)}m.useEffect(()=>{if(!Ct)return;function p(I){if(E){const C=I.clientX-U.x,F=I.clientY-U.y;C>=a&&C<=l&&vt(C),F>=400&&F<=1e3&&st(F)}else{const C=window.innerWidth-I.clientX;C>=a&&C<=l&&vt(C)}}function T(){At(!1),localStorage.setItem("arcten-sidebar-width",z.toString()),localStorage.setItem("arcten-sidebar-height",St.toString())}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",T)}},[Ct,z,St,E,U,a,l]);function ma(p){p.preventDefault(),At(!0)}function pa(){Y(!0),it(!1),localStorage.setItem("arcten-sidebar-detached","true"),localStorage.setItem("arcten-sidebar-minimized","false")}function ga(){Y(!1),it(!1),localStorage.setItem("arcten-sidebar-detached","false"),localStorage.setItem("arcten-sidebar-minimized","false")}function Ks(){it(!K),localStorage.setItem("arcten-sidebar-minimized",JSON.stringify(!K))}function ya(p){E&&(kt(!0),Rt({x:p.clientX-U.x,y:p.clientY-U.y}))}return m.useEffect(()=>{if(!E)return;function p(){ue(T=>{const C=window.innerWidth-50,F=window.innerHeight-50,L=50-z,Pt=0,gt=Math.max(L,Math.min(T.x,C)),Mt=Math.max(Pt,Math.min(T.y,F));if(gt!==T.x||Mt!==T.y){const Q={x:gt,y:Mt};return localStorage.setItem("arcten-sidebar-position",JSON.stringify(Q)),Q}return T})}return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)},[E,z]),m.useEffect(()=>{if(!Xt)return;function p(I){const C=I.clientX-de.x,F=I.clientY-de.y,L=50,Pt=window.innerWidth-L,gt=window.innerHeight-L,Mt=L-z,Q=0,yt=Math.max(Mt,Math.min(C,Pt)),Lt=Math.max(Q,Math.min(F,gt));ue({x:yt,y:Lt})}function T(){kt(!1),localStorage.setItem("arcten-sidebar-position",JSON.stringify(U))}return window.addEventListener("mousemove",p),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",T)}},[Xt,de,U,z]),he?k?h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsxs("div",{className:"p-4 bg-destructive/10 text-destructive text-sm rounded-lg",children:["Authentication error: ",k]})}):x?h.jsx(Lc,{features:hh,children:h.jsx(Ue,{id:"arcten-sidebar","data-theme":t,"data-layout":e,"data-model":n,initial:E?{opacity:0,scale:.95,filter:"blur(4px)"}:!1,animate:E?{opacity:1,scale:1,filter:"blur(0px)"}:{},transition:{duration:.2,ease:"easeOut"},className:`
|
|
43
|
+
${E?"fixed z-50 shadow-xl rounded-xl":"h-screen flex-shrink-0 relative rounded-l-2xl"}
|
|
44
44
|
${N?"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"}
|
|
45
|
-
${
|
|
45
|
+
${E?"border border-border":"border-l border-border"}
|
|
46
46
|
${N?"":"w-[30px]"}
|
|
47
|
-
`,style:N?V?{width:`${U}px`,height:L?"auto":`${Tt}px`,left:`${G.x}px`,top:`${G.y}px`}:{width:`${U}px`}:void 0,onClick:N?void 0:la,children:N?h.jsxs(h.Fragment,{children:[!V&&h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-500/40 hover:w-1 transition-all group",onMouseDown:ha,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),V&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",onMouseDown:p=>{p.preventDefault(),St(!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(),Ct(!0),Ve({x:p.clientX-G.x,y:p.clientY-G.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(),St(!0)}})]}),h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:`flex items-center justify-between p-3 border-b border-border ${V?"cursor-move":""}`,onMouseDown:V?pa:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${V&&L?"cursor-pointer":""}`,onClick:V&&L?p=>{p.stopPropagation(),Ws()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:Z(zt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:ua,"aria-label":"New chat",children:h.jsx(X.Plus,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:"Start a new conversation"})]}),h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:Z(zt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:V?ma:fa,"aria-label":V?"Dock sidebar":"Float sidebar",children:V?h.jsx(X.Dock,{className:"h-4 w-4"}):h.jsx(X.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:V?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:Z(zt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:V?Ws:ca,"aria-label":V?L?"Maximize":"Minimize":"Close sidebar",children:V?L?h.jsx(X.Maximize2,{className:"h-4 w-4"}):h.jsx(X.Minimize2,{className:"h-4 w-4"}):h.jsx(X.X,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:V?L?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!L&&h.jsxs(h.Fragment,{children:[w&&ln.length>0&&h.jsxs("div",{className:`border-b border-border ${Gt?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(He,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Gt||$s(),De(!Gt)},children:Gt?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Gt?"flex-1 overflow-y-auto":""}`,children:ln.slice(0,Gt?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:Z(zt({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>oa(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:na(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:C=>{C.stopPropagation(),ia(p._id)},"aria-label":"Delete conversation",children:h.jsx(X.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:ue.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[r&&h.jsx("div",{className:"mb-6",children:r}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),Nt.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:[(an?Nt:Nt.slice(0,10)).map(p=>h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(un,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{R(p.sampleUsage),Yt.current?.focus()},children:p.friendlyName})}),h.jsx(Bt,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:p.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',p.sampleUsage,'"']}),p.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",p.params.join(", ")]})]})})]},p.name)),Nt.length>10&&!an&&h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsxs(un,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Rs(!0),children:["+",Nt.length-10," more"]})}),h.jsx(Bt,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),h.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:Nt.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"})]})})]}),an&&Nt.length>10&&h.jsx(un,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Rs(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[ue.map(p=>{const I=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(dh,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:I}):h.jsx("div",{className:"space-y-2",children:p.parts.map((S,B)=>{if(S.type?.startsWith("tool-")){const O=S.type?.replace("tool-","")||"",At=Ls.find(J=>J.name===O),pt=S.state==="input-available",Pt=S.state==="output-available";if(pt)return Fs.has(O)?((async()=>{if(on.has(S.toolCallId))return;rn(Lt=>new Set(Lt).add(S.toolCallId));const gt=Os.get(O);if(gt)try{console.log("Auto-executing safe tool:",O);const Lt=await gt(...Object.values(S.input||{}));de({toolCallId:S.toolCallId,tool:O,output:Lt}),console.log("Safe tool result added:",S.toolCallId)}catch(Lt){de({toolCallId:S.toolCallId,tool:O,output:`Error: ${Lt}`}),console.log("Safe tool error result added:",S.toolCallId)}})(),null):h.jsx(Be,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(hh,{toolName:O,description:At?.description||"",args:S.input||{},onApprove:async()=>{if(on.has(S.toolCallId)){console.log("Tool call already being processed:",S.toolCallId);return}rn(gt=>new Set(gt).add(S.toolCallId));const J=Os.get(O);if(J)try{const gt=await J(...Object.values(S.input||{}));de({toolCallId:S.toolCallId,tool:O,output:gt}),console.log("Tool result added:",S.toolCallId)}catch(gt){de({toolCallId:S.toolCallId,tool:O,output:`Error: ${gt}`}),console.log("Tool error result added:",S.toolCallId)}},onDeny:async()=>{if(on.has(S.toolCallId)){console.log("Tool call already being processed:",S.toolCallId);return}rn(J=>new Set(J).add(S.toolCallId)),de({toolCallId:S.toolCallId,tool:O,output:"User denied tool execution"}),console.log("Tool denied:",S.toolCallId)}})},`${S.toolCallId}-${B}`);if(Pt){const J=S.output==="User denied tool execution";return h.jsx(fh,{toolName:O,args:S.input||{},isDenied:J,isSafe:Fs.has(O)},`${S.toolCallId}-${B}`)}return null}return S.type==="text"&&S.text&&_?h.jsx(_,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:S.text},`${p.id}-${B}`):S.type==="reasoning"&&S.text?h.jsxs(qr,{className:"w-full",isStreaming:mt==="streaming"&&B===p.parts.length-1&&p.id===ue.at(-1)?.id,children:[h.jsx(Zr,{}),h.jsx(Jr,{children:S.text})]},`${p.id}-${B}`):null})})})},p.id)}),h.jsx("div",{ref:Xt})]})}),zs&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",zs.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Rc,{mode:"wait",children:(mt==="streaming"||mt==="submitted")&&h.jsxs(Be,{initial:{opacity:0,filter:"blur(4px)",y:5},animate:{opacity:1,filter:"blur(0px)",y:0},exit:{opacity:0,filter:"blur(4px)",y:5},transition:{duration:.2,ease:"easeOut"},className:"absolute left-1/2 -translate-x-1/2 -top-6 flex items-center gap-1.5 bg-stone-100 dark:bg-stone-800 px-3 py-1.5 rounded-full shadow-lg border border-border z-50",children:[h.jsx(Be,{className:"w-2 h-2 bg-stone-400 dark:bg-stone-600",animate:{rotate:[0,0,90,90],borderRadius:["50%","30%","30%","50%"],scale:[.75,1,1,.75]},transition:{duration:2,repeat:1/0,ease:"easeInOut",times:[0,.4,.6,1]}}),h.jsx("p",{className:"text-xs text-muted-foreground",children:tt})]})}),h.jsxs("form",{onSubmit:Us,className:"relative",children:[h.jsx(ho,{ref:Yt,value:D,onChange:da,placeholder:"Ask anything..",className:"w-full pr-12 resize-none border border-border rounded-xl px-4 py-3",minHeight:24,maxHeight:200,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),Us(p))}}),mt==="streaming"||mt==="submitted"?h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:Z(zt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Re,children:h.jsx(X.Square,{className:"h-4 w-4"})})}),h.jsxs(Bt,{children:[h.jsx(Hs,{children:"Escape"})," to stop"]})]}):h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"submit",className:Z(zt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!D.trim(),children:h.jsx(X.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(Bt,{children:[h.jsx(Hs,{children:"Enter"})," to send"]})]})]})]})]}),h.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all overflow-hidden",children:[h.jsx("span",{className:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(X.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 Ph({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:r=[],safeTools:o=[],toolMetadata:a,systemPrompt:l="",initialMessages:u=[],conversationId:c,onToolCall:d,onFinish:f,ragFilters:g}={}){console.log("[useAgent] Hook initialized",{apiBaseUrl:t,tokenEndpoint:e,hasProvidedToken:!!n,skipTokenFetch:s,userId:i?.id,toolsCount:r.length,safeToolsCount:o.length});const[y,v]=m.useState(n||null),w=m.useRef(n||null),[x,T]=m.useState(null),[b,E]=m.useState(null),A=m.useRef(null),[j,k]=m.useState([]),[P,N]=m.useState(c||(typeof window<"u"?crypto.randomUUID():null)),[W,U]=m.useState(!1),[xt,Tt]=m.useState(new Set),ft=m.useMemo(()=>[...r,...o],[r,o]),Et=m.useMemo(()=>Yr(ft,a),[ft,a]),St=m.useMemo(()=>{const D=new Map;return ft.forEach(R=>D.set(R.name,R)),D},[ft]),V=m.useMemo(()=>new Set(o.map(D=>D.name)),[o]);m.useEffect(()=>{if(console.log("[useAgent] Token fetch effect running",{skipTokenFetch:s,hasProvidedToken:!!n,user:i?.id,tokenEndpoint:e}),s||n){console.log("[useAgent] Skipping token fetch",{reason:s?"skipTokenFetch=true":"token provided"});return}return(async()=>{console.log("[useAgent] Fetching initial token from",e);try{const R=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!R.ok)throw new Error("Failed to fetch token");const _=await R.json();console.log("[useAgent] Token fetched successfully",{expiresAt:_.expiresAt,expiresIn:_.expiresAt?`${_.expiresAt-Math.floor(Date.now()/1e3)}s`:"unknown"}),v(_.clientToken),w.current=_.clientToken,E(_.expiresAt),T(null)}catch(R){console.error("[useAgent] Token fetch failed:",R),T(R instanceof Error?R.message:"Failed to fetch token")}})(),()=>{console.log("[useAgent] Cleaning up token fetch effect"),A.current&&clearTimeout(A.current)}},[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(console.log("[useAgent] Token refresh effect running",{hasTokenExpiresAt:!!b,tokenExpiresAt:b,skipTokenFetch:s,hasProvidedToken:!!n}),!b||s||n){console.log("[useAgent] Skipping token refresh setup",{reason:b?s?"skipTokenFetch=true":"token provided":"no expiry"});return}A.current&&(console.log("[useAgent] Clearing existing token refresh timeout"),clearTimeout(A.current));const D=Math.floor(Date.now()/1e3),R=b-D,it=Math.max(0,R-5);return console.log("[useAgent] Scheduling token refresh",{expiresAt:b,now:D,timeUntilExpiry:`${R}s`,timeUntilRefresh:`${it}s`,refreshAt:new Date((D+it)*1e3).toISOString()}),A.current=setTimeout(async()=>{console.log("[useAgent] Refreshing token...");try{const tt=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!tt.ok)throw new Error("Failed to refresh token");const ct=await tt.json();console.log("[useAgent] Token refreshed successfully",{newExpiresAt:ct.expiresAt,expiresIn:`${ct.expiresAt-Math.floor(Date.now()/1e3)}s`}),v(ct.clientToken),w.current=ct.clientToken,E(ct.expiresAt),T(null)}catch(tt){console.error("[useAgent] Token refresh failed:",tt),T(tt instanceof Error?tt.message:"Failed to refresh token")}},it*1e3),()=>{console.log("[useAgent] Cleaning up token refresh effect"),A.current&&clearTimeout(A.current)}},[b,e,JSON.stringify(i),s,n]);const Y=async(D,R={})=>{const _=R.headers?new Headers(R.headers):new Headers;return _.delete("user-agent"),_.delete("User-Agent"),fetch(D,{...R,headers:_})},{messages:L,sendMessage:st,status:G,error:kt,stop:je,addToolResult:Ct,setMessages:Rt}=lo.useChat({id:P||void 0,messages:u,transport:new Ke.DefaultChatTransport({api:`${t}/chat`,fetch:Y,headers:()=>{const D={};return w.current&&(D.Authorization=`Bearer ${w.current}`),D},body:()=>({tools:Et.map(D=>({name:D.name,description:D.description,inputSchema:D.jsonSchema})),systemPrompt:l,...g&&{ragFilters:g}})}),sendAutomaticallyWhen:Ke.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{L.forEach(D=>{D.role==="assistant"&&D.parts.forEach(R=>{if(!R.type?.startsWith("tool-")||R.state!=="input-available")return;const _=R.type.replace("tool-",""),it=R.toolCallId;if(!xt.has(it)){if(Tt(tt=>new Set(tt).add(it)),V.has(_)){const tt=St.get(_);tt&&(async()=>{try{const ct=await tt(...Object.values(R.input||{}));Ct({toolCallId:it,tool:_,output:ct})}catch(ct){Ct({toolCallId:it,tool:_,output:`Error: ${ct}`})}})()}else if(d){const tt={toolCallId:it,toolName:_,args:R.input||{}};d({toolCall:tt})}}})})},[L,V,St,d,Ct,xt]),m.useEffect(()=>{if(G==="ready"&&L.length>0&&f){const D=L[L.length-1];D&&D.role==="assistant"&&f({message:D,messages:L,isAbort:!1,isDisconnect:!1,isError:!!kt})}},[G,L,kt,f]);async function Ve(){if(!(!i?.id||!y)){console.log("[useAgent] Fetching conversations for user:",i?.id),U(!0);try{const R=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${y}`}})).json();k(R.conversations||[])}catch(D){console.error("Failed to fetch conversations:",D)}finally{U(!1)}}}m.useEffect(()=>{i?.id&&y&&Ve()},[JSON.stringify(i),y,t]);async function nn(D){N(D),U(!0);try{const R=await fetch(`${t}/conversations/${D}/messages`,{headers:{Authorization:`Bearer ${w.current}`}});if(!R.ok)throw new Error(`Failed to fetch messages: ${R.statusText}`);const it=(await R.json()).messages||[];Rt(it)}catch(R){console.error("Failed to load conversation messages:",R)}finally{U(!1)}}async function sn(D){if(y)try{await fetch(`${t}/conversations/${D}`,{method:"DELETE",headers:{Authorization:`Bearer ${y}`}}),k(j.filter(R=>R._id!==D)),D===P&&Xt()}catch(R){console.error("Failed to delete conversation:",R)}}function Xt(){const D=crypto.randomUUID();N(D),Rt([]),Tt(new Set)}function Yt(D){Ct(D)}return{id:P,messages:L,status:G,error:kt,sendMessage:st,stop:je,addToolOutput:Yt,setMessages:Rt,conversations:j,loadConversation:nn,deleteConversation:sn,startNewConversation:Xt,isLoadingConversations:W,clientToken:y,tokenError:x}}exports.verifyToken=Ma.verifyToken;exports.ArctenAgent=Ah;exports.useAgent=Ph;
|
|
47
|
+
`,style:N?E?{width:`${z}px`,height:K?"auto":`${St}px`,left:`${U.x}px`,top:`${U.y}px`}:{width:`${z}px`}:void 0,onClick:N?void 0:ua,children:N?h.jsxs(h.Fragment,{children:[!E&&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:ma,children:h.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-3 -translate-x-1"})}),E&&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(),At(!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(),kt(!0),Rt({x:p.clientX-U.x,y:p.clientY-U.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(),At(!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 ${E?"cursor-move":""}`,onMouseDown:E?ya:void 0,children:[h.jsx("h2",{className:`text-base font-semibold ${E&&K?"cursor-pointer":""}`,onClick:E&&K?p=>{p.stopPropagation(),Ks()}:void 0,children:i}),h.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:J(zt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:ha,"aria-label":"New chat",children:h.jsx(G.Plus,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:"Start a new conversation"})]}),h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:J(zt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:E?ga:pa,"aria-label":E?"Dock sidebar":"Float sidebar",children:E?h.jsx(G.Dock,{className:"h-4 w-4"}):h.jsx(G.PictureInPicture2,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:E?"Dock to sidebar":"Undock to floating window"})]}),h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:J(zt({variant:"ghost",size:"icon"}),"h-8 w-8"),onClick:E?Ks:da,"aria-label":E?K?"Maximize":"Minimize":"Close sidebar",children:E?K?h.jsx(G.Maximize2,{className:"h-4 w-4"}):h.jsx(G.Minimize2,{className:"h-4 w-4"}):h.jsx(G.X,{className:"h-4 w-4"})})}),h.jsx(Bt,{children:E?K?"Maximize window":"Minimize to header":"Close the chat"})]})]})]}),!K&&h.jsxs(h.Fragment,{children:[w&&ln.length>0&&h.jsxs("div",{className:`border-b border-border ${Gt?"flex flex-col flex-1":""}`,children:[h.jsxs("div",{className:"flex items-center justify-between px-3 py-1",children:[h.jsx("h3",{className:"text-xs font-semibold text-muted-foreground",children:"Recent chats"}),h.jsx(Ge,{variant:"ghost",className:"h-auto px-2 py-1 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{Gt||Us(),Re(!Gt)},children:Gt?"Show less":"View all"})]}),h.jsx("div",{className:`px-2 pb-2 space-y-0.5 ${Gt?"flex-1 overflow-y-auto":""}`,children:ln.slice(0,Gt?void 0:3).map(p=>h.jsxs("div",{className:"group relative",children:[h.jsxs("button",{type:"button",className:J(zt({variant:"ghost"}),"w-full justify-between h-auto py-1 px-3 font-normal"),onClick:()=>aa(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:ia(p.updatedAt)})})]}),h.jsx("button",{type:"button",className:"absolute right-2 top-1/2 -translate-y-1/2 h-6 w-6 p-0 hidden group-hover:flex items-center justify-center text-muted-foreground hover:text-foreground rounded-md hover:bg-accent transition-colors",onClick:T=>{T.stopPropagation(),ra(p._id)},"aria-label":"Delete conversation",children:h.jsx(G.X,{className:"h-3 w-3"})})]},p._id))})]}),h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[h.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 scroll-smooth",children:pe.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[r&&h.jsx("div",{className:"mb-6",children:r}),h.jsx("h3",{className:"text-lg font-semibold text-center mb-2",children:"How can I help you?"}),It.length>0&&h.jsx("div",{className:"mt-4 px-4 max-w-md mx-auto",children:h.jsxs("div",{className:"flex flex-wrap gap-2 justify-center",children:[(an?It:It.slice(0,10)).map(p=>h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx(dn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>{me(p.sampleUsage),Yt.current?.focus()},children:p.friendlyName})}),h.jsx(Bt,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium",children:p.description}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[h.jsx("span",{className:"font-medium",children:"Example:"}),' "',p.sampleUsage,'"']}),p.paramCount>0&&h.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[h.jsx("span",{className:"font-medium",children:"Parameters:"})," ",p.params.join(", ")]})]})})]},p.name)),It.length>10&&!an&&h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsxs(dn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Ns(!0),children:["+",It.length-10," more"]})}),h.jsx(Bt,{children:h.jsxs("div",{className:"max-w-xs",children:[h.jsx("p",{className:"font-medium mb-2",children:"Additional tools:"}),h.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto pr-2",children:It.slice(10).map(p=>h.jsxs("div",{children:[h.jsxs("span",{className:"font-medium text-xs",children:[p.friendlyName,":"]}),h.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:p.description})]},p.name))}),h.jsx("p",{className:"text-xs text-muted-foreground mt-2 italic",children:"Click to show all tools"})]})})]}),an&&It.length>10&&h.jsx(dn,{variant:"secondary",className:"cursor-pointer text-xs px-2 py-1 hover:bg-stone-200 dark:hover:bg-stone-700 transition-colors",onClick:()=>Ns(!1),children:"Show less"})]})})]}):h.jsxs(h.Fragment,{children:[pe.map(p=>{const I=p.parts.filter(C=>C.type==="text").map(C=>C.text).join("");return h.jsx("div",{className:`${p.role==="user"?"flex justify-end":"w-full"}`,children:h.jsx("div",{className:`${p.role==="user"?"max-w-[85%] text-right":"w-full"}`,children:p.role==="user"?h.jsx(fh,{initial:{opacity:0,filter:"blur(4px)"},animate:{opacity:1,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},className:"text-sm whitespace-pre-wrap inline-block bg-stone-100 dark:bg-stone-800 px-3 py-2 rounded-xl",children:I}):h.jsx("div",{className:"space-y-2",children:p.parts.map((C,F)=>{if(C.type?.startsWith("tool-")){const L=C.type?.replace("tool-","")||"",Pt=un.find(Q=>Q.name===L),gt=C.state==="input-available",Mt=C.state==="output-available";if(gt)return $s.has(L)?((async()=>{if(q.has(C.toolCallId))return;rt(Lt=>new Set(Lt).add(C.toolCallId));const yt=Bs.get(L);if(yt)try{console.log("Auto-executing safe tool:",L);const Lt=await yt(...Object.values(C.input||{}));ge({toolCallId:C.toolCallId,tool:L,output:Lt}),console.log("Safe tool result added:",C.toolCallId)}catch(Lt){ge({toolCallId:C.toolCallId,tool:L,output:`Error: ${Lt}`}),console.log("Safe tool error result added:",C.toolCallId)}})(),null):h.jsx(Ue,{initial:{opacity:0,y:10,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{duration:.3,ease:"easeOut"},children:h.jsx(mh,{toolName:L,description:Pt?.description||"",args:C.input||{},onApprove:async()=>{if(q.has(C.toolCallId)){console.log("Tool call already being processed:",C.toolCallId);return}rt(yt=>new Set(yt).add(C.toolCallId));const Q=Bs.get(L);if(Q)try{const yt=await Q(...Object.values(C.input||{}));ge({toolCallId:C.toolCallId,tool:L,output:yt}),console.log("Tool result added:",C.toolCallId)}catch(yt){ge({toolCallId:C.toolCallId,tool:L,output:`Error: ${yt}`}),console.log("Tool error result added:",C.toolCallId)}},onDeny:async()=>{if(q.has(C.toolCallId)){console.log("Tool call already being processed:",C.toolCallId);return}rt(Q=>new Set(Q).add(C.toolCallId)),ge({toolCallId:C.toolCallId,tool:L,output:"User denied tool execution"}),console.log("Tool denied:",C.toolCallId)}})},`${C.toolCallId}-${F}`);if(Mt){const Q=C.output==="User denied tool execution";return h.jsx(ph,{toolName:L,args:C.input||{},isDenied:Q,isSafe:$s.has(L)},`${C.toolCallId}-${F}`)}return null}return C.type==="text"&&C.text&&V?h.jsx(V,{className:"text-sm prose prose-sm dark:prose-invert max-w-none",children:C.text},`${p.id}-${F}`):C.type==="reasoning"&&C.text?h.jsxs(Jr,{className:"w-full",isStreaming:pt==="streaming"&&F===p.parts.length-1&&p.id===pe.at(-1)?.id,children:[h.jsx(Qr,{}),h.jsx(ta,{children:C.text})]},`${p.id}-${F}`):null})})})},p.id)}),h.jsx("div",{ref:fe})]})}),_s&&h.jsxs("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-xs",children:["Error: ",_s.message]}),h.jsxs("div",{className:"p-4 border-t border-border relative overflow-visible",children:[h.jsx(Ic,{mode:"wait",children:(pt==="streaming"||pt==="submitted")&&h.jsxs(Ue,{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(Ue,{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:H})]})}),h.jsxs("form",{onSubmit:Ws,className:"relative",children:[h.jsx(mo,{ref:Yt,value:Nt,onChange:fa,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(),Ws(p))}}),pt==="streaming"||pt==="submitted"?h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"button",className:J(zt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),onClick:Le,children:h.jsx(G.Square,{className:"h-4 w-4"})})}),h.jsxs(Bt,{children:[h.jsx(Ys,{children:"Escape"})," to stop"]})]}):h.jsxs(Ot,{children:[h.jsx(Ft,{asChild:!0,children:h.jsx("button",{type:"submit",className:J(zt({variant:"ghost",size:"icon"}),"absolute top-1/2 -translate-y-1/2 right-2 h-8 w-8"),disabled:!Nt.trim(),children:h.jsx(G.ArrowRight,{className:"h-4 w-4"})})}),h.jsxs(Bt,{children:[h.jsx(Ys,{children:"Enter"})," to send"]})]})]})]})]}),h.jsxs("a",{href:"https://arcten.com",target:"_blank",rel:"noopener noreferrer",className:"group flex items-center justify-center gap-1.5 py-3 text-xs text-muted-foreground/40 hover:text-muted-foreground/60 transition-all overflow-hidden",children:[h.jsx("span",{className:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 whitespace-nowrap",children:"Powered by"}),h.jsx("div",{className:"w-4 h-2 bg-current rounded-t-full flex-shrink-0"}),h.jsx("span",{className:"max-w-0 opacity-0 group-hover:max-w-[100px] group-hover:opacity-100 transition-all duration-300 whitespace-nowrap",children:"Arcten"})]})]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 h-full cursor-pointer",children:[h.jsx(G.BotMessageSquare,{className:"h-5 w-5 text-stone-600 dark:text-stone-400"}),h.jsx("span",{className:"text-xs font-medium text-stone-600 dark:text-stone-400 [writing-mode:vertical-lr]",children:"AI agent"})]})})}):h.jsx("div",{className:"fixed right-0 top-0 h-screen w-96 flex items-center justify-center p-4 bg-stone-50 dark:bg-stone-900 border-l border-border",children:h.jsx("div",{className:"p-4 text-muted-foreground text-sm",children:"Loading..."})}):null}function jh({apiBaseUrl:t="https://api.arcten.com",tokenEndpoint:e="/api/arcten/token",clientToken:n,skipTokenFetch:s=!1,user:i,tools:r=[],safeTools:o=[],toolMetadata:a,systemPrompt:l="",initialMessages:u=[],conversationId:c,onToolCall:d,onFinish:f,ragFilters:g}={}){console.log("[useAgent] Hook initialized",{apiBaseUrl:t,tokenEndpoint:e,hasProvidedToken:!!n,skipTokenFetch:s,userId:i?.id,toolsCount:r.length,safeToolsCount:o.length});const[y,v]=m.useState(n||null),w=m.useRef(n||null),[x,S]=m.useState(null),[b,k]=m.useState(null),A=m.useRef(null),[D,R]=m.useState([]),[P,N]=m.useState(c||(typeof window<"u"?crypto.randomUUID():null)),[_,z]=m.useState(!1),[vt,St]=m.useState(new Set),st=m.useMemo(()=>[...r,...o],[r,o]),Ct=m.useMemo(()=>qr(st,a),[st,a]),At=m.useMemo(()=>new Set(st.map(V=>V.name)),[st]),E=m.useMemo(()=>Ct.filter(V=>At.has(V.name)),[Ct,At]),Y=m.useMemo(()=>{const V=new Map;return st.forEach(j=>V.set(j.name,j)),V},[st]),K=m.useMemo(()=>new Set(o.map(V=>V.name)),[o]);m.useEffect(()=>{if(console.log("[useAgent] Token fetch effect running",{skipTokenFetch:s,hasProvidedToken:!!n,user:i?.id,tokenEndpoint:e}),s||n){console.log("[useAgent] Skipping token fetch",{reason:s?"skipTokenFetch=true":"token provided"});return}return(async()=>{console.log("[useAgent] Fetching initial token from",e);try{const j=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!j.ok)throw new Error("Failed to fetch token");const H=await j.json();console.log("[useAgent] Token fetched successfully",{expiresAt:H.expiresAt,expiresIn:H.expiresAt?`${H.expiresAt-Math.floor(Date.now()/1e3)}s`:"unknown"}),v(H.clientToken),w.current=H.clientToken,k(H.expiresAt),S(null)}catch(j){console.error("[useAgent] Token fetch failed:",j),S(j instanceof Error?j.message:"Failed to fetch token")}})(),()=>{console.log("[useAgent] Cleaning up token fetch effect"),A.current&&clearTimeout(A.current)}},[e,JSON.stringify(i),s,n]),m.useEffect(()=>{if(console.log("[useAgent] Token refresh effect running",{hasTokenExpiresAt:!!b,tokenExpiresAt:b,skipTokenFetch:s,hasProvidedToken:!!n}),!b||s||n){console.log("[useAgent] Skipping token refresh setup",{reason:b?s?"skipTokenFetch=true":"token provided":"no expiry"});return}A.current&&(console.log("[useAgent] Clearing existing token refresh timeout"),clearTimeout(A.current));const V=Math.floor(Date.now()/1e3),j=b-V,ot=Math.max(0,j-5);return console.log("[useAgent] Scheduling token refresh",{expiresAt:b,now:V,timeUntilExpiry:`${j}s`,timeUntilRefresh:`${ot}s`,refreshAt:new Date((V+ot)*1e3).toISOString()}),A.current=setTimeout(async()=>{console.log("[useAgent] Refreshing token...");try{const q=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:i})});if(!q.ok)throw new Error("Failed to refresh token");const rt=await q.json();console.log("[useAgent] Token refreshed successfully",{newExpiresAt:rt.expiresAt,expiresIn:`${rt.expiresAt-Math.floor(Date.now()/1e3)}s`}),v(rt.clientToken),w.current=rt.clientToken,k(rt.expiresAt),S(null)}catch(q){console.error("[useAgent] Token refresh failed:",q),S(q instanceof Error?q.message:"Failed to refresh token")}},ot*1e3),()=>{console.log("[useAgent] Cleaning up token refresh effect"),A.current&&clearTimeout(A.current)}},[b,e,JSON.stringify(i),s,n]);const it=async(V,j={})=>{const H=j.headers?new Headers(j.headers):new Headers;return H.delete("user-agent"),H.delete("User-Agent"),fetch(V,{...j,headers:H})},{messages:U,sendMessage:ue,status:Xt,error:kt,stop:de,addToolResult:Rt,setMessages:he}=uo.useChat({id:P||void 0,messages:u,transport:new Ye.DefaultChatTransport({api:`${t}/chat`,fetch:it,headers:()=>{const V={};return w.current&&(V.Authorization=`Bearer ${w.current}`),V},body:()=>{const V=E.map(j=>({name:j.name,description:j.description,inputSchema:j.jsonSchema}));return process.env.NODE_ENV==="development"&&console.log("[useAgent] Sending tools to API:",{totalTools:V.length,toolNames:V.map(j=>j.name),allToolNames:st.map(j=>j.name),filteredToolNames:E.map(j=>j.name)}),{tools:V,systemPrompt:l,...g&&{ragFilters:g}}}}),sendAutomaticallyWhen:Ye.lastAssistantMessageIsCompleteWithToolCalls});m.useEffect(()=>{U.forEach(V=>{V.role==="assistant"&&V.parts.forEach(j=>{if(!j.type?.startsWith("tool-")||j.state!=="input-available")return;const H=j.type.replace("tool-",""),ot=j.toolCallId;if(!vt.has(ot)){if(St(q=>new Set(q).add(ot)),K.has(H)){const q=Y.get(H);q&&(async()=>{try{const rt=await q(...Object.values(j.input||{}));Rt({toolCallId:ot,tool:H,output:rt})}catch(rt){Rt({toolCallId:ot,tool:H,output:`Error: ${rt}`})}})()}else if(d){const q={toolCallId:ot,toolName:H,args:j.input||{}};d({toolCall:q})}}})})},[U,K,Y,d,Rt,vt]),m.useEffect(()=>{if(Xt==="ready"&&U.length>0&&f){const V=U[U.length-1];V&&V.role==="assistant"&&f({message:V,messages:U,isAbort:!1,isDisconnect:!1,isError:!!kt})}},[Xt,U,kt,f]);async function rn(){if(!(!i?.id||!y)){console.log("[useAgent] Fetching conversations for user:",i?.id),z(!0);try{const j=await(await fetch(`${t}/conversations`,{headers:{Authorization:`Bearer ${y}`}})).json();R(j.conversations||[])}catch(V){console.error("Failed to fetch conversations:",V)}finally{z(!1)}}}m.useEffect(()=>{i?.id&&y&&rn()},[JSON.stringify(i),y,t]);async function fe(V){N(V),z(!0);try{const j=await fetch(`${t}/conversations/${V}/messages`,{headers:{Authorization:`Bearer ${w.current}`}});if(!j.ok)throw new Error(`Failed to fetch messages: ${j.statusText}`);const ot=(await j.json()).messages||[];he(ot)}catch(j){console.error("Failed to load conversation messages:",j)}finally{z(!1)}}async function Yt(V){if(y)try{await fetch(`${t}/conversations/${V}`,{method:"DELETE",headers:{Authorization:`Bearer ${y}`}}),R(D.filter(j=>j._id!==V)),V===P&&Nt()}catch(j){console.error("Failed to delete conversation:",j)}}function Nt(){const V=crypto.randomUUID();N(V),he([]),St(new Set)}function me(V){Rt(V)}return{id:P,messages:U,status:Xt,error:kt,sendMessage:ue,stop:de,addToolOutput:me,setMessages:he,conversations:D,loadConversation:fe,deleteConversation:Yt,startNewConversation:Nt,isLoadingConversations:_,clientToken:y,tokenError:x}}exports.verifyToken=Va.verifyToken;exports.ArctenAgent=Mh;exports.useAgent=jh;
|