import{j as t,r as i,k as e,l as n,v as s,m as o}from"./p-BxEPsDRj.js";import{n as a,c as r,U as p}from"./p-CrMmJdZ6.js";import{e as h,n as u}from"./p-B9-TeWdB.js";var l=t`
  :host {
    position: relative;
    display: inline-block;
  }

  :host([data-error='true']) > input {
    color: ${({tokens:t})=>t.core.textError};
  }

  :host([data-error='false']) > input {
    color: ${({tokens:t})=>t.theme.textSecondary};
  }

  input {
    background: transparent;
    height: auto;
    box-sizing: border-box;
    color: ${({tokens:t})=>t.theme.textPrimary};
    font-feature-settings: 'case' on;
    font-size: ${({textSize:t})=>t.h4};
    caret-color: ${({tokens:t})=>t.core.backgroundAccentPrimary};
    line-height: ${({typography:t})=>t["h4-regular-mono"].lineHeight};
    letter-spacing: ${({typography:t})=>t["h4-regular-mono"].letterSpacing};
    -webkit-appearance: none;
    -moz-appearance: textfield;
    padding: 0px;
    font-family: ${({fontFamily:t})=>t.mono};
  }

  :host([data-width-variant='auto']) input {
    width: 100%;
  }

  :host([data-width-variant='fit']) input {
    width: 1ch;
  }

  .wui-input-amount-fit-mirror {
    position: absolute;
    visibility: hidden;
    white-space: pre;
    font-size: var(--local-font-size);
    line-height: 130%;
    letter-spacing: -1.28px;
    font-family: ${({fontFamily:t})=>t.mono};
  }

  .wui-input-amount-fit-width {
    display: inline-block;
    position: relative;
  }

  input::-webkit-outer-spin-button,
  input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  input::placeholder {
    color: ${({tokens:t})=>t.theme.textSecondary};
  }
`;var d=undefined&&undefined.__decorate||function(t,i,e,n){var s=arguments.length,o=s<3?i:n===null?n=Object.getOwnPropertyDescriptor(i,e):n,a;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")o=Reflect.decorate(t,i,e,n);else for(var r=t.length-1;r>=0;r--)if(a=t[r])o=(s<3?a(o):s>3?a(i,e,o):a(i,e))||o;return s>3&&o&&Object.defineProperty(i,e,o),o};let f=class t extends n{constructor(){super(...arguments);this.inputElementRef=h();this.disabled=false;this.value="";this.placeholder="0";this.widthVariant="auto";this.maxDecimals=undefined;this.maxIntegers=undefined;this.fontSize="h4";this.error=false}firstUpdated(){this.resizeInput()}updated(){this.style.setProperty("--local-font-size",s.textSize[this.fontSize]);this.resizeInput()}render(){this.dataset["widthVariant"]=this.widthVariant;this.dataset["error"]=String(this.error);if(this.inputElementRef?.value&&this.value){this.inputElementRef.value.value=this.value}if(this.widthVariant==="auto"){return this.inputTemplate()}return o`
      <div class="wui-input-amount-fit-width">
        <span class="wui-input-amount-fit-mirror"></span>
        ${this.inputTemplate()}
      </div>
    `}inputTemplate(){return o`<input
      ${u(this.inputElementRef)}
      type="text"
      inputmode="decimal"
      pattern="[0-9,.]*"
      placeholder=${this.placeholder}
      ?disabled=${this.disabled}
      autofocus
      value=${this.value??""}
      @input=${this.dispatchInputChangeEvent.bind(this)}
    />`}dispatchInputChangeEvent(){if(this.inputElementRef.value){this.inputElementRef.value.value=p.maskInput({value:this.inputElementRef.value.value,decimals:this.maxDecimals,integers:this.maxIntegers});this.dispatchEvent(new CustomEvent("inputChange",{detail:this.inputElementRef.value.value,bubbles:true,composed:true}));this.resizeInput()}}resizeInput(){if(this.widthVariant==="fit"){const t=this.inputElementRef.value;if(t){const i=t.previousElementSibling;if(i){i.textContent=t.value||"0";t.style.width=`${i.offsetWidth}px`}}}}};f.styles=[i,e,l];d([a({type:Boolean})],f.prototype,"disabled",void 0);d([a({type:String})],f.prototype,"value",void 0);d([a({type:String})],f.prototype,"placeholder",void 0);d([a({type:String})],f.prototype,"widthVariant",void 0);d([a({type:Number})],f.prototype,"maxDecimals",void 0);d([a({type:Number})],f.prototype,"maxIntegers",void 0);d([a({type:String})],f.prototype,"fontSize",void 0);d([a({type:Boolean})],f.prototype,"error",void 0);f=d([r("wui-input-amount")],f);
//# sourceMappingURL=p-x-xPR8Lc.js.map