@zag-js/slider 0.0.0-dev-20220412162814 → 0.0.0-dev-20220412212252

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/README.md CHANGED
@@ -12,10 +12,8 @@ npm i @zag-js/slider
12
12
 
13
13
  ## Contribution
14
14
 
15
- Yes please! See the [contributing guidelines](https://github.com/chakra-ui/ui-machines/blob/main/CONTRIBUTING.md) for
16
- details.
15
+ Yes please! See the [contributing guidelines](https://github.com/chakra-ui/zag/blob/main/CONTRIBUTING.md) for details.
17
16
 
18
17
  ## Licence
19
18
 
20
- This project is licensed under the terms of the
21
- [MIT license](https://github.com/chakra-ui/ui-machines/blob/main/LICENSE).
19
+ This project is licensed under the terms of the [MIT license](https://github.com/chakra-ui/zag/blob/main/LICENSE).
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var k=Object.defineProperty,ht=Object.defineProperties,vt=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertyNames,_=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,bt=Object.prototype.propertyIsEnumerable;var U=(t,e,n)=>e in t?k(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,O=(t,e)=>{for(var n in e||(e={}))j.call(e,n)&&U(t,n,e[n]);if(_)for(var n of _(e))bt.call(e,n)&&U(t,n,e[n]);return t},V=(t,e)=>ht(t,gt(e)),wt=t=>k(t,"__esModule",{value:!0});var Et=(t,e)=>{for(var n in e)k(t,n,{get:e[n],enumerable:!0})},xt=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of yt(e))!j.call(t,o)&&(n||o!=="default")&&k(t,o,{get:()=>e[o],enumerable:!(r=vt(e,o))||r.enumerable});return t};var Tt=(t=>(e,n)=>t&&t.get(e)||(n=xt(wt({}),e,1),t&&t.set(e,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var he={};Et(he,{connect:()=>ft,machine:()=>pt,unstable__dom:()=>a});var Y=Math.pow,d=t=>t?"":void 0;function P(t){let e=new Set;function n(r){let o=globalThis.requestAnimationFrame(r);e.add(()=>globalThis.cancelAnimationFrame(o))}return n(()=>n(t)),function(){e.forEach(function(r){r()})}}function $(t){let e=globalThis.requestAnimationFrame(t);return function(){globalThis.cancelAnimationFrame(e)}}var Pt=()=>{},kt=(...t)=>e=>t.reduce((n,r)=>r(n),e),ge=(()=>{let t=0;return()=>(t++,t.toString(36))})(),N=t=>St()&&t.test(navigator.platform),St=()=>typeof window!="undefined",Mt=()=>N(/^Mac/),At=()=>N(/^iPhone/),Ct=()=>N(/^iPad/)||Mt()&&navigator.maxTouchPoints>1,X=()=>At()||Ct(),Lt=t=>Array.isArray(t),It=t=>!(t==null||typeof t!="object"||Lt(t)),Rt=t=>It(t)&&"button"in t,Ot=t=>t.button===0,E=new Map,b=new Map;function Vt(t,e,n,r){var o;if(!t)return Pt;let i=JSON.stringify({type:e,options:r}),s=E.get(t);if(E.has(t))(s==null?void 0:s.has(i))?(o=s==null?void 0:s.get(i))==null||o.add(n):s==null||s.set(i,new Set([n]));else{let l=new Map([[i,new Set([n])]]);E.set(t,l)}function y(l){var m,f;function v(p){var u;let c=E.get(l);(u=c==null?void 0:c.get(i))==null||u.forEach(h=>h(p))}if(!(b==null?void 0:b.has(l))){b.set(l,new Map([[i,v]])),l.addEventListener(e,v,r);return}((m=b==null?void 0:b.get(l))==null?void 0:m.has(i))||((f=b.get(l))==null||f.set(i,v),l.addEventListener(e,v,r))}return y(t),function(){var l,m,f,v;if(!E.has(t))return;let p=E.get(t);if((l=p==null?void 0:p.get(i))==null||l.delete(n),((m=p==null?void 0:p.get(i))==null?void 0:m.size)===0){let u=(f=b.get(t))==null?void 0:f.get(i);t.removeEventListener(e,u,r),p==null||p.delete(i),(v=b.get(t))==null||v.delete(i),(p==null?void 0:p.size)===0&&(E.delete(t),b.delete(t))}}}var F=t=>Object.prototype.toString.call(t).slice(8,-1),Nt=t=>F(t)==="Object"&&"current"in t,Ft=t=>F(t)==="Function"?t():t,Dt=t=>F(t)==="Object"&&!!t.touches,Wt={pageX:0,pageY:0,clientX:0,clientY:0};function Ht(t,e="page"){let n=Dt(t)?t.touches[0]||t.changedTouches[0]||Wt:t;return{point:{x:n[`${e}X`],y:n[`${e}Y`]}}}function zt(t,e,n,r){let o=Nt(t)?t.current:Ft(t);return Vt(o,e,n,r)}function S(t,e,n,r){var o;let i=(o=qt(e))!=null?o:e;return zt(t,i,_t(n,e==="pointerdown"),r)}function _t(t,e=!1){let n=r=>{t(r,Ht(r))};return e?jt(n):n}function jt(t){return e=>{var n;let r=(n=e.view)!=null?n:window,o=e instanceof r.MouseEvent;(!o||o&&e.button===0)&&t(e)}}var Ut=()=>typeof window!="undefined"&&window.onpointerdown===null,Yt=()=>typeof window!="undefined"&&window.ontouchstart===null,$t=()=>typeof window!="undefined"&&window.onmousedown===null,Xt={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},Bt={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function qt(t){return Ut()?t:Yt()?Bt[t]:$t()?Xt[t]:t}function B(t){var e;return(e=t==null?void 0:t.ownerDocument.defaultView)!=null?e:window}function q(t){var e;return(e=t.nativeEvent)!=null?e:t}function K(t,e){var n;let{type:r,property:o}=e,i=B(t)[r==="input"?"HTMLInputElement":"HTMLTextAreaElement"].prototype;return(n=Object.getOwnPropertyDescriptor(i,o))!=null?n:{}}function G(t,e){var n;let r=B(t);if(!(t instanceof r.HTMLInputElement))return;(n=K(t,{type:"input",property:"value"}).set)==null||n.call(t,e);let o=new r.Event("input",{bubbles:!0});t.dispatchEvent(o)}function Z(t,e){let{fn:n,property:r,type:o}=e;if(!n||!t)return;let{get:i,set:s}=K(t,{property:r,type:o}),y=!0;return Object.defineProperty(t,r,{get(){return i==null?void 0:i.call(this)},set(l){return y&&n(l),s==null?void 0:s.call(this,l)}}),function(){y=!1}}var ye=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");function Kt(t){return Gt(t)?t.form:t.closest("form")}function Gt(t){return["textarea","input","select","button"].includes(t.localName)}function J(t,e){if(!t)return;let n=Kt(t);return n==null||n.addEventListener("reset",e,{passive:!0}),()=>{n==null||n.removeEventListener("reset",e)}}var Q={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft",Home:"End",End:"Home"},Zt={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"};function tt(t,e={}){var n;let{dir:r="ltr",orientation:o="horizontal"}=e,{key:i}=t;return i=(n=Zt[i])!=null?n:i,r==="rtl"&&o==="horizontal"&&i in Q&&(i=Q[i]),i}var Jt=new Set(["PageUp","PageDown"]),Qt=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function et(t){return t.ctrlKey||t.metaKey?.1:Jt.has(t.key)||t.shiftKey&&Qt.has(t.key)?10:1}var x="default",D="",M=new WeakMap;function te({target:t,doc:e}={}){let n=e!=null?e:document;return X()?(x==="default"&&(D=n.documentElement.style.webkitUserSelect,n.documentElement.style.webkitUserSelect="none"),x="disabled"):t&&(M.set(t,t.style.userSelect),t.style.userSelect="none"),()=>ee({target:t,doc:n})}function ee({target:t,doc:e}={}){let n=e!=null?e:document;if(X()){if(x!=="disabled")return;x="restoring",setTimeout(()=>{P(()=>{x==="restoring"&&(n.documentElement.style.webkitUserSelect==="none"&&(n.documentElement.style.webkitUserSelect=D||""),D="",x="default")})},300)}else if(t&&M.has(t)){let r=M.get(t);t.style.userSelect==="none"&&(t.style.userSelect=r!=null?r:""),t.getAttribute("style")===""&&t.removeAttribute("style"),M.delete(t)}}function nt(t){let{onPointerMove:e,onPointerUp:n,ctx:r}=t,{doc:o=document,threshold:i=5}=r;return kt(S(o,"pointermove",(s,y)=>{let{point:l}=y;if(!(Math.sqrt(Y(l.x,2)+Y(l.y,2))<i)){if(Rt(s)&&Ot(s)){n();return}e(y,s)}},!1),S(o,"pointerup",n,!1),S(o,"pointercancel",n,!1),S(o,"contextmenu",n,!1),te({doc:o}))}var ne=Math.pow;var rt=new Intl.NumberFormat("en-US",{style:"decimal"});function W(t){return parseFloat(rt.format(t))}function re(t,e){let n=w(t),r=ne(10,e!=null?e:10);return n=Math.round(n*r)/r,e?n.toFixed(e):t.toString()}var T=(t,e)=>(w(t)-e.min)*100/(e.max-e.min),A=(t,e)=>e.min+(e.max-e.min)*w(t);function C(t,e){return Math.min(Math.max(w(t),e.min),e.max)}function oe(t){var e,n;return(n=(e=rt.formatToParts(t).find(r=>r.type==="fraction"))==null?void 0:e.value.length)!=null?n:0}var ot=(t,e)=>W(w(t)+e),it=(t,e)=>W(w(t)-e),at=(t,e)=>W(w(t)*e);function H(t,e){let n=w(t),r=oe(e),o=Math.round(n/e)*e;return re(o,r)}function w(t){if(typeof t=="number")return t;let e=parseFloat(t.toString().replace(/[^\w.-]+/g,""));return Number.isNaN(e)?0:e}var L=(t,e)=>{let n={min:t[0],max:t[1]},r={min:e[0],max:e[1]};return o=>{if(n.min===n.max||r.min===r.max)return r.min;let i=(r.max-r.min)/(n.max-n.min);return r.min+i*(o-n.min)}};var Ee=(()=>{let t=0;return()=>(t++,t.toString(36))})(),ie=t=>Array.isArray(t),ae=t=>!(t==null||typeof t!="object"||ie(t)),le=t=>ae(t)&&"touches"in t;var ue={pageX:0,pageY:0,clientX:0,clientY:0};function lt(t,e="page"){let n=le(t)?t.touches[0]||t.changedTouches[0]||ue:t;return{x:n[`${e}X`],y:n[`${e}Y`]}}function ut(t,e){let n=t.x-e.offsetLeft-e.clientLeft+e.scrollLeft,r=t.y-e.offsetTop-e.clientTop+e.scrollTop;return{point:{x:n,y:r},progress:{x:n/e.offsetWidth,y:r/e.offsetHeight}}}var g={fromPercent(t,e){return e=C(e,{min:0,max:1}),parseFloat(H(A(e,t),t.step))},clamp(t,e){return C(e,t)},convert(t,e){return C(parseFloat(H(e,t.step)),t)},decrement(t,e){let n=it(t.value,e!=null?e:t.step);return g.convert(t,n)},increment(t,e){let n=ot(t.value,e!=null?e:t.step);return g.convert(t,n)}};function se(t){var r;let{height:e=0}=(r=t.thumbSize)!=null?r:{},n=L([t.min,t.max],[-e/2,e/2]);return parseFloat(n(t.value).toFixed(2))}function ce(t){var r;let{width:e=0}=(r=t.thumbSize)!=null?r:{};if(t.isRtl){let o=L([t.max,t.min],[-e*1.5,-e/2]);return-1*parseFloat(o(t.value).toFixed(2))}let n=L([t.min,t.max],[-e/2,e/2]);return parseFloat(n(t.value).toFixed(2))}function de(t){let e=T(t.value,t),n=t.isVertical?se(t):ce(t),r={visibility:t.hasMeasuredThumbSize?"visible":"hidden",position:"absolute",transform:"var(--slider-thumb-transform)","--slider-thumb-placement":`calc(${e}% - ${n}px)`};return t.isVertical?r.bottom="var(--slider-thumb-placement)":r[t.isRtl?"right":"left"]="var(--slider-thumb-placement)",r}function fe(t){let e=T(t.value,t),n={position:"absolute"},r="0%",o=`${100-e}%`;if(t.origin==="center"){let i=e<50;r=i?`${e}%`:"50%",o=i?"50%":o}return t.isVertical?V(O({},n),{bottom:r,top:o}):V(O({},n),{[t.isRtl?"right":"left"]:r,[t.isRtl?"left":"right"]:o})}function pe(t){return{touchAction:"none",userSelect:"none","--slider-thumb-transform":t.isVertical?"translateY(50%)":"translateX(-50%)",position:"relative"}}var a={getDoc:t=>{var e;return(e=t.doc)!=null?e:document},getRootId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.root)!=null?n:`slider-${t.uid}`},getThumbId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.thumb)!=null?n:`slider-${t.uid}-thumb`},getControlId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.control)!=null?n:`slider-${t.uid}-control`},getInputId:t=>`slider-${t.uid}-input`,getOutputId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.output)!=null?n:`slider-${t.uid}-output`},getTrackId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.track)!=null?n:`slider--${t.uid}track`},getRangeId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.track)!=null?n:`slider-${t.uid}-range`},getLabelId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.label)!=null?n:`slider-${t.uid}-label`},getMarkerId:(t,e)=>`slider-${t.uid}-marker-${e}`,getThumbEl:t=>a.getDoc(t).getElementById(a.getThumbId(t)),getControlEl:t=>a.getDoc(t).getElementById(a.getControlId(t)),getInputEl:t=>a.getDoc(t).getElementById(a.getInputId(t)),getControlStyle:pe,getThumbStyle:de,getRangeStyle:fe,getValueFromPoint(t,e){let n=a.getControlEl(t);if(!n)return;let{progress:r}=ut(e,n),o;return t.isHorizontal?o=t.isRtl?1-r.x:r.x:o=1-r.y,g.fromPercent(t,o)},dispatchChangeEvent(t){let e=a.getInputEl(t);!e||G(e,t.value)},getMarkerStyle(t,e){let n={position:"absolute",pointerEvents:"none"};return t.isHorizontal?(e=t.isRtl?100-e:e,n.left=`${e}%`):n.bottom=`${e}%`,n}};function me(t){return{button:t,label:t,input:t,output:t,element:t}}var st=me(t=>t);var Ie=(()=>{let t=0;return()=>(t++,t.toString(36))})();var ct=t=>t.button===0;var dt=t=>t.ctrlKey||t.altKey||t.metaKey||t.shiftKey;function ft(t,e,n=st){var v,p;let r=t.context["aria-label"],o=t.context["aria-labelledby"],i=(p=(v=t.context).getAriaValueText)==null?void 0:p.call(v,t.context.value),s=t.matches("focus"),y=t.matches("dragging"),l=t.context.disabled,m=t.context.isInteractive,f=t.context.invalid;return{isFocused:s,isDragging:y,value:t.context.value,percent:T(t.context.value,t.context),setValue(u){e({type:"SET_VALUE",value:u})},getPercentValue(u){return A(u,t.context)},focus(){var u;(u=a.getThumbEl(t.context))==null||u.focus()},increment(){e("INCREMENT")},decrement(){e("DECREMENT")},rootProps:n.element({"data-part":"root","data-disabled":d(l),"data-orientation":t.context.orientation,id:a.getRootId(t.context),dir:t.context.dir}),labelProps:n.label({"data-part":"label","data-disabled":d(l),"data-invalid":d(f),id:a.getLabelId(t.context),htmlFor:a.getInputId(t.context),onClick(u){var c;!m||(u.preventDefault(),(c=a.getThumbEl(t.context))==null||c.focus())},style:{userSelect:"none"}}),thumbProps:n.element({"data-part":"thumb",id:a.getThumbId(t.context),"data-disabled":d(l),"data-orientation":t.context.orientation,"data-focus":d(s),draggable:!1,"aria-invalid":f||void 0,"data-invalid":d(f),"aria-disabled":l||void 0,"aria-label":r,"aria-labelledby":r?void 0:o!=null?o:a.getLabelId(t.context),"aria-orientation":t.context.orientation,"aria-valuemax":t.context.max,"aria-valuemin":t.context.min,"aria-valuenow":t.context.value,"aria-valuetext":i,role:"slider",tabIndex:l?void 0:0,onBlur(){!m||e("BLUR")},onFocus(){!m||e("FOCUS")},onKeyDown(u){if(!m)return;let c=at(et(u),t.context.step),h=!0,R={ArrowUp(){e({type:"ARROW_UP",step:c}),h=t.context.isVertical},ArrowDown(){e({type:"ARROW_DOWN",step:c}),h=t.context.isVertical},ArrowLeft(){e({type:"ARROW_LEFT",step:c}),h=t.context.isHorizontal},ArrowRight(){e({type:"ARROW_RIGHT",step:c}),h=t.context.isHorizontal},PageUp(){e({type:"PAGE_UP",step:c})},PageDown(){e({type:"PAGE_DOWN",step:c})},Home(){e("HOME")},End(){e("END")}},mt=tt(u,t.context),z=R[mt];!z||(z(u),h&&(u.preventDefault(),u.stopPropagation()))},style:a.getThumbStyle(t.context)}),inputProps:n.input({"data-part":"input",type:"text",defaultValue:t.context.value,name:t.context.name,id:a.getInputId(t.context),hidden:!0}),outputProps:n.output({"data-part":"output","data-disabled":d(l),"data-invalid":d(f),id:a.getOutputId(t.context),htmlFor:a.getInputId(t.context),"aria-live":"off"}),trackProps:n.element({"data-part":"track",id:a.getTrackId(t.context),"data-disabled":d(l),"data-invalid":d(f),"data-orientation":t.context.orientation,"data-focus":d(s),style:{position:"relative"}}),rangeProps:n.element({"data-part":"range",id:a.getRangeId(t.context),"data-invalid":d(f),"data-disabled":d(l),"data-orientation":t.context.orientation,style:a.getRangeStyle(t.context)}),controlProps:n.element({"data-part":"control",id:a.getControlId(t.context),"data-disabled":d(l),"data-invalid":d(f),"data-orientation":t.context.orientation,"data-focus":d(s),onPointerDown(u){if(!m)return;let c=q(u);if(!ct(c)||dt(c))return;let h=lt(c);e({type:"POINTER_DOWN",point:h}),u.preventDefault(),u.stopPropagation()},style:a.getControlStyle(t.context)}),markerGroupProps:n.element({"data-part":"marker-group",role:"presentation","aria-hidden":!0,"data-orientation":t.context.orientation,style:{userSelect:"none",pointerEvents:"none",position:"relative"}}),getMarkerProps({value:u}){let c=T(u,t.context),h=a.getMarkerStyle(t.context,c),R=u>t.context.value?"over-value":u<t.context.value?"under-value":"at-value";return n.element({"data-part":"marker","data-orientation":t.context.orientation,id:a.getMarkerId(t.context,u),"data-value":u,"data-disabled":d(l),"data-state":R,style:h})}}}var I=require("@zag-js/core");var pt=(0,I.createMachine)({id:"slider",initial:"unknown",context:{thumbSize:null,uid:"",disabled:!1,threshold:5,dir:"ltr",origin:"start",orientation:"horizontal",initialValue:null,value:0,step:1,min:0,max:100},computed:{isHorizontal:t=>t.orientation==="horizontal",isVertical:t=>t.orientation==="vertical",isRtl:t=>t.orientation==="horizontal"&&t.dir==="rtl",isInteractive:t=>!(t.disabled||t.readonly),hasMeasuredThumbSize:t=>t.thumbSize!==null},watch:{value:["invokeOnChange","dispatchChangeEvent"]},activities:["trackFormReset","trackScriptedUpdate"],on:{SET_VALUE:{actions:"setValue"},INCREMENT:{actions:"increment"},DECREMENT:{actions:"decrement"}},states:{unknown:{on:{SETUP:{target:"idle",actions:["setupDocument","setThumbSize","checkValue"]}}},idle:{on:{POINTER_DOWN:{target:"dragging",actions:["setPointerValue","invokeOnChangeStart","focusThumb"]},FOCUS:"focus"}},focus:{entry:"focusThumb",on:{POINTER_DOWN:{target:"dragging",actions:["setPointerValue","invokeOnChangeStart","focusThumb"]},ARROW_LEFT:{guard:"isHorizontal",actions:"decrement"},ARROW_RIGHT:{guard:"isHorizontal",actions:"increment"},ARROW_UP:{guard:"isVertical",actions:"increment"},ARROW_DOWN:{guard:"isVertical",actions:"decrement"},PAGE_UP:{actions:"increment"},PAGE_DOWN:{actions:"decrement"},HOME:{actions:"setToMin"},END:{actions:"setToMax"},BLUR:"idle"}},dragging:{entry:"focusThumb",activities:"trackPointerMove",on:{POINTER_UP:{target:"focus",actions:"invokeOnChangeEnd"},POINTER_MOVE:{actions:"setPointerValue"}}}}},{guards:{isHorizontal:t=>t.isHorizontal,isVertical:t=>t.isVertical},activities:{trackScriptedUpdate(t,e,{send:n}){let r;return P(()=>{let o=a.getInputEl(t);!o||(r=Z(o,{type:"input",property:"value",fn(i){n({type:"SET_VALUE",value:parseFloat(i)})}}))}),()=>r==null?void 0:r()},trackFormReset(t){let e;return P(()=>{let n=a.getInputEl(t);!n||(e=J(n,()=>{t.initialValue!=null&&(t.value=t.initialValue)}))}),e},trackPointerMove(t,e,{send:n}){return nt({ctx:t,onPointerMove(r){n({type:"POINTER_MOVE",point:r.point})},onPointerUp(){n("POINTER_UP")}})}},actions:{setupDocument(t,e){e.doc&&(t.doc=(0,I.ref)(e.doc)),t.uid=e.id},checkValue(t){let e=g.convert(t,t.value);Object.assign(t,{value:e,initialValue:e})},invokeOnChangeStart(t){var e;(e=t.onChangeStart)==null||e.call(t,{value:t.value})},invokeOnChangeEnd(t){var e;(e=t.onChangeEnd)==null||e.call(t,{value:t.value})},invokeOnChange(t){var e;(e=t.onChange)==null||e.call(t,{value:t.value})},dispatchChangeEvent(t){a.dispatchChangeEvent(t)},setThumbSize(t){$(()=>{let e=a.getThumbEl(t);!e||(t.thumbSize={width:e.offsetWidth,height:e.offsetHeight})})},setPointerValue(t,e){let n=a.getValueFromPoint(t,e.point);n!=null&&(t.value=g.clamp(t,n))},focusThumb(t){P(()=>{var e;return(e=a.getThumbEl(t))==null?void 0:e.focus()})},decrement(t,e){t.value=g.decrement(t,e.step)},increment(t,e){t.value=g.increment(t,e.step)},setToMin(t){t.value=t.min},setToMax(t){t.value=t.max},setValue(t,e){t.value=g.convert(t,e.value)}}});module.exports=Tt(he);
1
+ var et=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var oe=(t,e)=>{for(var n in e)et(t,n,{get:e[n],enumerable:!0})},ae=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ie(e))!re.call(t,a)&&a!==n&&et(t,a,{get:()=>e[a],enumerable:!(r=ne(e,a))||r.enumerable});return t};var se=t=>ae(et({},"__esModule",{value:!0}),t);var bn={};oe(bn,{connect:()=>Wt,machine:()=>te,unstable__dom:()=>v});module.exports=se(bn);var E=t=>t?"":void 0;function F(t){let e=new Set;function n(r){let a=globalThis.requestAnimationFrame(r);e.add(()=>globalThis.cancelAnimationFrame(a))}return n(()=>n(t)),function(){e.forEach(function(r){r()})}}function gt(t){let e=globalThis.requestAnimationFrame(t);return function(){globalThis.cancelAnimationFrame(e)}}var le=()=>{},ue=(...t)=>e=>t.reduce((n,r)=>r(n),e),xn=(()=>{let t=0;return()=>(t++,t.toString(36))})(),it=t=>ce()&&t.test(navigator.platform),ce=()=>typeof window<"u",de=()=>it(/^Mac/),he=()=>it(/^iPhone/),fe=()=>it(/^iPad/)||de()&&navigator.maxTouchPoints>1,yt=()=>he()||fe(),pe=t=>Array.isArray(t),me=t=>!(t==null||typeof t!="object"||pe(t)),ve=t=>me(t)&&"button"in t,ge=t=>t.button===0,I=new Map,C=new Map;function ye(t,e,n,r){var a;if(!t)return le;let u=JSON.stringify({type:e,options:r}),m=I.get(t);if(I.has(t))m!=null&&m.has(u)?(a=m?.get(u))==null||a.add(n):m?.set(u,new Set([n]));else{let p=new Map([[u,new Set([n])]]);I.set(t,p)}function y(p){var w,b;function x(d){var l;let i=I.get(p);(l=i?.get(u))==null||l.forEach(o=>o(d))}if(!(C!=null&&C.has(p))){C.set(p,new Map([[u,x]])),p.addEventListener(e,x,r);return}(w=C?.get(p))!=null&&w.has(u)||((b=C.get(p))==null||b.set(u,x),p.addEventListener(e,x,r))}return y(t),function(){var p,w,b,x;if(!I.has(t))return;let d=I.get(t);if((p=d?.get(u))==null||p.delete(n),((w=d?.get(u))==null?void 0:w.size)===0){let l=(b=C.get(t))==null?void 0:b.get(u);t.removeEventListener(e,l,r),d?.delete(u),(x=C.get(t))==null||x.delete(u),d?.size===0&&(I.delete(t),C.delete(t))}}}var rt=t=>Object.prototype.toString.call(t).slice(8,-1),be=t=>rt(t)==="Object"&&"current"in t,we=t=>rt(t)==="Function"?t():t,xe=t=>rt(t)==="Object"&&!!t.touches,Ee={pageX:0,pageY:0,clientX:0,clientY:0};function Se(t,e="page"){let n=xe(t)?t.touches[0]||t.changedTouches[0]||Ee:t;return{point:{x:n[`${e}X`],y:n[`${e}Y`]}}}function Te(t,e,n,r){let a=be(t)?t.current:we(t);return ye(a,e,n,r)}function U(t,e,n,r){var a;let u=(a=Ie(e))!=null?a:e;return Te(t,u,Pe(n,e==="pointerdown"),r)}function Pe(t,e=!1){let n=r=>{t(r,Se(r))};return e?Ae(n):n}function Ae(t){return e=>{var n;let r=(n=e.view)!=null?n:window,a=e instanceof r.MouseEvent;(!a||a&&e.button===0)&&t(e)}}var ke=()=>typeof window<"u"&&window.onpointerdown===null,Me=()=>typeof window<"u"&&window.ontouchstart===null,Ce=()=>typeof window<"u"&&window.onmousedown===null,Le={pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointercancel:"mousecancel",pointerover:"mouseover",pointerout:"mouseout",pointerenter:"mouseenter",pointerleave:"mouseleave"},Oe={pointerdown:"touchstart",pointermove:"touchmove",pointerup:"touchend",pointercancel:"touchcancel"};function Ie(t){return ke()?t:Me()?Oe[t]:Ce()?Le[t]:t}function bt(t){var e;return(e=t?.ownerDocument.defaultView)!=null?e:window}function wt(t){var e;return(e=t.nativeEvent)!=null?e:t}function xt(t,e){var n;let{type:r,property:a}=e,u=bt(t)[r==="input"?"HTMLInputElement":"HTMLTextAreaElement"].prototype;return(n=Object.getOwnPropertyDescriptor(u,a))!=null?n:{}}function Et(t,e){var n;let r=bt(t);if(!(t instanceof r.HTMLInputElement))return;(n=xt(t,{type:"input",property:"value"}).set)==null||n.call(t,e);let a=new r.Event("input",{bubbles:!0});t.dispatchEvent(a)}function St(t,e){let{fn:n,property:r,type:a}=e;if(!n||!t)return;let{get:u,set:m}=xt(t,{property:r,type:a}),y=!0;return Object.defineProperty(t,r,{get(){return u?.call(this)},set(p){return y&&n(p),m?.call(this,p)}}),function(){y=!1}}var En=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");function Re(t){return Ne(t)?t.form:t.closest("form")}function Ne(t){return["textarea","input","select","button"].includes(t.localName)}function Tt(t,e){if(!t)return;let n=Re(t);return n?.addEventListener("reset",e,{passive:!0}),()=>{n?.removeEventListener("reset",e)}}var vt={ArrowLeft:"ArrowRight",ArrowRight:"ArrowLeft",Home:"End",End:"Home"},Ve={Up:"ArrowUp",Down:"ArrowDown",Esc:"Escape"," ":"Space",",":"Comma",Left:"ArrowLeft",Right:"ArrowRight"};function Pt(t,e={}){var n;let{dir:r="ltr",orientation:a="horizontal"}=e,{key:u}=t;return u=(n=Ve[u])!=null?n:u,r==="rtl"&&a==="horizontal"&&u in vt&&(u=vt[u]),u}var De=new Set(["PageUp","PageDown"]),We=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function At(t){return t.ctrlKey||t.metaKey?.1:De.has(t.key)||t.shiftKey&&We.has(t.key)?10:1}var N="default",nt="",$=new WeakMap;function je({target:t,doc:e}={}){let n=e??document;return yt()?(N==="default"&&(nt=n.documentElement.style.webkitUserSelect,n.documentElement.style.webkitUserSelect="none"),N="disabled"):t&&($.set(t,t.style.userSelect),t.style.userSelect="none"),()=>Fe({target:t,doc:n})}function Fe({target:t,doc:e}={}){let n=e??document;if(yt()){if(N!=="disabled")return;N="restoring",setTimeout(()=>{F(()=>{N==="restoring"&&(n.documentElement.style.webkitUserSelect==="none"&&(n.documentElement.style.webkitUserSelect=nt||""),nt="",N="default")})},300)}else if(t&&$.has(t)){let r=$.get(t);t.style.userSelect==="none"&&(t.style.userSelect=r??""),t.getAttribute("style")===""&&t.removeAttribute("style"),$.delete(t)}}function kt(t){let{onPointerMove:e,onPointerUp:n,ctx:r}=t,{doc:a=document,threshold:u=5}=r;return ue(U(a,"pointermove",(m,y)=>{let{point:p}=y;if(!(Math.sqrt(p.x**2+p.y**2)<u)){if(ve(m)&&ge(m)){n();return}e(y,m)}},!1),U(a,"pointerup",n,!1),U(a,"pointercancel",n,!1),U(a,"contextmenu",n,!1),je({doc:a}))}var Mt=new Intl.NumberFormat("en-US",{style:"decimal"});function ot(t){return parseFloat(Mt.format(t))}function He(t,e){let n=L(t),r=10**(e??10);return n=Math.round(n*r)/r,e?n.toFixed(e):t.toString()}var V=(t,e)=>(L(t)-e.min)*100/(e.max-e.min),Y=(t,e)=>e.min+(e.max-e.min)*L(t);function X(t,e){return Math.min(Math.max(L(t),e.min),e.max)}function ze(t){var e,n;return(n=(e=Mt.formatToParts(t).find(r=>r.type==="fraction"))==null?void 0:e.value.length)!=null?n:0}var Ct=(t,e)=>ot(L(t)+e),Lt=(t,e)=>ot(L(t)-e),Ot=(t,e)=>ot(L(t)*e);function at(t,e){let n=L(t),r=ze(e),a=Math.round(n/e)*e;return He(a,r)}function L(t){if(typeof t=="number")return t;let e=parseFloat(t.toString().replace(/[^\w.-]+/g,""));return Number.isNaN(e)?0:e}var K=(t,e)=>{let n={min:t[0],max:t[1]},r={min:e[0],max:e[1]};return a=>{if(n.min===n.max||r.min===r.max)return r.min;let u=(r.max-r.min)/(n.max-n.min);return r.min+u*(a-n.min)}};var Pn=(()=>{let t=0;return()=>(t++,t.toString(36))})(),_e=t=>Array.isArray(t),Be=t=>!(t==null||typeof t!="object"||_e(t)),Ue=t=>Be(t)&&"touches"in t;var $e={pageX:0,pageY:0,clientX:0,clientY:0};function It(t,e="page"){let n=Ue(t)?t.touches[0]||t.changedTouches[0]||$e:t;return{x:n[`${e}X`],y:n[`${e}Y`]}}function Rt(t,e){let n=t.x-e.offsetLeft-e.clientLeft+e.scrollLeft,r=t.y-e.offsetTop-e.clientTop+e.scrollTop;return{point:{x:n,y:r},progress:{x:n/e.offsetWidth,y:r/e.offsetHeight}}}var P={fromPercent(t,e){return e=X(e,{min:0,max:1}),parseFloat(at(Y(e,t),t.step))},clamp(t,e){return X(e,t)},convert(t,e){return X(parseFloat(at(e,t.step)),t)},decrement(t,e){let n=Lt(t.value,e!=null?e:t.step);return P.convert(t,n)},increment(t,e){let n=Ct(t.value,e!=null?e:t.step);return P.convert(t,n)}};function Ye(t){var r;let{height:e=0}=(r=t.thumbSize)!=null?r:{},n=K([t.min,t.max],[-e/2,e/2]);return parseFloat(n(t.value).toFixed(2))}function Xe(t){var r;let{width:e=0}=(r=t.thumbSize)!=null?r:{};if(t.isRtl){let a=K([t.max,t.min],[-e*1.5,-e/2]);return-1*parseFloat(a(t.value).toFixed(2))}let n=K([t.min,t.max],[-e/2,e/2]);return parseFloat(n(t.value).toFixed(2))}function Ke(t){let e=V(t.value,t),n=t.isVertical?Ye(t):Xe(t),r={visibility:t.hasMeasuredThumbSize?"visible":"hidden",position:"absolute",transform:"var(--slider-thumb-transform)","--slider-thumb-placement":`calc(${e}% - ${n}px)`};return t.isVertical?r.bottom="var(--slider-thumb-placement)":r[t.isRtl?"right":"left"]="var(--slider-thumb-placement)",r}function qe(t){let e=V(t.value,t),n={position:"absolute"},r="0%",a=`${100-e}%`;if(t.origin==="center"){let u=e<50;r=u?`${e}%`:"50%",a=u?"50%":a}return t.isVertical?{...n,bottom:r,top:a}:{...n,[t.isRtl?"right":"left"]:r,[t.isRtl?"left":"right"]:a}}function Ge(t){return{touchAction:"none",userSelect:"none","--slider-thumb-transform":t.isVertical?"translateY(50%)":"translateX(-50%)",position:"relative"}}var v={getDoc:t=>{var e;return(e=t.doc)!=null?e:document},getRootId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.root)!=null?n:`slider-${t.uid}`},getThumbId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.thumb)!=null?n:`slider-${t.uid}-thumb`},getControlId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.control)!=null?n:`slider-${t.uid}-control`},getInputId:t=>`slider-${t.uid}-input`,getOutputId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.output)!=null?n:`slider-${t.uid}-output`},getTrackId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.track)!=null?n:`slider--${t.uid}track`},getRangeId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.track)!=null?n:`slider-${t.uid}-range`},getLabelId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.label)!=null?n:`slider-${t.uid}-label`},getMarkerId:(t,e)=>`slider-${t.uid}-marker-${e}`,getThumbEl:t=>v.getDoc(t).getElementById(v.getThumbId(t)),getControlEl:t=>v.getDoc(t).getElementById(v.getControlId(t)),getInputEl:t=>v.getDoc(t).getElementById(v.getInputId(t)),getControlStyle:Ge,getThumbStyle:Ke,getRangeStyle:qe,getValueFromPoint(t,e){let n=v.getControlEl(t);if(!n)return;let{progress:r}=Rt(e,n),a;return t.isHorizontal?a=t.isRtl?1-r.x:r.x:a=1-r.y,P.fromPercent(t,a)},dispatchChangeEvent(t){let e=v.getInputEl(t);!e||Et(e,t.value)},getMarkerStyle(t,e){let n={position:"absolute",pointerEvents:"none"};return t.isHorizontal?(e=t.isRtl?100-e:e,n.left=`${e}%`):n.bottom=`${e}%`,n}};function Je(t){return{button:t,label:t,input:t,output:t,element:t}}var Nt=Je(t=>t);var Vn=(()=>{let t=0;return()=>(t++,t.toString(36))})();var Vt=t=>t.button===0;var Dt=t=>t.ctrlKey||t.altKey||t.metaKey||t.shiftKey;function Wt(t,e,n=Nt){var x,d;let r=t.context["aria-label"],a=t.context["aria-labelledby"],u=(d=(x=t.context).getAriaValueText)==null?void 0:d.call(x,t.context.value),m=t.matches("focus"),y=t.matches("dragging"),p=t.context.disabled,w=t.context.isInteractive,b=t.context.invalid;return{isFocused:m,isDragging:y,value:t.context.value,percent:V(t.context.value,t.context),setValue(l){e({type:"SET_VALUE",value:l})},getPercentValue(l){return Y(l,t.context)},focus(){var l;(l=v.getThumbEl(t.context))==null||l.focus()},increment(){e("INCREMENT")},decrement(){e("DECREMENT")},rootProps:n.element({"data-part":"root","data-disabled":E(p),"data-orientation":t.context.orientation,id:v.getRootId(t.context),dir:t.context.dir}),labelProps:n.label({"data-part":"label","data-disabled":E(p),"data-invalid":E(b),id:v.getLabelId(t.context),htmlFor:v.getInputId(t.context),onClick(l){var i;!w||(l.preventDefault(),(i=v.getThumbEl(t.context))==null||i.focus())},style:{userSelect:"none"}}),thumbProps:n.element({"data-part":"thumb",id:v.getThumbId(t.context),"data-disabled":E(p),"data-orientation":t.context.orientation,"data-focus":E(m),draggable:!1,"aria-invalid":b||void 0,"data-invalid":E(b),"aria-disabled":p||void 0,"aria-label":r,"aria-labelledby":r?void 0:a!=null?a:v.getLabelId(t.context),"aria-orientation":t.context.orientation,"aria-valuemax":t.context.max,"aria-valuemin":t.context.min,"aria-valuenow":t.context.value,"aria-valuetext":u,role:"slider",tabIndex:p?void 0:0,onBlur(){!w||e("BLUR")},onFocus(){!w||e("FOCUS")},onKeyDown(l){if(!w)return;let i=Ot(At(l),t.context.step),o=!0,s={ArrowUp(){e({type:"ARROW_UP",step:i}),o=t.context.isVertical},ArrowDown(){e({type:"ARROW_DOWN",step:i}),o=t.context.isVertical},ArrowLeft(){e({type:"ARROW_LEFT",step:i}),o=t.context.isHorizontal},ArrowRight(){e({type:"ARROW_RIGHT",step:i}),o=t.context.isHorizontal},PageUp(){e({type:"PAGE_UP",step:i})},PageDown(){e({type:"PAGE_DOWN",step:i})},Home(){e("HOME")},End(){e("END")}},c=Pt(l,t.context),h=s[c];!h||(h(l),o&&(l.preventDefault(),l.stopPropagation()))},style:v.getThumbStyle(t.context)}),inputProps:n.input({"data-part":"input",type:"text",defaultValue:t.context.value,name:t.context.name,id:v.getInputId(t.context),hidden:!0}),outputProps:n.output({"data-part":"output","data-disabled":E(p),"data-invalid":E(b),id:v.getOutputId(t.context),htmlFor:v.getInputId(t.context),"aria-live":"off"}),trackProps:n.element({"data-part":"track",id:v.getTrackId(t.context),"data-disabled":E(p),"data-invalid":E(b),"data-orientation":t.context.orientation,"data-focus":E(m),style:{position:"relative"}}),rangeProps:n.element({"data-part":"range",id:v.getRangeId(t.context),"data-invalid":E(b),"data-disabled":E(p),"data-orientation":t.context.orientation,style:v.getRangeStyle(t.context)}),controlProps:n.element({"data-part":"control",id:v.getControlId(t.context),"data-disabled":E(p),"data-invalid":E(b),"data-orientation":t.context.orientation,"data-focus":E(m),onPointerDown(l){if(!w)return;let i=wt(l);if(!Vt(i)||Dt(i))return;let o=It(i);e({type:"POINTER_DOWN",point:o}),l.preventDefault(),l.stopPropagation()},style:v.getControlStyle(t.context)}),markerGroupProps:n.element({"data-part":"marker-group",role:"presentation","aria-hidden":!0,"data-orientation":t.context.orientation,style:{userSelect:"none",pointerEvents:"none",position:"relative"}}),getMarkerProps({value:l}){let i=V(l,t.context),o=v.getMarkerStyle(t.context,i),s=l>t.context.value?"over-value":l<t.context.value?"under-value":"at-value";return n.element({"data-part":"marker","data-orientation":t.context.orientation,id:v.getMarkerId(t.context,l),"data-value":l,"data-disabled":E(p),"data-state":s,style:o})}}}var tt={},Xn=Symbol(),Kn=Symbol(),Ze=Symbol(),jt=Object.getPrototypeOf,ct=new WeakMap,Qe=t=>t&&(ct.has(t)?ct.get(t):jt(t)===Object.prototype||jt(t)===Array.prototype),tn=t=>Qe(t)&&t[Ze]||null,Ft=(t,e=!0)=>{ct.set(t,e)},Kt=Symbol(),A=Symbol(),J=Symbol(),en=Symbol(),H=Symbol(),Ht=Symbol(),ft=new WeakSet;function Z(t){return ft.add(t),t}var Q=t=>typeof t=="object"&&t!==null,nn=t=>Q(t)&&!ft.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer),zt=new WeakMap,_t=1,Bt=new WeakMap;function pt(t={}){if(!Q(t))throw new Error("object required");let e=zt.get(t);if(e)return e;let n=_t,r=new Set,a=(d,l=++_t)=>{n!==l&&(n=l,r.forEach(i=>i(d,l)))},u=new Map,m=d=>{let l=u.get(d);return l||(l=(i,o)=>{let s=[...i];s[1]=[d,...s[1]],a(s,o)},u.set(d,l)),l},y=d=>{let l=u.get(d);return u.delete(d),l},p=(d,l)=>{let i=Bt.get(l);if(i?.[0]===n)return i[1];let o=Array.isArray(d)?[]:Object.create(Object.getPrototypeOf(d));return Ft(o,!0),Bt.set(l,[n,o]),Reflect.ownKeys(d).forEach(s=>{let c=Reflect.get(d,s,l);if(ft.has(c))Ft(c,!1),o[s]=c;else if(c instanceof Promise)if(H in c)o[s]=c[H];else{let h=c[Ht]||c;Object.defineProperty(o,s,{get(){if(H in c)return c[H];throw h}})}else c?.[A]?o[s]=c[J]:o[s]=c}),Object.freeze(o),o},w=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),b={get(d,l,i){return l===Kt?n:l===A?r:l===J?p(d,i):l===en?b:Reflect.get(d,l,i)},deleteProperty(d,l){let i=Reflect.get(d,l),o=i?.[A];o&&o.delete(y(l));let s=Reflect.deleteProperty(d,l);return s&&a(["delete",[l],i]),s},is:Object.is,canProxy:nn,set(d,l,i,o){var s;let c=Reflect.get(d,l,o);if(this.is(c,i))return!0;let h=c?.[A];h&&h.delete(y(l)),Q(i)&&(i=tn(i)||i);let f;return(s=Object.getOwnPropertyDescriptor(d,l))!=null&&s.set?f=i:i instanceof Promise?f=i.then(g=>(f[H]=g,a(["resolve",[l],g]),g)).catch(g=>{f[Ht]=g,a(["reject",[l],g])}):i?.[A]?(f=i,f[A].add(m(l))):this.canProxy(i)?(f=pt(i),f[A].add(m(l))):f=i,Reflect.set(d,l,f,o),a(["set",[l],i,c]),!0}},x=new Proxy(w,b);return zt.set(t,x),Reflect.ownKeys(t).forEach(d=>{let l=Object.getOwnPropertyDescriptor(t,d);l.get||l.set?Object.defineProperty(w,d,l):x[d]=t[d]}),x}function Ut(t){return Q(t)?t[Kt]:void 0}function mt(t,e,n){(tt.env&&tt.env.MODE)!=="production"&&!t?.[A]&&console.warn("Please use proxy object");let r,a=[],u=m=>{if(a.push(m),n){e(a.splice(0));return}r||(r=Promise.resolve().then(()=>{r=void 0,e(a.splice(0))}))};return t[A].add(u),()=>{t[A].delete(u)}}function rn(t){return(tt.env&&tt.env.MODE)!=="production"&&!t?.[J]&&console.warn("Please use proxy object"),t[J]}function on(t){for(;t.length>0;)t.pop();return t}var $t=(t,...e)=>(typeof t=="function"?t(...e):t)??void 0,k=t=>t,Yt=()=>{};var an=(()=>{let t=0;return()=>(t++,t.toString(36))})(),D=t=>Array.isArray(t),_=t=>!(t==null||typeof t!="object"||D(t)),sn=t=>typeof t=="number"&&!Number.isNaN(t),M=t=>typeof t=="string",dt=t=>typeof t=="function";function st(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}function lt(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}function ln(t){return _(t)&&t.predicate!=null}function ut(t,e){return(n,r)=>ln(t)?t.predicate(e??{})(n,r):t}function un(t){return _(t)&&t.predicate!=null}var cn=()=>!0;function qt(t,e){return t=t??cn,(n,r)=>{if(M(t)){let a=e?.[t];return dt(a)?a(n,r):a}return un(t)?t.predicate(e??{})(n,r):t?.(n,r)}}function z(t){var e,n,r;if(Array.isArray(t)){for(n=Array(e=t.length);e--;)n[e]=(r=t[e])&&typeof r=="object"?z(r):r;return n}if(Object.prototype.toString.call(t)==="[object Object]"){n={};for(e in t)e==="__proto__"?Object.defineProperty(n,e,{value:z(t[e]),configurable:!0,enumerable:!0,writable:!0}):n[e]=(r=t[e])&&typeof r=="object"?z(r):r;return n}return t}function Xt(t,e,n,r){return mt(t,a=>{a.some(u=>u[1][0]===e)&&n(t[e])},r)}var qn=Symbol(),R=new WeakMap,B=new WeakMap,Gt=(t,e)=>{let n=R.get(t);n&&(n[0].forEach(r=>{let{d:a}=r;t!==a&&Gt(a)}),++n[2],e&&n[3].add(e))},dn=(t,e)=>{let n=R.get(t);return n?.[2]?(n[3].add(e),!0):!1},ht=t=>{let e=R.get(t);e&&(--e[2],e[2]||(e[3].forEach(n=>n()),e[3].clear()),e[0].forEach(n=>{let{d:r}=n;t!==r&&ht(r)}))},hn=t=>{let{s:e,d:n}=t,r=B.get(n);r||(r=[new Set],B.set(t.d,r)),r[0].add(t);let a=R.get(e);if(!a){let u=new Set,m=mt(e,y=>{u.forEach(p=>{let{d:w,c:b,n:x,i:d}=p;e===w&&y.every(l=>l[1].length===1&&d.includes(l[1][0]))||p.p||(Gt(e,b),x?ht(e):p.p=Promise.resolve().then(()=>{delete p.p,ht(e)}))})},!0);a=[u,m,0,new Set],R.set(e,a)}a[0].add(t)},Jt=t=>{let{s:e,d:n}=t,r=B.get(n);r?.[0].delete(t),r?.[0].size===0&&B.delete(n);let a=R.get(e);if(a){let[u,m]=a;u.delete(t),u.size||(m(),R.delete(e))}},fn=t=>{let e=B.get(t);return e?Array.from(e[0]):[]};function pn(t,e){let n=e?.proxy||pt({}),r=!!e?.sync,a=Object.keys(t);return a.forEach(u=>{if(Object.getOwnPropertyDescriptor(n,u))throw new Error("object property already defined");let m=t[u],y=null,p=()=>{if(y&&(Array.from(y).map(([d])=>dn(d,p)).some(d=>d)||Array.from(y).every(([d,l])=>Ut(d)===l.v)))return;let w=new Map,b=m(d=>(w.set(d,{v:Ut(d)}),d)),x=()=>{w.forEach((d,l)=>{var i;let o=(i=y?.get(l))==null?void 0:i.s;if(o)d.s=o;else{let s={s:l,d:n,k:u,c:p,n:r,i:a};hn(s),d.s=s}}),y?.forEach((d,l)=>{!w.has(l)&&d.s&&Jt(d.s)}),y=w};b instanceof Promise?b.finally(x):x(),n[u]=b};p()}),n}function mn(t,e){let n=e?.delete?new Set:null;fn(t).forEach(r=>{let{k:a}=r;(!e?.keys||e.keys.includes(a))&&(Jt(r),n&&n.add(a))}),n&&n.forEach(r=>{delete t[r]})}function vn(t){var e;let n=pt({value:"",previousValue:"",event:k({}),context:(e=t.context)!=null?e:k({}),done:!1,tags:[],hasTag(r){return this.tags.includes(r)},matches(...r){return r.includes(this.value)},can(r){return k(this).nextEvents.includes(r)},get nextEvents(){var r,a,u,m;let y=(u=(a=(r=t.states)==null?void 0:r[this.value])==null?void 0:a.on)!=null?u:{},p=(m=t?.on)!=null?m:{};return Object.keys({...y,...p})},get changed(){return this.event.value==="machine.init"||!this.previousValue?!1:this.value!==this.previousValue}});return k(n)}function q(t,e){return(n,r)=>{if(sn(t))return t;if(dt(t))return t(n,r);if(M(t)){let a=Number.parseFloat(t);if(!Number.isNaN(a))return a;if(e){let u=e?.[t];if(u==null){let m=`[machine] Cannot determine delay for ${t}. It doesn't exist in options.delays`;throw new Error(m)}return dt(u)?u(n,r):u}}}}function T(t){return M(t)?{type:t}:t}function O(t){return t?D(t)?t:[t]:[]}function Zt(t){return M(t)?{target:t}:t}function gn(t,e){return(n,r)=>O(t).map(Zt).find(a=>{var u;let m=qt(a.guard,e)(n,r);return(u=m??a.target)!=null?u:a.actions})}function yn(t,e){let n=M(t)?Zt(t):t,r=a=>(a.actions&&!a.target&&e&&(a.target=e),a);if(D(n))return n.map(r);if(_(n))return r(k(n))}var G=class{constructor(t,e){this.config=t,this.status="Not Started",this.type="machine",this.activityEvents=new Map,this.delayedEvents=new Map,this.stateListeners=new Set,this.eventListeners=new Set,this.doneListeners=new Set,this.contextWatchers=new Set,this.removeStateListener=Yt,this.removeEventListener=Yt,this.children=new Map,this.start=i=>{if(this.status==="Running")return this;this.status="Running";let o=T("machine.init");if(i){let h=_(i)?i:{context:this.config.context,value:i};this.setState(h.value),this.setContext(h.context)}let s={target:i?void 0:this.config.initial},c=this.getNextStateInfo(s,o);return c.target=k(c.target||s.target),this.initialState=c,this.performStateChangeEffects(c.target,c,o),this.removeStateListener=mt(this.state,()=>{this.stateListeners.forEach(h=>{h(this.stateSnapshot)})},this.sync),this.removeEventListener=Xt(this.state,"event",h=>{this.config.onEvent&&this.executeActions(this.config.onEvent,h);for(let f of this.eventListeners)f(h)}),this.setupContextWatchers(),this.executeActivities(T("machine.start"),O(this.config.activities),"machine.start"),this.executeActions(this.config.entry,T("machine.start")),this},this.setupContextWatchers=()=>{var i;for(let[o,s]of Object.entries((i=this.config.watch)!=null?i:{}))this.contextWatchers.add(Xt(this.state.context,o,()=>{this.executeActions(s,this.state.event)}))},this.setupComputed=()=>{var i;let o=k((i=this.config.computed)!=null?i:{}),s=Object.fromEntries(Object.entries(o).map(([c,h])=>[c,f=>h(f(this.state.context))]));pn(s,{proxy:this.state.context})},this.detachComputed=()=>{mn(this.state.context,{delete:!0})},this.stop=()=>{if(this.status!=="Stopped")return this.setState(null),this.setEvent("machine.stop"),this.config.context&&this.setContext(this.config.context),this.stopStateListeners(),this.stopChildren(),this.stopActivities(),this.stopDelayedEvents(),this.stopContextWatchers(),this.stopEventListeners(),this.detachComputed(),this.status="Stopped",this.executeActions(this.config.exit,T("machine.stop")),this},this.stopEventListeners=()=>{this.eventListeners.clear(),this.removeEventListener()},this.stopStateListeners=()=>{this.removeStateListener(),this.stateListeners.clear()},this.stopContextWatchers=()=>{this.contextWatchers.forEach(i=>i()),this.contextWatchers.clear()},this.stopDelayedEvents=()=>{this.delayedEvents.forEach(i=>{i.forEach(o=>o())}),this.delayedEvents.clear()},this.stopActivities=i=>{var o,s;i?((o=this.activityEvents.get(i))==null||o.forEach(c=>c()),(s=this.activityEvents.get(i))==null||s.clear(),this.activityEvents.delete(i)):(this.activityEvents.forEach(c=>{c.forEach(h=>h()),c.clear()}),this.activityEvents.clear())},this.sendChild=(i,o)=>{let s=T(i),c=$t(o,this.contextSnapshot),h=this.children.get(c);h||lt(`[machine/send-child] Cannot send '${s.type}' event to unknown child`),h.send(s)},this.stopChild=i=>{this.children.has(i)||lt("[machine/stop-child] Cannot stop unknown child"),this.children.get(i).stop(),this.children.delete(i)},this.removeChild=i=>{this.children.delete(i)},this.stopChildren=()=>{this.children.forEach(i=>i.stop()),this.children.clear()},this.setParent=i=>{this.parent=i},this.spawn=(i,o)=>{let s=$t(i);return o&&(s.id=o),s.type="machine.actor",s.setParent(this),this.children.set(s.id,k(s)),s.onDone(()=>{this.removeChild(s.id)}).start(),k(Z(s))},this.addActivityCleanup=(i,o)=>{var s;!i||(this.activityEvents.has(i)?(s=this.activityEvents.get(i))==null||s.add(o):this.activityEvents.set(i,new Set([o])))},this.setState=i=>{this.state.previousValue=this.state.value,this.state.value=i;let o=this.getStateNode(i);i==null?on(this.state.tags):this.state.tags=O(o?.tags)},this.setContext=i=>{for(let o in i)this.state.context[o]=i[o]},this.withContext=i=>{this.detachComputed();let o={...this.config.context,...i};return new G({...this.config,context:o},this.options)},this.withOptions=i=>(this.detachComputed(),new G(this.config,{...this.options,...i})),this.setActions=i=>{this.actionMap={...this.actionMap,...i}},this.clone=()=>(this.detachComputed(),new G(this.config,this.options)),this.getStateNode=i=>{var o;if(i)return(o=this.config.states)==null?void 0:o[i]},this.getNextStateInfo=(i,o)=>{var s;let c=this.determineTransition(i,o),h=(s=c?.target)!=null?s:this.state.value,f=this.getStateNode(h);return{transition:c,stateNode:f,target:h}},this.getActionFromDelayedTransition=i=>{let o=T("machine.after"),s=q(i.delay,this.delayMap)(this.contextSnapshot,o),c;return{entry:()=>{c=globalThis.setTimeout(()=>{let h=this.state.value,f=this.getNextStateInfo(i,o);this.performStateChangeEffects(h,f,o)},s)},exit:()=>{globalThis.clearTimeout(c)}}},this.getDelayedEventActions=i=>{let o=this.getStateNode(i),s=T("machine.after");if(!o||!o.after)return;let c=[],h=[];if(D(o.after)){let f=this.determineTransition(o.after,s);if(!f)return;let g=this.getActionFromDelayedTransition(f);c.push(g.entry),h.push(g.exit)}else if(_(o.after))for(let f in o.after){let g=o.after[f],S={};if(D(g)){let j=this.determineTransition(g,s);j&&(S=j)}else M(g)?S={target:g,delay:f}:S={...g,delay:f};let W=this.getActionFromDelayedTransition(S);c.push(W.entry),h.push(W.exit)}return{entries:c,exits:h}},this.executeActions=(i,o)=>{var s;let c=ut(i,this.guardMap)(this.contextSnapshot,o);for(let h of O(c)){let f=M(h)?(s=this.actionMap)==null?void 0:s[h]:h;st(M(h)&&!f,`[machine/exec-action] No implementation found for action: \`${h}\``),f?.(this.state.context,o,this.meta)}},this.executeActivities=(i,o,s)=>{var c;for(let h of o){let f=M(h)?(c=this.activityMap)==null?void 0:c[h]:h;if(!f){st(`[machine/exec-activity] No implementation found for activity: \`${h}\``);continue}let g=f(this.state.context,i,this.meta);g&&this.addActivityCleanup(s??this.state.value,g)}},this.createEveryActivities=(i,o)=>{if(!i)return;let s=T("machine.every");if(D(i)){let c=O(i).find(f=>{let g=q(f.delay,this.delayMap);f.delay=g(this.contextSnapshot,s);let S=qt(f.guard,this.guardMap)(this.contextSnapshot,s);return S??f.delay});if(!c)return;let h=q(c.delay,this.delayMap)(this.contextSnapshot,s);o(()=>{let f=globalThis.setInterval(()=>{this.executeActions(c.actions,s)},h);return()=>{globalThis.clearInterval(f)}})}else for(let c in i){let h=i?.[c],f=q(c,this.delayMap)(this.contextSnapshot,s);o(()=>{let g=globalThis.setInterval(()=>{this.executeActions(h,s)},f);return()=>{globalThis.clearInterval(g)}})}},this.setEvent=i=>{this.state.event=Z(T(i))},this.performExitEffects=(i,o)=>{let s=this.state.value,c=i?this.getStateNode(i):void 0;this.stopActivities(s);let h=ut(c?.exit,this.guardMap)(this.contextSnapshot,o),f=O(h),g=this.delayedEvents.get(s);g&&f.push(...g),this.executeActions(f,o),this.eventListeners.clear()},this.performEntryEffects=(i,o)=>{let s=this.getStateNode(i),c=O(s?.activities);this.createEveryActivities(s?.every,S=>{c.unshift(S)}),c.length>0&&this.executeActivities(o,c);let h=ut(s?.entry,this.guardMap)(this.contextSnapshot,o),f=O(h),g=this.getDelayedEventActions(i);s?.after&&g&&(this.delayedEvents.set(i,g?.exits),f.push(...g.entries)),this.executeActions(f,o),s?.type==="final"&&(this.state.done=!0,this.doneListeners.forEach(S=>{S(this.stateSnapshot)}),this.stop())},this.performTransitionEffects=(i,o)=>{let s=this.determineTransition(i,o);this.executeActions(s?.actions,o)},this.performStateChangeEffects=(i,o,s)=>{var c,h;this.setEvent(s),o.target=(h=(c=o.target)!=null?c:this.state.value)!=null?h:void 0;let f=o.target&&o.target!==this.state.value;f&&this.performExitEffects(i,s),this.performTransitionEffects(o?.transition,s),this.setState(o.target),f&&this.performEntryEffects(o.target,s)},this.determineTransition=(i,o)=>{let s=gn(i,this.guardMap);return s?.(this.contextSnapshot,o)},this.sendParent=i=>{var o;this.parent||lt("[machine/send-parent] Cannot send event to an unknown parent");let s=T(i);(o=this.parent)==null||o.send(s)},this.send=i=>{let o=T(i);this.transition(this.state.value,o)},this.transition=(i,o)=>{var s,c,h;let f=M(i)?this.getStateNode(i):i?.stateNode,g=T(o);if(!f&&!this.config.on){let ee=this.status==="Stopped"?"[machine/transition] Cannot transition a stopped machine":"[machine/transition] State does not have a definition";st(ee);return}let S=(h=(s=f?.on)==null?void 0:s[g.type])!=null?h:(c=this.config.on)==null?void 0:c[g.type],W=yn(S,this.state.value);if(!W)return;let j=this.getNextStateInfo(W,g);return this.performStateChangeEffects(this.state.value,j,g),j.stateNode},this.subscribe=i=>(this.stateListeners.add(i),this.status==="Running"&&i(this.stateSnapshot),()=>{this.stateListeners.delete(i)}),this.onDone=i=>(this.doneListeners.add(i),this),this.onTransition=i=>(this.stateListeners.add(i),this.status==="Running"&&i(this.stateSnapshot),this),this.onEvent=i=>(i(this.state.event),this.eventListeners.add(i),this);var n,r,a,u,m,y,p,w,b,x,d;this.options=z(e),this.id=(n=t.id)!=null?n:`machine-${an()}`,this.guardMap=(a=(r=this.options)==null?void 0:r.guards)!=null?a:{},this.actionMap=(m=(u=this.options)==null?void 0:u.actions)!=null?m:{},this.delayMap=(p=(y=this.options)==null?void 0:y.delays)!=null?p:{},this.activityMap=(b=(w=this.options)==null?void 0:w.activities)!=null?b:{},this.sync=(d=(x=this.options)==null?void 0:x.sync)!=null?d:!1,this.state=vn(z(t)),this.setupComputed();let l=T("machine.created");this.executeActions(t?.created,l)}get stateSnapshot(){return k(rn(this.state))}get contextSnapshot(){return this.stateSnapshot.context}get self(){let t=this;return{id:this.id,send:this.send.bind(this),sendParent:this.sendParent.bind(this),sendChild:this.sendChild.bind(this),stop:this.stop.bind(this),stopChild:this.stopChild.bind(this),spawn:this.spawn.bind(this),get state(){return t.stateSnapshot}}}get meta(){return{state:this.stateSnapshot,guards:this.guardMap,send:this.send.bind(this),listen:this.onEvent.bind(this),self:this.self,getState:()=>this.stateSnapshot}}},Qt=(t,e)=>new G(t,e);var te=Qt({id:"slider",initial:"unknown",context:{thumbSize:null,uid:"",disabled:!1,threshold:5,dir:"ltr",origin:"start",orientation:"horizontal",initialValue:null,value:0,step:1,min:0,max:100},computed:{isHorizontal:t=>t.orientation==="horizontal",isVertical:t=>t.orientation==="vertical",isRtl:t=>t.orientation==="horizontal"&&t.dir==="rtl",isInteractive:t=>!(t.disabled||t.readonly),hasMeasuredThumbSize:t=>t.thumbSize!==null},watch:{value:["invokeOnChange","dispatchChangeEvent"]},activities:["trackFormReset","trackScriptedUpdate"],on:{SET_VALUE:{actions:"setValue"},INCREMENT:{actions:"increment"},DECREMENT:{actions:"decrement"}},states:{unknown:{on:{SETUP:{target:"idle",actions:["setupDocument","setThumbSize","checkValue"]}}},idle:{on:{POINTER_DOWN:{target:"dragging",actions:["setPointerValue","invokeOnChangeStart","focusThumb"]},FOCUS:"focus"}},focus:{entry:"focusThumb",on:{POINTER_DOWN:{target:"dragging",actions:["setPointerValue","invokeOnChangeStart","focusThumb"]},ARROW_LEFT:{guard:"isHorizontal",actions:"decrement"},ARROW_RIGHT:{guard:"isHorizontal",actions:"increment"},ARROW_UP:{guard:"isVertical",actions:"increment"},ARROW_DOWN:{guard:"isVertical",actions:"decrement"},PAGE_UP:{actions:"increment"},PAGE_DOWN:{actions:"decrement"},HOME:{actions:"setToMin"},END:{actions:"setToMax"},BLUR:"idle"}},dragging:{entry:"focusThumb",activities:"trackPointerMove",on:{POINTER_UP:{target:"focus",actions:"invokeOnChangeEnd"},POINTER_MOVE:{actions:"setPointerValue"}}}}},{guards:{isHorizontal:t=>t.isHorizontal,isVertical:t=>t.isVertical},activities:{trackScriptedUpdate(t,e,{send:n}){let r;return F(()=>{let a=v.getInputEl(t);!a||(r=St(a,{type:"input",property:"value",fn(u){n({type:"SET_VALUE",value:parseFloat(u)})}}))}),()=>r==null?void 0:r()},trackFormReset(t){let e;return F(()=>{let n=v.getInputEl(t);!n||(e=Tt(n,()=>{t.initialValue!=null&&(t.value=t.initialValue)}))}),e},trackPointerMove(t,e,{send:n}){return kt({ctx:t,onPointerMove(r){n({type:"POINTER_MOVE",point:r.point})},onPointerUp(){n("POINTER_UP")}})}},actions:{setupDocument(t,e){e.doc&&(t.doc=Z(e.doc)),t.uid=e.id},checkValue(t){let e=P.convert(t,t.value);Object.assign(t,{value:e,initialValue:e})},invokeOnChangeStart(t){var e;(e=t.onChangeStart)==null||e.call(t,{value:t.value})},invokeOnChangeEnd(t){var e;(e=t.onChangeEnd)==null||e.call(t,{value:t.value})},invokeOnChange(t){var e;(e=t.onChange)==null||e.call(t,{value:t.value})},dispatchChangeEvent(t){v.dispatchChangeEvent(t)},setThumbSize(t){gt(()=>{let e=v.getThumbEl(t);!e||(t.thumbSize={width:e.offsetWidth,height:e.offsetHeight})})},setPointerValue(t,e){let n=v.getValueFromPoint(t,e.point);n!=null&&(t.value=P.clamp(t,n))},focusThumb(t){F(()=>{var e;return(e=v.getThumbEl(t))==null?void 0:e.focus()})},decrement(t,e){t.value=P.decrement(t,e.step)},increment(t,e){t.value=P.increment(t,e.step)},setToMin(t){t.value=t.min},setToMax(t){t.value=t.max},setValue(t,e){t.value=P.convert(t,e.value)}}});
2
2
  //# sourceMappingURL=index.js.map