import{r as i}from"./index-NdkWRN8K.js";import{M as T}from"./Box-1mvP3NLW.js";import{u as N,K as F}from"./OdysseyThemeProvider-Bh0Bu-2o.js";import{j as e}from"./jsx-runtime-CnH95YSl.js";import{L as $}from"./List-CmjR1pNu.js";import{a as k,I as A,F as B}from"./ListItem-C0ExFtXb.js";import{M as h}from"./ScreenReaderText-CebALBsG.js";import{F as v}from"./FormHelperText-CsNAE1E3.js";import{M as H}from"./FieldHint-B3Jif_Up.js";import{c as R,M as q}from"./Typography-Cz6D417Y.js";import{u as K}from"./useUniqueId-Bsgqe1tm.js";import{F as P}from"./FormLabel-CiGre9wK.js";const U={display:"list-item",paddingInlineStart:0},V=({errorMessages:r})=>{const o=N(),s=i.useMemo(()=>({listStyle:"disc",paddingInlineStart:o.Spacing4}),[o]);return e.jsx($,{dense:!0,disablePadding:!0,sx:s,children:r.map(t=>e.jsx(k,{dense:!0,disablePadding:!0,sx:U,children:t},t))})},y=i.memo(V);y.displayName="ErrorMessageList";const W=({id:r,message:o,messageList:s,testId:t,translate:d})=>{const{t:n}=F();return e.jsxs(v,{component:"div","data-se":t,error:!0,id:r,translate:d,children:[e.jsx(h,{translate:d,children:`${n("fielderror.screenreader.text")}:`}),e.jsxs(T,{children:[o,s&&e.jsx(y,{errorMessages:s})]})]})},M=i.memo(W);M.displayName="FieldError";const w=({hasVisibleLabel:r,id:o,inputId:s,isOptional:t,testId:d,translate:n,text:m})=>{const{t:c}=F(),l=i.useMemo(()=>e.jsxs(A,{"data-se":d,htmlFor:s,id:o,translate:n,children:[e.jsx("span",{children:m}),t&&e.jsx(R,{children:c("fieldlabel.optional.text")})]}),[o,s,t,d,n,m,c]);return r?l:e.jsx(h,{translate:n,children:l})},g=i.memo(w);g.displayName="FieldLabel";/*!
 * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const G=i.createContext({isDisabled:!1}),J=()=>i.useContext(G),O=({ariaDescribedBy:r,errorMessage:o,errorMessageList:s,fieldType:t,hasVisibleLabel:d,hint:n,HintLinkComponent:m,id:c,isDisabled:l=!1,isFullWidth:E=!1,isRadioGroup:L=!1,isOptional:b=!1,isReadOnly:z=!1,label:u,renderFieldComponent:I})=>{const{t:S}=F(),a=K(c),x=n?`${a}-hint`:void 0,p=o||s?`${a}-error`:void 0,f=`${a}-label`,D=i.useMemo(()=>[x,p,r].join(" ").trim()||void 0,[r,p,x]),{isDisabled:j}=J(),C=i.useMemo(()=>l||j,[l,j]);return e.jsxs(B,{component:t==="group"?"fieldset":"div",disabled:C,error:!!o||Array.isArray(s)&&s.length>0,fullWidth:E,role:L?"radiogroup":void 0,children:[t==="group"?e.jsxs(P,{component:"legend",id:f,children:[u," ",b&&u&&e.jsxs(q,{color:"textSecondary",component:"span",children:["(",S("fieldlabel.optional.text"),")"]})]}):e.jsx(g,{hasVisibleLabel:d,id:f,inputId:a,isOptional:b,text:u}),n&&e.jsx(H,{id:x,LinkComponent:m,text:n}),I({ariaDescribedBy:D,errorMessageElementId:p,id:a,labelElementId:f,isReadOnly:z}),(o||s)&&e.jsx(M,{id:p,message:o,messageList:s})]})},Q=i.memo(O);Q.displayName="Field";export{G as F,Q as M};
