import{r as t,c as i,h as s,H as e,g as a}from"./p-444192d7.js";import{L as n}from"./p-a0c4df1d.js";import{I as o}from"./p-051d4d3b.js";import{c as r}from"./p-9c6e275c.js";const h=class{constructor(s){t(this,s),this.onSubInputEvent=i(this,"sub",3),this.onSumInputEvent=i(this,"sum",3),this.onValidateInputEvent=i(this,"validated",3),s.$hostElement$["s-ei"]?this.internals=s.$hostElement$["s-ei"]:(this.internals=s.$hostElement$.attachInternals(),s.$hostElement$["s-ei"]=this.internals),this.name=void 0,this.min=void 0,this.max=void 0,this.value=1,this.required=void 0,this.number=void 0,this.isValid=!0,this.isDisabled=void 0}watchValue(t){var i;this.number="number"==typeof t?t:parseInt(t),this.internals.setFormValue(this.number.toString()),this.el.dispatchEvent(new InputEvent("input",{bubbles:!1})),this.formValidateCallback(!0),null===(i=this.internals.form)||void 0===i||i.dispatchEvent(new InputEvent("input",{bubbles:!1}))}formDisabledCallback(t){this.isDisabled=t}formResetCallback(){this.isValid=!0,this.value=0}formValidateCallback(t){this.required&&Number.isNaN(this.value)?this.internals.setValidity({valueMissing:!0},n.get("fields.validation.value-missing")):!Number.isNaN(this.max)&&this.value>this.max?this.internals.setValidity({rangeOverflow:!0},n.get("fields.validation.range-overflow",{max:this.max})):!Number.isNaN(this.min)&&this.value<this.min?this.internals.setValidity({rangeUnderflow:!0},n.get("fields.validation.range-underflow",{min:this.min})):this.internals.setValidity({}),t&&(this.isValid=this.internals.validity.valid,this.onValidateInputEvent.emit(this.internals))}componentWillLoad(){this.min&&this.min>this.value&&(this.value=this.min),this.number=this.value}componentDidLoad(){o(this.input,{mask:Number}),setTimeout((()=>this.formValidateCallback()),0)}onBlurInput(){setTimeout((()=>this.formValidateCallback(!0)),50)}handleChange(t){this.value=parseInt(t.target.value)}onPlusClick(){!Number.isNaN(this.number)&&this.number+1>this.max||(this.number++,this.value=this.number,this.onSumInputEvent.emit(this.number))}onMinusClick(){!Number.isNaN(this.number)&&this.number-1<this.min||(this.number--,this.value=this.number,this.onSubInputEvent.emit(this.number))}render(){return s(e,{key:"3fbb825ddea2e3c6c097e1a4a8fd05a95a12a04c",class:r({invalid:!this.isValid,disabled:this.isDisabled,required:this.required}),"data-for":this.name},s("x-chip",{key:"13613220bb2d055c6fc681dc38300dfb727f8d07",hoverable:!0},s("x-button",{key:"1f0a28f39bb41b0928f708fe8d928f783dd885d7",icon:"plus",tabindex:"-1",onClick:this.onPlusClick.bind(this)}),s("input",{key:"962eb7c5cd812ca0b18d8a2314ff7650a888f6dc",ref:t=>this.input=t,min:this.min,max:this.max,required:this.required,inputMode:"numeric",value:this.number,onInput:t=>this.handleChange(t)}),s("x-button",{key:"9d1a3ba0bb32682750904f7dff47163ea963880b",icon:"minus",tabindex:"-1",onClick:this.onMinusClick.bind(this)})))}static get formAssociated(){return!0}get el(){return a(this)}static get watchers(){return{value:["watchValue"]}}};h.style="x-quantity.invalid x-chip{border-color:var(--color-danger, #DC3545) !important;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 0 3px rgba(var(--color-danger-rgb, 220, 53, 69), 0.3) !important;box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 0 3px rgba(var(--color-danger-rgb, 220, 53, 69), 0.3) !important}x-quantity x-chip x-button button{background-color:transparent !important}x-quantity x-button:focus{border-radius:50%;background-color:rgba(var(--color-primary-rgb, 66, 117, 242), 0.3);outline:0;-webkit-box-shadow:none !important;box-shadow:none !important}x-quantity input{width:2rem;-webkit-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:none;-moz-appearance:none;appearance:none;font-weight:bold;text-align:center;display:inline-block;position:relative;margin:0 0.25rem;border:none;background:transparent;outline:none;-moz-appearance:textfield;border-radius:0.25rem}x-quantity input::-webkit-outer-spin-button,x-quantity input::-webkit-inner-spin-button{-webkit-appearance:none}.is-dark-mode x-quantity input{color:var(--color-text-light, #FEFEFE)}";export{h as x_quantity}