import e,{useRef as t,useContext as n,useState as r}from"react";import{PrimeReactContext as a,ariaLabel as l}from"primereact/api";import{ComponentBase as o,useHandleStyle as i}from"primereact/componentbase";import{useMergeProps as u,useUpdateEffect as c}from"primereact/hooks";import{InputText as s}from"primereact/inputtext";import{ObjectUtils as p}from"primereact/utils";function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n=0&&Number(e.key)<=9)||M.join("").length>=P.length&&"Delete"!==e.code)&&e.preventDefault()}},z=function(e,t){return e.length===t&&e.every((function(e){return""===e||null==e}))};c((function(){var e,t,n=P.value?null===(e=P.value)||void 0===e||null===(e=e.toString())||void 0===e||null===(t=e.split)||void 0===t?void 0:t.call(e,""):new Array(P.length);U(n)}),[P.value]);var G=function(t){if(t<=0)return[];var n=P.length-t,r={onInput:function(e){return V(e,n)},onKeyDown:q,onFocus:Y,onBlur:$,onPaste:X},a={value:M[n]||"",type:null!=P&&P.mask?"password":"text",variant:null==P?void 0:P.variant,readOnly:null==P?void 0:P.readOnly,disabled:null==P?void 0:P.disabled,tabIndex:null==P?void 0:P.tabIndex,autoFocus:(null==P?void 0:P.autoFocus)&&0===n,"aria-label":l("otpLabel",{0:n+1}),"data-index":n,className:A("input")};return[null!=P&&P.inputTemplate?p.getJSXElement(null==P?void 0:P.inputTemplate,{events:r,props:a}):e.createElement(s,f({},a,r,{invalid:null==P?void 0:P.invalid,unstyled:null==P?void 0:P.unstyled,pt:D("input"),inputMode:null!=P&&P.integerOnly?"numeric":"text",key:n}))].concat(g(G(t-1))).map((function(t,n){return e.createElement(e.Fragment,{key:n},t)}))},H=j({className:A("root"),ref:b,style:null==P?void 0:P.style},D("root"));return e.createElement("div",H,G(P.length))})));A.displayName="InputOtp";export{A as InputOtp};