@yourgoods/ui-smart 0.46.0 → 0.46.3

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