import{__awaiter,__generator}from"tslib"; /*! * (C) Ionic http://ionicframework.com - MIT License */import{r as registerInstance,d as createEvent,h,f as Host,i as getElement}from"./index-6e4709ff.js";import{f as findClosestIonContent,d as disableContentScrollY,r as resetContentScrollY}from"./index-5cc724f3.js";import{j as clamp,e as debounceEvent,i as inheritAriaAttributes,d as renderHiddenInput}from"./helpers-da915de8.js";import{p as printIonWarning}from"./index-9b0d46f4.js";import{i as isRTL}from"./dir-babeabeb.js";import{h as hostContext,c as createColorClasses}from"./theme-01f3f29c.js";import{b as getIonMode}from"./ionic-global-c4e0c089.js";function getDecimalPlaces(e){if(e%1===0)return 0;return e.toString().split(".")[1].length}function roundToMaxDecimalPlaces(e){var t=[];for(var r=1;r0?a:1;a=a/(t.max-t.min);if(!r){a*=-1}if(e==="A"){t.ratioA=clamp(0,t.ratioA+a,1)}else{t.ratioB=clamp(0,t.ratioB+a,1)}t.ionKnobMoveStart.emit({value:n(t.value)});t.updateValue();t.emitValueChange();t.ionKnobMoveEnd.emit({value:n(t.value)})};this.onBlur=function(){if(t.hasFocus){t.hasFocus=false;t.ionBlur.emit()}};this.onFocus=function(){if(!t.hasFocus){t.hasFocus=true;t.ionFocus.emit()}};this.ratioA=0;this.ratioB=0;this.pressedKnob=undefined;this.color=undefined;this.debounce=undefined;this.name=this.rangeId;this.label=undefined;this.dualKnobs=false;this.min=0;this.max=100;this.pin=false;this.pinFormatter=function(e){return Math.round(e)};this.snaps=false;this.step=1;this.ticks=true;this.activeBarStart=undefined;this.disabled=false;this.value=0;this.labelPlacement="start"}e.prototype.debounceChanged=function(){var e=this,t=e.ionInput,r=e.debounce,n=e.originalIonInput;this.ionInput=r===undefined?n!==null&&n!==void 0?n:t:debounceEvent(t,r)};e.prototype.minChanged=function(){if(!this.noUpdate){this.updateRatio()}};e.prototype.maxChanged=function(){if(!this.noUpdate){this.updateRatio()}};e.prototype.activeBarStartChanged=function(){var e=this.activeBarStart;if(e!==undefined){if(e>this.max){printIonWarning("Range: The value of activeBarStart (".concat(e,") is greater than the max (").concat(this.max,"). Valid values are greater than or equal to the min value and less than or equal to the max value."),this.el);this.activeBarStart=this.max}else if(e=M&&C<=I};R[k]="".concat(C*100,"%");z.push(R)}}return h("div",{class:"range-slider",ref:function(e){return t.rangeSlider=e},onPointerUp:function(e){if(t.pressedKnob===undefined){t.onStart();t.onEnd(e)}}},z.map((function(e){return h("div",{style:w(e),role:"presentation",class:{"range-tick":true,"range-tick-active":e.active},part:e.active?"tick-active":"tick"})})),h("div",{class:"range-bar-container"},h("div",{class:"range-bar",role:"presentation",part:"bar"}),h("div",{class:{"range-bar":true,"range-bar-active":true,"has-ticks":z.length>0},role:"presentation",style:y,part:"bar-active"})),renderKnob(v,{knob:"A",pressed:l==="A",value:this.valA,ratio:this.ratioA,pin:d,pinFormatter:p,disabled:b,handleKeyboard:s,min:a,max:i,inheritedAttributes:f}),this.dualKnobs&&renderKnob(v,{knob:"B",pressed:l==="B",value:this.valB,ratio:this.ratioB,pin:d,pinFormatter:p,disabled:b,handleKeyboard:s,min:a,max:i,inheritedAttributes:f}))};e.prototype.render=function(){var e;var t=this,r=t.disabled,n=t.el,a=t.hasLabel,i=t.rangeId,o=t.pin,s=t.pressedKnob,l=t.labelPlacement,b=t.label;var d=hostContext("ion-item",n);var c=a&&(l==="start"||l==="fixed")||this.hasStartSlotContent;var g=d&&!c;var p=a&&l==="end"||this.hasEndSlotContent;var f=d&&!p;var u=getIonMode(this);renderHiddenInput(true,n,this.name,JSON.stringify(this.getValue()),r);return h(Host,{key:"201677b1146738b96d74081e59d3e13a8472326e",onFocusin:this.onFocus,onFocusout:this.onBlur,id:i,class:createColorClasses(this.color,(e={},e[u]=true,e["in-item"]=d,e["range-disabled"]=r,e["range-pressed"]=s!==undefined,e["range-has-pin"]=o,e["range-label-placement-".concat(l)]=true,e["range-item-start-adjustment"]=g,e["range-item-end-adjustment"]=f,e))},h("label",{key:"055dda4f2673432e639b7efdbb01b2794c91e705",class:"range-wrapper",id:"range-label"},h("div",{key:"3efe1eda1f68810a739a42b7655f2dd71beccf1e",class:{"label-text-wrapper":true,"label-text-wrapper-hidden":!a},part:"label"},b!==undefined?h("div",{class:"label-text"},b):h("slot",{name:"label"})),h("div",{key:"31458b02c2973f4ecf4a10de4c0ae1c4befda37a",class:"native-wrapper"},h("slot",{key:"21c78b192f312396bd86bf52a0888312ffefea8a",name:"start"}),this.renderRangeSlider(),h("slot",{key:"843193879728ccfec62b4becb1b57d64b6d96804",name:"end"}))))};Object.defineProperty(e.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{debounce:["debounceChanged"],min:["minChanged"],max:["maxChanged"],activeBarStart:["activeBarStartChanged"],disabled:["disabledChanged"],value:["valueChanged"]}},enumerable:false,configurable:true});return e}();var renderKnob=function(e,t){var r=t.knob,n=t.value,a=t.ratio,i=t.min,o=t.max,s=t.disabled,l=t.pressed,b=t.pin,d=t.handleKeyboard,c=t.pinFormatter,g=t.inheritedAttributes;var p=e?"right":"left";var f=function(){var e={};e[p]="".concat(a*100,"%");return e};var u=g["aria-label"];return h("div",{onKeyDown:function(e){var t=e.key;if(t==="ArrowLeft"||t==="ArrowDown"){d(r,false);e.preventDefault();e.stopPropagation()}else if(t==="ArrowRight"||t==="ArrowUp"){d(r,true);e.preventDefault();e.stopPropagation()}},class:{"range-knob-handle":true,"range-knob-a":r==="A","range-knob-b":r==="B","range-knob-pressed":l,"range-knob-min":n===i,"range-knob-max":n===o,"ion-activatable":true,"ion-focusable":true},style:f(),role:"slider",tabindex:s?-1:0,"aria-label":u!==undefined?u:null,"aria-labelledby":u===undefined?"range-label":null,"aria-valuemin":i,"aria-valuemax":o,"aria-disabled":s?"true":null,"aria-valuenow":n},b&&h("div",{class:"range-pin",role:"presentation",part:"pin"},c(n)),h("div",{class:"range-knob",role:"presentation",part:"knob"}))};var ratioToValue=function(e,t,r,n){var a=(r-t)*e;if(n>0){a=Math.round(a/n)*n+t}var i=clamp(t,a,r);return roundToMaxDecimalPlaces(i,t,r,n)};var valueToRatio=function(e,t,r){return clamp(0,(e-t)/(r-t),1)};var rangeIds=0;Range.style={ios:IonRangeIosStyle0,md:IonRangeMdStyle0};export{Range as ion_range};