import{n as e}from"./rolldown-runtime-Bh1tDfsg.js";import{a as t,i as n}from"./graphql-w47gyQE9.js";import{n as r,t as i}from"./jsx-runtime-BHz_hoGM.js";import{r as a}from"./link-RG1Klsig.js";import{d as o,t as s}from"./useTranslation-CWZfA4RN.js";import{t as c}from"./preload-helper-DYl5dUZ5.js";import{A as l,q as u}from"./main-CqHK_FoX.js";var d={"progress-bar":`_progress-bar_1kvi5_8`,"progress-bar-container":`_progress-bar-container_1kvi5_24`,"progress-bar-label":`_progress-bar-label_1kvi5_53`,"progress-bar-indicator":`_progress-bar-indicator_1kvi5_59`},f=e(o(),1),p=e(r(),1),m=i();function h(e,t=[]){let n=[];function r(t,r){let i=p.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=p.useMemo(()=>o,Object.values(o));return(0,m.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=p.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>p.createContext(e));return function(n){let r=n?.[e]||t;return p.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,g(i,...t)]}function g(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}a();var _=Symbol.for(`react.lazy`),v=p.use;function y(e){return typeof e==`object`&&!!e&&`then`in e}function b(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===_&&`_payload`in e&&y(e._payload)}function x(e){let t=S(e),n=p.forwardRef((e,n)=>{let{children:r,...i}=e;b(r)&&typeof v==`function`&&(r=v(r._payload));let a=p.Children.toArray(r),o=a.find(w);if(o){let e=o.props.children,r=a.map(t=>t===o?p.Children.count(e)>1?p.Children.only(null):p.isValidElement(e)?e.props.children:null:t);return(0,m.jsx)(t,{...i,ref:n,children:p.isValidElement(e)?p.cloneElement(e,void 0,r):null})}return(0,m.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function S(e){let t=p.forwardRef((e,t)=>{let{children:n,...r}=e;if(b(n)&&typeof v==`function`&&(n=v(n._payload)),p.isValidElement(n)){let e=E(n),i=T(r,n.props);return n.type!==p.Fragment&&(i.ref=t?u(t,e):e),p.cloneElement(n,i)}return p.Children.count(n)>1?p.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var C=Symbol(`radix.slottable`);function w(e){return p.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===C}function T(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function E(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var D=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=x(`Primitive.${t}`),r=p.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,m.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),O=`Progress`,k=100,[A,j]=h(O),[M,N]=A(O),P=p.forwardRef((e,t)=>{let{__scopeProgress:n,value:r=null,max:i,getValueLabel:a=L,...o}=e;(i||i===0)&&!B(i)&&console.error(H(`${i}`,`Progress`));let s=B(i)?i:k;r!==null&&!V(r,s)&&console.error(U(`${r}`,`Progress`));let c=V(r,s)?r:null,l=z(c)?a(c,s):void 0;return(0,m.jsx)(M,{scope:n,value:c,max:s,children:(0,m.jsx)(D.div,{"aria-valuemax":s,"aria-valuemin":0,"aria-valuenow":z(c)?c:void 0,"aria-valuetext":l,role:`progressbar`,"data-state":R(c,s),"data-value":c??void 0,"data-max":s,...o,ref:t})})});P.displayName=O;var F=`ProgressIndicator`,I=p.forwardRef((e,t)=>{let{__scopeProgress:n,...r}=e,i=N(F,n);return(0,m.jsx)(D.div,{"data-state":R(i.value,i.max),"data-value":i.value??void 0,"data-max":i.max,...r,ref:t})});I.displayName=F;function L(e,t){return`${Math.round(e/t*100)}%`}function R(e,t){return e==null?`indeterminate`:e===t?`complete`:`loading`}function z(e){return typeof e==`number`}function B(e){return z(e)&&!isNaN(e)&&e>0}function V(e,t){return z(e)&&!isNaN(e)&&e<=t&&e>=0}function H(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${k}\`.`}function U(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
  - a positive number
  - less than the value passed to \`max\` (or ${k} if no \`max\` prop is set)
  - \`null\` or \`undefined\` if the progress is indeterminate.

Defaulting to \`null\`.`}var W=P,G=I,K=(0,p.forwardRef)(function({size:e,tint:t,className:n,value:r,max:i,getValueLabel:a,...o},s){let c=i??1,l=r??c,u=(0,p.useId)(),h=a?a(l,c):null;return(0,m.jsxs)(`div`,{className:(0,f.default)(d[`progress-bar-container`],n),"data-tint":t,...o,children:[h&&(0,m.jsx)(`div`,{id:u,className:d[`progress-bar-label`],children:h}),(0,m.jsx)(W,{className:d[`progress-bar`],"data-size":e,max:c,value:l,ref:s,"aria-labelledby":h?u:void 0,getValueLabel:a,children:(0,m.jsx)(G,{className:d[`progress-bar-indicator`],style:{transform:`translateX(-${100-l/c*100}%)`}})})]})});function q(e,t){return(0,m.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,viewBox:`0 0 24 24`,ref:t,...e,children:(0,m.jsx)(`path`,{d:`M6 22q-.824 0-1.412-.587A1.93 1.93 0 0 1 4 20V10q0-.825.588-1.412A1.93 1.93 0 0 1 6 8h1V6q0-2.075 1.463-3.537Q9.926 1 12 1q2.075 0 3.537 1.463Q17 3.925 17 6v2h1q.824 0 1.413.588Q20 9.175 20 10v10q0 .824-.587 1.413A1.93 1.93 0 0 1 18 22zM9 8h6V6q0-1.25-.875-2.125A2.9 2.9 0 0 0 12 3q-1.25 0-2.125.875A2.9 2.9 0 0 0 9 6z`})})}q.displayName=`LockSolidIcon`;var J=(0,p.forwardRef)(q),Y=n(`
  fragment PasswordCreationDoubleInput_siteConfig on SiteConfig {
    id
    minimumPasswordComplexity
  }
`),X=c(async()=>{let{estimatePasswordComplexity:e}=await import(`./password_complexity-CsbgBnIf.js`);return{estimatePasswordComplexity:e}},[],import.meta.url).then(({estimatePasswordComplexity:e})=>e),Z=e=>{let{t}=s(),[n,r]=(0,p.useState)({score:0,scoreText:t(`frontend.password_strength.placeholder`),improvementsText:[]}),i=(0,p.useDeferredValue)(e);return(0,p.useEffect)(()=>{i===``?r({score:0,scoreText:t(`frontend.password_strength.placeholder`),improvementsText:[]}):X.then(e=>e(i,t)).then(e=>r(e))},[i,t]),n};function Q({siteConfig:e,forceShowNewPasswordInvalid:n}){let{t:r}=s(),{minimumPasswordComplexity:i}=t(Y,e),a=(0,p.useRef)(null),o=(0,p.useRef)(null),[c,u]=(0,p.useState)(``),d=Z(c),f;return f=c===``?void 0:[`red`,`red`,`orange`,`lime`,`green`][d.score],(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(l.Field,{name:`new_password`,children:[(0,m.jsx)(l.Label,{children:r(`frontend.password_change.new_password_label`)}),(0,m.jsx)(l.PasswordControl,{required:!0,autoComplete:`new-password`,ref:a,onBlur:()=>o.current?.value&&o.current?.reportValidity(),onChange:e=>u(e.target.value)}),(0,m.jsx)(K,{size:`sm`,getValueLabel:()=>d.scoreText,tint:f,max:4,value:d.score}),d.improvementsText.map(e=>(0,m.jsx)(l.HelpMessage,{children:e},e)),d.score<i&&(0,m.jsx)(l.ErrorMessage,{match:()=>!0,children:r(`frontend.password_strength.too_weak`)}),(0,m.jsx)(l.ErrorMessage,{match:`valueMissing`,children:r(`frontend.errors.field_required`)}),n&&(0,m.jsx)(l.ErrorMessage,{children:r(`frontend.password_change.failure.description.invalid_new_password`)})]}),(0,m.jsxs)(l.Field,{name:`new_password_again`,children:[(0,m.jsx)(l.Label,{children:r(`frontend.password_change.new_password_again_label`)}),(0,m.jsx)(l.PasswordControl,{required:!0,ref:o,autoComplete:`new-password`}),(0,m.jsx)(l.ErrorMessage,{match:`valueMissing`,children:r(`frontend.errors.field_required`)}),(0,m.jsx)(l.ErrorMessage,{match:(e,t)=>e!==t.get(`new_password`),children:r(`frontend.password_change.passwords_no_match`)}),(0,m.jsx)(l.SuccessMessage,{match:`valid`,children:r(`frontend.password_change.passwords_match`)})]})]})}function $(e,t){switch(t){case`NO_CURRENT_PASSWORD`:return e(`frontend.password_change.failure.description.no_current_password`);case`PASSWORD_CHANGES_DISABLED`:return e(`frontend.password_change.failure.description.password_changes_disabled`);case`ACCOUNT_LOCKED`:return e(`frontend.password_change.failure.description.account_locked`);case`EXPIRED_RECOVERY_TICKET`:return e(`frontend.password_change.failure.description.expired_recovery_ticket`);case`NO_SUCH_RECOVERY_TICKET`:return e(`frontend.password_change.failure.description.no_such_recovery_ticket`);case`RECOVERY_TICKET_ALREADY_USED`:return e(`frontend.password_change.failure.description.recovery_ticket_already_used`);case`WRONG_PASSWORD`:case`INVALID_NEW_PASSWORD`:return;case`ALLOWED`:case void 0:return;default:throw Error(`unexpected error when changing password: ${t}`)}}export{Q as n,J as r,$ as t};
//# sourceMappingURL=password_changes-DPV_YyfH.js.map