@harness-engineering/dashboard 0.7.0 → 0.8.1
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/client/assets/framer-motion-CKCla3Ft.js +9 -0
- package/dist/client/assets/index-EpR7A63v.js +24 -0
- package/dist/client/assets/index-krfRxYsf.css +1 -0
- package/dist/client/assets/react-Dauv-dA-.js +40 -0
- package/dist/client/assets/react-router-rpxWuPlF.js +12 -0
- package/dist/client/assets/syntax-highlighter-DWwEaa3J.js +8 -0
- package/dist/client/assets/vendor-CUJ5XKnx.js +305 -0
- package/dist/client/assets/virtuoso-DIddGMdU.js +1 -0
- package/dist/client/index.html +8 -2
- package/package.json +6 -6
- package/dist/client/assets/index-C1PzHUX3.css +0 -1
- package/dist/client/assets/index-DGwRoJeP.js +0 -393
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{r as u,j as V}from"./react-Dauv-dA-.js";import{i as Y,g as ee,s as It,a as $,b as Tt,c as ct,d as ne,e as se,f as oe,h as ie,r as re,j as ae,k as Rt,l as ue,m as ce,n as le,o as fe,S as he,H as de,F as b,p as me,q as pe,t as kt,u as B,v as lt,w as S,x as jt,y as Ft,z as ft,A as ge,B as U,C as et,D as ht,E as ve,G as ye,I as A,J as Pe,K as xe,L as we,M as dt,N as Ce,O as Ee,P as mt,Q as Se,R as Me,T as H,U as Ve,V as Ae,W as Gt,X as be,Y as Le,Z as De,_ as q,$ as Ie,a0 as Te,a1 as Re,a2 as ke,a3 as je}from"./vendor-CUJ5XKnx.js";const ot=u.createContext({});function D(e){const t=u.useRef(null);return t.current===null&&(t.current=e()),t.current}const Fe=typeof window<"u",it=Fe?u.useLayoutEffect:u.useEffect,z=u.createContext(null),j=u.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function pt(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ge(...e){return t=>{let n=!1;const s=e.map(o=>{const i=pt(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():pt(e[o],null)}}}}function Oe(...e){return u.useCallback(Ge(...e),e)}class We extends u.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(Y(n)&&t.isPresent&&!this.props.isPresent&&this.props.pop!==!1){const s=n.offsetParent,o=Y(s)&&s.offsetWidth||0,i=Y(s)&&s.offsetHeight||0,r=getComputedStyle(n),a=this.props.sizeRef.current;a.height=parseFloat(r.height),a.width=parseFloat(r.width),a.top=n.offsetTop,a.left=n.offsetLeft,a.right=o-a.width-a.left,a.bottom=i-a.height-a.top}return null}componentDidUpdate(){}render(){return this.props.children}}function He({children:e,isPresent:t,anchorX:n,anchorY:s,root:o,pop:i}){var c;const r=u.useId(),a=u.useRef(null),h=u.useRef({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:p}=u.useContext(j),d=((c=e.props)==null?void 0:c.ref)??(e==null?void 0:e.ref),l=Oe(a,d);return u.useInsertionEffect(()=>{const{width:m,height:f,top:g,left:v,right:y,bottom:P}=h.current;if(t||i===!1||!a.current||!m||!f)return;const x=n==="left"?`left: ${v}`:`right: ${y}`,w=s==="bottom"?`bottom: ${P}`:`top: ${g}`;a.current.dataset.motionPopId=r;const E=document.createElement("style");p&&(E.nonce=p);const L=o??document.head;return L.appendChild(E),E.sheet&&E.sheet.insertRule(`
|
|
2
|
+
[data-motion-pop-id="${r}"] {
|
|
3
|
+
position: absolute !important;
|
|
4
|
+
width: ${m}px !important;
|
|
5
|
+
height: ${f}px !important;
|
|
6
|
+
${x}px !important;
|
|
7
|
+
${w}px !important;
|
|
8
|
+
}
|
|
9
|
+
`),()=>{var I;(I=a.current)==null||I.removeAttribute("data-motion-pop-id"),L.contains(E)&&L.removeChild(E)}},[t]),V.jsx(We,{isPresent:t,childRef:a,sizeRef:h,pop:i,children:i===!1?e:u.cloneElement(e,{ref:l})})}const Be=({children:e,initial:t,isPresent:n,onExitComplete:s,custom:o,presenceAffectsLayout:i,mode:r,anchorX:a,anchorY:h,root:p})=>{const d=D(Ue),l=u.useId();let c=!0,m=u.useMemo(()=>(c=!1,{id:l,initial:t,isPresent:n,custom:o,onExitComplete:f=>{d.set(f,!0);for(const g of d.values())if(!g)return;s&&s()},register:f=>(d.set(f,!1),()=>d.delete(f))}),[n,d,s]);return i&&c&&(m={...m}),u.useMemo(()=>{d.forEach((f,g)=>d.set(g,!1))},[n]),u.useEffect(()=>{!n&&!d.size&&s&&s()},[n]),e=V.jsx(He,{pop:r==="popLayout",isPresent:n,anchorX:a,anchorY:h,root:p,children:e}),V.jsx(z.Provider,{value:m,children:e})};function Ue(){return new Map}function Ot(e=!0){const t=u.useContext(z);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:s,register:o}=t,i=u.useId();u.useEffect(()=>{if(e)return o(i)},[e]);const r=u.useCallback(()=>e&&s&&s(i),[i,s,e]);return!n&&s?[!1,r]:[!0]}const G=e=>e.key||"";function gt(e){const t=[];return u.Children.forEach(e,n=>{u.isValidElement(n)&&t.push(n)}),t}const ns=({children:e,custom:t,initial:n=!0,onExitComplete:s,presenceAffectsLayout:o=!0,mode:i="sync",propagate:r=!1,anchorX:a="left",anchorY:h="top",root:p})=>{const[d,l]=Ot(r),c=u.useMemo(()=>gt(e),[e]),m=r&&!d?[]:c.map(G),f=u.useRef(!0),g=u.useRef(c),v=D(()=>new Map),y=u.useRef(new Set),[P,x]=u.useState(c),[w,E]=u.useState(c);it(()=>{f.current=!1,g.current=c;for(let M=0;M<w.length;M++){const C=G(w[M]);m.includes(C)?(v.delete(C),y.current.delete(C)):v.get(C)!==!0&&v.set(C,!1)}},[w,m.length,m.join("-")]);const L=[];if(c!==P){let M=[...c];for(let C=0;C<w.length;C++){const T=w[C],X=G(T);m.includes(X)||(M.splice(C,0,T),L.push(T))}return i==="wait"&&L.length&&(M=L),E(gt(M)),x(c),null}const{forceRender:I}=u.useContext(ot);return V.jsx(V.Fragment,{children:w.map(M=>{const C=G(M),T=r&&!d?!1:c===w||m.includes(C),X=()=>{if(y.current.has(C))return;if(v.has(C))y.current.add(C),v.set(C,!0);else return;let ut=!0;v.forEach(te=>{te||(ut=!1)}),ut&&(I==null||I(),E(g.current),r&&(l==null||l()),s&&s())};return V.jsx(Be,{isPresent:T,initial:!f.current||n?void 0:!1,custom:t,presenceAffectsLayout:o,mode:i,root:p,onExitComplete:T?void 0:X,anchorX:a,anchorY:h,children:M},C)})})},Wt=u.createContext({strict:!1}),vt={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 yt=!1;function Ne(){if(yt)return;const e={};for(const t in vt)e[t]={isEnabled:n=>vt[t].some(s=>!!n[s])};It(e),yt=!0}function Ht(){return Ne(),ee()}function $e(e){const t=Ht();for(const n in e)t[n]={...t[n],...e[n]};It(t)}const ze=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 N(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||ze.has(e)}let Bt=e=>!N(e);function _e(e){typeof e=="function"&&(Bt=t=>t.startsWith("on")?!N(t):e(t))}try{_e(require("@emotion/is-prop-valid").default)}catch{}function Xe(e,t,n){const s={};for(const o in e)o==="values"&&typeof e.values=="object"||$(e[o])||(Bt(o)||n===!0&&N(o)||!t&&!N(o)||e.draggable&&o.startsWith("onDrag"))&&(s[o]=e[o]);return s}const _=u.createContext({});function Ye(e,t){if(Tt(e)){const{initial:n,animate:s}=e;return{initial:n===!1||ct(n)?n:void 0,animate:ct(s)?s:void 0}}return e.inherit!==!1?t:{}}function qe(e){const{initial:t,animate:n}=Ye(e,u.useContext(_));return u.useMemo(()=>({initial:t,animate:n}),[Pt(t),Pt(n)])}function Pt(e){return Array.isArray(e)?e.join(" "):e}const rt=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ut(e,t,n){for(const s in t)!$(t[s])&&!ne(s,n)&&(e[s]=t[s])}function Ke({transformTemplate:e},t){return u.useMemo(()=>{const n=rt();return se(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Je(e,t){const n=e.style||{},s={};return Ut(s,n,e),Object.assign(s,Ke(e,t)),s}function Ze(e,t){const n={},s=Je(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 Nt=()=>({...rt(),attrs:{}});function Qe(e,t,n,s){const o=u.useMemo(()=>{const i=Nt();return oe(i,t,ie(s),e.transformTemplate,e.style),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};Ut(i,e.style,e),o.style={...i,...o.style}}return o}const tn=["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 at(e){return typeof e!="string"||e.includes("-")?!1:!!(tn.indexOf(e)>-1||/[A-Z]/u.test(e))}function en(e,t,n,{latestValues:s},o,i=!1,r){const h=(r??at(e)?Qe:Ze)(t,s,o,e),p=Xe(t,typeof e=="string",i),d=e!==u.Fragment?{...p,...h,ref:n}:{},{children:l}=t,c=u.useMemo(()=>$(l)?l.get():l,[l]);return u.createElement(e,{...d,children:c})}function nn({scrapeMotionValuesFromProps:e,createRenderState:t},n,s,o){return{latestValues:sn(n,s,o,e),renderState:t()}}function sn(e,t,n,s){const o={},i=s(e,{});for(const c in i)o[c]=re(i[c]);let{initial:r,animate:a}=e;const h=Tt(e),p=ae(e);t&&p&&!h&&e.inherit!==!1&&(r===void 0&&(r=t.initial),a===void 0&&(a=t.animate));let d=n?n.initial===!1:!1;d=d||r===!1;const l=d?a:r;if(l&&typeof l!="boolean"&&!Rt(l)){const c=Array.isArray(l)?l:[l];for(let m=0;m<c.length;m++){const f=ue(e,c[m]);if(f){const{transitionEnd:g,transition:v,...y}=f;for(const P in y){let x=y[P];if(Array.isArray(x)){const w=d?x.length-1:0;x=x[w]}x!==null&&(o[P]=x)}for(const P in g)o[P]=g[P]}}}return o}const $t=e=>(t,n)=>{const s=u.useContext(_),o=u.useContext(z),i=()=>nn(e,t,s,o);return n?i():D(i)},on=$t({scrapeMotionValuesFromProps:ce,createRenderState:rt}),rn=$t({scrapeMotionValuesFromProps:le,createRenderState:Nt}),an=Symbol.for("motionComponentSymbol");function un(e,t,n){const s=u.useRef(n);u.useInsertionEffect(()=>{s.current=n});const o=u.useRef(null);return u.useCallback(i=>{var a;i&&((a=e.onMount)==null||a.call(e,i));const r=s.current;if(typeof r=="function")if(i){const h=r(i);typeof h=="function"&&(o.current=h)}else o.current?(o.current(),o.current=null):r(i);else r&&(r.current=i);t&&(i?t.mount(i):t.unmount())},[t])}const zt=u.createContext({});function R(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function cn(e,t,n,s,o,i){var x,w;const{visualElement:r}=u.useContext(_),a=u.useContext(Wt),h=u.useContext(z),p=u.useContext(j),d=p.reducedMotion,l=p.skipAnimations,c=u.useRef(null),m=u.useRef(!1);s=s||a.renderer,!c.current&&s&&(c.current=s(e,{visualState:t,parent:r,props:n,presenceContext:h,blockInitialAnimation:h?h.initial===!1:!1,reducedMotionConfig:d,skipAnimations:l,isSVG:i}),m.current&&c.current&&(c.current.manuallyAnimateOnMount=!0));const f=c.current,g=u.useContext(zt);f&&!f.projection&&o&&(f.type==="html"||f.type==="svg")&&ln(c.current,n,o,g);const v=u.useRef(!1);u.useInsertionEffect(()=>{f&&v.current&&f.update(n,h)});const y=n[fe],P=u.useRef(!!y&&typeof window<"u"&&!((x=window.MotionHandoffIsComplete)!=null&&x.call(window,y))&&((w=window.MotionHasOptimisedAnimation)==null?void 0:w.call(window,y)));return it(()=>{m.current=!0,f&&(v.current=!0,window.MotionIsMounted=!0,f.updateFeatures(),f.scheduleRenderMicrotask(),P.current&&f.animationState&&f.animationState.animateChanges())}),u.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 ln(e,t,n,s){const{layoutId:o,layout:i,drag:r,dragConstraints:a,layoutScroll:h,layoutRoot:p,layoutAnchor:d,layoutCrossfade:l}=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||a&&R(a),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:s,crossfade:l,layoutScroll:h,layoutRoot:p,layoutAnchor:d})}function _t(e){if(e)return e.options.allowProjection!==!1?e.projection:_t(e.parent)}function K(e,{forwardMotionProps:t=!1,type:n}={},s,o){s&&$e(s);const i=n?n==="svg":at(e),r=i?rn:on;function a(p,d){let l;const c={...u.useContext(j),...p,layoutId:fn(p)},{isStatic:m}=c,f=qe(p),g=r(p,m);if(!m&&typeof window<"u"){hn();const v=dn(c);l=v.MeasureLayout,f.visualElement=cn(e,g,c,o,v.ProjectionNode,i)}return V.jsxs(_.Provider,{value:f,children:[l&&f.visualElement?V.jsx(l,{visualElement:f.visualElement,...c}):null,en(e,p,un(g,f.visualElement,d),g,m,t,i)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const h=u.forwardRef(a);return h[an]=e,h}function fn({layoutId:e}){const t=u.useContext(ot).id;return t&&e!==void 0?t+"-"+e:e}function hn(e,t){u.useContext(Wt).strict}function dn(e){const t=Ht(),{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 mn(e,t){if(typeof Proxy>"u")return K;const n=new Map,s=(i,r)=>K(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,K(r,void 0,e,t)),n.get(r))})}const pn=(e,t)=>t.isSVG??at(e)?new he(t):new de(t,{allowProjection:e!==u.Fragment});class gn extends b{constructor(t){super(t),t.animationState||(t.animationState=me(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Rt(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 vn=0;class yn extends b{constructor(){super(...arguments),this.id=vn++,this.isExitComplete=!1}update(){var i;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;if(t&&s===!1){if(this.isExitComplete){const{initial:r,custom:a}=this.node.getProps();if(typeof r=="string"){const h=pe(this.node,r,a);if(h){const{transition:p,transitionEnd:d,...l}=h;for(const c in l)(i=this.node.getValue(c))==null||i.jump(l[c])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const o=this.node.animationState.setActive("exit",!t);n&&!t&&o.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const Pn={animation:{Feature:gn},exit:{Feature:yn}};function F(e){return{point:{x:e.pageX,y:e.pageY}}}const xn=e=>t=>kt(t)&&e(t,F(t));function k(e,t,n,s){return B(e,t,xn(n),s)}const Xt=({current:e})=>e?e.ownerDocument.defaultView:null,xt=(e,t)=>Math.abs(e-t);function wn(e,t){const n=xt(e.x,t.x),s=xt(e.y,t.y);return Math.sqrt(n**2+s**2)}const wt=new Set(["auto","scroll"]);class Yt{constructor(t,n,{transformPagePoint:s,contextWindow:o=window,dragSnapToOrigin:i=!1,distanceThreshold:r=3,element:a}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=m=>{this.handleScroll(m.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=O(this.lastRawMoveEventInfo,this.transformPagePoint));const m=J(this.lastMoveEventInfo,this.history),f=this.startEvent!==null,g=wn(m.offset,{x:0,y:0})>=this.distanceThreshold;if(!f&&!g)return;const{point:v}=m,{timestamp:y}=lt;this.history.push({...v,timestamp:y});const{onStart:P,onMove:x}=this.handlers;f||(P&&P(this.lastMoveEvent,m),this.startEvent=this.lastMoveEvent),x&&x(this.lastMoveEvent,m)},this.handlePointerMove=(m,f)=>{this.lastMoveEvent=m,this.lastRawMoveEventInfo=f,this.lastMoveEventInfo=O(f,this.transformPagePoint),S.update(this.updatePoint,!0)},this.handlePointerUp=(m,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=J(m.type==="pointercancel"?this.lastMoveEventInfo:O(f,this.transformPagePoint),this.history);this.startEvent&&g&&g(m,P),v&&v(m,P)},!kt(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=s,this.distanceThreshold=r,this.contextWindow=o||window;const h=F(t),p=O(h,this.transformPagePoint),{point:d}=p,{timestamp:l}=lt;this.history=[{...d,timestamp:l}];const{onSessionStart:c}=n;c&&c(t,J(p,this.history)),this.removeListeners=jt(k(this.contextWindow,"pointermove",this.handlePointerMove),k(this.contextWindow,"pointerup",this.handlePointerUp),k(this.contextWindow,"pointercancel",this.handlePointerUp)),a&&this.startScrollTracking(a)}startScrollTracking(t){let n=t.parentElement;for(;n;){const s=getComputedStyle(n);(wt.has(s.overflowX)||wt.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}),window.addEventListener("scroll",this.onWindowScroll),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(),Ft(this.updatePoint)}}function O(e,t){return t?{point:t(e.point)}:e}function Ct(e,t){return{x:e.x-t.x,y:e.y-t.y}}function J({point:e},t){return{point:e,delta:Ct(e,qt(t)),offset:Ct(e,Cn(t)),velocity:En(t,.1)}}function Cn(e){return e[0]}function qt(e){return e[e.length-1]}function En(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,s=null;const o=qt(e);for(;n>=0&&(s=e[n],!(o.timestamp-s.timestamp>ft(t)));)n--;if(!s)return{x:0,y:0};s===e[0]&&e.length>2&&o.timestamp-s.timestamp>ft(t)*2&&(s=e[1]);const i=ge(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 Sn(e,{min:t,max:n},s){return t!==void 0&&e<t?e=s?U(t,e,s.min):Math.max(e,t):n!==void 0&&e>n&&(e=s?U(n,e,s.max):Math.min(e,n)),e}function Et(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 Mn(e,{top:t,left:n,bottom:s,right:o}){return{x:Et(e.x,n,o),y:Et(e.y,t,s)}}function St(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 Vn(e,t){return{x:St(e.x,t.x),y:St(e.y,t.y)}}function An(e,t){let n=.5;const s=et(e),o=et(t);return o>s?n=ht(t.min,t.max-s,e.min):s>o&&(n=ht(e.min,e.max-o,t.min)),ve(0,1,n)}function bn(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 nt=.35;function Ln(e=nt){return e===!1?e=0:e===!0&&(e=nt),{x:Mt(e,"left","right"),y:Mt(e,"top","bottom")}}function Mt(e,t,n){return{min:Vt(e,t),max:Vt(e,n)}}function Vt(e,t){return typeof e=="number"?e:e[t]||0}const Dn=new WeakMap;class In{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=ye(),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=l=>{n&&this.snapToCursor(F(l).point),this.stopAnimation()},r=(l,c)=>{const{drag:m,dragPropagation:f,onDragStart:g}=this.getProps();if(m&&!f&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Ee(m),!this.openDragLock))return;this.latestPointerEvent=l,this.latestPanInfo=c,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),A(y=>{let P=this.getAxisMotionValue(y).get()||0;if(Se.test(P)){const{projection:x}=this.visualElement;if(x&&x.layout){const w=x.layout.layoutBox[y];w&&(P=et(w)*(parseFloat(P)/100))}}this.originPoint[y]=P}),g&&S.update(()=>g(l,c),!1,!0),dt(this.visualElement,"transform");const{animationState:v}=this.visualElement;v&&v.setActive("whileDrag",!0)},a=(l,c)=>{this.latestPointerEvent=l,this.latestPanInfo=c;const{dragPropagation:m,dragDirectionLock:f,onDirectionLock:g,onDrag:v}=this.getProps();if(!m&&!this.openDragLock)return;const{offset:y}=c;if(f&&this.currentDirection===null){this.currentDirection=Rn(y),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",c.point,y),this.updateAxis("y",c.point,y),this.visualElement.render(),v&&S.update(()=>v(l,c),!1,!0)},h=(l,c)=>{this.latestPointerEvent=l,this.latestPanInfo=c,this.stop(l,c),this.latestPointerEvent=null,this.latestPanInfo=null},p=()=>{const{dragSnapToOrigin:l}=this.getProps();(l||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:d}=this.getProps();this.panSession=new Yt(t,{onSessionStart:i,onStart:r,onMove:a,onSessionEnd:h,resumeAnimation:p},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:s,contextWindow:Xt(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:a}=this.getProps();a&&S.postRender(()=>a(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||!W(t,o,this.currentDirection))return;const i=this.getAxisMotionValue(t);let r=this.originPoint[t]+s[t];this.constraints&&this.constraints[t]&&(r=Sn(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&&R(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&s?this.constraints=Mn(s.layoutBox,t):this.constraints=!1,this.elastic=Ln(n),o!==this.constraints&&!R(t)&&s&&this.constraints&&!this.hasMutatedConstraints&&A(r=>{this.constraints!==!1&&this.getAxisMotionValue(r)&&(this.constraints[r]=bn(s.layoutBox[r],this.constraints[r]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!R(t))return!1;const s=t.current,{projection:o}=this.visualElement;if(!o||!o.layout)return!1;const i=Pe(s,o.root,this.visualElement.getTransformPagePoint());let r=Vn(o.layout.layoutBox,i);if(n){const a=n(xe(r));this.hasMutatedConstraints=!!a,a&&(r=we(a))}return r}startAnimation(t){const{drag:n,dragMomentum:s,dragElastic:o,dragTransition:i,dragSnapToOrigin:r,onDragTransitionEnd:a}=this.getProps(),h=this.constraints||{},p=A(d=>{if(!W(d,n,this.currentDirection))return;let l=h&&h[d]||{};(r===!0||r===d)&&(l={min:0,max:0});const c=o?200:1e6,m=o?40:1e7,f={type:"inertia",velocity:s?t[d]:0,bounceStiffness:c,bounceDamping:m,timeConstant:750,restDelta:1,restSpeed:10,...i,...l};return this.startAxisValueAnimation(d,f)});return Promise.all(p).then(a)}startAxisValueAnimation(t,n){const s=this.getAxisMotionValue(t);return dt(this.visualElement,t),s.start(Ce(t,s,0,n,this.visualElement,!1))}stopAnimation(){A(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){A(n=>{const{drag:s}=this.getProps();if(!W(n,s,this.currentDirection))return;const{projection:o}=this.visualElement,i=this.getAxisMotionValue(n);if(o&&o.layout){const{min:r,max:a}=o.layout.layoutBox[n],h=i.get()||0;i.set(t[n]-U(r,a,.5)+h)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:s}=this.visualElement;if(!R(n)||!s||!this.constraints)return;this.stopAnimation();const o={x:0,y:0};A(r=>{const a=this.getAxisMotionValue(r);if(a&&this.constraints!==!1){const h=a.get();o[r]=An({min:h,max:h},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(),A(r=>{if(!W(r,t,null))return;const a=this.getAxisMotionValue(r),{min:h,max:p}=this.constraints[r];a.set(U(h,p,o[r]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Dn.set(this.visualElement,this);const t=this.visualElement.current,n=k(t,"pointerdown",p=>{const{drag:d,dragListener:l=!0}=this.getProps(),c=p.target,m=c!==t&&Me(c);d&&l&&!m&&this.start(p)});let s;const o=()=>{const{dragConstraints:p}=this.getProps();R(p)&&p.current&&(this.constraints=this.resolveRefConstraints(),s||(s=Tn(t,p.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 a=B(window,"resize",()=>this.scalePositionWithinConstraints()),h=i.addEventListener("didUpdate",(({delta:p,hasLayoutChanged:d})=>{this.isDragging&&d&&(A(l=>{const c=this.getAxisMotionValue(l);c&&(this.originPoint[l]+=p[l].translate,c.set(c.get()+p[l].translate))}),this.visualElement.render())}));return()=>{a(),n(),r(),h&&h(),s&&s()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:s=!1,dragPropagation:o=!1,dragConstraints:i=!1,dragElastic:r=nt,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:s,dragPropagation:o,dragConstraints:i,dragElastic:r,dragMomentum:a}}}function At(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Tn(e,t,n){const s=mt(e,At(n)),o=mt(t,At(n));return()=>{s(),o()}}function W(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Rn(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class kn extends b{constructor(t){super(t),this.removeGroupControls=H,this.removeListeners=H,this.controls=new In(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||H}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 Z=e=>(t,n)=>{e&&S.update(()=>e(t,n),!1,!0)};class jn extends b{constructor(){super(...arguments),this.removePointerDownListener=H}onPointerDown(t){this.session=new Yt(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Xt(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:s,onPanEnd:o}=this.node.getProps();return{onSessionStart:Z(t),onStart:Z(n),onMove:Z(s),onEnd:(i,r)=>{delete this.session,o&&S.postRender(()=>o(i,r))}}}mount(){this.removePointerDownListener=k(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 Q=!1;class Fn extends u.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),Q&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Ae.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}),Q=!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 a=r.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:s}=t;s&&(s.options.layoutAnchor=n,s.root.didUpdate(),Ve.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:s}=this.props,{projection:o}=t;Q=!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 Kt(e){const[t,n]=Ot(),s=u.useContext(ot);return V.jsx(Fn,{...e,layoutGroup:s,switchLayoutGroup:u.useContext(zt),isPresent:t,safeToRemove:n})}const Gn={pan:{Feature:jn},drag:{Feature:kn,ProjectionNode:Gt,MeasureLayout:Kt}};function bt(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,F(t)))}class On extends b{mount(){const{current:t}=this.node;t&&(this.unmount=be(t,(n,s)=>(bt(this.node,s,"Start"),o=>bt(this.node,o,"End"))))}unmount(){}}class Wn extends b{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=jt(B(this.node.current,"focus",()=>this.onFocus()),B(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Lt(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,F(t)))}class Hn extends b{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:s}=this.node.props;this.unmount=Le(t,(o,i)=>(Lt(this.node,i,"Start"),(r,{success:a})=>Lt(this.node,r,a?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(s==null?void 0:s.tap)===!1})}unmount(){}}const st=new WeakMap,tt=new WeakMap,Bn=e=>{const t=st.get(e.target);t&&t(e)},Un=e=>{e.forEach(Bn)};function Nn({root:e,...t}){const n=e||document;tt.has(n)||tt.set(n,{});const s=tt.get(n),o=JSON.stringify(t);return s[o]||(s[o]=new IntersectionObserver(Un,{root:e,...t})),s[o]}function $n(e,t,n){const s=Nn(t);return st.set(e,n),s.observe(e),()=>{st.delete(e),s.unobserve(e)}}const zn={some:0,all:1};class _n extends b{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var h;(h=this.stopObserver)==null||h.call(this);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:zn[o]},a=p=>{const{isIntersecting:d}=p;if(this.isInView===d||(this.isInView=d,i&&!d&&this.hasEnteredView))return;d&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",d);const{onViewportEnter:l,onViewportLeave:c}=this.node.getProps(),m=d?l:c;m&&m(p)};this.stopObserver=$n(this.node.current,r,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(Xn(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function Xn({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Yn={inView:{Feature:_n},tap:{Feature:Hn},focus:{Feature:Wn},hover:{Feature:On}},qn={layout:{ProjectionNode:Gt,MeasureLayout:Kt}},Kn={...Pn,...Yn,...Gn,...qn},ss=mn(Kn,pn);function Jt(e){const t=D(()=>De(e)),{isStatic:n}=u.useContext(j);if(n){const[,s]=u.useState(e);u.useEffect(()=>t.on("change",s),[])}return t}function Zt(e,t){const n=Jt(t()),s=()=>n.set(t());return s(),it(()=>{const o=()=>S.preRender(s,!1,!0),i=e.map(r=>r.on("change",o));return()=>{i.forEach(r=>r()),Ft(s)}}),n}function Jn(e){q.current=[],e();const t=Zt(q.current,e);return q.current=void 0,t}function Qt(e,t,n,s){if(typeof e=="function")return Jn(e);if(n!==void 0&&!Array.isArray(n)&&typeof t!="function")return Zn(e,t,n,s);const r=typeof t=="function"?t:Ie(t,n,s),a=Array.isArray(e)?Dt(e,r):Dt([e],([p])=>r(p)),h=Array.isArray(e)?void 0:e.accelerate;return h&&!h.isTransformed&&typeof t!="function"&&Array.isArray(n)&&(s==null?void 0:s.clamp)!==!1&&(a.accelerate={...h,times:t,keyframes:n,isTransformed:!0}),a}function Dt(e,t){const n=D(()=>[]);return Zt(e,()=>{n.length=0;const s=e.length;for(let o=0;o<s;o++)n[o]=e[o].get();return t(n)})}function Zn(e,t,n,s){const o=D(()=>Object.keys(n)),i=D(()=>({}));for(const r of o)i[r]=Qt(e,t,n[r],s);return i}function Qn(e,t={}){const{isStatic:n}=u.useContext(j),s=()=>$(e)?e.get():e;if(n)return Qt(s);const o=Jt(s());return u.useInsertionEffect(()=>Te(o,e,t),[o,JSON.stringify(t)]),o}function os(e,t={}){return Qn(e,{type:"spring",...t})}function is(){!Re.current&&ke();const[e]=u.useState(je.current);return e}export{ns as A,Qt as a,is as b,Jt as c,ss as m,os as u};
|