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