"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),y=require("../../classix-5H4IWnMA.cjs"),l=require("react"),P=require("../../icons-o8Z5npPW.cjs"),T=require("../../utils-DBzf7CFq.cjs"),s=require("../../styles.module-DvIhipVo.cjs");function b({className:C,defaultCountryCode:h="+47",disabled:a=!1,icon:i,label:d,placeholder:m,ref:v,required:c,type:t="text",...e}){const[r,g]=l.useState(""),[o,x]=l.useState(""),{onChange:N,value:j,...q}=e,{touched:S,onBlur:p}=T.useTouched(j===""),f=i&&t!=="radio"&&t!=="datetime-local"?{"--icon-svg":P.iconSVG(i,!0)}:void 0;l.useEffect(()=>{if(typeof e.onChange=="function"&&t==="tel"){const u={name:e.name,value:o?(r||h).split(" ").join("")+o.split(" ").join(""):void 0};e.onChange({target:u,currentTarget:u})}},[r,o]),l.useEffect(()=>{t==="tel"&&!e.value&&(x(""),g(""))},[e.value,t]);const I=n.jsxs(n.Fragment,{children:[n.jsx("input",{disabled:a,hidden:!0,onChange:N,pattern:void 0,placeholder:m,ref:v,type:t,value:j}),n.jsx("input",{type:"text",className:s.inputStyles.input,disabled:a,maxLength:5,onChange:u=>g(u.target.value),placeholder:h,value:r}),n.jsx("input",{type:"tel",className:y.t(s.inputStyles.input,S&&s.inputStyles.touched),"data-icon":i?"true":void 0,disabled:a,maxLength:14,name:void 0,onChange:u=>x(u.target.value),onBlur:p,pattern:e.pattern,required:c,style:f,value:o,...q})]});return n.jsxs("label",{className:s.inputStyles.label,"data-component":"input",children:[d&&n.jsx("span",{"data-required":c||void 0,children:d}),t==="tel"?I:n.jsx("input",{ref:v,className:y.t(s.inputStyles.input,C,S&&s.inputStyles.touched),"data-icon":i?"true":void 0,disabled:a,onBlur:p,placeholder:m,required:c,style:f,type:t,...e})]})}exports.Input=b;
//# sourceMappingURL=index.cjs.map
