import*as e from"lit";import*as t from"lit/decorators.js";import*as s from"lit/directives/if-defined.js";import*as i from"lit/directives/repeat.js";import*as r from"lit/directives/style-map.js";var o,n,a={3773(e,t,s){s.d(t,{A:()=>i});var i,r=s(2900),o=s(7704),n=s(9609),a=s(4084),l=s(2927),d=s(8899),h=s(3517),p=s(2577),m=s(1156),c=s(2297),u=function(e,t,s,i){var r,o=arguments.length,n=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o<3?r(n):o>3?r(t,s,n):r(t,s))||n);return o>3&&n&&Object.defineProperty(t,s,n),n};!function(e){let t=class extends((0,o.yC)(l.LitElement)){constructor(){super(...arguments),this._disabled=!1,this._now=0,this.min=0,this.max=100,this.hideValue=!1,this.text=0,this.label="slider",this.step=0,this.dragging=!1}get now(){return this._now}set now(e){const t=this._now;e<this.min||e>this.max?console.warn("Please select correct value"):(this._now=Math.round(e),this.requestUpdate("now",t))}get disabled(){return this._disabled}set disabled(e){const t=this._disabled;this._disabled=e,this.setAttribute("aria-disabled",`${e}`),this.tabIndex=e?-1:0,this.requestUpdate("disabled",t)}get pointerPosition(){const e=this.max-this.min;return(this.now-this.min)/e*100}get isRtl(){return"rtl"===getComputedStyle(this).direction}calculateHandlePosition(e){const{width:t,left:s}=this.getBoundingClientRect(),{clientX:i}=e;let r=(i-s)/t;return this.isRtl&&(r=1-r),this.min+(this.max-this.min)*r}moveSliderTo(e){this.disabled||(e>this.max?this.now=this.max:e<this.min?this.now=this.min:this.now=e)}trackMouseEvent(){if(!this.currentMouseEvent||!this.dragging)return;const e=this.calculateHandlePosition(this.currentMouseEvent),t=this.now;this.moveSliderTo(e),this.notifyChanging(t,this.now),requestAnimationFrame(()=>{this.trackMouseEvent()})}ticksTemplate(){const{min:e,max:t,step:s}=this,i=Math.round((t-e)/s),r=new Array(i+1).fill(0,0,i+1).map((t,i)=>e+i*s).filter(s=>s>=e&&s<=t);return l.html`
        <div class="md-slider__hashlabel">${(0,p.repeat)(r,e=>l.html` <div class="tick">${e}</div> `)}</div>
      `}displayValueTemplate(){return l.html` <span class="md-slider__value"> ${this.now} </span> `}notifyChanges(){this.dispatchEvent(new CustomEvent("slider-change",{bubbles:!0,composed:!0,detail:{value:this.now}}))}notifyChanging(e,t){e!==t&&this.dispatchEvent(new CustomEvent("slider-changing",{bubbles:!0,composed:!0,detail:{oldValue:e,newValue:t}}))}handleMouseDown(e){if(e.preventDefault(),this.disabled)return;const t=e=>{this.currentMouseEvent=e},s=e=>{this.focus(),this.currentMouseEvent=e,document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",s),requestAnimationFrame(()=>{this.dragging=!1,this.notifyChanges()})};document.addEventListener("mousemove",t),document.addEventListener("mouseup",s),this.focus(),this.dragging=!0,this.currentMouseEvent=e,requestAnimationFrame(()=>{this.trackMouseEvent()})}handleKeyDown(e){const{code:t}=e,s=this.now;switch(t){case r.Uz.ArrowLeft:this.moveSliderTo(this.now+(this.isRtl?1:-1));break;case r.Uz.ArrowRight:this.moveSliderTo(this.now+(this.isRtl?-1:1));break;case r.Uz.ArrowDown:this.moveSliderTo(this.now-1);break;case r.Uz.ArrowUp:this.moveSliderTo(this.now+1);break;case r.Uz.Home:this.moveSliderTo(this.min);break;case r.Uz.End:this.moveSliderTo(this.max)}this.notifyChanging(s,this.now);const i=()=>{document.removeEventListener("keyup",i),this.notifyChanges()};document.addEventListener("keyup",i)}get sliderPointerStyleMap(){return{"inset-inline-start":`${this.pointerPosition}%`}}get sliderSelectionStyleMap(){return{"inset-inline-end":`calc(100% - ${this.pointerPosition}%)`}}static get styles(){return[a.A,c.A]}firstUpdated(e){super.firstUpdated(e),this.setAttribute("tabindex",this.disabled?"-1":"0")}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("mousedown",this.handleMouseDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("mousedown",this.handleMouseDown)}render(){return l.html`
        <div class="md-slider">
          <span class="md-slider__bar"></span>
          <span class="md-slider__selection" style=${(0,m.styleMap)(this.sliderSelectionStyleMap)}></span>
          <span
            class="md-slider__pointer"
            role="slider"
            part="slider"
            aria-valuemin=${this.min}
            aria-valuemax=${this.max}
            aria-valuenow=${this.now}
            aria-label=${(0,h.ifDefined)(this.label)}
            style=${(0,m.styleMap)(this.sliderPointerStyleMap)}
          ></span>
          ${this.step?this.ticksTemplate():l.nothing} ${this.hideValue?l.nothing:this.displayValueTemplate()}
        </div>
      `}};u([(0,d.property)({type:Number,reflect:!0})],t.prototype,"min",void 0),u([(0,d.property)({type:Number,reflect:!0})],t.prototype,"max",void 0),u([(0,d.property)({type:Boolean,attribute:"hide-value"})],t.prototype,"hideValue",void 0),u([(0,d.property)({type:Number,reflect:!0})],t.prototype,"now",null),u([(0,d.property)({type:Number})],t.prototype,"text",void 0),u([(0,d.property)({type:String})],t.prototype,"label",void 0),u([(0,d.property)({type:Number,reflect:!0})],t.prototype,"step",void 0),u([(0,d.property)({type:Boolean,reflect:!0})],t.prototype,"disabled",null),u([(0,d.state)()],t.prototype,"dragging",void 0),t=u([(0,n.w)("md-slider")],t),e.ELEMENT=t}(i||(i={}))},2927(t,s,i){var r,o;t.exports=(r={LitElement:()=>e.LitElement,css:()=>e.css,html:()=>e.html,nothing:()=>e.nothing},o={},i.d(o,r),o)},8899(e,s,i){var r,o;e.exports=(r={property:()=>t.property,state:()=>t.state},o={},i.d(o,r),o)},3517(e,t,i){var r,o;e.exports=(r={ifDefined:()=>s.ifDefined},o={},i.d(o,r),o)},2577(e,t,s){var r,o;e.exports=(r={repeat:()=>i.repeat},o={},s.d(o,r),o)},1156(e,t,s){var i,o;e.exports=(i={styleMap:()=>r.styleMap},o={},s.d(o,i),o)}},l={};function d(e){var t=l[e];if(void 0!==t)return t.exports;var s=l[e]={exports:{}};return a[e](s,s.exports,d),s.exports}d.m=a,o=[],d.O=(e,t,s,i)=>{if(!t){var r=1/0;for(h=0;h<o.length;h++){for(var[t,s,i]=o[h],n=!0,a=0;a<t.length;a++)(!1&i||r>=i)&&Object.keys(d.O).every(e=>d.O[e](t[a]))?t.splice(a--,1):(n=!1,i<r&&(r=i));if(n){o.splice(h--,1);var l=s();void 0!==l&&(e=l)}}return e}i=i||0;for(var h=o.length;h>0&&o[h-1][2]>i;h--)o[h]=o[h-1];o[h]=[t,s,i]},d.d=(e,t)=>{for(var s in t)d.o(t,s)&&!d.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},d.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);export{d as __webpack_require__};n={1459:0,6060:0},d.C=e=>{var t,s,{__webpack_esm_ids__:i,__webpack_esm_modules__:r,__webpack_esm_runtime__:o}=e,a=0;for(t in r)d.o(r,t)&&(d.m[t]=r[t]);for(o&&o(d);a<i.length;a++)s=i[a],d.o(n,s)&&n[s]&&n[s][0](),n[i[a]]=0;d.O()},d.O.j=e=>0===n[e];import*as h from"../9609.js";d.C(h);import*as p from"../4084.js";d.C(p);import*as m from"../2364.js";d.C(m);import*as c from"../9938.js";d.C(c);import*as u from"../4781.js";d.C(u);import*as v from"../5201.js";d.C(v);import*as f from"../5584.js";d.C(f);import*as y from"../8227.js";d.C(y);import*as b from"../2900.js";d.C(b);import*as w from"../7704.js";d.C(w);import*as g from"../2297.js";d.C(g);var _=d.O(void 0,[9609,4084,2364,9938,4781,5201,5584,8227,2900,7704,2297],()=>d(3773));const E=(_=d.O(_)).A;export{E as Slider};