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