import{_ as S}from"./ButtonDefault-BIBStZbJ.js";import{c as b,o as y,a as o,b as C,t as v,I as f,S as w,n as p,r as d,x as E,H as P,s as x}from"./index-CmCGXBst.js";import{u as k}from"./global-5eUCDNCu.js";import{_ as D}from"./_plugin-vue_export-helper-DlAUqK2U.js";const I={props:{data:{type:Object,default:()=>{}}},emits:["modalClose"],setup(l,{emit:s}){const t=d(""),e=d(""),r=d(""),i=d(!1),n=k(),a=d(!1),m=E("emitter");function u(){t.value===e.value&&t.value.length>0&&e.value.length>0?(a.value=!0,n.OrderChangePassword({ServiceOrderID:l.data?.OrderID,ServiceID:l.data?.ServiceID,Password:t.value,_Password:e.value}).then(c=>{let{result:h,error:H}=c;h==="SUCCESS"&&(l.data?.emitEvent&&m.emit(l.data?.emitEvent),s("modalClose"),m.emit("open-modal",{component:"SuccessChange",data:{newPassword:t.value}})),a.value=!1})):i.value=!0}function g(){t.value=r.value.Password,e.value=r.value.Password}const _=c=>{c.key==="Enter"&&u()};return P(()=>{document.addEventListener("keyup",_)}),P(async()=>{r.value=await n.fetchPassword()}),x(()=>{document.removeEventListener("keyup",_)}),{Password:t,isError:i,PasswordNew:e,isLoading:a,changePassword:u,generatedPassword:r,useGeneratedPassword:g}}},L={class:"modal__body"},N={class:"list-item__title"},O={class:"list-item__pass"},B={class:"modal__input-row"},G={class:"list-form_col list-form_col--xl"},U={class:"search-field form-field"},V={class:"modal__input-row"},M={class:"list-form_col list-form_col--xl"},j={class:"search-field form-field"};function z(l,s,t,e,r,i){const n=S;return y(),b("div",L,[o("div",N,"Смена пароля, "+v(t.data?.Login),1),o("div",O,[s[4]||(s[4]=o("div",{class:"list-item__prepassword"},"Использовать сгенерированный пароль:",-1)),o("div",{class:"list-item__password",onClick:s[0]||(s[0]=(...a)=>e.useGeneratedPassword&&e.useGeneratedPassword(...a))},v(e.generatedPassword.Password),1)]),o("div",B,[s[5]||(s[5]=o("div",{class:"modal__input-label"},"Новый пароль",-1)),o("div",G,[o("div",U,[f(o("input",{class:p({"error-input":e.isError}),"onUpdate:modelValue":s[1]||(s[1]=a=>e.Password=a),placeholder:"",name:"password",autocomplete:"off",type:"text"},null,2),[[w,e.Password]])])])]),o("div",V,[s[6]||(s[6]=o("div",{class:"modal__input-label"},"Подтверждение пароля",-1)),o("div",M,[o("div",j,[f(o("input",{class:p({"error-input":e.isError}),"onUpdate:modelValue":s[2]||(s[2]=a=>e.PasswordNew=a),placeholder:"",name:"password",autocomplete:"off",type:"text"},null,2),[[w,e.PasswordNew]])])])]),C(n,{class:"modal__button",label:"Сменить пароль","is-loading":e.isLoading,onClick:s[3]||(s[3]=a=>e.changePassword())},null,8,["is-loading"])])}const A=D(I,[["render",z],["__scopeId","data-v-8123e962"]]);export{A as default};
