autosnippet 3.1.13 → 3.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ import{r as a,j as V,i as it,g as Kt,s as Dt,a as Lt,b as rt,c as bt,d as Jt,e as Zt,f as Qt,h as te,k as ee,l as ne,m as At,n as se,o as oe,p as ie,q as re,S as ae,H as ue,F as L,t as le,u as Tt,v as O,w as at,x as S,y as It,z as ce,A as ut,B as fe,C as W,D as K,E as lt,G as he,I as de,J as D,K as me,L as pe,M as ge,N as ct,O as ve,P as ye,Q as ft,R as Pe,T as xe,U as F,V as we,W as Ce,X as Rt,Y as Ee,Z as Se}from"./vendor-Ck-HBmg5.js";const Q=a.createContext({});function tt(e){const t=a.useRef(null);return t.current===null&&(t.current=e()),t.current}const kt=typeof window<"u",jt=kt?a.useLayoutEffect:a.useEffect,H=a.createContext(null),et=a.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function ht(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Me(...e){return t=>{let n=!1;const s=e.map(o=>{const i=ht(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<s.length;o++){const i=s[o];typeof i=="function"?i():ht(e[o],null)}}}}function Ve(...e){return a.useCallback(Me(...e),e)}class De extends a.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,o=it(s)&&s.offsetWidth||0,i=it(s)&&s.offsetHeight||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=o-r.width-r.left,r.bottom=i-r.height-r.top}return null}componentDidUpdate(){}render(){return this.props.children}}function Le({children:e,isPresent:t,anchorX:n,anchorY:s,root:o,pop:i}){var u;const r=a.useId(),l=a.useRef(null),m=a.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:h}=a.useContext(et),p=((u=e.props)==null?void 0:u.ref)??(e==null?void 0:e.ref),c=Ve(l,p);return a.useInsertionEffect(()=>{const{width:d,height:f,top:g,left:v,right:y,bottom:P}=m.current;if(t||i===!1||!l.current||!d||!f)return;const x=n==="left"?`left: ${v}`:`right: ${y}`,w=s==="bottom"?`bottom: ${P}`:`top: ${g}`;l.current.dataset.motionPopId=r;const E=document.createElement("style");h&&(E.nonce=h);const b=o??document.head;return b.appendChild(E),E.sheet&&E.sheet.insertRule(`
2
+ [data-motion-pop-id="${r}"] {
3
+ position: absolute !important;
4
+ width: ${d}px !important;
5
+ height: ${f}px !important;
6
+ ${x}px !important;
7
+ ${w}px !important;
8
+ }
9
+ `),()=>{b.contains(E)&&b.removeChild(E)}},[t]),V.jsx(De,{isPresent:t,childRef:l,sizeRef:m,pop:i,children:i===!1?e:a.cloneElement(e,{ref:c})})}const be=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:o,presenceAffectsLayout:i,mode:r,anchorX:l,anchorY:m,root:h})=>{const p=tt(Ae),c=a.useId();let u=!0,d=a.useMemo(()=>(u=!1,{id:c,initial:t,isPresent:n,custom:o,onExitComplete:f=>{p.set(f,!0);for(const g of p.values())if(!g)return;s&&s()},register:f=>(p.set(f,!1),()=>p.delete(f))}),[n,p,s]);return i&&u&&(d={...d}),a.useMemo(()=>{p.forEach((f,g)=>p.set(g,!1))},[n]),a.useEffect(()=>{!n&&!p.size&&s&&s()},[n]),e=V.jsx(Le,{pop:r==="popLayout",isPresent:n,anchorX:l,anchorY:m,root:h,children:e}),V.jsx(H.Provider,{value:d,children:e})};function Ae(){return new Map}function Ft(e=!0){const t=a.useContext(H);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:o}=t,i=a.useId();a.useEffect(()=>{if(e)return o(i)},[e]);const r=a.useCallback(()=>e&&s&&s(i),[i,s,e]);return!n&&s?[!1,r]:[!0]}const k=e=>e.key||"";function dt(e){const t=[];return a.Children.forEach(e,n=>{a.isValidElement(n)&&t.push(n)}),t}const Hn=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:o=!0,mode:i="sync",propagate:r=!1,anchorX:l="left",anchorY:m="top",root:h})=>{const[p,c]=Ft(r),u=a.useMemo(()=>dt(e),[e]),d=r&&!p?[]:u.map(k),f=a.useRef(!0),g=a.useRef(u),v=tt(()=>new Map),y=a.useRef(new Set),[P,x]=a.useState(u),[w,E]=a.useState(u);jt(()=>{f.current=!1,g.current=u;for(let M=0;M<w.length;M++){const C=k(w[M]);d.includes(C)?(v.delete(C),y.current.delete(C)):v.get(C)!==!0&&v.set(C,!1)}},[w,d.length,d.join("-")]);const b=[];if(u!==P){let M=[...u];for(let C=0;C<w.length;C++){const A=w[C],N=k(A);d.includes(N)||(M.splice(C,0,A),b.push(A))}return i==="wait"&&b.length&&(M=b),E(dt(M)),x(u),null}const{forceRender:U}=a.useContext(Q);return V.jsx(V.Fragment,{children:w.map(M=>{const C=k(M),A=r&&!p?!1:u===w||d.includes(C),N=()=>{if(y.current.has(C))return;if(y.current.add(C),v.has(C))v.set(C,!0);else return;let ot=!0;v.forEach(qt=>{qt||(ot=!1)}),ot&&(U==null||U(),E(g.current),r&&(c==null||c()),s&&s())};return V.jsx(be,{isPresent:A,initial:!f.current||n?void 0:!1,custom:t,presenceAffectsLayout:o,mode:i,root:h,onExitComplete:A?void 0:N,anchorX:l,anchorY:m,children:M},C)})})},Ot=a.createContext({strict:!1}),mt={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"]};let pt=!1;function Te(){if(pt)return;const e={};for(const t in mt)e[t]={isEnabled:n=>mt[t].some(s=>!!n[s])};Dt(e),pt=!0}function Wt(){return Te(),Kt()}function Ie(e){const t=Wt();for(const n in e)t[n]={...t[n],...e[n]};Dt(t)}const Re=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","propagate","ignoreStrict","viewport"]);function G(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Re.has(e)}let Gt=e=>!G(e);function ke(e){typeof e=="function"&&(Gt=t=>t.startsWith("on")?!G(t):e(t))}try{ke(require("@emotion/is-prop-valid").default)}catch{}function je(e,t,n){const s={};for(const o in e)o==="values"&&typeof e.values=="object"||(Gt(o)||n===!0&&G(o)||!t&&!G(o)||e.draggable&&o.startsWith("onDrag"))&&(s[o]=e[o]);return s}const B=a.createContext({});function Fe(e,t){if(Lt(e)){const{initial:n,animate:s}=e;return{initial:n===!1||rt(n)?n:void 0,animate:rt(s)?s:void 0}}return e.inherit!==!1?t:{}}function Oe(e){const{initial:t,animate:n}=Fe(e,a.useContext(B));return a.useMemo(()=>({initial:t,animate:n}),[gt(t),gt(n)])}function gt(e){return Array.isArray(e)?e.join(" "):e}const nt=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ht(e,t,n){for(const s in t)!bt(t[s])&&!Jt(s,n)&&(e[s]=t[s])}function We({transformTemplate:e},t){return a.useMemo(()=>{const n=nt();return Zt(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Ge(e,t){const n=e.style||{},s={};return Ht(s,n,e),Object.assign(s,We(e,t)),s}function He(e,t){const n={},s=Ge(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,s.userSelect=s.WebkitUserSelect=s.WebkitTouchCallout="none",s.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=s,n}const Bt=()=>({...nt(),attrs:{}});function Be(e,t,n,s){const o=a.useMemo(()=>{const i=Bt();return Qt(i,t,te(s),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};Ht(i,e.style,e),o.style={...i,...o.style}}return o}const Ue=["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 st(e){return typeof e!="string"||e.includes("-")?!1:!!(Ue.indexOf(e)>-1||/[A-Z]/u.test(e))}function Ne(e,t,n,{latestValues:s},o,i=!1,r){const m=(r??st(e)?Be:He)(t,s,o,e),h=je(t,typeof e=="string",i),p=e!==a.Fragment?{...h,...m,ref:n}:{},{children:c}=t,u=a.useMemo(()=>bt(c)?c.get():c,[c]);return a.createElement(e,{...p,children:u})}function $e({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,o){return{latestValues:ze(n,s,o,e),renderState:t()}}function ze(e,t,n,s){const o={},i=s(e,{});for(const u in i)o[u]=ee(i[u]);let{initial:r,animate:l}=e;const m=Lt(e),h=ne(e);t&&h&&!m&&e.inherit!==!1&&(r===void 0&&(r=t.initial),l===void 0&&(l=t.animate));let p=n?n.initial===!1:!1;p=p||r===!1;const c=p?l:r;if(c&&typeof c!="boolean"&&!At(c)){const u=Array.isArray(c)?c:[c];for(let d=0;d<u.length;d++){const f=se(e,u[d]);if(f){const{transitionEnd:g,transition:v,...y}=f;for(const P in y){let x=y[P];if(Array.isArray(x)){const w=p?x.length-1:0;x=x[w]}x!==null&&(o[P]=x)}for(const P in g)o[P]=g[P]}}}return o}const Ut=e=>(t,n)=>{const s=a.useContext(B),o=a.useContext(H),i=()=>$e(e,t,s,o);return n?i():tt(i)},_e=Ut({scrapeMotionValuesFromProps:oe,createRenderState:nt}),Xe=Ut({scrapeMotionValuesFromProps:ie,createRenderState:Bt}),Ye=Symbol.for("motionComponentSymbol");function qe(e,t,n){const s=a.useRef(n);a.useInsertionEffect(()=>{s.current=n});const o=a.useRef(null);return a.useCallback(i=>{var l;i&&((l=e.onMount)==null||l.call(e,i)),t&&(i?t.mount(i):t.unmount());const r=s.current;if(typeof r=="function")if(i){const m=r(i);typeof m=="function"&&(o.current=m)}else o.current?(o.current(),o.current=null):r(i);else r&&(r.current=i)},[t])}const Nt=a.createContext({});function T(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function Ke(e,t,n,s,o,i){var x,w;const{visualElement:r}=a.useContext(B),l=a.useContext(Ot),m=a.useContext(H),h=a.useContext(et),p=h.reducedMotion,c=h.skipAnimations,u=a.useRef(null),d=a.useRef(!1);s=s||l.renderer,!u.current&&s&&(u.current=s(e,{visualState:t,parent:r,props:n,presenceContext:m,blockInitialAnimation:m?m.initial===!1:!1,reducedMotionConfig:p,skipAnimations:c,isSVG:i}),d.current&&u.current&&(u.current.manuallyAnimateOnMount=!0));const f=u.current,g=a.useContext(Nt);f&&!f.projection&&o&&(f.type==="html"||f.type==="svg")&&Je(u.current,n,o,g);const v=a.useRef(!1);a.useInsertionEffect(()=>{f&&v.current&&f.update(n,m)});const y=n[re],P=a.useRef(!!y&&!((x=window.MotionHandoffIsComplete)!=null&&x.call(window,y))&&((w=window.MotionHasOptimisedAnimation)==null?void 0:w.call(window,y)));return jt(()=>{d.current=!0,f&&(v.current=!0,window.MotionIsMounted=!0,f.updateFeatures(),f.scheduleRenderMicrotask(),P.current&&f.animationState&&f.animationState.animateChanges())}),a.useEffect(()=>{f&&(!P.current&&f.animationState&&f.animationState.animateChanges(),P.current&&(queueMicrotask(()=>{var E;(E=window.MotionHandoffMarkAsComplete)==null||E.call(window,y)}),P.current=!1),f.enteringChildren=void 0)}),f}function Je(e,t,n,s){const{layoutId:o,layout:i,drag:r,dragConstraints:l,layoutScroll:m,layoutRoot:h,layoutCrossfade:p}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:$t(e.parent)),e.projection.setOptions({layoutId:o,layout:i,alwaysMeasureLayout:!!r||l&&T(l),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:s,crossfade:p,layoutScroll:m,layoutRoot:h})}function $t(e){if(e)return e.options.allowProjection!==!1?e.projection:$t(e.parent)}function $(e,{forwardMotionProps:t=!1,type:n}={},s,o){s&&Ie(s);const i=n?n==="svg":st(e),r=i?Xe:_e;function l(h,p){let c;const u={...a.useContext(et),...h,layoutId:Ze(h)},{isStatic:d}=u,f=Oe(h),g=r(h,d);if(!d&&kt){Qe();const v=tn(u);c=v.MeasureLayout,f.visualElement=Ke(e,g,u,o,v.ProjectionNode,i)}return V.jsxs(B.Provider,{value:f,children:[c&&f.visualElement?V.jsx(c,{visualElement:f.visualElement,...u}):null,Ne(e,h,qe(g,f.visualElement,p),g,d,t,i)]})}l.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const m=a.forwardRef(l);return m[Ye]=e,m}function Ze({layoutId:e}){const t=a.useContext(Q).id;return t&&e!==void 0?t+"-"+e:e}function Qe(e,t){a.useContext(Ot).strict}function tn(e){const t=Wt(),{drag:n,layout:s}=t;if(!n&&!s)return{};const o={...n,...s};return{MeasureLayout:n!=null&&n.isEnabled(e)||s!=null&&s.isEnabled(e)?o.MeasureLayout:void 0,ProjectionNode:o.ProjectionNode}}function en(e,t){if(typeof Proxy>"u")return $;const n=new Map,s=(i,r)=>$(i,r,e,t),o=(i,r)=>s(i,r);return new Proxy(o,{get:(i,r)=>r==="create"?s:(n.has(r)||n.set(r,$(r,void 0,e,t)),n.get(r))})}const nn=(e,t)=>t.isSVG??st(e)?new ae(t):new ue(t,{allowProjection:e!==a.Fragment});class sn extends L{constructor(t){super(t),t.animationState||(t.animationState=le(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();At(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let on=0;class rn extends L{constructor(){super(...arguments),this.id=on++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:s}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===s)return;const o=this.node.animationState.setActive("exit",!t);n&&!t&&o.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const an={animation:{Feature:sn},exit:{Feature:rn}};function R(e){return{point:{x:e.pageX,y:e.pageY}}}const un=e=>t=>Tt(t)&&e(t,R(t));function I(e,t,n,s){return O(e,t,un(n),s)}const zt=({current:e})=>e?e.ownerDocument.defaultView:null,vt=(e,t)=>Math.abs(e-t);function ln(e,t){const n=vt(e.x,t.x),s=vt(e.y,t.y);return Math.sqrt(n**2+s**2)}const yt=new Set(["auto","scroll"]);class _t{constructor(t,n,{transformPagePoint:s,contextWindow:o=window,dragSnapToOrigin:i=!1,distanceThreshold:r=3,element:l}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=d=>{this.handleScroll(d.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const d=_(this.lastMoveEventInfo,this.history),f=this.startEvent!==null,g=ln(d.offset,{x:0,y:0})>=this.distanceThreshold;if(!f&&!g)return;const{point:v}=d,{timestamp:y}=at;this.history.push({...v,timestamp:y});const{onStart:P,onMove:x}=this.handlers;f||(P&&P(this.lastMoveEvent,d),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,d)},this.handlePointerMove=(d,f)=>{this.lastMoveEvent=d,this.lastMoveEventInfo=z(f,this.transformPagePoint),S.update(this.updatePoint,!0)},this.handlePointerUp=(d,f)=>{this.end();const{onEnd:g,onSessionEnd:v,resumeAnimation:y}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&y&&y(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const P=_(d.type==="pointercancel"?this.lastMoveEventInfo:z(f,this.transformPagePoint),this.history);this.startEvent&&g&&g(d,P),v&&v(d,P)},!Tt(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=o||window;const m=R(t),h=z(m,this.transformPagePoint),{point:p}=h,{timestamp:c}=at;this.history=[{...p,timestamp:c}];const{onSessionStart:u}=n;u&&u(t,_(h,this.history)),this.removeListeners=It(I(this.contextWindow,"pointermove",this.handlePointerMove),I(this.contextWindow,"pointerup",this.handlePointerUp),I(this.contextWindow,"pointercancel",this.handlePointerUp)),l&&this.startScrollTracking(l)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(yt.has(s.overflowX)||yt.has(s.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const s=t===window,o=s?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},i={x:o.x-n.x,y:o.y-n.y};i.x===0&&i.y===0||(s?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(t,o),S.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),ce(this.updatePoint)}}function z(e,t){return t?{point:t(e.point)}:e}function Pt(e,t){return{x:e.x-t.x,y:e.y-t.y}}function _({point:e},t){return{point:e,delta:Pt(e,Xt(t)),offset:Pt(e,cn(t)),velocity:fn(t,.1)}}function cn(e){return e[0]}function Xt(e){return e[e.length-1]}function fn(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const o=Xt(e);for(;n>=0&&(s=e[n],!(o.timestamp-s.timestamp>ut(t)));)n--;if(!s)return{x:0,y:0};s===e[0]&&e.length>2&&o.timestamp-s.timestamp>ut(t)*2&&(s=e[1]);const i=fe(o.timestamp-s.timestamp);if(i===0)return{x:0,y:0};const r={x:(o.x-s.x)/i,y:(o.y-s.y)/i};return r.x===1/0&&(r.x=0),r.y===1/0&&(r.y=0),r}function hn(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?W(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?W(n,e,s.max):Math.min(e,n)),e}function xt(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function dn(e,{top:t,left:n,bottom:s,right:o}){return{x:xt(e.x,n,o),y:xt(e.y,t,s)}}function wt(e,t){let n=t.min-e.min,s=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,s]=[s,n]),{min:n,max:s}}function mn(e,t){return{x:wt(e.x,t.x),y:wt(e.y,t.y)}}function pn(e,t){let n=.5;const s=K(e),o=K(t);return o>s?n=lt(t.min,t.max-s,e.min):s>o&&(n=lt(e.min,e.max-o,t.min)),he(0,1,n)}function gn(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const J=.35;function vn(e=J){return e===!1?e=0:e===!0&&(e=J),{x:Ct(e,"left","right"),y:Ct(e,"top","bottom")}}function Ct(e,t,n){return{min:Et(e,t),max:Et(e,n)}}function Et(e,t){return typeof e=="number"?e:e[t]||0}const yn=new WeakMap;class Pn{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=de(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:s}={}){const{presenceContext:o}=this.visualElement;if(o&&o.isPresent===!1)return;const i=c=>{n&&this.snapToCursor(R(c).point),this.stopAnimation()},r=(c,u)=>{const{drag:d,dragPropagation:f,onDragStart:g}=this.getProps();if(d&&!f&&(this.openDragLock&&this.openDragLock(),this.openDragLock=ye(d),!this.openDragLock))return;this.latestPointerEvent=c,this.latestPanInfo=u,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),D(y=>{let P=this.getAxisMotionValue(y).get()||0;if(Pe.test(P)){const{projection:x}=this.visualElement;if(x&&x.layout){const w=x.layout.layoutBox[y];w&&(P=K(w)*(parseFloat(P)/100))}}this.originPoint[y]=P}),g&&S.update(()=>g(c,u),!1,!0),ct(this.visualElement,"transform");const{animationState:v}=this.visualElement;v&&v.setActive("whileDrag",!0)},l=(c,u)=>{this.latestPointerEvent=c,this.latestPanInfo=u;const{dragPropagation:d,dragDirectionLock:f,onDirectionLock:g,onDrag:v}=this.getProps();if(!d&&!this.openDragLock)return;const{offset:y}=u;if(f&&this.currentDirection===null){this.currentDirection=wn(y),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",u.point,y),this.updateAxis("y",u.point,y),this.visualElement.render(),v&&S.update(()=>v(c,u),!1,!0)},m=(c,u)=>{this.latestPointerEvent=c,this.latestPanInfo=u,this.stop(c,u),this.latestPointerEvent=null,this.latestPanInfo=null},h=()=>{const{dragSnapToOrigin:c}=this.getProps();(c||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new _t(t,{onSessionStart:i,onStart:r,onMove:l,onSessionEnd:m,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:s,contextWindow:zt(this.visualElement),element:this.visualElement.current})}stop(t,n){const s=t||this.latestPointerEvent,o=n||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!o||!s)return;const{velocity:r}=o;this.startAnimation(r);const{onDragEnd:l}=this.getProps();l&&S.postRender(()=>l(s,o))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:s}=this.getProps();!s&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,s){const{drag:o}=this.getProps();if(!s||!j(t,o,this.currentDirection))return;const i=this.getAxisMotionValue(t);let r=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(r=hn(r,this.constraints[t],this.elastic[t])),i.set(r)}resolveConstraints(){var i;const{dragConstraints:t,dragElastic:n}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(i=this.visualElement.projection)==null?void 0:i.layout,o=this.constraints;t&&T(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=dn(s.layoutBox,t):this.constraints=!1,this.elastic=vn(n),o!==this.constraints&&!T(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&D(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=gn(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!T(t))return!1;const s=t.current,{projection:o}=this.visualElement;if(!o||!o.layout)return!1;const i=me(s,o.root,this.visualElement.getTransformPagePoint());let r=mn(o.layout.layoutBox,i);if(n){const l=n(pe(r));this.hasMutatedConstraints=!!l,l&&(r=ge(l))}return r}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:o,dragTransition:i,dragSnapToOrigin:r,onDragTransitionEnd:l}=this.getProps(),m=this.constraints||{},h=D(p=>{if(!j(p,n,this.currentDirection))return;let c=m&&m[p]||{};r&&(c={min:0,max:0});const u=o?200:1e6,d=o?40:1e7,f={type:"inertia",velocity:s?t[p]:0,bounceStiffness:u,bounceDamping:d,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(p,f)});return Promise.all(h).then(l)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return ct(this.visualElement,t),s.start(ve(t,s,0,n,this.visualElement,!1))}stopAnimation(){D(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps(),o=s[n];return o||this.visualElement.getValue(t,(s.initial?s.initial[t]:void 0)||0)}snapToCursor(t){D(n=>{const{drag:s}=this.getProps();if(!j(n,s,this.currentDirection))return;const{projection:o}=this.visualElement,i=this.getAxisMotionValue(n);if(o&&o.layout){const{min:r,max:l}=o.layout.layoutBox[n],m=i.get()||0;i.set(t[n]-W(r,l,.5)+m)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!T(n)||!s||!this.constraints)return;this.stopAnimation();const o={x:0,y:0};D(r=>{const l=this.getAxisMotionValue(r);if(l&&this.constraints!==!1){const m=l.get();o[r]=pn({min:m,max:m},this.constraints[r])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",s.root&&s.root.updateScroll(),s.updateLayout(),this.constraints=!1,this.resolveConstraints(),D(r=>{if(!j(r,t,null))return;const l=this.getAxisMotionValue(r),{min:m,max:h}=this.constraints[r];l.set(W(m,h,o[r]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;yn.set(this.visualElement,this);const t=this.visualElement.current,n=I(t,"pointerdown",h=>{const{drag:p,dragListener:c=!0}=this.getProps(),u=h.target,d=u!==t&&xe(u);p&&c&&!d&&this.start(h)});let s;const o=()=>{const{dragConstraints:h}=this.getProps();T(h)&&h.current&&(this.constraints=this.resolveRefConstraints(),s||(s=xn(t,h.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,r=i.addEventListener("measure",o);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),S.read(o);const l=O(window,"resize",()=>this.scalePositionWithinConstraints()),m=i.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:p})=>{this.isDragging&&p&&(D(c=>{const u=this.getAxisMotionValue(c);u&&(this.originPoint[c]+=h[c].translate,u.set(u.get()+h[c].translate))}),this.visualElement.render())}));return()=>{l(),n(),r(),m&&m(),s&&s()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:o=!1,dragConstraints:i=!1,dragElastic:r=J,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:o,dragConstraints:i,dragElastic:r,dragMomentum:l}}}function St(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function xn(e,t,n){const s=ft(e,St(n)),o=ft(t,St(n));return()=>{s(),o()}}function j(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function wn(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class Cn extends L{constructor(t){super(t),this.removeGroupControls=F,this.removeListeners=F,this.controls=new Pn(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||F}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const X=e=>(t,n)=>{e&&S.update(()=>e(t,n),!1,!0)};class En extends L{constructor(){super(...arguments),this.removePointerDownListener=F}onPointerDown(t){this.session=new _t(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:zt(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:o}=this.node.getProps();return{onSessionStart:X(t),onStart:X(n),onMove:X(s),onEnd:(i,r)=>{delete this.session,o&&S.postRender(()=>o(i,r))}}}mount(){this.removePointerDownListener=I(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let Y=!1;class Sn extends a.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s,layoutId:o}=this.props,{projection:i}=t;i&&(n.group&&n.group.add(i),s&&s.register&&o&&s.register(i),Y&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Ce.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:s,drag:o,isPresent:i}=this.props,{projection:r}=s;return r&&(r.isPresent=i,t.layoutDependency!==n&&r.setOptions({...r.options,layoutDependency:n}),Y=!0,o||t.layoutDependency!==n||n===void 0||t.isPresent!==i?r.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?r.promote():r.relegate()||S.postRender(()=>{const l=r.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),we.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:o}=t;Y=!0,o&&(o.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(o),s&&s.deregister&&s.deregister(o))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Yt(e){const[t,n]=Ft(),s=a.useContext(Q);return V.jsx(Sn,{...e,layoutGroup:s,switchLayoutGroup:a.useContext(Nt),isPresent:t,safeToRemove:n})}const Mn={pan:{Feature:En},drag:{Feature:Cn,ProjectionNode:Rt,MeasureLayout:Yt}};function Mt(e,t,n){const{props:s}=e;e.animationState&&s.whileHover&&e.animationState.setActive("whileHover",n==="Start");const o="onHover"+n,i=s[o];i&&S.postRender(()=>i(t,R(t)))}class Vn extends L{mount(){const{current:t}=this.node;t&&(this.unmount=Ee(t,(n,s)=>(Mt(this.node,s,"Start"),o=>Mt(this.node,o,"End"))))}unmount(){}}class Dn extends L{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!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=It(O(this.node.current,"focus",()=>this.onFocus()),O(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Vt(e,t,n){const{props:s}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&s.whileTap&&e.animationState.setActive("whileTap",n==="Start");const o="onTap"+(n==="End"?"":n),i=s[o];i&&S.postRender(()=>i(t,R(t)))}class Ln extends L{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=Se(t,(o,i)=>(Vt(this.node,i,"Start"),(r,{success:l})=>Vt(this.node,r,l?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(s==null?void 0:s.tap)===!1})}unmount(){}}const Z=new WeakMap,q=new WeakMap,bn=e=>{const t=Z.get(e.target);t&&t(e)},An=e=>{e.forEach(bn)};function Tn({root:e,...t}){const n=e||document;q.has(n)||q.set(n,{});const s=q.get(n),o=JSON.stringify(t);return s[o]||(s[o]=new IntersectionObserver(An,{root:e,...t})),s[o]}function In(e,t,n){const s=Tn(t);return Z.set(e,n),s.observe(e),()=>{Z.delete(e),s.unobserve(e)}}const Rn={some:0,all:1};class kn extends L{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:s,amount:o="some",once:i}=t,r={root:n?n.current:void 0,rootMargin:s,threshold:typeof o=="number"?o:Rn[o]},l=m=>{const{isIntersecting:h}=m;if(this.isInView===h||(this.isInView=h,i&&!h&&this.hasEnteredView))return;h&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",h);const{onViewportEnter:p,onViewportLeave:c}=this.node.getProps(),u=h?p:c;u&&u(m)};return In(this.node.current,r,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(jn(t,n))&&this.startObserver()}unmount(){}}function jn({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Fn={inView:{Feature:kn},tap:{Feature:Ln},focus:{Feature:Dn},hover:{Feature:Vn}},On={layout:{ProjectionNode:Rt,MeasureLayout:Yt}},Wn={...an,...Fn,...Mn,...On},Bn=en(Wn,nn);export{Hn as A,Bn as m};