@yourgoods/ui-smart 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/ProfileEmailDialog-_CmzDM2p.js +777 -0
  2. package/dist/ProfilePasswordDialog-DTLqgHqm.js +268 -0
  3. package/dist/ProfilePhoneDialog-D4EwUMe2.js +737 -0
  4. package/dist/components/PEditUserContact/PEditUserContact.vue.d.ts +44 -0
  5. package/dist/components/PEditUserContact/ProfileDialogs/DialogManager.vue.d.ts +24 -0
  6. package/dist/components/PEditUserContact/ProfileDialogs/DialogSegments/AddNewEmailContent.vue.d.ts +60 -0
  7. package/dist/components/PEditUserContact/ProfileDialogs/DialogSegments/AddNewPasswordContent.vue.d.ts +25 -0
  8. package/dist/components/PEditUserContact/ProfileDialogs/DialogSegments/AddNewPhoneContent.vue.d.ts +63 -0
  9. package/dist/components/PEditUserContact/ProfileDialogs/DialogSegments/NewEmailContent.vue.d.ts +64 -0
  10. package/dist/components/PEditUserContact/ProfileDialogs/DialogSegments/NewPhoneContent.vue.d.ts +64 -0
  11. package/dist/components/PEditUserContact/ProfileDialogs/DialogSegments/OldEmailContent.vue.d.ts +55 -0
  12. package/dist/components/PEditUserContact/ProfileDialogs/DialogSegments/OldPhoneContent.vue.d.ts +55 -0
  13. package/dist/components/PEditUserContact/ProfileDialogs/DialogSegments/ThrottlerTimer.vue.d.ts +45 -0
  14. package/dist/components/PEditUserContact/ProfileDialogs/ProfileEmailDialog.vue.d.ts +55 -0
  15. package/dist/components/PEditUserContact/ProfileDialogs/ProfilePasswordDialog.vue.d.ts +36 -0
  16. package/dist/components/PEditUserContact/ProfileDialogs/ProfilePhoneDialog.vue.d.ts +89 -0
  17. package/dist/components/PEditUserContact/ProfileOverlayLoading.vue.d.ts +2 -0
  18. package/dist/components/PEditUserContact/index.vue.d.ts +36 -0
  19. package/dist/components/PEditUserContact/types.d.ts +29 -0
  20. package/dist/components/index.d.ts +1 -0
  21. package/dist/composables/profile/useDialogManager.d.ts +21 -0
  22. package/dist/composables/profile/useModeFlow.d.ts +7 -0
  23. package/dist/composables/profile/usePasswordRateLimitToast.d.ts +9 -0
  24. package/dist/composables/profile/useRateLimitToast.d.ts +9 -0
  25. package/dist/composables/profile/useThrottler.d.ts +13 -0
  26. package/dist/index-DtHlzO1x.js +570 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.js +5 -0
  29. package/dist/locales/index.d.ts +130 -0
  30. package/dist/modules/api/profile/check-availability.d.ts +1 -0
  31. package/dist/modules/api/profile/me.d.ts +19 -0
  32. package/dist/modules/index.d.ts +8 -0
  33. package/dist/types/vue-shims.d.ts +5 -0
  34. package/dist/useRateLimitToast-DsEVCh0F.js +140 -0
  35. package/dist/vue-shims.d.ts +5 -0
  36. package/package.json +49 -0
