import{d as e,n as t,t as n}from"./objectSpread2-DtFdQpqy.js";import{a as r,n as i}from"./preload-helper-EQ20WQt-.js";import{d as a,o,u as s}from"./prop-types-DdDwMzX7.js";import{G as c,X as l,lt as u}from"./poll-BqfIhRzt.js";import{t as d}from"./classnames-CFUb2mE1.js";import{V as f}from"./status_quoted-BBEee1ee.js";import{t as p}from"./info-BVkb-J5l.js";import{t as m}from"./error-BTrrBeMC.js";var h=i();a(),t();var g=[`role`,`as`,`children`],_=l((e,t)=>{let{role:r=`status`,as:i=`div`,children:a}=e,o=s(e,g);return(0,h.jsx)(i,n(n({role:r,"aria-live":r===`alert`?`assertive`:`polite`,ref:t},o),{},{children:a}))}),v={wrapper:`_comp_callout_inline__wrapper`,icon:`_comp_callout_inline__icon`},y=e(d());a(),t();var b=[`variant`,`message`,`className`,`children`],x={error:m,warning:f,info:p,success:c},S=e=>{let{variant:t=`error`,message:r,className:i,children:a}=e;return(0,h.jsxs)(`div`,n(n({},s(e,b)),{},{className:(0,y.default)(i,v.wrapper),"data-variant":t,children:[(0,h.jsx)(u,{id:t,icon:x[t],className:v.icon}),r==null?a:r]}))},C={fieldset:`_comp_form_fields_fieldset__fieldset`,fieldsWrapper:`_comp_form_fields_fieldset__fieldsWrapper`,status:`_comp_form_fields_fieldset__status`},w={wrapper:`_comp_form_fields_form_field_wrapper__wrapper`,labelWrapper:`_comp_form_fields_form_field_wrapper__labelWrapper`,label:`_comp_form_fields_form_field_wrapper__label`,hint:`_comp_form_fields_form_field_wrapper__hint`,status:`_comp_form_fields_form_field_wrapper__status`,inputWrapper:`_comp_form_fields_form_field_wrapper__inputWrapper`},T=e(r());t();var E=(0,T.createContext)(void 0),D=({legend:e,hint:t,name:r,status:i,layout:a,children:o})=>{let s=(0,T.useId)(),c=`${s}-label`,l=`${s}-hint`,u=`${s}-status`,d=r||`${s}-fieldset-name`,f=!!t,p=A(i),m=!!(p!=null&&p.message),g=[f?l:``,m?u:``].filter(e=>!!e).join(` `);return(0,h.jsxs)(`fieldset`,{className:C.fieldset,"data-has-error":i===`error`,"aria-labelledby":c,"aria-describedby":g,children:[(0,h.jsxs)(`div`,{className:w.labelWrapper,children:[(0,h.jsx)(`div`,{id:c,className:w.label,children:e}),f&&(0,h.jsx)(`p`,{id:l,className:w.hint,children:t})]}),(0,h.jsx)(`div`,{className:C.fieldsWrapper,"data-layout":a,children:(0,h.jsx)(E.Provider,{value:d,children:o})}),(0,h.jsx)(_,{className:C.status,id:u,children:m&&(0,h.jsx)(S,n({},p))})]})};t();var O=({inputId:e,label:t,hint:r,describedById:i,required:a,status:o,inputPlacement:s,children:c,className:l})=>{let u=(0,T.useId)(),d=e||`${u}-input`,f=`${e||u}-status`,p=`${e||u}-hint`,m=!!r,g=A(o),v=!!(g!=null&&g.message),b=!!(0,T.useContext)(E),x={required:a,id:d,"aria-describedby":[m?p:``,v?f:``,i].filter(e=>!!e).join(` `)||void 0},C=(0,h.jsx)(`div`,{className:w.inputWrapper,children:c(x)});return(0,h.jsxs)(`div`,{className:(0,y.default)(w.wrapper,l),"data-has-error":(g==null?void 0:g.variant)===`error`,"data-input-placement":s,children:[s===`inline-start`&&C,(0,h.jsxs)(`div`,{className:w.labelWrapper,children:[(0,h.jsxs)(`label`,{htmlFor:d,className:w.label,"data-has-parent-fieldset":b,children:[t,a!==void 0&&(0,h.jsx)(k,{required:a})]}),m&&(0,h.jsx)(`span`,{className:w.hint,id:p,children:r})]}),s!==`inline-start`&&C,(0,h.jsx)(_,{className:w.status,id:f,children:v&&(0,h.jsx)(S,n({},g))})]})},k=({required:e})=>e?(0,h.jsxs)(h.Fragment,{children:[` `,(0,h.jsx)(`abbr`,{"aria-hidden":`true`,children:`*`})]}):(0,h.jsxs)(h.Fragment,{children:[` `,(0,h.jsx)(o,{id:`form_field.optional`,defaultMessage:`(optional)`})]});function A(e){return e?typeof e==`string`?{variant:e,message:``}:e:null}export{D as n,E as r,O as t};
//# sourceMappingURL=form_field_wrapper-C6htjl7Q.js.map