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