@yourgoods/ui-smart 0.53.36 → 0.53.38

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,13 +1,13 @@
1
- import { ref as y, shallowRef as je, defineComponent as X, defineAsyncComponent as Z, watch as we, createBlock as S, createCommentVNode as D, unref as c, openBlock as P, resolveDynamicComponent as qe, mergeProps as Je, computed as A, reactive as H, onMounted as We, createElementBlock as U, Fragment as be, createVNode as w, createElementVNode as Q, withCtx as z, toDisplayString as L, createTextVNode as ee, Teleport as pe, Transition as Ye, withDirectives as Xe, vShow as Ke } from "vue";
2
- import Ze from "axios";
3
- import { PInputFileUploader as He, PInput as R, IconFilledEditMd as W, PButton as fe, PImageCropper as Qe, PToast as ea, PTeleportContainer as Pe, PToastContainer as aa, IconPhoneMd as ta, IconMailMd as oa } from "@profeat/ui-kit";
4
- function na(l, s = 2) {
1
+ import { ref as b, shallowRef as Je, defineComponent as ee, defineAsyncComponent as ae, watch as Ne, createBlock as $, createCommentVNode as I, unref as p, openBlock as N, resolveDynamicComponent as We, mergeProps as Ye, computed as B, reactive as te, onMounted as Ke, createElementBlock as V, Fragment as Ce, createVNode as E, createElementVNode as ne, withCtx as O, toDisplayString as G, createTextVNode as oe, Teleport as ve, Transition as Xe, withDirectives as Ze, vShow as He } from "vue";
2
+ import Qe from "axios";
3
+ import { PInputFileUploader as ea, PInput as j, IconFilledEditMd as H, PButton as he, PImageCropper as aa, PToast as ta, PTeleportContainer as ke, PToastContainer as na, IconPhoneMd as oa, IconMailMd as ra } from "@profeat/ui-kit";
4
+ function la(l, s = 2) {
5
5
  if (l === 0)
6
6
  return "0 B";
7
- const o = 1024, n = ["B", "KB", "MB", "GB", "TB", "PB", "EB"], i = Math.floor(Math.log(l) / Math.log(o));
8
- return `${Number.parseFloat((l / o ** i).toFixed(s))} ${n[i]}`;
7
+ const t = 1024, n = ["B", "KB", "MB", "GB", "TB", "PB", "EB"], f = Math.floor(Math.log(l) / Math.log(t));
8
+ return `${Number.parseFloat((l / t ** f).toFixed(s))} ${n[f]}`;
9
9
  }
10
- const ra = {
10
+ const sa = {
11
11
  "image/jpeg": "JPEG",
12
12
  "image/png": "PNG",
13
13
  "application/pdf": "PDF",
@@ -15,10 +15,10 @@ const ra = {
15
15
  "application/zip": "ZIP Archive"
16
16
  // ...
17
17
  };
18
- function la(l) {
18
+ function ia(l) {
19
19
  return l.map((s) => {
20
- var o;
21
- return ra[s] || ((o = s.split("/")[1]) == null ? void 0 : o.toUpperCase());
20
+ var t;
21
+ return sa[s] || ((t = s.split("/")[1]) == null ? void 0 : t.toUpperCase());
22
22
  });
23
23
  }
24
24
  const $a = {
@@ -28,54 +28,54 @@ const $a = {
28
28
  }, za = {
29
29
  VERIFY_EMAIL: "verify-email"
30
30
  };
31
- let te = null;
32
- function sa(l, s, o) {
33
- te = Ze.create({
31
+ let le = null;
32
+ function ua(l, s, t) {
33
+ le = Qe.create({
34
34
  baseURL: s,
35
35
  headers: {
36
36
  Authorization: `Bearer ${l}`,
37
- "x-throttler-prefix": o ?? "throttler_profile_edit"
37
+ "x-throttler-prefix": t ?? "throttler_profile_edit"
38
38
  // здесь можно словить баг, который может быть сложно отследить, если будет передаваться пустой прелфикс
39
39
  // 'Content-Type': 'application/json',
40
40
  },
41
41
  validateStatus: (n) => n >= 200 && n < 300
42
42
  });
43
43
  }
44
- function ne() {
45
- if (!te)
44
+ function ue() {
45
+ if (!le)
46
46
  throw new Error("Axios instance not initialized. Call initAxios(token, baseUrl) first.");
47
- return te;
47
+ return le;
48
48
  }
49
- async function oe(l, s, o) {
50
- return ne().post(l, s, o);
49
+ async function se(l, s, t) {
50
+ return ue().post(l, s, t);
51
51
  }
52
- async function ia(l, s) {
53
- return ne().get(l, s);
52
+ async function da(l, s) {
53
+ return ue().get(l, s);
54
54
  }
55
- async function ua(l, s) {
56
- return ne().delete(l, s);
55
+ async function ma(l, s) {
56
+ return ue().delete(l, s);
57
57
  }
58
- async function da(l) {
59
- const s = await oe("/users/profile/me", l);
58
+ async function ca(l) {
59
+ const s = await se("/users/profile/me", l);
60
60
  if (s.status !== 200 && s.status !== 201 || !s.data)
61
61
  throw new Error("Ошибка при получении профиля пользователя");
62
62
  return s.data;
63
63
  }
64
- const Y = y(null), ae = je(null);
65
- function re() {
64
+ const Q = b(null), re = Je(null);
65
+ function de() {
66
66
  return {
67
- currentDialog: Y,
68
- dialogPayload: ae,
69
- openDialog: (n, i) => {
70
- Y.value = n, ae.value = i ?? null;
67
+ currentDialog: Q,
68
+ dialogPayload: re,
69
+ openDialog: (n, f) => {
70
+ Q.value = n, re.value = f ?? null;
71
71
  },
72
72
  closeDialog: () => {
73
- Y.value = null, ae.value = null;
73
+ Q.value = null, re.value = null;
74
74
  },
75
- isDialogOpen: (n) => Y.value === n
75
+ isDialogOpen: (n) => Q.value === n
76
76
  };
77
77
  }
78
- const ma = {
78
+ const ie = {
79
79
  ru: {
80
80
  Имя: "Имя",
81
81
  Фамилия: "Фамилия",
@@ -140,7 +140,11 @@ const ma = {
140
140
  "Повторите пароль": "Повторите пароль",
141
141
  "E-mail успешно привязан к аккаунту": "E-mail успешно привязан к аккаунту",
142
142
  "Введите новый номер телефона": "Введите новый номер телефона",
143
- "Телефон успешно изменен": "Телефон успешно изменен"
143
+ "Телефон успешно изменен": "Телефон успешно изменен",
144
+ // перевод для общего phone\email компонента
145
+ "Допустимы только цифры и знак + в начале": "Допустимы только цифры и знак + в начале",
146
+ "Это не похоже на email": "Это не похоже на email",
147
+ "Email или телефон": "Email или телефон"
144
148
  },
145
149
  en: {
146
150
  Имя: "First Name",
@@ -206,9 +210,13 @@ const ma = {
206
210
  "Повторите пароль": "Repeat password",
207
211
  "E-mail успешно привязан к аккаунту": "The email has been successfully linked to the account",
208
212
  "Введите новый номер телефона": "Enter a new phone number",
209
- "Телефон успешно изменен": "Phone number successfully changed"
213
+ "Телефон успешно изменен": "Phone number successfully changed",
214
+ // перевод для общего phone\email компонента
215
+ "Допустимы только цифры и знак + в начале": "Only numbers and + sign are allowed at the beginning",
216
+ "Это не похоже на email": "It’s not like email",
217
+ "Email или телефон": "Email or phone"
210
218
  }
211
- }, ca = /* @__PURE__ */ X({
219
+ }, pa = /* @__PURE__ */ ee({
212
220
  __name: "DialogManager",
213
221
  props: {
214
222
  language: {},
@@ -217,53 +225,53 @@ const ma = {
217
225
  },
218
226
  emits: ["clean-input-errors", "on-update-jwt", "update-phone-field", "update-email-field", "on-password-error", "on-toast"],
219
227
  setup(l, { emit: s }) {
220
- const o = s, n = y(!0), { currentDialog: i, dialogPayload: g, closeDialog: V } = re(), u = {
221
- email: Z(() => import("./ProfileEmailDialog-BeE9t0G7.js")),
222
- phone: Z(() => import("./ProfilePhoneDialog-CzsvzQvb.js")),
223
- password: Z(() => import("./ProfilePasswordDialog-DCrkegUa.js"))
224
- }, d = ({ email: E }) => {
225
- o("update-email-field", E);
226
- }, m = ({ phone: E }) => {
227
- o("update-phone-field", E);
228
+ const t = s, n = b(!0), { currentDialog: f, dialogPayload: g, closeDialog: S } = de(), c = {
229
+ email: ae(() => import("./ProfileEmailDialog-Dc2fR8ip.js")),
230
+ phone: ae(() => import("./ProfilePhoneDialog-DBSI5V-4.js")),
231
+ password: ae(() => import("./ProfilePasswordDialog-34IUb78U.js"))
232
+ }, i = ({ email: P }) => {
233
+ t("update-email-field", P);
234
+ }, v = ({ phone: P }) => {
235
+ t("update-phone-field", P);
228
236
  };
229
- return we(i, (E) => {
230
- n.value = !!E;
231
- }), (E, p) => c(i) ? (P(), S(qe(u[c(i)]), Je({
237
+ return Ne(f, (P) => {
238
+ n.value = !!P;
239
+ }), (P, m) => p(f) ? (N(), $(We(c[p(f)]), Ye({
232
240
  key: 0,
233
241
  modelValue: n.value,
234
- "onUpdate:modelValue": p[0] || (p[0] = (h) => n.value = h),
235
- language: E.language,
236
- provider: E.provider,
237
- "disable-add-phone": E.disableAddPhone
238
- }, c(g), {
239
- onClose: c(V),
240
- onCleanInputErrors: p[1] || (p[1] = (h) => o("clean-input-errors")),
241
- onOnUpdateJwt: p[2] || (p[2] = (h, C, t) => o("on-update-jwt", h, C, t)),
242
- onSubmitEmail: d,
243
- onSubmitPhone: m,
244
- onOnPasswordError: p[3] || (p[3] = (h, C) => o("on-password-error", h, C)),
245
- onOnToast: p[4] || (p[4] = (h) => o("on-toast", h))
246
- }), null, 16, ["modelValue", "language", "provider", "disable-add-phone", "onClose"])) : D("", !0);
242
+ "onUpdate:modelValue": m[0] || (m[0] = (d) => n.value = d),
243
+ language: P.language,
244
+ provider: P.provider,
245
+ "disable-add-phone": P.disableAddPhone
246
+ }, p(g), {
247
+ onClose: p(S),
248
+ onCleanInputErrors: m[1] || (m[1] = (d) => t("clean-input-errors")),
249
+ onOnUpdateJwt: m[2] || (m[2] = (d, w, o) => t("on-update-jwt", d, w, o)),
250
+ onSubmitEmail: i,
251
+ onSubmitPhone: v,
252
+ onOnPasswordError: m[3] || (m[3] = (d, w) => t("on-password-error", d, w)),
253
+ onOnToast: m[4] || (m[4] = (d) => t("on-toast", d))
254
+ }), null, 16, ["modelValue", "language", "provider", "disable-add-phone", "onClose"])) : I("", !0);
247
255
  }
248
- }), pa = { class: "base-container" }, fa = {
256
+ }), fa = { class: "base-container" }, ga = {
249
257
  key: 0,
250
258
  style: { color: "#E46060" }
251
- }, ga = { key: 1 }, va = {
259
+ }, va = { key: 1 }, ha = {
252
260
  key: 1,
253
261
  class: "input-wrapper"
254
- }, ha = {
262
+ }, ya = {
255
263
  key: 2,
256
264
  class: "input-wrapper"
257
- }, ya = {
265
+ }, wa = {
258
266
  key: 3,
259
267
  class: "input-wrapper"
260
- }, wa = {
268
+ }, ba = {
261
269
  key: 4,
262
270
  class: "input-wrapper"
263
- }, ba = { class: "buttons-container" }, Pa = {
271
+ }, Ea = { class: "buttons-container" }, Pa = {
264
272
  key: 0,
265
273
  class: "centered-overlay"
266
- }, Ea = { class: "toastWrapper" }, Na = /* @__PURE__ */ X({
274
+ }, Na = { class: "toastWrapper" }, Ca = /* @__PURE__ */ ee({
267
275
  __name: "PEditUserContact",
268
276
  props: {
269
277
  language: {},
@@ -278,7 +286,7 @@ const ma = {
278
286
  },
279
287
  emits: ["open-email-dialog", "open-phone-dialog", "open-password-dialog", "on-update-jwt", "on-password-error", "update-tokens"],
280
288
  setup(l, { emit: s }) {
281
- const o = l, n = s, i = A(() => o.language ?? "ru"), g = (e) => ma[i.value][e] || e, { openDialog: V } = re(), u = H({ firstName: "", lastName: "" }), d = y({ firstName: "", lastName: "" }), m = H({ firstName: !1, lastName: !1, email: !1, phone: !1 }), E = y(""), p = y(""), h = y(""), C = y(!1), t = H({
289
+ const t = l, n = s, f = B(() => t.language ?? "ru"), g = (e) => ie[f.value][e] || e, { openDialog: S } = de(), c = te({ firstName: "", lastName: "" }), i = b({ firstName: "", lastName: "" }), v = te({ firstName: !1, lastName: !1, email: !1, phone: !1 }), P = b(""), m = b(""), d = b(""), w = b(!1), o = te({
282
290
  value: null,
283
291
  loading: !1,
284
292
  accept: ["image/png", "image/jpeg"],
@@ -286,334 +294,334 @@ const ma = {
286
294
  // 10 MB
287
295
  imageBinary: null,
288
296
  imageContent: ""
289
- }), v = y(""), f = y(!1), b = y(!0), I = y(!0), N = y(void 0), x = y(""), M = A(() => se(u.firstName, m.firstName)), F = A(() => se(u.lastName, m.lastName)), _ = A(() => m.email && !p.value.trim() ? "Введите e-mail" : ""), O = A(() => m.phone && !h.value.trim() ? "Введите номер телефона" : ""), $ = (e) => o.fields.some((a) => a.key === e), le = (e) => e && e.trim() ? "edit" : "bind", K = () => setTimeout(() => {
297
+ }), x = b(""), z = b(!1), L = b(!0), _ = b(!0), q = b(void 0), u = b(""), h = B(() => R(c.firstName, v.firstName)), y = B(() => R(c.lastName, v.lastName)), A = B(() => v.email && !m.value.trim() ? "Введите e-mail" : ""), k = B(() => v.phone && !d.value.trim() ? "Введите номер телефона" : ""), F = (e) => t.fields.some((a) => a.key === e), M = (e) => e && e.trim() ? "edit" : "bind", U = () => setTimeout(() => {
290
298
  var e;
291
299
  return (e = document.activeElement) == null ? void 0 : e.blur();
292
- }, 0), Ne = A(() => !!(p.value && p.value.trim() !== "")), Ce = A(() => t.imageContent ? g("Загрузить другое фото") : g("Загрузить фото")), se = (e, a) => {
300
+ }, 0), J = B(() => !!(m.value && m.value.trim() !== "")), W = B(() => o.imageContent ? g("Загрузить другое фото") : g("Загрузить фото")), R = (e, a) => {
293
301
  if (!a) return "";
294
302
  const r = e.trim();
295
303
  return r ? r.length < 2 ? "Поле должно содержать минимум 2 символа" : "" : "Введите значение";
296
- }, ke = (e) => V("email", { mode: e ? "edit" : "bind", initialEmail: e }), Te = () => {
297
- K(), m.email = !1, I.value = !1, n("open-email-dialog", p.value, le(p.value)), ke(p.value);
298
- }, Be = () => {
299
- K(), m.phone = !1, b.value = !1, n("open-phone-dialog", h.value, le(h.value));
300
- }, De = async (e, a, r) => {
301
- e === "email" && r && (p.value = r), e === "phone" && r && (h.value = r), n("on-update-jwt");
302
- }, Ie = (e) => {
303
- h.value = e;
304
- }, Ue = (e) => {
305
- p.value = e;
306
- }, Ve = (e, a) => {
307
- f.value = !0, n("on-password-error", e, a);
308
- }, Ae = () => {
309
- b.value = !1, I.value = !1;
310
- }, G = (e) => {
311
- f.value = !0, N.value = e.color ?? "", x.value = e.text ?? "";
312
- }, j = (e) => {
313
- if (m[e] = !0, e === "firstName" || e === "lastName") {
314
- const a = u[e];
315
- a.length > 40 && (u[e] = a.slice(0, 40));
304
+ }, Be = (e) => S("email", { mode: e ? "edit" : "bind", initialEmail: e }), De = () => {
305
+ U(), v.email = !1, _.value = !1, n("open-email-dialog", m.value, M(m.value)), Be(m.value);
306
+ }, Ie = () => {
307
+ U(), v.phone = !1, L.value = !1, n("open-phone-dialog", d.value, M(d.value));
308
+ }, Ue = async (e, a, r) => {
309
+ e === "email" && r && (m.value = r), e === "phone" && r && (d.value = r), n("on-update-jwt");
310
+ }, Ve = (e) => {
311
+ d.value = e;
312
+ }, Ae = (e) => {
313
+ m.value = e;
314
+ }, Fe = (e, a) => {
315
+ z.value = !0, n("on-password-error", e, a);
316
+ }, Se = () => {
317
+ L.value = !1, _.value = !1;
318
+ }, Y = (e) => {
319
+ z.value = !0, q.value = e.color ?? "", u.value = e.text ?? "";
320
+ }, K = (e) => {
321
+ if (v[e] = !0, e === "firstName" || e === "lastName") {
322
+ const a = c[e];
323
+ a.length > 40 && (c[e] = a.slice(0, 40));
316
324
  }
317
- }, Fe = (e) => {
318
- var q, J;
319
- if (v.value = "", !e) {
320
- ie();
325
+ }, xe = (e) => {
326
+ var X, Z;
327
+ if (x.value = "", !e) {
328
+ me();
321
329
  return;
322
330
  }
323
- const a = ((q = e.fileBinary) == null ? void 0 : q.type) ?? "", r = ((J = e.fileBinary) == null ? void 0 : J.size) ?? 0, B = !["image/png", "image/jpeg"].includes(a), T = r > t.uploadLimit;
324
- if (B || T) {
325
- v.value = "Файл не подходит. Пожалуйста, загрузите PNG или JPEG размером до 10 МБ", ie();
331
+ const a = ((X = e.fileBinary) == null ? void 0 : X.type) ?? "", r = ((Z = e.fileBinary) == null ? void 0 : Z.size) ?? 0, D = !["image/png", "image/jpeg"].includes(a), T = r > o.uploadLimit;
332
+ if (D || T) {
333
+ x.value = "Файл не подходит. Пожалуйста, загрузите PNG или JPEG размером до 10 МБ", me();
326
334
  return;
327
335
  }
328
- t.value = e, t.imageBinary = e.fileBinary ?? null, t.imageContent = e.fileContent ?? "", C.value = !0;
329
- }, ie = () => {
330
- t.value = null, t.imageBinary = null, t.imageContent = "", C.value = !1;
331
- }, Se = async () => {
336
+ o.value = e, o.imageBinary = e.fileBinary ?? null, o.imageContent = e.fileContent ?? "", w.value = !0;
337
+ }, me = () => {
338
+ o.value = null, o.imageBinary = null, o.imageContent = "", w.value = !1;
339
+ }, Me = async () => {
332
340
  try {
333
- const a = (await ua("/users/profile/delete/avatar")).data;
341
+ const a = (await ma("/users/profile/delete/avatar")).data;
334
342
  return (a == null ? void 0 : a.success) === !0;
335
343
  } catch (e) {
336
344
  return console.error("Ошибка при удалении аватара:", e), !1;
337
345
  }
338
- }, xe = () => {
339
- v.value = "Файл не подходит. Пожалуйста, загрузите PNG или JPEG размером до 10 МБ", t.value = null, t.imageBinary = null, t.imageContent = "", C.value = !1;
340
- }, ue = async (e, a, r = "image/png") => {
346
+ }, $e = () => {
347
+ x.value = "Файл не подходит. Пожалуйста, загрузите PNG или JPEG размером до 10 МБ", o.value = null, o.imageBinary = null, o.imageContent = "", w.value = !1;
348
+ }, ce = async (e, a, r = "image/png") => {
341
349
  if (!e) return null;
342
- const B = await (await fetch(e)).blob();
343
- return new File([B], a, { type: r });
344
- }, Me = () => {
345
- t.value = null, t.imageBinary = null, t.imageContent = "", C.value = !1;
346
- }, $e = async (e) => {
347
- C.value = !1;
348
- const a = t.imageContent;
349
- if (t.imageContent = e, !t.imageBinary) return;
350
- const r = await ue(
350
+ const D = await (await fetch(e)).blob();
351
+ return new File([D], a, { type: r });
352
+ }, ze = () => {
353
+ o.value = null, o.imageBinary = null, o.imageContent = "", w.value = !1;
354
+ }, Le = async (e) => {
355
+ w.value = !1;
356
+ const a = o.imageContent;
357
+ if (o.imageContent = e, !o.imageBinary) return;
358
+ const r = await ce(
351
359
  e,
352
- t.imageBinary.name,
353
- t.imageBinary.type || "image/png"
360
+ o.imageBinary.name,
361
+ o.imageBinary.type || "image/png"
354
362
  );
355
363
  if (!r) {
356
- t.imageContent = a;
364
+ o.imageContent = a;
357
365
  return;
358
366
  }
359
367
  try {
360
- t.loading = !0;
361
- const k = new FormData();
362
- k.append("file", r), await oe(`/users/profile/avatar/${E.value}`, k, { headers: { "Content-Type": void 0 } });
363
- } catch (k) {
364
- console.error(k), G({
368
+ o.loading = !0;
369
+ const C = new FormData();
370
+ C.append("file", r), await se(`/users/profile/avatar/${P.value}`, C, { headers: { "Content-Type": void 0 } });
371
+ } catch (C) {
372
+ console.error(C), Y({
365
373
  color: "error",
366
374
  text: g("Не удалось сохранить изменения. Попробуйте позже")
367
- }), t.imageContent = a;
375
+ }), o.imageContent = a;
368
376
  } finally {
369
- t.loading = !1;
377
+ o.loading = !1;
370
378
  }
371
- }, ze = async (e) => {
372
- t.imageContent = e ?? "", t.imageBinary && (t.imageBinary = await ue(
379
+ }, _e = async (e) => {
380
+ o.imageContent = e ?? "", o.imageBinary && (o.imageBinary = await ce(
373
381
  e ?? "",
374
- t.imageBinary.name,
375
- t.imageBinary.type || "image/png"
382
+ o.imageBinary.name,
383
+ o.imageBinary.type || "image/png"
376
384
  ));
377
- }, de = y(!1), me = async (e) => {
378
- var r, k;
379
- const a = (r = u[e]) == null ? void 0 : r.trim();
385
+ }, pe = b(!1), fe = async (e) => {
386
+ var r, C;
387
+ const a = (r = c[e]) == null ? void 0 : r.trim();
380
388
  if (a)
381
389
  try {
382
- de.value = !0;
383
- const T = (k = (await oe("/users/profile/update-name", { [e]: a })).data) == null ? void 0 : k.data;
384
- T != null && T.user && (u.firstName = T.user.firstName ?? u.firstName, u.lastName = T.user.lastName ?? u.lastName, d.value = {
385
- firstName: u.firstName,
386
- lastName: u.lastName
390
+ pe.value = !0;
391
+ const T = (C = (await se("/users/profile/update-name", { [e]: a })).data) == null ? void 0 : C.data;
392
+ T != null && T.user && (c.firstName = T.user.firstName ?? c.firstName, c.lastName = T.user.lastName ?? c.lastName, i.value = {
393
+ firstName: c.firstName,
394
+ lastName: c.lastName
387
395
  });
388
- } catch (B) {
389
- throw B;
396
+ } catch (D) {
397
+ throw D;
390
398
  } finally {
391
- de.value = !1;
399
+ pe.value = !1;
392
400
  }
393
- }, Le = async () => {
401
+ }, Re = async () => {
394
402
  var e;
395
- if (!o.accessToken)
403
+ if (!t.accessToken)
396
404
  throw console.error("Access token не передан в props"), new Error("Access token is required");
397
405
  try {
398
- const r = (e = (await da({
399
- accessToken: o.accessToken,
400
- refreshToken: o.refreshToken ?? "",
406
+ const r = (e = (await ca({
407
+ accessToken: t.accessToken,
408
+ refreshToken: t.refreshToken ?? "",
401
409
  excludeFields: []
402
410
  })).data) == null ? void 0 : e.user;
403
411
  if (!r)
404
412
  throw console.error("Данные пользователя отсутствуют в ответе сервера"), new Error("User data is missing from the response");
405
413
  const {
406
- userId: k,
407
- privateFirstName: B,
414
+ userId: C,
415
+ privateFirstName: D,
408
416
  privateLastName: T,
409
- email: q,
410
- phoneNumber: J
417
+ email: X,
418
+ phoneNumber: Z
411
419
  } = r;
412
- E.value = k ?? "", u.firstName = B ?? "", u.lastName = T ?? "", p.value = q ?? "", h.value = J ?? "", t.imageContent = await Re(), d.value = {
413
- firstName: B ?? "",
420
+ P.value = C ?? "", c.firstName = D ?? "", c.lastName = T ?? "", m.value = X ?? "", d.value = Z ?? "", o.imageContent = await Oe(), i.value = {
421
+ firstName: D ?? "",
414
422
  lastName: T ?? ""
415
423
  };
416
424
  } catch (a) {
417
425
  console.error("Критическая ошибка при загрузке профиля:", a);
418
426
  }
419
- }, Re = async () => {
427
+ }, Oe = async () => {
420
428
  var e;
421
429
  try {
422
- const r = (e = (await ia("/users/profile/avatar")).data) == null ? void 0 : e.data;
423
- return r ? _e(r) : "";
430
+ const r = (e = (await da("/users/profile/avatar")).data) == null ? void 0 : e.data;
431
+ return r ? Ge(r) : "";
424
432
  } catch (a) {
425
433
  return console.error("Ошибка при загрузке метаданных аватара:", a), "";
426
434
  }
427
435
  };
428
- function _e(e) {
436
+ function Ge(e) {
429
437
  if (!e)
430
438
  return "";
431
439
  try {
432
- return new URL(e.key, o.awsStorageUrl).toString();
440
+ return new URL(e.key, t.awsStorageUrl).toString();
433
441
  } catch (a) {
434
442
  return console.error("Ошибка при составлении URL аватара:", a), "";
435
443
  }
436
444
  }
437
- const ce = A(() => {
438
- if (!d.value.firstName && !d.value.lastName)
445
+ const ge = B(() => {
446
+ if (!i.value.firstName && !i.value.lastName)
439
447
  return !1;
440
- const e = u.firstName.trim(), a = u.lastName.trim(), r = d.value.firstName.trim(), k = d.value.lastName.trim(), B = e !== r || a !== k, T = e.length >= 2 && a.length >= 2;
441
- return B && T;
442
- }), Oe = async () => {
443
- if (ce.value)
448
+ const e = c.firstName.trim(), a = c.lastName.trim(), r = i.value.firstName.trim(), C = i.value.lastName.trim(), D = e !== r || a !== C, T = e.length >= 2 && a.length >= 2;
449
+ return D && T;
450
+ }), je = async () => {
451
+ if (ge.value)
444
452
  try {
445
- await Promise.all([me("firstName"), me("lastName")]), n("on-update-jwt"), G({ color: "success", text: "Изменения сохранены" });
453
+ await Promise.all([fe("firstName"), fe("lastName")]), n("on-update-jwt"), Y({ color: "success", text: "Изменения сохранены" });
446
454
  } catch (e) {
447
- console.error(e), G({
455
+ console.error(e), Y({
448
456
  color: "error",
449
457
  text: g("Не удалось сохранить изменения. Попробуйте позже")
450
458
  });
451
459
  }
452
- }, Ge = () => {
453
- K(), n("open-password-dialog");
460
+ }, qe = () => {
461
+ U(), n("open-password-dialog");
454
462
  };
455
- return We(async () => {
456
- if (!o.accessToken) throw new Error("Access token не передан в props");
457
- if (!o.requestUrl) throw new Error("auth-backend url не передан в props");
458
- sa(o.accessToken, o.requestUrl, o.throttlerPrefix), await Le();
459
- }), (e, a) => (P(), U(be, null, [
460
- w(ca, {
461
- language: i.value,
463
+ return Ke(async () => {
464
+ if (!t.accessToken) throw new Error("Access token не передан в props");
465
+ if (!t.requestUrl) throw new Error("auth-backend url не передан в props");
466
+ ua(t.accessToken, t.requestUrl, t.throttlerPrefix), await Re();
467
+ }), (e, a) => (N(), V(Ce, null, [
468
+ E(pa, {
469
+ language: f.value,
462
470
  provider: e.provider,
463
471
  "disable-add-phone": e.disableAddPhone,
464
- onCleanInputErrors: Ae,
465
- onOnUpdateJwt: De,
466
- onUpdatePhoneField: Ie,
467
- onUpdateEmailField: Ue,
468
- onOnPasswordError: Ve,
469
- onOnToast: G
472
+ onCleanInputErrors: Se,
473
+ onOnUpdateJwt: Ue,
474
+ onUpdatePhoneField: Ve,
475
+ onUpdateEmailField: Ae,
476
+ onOnPasswordError: Fe,
477
+ onOnToast: Y
470
478
  }, null, 8, ["language", "provider", "disable-add-phone"]),
471
- Q("div", pa, [
472
- $("avatar") ? (P(), S(c(He), {
479
+ ne("div", fa, [
480
+ F("avatar") ? (N(), $(p(ea), {
473
481
  key: 0,
474
- modelValue: t.value,
482
+ modelValue: o.value,
475
483
  "onUpdate:modelValue": [
476
- a[0] || (a[0] = (r) => t.value = r),
477
- a[1] || (a[1] = (r) => Fe(r))
484
+ a[0] || (a[0] = (r) => o.value = r),
485
+ a[1] || (a[1] = (r) => xe(r))
478
486
  ],
479
487
  type: "img",
480
488
  class: "avatar-input",
481
- src: t.imageContent,
482
- loading: t.loading,
489
+ src: o.imageContent,
490
+ loading: o.loading,
483
491
  label: g("Загрузить фото"),
484
- "upload-limit": t.uploadLimit,
492
+ "upload-limit": o.uploadLimit,
485
493
  accept: "image/jpeg, image/png",
486
- onDelete: Se,
487
- "onChange:error": xe
494
+ onDelete: Me,
495
+ "onChange:error": $e
488
496
  }, {
489
- afterLoadLabel: z(() => [
490
- ee(L(Ce.value), 1)
497
+ afterLoadLabel: O(() => [
498
+ oe(G(W.value), 1)
491
499
  ]),
492
- subtext: z(() => [
493
- v.value ? (P(), U("span", fa, L(v.value), 1)) : (P(), U("span", ga, L(`${g("Формат")} ${c(la)(t.accept).join(", ")} ${g("до")} ${c(na)(t.uploadLimit)}`), 1))
500
+ subtext: O(() => [
501
+ x.value ? (N(), V("span", ga, G(x.value), 1)) : (N(), V("span", va, G(`${g("Формат")} ${p(ia)(o.accept).join(", ")} ${g("до")} ${p(la)(o.uploadLimit)}`), 1))
494
502
  ]),
495
503
  _: 1
496
- }, 8, ["modelValue", "src", "loading", "label", "upload-limit"])) : D("", !0),
497
- $("firstName") ? (P(), U("div", va, [
498
- w(c(R), {
499
- modelValue: u.firstName,
500
- "onUpdate:modelValue": a[2] || (a[2] = (r) => u.firstName = r),
504
+ }, 8, ["modelValue", "src", "loading", "label", "upload-limit"])) : I("", !0),
505
+ F("firstName") ? (N(), V("div", ha, [
506
+ E(p(j), {
507
+ modelValue: c.firstName,
508
+ "onUpdate:modelValue": a[2] || (a[2] = (r) => c.firstName = r),
501
509
  size: "large",
502
510
  label: g("Имя"),
503
- error: M.value,
504
- onBlur: a[3] || (a[3] = (r) => m.firstName = !0),
505
- onInput: a[4] || (a[4] = (r) => j("firstName"))
511
+ error: h.value,
512
+ onBlur: a[3] || (a[3] = (r) => v.firstName = !0),
513
+ onInput: a[4] || (a[4] = (r) => K("firstName"))
506
514
  }, null, 8, ["modelValue", "label", "error"]),
507
- w(c(W), { class: "icon-locked" })
508
- ])) : D("", !0),
509
- $("lastName") ? (P(), U("div", ha, [
510
- w(c(R), {
511
- modelValue: u.lastName,
512
- "onUpdate:modelValue": a[5] || (a[5] = (r) => u.lastName = r),
515
+ E(p(H), { class: "icon-locked" })
516
+ ])) : I("", !0),
517
+ F("lastName") ? (N(), V("div", ya, [
518
+ E(p(j), {
519
+ modelValue: c.lastName,
520
+ "onUpdate:modelValue": a[5] || (a[5] = (r) => c.lastName = r),
513
521
  size: "large",
514
522
  label: g("Фамилия"),
515
- error: F.value,
516
- onBlur: a[6] || (a[6] = (r) => m.lastName = !0),
517
- onInput: a[7] || (a[7] = (r) => j("lastName"))
523
+ error: y.value,
524
+ onBlur: a[6] || (a[6] = (r) => v.lastName = !0),
525
+ onInput: a[7] || (a[7] = (r) => K("lastName"))
518
526
  }, null, 8, ["modelValue", "label", "error"]),
519
- w(c(W), { class: "icon-locked" })
520
- ])) : D("", !0),
521
- $("email") ? (P(), U("div", ya, [
522
- w(c(R), {
523
- modelValue: p.value,
524
- "onUpdate:modelValue": a[8] || (a[8] = (r) => p.value = r),
527
+ E(p(H), { class: "icon-locked" })
528
+ ])) : I("", !0),
529
+ F("email") ? (N(), V("div", wa, [
530
+ E(p(j), {
531
+ modelValue: m.value,
532
+ "onUpdate:modelValue": a[8] || (a[8] = (r) => m.value = r),
525
533
  size: "large",
526
534
  "text-size": "medium",
527
535
  label: "E-mail",
528
536
  type: "email",
529
537
  readonly: "",
530
538
  style: { cursor: "pointer" },
531
- error: _.value && I.value,
532
- onBlur: a[9] || (a[9] = (r) => m.email = !0),
533
- onInput: a[10] || (a[10] = (r) => j("email")),
534
- onClick: Te
539
+ error: A.value && _.value,
540
+ onBlur: a[9] || (a[9] = (r) => v.email = !0),
541
+ onInput: a[10] || (a[10] = (r) => K("email")),
542
+ onClick: De
535
543
  }, null, 8, ["modelValue", "error"]),
536
- w(c(W), { class: "icon-locked" })
537
- ])) : D("", !0),
538
- $("phone") ? (P(), U("div", wa, [
539
- w(c(R), {
540
- modelValue: h.value,
541
- "onUpdate:modelValue": a[11] || (a[11] = (r) => h.value = r),
544
+ E(p(H), { class: "icon-locked" })
545
+ ])) : I("", !0),
546
+ F("phone") ? (N(), V("div", ba, [
547
+ E(p(j), {
548
+ modelValue: d.value,
549
+ "onUpdate:modelValue": a[11] || (a[11] = (r) => d.value = r),
542
550
  size: "large",
543
551
  "text-size": "medium",
544
552
  label: g("Номер телефона"),
545
553
  type: "tel",
546
554
  readonly: "",
547
555
  style: { cursor: "pointer" },
548
- error: O.value && b.value,
549
- onBlur: a[12] || (a[12] = (r) => m.phone = !0),
550
- onInput: a[13] || (a[13] = (r) => j("phone")),
551
- onClick: Be
556
+ error: k.value && L.value,
557
+ onBlur: a[12] || (a[12] = (r) => v.phone = !0),
558
+ onInput: a[13] || (a[13] = (r) => K("phone")),
559
+ onClick: Ie
552
560
  }, null, 8, ["modelValue", "label", "error"]),
553
- w(c(W), { class: "icon-locked" })
554
- ])) : D("", !0),
555
- Q("div", ba, [
556
- Ne.value ? (P(), S(c(fe), {
561
+ E(p(H), { class: "icon-locked" })
562
+ ])) : I("", !0),
563
+ ne("div", Ea, [
564
+ J.value ? (N(), $(p(he), {
557
565
  key: 0,
558
566
  color: "secondary",
559
- onClick: Ge
567
+ onClick: qe
560
568
  }, {
561
- default: z(() => [
562
- ee(L(g("Сменить пароль")), 1)
569
+ default: O(() => [
570
+ oe(G(g("Сменить пароль")), 1)
563
571
  ]),
564
572
  _: 1
565
- })) : D("", !0),
566
- w(c(fe), {
567
- disabled: !ce.value,
568
- onClick: Oe
573
+ })) : I("", !0),
574
+ E(p(he), {
575
+ disabled: !ge.value,
576
+ onClick: je
569
577
  }, {
570
- default: z(() => [
571
- ee(L(g("Сохранить")), 1)
578
+ default: O(() => [
579
+ oe(G(g("Сохранить")), 1)
572
580
  ]),
573
581
  _: 1
574
582
  }, 8, ["disabled"])
575
583
  ])
576
584
  ]),
577
- C.value ? (P(), S(pe, {
585
+ w.value ? (N(), $(ve, {
578
586
  key: 0,
579
587
  to: "body"
580
588
  }, [
581
- C.value ? (P(), U("div", Pa, [
582
- w(c(Qe), {
589
+ w.value ? (N(), V("div", Pa, [
590
+ E(p(aa), {
583
591
  "circle-mode": !0,
584
- "model-value": t.imageContent,
585
- onClose: Me,
586
- onSave: a[14] || (a[14] = (r) => $e(r)),
587
- "onUpdate:modelValue": a[15] || (a[15] = (r) => ze(r))
592
+ "model-value": o.imageContent,
593
+ onClose: ze,
594
+ onSave: a[14] || (a[14] = (r) => Le(r)),
595
+ "onUpdate:modelValue": a[15] || (a[15] = (r) => _e(r))
588
596
  }, null, 8, ["model-value"])
589
- ])) : D("", !0)
590
- ])) : D("", !0),
591
- (P(), S(pe, { to: "#toast-root" }, [
592
- Q("div", Ea, [
593
- w(Ye, { name: "list" }, {
594
- default: z(() => [
595
- Xe(w(c(ea), {
597
+ ])) : I("", !0)
598
+ ])) : I("", !0),
599
+ (N(), $(ve, { to: "#toast-root" }, [
600
+ ne("div", Na, [
601
+ E(Xe, { name: "list" }, {
602
+ default: O(() => [
603
+ Ze(E(p(ta), {
596
604
  class: "toast",
597
- color: N.value,
598
- text: x.value,
599
- onClose: a[16] || (a[16] = (r) => f.value = !1)
605
+ color: q.value,
606
+ text: u.value,
607
+ onClose: a[16] || (a[16] = (r) => z.value = !1)
600
608
  }, null, 8, ["color", "text"]), [
601
- [Ke, f.value]
609
+ [He, z.value]
602
610
  ])
603
611
  ]),
604
612
  _: 1
605
613
  })
606
614
  ])
607
615
  ])),
608
- w(c(Pe))
616
+ E(p(ke))
609
617
  ], 64));
610
618
  }
611
- }), Ee = (l, s) => {
612
- const o = l.__vccOpts || l;
613
- for (const [n, i] of s)
614
- o[n] = i;
615
- return o;
616
- }, Ca = /* @__PURE__ */ Ee(Na, [["__scopeId", "data-v-a56fcdbb"]]), La = /* @__PURE__ */ X({
619
+ }), Te = (l, s) => {
620
+ const t = l.__vccOpts || l;
621
+ for (const [n, f] of s)
622
+ t[n] = f;
623
+ return t;
624
+ }, ka = /* @__PURE__ */ Te(Ca, [["__scopeId", "data-v-4e8a6f81"]]), La = /* @__PURE__ */ ee({
617
625
  __name: "index",
618
626
  props: {
619
627
  throttlerPrefix: {},
@@ -628,66 +636,66 @@ const ma = {
628
636
  },
629
637
  emits: ["on-update-jwt", "update-tokens"],
630
638
  setup(l, { emit: s }) {
631
- const o = s, { openDialog: n } = re(), i = (d, m) => {
632
- n("email", { initialEmail: d, mode: m });
633
- }, g = (d, m) => {
634
- n("phone", { initialPhone: d, mode: m });
635
- }, V = () => {
639
+ const t = s, { openDialog: n } = de(), f = (i, v) => {
640
+ n("email", { initialEmail: i, mode: v });
641
+ }, g = (i, v) => {
642
+ n("phone", { initialPhone: i, mode: v });
643
+ }, S = () => {
636
644
  n("password");
637
- }, u = (d, m, E) => {
638
- o("on-update-jwt", d, m, E);
645
+ }, c = (i, v, P) => {
646
+ t("on-update-jwt", i, v, P);
639
647
  };
640
- return (d, m) => (P(), U(be, null, [
641
- w(c(aa)),
642
- w(Ca, {
643
- "throttler-prefix": d.throttlerPrefix,
644
- provider: d.provider,
645
- "request-url": d.requestUrl,
646
- language: d.language,
647
- fields: d.fields,
648
- "access-token": d.accessToken,
649
- "refresh-token": d.refreshToken,
650
- "aws-storage-url": d.awsStorageUrl,
651
- "disable-add-phone": d.disableAddPhone,
652
- onOpenEmailDialog: i,
648
+ return (i, v) => (N(), V(Ce, null, [
649
+ E(p(na)),
650
+ E(ka, {
651
+ "throttler-prefix": i.throttlerPrefix,
652
+ provider: i.provider,
653
+ "request-url": i.requestUrl,
654
+ language: i.language,
655
+ fields: i.fields,
656
+ "access-token": i.accessToken,
657
+ "refresh-token": i.refreshToken,
658
+ "aws-storage-url": i.awsStorageUrl,
659
+ "disable-add-phone": i.disableAddPhone,
660
+ onOpenEmailDialog: f,
653
661
  onOpenPhoneDialog: g,
654
- onOpenPasswordDialog: V,
655
- onOnUpdateJwt: u
662
+ onOpenPasswordDialog: S,
663
+ onOnUpdateJwt: c
656
664
  }, null, 8, ["throttler-prefix", "provider", "request-url", "language", "fields", "access-token", "refresh-token", "aws-storage-url", "disable-add-phone"]),
657
- w(c(Pe))
665
+ E(p(ke))
658
666
  ], 64));
659
667
  }
660
- }), ka = 10, Ta = 10, Ba = 15;
661
- function ge(l, s, o) {
668
+ }), Ta = 10, Ba = 10, Da = 15;
669
+ function ye(l, s, t) {
662
670
  let n = l.replace(/[^\d+]/g, "").replace(/(?!^)\+/g, "");
663
- return o != null && o.startsWith("ru") && n.startsWith("8") ? n = `+7${n.slice(1)}` : s && n && !n.startsWith("+") && (n = `+${n}`), n;
671
+ return t != null && t.startsWith("ru") && n.startsWith("8") ? n = `+7${n.slice(1)}` : s && n && !n.startsWith("+") && (n = `+${n}`), n;
664
672
  }
665
- function ve(l) {
673
+ function we(l) {
666
674
  return l.startsWith("+") ? l.slice(1).replace(/\D/g, "") : l.replace(/\D/g, "");
667
675
  }
668
- function he(l, s = ka, o = Ba) {
676
+ function be(l, s = Ta, t = Da) {
669
677
  if (!l.startsWith("+"))
670
678
  return !1;
671
679
  const n = l.slice(1);
672
- return !(!/^\d+$/.test(n) || n.length < s || n.length > o);
680
+ return !(!/^\d+$/.test(n) || n.length < s || n.length > t);
673
681
  }
674
- function Da(l) {
682
+ function Ee(l) {
675
683
  return !/^\+?\d*$/.test(l);
676
684
  }
677
685
  function Ia(l, s) {
678
- let o = 0, n = !1;
679
- return l.split("").filter((i, g) => i === "+" ? g !== 0 || n ? !1 : (n = !0, !0) : /\d/.test(i) ? (o++, o <= s) : !1).join("");
686
+ let t = 0, n = !1;
687
+ return l.split("").filter((f, g) => f === "+" ? g !== 0 || n ? !1 : (n = !0, !0) : /\d/.test(f) ? (t++, t <= s) : !1).join("");
680
688
  }
681
689
  const Ua = /^[\w.%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/i;
682
- function ye(l) {
690
+ function Pe(l) {
683
691
  return Ua.test(l);
684
692
  }
685
693
  function Va(l, s) {
686
- var n, i;
687
- const o = l.trim();
688
- return (n = s.phone) != null && n.enabled && /\d/.test(o) && !o.includes("@") ? "phone" : (i = s.email) != null && i.enabled ? "email" : null;
694
+ var n, f;
695
+ const t = l.trim();
696
+ return (n = s.phone) != null && n.enabled && /\d/.test(t) && !t.includes("@") ? "phone" : (f = s.email) != null && f.enabled ? "email" : null;
689
697
  }
690
- const Aa = { class: "smart-input" }, Fa = /* @__PURE__ */ X({
698
+ const Aa = { class: "smart-input" }, Fa = /* @__PURE__ */ ee({
691
699
  __name: "index",
692
700
  props: {
693
701
  modelValue: {},
@@ -701,132 +709,153 @@ const Aa = { class: "smart-input" }, Fa = /* @__PURE__ */ X({
701
709
  },
702
710
  emits: ["update:modelValue", "validity-change", "type-change"],
703
711
  setup(l, { emit: s }) {
704
- const o = l, n = s, i = A(() => {
705
- var t, v, f, b, I, N, x, M, F, _, O;
712
+ const t = l, n = s, f = B(() => t.locale ?? "ru"), g = (u) => ie[f.value][u] || u, S = B(() => t.label ? g(t.label) : g("Email или телефон"));
713
+ function c(u, h) {
714
+ return h ? h in ie[f.value] ? g(h) : h : g(u);
715
+ }
716
+ const i = B(() => {
717
+ var u, h, y, A, k, F, M, U, J, W, R;
706
718
  return {
707
- mode: ((t = o.config) == null ? void 0 : t.mode) ?? "auto",
719
+ mode: ((u = t.config) == null ? void 0 : u.mode) ?? "auto",
708
720
  phone: {
709
- enabled: ((f = (v = o.config) == null ? void 0 : v.phone) == null ? void 0 : f.enabled) ?? !0,
710
- minDigits: ((I = (b = o.config) == null ? void 0 : b.phone) == null ? void 0 : I.minDigits) ?? 10,
711
- maxDigits: ((x = (N = o.config) == null ? void 0 : N.phone) == null ? void 0 : x.maxDigits) ?? 15,
712
- autoPlus: ((F = (M = o.config) == null ? void 0 : M.phone) == null ? void 0 : F.autoPlus) ?? !0
721
+ enabled: ((y = (h = t.config) == null ? void 0 : h.phone) == null ? void 0 : y.enabled) ?? !0,
722
+ minDigits: ((k = (A = t.config) == null ? void 0 : A.phone) == null ? void 0 : k.minDigits) ?? 10,
723
+ maxDigits: ((M = (F = t.config) == null ? void 0 : F.phone) == null ? void 0 : M.maxDigits) ?? 15,
724
+ autoPlus: ((J = (U = t.config) == null ? void 0 : U.phone) == null ? void 0 : J.autoPlus) ?? !0
713
725
  },
714
726
  email: {
715
- enabled: ((O = (_ = o.config) == null ? void 0 : _.email) == null ? void 0 : O.enabled) ?? !0
727
+ enabled: ((R = (W = t.config) == null ? void 0 : W.email) == null ? void 0 : R.enabled) ?? !0
716
728
  }
717
729
  };
718
- }), g = y(null), V = y(""), u = y(o.modelValue ?? ""), d = y(null), m = y("");
719
- we(() => o.modelValue, (t) => {
720
- t !== void 0 && (u.value = t, V.value = t);
721
730
  });
722
- function E(t) {
723
- var I;
724
- m.value = "";
725
- const f = t.target.value;
726
- if (f.trim() === "") {
727
- d.value = null, m.value = "", n("type-change", null), n("update:modelValue", ""), n("validity-change", !1);
731
+ function v(u) {
732
+ if (t.errorMessages)
733
+ switch (u) {
734
+ case "Допустимы только цифры и знак + в начале":
735
+ return t.errorMessages.invalidPhoneChars;
736
+ case "Это не похоже на номер телефона":
737
+ return t.errorMessages.invalidPhoneLength;
738
+ case "Это не похоже на email":
739
+ return t.errorMessages.invalidEmail;
740
+ }
741
+ }
742
+ const P = b(null), m = b(""), d = b(t.modelValue ?? ""), w = b(null), o = b(null), x = B(() => o.value ? c(
743
+ o.value,
744
+ v(o.value)
745
+ ) : "");
746
+ Ne(() => t.modelValue, (u) => {
747
+ u !== void 0 && (d.value = u, m.value = u);
748
+ });
749
+ function z(u) {
750
+ o.value = null;
751
+ const y = u.target.value;
752
+ if (y.trim() === "") {
753
+ w.value = null, o.value = null, n("type-change", null), n("update:modelValue", ""), n("validity-change", !1);
728
754
  return;
729
755
  }
730
- const b = i.value.mode === "auto" ? Va(f, i.value) : i.value.mode;
731
- if (d.value = b, n("type-change", b), b === "email") {
732
- const N = ye(f);
733
- u.value = f, V.value = f, n("update:modelValue", f), n("validity-change", N);
756
+ const A = i.value.mode === "auto" ? Va(y, i.value) : i.value.mode;
757
+ if (w.value = A, n("type-change", A), A === "email") {
758
+ const k = Pe(y);
759
+ d.value = y, m.value = y, n("update:modelValue", y), n("validity-change", k);
734
760
  return;
735
761
  }
736
- if (b === "phone") {
737
- const N = ge(
738
- f,
762
+ if (A === "phone") {
763
+ const k = ye(
764
+ y,
739
765
  i.value.phone.autoPlus,
740
- o.locale
766
+ t.locale
741
767
  );
742
- if (ve(N).length > i.value.phone.maxDigits) {
743
- const F = Ia(f, i.value.phone.maxDigits);
744
- u.value = F, n("update:modelValue", F), C(F);
768
+ if (we(k).length > i.value.phone.maxDigits) {
769
+ const U = Ia(y, i.value.phone.maxDigits);
770
+ d.value = U, n("update:modelValue", U), q(U);
745
771
  return;
746
772
  }
747
- if (u.value = f, Da(f)) {
748
- m.value = ((I = o.errorMessages) == null ? void 0 : I.invalidPhoneChars) ?? "Допустимы только цифры и знак +", n("validity-change", !1);
773
+ if (d.value = y, Ee(y)) {
774
+ o.value = "Допустимы только цифры и знак + в начале", n("validity-change", !1);
749
775
  return;
750
776
  }
751
- u.value = N, n("update:modelValue", N), V.value = N;
752
- const M = he(
753
- N,
777
+ d.value = k, n("update:modelValue", k), m.value = k;
778
+ const M = be(
779
+ k,
754
780
  i.value.phone.minDigits,
755
781
  i.value.phone.maxDigits
756
782
  );
757
783
  n("validity-change", M);
758
784
  }
759
785
  }
760
- function p() {
761
- var t, v, f;
762
- if (console.debug("✅[event] onBlur is working"), !!d.value) {
763
- if (d.value === "phone") {
764
- const b = ge(
765
- u.value,
786
+ function L() {
787
+ if (console.debug("✅[event] onBlur is working"), !!w.value) {
788
+ if (w.value === "phone") {
789
+ const u = ye(
790
+ d.value,
766
791
  i.value.phone.autoPlus,
767
- o.locale
768
- );
769
- if (ve(b).length < Ta) {
770
- m.value = ((t = o.errorMessages) == null ? void 0 : t.invalidPhoneLength) ?? "Это не похоже на номер телефона", n("validity-change", !1);
792
+ t.locale
793
+ ), h = we(u);
794
+ if (Ee(d.value)) {
795
+ o.value = "Допустимы только цифры и знак + в начале", n("validity-change", !1);
796
+ return;
797
+ }
798
+ if (h.length < Ba) {
799
+ o.value = "Это не похоже на номер телефона", n("validity-change", !1);
771
800
  return;
772
801
  }
773
- const N = he(
774
- b,
802
+ const y = be(
803
+ u,
775
804
  i.value.phone.minDigits,
776
805
  i.value.phone.maxDigits
777
806
  );
778
- m.value = N ? "" : ((v = o.errorMessages) == null ? void 0 : v.invalidPhoneLength) ?? "Это не похоже на номер телефона", n("validity-change", N);
807
+ o.value = y ? null : "Это не похоже на номер телефона", n("validity-change", y);
779
808
  }
780
- if (d.value === "email") {
781
- const b = ye(u.value);
782
- m.value = b ? "" : ((f = o.errorMessages) == null ? void 0 : f.invalidEmail) ?? "Это не похоже на email", n("validity-change", b);
809
+ if (w.value === "email") {
810
+ const u = Pe(d.value);
811
+ o.value = u ? null : "Это не похоже на email", n("validity-change", u);
783
812
  }
784
813
  }
785
814
  }
786
- function h() {
787
- var v;
788
- const t = (v = g.value) == null ? void 0 : v.$el;
789
- return t ? t.querySelector("input") : null;
815
+ function _() {
816
+ var h;
817
+ const u = (h = P.value) == null ? void 0 : h.$el;
818
+ return u ? u.querySelector("input") : null;
790
819
  }
791
- function C(t) {
792
- const v = h();
793
- if (!v) return;
794
- const f = v.selectionStart ?? t.length;
795
- v.value = t, requestAnimationFrame(() => {
796
- v.setSelectionRange(f, f);
820
+ function q(u) {
821
+ const h = _();
822
+ if (!h) return;
823
+ const y = h.selectionStart ?? u.length;
824
+ h.value = u, requestAnimationFrame(() => {
825
+ h.setSelectionRange(y, y);
797
826
  });
798
827
  }
799
- return (t, v) => (P(), U("div", Aa, [
800
- w(c(R), {
828
+ return (u, h) => (N(), V("div", Aa, [
829
+ E(p(j), {
801
830
  ref_key: "inputRef",
802
- ref: g,
803
- "model-value": u.value,
804
- readonly: t.disabled,
805
- error: m.value,
806
- type: t.type ?? "text",
807
- size: t.size ?? "large",
808
- label: t.label ?? "Email или телефон",
809
- onInput: E,
810
- onBlur: p
831
+ ref: P,
832
+ "model-value": d.value,
833
+ readonly: u.disabled,
834
+ error: x.value,
835
+ type: u.type ?? "text",
836
+ size: u.size ?? "large",
837
+ label: S.value,
838
+ onInput: z,
839
+ onBlur: L
811
840
  }, null, 8, ["model-value", "readonly", "error", "type", "size", "label"]),
812
- d.value === "phone" ? (P(), S(c(ta), {
841
+ w.value === "phone" ? (N(), $(p(oa), {
813
842
  key: 0,
814
843
  class: "smart-input__icon"
815
- })) : D("", !0),
816
- d.value === "email" ? (P(), S(c(oa), {
844
+ })) : I("", !0),
845
+ w.value === "email" ? (N(), $(p(ra), {
817
846
  key: 1,
818
847
  class: "smart-input__icon"
819
- })) : D("", !0)
848
+ })) : I("", !0)
820
849
  ]));
821
850
  }
822
- }), Ra = /* @__PURE__ */ Ee(Fa, [["__scopeId", "data-v-a4c487e2"]]);
851
+ }), _a = /* @__PURE__ */ Te(Fa, [["__scopeId", "data-v-8928dcc3"]]);
823
852
  export {
824
853
  za as B,
825
854
  $a as C,
826
- Ee as _,
855
+ Te as _,
827
856
  La as a,
828
- ia as g,
829
- Ra as i,
830
- oe as p,
831
- ma as t
857
+ da as g,
858
+ _a as i,
859
+ se as p,
860
+ ie as t
832
861
  };