import{j as o,B as y}from"./index-5768b108.js";import{C as F}from"./index.esm-4803c918.js";import{F as I}from"./FormControlLabel-a8ce6f4f.js";import{C as w}from"./Checkbox-6b2ed436.js";import{I as D,F as L}from"./InputLabel-bfa922b7.js";import{O as f}from"./OutlinedInput-8a98392b.js";const R=({control:b,id:a,label:p,name:l,helperText:i,containerSx:h,minlength:j,maxlength:C,onChange:u,required:m,type:s,format:M="DD/MM/YYYY",disabled:O=!1,size:P="small",minDate:x,...n})=>o.jsx(F,{control:b,defaultValue:"",render:({field:t,fieldState:e})=>{var c,d,g;return o.jsxs(y,{sx:h,children:[s==="checkbox"?o.jsx(I,{control:o.jsx(w,{id:a??l,...t,required:m,checked:!!t.value,onChange:r=>{t.onChange(r.target.checked),u&&u(r)}}),label:p}):o.jsxs(o.Fragment,{children:[o.jsx(D,{sx:{".MuiInputLabel-asterisk":{color:"red"}},required:m,htmlFor:a??l,style:{fontWeight:"medium"},error:e.error!=null,children:p}),o.jsx(f,{size:"small",id:a??l,...t,...n,type:s==="number"?"text":s,sx:r=>({width:"100%",mt:1,backgroundColor:r.palette.background.paper,"&.Mui-disabled":{borderColor:e.error?"red":"#e6e6e6fd","& .MuiOutlinedInput-notchedOutline":{borderColor:e.error?"red":"inherit"}}}),error:e.error!=null,inputProps:{minLength:j,maxLength:C,...s==="date"&&x?{min:x.toISOString().split("T")[0]}:{},style:{padding:"10px 12px",...((c=n.inputProps)==null?void 0:c.style)||{}},...n.inputProps,...s==="number"?{onKeyDown:r=>{var k;!/[0-9.-]/.test(r.key)&&r.key!=="Backspace"&&r.key!=="Delete"&&r.key!=="ArrowLeft"&&r.key!=="ArrowRight"&&r.preventDefault(),(k=n.inputProps)!=null&&k.onKeyDown&&n.inputProps.onKeyDown(r)}}:{}},onChange:r=>{t.onChange(r.target.value),u&&u(r)}})]}),(i||((d=e.error)==null?void 0:d.message))&&o.jsx(L,{error:e.error!=null,children:((g=e.error)==null?void 0:g.message)??i})]})},name:l});export{R as F};
