import{a as e,n as t}from"./chunk-BneVvdWh.js";import{t as n}from"./react-C7IZe2D1.js";import{T as r,w as i}from"./dist-DtfJeYQK.js";import{t as a}from"./jsx-runtime-C2wGStra.js";import{n as o,t as s}from"./dist-Cc1j9Pjk.js";import{n as c,o as l,r as u}from"./lib-8ue2PVWI.js";import{n as d,t as f}from"./FieldButton-SkKd22gq.js";import{n as p,t as m}from"./FormControl-De3NG2dC.js";import{r as h,t as g}from"./Input-we-163s5.js";import{i as _,n as v,r as y,t as b}from"./TokyoUIEye-B3okJSKv.js";var x,S,C,w,T=t((()=>{x=e(n(),1),p(),g(),i(),s(),_(),v(),d(),u(),S=a(),C=c({reveal:{id:`preply-ds.password-field.reveal.button`,defaultMessage:`Reveal password`,description:`A11y label for the "reveal password" button. Will be announced by screen reader.`},conceal:{id:`preply-ds.password-field.conceal.button`,defaultMessage:`Conceal password`,description:`A11y label for the "conceal password" button. Will be announced by screen reader.`}}),w=(0,x.forwardRef)(function({id:e,label:t,description:n,error:i,required:a,inputDataset:s,dataset:c,hideLabel:u,onClick:d,hasError:p,useLegacyRequiredLabel:g,className:_,style:v,...w},T){let{formatMessage:E}=l(),[D,O]=(0,x.useState)(!1),k=(0,x.useRef)(null),A=r(k,T),j=D?`text`:`password`,M=()=>{O(!D),k.current?.focus()};return(0,S.jsx)(m,{id:e,label:t,description:n,error:i,hasError:p,required:a,dataset:c,hideLabel:u,onClick:d,useLegacyRequiredLabel:g,preplyDsComponent:o.PasswordField,children:(0,S.jsx)(h,{...w,type:j,ref:A,dataset:s,button:(0,S.jsx)(f,{onClick:M,svg:D?y:b,assistiveText:E(D?C.conceal:C.reveal),dataset:{testid:`toggle-password-button`}})})})});try{w.displayName=`PasswordField`,w.__docgenInfo={description:``,displayName:`PasswordField`,props:{dataset:{defaultValue:null,description:``,name:`dataset`,required:!1,type:{name:`enum`,value:[{value:`Dataset`}]}},id:{defaultValue:null,description:`The id to be passed to the input element.
If not provided, will be generated for accessibility purposes.`,name:`id`,required:!1,type:{name:`enum`,value:[{value:`string`}]}},label:{defaultValue:null,description:"The field label. This is needed for accessibility purposes, but can be\nhidden using the `hideLabel` prop.",name:`label`,required:!0,type:{name:`enum`,value:[{value:`undefined`},{value:`null`},{value:`string`},{value:`number`},{value:`false`},{value:`true`},{value:`ReactElement<any, string | JSXElementConstructor<any>>`},{value:`Iterable<ReactNode>`},{value:`ReactPortal`}]}},hideLabel:{defaultValue:null,description:"Use this to hide the `label` visually, but keep it in the accessibility\ntree.",name:`hideLabel`,required:!1,type:{name:`enum`,value:[{value:`false`},{value:`true`}]}},description:{defaultValue:null,description:`Additional descriptive text that appears below the input field
to provide more context or instructions to the user.`,name:`description`,required:!1,type:{name:`enum`,value:[{value:`null`},{value:`string`},{value:`number`},{value:`false`},{value:`true`},{value:`ReactElement<any, string | JSXElementConstructor<any>>`},{value:`Iterable<ReactNode>`},{value:`ReactPortal`}]}},error:{defaultValue:null,description:`Error message to display when the field has an invalid value.`,name:`error`,required:!1,type:{name:`enum`,value:[{value:`null`},{value:`string`},{value:`number`},{value:`false`},{value:`true`},{value:`ReactElement<any, string | JSXElementConstructor<any>>`},{value:`Iterable<ReactNode>`},{value:`ReactPortal`}]}},hasError:{defaultValue:null,description:"Whether the field has an error.\n@deprecated Use `error` prop to explicitly describe the error to users",name:`hasError`,required:!1,type:{name:`enum`,value:[{value:`false`},{value:`true`}]}},required:{defaultValue:null,description:`Indicates if the field is required. When false, adds a "Optional"
indicator next to the label.`,name:`required`,required:!1,type:{name:`enum`,value:[{value:`false`},{value:`true`}]}},onClick:{defaultValue:null,description:``,name:`onClick`,required:!1,type:{name:`enum`,value:[{value:`MouseEventHandler<HTMLDivElement> & MouseEventHandler<HTMLInputElement>`}]}},useLegacyRequiredLabel:{defaultValue:null,description:`When true, adds a "Required" indicator next to the label for the required fields.
When false, adds a "Optional" indicator next to the label for the optional fields instead.
@deprecated This is a temporary solution for gradual migration to the "Optional" label.`,name:`useLegacyRequiredLabel`,required:!1,type:{name:`enum`,value:[{value:`false`},{value:`true`}]}},icon:{defaultValue:null,description:``,name:`icon`,required:!1,type:{name:`enum`,value:[{value:`ReactElement<any, string | JSXElementConstructor<any>>`}]}},onValueChange:{defaultValue:null,description:``,name:`onValueChange`,required:!1,type:{name:`enum`,value:[{value:`(value: string) => void`}]}},value:{defaultValue:null,description:``,name:`value`,required:!1,type:{name:`enum`,value:[{value:`string`}]}},defaultValue:{defaultValue:null,description:``,name:`defaultValue`,required:!1,type:{name:`enum`,value:[{value:`string`}]}},autoComplete:{defaultValue:null,description:``,name:`autoComplete`,required:!1,type:{name:`enum`,value:[{value:`"off"`},{value:`"new-password"`},{value:`"current-password"`}]}},inputDataset:{defaultValue:null,description:``,name:`inputDataset`,required:!1,type:{name:`enum`,value:[{value:`Dataset`}]}}}}}catch{}}));export{T as n,w as t};