@@ -0,0 +1,777 @@
1
+ import { defineComponent as le, ref as V, reactive as Q, watch as j, computed as b, toRefs as de, createElementBlock as k, openBlock as y, createElementVNode as S, createCommentVNode as P, toDisplayString as Y, createVNode as T, unref as m, isRef as X, withCtx as W, createTextVNode as ee, Fragment as Oe, createBlock as z, resolveDynamicComponent as Ce, onMounted as Ue } from "vue";
2
+ import { _ as re, c as Ve, a as Ae, u as Fe, b as Re, P as ye, d as ze } from "./useRateLimitToast-DsEVCh0F.js";
3
+ import { C as D, B as We, p as R, g as _e } from "./index-DtHlzO1x.js";
4
+ import { PInput as G, IconMailMd as ue, PButton as te, IconEyeMd as ge, IconEyeClosedMd as he, PDialog as He, PTopBar as qe, IconCrossMd as je } from "@profeat/ui-kit";
5
+ const Ge = { class: "dialogDefaultContainerInsideContent" }, Ye = { class: "dialogDefaultContainerTextHint" }, Je = {
6
+ key: 0,
7
+ class: "input-wrapper"
8
+ }, Ke = {
9
+ key: 1,
10
+ class: "input-wrapper"
11
+ }, Qe = {
12
+ key: 2,
13
+ class: "input-wrapper"
14
+ }, Xe = { key: 3 }, Ze = /* @__PURE__ */ le({
15
+ __name: "AddNewEmailContent",
16
+ props: {
17
+ email: {},
18
+ oldEmail: {},
19
+ hintText: { default: "" },
20
+ emailError: { default: "" },
21
+ codeError: { default: "" },
22
+ rateLimitText: { default: "" },
23
+ showEmail: { type: Boolean, default: !0 },
24
+ isFinalLimit: { type: Boolean },
25
+ isNotMatchCode: { type: Boolean },
26
+ loading: { type: Boolean }
27
+ },
28
+ emits: ["update:email", "update:code", "edit", "on-match-code", "on-match-code-error", "on-send-code", "on-send-code-again"],
29
+ setup(_, { emit: A }) {
30
+ const v = _, d = A, p = V(!1), e = V(""), i = Q({
31
+ emailModel: v.email || "",
32
+ codeModel: "",
33
+ touched: { email: !1, code: !1 }
34
+ });
35
+ j(
36
+ () => i.emailModel,
37
+ (n) => {
38
+ d("update:email", n), e.value = "";
39
+ }
40
+ ), j(
41
+ () => i.codeModel,
42
+ (n) => d("update:code", n)
43
+ );
44
+ const g = (n) => {
45
+ i.touched[n] = !0;
46
+ }, r = b(() => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.emailModel.trim())), c = async () => {
47
+ var s;
48
+ if (g("email"), !r.value) {
49
+ e.value = "Это не похоже на e-mail";
50
+ return;
51
+ }
52
+ const {
53
+ data: { data: n }
54
+ } = await Ve(i.emailModel);
55
+ if (!(((s = n == null ? void 0 : n[0]) == null ? void 0 : s.available) ?? !1)) {
56
+ e.value = "Такой email уже используется";
57
+ return;
58
+ }
59
+ e.value = "", d("on-send-code", {
60
+ email: i.emailModel,
61
+ prevEmail: v.oldEmail,
62
+ offLoading: !0
63
+ }), p.value = !0;
64
+ };
65
+ let $ = "";
66
+ const O = (n) => {
67
+ const a = n.target;
68
+ let s = a.value.replace(/\D/g, "");
69
+ s.length > 4 && (s = s.slice(0, 4)), a.value = s, i.codeModel = s, s.length === 4 && s !== $ && ($ = s, d("on-match-code", { email: i.emailModel, code: s }));
70
+ }, B = () => {
71
+ d("on-send-code-again", { email: i.emailModel });
72
+ }, N = b(() => e.value ? e.value : i.touched.email && !i.emailModel.trim() ? "Введите e-mail" : v.emailError || ""), f = b(() => v.isNotMatchCode ? "Неверный код" : i.touched.code ? h.value.trim() ? v.codeError ?? null : "Введите код" : ""), { emailModel: u, codeModel: h } = de(i);
73
+ return (n, a) => {
74
+ const s = re;
75
+ return y(), k("div", Ge, [
76
+ S("div", Ye, Y(p.value ? "Введите код подтверждения" : n.hintText), 1),
77
+ n.showEmail ? (y(), k("div", Je, [
78
+ T(m(G), {
79
+ modelValue: m(u),
80
+ "onUpdate:modelValue": a[0] || (a[0] = (w) => X(u) ? u.value = w : null),
81
+ size: "large",
82
+ "text-size": "medium",
83
+ label: "Почта",
84
+ type: "email",
85
+ error: N.value,
86
+ onBlur: a[1] || (a[1] = (w) => g("email")),
87
+ onInput: a[2] || (a[2] = (w) => g("email"))
88
+ }, null, 8, ["modelValue", "error"]),
89
+ T(m(ue), {
90
+ class: "icon-locked",
91
+ onClick: a[3] || (a[3] = (w) => n.$emit("edit", "email"))
92
+ })
93
+ ])) : P("", !0),
94
+ p.value ? P("", !0) : (y(), k("div", Ke, [
95
+ T(m(te), {
96
+ style: { width: "100%" },
97
+ disabled: !r.value,
98
+ onClick: c
99
+ }, {
100
+ default: W(() => a[6] || (a[6] = [
101
+ ee(" Отправить код ")
102
+ ])),
103
+ _: 1,
104
+ __: [6]
105
+ }, 8, ["disabled"])
106
+ ])),
107
+ p.value ? (y(), k("div", Qe, [
108
+ T(m(G), {
109
+ modelValue: m(h),
110
+ "onUpdate:modelValue": a[4] || (a[4] = (w) => X(h) ? h.value = w : null),
111
+ size: "large",
112
+ "text-size": "medium",
113
+ label: "Код",
114
+ type: "text",
115
+ error: f.value,
116
+ onInput: O,
117
+ onBlur: a[5] || (a[5] = (w) => g("code"))
118
+ }, null, 8, ["modelValue", "error"])
119
+ ])) : P("", !0),
120
+ !n.loading && p.value ? (y(), k("div", Xe, [
121
+ T(s, {
122
+ loading: n.loading,
123
+ "rate-limit-text": n.rateLimitText,
124
+ "is-final-limit": n.isFinalLimit,
125
+ "on-send-again": B
126
+ }, null, 8, ["loading", "rate-limit-text", "is-final-limit"])
127
+ ])) : P("", !0)
128
+ ]);
129
+ };
130
+ }
131
+ }), et = { class: "dialogDefaultContainer" }, tt = { class: "dialogDefaultContainerInsideContent" }, lt = { class: "input-wrapper" }, at = { class: "input-wrapper" }, ot = { style: { width: "100%", display: "flex" } }, it = {
132
+ key: 0,
133
+ class: "dialogDefaultContainer"
134
+ }, nt = { class: "dialogDefaultContainerInsideContent" }, st = { style: { "margin-top": "12px" } }, Me = 8, dt = /* @__PURE__ */ le({
135
+ __name: "AddNewPasswordContent",
136
+ props: {
137
+ modelValue: { type: Boolean },
138
+ title: { default: "Установка пароля" },
139
+ hintText: { default: "" },
140
+ emailSessionId: {}
141
+ },
142
+ emits: ["update:modelValue", "submit", "close", "update-user"],
143
+ setup(_, { emit: A }) {
144
+ const v = A, d = V(!1), p = V(""), e = V(""), i = Q({
145
+ newPassword: !1,
146
+ newPasswordConfirm: !1
147
+ }), g = V(D.NEW), r = V(!1), c = V(!1), $ = b(() => r.value ? "text" : "password"), O = b(() => c.value ? "text" : "password"), B = () => {
148
+ r.value = !r.value;
149
+ }, N = () => {
150
+ c.value = !c.value;
151
+ }, f = b(() => i.newPassword ? p.value.trim() ? p.value.trim().length < Me ? `Пароль слишком короткий. Введите хотя бы ${Me} символов` : "" : "Введите пароль" : ""), u = b(() => i.newPasswordConfirm ? e.value.trim() ? e.value !== p.value ? "Пароли не совпадают" : "" : "Повторите пароль" : ""), h = b(() => !!(f.value || u.value)), n = b(() => d.value || !p.value.trim() || !e.value.trim() ? !0 : h.value), a = () => {
152
+ v("update:modelValue", !1), v("close");
153
+ }, s = () => {
154
+ p.value = "", e.value = "", i.newPassword = !1, i.newPasswordConfirm = !1, v("close");
155
+ }, w = async () => {
156
+ v("update-user", p.value);
157
+ };
158
+ return (U, C) => (y(), k(Oe, null, [
159
+ S("div", et, [
160
+ S("div", tt, [
161
+ C[9] || (C[9] = S("div", { class: "dialogDefaultContainerTextHint" }, Y("Установите новый пароль для защиты аккаунта. Пароль должен содержать не менее 8 символов."), -1)),
162
+ S("div", lt, [
163
+ T(m(G), {
164
+ modelValue: p.value,
165
+ "onUpdate:modelValue": C[0] || (C[0] = (J) => p.value = J),
166
+ size: "large",
167
+ "text-size": "medium",
168
+ label: "Новый пароль",
169
+ type: $.value,
170
+ error: f.value,
171
+ onBlur: C[1] || (C[1] = () => i.newPassword = !0),
172
+ onInput: C[2] || (C[2] = () => i.newPassword = !0)
173
+ }, null, 8, ["modelValue", "type", "error"]),
174
+ (y(), z(Ce(r.value ? m(ge) : m(he)), {
175
+ class: "icon-locked",
176
+ onClick: B
177
+ }))
178
+ ]),
179
+ S("div", at, [
180
+ T(m(G), {
181
+ modelValue: e.value,
182
+ "onUpdate:modelValue": C[3] || (C[3] = (J) => e.value = J),
183
+ size: "large",
184
+ "text-size": "medium",
185
+ label: "Повторите новый пароль",
186
+ type: O.value,
187
+ error: u.value,
188
+ onBlur: C[4] || (C[4] = () => i.newPasswordConfirm = !0),
189
+ onInput: C[5] || (C[5] = () => i.newPasswordConfirm = !0)
190
+ }, null, 8, ["modelValue", "type", "error"]),
191
+ (y(), z(Ce(c.value ? m(ge) : m(he)), {
192
+ class: "icon-locked",
193
+ onClick: N
194
+ }))
195
+ ]),
196
+ S("div", ot, [
197
+ T(m(te), {
198
+ style: { width: "100%" },
199
+ color: "secondary",
200
+ disabled: d.value,
201
+ onClick: s
202
+ }, {
203
+ default: W(() => C[6] || (C[6] = [
204
+ ee(Y("Отмена"))
205
+ ])),
206
+ _: 1,
207
+ __: [6]
208
+ }, 8, ["disabled"]),
209
+ C[8] || (C[8] = S("div", { style: { width: "5%" } }, null, -1)),
210
+ T(m(te), {
211
+ style: { width: "100%" },
212
+ disabled: n.value,
213
+ onClick: w
214
+ }, {
215
+ default: W(() => C[7] || (C[7] = [
216
+ ee(Y("Сохранить"))
217
+ ])),
218
+ _: 1,
219
+ __: [7]
220
+ }, 8, ["disabled"])
221
+ ])
222
+ ])
223
+ ]),
224
+ g.value === m(D).COMPLETED ? (y(), k("div", it, [
225
+ S("div", nt, [
226
+ C[11] || (C[11] = S("p", null, "Пароль успешно установлен", -1)),
227
+ S("div", st, [
228
+ T(m(te), {
229
+ style: { width: "100%" },
230
+ onClick: a
231
+ }, {
232
+ default: W(() => C[10] || (C[10] = [
233
+ ee("Закрыть")
234
+ ])),
235
+ _: 1,
236
+ __: [10]
237
+ })
238
+ ])
239
+ ])
240
+ ])) : P("", !0)
241
+ ], 64));
242
+ }
243
+ }), rt = { class: "dialogDefaultContainerInsideContent" }, ut = { class: "dialogDefaultContainerTextHint" }, mt = {
244
+ key: 0,
245
+ class: "input-wrapper"
246
+ }, ct = {
247
+ key: 1,
248
+ class: "input-wrapper"
249
+ }, vt = /* @__PURE__ */ le({
250
+ __name: "OldEmailContent",
251
+ props: {
252
+ email: {},
253
+ code: {},
254
+ hintText: { default: "" },
255
+ emailError: { default: "" },
256
+ codeError: { default: "" },
257
+ rateLimitText: { default: "" },
258
+ showEmail: { type: Boolean, default: !0 },
259
+ showCode: { type: Boolean, default: !0 },
260
+ isFinalLimit: { type: Boolean },
261
+ isNotMatchCode: { type: Boolean, default: !1 },
262
+ loading: { type: Boolean }
263
+ },
264
+ emits: ["update:email", "update:code", "edit", "on-match-code", "on-match-code-error", "on-send-code-again", "on-clear-code-error"],
265
+ setup(_, { emit: A }) {
266
+ const v = _, d = A, p = Q({
267
+ touched: {
268
+ email: !1,
269
+ code: !1
270
+ },
271
+ emailModel: v.email,
272
+ codeModel: v.code
273
+ });
274
+ j(
275
+ () => p.emailModel,
276
+ (f) => d("update:email", f)
277
+ ), j(
278
+ () => p.codeModel,
279
+ (f) => d("update:code", f)
280
+ );
281
+ const e = (f) => {
282
+ p.touched[f] = !0;
283
+ }, i = V(""), g = (f) => {
284
+ d("on-clear-code-error");
285
+ const u = f.target;
286
+ let h = ((u == null ? void 0 : u.value) ?? "").replace(/\D/g, "");
287
+ h.length > 4 && (h = h.slice(0, 4)), $.value = h, u && u.value !== h && (u.value = h), h.length === 4 && h !== i.value && (i.value = h, d("on-match-code", { email: c.value, code: h }));
288
+ }, r = () => {
289
+ d("on-send-code-again", { email: c.value });
290
+ }, { emailModel: c, codeModel: $, touched: O } = de(p), B = b(() => O.value.email && !c.value.trim() ? "Введите e-mail" : v.emailError), N = b(() => v.isNotMatchCode ? "Неверный код" : O.value.code ? $.value.trim() ? v.codeError ?? null : "Введите код" : "");
291
+ return (f, u) => {
292
+ const h = re;
293
+ return y(), k("div", rt, [
294
+ S("div", ut, Y(f.hintText), 1),
295
+ f.showEmail ? (y(), k("div", mt, [
296
+ T(m(G), {
297
+ modelValue: m(c),
298
+ "onUpdate:modelValue": u[0] || (u[0] = (n) => X(c) ? c.value = n : null),
299
+ size: "large",
300
+ "text-size": "medium",
301
+ label: "Почта",
302
+ type: "email",
303
+ error: B.value,
304
+ disabled: !0,
305
+ onBlur: u[1] || (u[1] = (n) => e("email")),
306
+ onInput: u[2] || (u[2] = (n) => e("email"))
307
+ }, null, 8, ["modelValue", "error"]),
308
+ T(m(ue), {
309
+ class: "icon-locked",
310
+ onClick: u[3] || (u[3] = (n) => f.$emit("edit", "email"))
311
+ })
312
+ ])) : P("", !0),
313
+ f.showCode ? (y(), k("div", ct, [
314
+ T(m(G), {
315
+ modelValue: m($),
316
+ "onUpdate:modelValue": u[4] || (u[4] = (n) => X($) ? $.value = n : null),
317
+ size: "large",
318
+ "text-size": "medium",
319
+ label: "Код",
320
+ type: "text",
321
+ disabled: v.isFinalLimit,
322
+ error: N.value,
323
+ onInput: g,
324
+ onBlur: u[5] || (u[5] = (n) => e("code"))
325
+ }, null, 8, ["modelValue", "disabled", "error"])
326
+ ])) : P("", !0),
327
+ T(h, {
328
+ loading: f.loading,
329
+ "rate-limit-text": f.rateLimitText,
330
+ "is-final-limit": f.isFinalLimit,
331
+ "on-send-again": r
332
+ }, null, 8, ["loading", "rate-limit-text", "is-final-limit"])
333
+ ]);
334
+ };
335
+ }
336
+ }), pt = /* @__PURE__ */ Ae(vt, [["__scopeId", "data-v-ac04d1ee"]]), ft = { class: "dialogDefaultContainerInsideContent" }, wt = { class: "dialogDefaultContainerTextHint" }, Et = {
337
+ key: 0,
338
+ class: "input-wrapper"
339
+ }, Ct = {
340
+ key: 1,
341
+ class: "input-wrapper"
342
+ }, yt = {
343
+ key: 2,
344
+ class: "input-wrapper"
345
+ }, gt = { key: 3 }, ht = /* @__PURE__ */ le({
346
+ __name: "NewEmailContent",
347
+ props: {
348
+ email: {},
349
+ oldEmail: {},
350
+ hintText: { default: "" },
351
+ emailError: { default: "" },
352
+ codeError: { default: "" },
353
+ rateLimitText: { default: "" },
354
+ showEmail: { type: Boolean, default: !0 },
355
+ isFinalLimit: { type: Boolean, default: !1 },
356
+ isNotMatchCode: { type: Boolean, default: !1 },
357
+ loading: { type: Boolean }
358
+ },
359
+ emits: ["update:email", "update:code", "edit", "on-match-code", "on-match-code-error", "on-send-code", "on-send-code-again", "on-clear-code-error"],
360
+ setup(_, { emit: A }) {
361
+ const v = _, d = A, p = V(!1), e = V(""), i = Q({
362
+ touched: { email: !1, code: !1 },
363
+ emailModel: "",
364
+ codeModel: ""
365
+ });
366
+ j(
367
+ () => i.emailModel,
368
+ (a) => {
369
+ d("update:email", a), e.value = "";
370
+ }
371
+ ), j(
372
+ () => i.codeModel,
373
+ (a) => d("update:code", a)
374
+ );
375
+ const g = (a) => i.touched[a] = !0, r = b(() => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.emailModel.trim())), c = async () => {
376
+ var w;
377
+ if (g("email"), !r.value) {
378
+ e.value = "Это не похоже на e-mail";
379
+ return;
380
+ }
381
+ const {
382
+ data: { data: a }
383
+ } = await Ve(i.emailModel);
384
+ if (!(((w = a == null ? void 0 : a[0]) == null ? void 0 : w.available) ?? !1)) {
385
+ e.value = "Такой email уже используется";
386
+ return;
387
+ }
388
+ e.value = "", d("on-send-code", { email: i.emailModel, prevEmail: v.oldEmail, offLoading: !0 }), p.value = !0;
389
+ };
390
+ let $ = "";
391
+ const O = (a) => {
392
+ d("on-clear-code-error");
393
+ const s = a.target;
394
+ let w = s.value.replace(/\D/g, "");
395
+ w.length > 4 && (w = w.slice(0, 4), s.value = w), i.codeModel = w, w.length === 4 && w !== $ && ($ = w, d("on-match-code", { email: i.emailModel, code: w }));
396
+ }, B = () => {
397
+ d("on-send-code-again", { email: i.emailModel });
398
+ }, { emailModel: N, codeModel: f, touched: u } = de(i), h = b(() => e.value ? e.value : u.value.email && !N.value.trim() ? "Введите e-mail" : v.emailError || ""), n = b(() => v.isNotMatchCode ? "Неверный код" : u.value.code ? f.value.trim() ? v.codeError ?? null : "Введите код" : "");
399
+ return (a, s) => {
400
+ const w = re;
401
+ return y(), k("div", ft, [
402
+ S("div", wt, Y(p.value ? "Введите код подтверждения" : a.hintText), 1),
403
+ a.showEmail ? (y(), k("div", Et, [
404
+ T(m(G), {
405
+ modelValue: m(N),
406
+ "onUpdate:modelValue": s[0] || (s[0] = (U) => X(N) ? N.value = U : null),
407
+ size: "large",
408
+ "text-size": "medium",
409
+ label: "Почта",
410
+ type: "email",
411
+ error: h.value,
412
+ onBlur: s[1] || (s[1] = (U) => g("email")),
413
+ onInput: s[2] || (s[2] = (U) => g("email"))
414
+ }, null, 8, ["modelValue", "error"]),
415
+ T(m(ue), {
416
+ class: "icon-locked",
417
+ onClick: s[3] || (s[3] = (U) => a.$emit("edit", "email"))
418
+ })
419
+ ])) : P("", !0),
420
+ p.value ? P("", !0) : (y(), k("div", Ct, [
421
+ T(m(te), {
422
+ style: { width: "100%" },
423
+ disabled: !r.value,
424
+ onClick: c
425
+ }, {
426
+ default: W(() => s[6] || (s[6] = [
427
+ ee(" Отправить код ")
428
+ ])),
429
+ _: 1,
430
+ __: [6]
431
+ }, 8, ["disabled"])
432
+ ])),
433
+ p.value ? (y(), k("div", yt, [
434
+ T(m(G), {
435
+ modelValue: m(f),
436
+ "onUpdate:modelValue": s[4] || (s[4] = (U) => X(f) ? f.value = U : null),
437
+ size: "large",
438
+ "text-size": "medium",
439
+ label: "Код",
440
+ type: "text",
441
+ error: n.value,
442
+ onInput: O,
443
+ onBlur: s[5] || (s[5] = (U) => g("code"))
444
+ }, null, 8, ["modelValue", "error"])
445
+ ])) : P("", !0),
446
+ p.value ? (y(), k("div", gt, [
447
+ T(w, {
448
+ loading: a.loading,
449
+ "rate-limit-text": a.rateLimitText,
450
+ "is-final-limit": a.isFinalLimit,
451
+ "on-send-again": B
452
+ }, null, 8, ["loading", "rate-limit-text", "is-final-limit"])
453
+ ])) : P("", !0)
454
+ ]);
455
+ };
456
+ }
457
+ }), Mt = { class: "text-center w-full" }, Tt = { class: "dialogTitle" }, Vt = {
458
+ key: 0,
459
+ class: "dialogDefaultContainer"
460
+ }, bt = {
461
+ key: 1,
462
+ class: "dialogDefaultContainer"
463
+ }, Te = 3, St = /* @__PURE__ */ le({
464
+ __name: "ProfileEmailDialog",
465
+ props: {
466
+ modelValue: { type: Boolean },
467
+ title: { default: "Смена почты" },
468
+ hintText: { default: "Чтобы продолжить, введите код подтверждения" },
469
+ initialEmail: { default: "" },
470
+ throttler: {},
471
+ provider: {},
472
+ mode: {}
473
+ },
474
+ emits: ["update:modelValue", "submit-email", "edit", "close", "notify", "clean-input-errors", "on-update-jwt", "update-email-field", "on-password-error", "on-toast"],
475
+ setup(_, { emit: A }) {
476
+ const v = _, d = A, p = V(v.modelValue), e = Q({
477
+ oldEmail: v.initialEmail,
478
+ newEmail: "",
479
+ code: "",
480
+ addEmail: "",
481
+ addCode: ""
482
+ }), i = Q({ email: !1, code: !1 }), g = V(D.OLD), r = V(null), c = V(!1), $ = V(!1), O = V(!1), B = V(We.VERIFY_EMAIL), N = b(() => B.value === "password-flow"), f = b(() => w.value ? v.title : N.value ? "Добавление пароля" : "Добавление почты"), { startTimer: u, remainingSeconds: h, isAvailableForSendAgain: n, totalRateAttempts: a, currentRateAttempt: s } = Re(), { isEditFlow: w, getFlow: U } = Fe(V(v.mode ?? "edit")), { showRateLimitToast: C } = ze(d), J = b(() => i.email && !e.oldEmail.trim() ? "Введите e-mail" : ""), me = b(() => i.code && !e.code.trim() ? "Введите код" : ""), oe = b(() => n.value ? "Повторить" : `${h.value}`), H = V(Te), be = b(() => H.value === 0), $e = (l) => new Promise((t) => setTimeout(t, l));
483
+ j(
484
+ () => v.modelValue,
485
+ (l) => p.value = l
486
+ ), j(p, (l) => d("update:modelValue", l));
487
+ const ie = () => {
488
+ d("close"), p.value = !1;
489
+ }, ce = (l) => d("edit", l);
490
+ async function ve(l, t = !1) {
491
+ var o;
492
+ try {
493
+ const M = (o = (await R("/users/profile/check-throttler", { method: "email", email: l, isInvite: t })).data) == null ? void 0 : o.data;
494
+ return M ? (await $e(1e3), M.restTimeSec > 0 ? (u(M.restTimeSec), n.value = !1, a.value = M.attempts.total ?? a.value, s.value = (M.attempts.total ?? 0) - (M.attempts.available ?? 0), H.value = M.attempts.available ?? H.value) : n.value = !0, M) : null;
495
+ } catch {
496
+ return null;
497
+ }
498
+ }
499
+ async function ne(l = "email") {
500
+ var o;
501
+ return ((o = (await _e("/users/profile/session/get-edit-session", { params: { field: l } })).data) == null ? void 0 : o.data) ?? null;
502
+ }
503
+ async function xe(l = "email") {
504
+ try {
505
+ const t = await ne(l);
506
+ r.value = (t == null ? void 0 : t.sessionId) ?? r.value, g.value = (t == null ? void 0 : t.step) ?? g.value, e.oldEmail = (t == null ? void 0 : t.oldValue) ?? e.oldEmail, t != null && t.sessionId || await pe(l);
507
+ } catch {
508
+ await pe(l);
509
+ }
510
+ }
511
+ async function pe(l = "email") {
512
+ var t;
513
+ try {
514
+ const o = await R("/users/profile/session/create-if-not-exists", { field: l, oldValue: v.initialEmail }), E = ((t = o.data) == null ? void 0 : t.data) ?? o.data;
515
+ r.value = (E == null ? void 0 : E.sessionId) ?? r.value, g.value = (E == null ? void 0 : E.step) ?? g.value, e.oldEmail = (E == null ? void 0 : E.oldValue) ?? e.oldEmail, e.newEmail = (E == null ? void 0 : E.newValue) ?? e.newEmail;
516
+ } catch {
517
+ }
518
+ }
519
+ async function Z({ value: l, offLoading: t = !0 }) {
520
+ var o;
521
+ try {
522
+ c.value = !0;
523
+ const E = l ?? e.addEmail, M = await R(
524
+ "/users/profile/email/contact/send-code",
525
+ {
526
+ sessionId: r.value,
527
+ email: E,
528
+ value: E,
529
+ oldValue: e.oldEmail,
530
+ provider: v.provider
531
+ }
532
+ // { headers: { 'x-only-sms': 'true' } }
533
+ );
534
+ if (M.status === 403 && ((o = M.data) != null && o.tooManyRequests)) {
535
+ const I = M.data.tooManyRequests;
536
+ return I.restTimeSec > 0 ? (u(I.restTimeSec), a.value = I.attempts.total ?? a.value, s.value = (I.attempts.total ?? 0) - (I.attempts.available ?? 0), H.value = I.attempts.available ?? H.value) : n.value = !0, M;
537
+ }
538
+ return await ve(l ?? e.oldEmail), M;
539
+ } catch (E) {
540
+ throw console.error(E), E;
541
+ } finally {
542
+ t && (c.value = !1);
543
+ }
544
+ }
545
+ const fe = async (l, t) => {
546
+ var o, E, M, I, x, q;
547
+ if (!e.oldEmail && t === D.OLD) throw new Error("oldEmail пустой — модель потерялась");
548
+ try {
549
+ c.value = !0;
550
+ const L = await ne();
551
+ if (r.value = (L == null ? void 0 : L.sessionId) ?? r.value, g.value = (L == null ? void 0 : L.step) ?? g.value, e.oldEmail = (L == null ? void 0 : L.oldValue) ?? e.oldEmail, e.newEmail = (L == null ? void 0 : L.newValue) ?? e.newEmail, !r.value) throw new Error("Нет sessionId для match");
552
+ const F = await R("/users/profile/change/email/match-code", {
553
+ email: t === D.NEW ? e.newEmail : e.oldEmail,
554
+ sessionId: r.value,
555
+ code: l,
556
+ step: t
557
+ }), ae = ((o = F.data) == null ? void 0 : o.nextStep) ?? ((M = (E = F.data) == null ? void 0 : E.data) == null ? void 0 : M.nextStep) ?? null, Ne = ((x = (I = F.data) == null ? void 0 : I.data) == null ? void 0 : x.rateLimit) ?? ((q = F.data) == null ? void 0 : q.rateLimit) ?? null, De = F.data.data.success ?? F.data.success;
558
+ if (C(Ne), !De) {
559
+ $.value = !0;
560
+ return;
561
+ }
562
+ if (ae) {
563
+ if (g.value = ae, g.value === D.NEW) {
564
+ const K = await ne();
565
+ e.oldEmail = (K == null ? void 0 : K.oldValue) ?? e.oldEmail, e.newEmail = (K == null ? void 0 : K.newValue) ?? e.newEmail, e.code = "";
566
+ }
567
+ g.value === D.COMPLETED && (e.code = "", d("submit-email", { email: e.addEmail, code: l }), d("on-toast", { color: "success", text: "E-mail изменён" }), d("on-update-jwt", "email", "edit", e.newEmail), r.value = null, d("close"));
568
+ }
569
+ return F;
570
+ } finally {
571
+ c.value = !1;
572
+ }
573
+ }, ke = async () => {
574
+ try {
575
+ const l = await R("/users/profile/bind/email/cancel", {
576
+ sessionId: r.value
577
+ });
578
+ if ((l.data.data ?? l.data).success) {
579
+ d("close");
580
+ return;
581
+ }
582
+ } catch (l) {
583
+ console.error(l);
584
+ }
585
+ };
586
+ async function Ie({ code: l }) {
587
+ await fe(l, D.OLD);
588
+ }
589
+ function we(l) {
590
+ }
591
+ async function Se({ code: l }) {
592
+ await fe(l, D.NEW);
593
+ }
594
+ const Ee = async ({
595
+ value: l,
596
+ field: t = "email",
597
+ offLoading: o = !0
598
+ }) => {
599
+ var E;
600
+ try {
601
+ if (c.value = !0, !r.value) throw new Error("Bind-сессия не найдена. Создайте её через createBindSession.");
602
+ const M = l ?? e.addEmail, I = await R(`/users/profile/bind/contact/send-code/${t}`, {
603
+ sessionId: r.value,
604
+ email: M,
605
+ provider: v.provider
606
+ }), x = (E = I.data) == null ? void 0 : E.tooManyRequests;
607
+ if (I.status === 403 && x) {
608
+ x.restTimeSec > 0 ? (u(x.restTimeSec), a.value = x.attempts.total ?? a.value, s.value = (x.attempts.total ?? 0) - (x.attempts.available ?? 0), H.value = x.attempts.available ?? Te) : n.value = !0;
609
+ return;
610
+ }
611
+ const q = await ve(M);
612
+ return q && q.restTimeSec > 0 ? u(q.restTimeSec) : n.value = !0, I;
613
+ } finally {
614
+ o && (c.value = !1);
615
+ }
616
+ }, Be = async () => {
617
+ var l, t, o, E, M, I;
618
+ try {
619
+ if (!r.value) {
620
+ const ae = await se();
621
+ r.value = ae.sessionId ?? r.value;
622
+ }
623
+ const x = await R("/users/profile/bind/email/match-code", {
624
+ email: e.addEmail,
625
+ sessionId: r.value,
626
+ code: e.addCode
627
+ }), q = ((l = x.data) == null ? void 0 : l.nextStep) ?? ((o = (t = x.data) == null ? void 0 : t.data) == null ? void 0 : o.nextStep);
628
+ B.value = q ?? B.value;
629
+ const L = ((M = (E = x.data) == null ? void 0 : E.data) == null ? void 0 : M.rateLimit) ?? ((I = x.data) == null ? void 0 : I.rateLimit) ?? null, F = x.data.data.success ?? x.data.success;
630
+ if (C(L), !F) {
631
+ O.value = !0;
632
+ return;
633
+ }
634
+ } catch {
635
+ }
636
+ }, Le = async () => {
637
+ }, Pe = async (l) => {
638
+ if (!r.value) {
639
+ const t = await se();
640
+ r.value = t.sessionId ?? r.value;
641
+ }
642
+ c.value = !0;
643
+ try {
644
+ await R("/users/profile/bind/email/password/set", { sessionId: r.value, newPassword: l }), B.value = D.COMPLETED, d("on-toast", { color: "success", text: "E-mail успешно привязан к аккаунту" }), d("update-email-field", e.addEmail), d("submit-email", { email: e.addEmail, code: e.addCode }), d("on-update-jwt", "email", "bind", e.addEmail), d("close");
645
+ } finally {
646
+ c.value = !1;
647
+ }
648
+ }, se = async () => {
649
+ c.value = !0;
650
+ try {
651
+ const l = await R("/users/profile/bind/email/init", { email: "" }), t = l.data.data ?? l.data;
652
+ return B.value = t.step ?? B.value, r.value = t.sessionId ?? r.value, t;
653
+ } finally {
654
+ c.value = !1;
655
+ }
656
+ };
657
+ return Ue(async () => {
658
+ const l = await U("email");
659
+ if (v.mode === "bind" && l === "bind") {
660
+ await se(), c.value = !1;
661
+ return;
662
+ }
663
+ await xe(), e.oldEmail && await Z({ value: e.oldEmail }), c.value = !1;
664
+ }), (l, t) => (y(), z(m(He), {
665
+ modelValue: p.value,
666
+ "onUpdate:modelValue": [
667
+ t[17] || (t[17] = (o) => p.value = o),
668
+ ie
669
+ ],
670
+ width: "small",
671
+ "auto-height": !0,
672
+ "close-on-click-outside": !0,
673
+ "onClick:outside": ie
674
+ }, {
675
+ header: W(() => [
676
+ S("div", Mt, [
677
+ T(m(qe), {
678
+ "slot-left": !1,
679
+ size: "small",
680
+ borded: !0,
681
+ "no-padding": !1
682
+ }, {
683
+ title: W(() => [
684
+ S("span", Tt, Y(f.value), 1)
685
+ ]),
686
+ "right-button": W(() => [
687
+ T(m(je), {
688
+ class: "cross",
689
+ onClick: ie
690
+ })
691
+ ]),
692
+ _: 1
693
+ })
694
+ ])
695
+ ]),
696
+ default: W(() => [
697
+ S("div", null, [
698
+ m(w) ? (y(), k("div", Vt, [
699
+ c.value ? (y(), z(ye, { key: 0 })) : P("", !0),
700
+ g.value === m(D).OLD ? (y(), z(pt, {
701
+ key: 1,
702
+ email: e.oldEmail,
703
+ "onUpdate:email": t[0] || (t[0] = (o) => e.oldEmail = o),
704
+ code: e.code,
705
+ "onUpdate:code": t[1] || (t[1] = (o) => e.code = o),
706
+ "hint-text": l.hintText,
707
+ "email-error": J.value,
708
+ "code-error": me.value,
709
+ "rate-limit-text": oe.value,
710
+ "is-final-limit": H.value === 0,
711
+ "is-not-match-code": $.value,
712
+ loading: c.value,
713
+ onEdit: ce,
714
+ onOnMatchCode: Ie,
715
+ onOnMatchCodeError: we,
716
+ onSendCode: t[2] || (t[2] = (o) => Z({ value: e.oldEmail })),
717
+ onOnSendCodeAgain: t[3] || (t[3] = (o) => Z({ value: e.oldEmail })),
718
+ onOnClearCodeError: t[4] || (t[4] = (o) => $.value = !1)
719
+ }, null, 8, ["email", "code", "hint-text", "email-error", "code-error", "rate-limit-text", "is-final-limit", "is-not-match-code", "loading"])) : g.value === m(D).NEW ? (y(), z(ht, {
720
+ key: 2,
721
+ email: e.newEmail,
722
+ "onUpdate:email": t[5] || (t[5] = (o) => e.newEmail = o),
723
+ oldEmail: e.oldEmail,
724
+ "onUpdate:oldEmail": t[6] || (t[6] = (o) => e.oldEmail = o),
725
+ code: e.code,
726
+ "onUpdate:code": t[7] || (t[7] = (o) => e.code = o),
727
+ "hint-text": "Введите новый адрес вашей почты",
728
+ "email-error": J.value,
729
+ "code-error": me.value,
730
+ "rate-limit-text": oe.value,
731
+ "is-final-limit": H.value === 0,
732
+ "is-not-match-code": $.value,
733
+ loading: c.value,
734
+ onEdit: ce,
735
+ onOnMatchCode: Se,
736
+ onOnMatchCodeError: we,
737
+ onOnSendCode: t[8] || (t[8] = (o) => Z({ value: e.newEmail })),
738
+ onOnSendCodeAgain: t[9] || (t[9] = (o) => Z({ value: e.newEmail })),
739
+ onOnClearCodeError: t[10] || (t[10] = (o) => $.value = !1)
740
+ }, null, 8, ["email", "oldEmail", "code", "email-error", "code-error", "rate-limit-text", "is-final-limit", "is-not-match-code", "loading"])) : P("", !0)
741
+ ])) : (y(), k("div", bt, [
742
+ c.value ? (y(), z(ye, { key: 0 })) : P("", !0),
743
+ N.value ? (y(), z(dt, {
744
+ key: 2,
745
+ "model-value": p.value,
746
+ "email-session-id": r.value,
747
+ "onUpdate:modelValue": t[16] || (t[16] = (o) => d("update:modelValue", o)),
748
+ onUpdateUser: Pe,
749
+ onClose: ke
750
+ }, null, 8, ["model-value", "email-session-id"])) : (y(), z(Ze, {
751
+ key: 1,
752
+ email: e.addEmail,
753
+ "onUpdate:email": t[11] || (t[11] = (o) => e.addEmail = o),
754
+ oldEmail: e.addEmail,
755
+ "onUpdate:oldEmail": t[12] || (t[12] = (o) => e.addEmail = o),
756
+ code: e.addCode,
757
+ "onUpdate:code": t[13] || (t[13] = (o) => e.addCode = o),
758
+ "hint-text": m(w) ? l.hintText : "Чтобы продолжить, введите новый адрес вашей почты",
759
+ "rate-limit-text": oe.value,
760
+ "is-final-limit": be.value,
761
+ "is-not-match-code": O.value,
762
+ loading: c.value,
763
+ onOnSendCode: t[14] || (t[14] = (o) => Ee({ value: e.addEmail, field: "email" })),
764
+ onOnSendCodeAgain: t[15] || (t[15] = (o) => Ee({ value: e.addEmail, field: "email" })),
765
+ onOnMatchCode: Be,
766
+ onOnMatchCodeError: Le
767
+ }, null, 8, ["email", "oldEmail", "code", "hint-text", "rate-limit-text", "is-final-limit", "is-not-match-code", "loading"]))
768
+ ]))
769
+ ])
770
+ ]),
771
+ _: 1
772
+ }, 8, ["modelValue"]));
773
+ }
774
+ });
775
+ export {
776
+ St as default
777
+ };