@yourgoods/ui-smart 0.50.0 → 0.50.1

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