@yourgoods/ui-smart 0.48.0 → 0.49.0

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