import{_ as S}from"./BlueButton.vue_vue_type_script_setup_true_lang-CY8chwQm.js";import{_ as E}from"./InputPassword.vue_vue_type_script_setup_true_lang-dEz0sNQ-.js";import{u as V}from"./global-BK91p1BE.js";import{_ as b}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{r as l,A as k,l as O,D as B,o as D,c as I,a as o,f as p,t as U,b as m,w as L}from"./index-Bb2UEb_P.js";import"./IconEye-Cnj13y34.js";const M={class:"modal__body"},N={class:"tw-mt-4"},R={class:"tw-flex tw-flex-col sm:tw-flex-row sm:tw-items-center tw-gap-4 tw-mt-4"},$={class:"tw-flex tw-flex-col sm:tw-flex-row sm:tw-items-center tw-gap-4 tw-mt-4"},j={__name:"ModalWindowOrderPasswordChange",props:{data:{type:Object,default:()=>{}}},emits:["modalClose"],setup(_,{emit:x}){const n=_,g=x,t=l(""),s=l(""),r=l(""),P=l(!1),u=V(),i=l(!1),w=k("emitter");async function c(){if(t.value&&s.value&&t.value===s.value){i.value=!0;const{result:a}=await u.OrderChangePassword({ServiceOrderID:n.data?.OrderID,ServiceID:n.data?.ServiceID,Password:t.value,_Password:s.value});a==="SUCCESS"&&(n.data?.emitEvent&&w.emit(n.data?.emitEvent),g("modalClose"),w.emit("open-modal",{component:"SuccessChange",data:{newPassword:t.value}})),i.value=!1}else P.value=!0}function C(){t.value=r.value,s.value=r.value}const v=a=>{a.key==="Enter"&&c()};return O(async()=>{document.addEventListener("keyup",v);const a=await u.generatePassword();a!=="ERROR"&&(r.value=a.Password)}),B(()=>{document.removeEventListener("keyup",v)}),(a,e)=>{const f=E,y=S;return D(),I("div",M,[e[7]||(e[7]=o("div",{class:"list-item__title"},"Сменить пароль",-1)),o("div",N,[e[3]||(e[3]=p(" Использовать сгенерированный пароль: ",-1)),o("span",{class:"tw-text-sky-400 tw-font-semibold tw-cursor-pointer tw-ml-1",onClick:C},U(r.value),1)]),o("div",R,[e[4]||(e[4]=o("div",{class:"tw-flex-none tw-w-64"},"Новый пароль",-1)),m(f,{modelValue:t.value,"onUpdate:modelValue":e[0]||(e[0]=d=>t.value=d),"is-new":!0,name:"password",class:"tw-w-full sm:tw-w-[450px]"},null,8,["modelValue"])]),o("div",$,[e[5]||(e[5]=o("div",{class:"tw-flex-none tw-w-64"},"Подтверждение пароля",-1)),m(f,{modelValue:s.value,"onUpdate:modelValue":e[1]||(e[1]=d=>s.value=d),"is-new":!0,name:"confirmPassword",class:"tw-w-full sm:tw-w-[450px]"},null,8,["modelValue"])]),m(y,{class:"tw-mt-10",disabled:!t.value||!s.value,loading:i.value,onClick:e[2]||(e[2]=d=>c())},{default:L(()=>e[6]||(e[6]=[p(" Сменить пароль ",-1)])),_:1,__:[6]},8,["disabled","loading"])])}}},z=b(j,[["__scopeId","data-v-95077151"]]);export{z as default};
