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