"use strict";(self.webpackChunkbackend_ai_webui_react=self.webpackChunkbackend_ai_webui_react||[]).push([[273],{33273:(e,r,n)=>{n.r(r),n.d(r,{default:()=>f,passwordPattern:()=>b});var s=n(30032),a=n(83468),t=n(57857),o=n(91412),i=n(29871),d=n(82156),l=n(50840),c=n(65080),u=n(90214),w=n(24128),m=n(36209),h=n(6932),p=n(76998),g=n(77678),P=n(23446);const b=/^(?=.*\d)(?=.*[a-zA-Z])(?=.*[_\W]).{8,}$/,f=()=>{const{value:e,dispatchEvent:r}=(0,o.useWebComponentInfo)();let n;try{n=JSON.parse(e||"")}catch(z){n={open:!1,currentPassword:"",username:"",api_endpoint:""}}const{open:f,currentPassword:v,username:A,api_endpoint:k}=n,{token:j}=l.A.useToken(),[C]=c.A.useForm(),{t:_}=(0,g.Bd)();(0,p.useEffect)((()=>{f&&C.resetFields()}),[f,C]);const x=(0,a.oM)({api_endpoint:k}),y=(0,t.E)({mutationFn:e=>(0,s.hu)({method:"POST",url:"/server/update-password-no-auth",body:e,client:x})}),M=()=>{C.validateFields().then((e=>{y.mutate({username:A,current_password:v,new_password:e.newPassword},{onSuccess(e,n,s){r("ok",null)},onError(e,r,n){}})}))};return(0,P.jsx)(u.A,{open:f,centered:!0,mask:!1,onCancel:()=>{r("cancel",null)},keyboard:!1,maskClosable:!1,footer:null,width:450,destroyOnClose:!0,forceRender:!0,children:(0,P.jsxs)(i.A,{direction:"column",justify:"start",align:"stretch",gap:"md",style:{alignSelf:"stretch",paddingTop:j.paddingMD,paddingBottom:j.paddingMD},children:[(0,P.jsxs)(w.A.Title,{level:3,style:{margin:0},children:[(0,P.jsx)(d.A,{twoToneColor:j.colorWarning})," ",_("webui.menu.PleaseChangeYourPassword")]}),_("webui.menu.YouMushChangeYourPassword"),(0,P.jsxs)(c.A,{form:C,layout:"vertical",initialValues:{currentPassword:v},disabled:y.isLoading,children:[(0,P.jsx)(c.A.Item,{name:"newPassword",label:_("webui.menu.NewPassword"),rules:[{required:!0},{pattern:b,message:_("webui.menu.InvalidPasswordMessage").toString()},()=>({validator:(e,r)=>v===r?Promise.reject(new Error(_("webui.menu.NewPasswordCannotBeSame").toString())):Promise.resolve()})],hasFeedback:!0,children:(0,P.jsx)(m.A.Password,{})}),(0,P.jsx)(c.A.Item,{name:"confirm",label:_("webui.menu.NewPasswordAgain"),dependencies:["newPassword"],hasFeedback:!0,rules:[{required:!0},e=>{let{getFieldValue:r}=e;return{validator:(e,n)=>n&&r("newPassword")!==n?Promise.reject(new Error(_("environment.PasswordsDoNotMatch").toString())):Promise.resolve()}}],children:(0,P.jsx)(m.A.Password,{onPressEnter:M})})]}),(0,P.jsx)(h.Ay,{type:"primary",onClick:M,loading:y.isLoading,children:_("webui.menu.Update")})]})})}},82156:(e,r,n)=>{n.d(r,{A:()=>d});var s=n(58168),a=n(76998);const t={icon:function(e,r){return{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M955.7 856l-416-720c-6.2-10.7-16.9-16-27.7-16s-21.6 5.3-27.7 16l-416 720C56 877.4 71.4 904 96 904h832c24.6 0 40-26.6 27.7-48zm-783.5-27.9L512 239.9l339.8 588.2H172.2z",fill:e}},{tag:"path",attrs:{d:"M172.2 828.1h679.6L512 239.9 172.2 828.1zM560 720a48.01 48.01 0 01-96 0 48.01 48.01 0 0196 0zm-16-304v184c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V416c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8z",fill:r}},{tag:"path",attrs:{d:"M464 720a48 48 0 1096 0 48 48 0 10-96 0zm16-304v184c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V416c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8z",fill:e}}]}},name:"warning",theme:"twotone"};var o=n(76228),i=function(e,r){return a.createElement(o.A,(0,s.A)({},e,{ref:r,icon:t}))};const d=a.forwardRef(i)}}]);
//# sourceMappingURL=273.a8b3037f.chunk.js.map