%PDF- %PDF-
| Direktori : /home/vacivi36/.trash/vacivitta/node_modules/motion-dom/dist/ |
| Current File : /home/vacivi36/.trash/vacivitta/node_modules/motion-dom/dist/size-rollup-style-effect.js |
const t=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],e=(()=>new Set(t))();const s={};class n{constructor(){this.subscriptions=[]}add(t){var e,s;return e=this.subscriptions,s=t,-1===e.indexOf(s)&&e.push(s),()=>function(t,e){const s=t.indexOf(e);s>-1&&t.splice(s,1)}(this.subscriptions,t)}notify(t,e,s){const n=this.subscriptions.length;if(n)if(1===n)this.subscriptions[0](t,e,s);else for(let r=0;r<n;r++){const n=this.subscriptions[r];n&&n(t,e,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const r=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],i={value:null,addProjectionMetrics:null};function a(t,e){let n=!1,a=!0;const o={delta:0,timestamp:0,isProcessing:!1},c=()=>n=!0,h=r.reduce(((t,s)=>(t[s]=function(t,e){let s=new Set,n=new Set,r=!1,a=!1;const o=new WeakSet;let c={delta:0,timestamp:0,isProcessing:!1},h=0;function d(e){o.has(e)&&(p.schedule(e),t()),h++,e(c)}const p={schedule:(t,e=!1,i=!1)=>{const a=i&&r?s:n;return e&&o.add(t),a.has(t)||a.add(t),t},cancel:t=>{n.delete(t),o.delete(t)},process:t=>{c=t,r?a=!0:(r=!0,[s,n]=[n,s],s.forEach(d),e&&i.value&&i.value.frameloop[e].push(h),h=0,s.clear(),r=!1,a&&(a=!1,p.process(t)))}};return p}(c,e?s:void 0),t)),{}),{setup:d,read:p,resolveKeyframes:u,preUpdate:l,update:f,preRender:m,render:v,postRender:g}=h,y=()=>{const r=s.useManualTiming?o.timestamp:performance.now();n=!1,s.useManualTiming||(o.delta=a?1e3/60:Math.max(Math.min(r-o.timestamp,40),1)),o.timestamp=r,o.isProcessing=!0,d.process(o),p.process(o),u.process(o),l.process(o),f.process(o),m.process(o),v.process(o),g.process(o),o.isProcessing=!1,n&&e&&(a=!1,t(y))};return{schedule:r.reduce(((e,s)=>{const r=h[s];return e[s]=(e,s=!1,i=!1)=>(n||(n=!0,a=!0,o.isProcessing||t(y)),r.schedule(e,s,i)),e}),{}),cancel:t=>{for(let e=0;e<r.length;e++)h[r[e]].cancel(t)},state:o,steps:h}}const{schedule:o,cancel:c,state:h,steps:d}=a("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:t=>t,!0);let p;function u(){p=void 0}const l={now:()=>(void 0===p&&l.set(h.isProcessing||s.useManualTiming?h.timestamp:performance.now()),p),set:t=>{p=t,queueMicrotask(u)}};class f{constructor(t,e={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=(t,e=!0)=>{const s=l.now();if(this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(t),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const t of this.dependents)t.dirty();e&&this.events.renderRequest?.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=e.owner}setCurrent(t){var e;this.current=t,this.updatedAt=l.now(),null===this.canTrackVelocity&&void 0!==t&&(this.canTrackVelocity=(e=this.current,!isNaN(parseFloat(e))))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,e){this.events[t]||(this.events[t]=new n);const s=this.events[t].add(e);return"change"===t?()=>{s(),o.read((()=>{this.events.change.getSize()||this.stop()}))}:s}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,e){this.passiveEffect=t,this.stopPassiveEffect=e}set(t,e=!0){e&&this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t,e)}setWithVelocity(t,e,s){this.set(e),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,e=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,e&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=l.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;const e=Math.min(this.updatedAt-this.prevUpdatedAt,30);return s=parseFloat(this.current)-parseFloat(this.prevFrameValue),(n=e)?s*(1e3/n):0;var s,n}start(t){return this.stop(),new Promise((e=>{this.hasAnimated=!0,this.animation=t(e),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()}}const m={test:t=>"number"==typeof t,parse:parseFloat,transform:t=>t},v={...m,transform:t=>((t,e,s)=>s>e?e:s<t?t:s)(0,1,t)},g={...m,default:1},y={...m,transform:Math.round},w=t=>({test:e=>"string"==typeof e&&e.endsWith(t)&&1===e.split(" ").length,parse:parseFloat,transform:e=>`${e}${t}`}),A=w("deg"),b=w("%"),P=w("px"),R=(()=>({...b,parse:t=>b.parse(t)/100,transform:t=>b.transform(100*t)}))(),k={borderWidth:P,borderTopWidth:P,borderRightWidth:P,borderBottomWidth:P,borderLeftWidth:P,borderRadius:P,radius:P,borderTopLeftRadius:P,borderTopRightRadius:P,borderBottomRightRadius:P,borderBottomLeftRadius:P,width:P,maxWidth:P,height:P,maxHeight:P,top:P,right:P,bottom:P,left:P,padding:P,paddingTop:P,paddingRight:P,paddingBottom:P,paddingLeft:P,margin:P,marginTop:P,marginRight:P,marginBottom:P,marginLeft:P,backgroundPositionX:P,backgroundPositionY:P,...{rotate:A,rotateX:A,rotateY:A,rotateZ:A,scale:g,scaleX:g,scaleY:g,scaleZ:g,skew:A,skewX:A,skewY:A,distance:P,translateX:P,translateY:P,translateZ:P,x:P,y:P,z:P,perspective:P,transformPerspective:P,opacity:v,originX:R,originY:R,originZ:P},zIndex:y,fillOpacity:v,strokeOpacity:v,numOctaves:y};class F{constructor(){this.latest={},this.values=new Map}set(t,e,s,n){const r=this.values.get(t);r&&r.onRemove();const i=()=>{this.latest[t]=((t,e)=>e&&"number"==typeof t?e.transform(t):t)(e.get(),k[t]),s&&o.render(s)};i();const a=e.on("change",i);n&&e.addDependent(n);const h=()=>{a(),s&&c(s),this.values.delete(t),n&&e.removeDependent(n)};return this.values.set(t,{value:e,onRemove:h}),h}get(t){return this.values.get(t)?.value}destroy(){for(const t of this.values.values())t.onRemove()}}const T={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"};const V=new WeakMap;function W(t,e){const s=function(t,e,s){if(t instanceof EventTarget)return[t];if("string"==typeof t){let n=document;e&&(n=e.current);const r=s?.[t]??n.querySelectorAll(t);return r?Array.from(r):[]}return Array.from(t)}(t),n=[];for(let t=0;t<s.length;t++){const r=s[t],i=V.get(r)??new F;V.set(r,i);for(const t in e){const s=x(r,i,t,e[t]);n.push(s)}}return()=>{for(const t of n)t()}}function x(s,n,r,i){let a,o;return e.has(r)?(n.get("transform")||n.set("transform",new f("none"),(()=>{s.style.transform=function(e){let s="",n=!0;for(let r=0;r<t.length;r++){const i=t[r],a=e.latest[i];if(void 0===a)continue;let o=!0;o="number"==typeof a?a===(i.startsWith("scale")?1:0):0===parseFloat(a),o||(n=!1,s+=`${T[i]||i}(${e.latest[i]}) `)}return n?"none":s.trim()}(n)})),o=n.get("transform")):a=r.startsWith("--")?()=>{s.style.setProperty(r,n.latest[r])}:()=>{s.style[r]=n.latest[r]},n.set(r,i,a,o)}export{W as styleEffect};