import{b as j,g as w,s as S,c as x,f as P,_ as z,j as E,h as B,i as T,a as U}from"./styled-6f3628cf.js";import{_ as c}from"./emotion-use-insertion-effect-with-fallbacks.browser.esm-e1338cfd.js";import{r as d}from"./index-8ee6c85d.js";import{i as K,a as _}from"./utils-a73c94d0.js";import{F as O,u as Q}from"./useFormControl-67bfd31d.js";import{i as L}from"./isMuiElement-86d0161e.js";import{f as V}from"./formControlState-a1fb9590.js";function X(r){return j("MuiFormControl",r)}w("MuiFormControl",["root","marginNone","marginNormal","marginDense","fullWidth","disabled"]);const Y=["children","className","color","component","disabled","error","focused","fullWidth","hiddenLabel","margin","required","size","variant"],Z=r=>{const{classes:o,margin:a,fullWidth:e}=r,s={root:["root",a!=="none"&&`margin${x(a)}`,e&&"fullWidth"]};return T(s,X,o)},rr=S("div",{name:"MuiFormControl",slot:"Root",overridesResolver:({ownerState:r},o)=>c({},o.root,o[`margin${x(r.margin)}`],r.fullWidth&&o.fullWidth)})(({ownerState:r})=>c({display:"inline-flex",flexDirection:"column",position:"relative",minWidth:0,padding:0,margin:0,border:0,verticalAlign:"top"},r.margin==="normal"&&{marginTop:16,marginBottom:8},r.margin==="dense"&&{marginTop:8,marginBottom:4},r.fullWidth&&{width:"100%"})),or=d.forwardRef(function(o,a){const e=P({props:o,name:"MuiFormControl"}),{children:s,className:u,color:i="primary",component:m="div",disabled:l=!1,error:t=!1,focused:f,fullWidth:p=!1,hiddenLabel:g=!1,margin:D="none",required:C=!1,size:v="medium",variant:h="outlined"}=e,I=z(e,Y),$=c({},e,{color:i,component:m,disabled:l,error:t,fullWidth:p,hiddenLabel:g,margin:D,required:C,size:v,variant:h}),H=Z($),[M,G]=d.useState(()=>{let b=!1;return s&&d.Children.forEach(s,n=>{if(!L(n,["Input","Select"]))return;const A=L(n,["Select"])?n.props.input:n;A&&K(A.props)&&(b=!0)}),b}),[q,W]=d.useState(()=>{let b=!1;return s&&d.Children.forEach(s,n=>{L(n,["Input","Select"])&&(_(n.props,!0)||_(n.props.inputProps,!0))&&(b=!0)}),b}),[N,y]=d.useState(!1);l&&N&&y(!1);const R=f!==void 0&&!l?f:N;let k;const J=d.useMemo(()=>({adornedStart:M,setAdornedStart:G,color:i,disabled:l,error:t,filled:q,focused:R,fullWidth:p,hiddenLabel:g,size:v,onBlur:()=>{y(!1)},onEmpty:()=>{W(!1)},onFilled:()=>{W(!0)},onFocus:()=>{y(!0)},registerEffect:k,required:C,variant:h}),[M,i,l,t,q,R,p,g,k,C,v,h]);return E(O.Provider,{value:J,children:E(rr,c({as:m,ownerState:$,className:B(H.root,u),ref:a},I,{children:s}))})}),Fr=or;function er(r){return j("MuiFormLabel",r)}const sr=w("MuiFormLabel",["root","colorSecondary","focused","disabled","error","filled","required","asterisk"]),F=sr,tr=["children","className","color","component","disabled","error","filled","focused","required"],lr=r=>{const{classes:o,color:a,focused:e,disabled:s,error:u,filled:i,required:m}=r,l={root:["root",`color${x(a)}`,s&&"disabled",u&&"error",i&&"filled",e&&"focused",m&&"required"],asterisk:["asterisk",u&&"error"]};return T(l,er,o)},ar=S("label",{name:"MuiFormLabel",slot:"Root",overridesResolver:({ownerState:r},o)=>c({},o.root,r.color==="secondary"&&o.colorSecondary,r.filled&&o.filled)})(({theme:r,ownerState:o})=>c({color:(r.vars||r).palette.text.secondary},r.typography.body1,{lineHeight:"1.4375em",padding:0,position:"relative",[`&.${F.focused}`]:{color:(r.vars||r).palette[o.color].main},[`&.${F.disabled}`]:{color:(r.vars||r).palette.text.disabled},[`&.${F.error}`]:{color:(r.vars||r).palette.error.main}})),ir=S("span",{name:"MuiFormLabel",slot:"Asterisk",overridesResolver:(r,o)=>o.asterisk})(({theme:r})=>({[`&.${F.error}`]:{color:(r.vars||r).palette.error.main}})),nr=d.forwardRef(function(o,a){const e=P({props:o,name:"MuiFormLabel"}),{children:s,className:u,component:i="label"}=e,m=z(e,tr),l=Q(),t=V({props:e,muiFormControl:l,states:["color","required","focused","disabled","error","filled"]}),f=c({},e,{color:t.color||"primary",component:i,disabled:t.disabled,error:t.error,filled:t.filled,focused:t.focused,required:t.required}),p=lr(f);return U(ar,c({as:i,ownerState:f,className:B(p.root,u),ref:a},m,{children:[s,t.required&&U(ir,{ownerState:f,"aria-hidden":!0,className:p.asterisk,children:[" ","*"]})]}))}),gr=nr;export{Fr as F,gr as a,F as f};
