@ozdao/prometheus-framework 0.1.20 → 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/BackofficeGallery-7ae8fbba.mjs +307 -0
- package/dist/BackofficeGallery-fe39cff3.js +1 -0
- package/dist/Breadcrumbs.vue_vue_type_style_index_0_lang-8660f9cb.js +1 -0
- package/dist/Breadcrumbs.vue_vue_type_style_index_0_lang-bd3889ee.mjs +1945 -0
- package/dist/ButtonFollow-81508d85.mjs +132 -0
- package/dist/ButtonFollow-df6317f0.js +1 -0
- package/dist/CardOrganization-d8f209ee.js +1 -0
- package/dist/CardOrganization-de8ec36e.mjs +230 -0
- package/dist/Feed-a75d053e.js +1 -0
- package/dist/Feed-c4084664.mjs +368 -0
- package/dist/Feed-fea84ce7.mjs +439 -0
- package/dist/Feed-ff3b96b2.js +1 -0
- package/dist/Image-1281bc48.mjs +477 -0
- package/dist/Image-8e67dd2d.js +9 -0
- package/dist/Popup-b7609baa.js +1 -0
- package/dist/Popup-d5c4cb46.mjs +76 -0
- package/dist/Product-3c7b2921.mjs +841 -0
- package/dist/Product-6df77924.js +7 -0
- package/dist/ProductEdit-737e2a5a.mjs +302 -0
- package/dist/ProductEdit-c99ab559.js +1 -0
- package/dist/ProfileBlogposts-4293a1e3.js +1 -0
- package/dist/ProfileBlogposts-4c326fed.mjs +65 -0
- package/dist/ProfileComments-03f88b54.mjs +44 -0
- package/dist/ProfileComments-761ce00e.js +1 -0
- package/dist/ProfileEvents-0bdd36e4.mjs +57 -0
- package/dist/ProfileEvents-a9b96fec.js +1 -0
- package/dist/ProfileLikes-3edf6fb8.mjs +44 -0
- package/dist/ProfileLikes-51729962.js +1 -0
- package/dist/ProfileOrganizations-8961aaee.mjs +213 -0
- package/dist/ProfileOrganizations-f52e62e1.js +1 -0
- package/dist/Publics-70a0ca9c.mjs +45 -0
- package/dist/Publics-bbab7a79.js +1 -0
- package/dist/Select-90d4b7c8.mjs +81 -0
- package/dist/Select-b9299fb6.js +1 -0
- package/dist/Select.vue_vue_type_style_index_0_scoped_a78dbba1_lang-0ea8fbf8.js +1 -0
- package/dist/Select.vue_vue_type_style_index_0_scoped_a78dbba1_lang-4ed993c7.mjs +1 -0
- package/dist/UploadImage-c9711af2.js +1 -0
- package/dist/UploadImage-ec3714e8.mjs +83 -0
- package/dist/UploadImageMultiple-b4c8d627.js +1 -0
- package/dist/UploadImageMultiple-ebcc51e6.mjs +58 -0
- package/dist/auth-78d9392a.mjs +612 -0
- package/dist/auth-96449d96.js +7 -0
- package/dist/auth.client.cjs +8 -8
- package/dist/auth.client.js +8 -8
- package/dist/auth.validation-9e493d2f.mjs +20 -0
- package/dist/auth.validation-d4795c25.js +1 -0
- package/dist/backoffice.client.cjs +1 -1
- package/dist/backoffice.client.js +43 -48
- package/dist/community.client.cjs +1 -1
- package/dist/community.client.js +44 -42
- package/dist/events.client.cjs +2 -2
- package/dist/events.client.js +25 -24
- package/dist/index-2a0269fc.js +2 -0
- package/dist/index-9128ade5.mjs +1228 -0
- package/dist/landing.client.cjs +1 -1
- package/dist/organizations-0fb56927.mjs +122 -0
- package/dist/organizations-195ec134.js +1 -0
- package/dist/organizations.client-b39db194.js +3 -0
- package/dist/organizations.client-df5e8a6f.mjs +3020 -0
- package/dist/organizations.client.cjs +1 -1
- package/dist/organizations.client.js +46 -44
- package/dist/style.css +1 -1
- package/dist/users.client.cjs +1 -1
- package/dist/users.client.js +23 -23
- package/package.json +1 -1
- package/src/modules/backoffice/components/layouts/Backoffice.vue +0 -11
- package/src/modules/gallery/components/sections/BackofficeGallery.vue +3 -1
@@ -0,0 +1,612 @@
|
|
1
|
+
import { g as le, a as z } from "./index-9128ade5.mjs";
|
2
|
+
import { reactive as N, watch as Z } from "vue";
|
3
|
+
import { s as x } from "./globals-96ba60e4.mjs";
|
4
|
+
var Q = { exports: {} };
|
5
|
+
/*!
|
6
|
+
* JavaScript Cookie v2.2.1
|
7
|
+
* https://github.com/js-cookie/js-cookie
|
8
|
+
*
|
9
|
+
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
10
|
+
* Released under the MIT license
|
11
|
+
*/
|
12
|
+
(function(r, e) {
|
13
|
+
(function(t) {
|
14
|
+
var o;
|
15
|
+
if (r.exports = t(), o = !0, !o) {
|
16
|
+
var n = window.Cookies, s = window.Cookies = t();
|
17
|
+
s.noConflict = function() {
|
18
|
+
return window.Cookies = n, s;
|
19
|
+
};
|
20
|
+
}
|
21
|
+
})(function() {
|
22
|
+
function t() {
|
23
|
+
for (var s = 0, i = {}; s < arguments.length; s++) {
|
24
|
+
var a = arguments[s];
|
25
|
+
for (var d in a)
|
26
|
+
i[d] = a[d];
|
27
|
+
}
|
28
|
+
return i;
|
29
|
+
}
|
30
|
+
function o(s) {
|
31
|
+
return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
|
32
|
+
}
|
33
|
+
function n(s) {
|
34
|
+
function i() {
|
35
|
+
}
|
36
|
+
function a(c, p, l) {
|
37
|
+
if (!(typeof document > "u")) {
|
38
|
+
l = t({
|
39
|
+
path: "/"
|
40
|
+
}, i.defaults, l), typeof l.expires == "number" && (l.expires = new Date(/* @__PURE__ */ new Date() * 1 + l.expires * 864e5)), l.expires = l.expires ? l.expires.toUTCString() : "";
|
41
|
+
try {
|
42
|
+
var b = JSON.stringify(p);
|
43
|
+
/^[\{\[]/.test(b) && (p = b);
|
44
|
+
} catch {
|
45
|
+
}
|
46
|
+
p = s.write ? s.write(p, c) : encodeURIComponent(String(p)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent), c = encodeURIComponent(String(c)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[\(\)]/g, escape);
|
47
|
+
var y = "";
|
48
|
+
for (var C in l)
|
49
|
+
l[C] && (y += "; " + C, l[C] !== !0 && (y += "=" + l[C].split(";")[0]));
|
50
|
+
return document.cookie = c + "=" + p + y;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
function d(c, p) {
|
54
|
+
if (!(typeof document > "u")) {
|
55
|
+
for (var l = {}, b = document.cookie ? document.cookie.split("; ") : [], y = 0; y < b.length; y++) {
|
56
|
+
var C = b[y].split("="), h = C.slice(1).join("=");
|
57
|
+
!p && h.charAt(0) === '"' && (h = h.slice(1, -1));
|
58
|
+
try {
|
59
|
+
var U = o(C[0]);
|
60
|
+
if (h = (s.read || s)(h, U) || o(h), p)
|
61
|
+
try {
|
62
|
+
h = JSON.parse(h);
|
63
|
+
} catch {
|
64
|
+
}
|
65
|
+
if (l[U] = h, c === U)
|
66
|
+
break;
|
67
|
+
} catch {
|
68
|
+
}
|
69
|
+
}
|
70
|
+
return c ? l[c] : l;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
return i.set = a, i.get = function(c) {
|
74
|
+
return d(
|
75
|
+
c,
|
76
|
+
!1
|
77
|
+
/* read as raw */
|
78
|
+
);
|
79
|
+
}, i.getJSON = function(c) {
|
80
|
+
return d(
|
81
|
+
c,
|
82
|
+
!0
|
83
|
+
/* read as json */
|
84
|
+
);
|
85
|
+
}, i.remove = function(c, p) {
|
86
|
+
a(c, "", t(p, {
|
87
|
+
expires: -1
|
88
|
+
}));
|
89
|
+
}, i.defaults = {}, i.withConverter = n, i;
|
90
|
+
}
|
91
|
+
return n(function() {
|
92
|
+
});
|
93
|
+
});
|
94
|
+
})(Q);
|
95
|
+
var de = Q.exports;
|
96
|
+
const D = /* @__PURE__ */ le(de);
|
97
|
+
/*! Capacitor: https://capacitorjs.com/ - MIT License */
|
98
|
+
const ue = (r) => {
|
99
|
+
const e = /* @__PURE__ */ new Map();
|
100
|
+
e.set("web", { name: "web" });
|
101
|
+
const t = r.CapacitorPlatforms || {
|
102
|
+
currentPlatform: { name: "web" },
|
103
|
+
platforms: e
|
104
|
+
}, o = (s, i) => {
|
105
|
+
t.platforms.set(s, i);
|
106
|
+
}, n = (s) => {
|
107
|
+
t.platforms.has(s) && (t.currentPlatform = t.platforms.get(s));
|
108
|
+
};
|
109
|
+
return t.addPlatform = o, t.setPlatform = n, t;
|
110
|
+
}, fe = (r) => r.CapacitorPlatforms = ue(r), X = /* @__PURE__ */ fe(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
|
111
|
+
X.addPlatform;
|
112
|
+
X.setPlatform;
|
113
|
+
var _;
|
114
|
+
(function(r) {
|
115
|
+
r.Unimplemented = "UNIMPLEMENTED", r.Unavailable = "UNAVAILABLE";
|
116
|
+
})(_ || (_ = {}));
|
117
|
+
class q extends Error {
|
118
|
+
constructor(e, t, o) {
|
119
|
+
super(e), this.message = e, this.code = t, this.data = o;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
const pe = (r) => {
|
123
|
+
var e, t;
|
124
|
+
return r != null && r.androidBridge ? "android" : !((t = (e = r == null ? void 0 : r.webkit) === null || e === void 0 ? void 0 : e.messageHandlers) === null || t === void 0) && t.bridge ? "ios" : "web";
|
125
|
+
}, me = (r) => {
|
126
|
+
var e, t, o, n, s;
|
127
|
+
const i = r.CapacitorCustomPlatform || null, a = r.Capacitor || {}, d = a.Plugins = a.Plugins || {}, c = r.CapacitorPlatforms, p = () => i !== null ? i.name : pe(r), l = ((e = c == null ? void 0 : c.currentPlatform) === null || e === void 0 ? void 0 : e.getPlatform) || p, b = () => l() !== "web", y = ((t = c == null ? void 0 : c.currentPlatform) === null || t === void 0 ? void 0 : t.isNativePlatform) || b, C = (u) => {
|
128
|
+
const f = H.get(u);
|
129
|
+
return !!(f != null && f.platforms.has(l()) || R(u));
|
130
|
+
}, h = ((o = c == null ? void 0 : c.currentPlatform) === null || o === void 0 ? void 0 : o.isPluginAvailable) || C, U = (u) => {
|
131
|
+
var f;
|
132
|
+
return (f = a.PluginHeaders) === null || f === void 0 ? void 0 : f.find((E) => E.name === u);
|
133
|
+
}, R = ((n = c == null ? void 0 : c.currentPlatform) === null || n === void 0 ? void 0 : n.getPluginHeader) || U, re = (u) => r.console.error(u), se = (u, f, E) => Promise.reject(`${E} does not have an implementation of "${f}".`), H = /* @__PURE__ */ new Map(), ne = (u, f = {}) => {
|
134
|
+
const E = H.get(u);
|
135
|
+
if (E)
|
136
|
+
return console.warn(`Capacitor plugin "${u}" already registered. Cannot register plugins twice.`), E.proxy;
|
137
|
+
const k = l(), S = R(u);
|
138
|
+
let O;
|
139
|
+
const ae = async () => (!O && k in f ? O = typeof f[k] == "function" ? O = await f[k]() : O = f[k] : i !== null && !O && "web" in f && (O = typeof f.web == "function" ? O = await f.web() : O = f.web), O), ie = (m, w) => {
|
140
|
+
var P, L;
|
141
|
+
if (S) {
|
142
|
+
const j = S == null ? void 0 : S.methods.find((v) => w === v.name);
|
143
|
+
if (j)
|
144
|
+
return j.rtype === "promise" ? (v) => a.nativePromise(u, w.toString(), v) : (v, T) => a.nativeCallback(u, w.toString(), v, T);
|
145
|
+
if (m)
|
146
|
+
return (P = m[w]) === null || P === void 0 ? void 0 : P.bind(m);
|
147
|
+
} else {
|
148
|
+
if (m)
|
149
|
+
return (L = m[w]) === null || L === void 0 ? void 0 : L.bind(m);
|
150
|
+
throw new q(`"${u}" plugin is not implemented on ${k}`, _.Unimplemented);
|
151
|
+
}
|
152
|
+
}, B = (m) => {
|
153
|
+
let w;
|
154
|
+
const P = (...L) => {
|
155
|
+
const j = ae().then((v) => {
|
156
|
+
const T = ie(v, m);
|
157
|
+
if (T) {
|
158
|
+
const I = T(...L);
|
159
|
+
return w = I == null ? void 0 : I.remove, I;
|
160
|
+
} else
|
161
|
+
throw new q(`"${u}.${m}()" is not implemented on ${k}`, _.Unimplemented);
|
162
|
+
});
|
163
|
+
return m === "addListener" && (j.remove = async () => w()), j;
|
164
|
+
};
|
165
|
+
return P.toString = () => `${m.toString()}() { [capacitor code] }`, Object.defineProperty(P, "name", {
|
166
|
+
value: m,
|
167
|
+
writable: !1,
|
168
|
+
configurable: !1
|
169
|
+
}), P;
|
170
|
+
}, J = B("addListener"), G = B("removeListener"), ce = (m, w) => {
|
171
|
+
const P = J({ eventName: m }, w), L = async () => {
|
172
|
+
const v = await P;
|
173
|
+
G({
|
174
|
+
eventName: m,
|
175
|
+
callbackId: v
|
176
|
+
}, w);
|
177
|
+
}, j = new Promise((v) => P.then(() => v({ remove: L })));
|
178
|
+
return j.remove = async () => {
|
179
|
+
console.warn("Using addListener() without 'await' is deprecated."), await L();
|
180
|
+
}, j;
|
181
|
+
}, W = new Proxy({}, {
|
182
|
+
get(m, w) {
|
183
|
+
switch (w) {
|
184
|
+
case "$$typeof":
|
185
|
+
return;
|
186
|
+
case "toJSON":
|
187
|
+
return () => ({});
|
188
|
+
case "addListener":
|
189
|
+
return S ? ce : J;
|
190
|
+
case "removeListener":
|
191
|
+
return G;
|
192
|
+
default:
|
193
|
+
return B(w);
|
194
|
+
}
|
195
|
+
}
|
196
|
+
});
|
197
|
+
return d[u] = W, H.set(u, {
|
198
|
+
name: u,
|
199
|
+
proxy: W,
|
200
|
+
platforms: /* @__PURE__ */ new Set([
|
201
|
+
...Object.keys(f),
|
202
|
+
...S ? [k] : []
|
203
|
+
])
|
204
|
+
}), W;
|
205
|
+
}, oe = ((s = c == null ? void 0 : c.currentPlatform) === null || s === void 0 ? void 0 : s.registerPlugin) || ne;
|
206
|
+
return a.convertFileSrc || (a.convertFileSrc = (u) => u), a.getPlatform = l, a.handleError = re, a.isNativePlatform = y, a.isPluginAvailable = h, a.pluginMethodNoop = se, a.registerPlugin = oe, a.Exception = q, a.DEBUG = !!a.DEBUG, a.isLoggingEnabled = !!a.isLoggingEnabled, a.platform = a.getPlatform(), a.isNative = a.isNativePlatform(), a;
|
207
|
+
}, ge = (r) => r.Capacitor = me(r), M = /* @__PURE__ */ ge(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {}), Y = M.registerPlugin;
|
208
|
+
M.Plugins;
|
209
|
+
class ee {
|
210
|
+
constructor(e) {
|
211
|
+
this.listeners = {}, this.windowListeners = {}, e && (console.warn(`Capacitor WebPlugin "${e.name}" config object was deprecated in v3 and will be removed in v4.`), this.config = e);
|
212
|
+
}
|
213
|
+
addListener(e, t) {
|
214
|
+
this.listeners[e] || (this.listeners[e] = []), this.listeners[e].push(t);
|
215
|
+
const n = this.windowListeners[e];
|
216
|
+
n && !n.registered && this.addWindowListener(n);
|
217
|
+
const s = async () => this.removeListener(e, t), i = Promise.resolve({ remove: s });
|
218
|
+
return Object.defineProperty(i, "remove", {
|
219
|
+
value: async () => {
|
220
|
+
console.warn("Using addListener() without 'await' is deprecated."), await s();
|
221
|
+
}
|
222
|
+
}), i;
|
223
|
+
}
|
224
|
+
async removeAllListeners() {
|
225
|
+
this.listeners = {};
|
226
|
+
for (const e in this.windowListeners)
|
227
|
+
this.removeWindowListener(this.windowListeners[e]);
|
228
|
+
this.windowListeners = {};
|
229
|
+
}
|
230
|
+
notifyListeners(e, t) {
|
231
|
+
const o = this.listeners[e];
|
232
|
+
o && o.forEach((n) => n(t));
|
233
|
+
}
|
234
|
+
hasListeners(e) {
|
235
|
+
return !!this.listeners[e].length;
|
236
|
+
}
|
237
|
+
registerWindowListener(e, t) {
|
238
|
+
this.windowListeners[t] = {
|
239
|
+
registered: !1,
|
240
|
+
windowEventName: e,
|
241
|
+
pluginEventName: t,
|
242
|
+
handler: (o) => {
|
243
|
+
this.notifyListeners(t, o);
|
244
|
+
}
|
245
|
+
};
|
246
|
+
}
|
247
|
+
unimplemented(e = "not implemented") {
|
248
|
+
return new M.Exception(e, _.Unimplemented);
|
249
|
+
}
|
250
|
+
unavailable(e = "not available") {
|
251
|
+
return new M.Exception(e, _.Unavailable);
|
252
|
+
}
|
253
|
+
async removeListener(e, t) {
|
254
|
+
const o = this.listeners[e];
|
255
|
+
if (!o)
|
256
|
+
return;
|
257
|
+
const n = o.indexOf(t);
|
258
|
+
this.listeners[e].splice(n, 1), this.listeners[e].length || this.removeWindowListener(this.windowListeners[e]);
|
259
|
+
}
|
260
|
+
addWindowListener(e) {
|
261
|
+
window.addEventListener(e.windowEventName, e.handler), e.registered = !0;
|
262
|
+
}
|
263
|
+
removeWindowListener(e) {
|
264
|
+
e && (window.removeEventListener(e.windowEventName, e.handler), e.registered = !1);
|
265
|
+
}
|
266
|
+
}
|
267
|
+
const K = (r) => encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape), V = (r) => r.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
268
|
+
class we extends ee {
|
269
|
+
async getCookies() {
|
270
|
+
const e = document.cookie, t = {};
|
271
|
+
return e.split(";").forEach((o) => {
|
272
|
+
if (o.length <= 0)
|
273
|
+
return;
|
274
|
+
let [n, s] = o.replace(/=/, "CAP_COOKIE").split("CAP_COOKIE");
|
275
|
+
n = V(n).trim(), s = V(s).trim(), t[n] = s;
|
276
|
+
}), t;
|
277
|
+
}
|
278
|
+
async setCookie(e) {
|
279
|
+
try {
|
280
|
+
const t = K(e.key), o = K(e.value), n = `; expires=${(e.expires || "").replace("expires=", "")}`, s = (e.path || "/").replace("path=", ""), i = e.url != null && e.url.length > 0 ? `domain=${e.url}` : "";
|
281
|
+
document.cookie = `${t}=${o || ""}${n}; path=${s}; ${i};`;
|
282
|
+
} catch (t) {
|
283
|
+
return Promise.reject(t);
|
284
|
+
}
|
285
|
+
}
|
286
|
+
async deleteCookie(e) {
|
287
|
+
try {
|
288
|
+
document.cookie = `${e.key}=; Max-Age=0`;
|
289
|
+
} catch (t) {
|
290
|
+
return Promise.reject(t);
|
291
|
+
}
|
292
|
+
}
|
293
|
+
async clearCookies() {
|
294
|
+
try {
|
295
|
+
const e = document.cookie.split(";") || [];
|
296
|
+
for (const t of e)
|
297
|
+
document.cookie = t.replace(/^ +/, "").replace(/=.*/, `=;expires=${(/* @__PURE__ */ new Date()).toUTCString()};path=/`);
|
298
|
+
} catch (e) {
|
299
|
+
return Promise.reject(e);
|
300
|
+
}
|
301
|
+
}
|
302
|
+
async clearAllCookies() {
|
303
|
+
try {
|
304
|
+
await this.clearCookies();
|
305
|
+
} catch (e) {
|
306
|
+
return Promise.reject(e);
|
307
|
+
}
|
308
|
+
}
|
309
|
+
}
|
310
|
+
const te = Y("CapacitorCookies", {
|
311
|
+
web: () => new we()
|
312
|
+
}), he = async (r) => new Promise((e, t) => {
|
313
|
+
const o = new FileReader();
|
314
|
+
o.onload = () => {
|
315
|
+
const n = o.result;
|
316
|
+
e(n.indexOf(",") >= 0 ? n.split(",")[1] : n);
|
317
|
+
}, o.onerror = (n) => t(n), o.readAsDataURL(r);
|
318
|
+
}), ve = (r = {}) => {
|
319
|
+
const e = Object.keys(r);
|
320
|
+
return Object.keys(r).map((n) => n.toLocaleLowerCase()).reduce((n, s, i) => (n[s] = r[e[i]], n), {});
|
321
|
+
}, Pe = (r, e = !0) => r ? Object.entries(r).reduce((o, n) => {
|
322
|
+
const [s, i] = n;
|
323
|
+
let a, d;
|
324
|
+
return Array.isArray(i) ? (d = "", i.forEach((c) => {
|
325
|
+
a = e ? encodeURIComponent(c) : c, d += `${s}=${a}&`;
|
326
|
+
}), d.slice(0, -1)) : (a = e ? encodeURIComponent(i) : i, d = `${s}=${a}`), `${o}&${d}`;
|
327
|
+
}, "").substr(1) : null, be = (r, e = {}) => {
|
328
|
+
const t = Object.assign({ method: r.method || "GET", headers: r.headers }, e), n = ve(r.headers)["content-type"] || "";
|
329
|
+
if (typeof r.data == "string")
|
330
|
+
t.body = r.data;
|
331
|
+
else if (n.includes("application/x-www-form-urlencoded")) {
|
332
|
+
const s = new URLSearchParams();
|
333
|
+
for (const [i, a] of Object.entries(r.data || {}))
|
334
|
+
s.set(i, a);
|
335
|
+
t.body = s.toString();
|
336
|
+
} else if (n.includes("multipart/form-data")) {
|
337
|
+
const s = new FormData();
|
338
|
+
if (r.data instanceof FormData)
|
339
|
+
r.data.forEach((a, d) => {
|
340
|
+
s.append(d, a);
|
341
|
+
});
|
342
|
+
else
|
343
|
+
for (const a of Object.keys(r.data))
|
344
|
+
s.append(a, r.data[a]);
|
345
|
+
t.body = s;
|
346
|
+
const i = new Headers(t.headers);
|
347
|
+
i.delete("content-type"), t.headers = i;
|
348
|
+
} else
|
349
|
+
(n.includes("application/json") || typeof r.data == "object") && (t.body = JSON.stringify(r.data));
|
350
|
+
return t;
|
351
|
+
};
|
352
|
+
class ye extends ee {
|
353
|
+
/**
|
354
|
+
* Perform an Http request given a set of options
|
355
|
+
* @param options Options to build the HTTP request
|
356
|
+
*/
|
357
|
+
async request(e) {
|
358
|
+
const t = be(e, e.webFetchExtra), o = Pe(e.params, e.shouldEncodeUrlParams), n = o ? `${e.url}?${o}` : e.url, s = await fetch(n, t), i = s.headers.get("content-type") || "";
|
359
|
+
let { responseType: a = "text" } = s.ok ? e : {};
|
360
|
+
i.includes("application/json") && (a = "json");
|
361
|
+
let d, c;
|
362
|
+
switch (a) {
|
363
|
+
case "arraybuffer":
|
364
|
+
case "blob":
|
365
|
+
c = await s.blob(), d = await he(c);
|
366
|
+
break;
|
367
|
+
case "json":
|
368
|
+
d = await s.json();
|
369
|
+
break;
|
370
|
+
case "document":
|
371
|
+
case "text":
|
372
|
+
default:
|
373
|
+
d = await s.text();
|
374
|
+
}
|
375
|
+
const p = {};
|
376
|
+
return s.headers.forEach((l, b) => {
|
377
|
+
p[b] = l;
|
378
|
+
}), {
|
379
|
+
data: d,
|
380
|
+
headers: p,
|
381
|
+
status: s.status,
|
382
|
+
url: s.url
|
383
|
+
};
|
384
|
+
}
|
385
|
+
/**
|
386
|
+
* Perform an Http GET request given a set of options
|
387
|
+
* @param options Options to build the HTTP request
|
388
|
+
*/
|
389
|
+
async get(e) {
|
390
|
+
return this.request(Object.assign(Object.assign({}, e), { method: "GET" }));
|
391
|
+
}
|
392
|
+
/**
|
393
|
+
* Perform an Http POST request given a set of options
|
394
|
+
* @param options Options to build the HTTP request
|
395
|
+
*/
|
396
|
+
async post(e) {
|
397
|
+
return this.request(Object.assign(Object.assign({}, e), { method: "POST" }));
|
398
|
+
}
|
399
|
+
/**
|
400
|
+
* Perform an Http PUT request given a set of options
|
401
|
+
* @param options Options to build the HTTP request
|
402
|
+
*/
|
403
|
+
async put(e) {
|
404
|
+
return this.request(Object.assign(Object.assign({}, e), { method: "PUT" }));
|
405
|
+
}
|
406
|
+
/**
|
407
|
+
* Perform an Http PATCH request given a set of options
|
408
|
+
* @param options Options to build the HTTP request
|
409
|
+
*/
|
410
|
+
async patch(e) {
|
411
|
+
return this.request(Object.assign(Object.assign({}, e), { method: "PATCH" }));
|
412
|
+
}
|
413
|
+
/**
|
414
|
+
* Perform an Http DELETE request given a set of options
|
415
|
+
* @param options Options to build the HTTP request
|
416
|
+
*/
|
417
|
+
async delete(e) {
|
418
|
+
return this.request(Object.assign(Object.assign({}, e), { method: "DELETE" }));
|
419
|
+
}
|
420
|
+
}
|
421
|
+
Y("CapacitorHttp", {
|
422
|
+
web: () => new ye()
|
423
|
+
});
|
424
|
+
const Ce = z.create({ baseURL: process.env.API_URL, withCredentials: !0 }), $ = N({
|
425
|
+
code: {
|
426
|
+
value: "",
|
427
|
+
type: "",
|
428
|
+
method: "",
|
429
|
+
isSended: !1,
|
430
|
+
isValid: !1
|
431
|
+
}
|
432
|
+
});
|
433
|
+
async function Oe(r, e, t) {
|
434
|
+
return await Ce.post("/api/twofa/sendcode", {
|
435
|
+
phone: r.phone.number,
|
436
|
+
email: r.email,
|
437
|
+
method: e,
|
438
|
+
type: t
|
439
|
+
}).then(
|
440
|
+
(o) => ($.code = o.data, $.code.isSended = !0, Promise.resolve(o.data)),
|
441
|
+
(o) => (console.log(o), x(o), Promise.reject(o))
|
442
|
+
);
|
443
|
+
}
|
444
|
+
Z($, (r, e) => {
|
445
|
+
});
|
446
|
+
const _e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
447
|
+
__proto__: null,
|
448
|
+
sendCode: Oe,
|
449
|
+
state: $
|
450
|
+
}, Symbol.toStringTag, { value: "Module" })), A = z.create({ baseURL: process.env.API_URL, withCredentials: !0 }), g = N({
|
451
|
+
user: {
|
452
|
+
_id: "",
|
453
|
+
username: "",
|
454
|
+
email: "",
|
455
|
+
phone: "",
|
456
|
+
password: "",
|
457
|
+
passwordRepeat: ""
|
458
|
+
},
|
459
|
+
access: {
|
460
|
+
roles: null,
|
461
|
+
token: null,
|
462
|
+
status: !1
|
463
|
+
}
|
464
|
+
});
|
465
|
+
if (D.get("user")) {
|
466
|
+
const { _id: r, email: e, phone: t, roles: o, accessToken: n } = JSON.parse(D.get("user"));
|
467
|
+
Object.assign(g.user, { _id: r, email: e, phone: t }), Object.assign(g.access, { token: n, roles: o, status: !!n }), A.interceptors.request.use((s) => (n && (s.headers["x-access-token"] = n), s), (s) => Promise.reject(s));
|
468
|
+
}
|
469
|
+
const Le = {
|
470
|
+
async login(r, e) {
|
471
|
+
try {
|
472
|
+
const t = await A.post("/api/auth/signin", {
|
473
|
+
...r,
|
474
|
+
type: e
|
475
|
+
});
|
476
|
+
return F("user", t.data), Object.assign(g.user, {
|
477
|
+
...t.data
|
478
|
+
}), Object.assign(g.access, {
|
479
|
+
token: t.data.accessToken,
|
480
|
+
status: !0,
|
481
|
+
roles: t.data.roles
|
482
|
+
}), t.data;
|
483
|
+
} catch (t) {
|
484
|
+
return Object.assign(g.access, {
|
485
|
+
token: null,
|
486
|
+
status: !1,
|
487
|
+
roles: null
|
488
|
+
}), x(t), Promise.reject(t);
|
489
|
+
}
|
490
|
+
},
|
491
|
+
async signup(r, e, t) {
|
492
|
+
const { password: o, passwordRepeat: n } = g.user;
|
493
|
+
if (o !== n) {
|
494
|
+
const s = {
|
495
|
+
response: {
|
496
|
+
data: { errorCode: "PASSWORDS_DO_NOT_MATCH" }
|
497
|
+
}
|
498
|
+
};
|
499
|
+
throw x(s), new Error(s.response.status);
|
500
|
+
}
|
501
|
+
try {
|
502
|
+
r.phone = r.phone.number;
|
503
|
+
const s = await A.post("/api/auth/signup", {
|
504
|
+
...r,
|
505
|
+
type: e,
|
506
|
+
inviteCode: t
|
507
|
+
});
|
508
|
+
return s.data.accessToken && F("user", s.data), Object.assign(g.user, {
|
509
|
+
...s.data
|
510
|
+
}), Object.assign(g.access, {
|
511
|
+
token: s.data.accessToken,
|
512
|
+
status: !0,
|
513
|
+
roles: s.data.roles
|
514
|
+
}), s.data;
|
515
|
+
} catch (s) {
|
516
|
+
throw x(s), console.log("Sign up falied"), s;
|
517
|
+
}
|
518
|
+
},
|
519
|
+
logout() {
|
520
|
+
ke("user"), Object.assign(g.user, {
|
521
|
+
email: "",
|
522
|
+
phone: "",
|
523
|
+
password: "",
|
524
|
+
passwordRepeat: ""
|
525
|
+
}), Object.assign(g.access, {
|
526
|
+
token: null,
|
527
|
+
status: !1
|
528
|
+
});
|
529
|
+
},
|
530
|
+
async resetPassword(r, e) {
|
531
|
+
try {
|
532
|
+
const t = await A.post("/api/auth/reset-password", {
|
533
|
+
email: r.email,
|
534
|
+
phone: r.phone.number,
|
535
|
+
type: e
|
536
|
+
});
|
537
|
+
return Object.assign($.code, {
|
538
|
+
...t.data,
|
539
|
+
isSended: !0
|
540
|
+
}), t.data;
|
541
|
+
} catch (t) {
|
542
|
+
return x(t), Promise.reject(t);
|
543
|
+
}
|
544
|
+
},
|
545
|
+
async updatePassword(r, e) {
|
546
|
+
const { password: t, passwordRepeat: o } = g.user;
|
547
|
+
if (t !== o) {
|
548
|
+
const n = {
|
549
|
+
response: {
|
550
|
+
data: { errorCode: "PASSWORDS_DO_NOT_MATCH" }
|
551
|
+
}
|
552
|
+
};
|
553
|
+
throw x(n), new Error(n.response.status);
|
554
|
+
}
|
555
|
+
try {
|
556
|
+
const n = await A.post("/api/auth/update-password", {
|
557
|
+
email: r.email,
|
558
|
+
phone: r.phone.number,
|
559
|
+
password: r.password,
|
560
|
+
passwordRepeat: r.passwordRepeat,
|
561
|
+
type: e
|
562
|
+
});
|
563
|
+
return n.data.accessToken && F("user", n.data), Object.assign(g.user, {
|
564
|
+
...n.data
|
565
|
+
}), Object.assign(g.access, {
|
566
|
+
token: n.data.accessToken,
|
567
|
+
status: !0
|
568
|
+
}), n.data;
|
569
|
+
} catch (n) {
|
570
|
+
return x(n), Promise.reject(n);
|
571
|
+
}
|
572
|
+
}
|
573
|
+
}, je = {
|
574
|
+
development: { secure: !1, expires: 1 },
|
575
|
+
production: { expires: 1, domain: process.env.API_URL, sameSite: "none", secure: !0 }
|
576
|
+
};
|
577
|
+
function F(r, e, t = process.env.NODE_ENV) {
|
578
|
+
process.env.MOBILE_APP ? te.setCookie({
|
579
|
+
url: process.env.API_URL,
|
580
|
+
// используйте ваш API_URL
|
581
|
+
key: r,
|
582
|
+
value: JSON.stringify(e)
|
583
|
+
}) : D.set(r, JSON.stringify(e), je[t]);
|
584
|
+
}
|
585
|
+
function ke(r, e = process.env.NODE_ENV) {
|
586
|
+
if (process.env.MOBILE_APP)
|
587
|
+
te.deleteCookie({
|
588
|
+
url: process.env.API_URL,
|
589
|
+
// используйте ваш API_URL
|
590
|
+
key: r
|
591
|
+
});
|
592
|
+
else {
|
593
|
+
const t = e === "production" ? { domain: process.env.API_URL } : {};
|
594
|
+
D.remove(r, t);
|
595
|
+
}
|
596
|
+
}
|
597
|
+
Z(g, (r, e) => {
|
598
|
+
});
|
599
|
+
const Ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
600
|
+
__proto__: null,
|
601
|
+
actions: Le,
|
602
|
+
state: g
|
603
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
604
|
+
export {
|
605
|
+
D as C,
|
606
|
+
Le as a,
|
607
|
+
$ as b,
|
608
|
+
Oe as c,
|
609
|
+
Ue as d,
|
610
|
+
g as s,
|
611
|
+
_e as t
|
612
|
+
};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
"use strict";const G=require("./index-2a0269fc.js"),H=require("vue"),j=require("./globals-928eb13c.js");var Z={exports:{}};/*!
|
2
|
+
* JavaScript Cookie v2.2.1
|
3
|
+
* https://github.com/js-cookie/js-cookie
|
4
|
+
*
|
5
|
+
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
6
|
+
* Released under the MIT license
|
7
|
+
*/(function(r,e){(function(t){var o;if(r.exports=t(),o=!0,!o){var n=window.Cookies,s=window.Cookies=t();s.noConflict=function(){return window.Cookies=n,s}}})(function(){function t(){for(var s=0,i={};s<arguments.length;s++){var a=arguments[s];for(var d in a)i[d]=a[d]}return i}function o(s){return s.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}function n(s){function i(){}function a(c,p,l){if(!(typeof document>"u")){l=t({path:"/"},i.defaults,l),typeof l.expires=="number"&&(l.expires=new Date(new Date*1+l.expires*864e5)),l.expires=l.expires?l.expires.toUTCString():"";try{var b=JSON.stringify(p);/^[\{\[]/.test(b)&&(p=b)}catch{}p=s.write?s.write(p,c):encodeURIComponent(String(p)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),c=encodeURIComponent(String(c)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var y="";for(var C in l)l[C]&&(y+="; "+C,l[C]!==!0&&(y+="="+l[C].split(";")[0]));return document.cookie=c+"="+p+y}}function d(c,p){if(!(typeof document>"u")){for(var l={},b=document.cookie?document.cookie.split("; "):[],y=0;y<b.length;y++){var C=b[y].split("="),h=C.slice(1).join("=");!p&&h.charAt(0)==='"'&&(h=h.slice(1,-1));try{var A=o(C[0]);if(h=(s.read||s)(h,A)||o(h),p)try{h=JSON.parse(h)}catch{}if(l[A]=h,c===A)break}catch{}}return c?l[c]:l}}return i.set=a,i.get=function(c){return d(c,!1)},i.getJSON=function(c){return d(c,!0)},i.remove=function(c,p){a(c,"",t(p,{expires:-1}))},i.defaults={},i.withConverter=n,i}return n(function(){})})})(Z);var de=Z.exports;const R=G.getDefaultExportFromCjs(de);/*! Capacitor: https://capacitorjs.com/ - MIT License */const ue=r=>{const e=new Map;e.set("web",{name:"web"});const t=r.CapacitorPlatforms||{currentPlatform:{name:"web"},platforms:e},o=(s,i)=>{t.platforms.set(s,i)},n=s=>{t.platforms.has(s)&&(t.currentPlatform=t.platforms.get(s))};return t.addPlatform=o,t.setPlatform=n,t},fe=r=>r.CapacitorPlatforms=ue(r),Q=fe(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});Q.addPlatform;Q.setPlatform;var _;(function(r){r.Unimplemented="UNIMPLEMENTED",r.Unavailable="UNAVAILABLE"})(_||(_={}));class F extends Error{constructor(e,t,o){super(e),this.message=e,this.code=t,this.data=o}}const pe=r=>{var e,t;return r!=null&&r.androidBridge?"android":!((t=(e=r==null?void 0:r.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||t===void 0)&&t.bridge?"ios":"web"},ge=r=>{var e,t,o,n,s;const i=r.CapacitorCustomPlatform||null,a=r.Capacitor||{},d=a.Plugins=a.Plugins||{},c=r.CapacitorPlatforms,p=()=>i!==null?i.name:pe(r),l=((e=c==null?void 0:c.currentPlatform)===null||e===void 0?void 0:e.getPlatform)||p,b=()=>l()!=="web",y=((t=c==null?void 0:c.currentPlatform)===null||t===void 0?void 0:t.isNativePlatform)||b,C=u=>{const f=B.get(u);return!!(f!=null&&f.platforms.has(l())||T(u))},h=((o=c==null?void 0:c.currentPlatform)===null||o===void 0?void 0:o.isPluginAvailable)||C,A=u=>{var f;return(f=a.PluginHeaders)===null||f===void 0?void 0:f.find(x=>x.name===u)},T=((n=c==null?void 0:c.currentPlatform)===null||n===void 0?void 0:n.getPluginHeader)||A,se=u=>r.console.error(u),ne=(u,f,x)=>Promise.reject(`${x} does not have an implementation of "${f}".`),B=new Map,oe=(u,f={})=>{const x=B.get(u);if(x)return console.warn(`Capacitor plugin "${u}" already registered. Cannot register plugins twice.`),x.proxy;const k=l(),S=T(u);let O;const ie=async()=>(!O&&k in f?O=typeof f[k]=="function"?O=await f[k]():O=f[k]:i!==null&&!O&&"web"in f&&(O=typeof f.web=="function"?O=await f.web():O=f.web),O),ce=(g,w)=>{var P,L;if(S){const E=S==null?void 0:S.methods.find(v=>w===v.name);if(E)return E.rtype==="promise"?v=>a.nativePromise(u,w.toString(),v):(v,I)=>a.nativeCallback(u,w.toString(),v,I);if(g)return(P=g[w])===null||P===void 0?void 0:P.bind(g)}else{if(g)return(L=g[w])===null||L===void 0?void 0:L.bind(g);throw new F(`"${u}" plugin is not implemented on ${k}`,_.Unimplemented)}},W=g=>{let w;const P=(...L)=>{const E=ie().then(v=>{const I=ce(v,g);if(I){const D=I(...L);return w=D==null?void 0:D.remove,D}else throw new F(`"${u}.${g}()" is not implemented on ${k}`,_.Unimplemented)});return g==="addListener"&&(E.remove=async()=>w()),E};return P.toString=()=>`${g.toString()}() { [capacitor code] }`,Object.defineProperty(P,"name",{value:g,writable:!1,configurable:!1}),P},K=W("addListener"),V=W("removeListener"),le=(g,w)=>{const P=K({eventName:g},w),L=async()=>{const v=await P;V({eventName:g,callbackId:v},w)},E=new Promise(v=>P.then(()=>v({remove:L})));return E.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await L()},E},q=new Proxy({},{get(g,w){switch(w){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return S?le:K;case"removeListener":return V;default:return W(w)}}});return d[u]=q,B.set(u,{name:u,proxy:q,platforms:new Set([...Object.keys(f),...S?[k]:[]])}),q},ae=((s=c==null?void 0:c.currentPlatform)===null||s===void 0?void 0:s.registerPlugin)||oe;return a.convertFileSrc||(a.convertFileSrc=u=>u),a.getPlatform=l,a.handleError=se,a.isNativePlatform=y,a.isPluginAvailable=h,a.pluginMethodNoop=ne,a.registerPlugin=ae,a.Exception=F,a.DEBUG=!!a.DEBUG,a.isLoggingEnabled=!!a.isLoggingEnabled,a.platform=a.getPlatform(),a.isNative=a.isNativePlatform(),a},me=r=>r.Capacitor=ge(r),M=me(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),X=M.registerPlugin;M.Plugins;class Y{constructor(e){this.listeners={},this.windowListeners={},e&&(console.warn(`Capacitor WebPlugin "${e.name}" config object was deprecated in v3 and will be removed in v4.`),this.config=e)}addListener(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t);const n=this.windowListeners[e];n&&!n.registered&&this.addWindowListener(n);const s=async()=>this.removeListener(e,t),i=Promise.resolve({remove:s});return Object.defineProperty(i,"remove",{value:async()=>{console.warn("Using addListener() without 'await' is deprecated."),await s()}}),i}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,t){const o=this.listeners[e];o&&o.forEach(n=>n(t))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,t){this.windowListeners[t]={registered:!1,windowEventName:e,pluginEventName:t,handler:o=>{this.notifyListeners(t,o)}}}unimplemented(e="not implemented"){return new M.Exception(e,_.Unimplemented)}unavailable(e="not available"){return new M.Exception(e,_.Unavailable)}async removeListener(e,t){const o=this.listeners[e];if(!o)return;const n=o.indexOf(t);this.listeners[e].splice(n,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}}const z=r=>encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),N=r=>r.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class we extends Y{async getCookies(){const e=document.cookie,t={};return e.split(";").forEach(o=>{if(o.length<=0)return;let[n,s]=o.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");n=N(n).trim(),s=N(s).trim(),t[n]=s}),t}async setCookie(e){try{const t=z(e.key),o=z(e.value),n=`; expires=${(e.expires||"").replace("expires=","")}`,s=(e.path||"/").replace("path=",""),i=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${t}=${o||""}${n}; path=${s}; ${i};`}catch(t){return Promise.reject(t)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(t){return Promise.reject(t)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const t of e)document.cookie=t.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}const ee=X("CapacitorCookies",{web:()=>new we}),he=async r=>new Promise((e,t)=>{const o=new FileReader;o.onload=()=>{const n=o.result;e(n.indexOf(",")>=0?n.split(",")[1]:n)},o.onerror=n=>t(n),o.readAsDataURL(r)}),ve=(r={})=>{const e=Object.keys(r);return Object.keys(r).map(n=>n.toLocaleLowerCase()).reduce((n,s,i)=>(n[s]=r[e[i]],n),{})},Pe=(r,e=!0)=>r?Object.entries(r).reduce((o,n)=>{const[s,i]=n;let a,d;return Array.isArray(i)?(d="",i.forEach(c=>{a=e?encodeURIComponent(c):c,d+=`${s}=${a}&`}),d.slice(0,-1)):(a=e?encodeURIComponent(i):i,d=`${s}=${a}`),`${o}&${d}`},"").substr(1):null,be=(r,e={})=>{const t=Object.assign({method:r.method||"GET",headers:r.headers},e),n=ve(r.headers)["content-type"]||"";if(typeof r.data=="string")t.body=r.data;else if(n.includes("application/x-www-form-urlencoded")){const s=new URLSearchParams;for(const[i,a]of Object.entries(r.data||{}))s.set(i,a);t.body=s.toString()}else if(n.includes("multipart/form-data")){const s=new FormData;if(r.data instanceof FormData)r.data.forEach((a,d)=>{s.append(d,a)});else for(const a of Object.keys(r.data))s.append(a,r.data[a]);t.body=s;const i=new Headers(t.headers);i.delete("content-type"),t.headers=i}else(n.includes("application/json")||typeof r.data=="object")&&(t.body=JSON.stringify(r.data));return t};class ye extends Y{async request(e){const t=be(e,e.webFetchExtra),o=Pe(e.params,e.shouldEncodeUrlParams),n=o?`${e.url}?${o}`:e.url,s=await fetch(n,t),i=s.headers.get("content-type")||"";let{responseType:a="text"}=s.ok?e:{};i.includes("application/json")&&(a="json");let d,c;switch(a){case"arraybuffer":case"blob":c=await s.blob(),d=await he(c);break;case"json":d=await s.json();break;case"document":case"text":default:d=await s.text()}const p={};return s.headers.forEach((l,b)=>{p[b]=l}),{data:d,headers:p,status:s.status,url:s.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}X("CapacitorHttp",{web:()=>new ye});const Ce=G.axios.create({baseURL:process.env.API_URL,withCredentials:!0}),U=H.reactive({code:{value:"",type:"",method:"",isSended:!1,isValid:!1}});async function te(r,e,t){return await Ce.post("/api/twofa/sendcode",{phone:r.phone.number,email:r.email,method:e,type:t}).then(o=>(U.code=o.data,U.code.isSended=!0,Promise.resolve(o.data)),o=>(console.log(o),j.setError(o),Promise.reject(o)))}H.watch(U,(r,e)=>{});const Oe=Object.freeze(Object.defineProperty({__proto__:null,sendCode:te,state:U},Symbol.toStringTag,{value:"Module"})),$=G.axios.create({baseURL:process.env.API_URL,withCredentials:!0}),m=H.reactive({user:{_id:"",username:"",email:"",phone:"",password:"",passwordRepeat:""},access:{roles:null,token:null,status:!1}});if(R.get("user")){const{_id:r,email:e,phone:t,roles:o,accessToken:n}=JSON.parse(R.get("user"));Object.assign(m.user,{_id:r,email:e,phone:t}),Object.assign(m.access,{token:n,roles:o,status:!!n}),$.interceptors.request.use(s=>(n&&(s.headers["x-access-token"]=n),s),s=>Promise.reject(s))}const re={async login(r,e){try{const t=await $.post("/api/auth/signin",{...r,type:e});return J("user",t.data),Object.assign(m.user,{...t.data}),Object.assign(m.access,{token:t.data.accessToken,status:!0,roles:t.data.roles}),t.data}catch(t){return Object.assign(m.access,{token:null,status:!1,roles:null}),j.setError(t),Promise.reject(t)}},async signup(r,e,t){const{password:o,passwordRepeat:n}=m.user;if(o!==n){const s={response:{data:{errorCode:"PASSWORDS_DO_NOT_MATCH"}}};throw j.setError(s),new Error(s.response.status)}try{r.phone=r.phone.number;const s=await $.post("/api/auth/signup",{...r,type:e,inviteCode:t});return s.data.accessToken&&J("user",s.data),Object.assign(m.user,{...s.data}),Object.assign(m.access,{token:s.data.accessToken,status:!0,roles:s.data.roles}),s.data}catch(s){throw j.setError(s),console.log("Sign up falied"),s}},logout(){Ee("user"),Object.assign(m.user,{email:"",phone:"",password:"",passwordRepeat:""}),Object.assign(m.access,{token:null,status:!1})},async resetPassword(r,e){try{const t=await $.post("/api/auth/reset-password",{email:r.email,phone:r.phone.number,type:e});return Object.assign(U.code,{...t.data,isSended:!0}),t.data}catch(t){return j.setError(t),Promise.reject(t)}},async updatePassword(r,e){const{password:t,passwordRepeat:o}=m.user;if(t!==o){const n={response:{data:{errorCode:"PASSWORDS_DO_NOT_MATCH"}}};throw j.setError(n),new Error(n.response.status)}try{const n=await $.post("/api/auth/update-password",{email:r.email,phone:r.phone.number,password:r.password,passwordRepeat:r.passwordRepeat,type:e});return n.data.accessToken&&J("user",n.data),Object.assign(m.user,{...n.data}),Object.assign(m.access,{token:n.data.accessToken,status:!0}),n.data}catch(n){return j.setError(n),Promise.reject(n)}}},Le={development:{secure:!1,expires:1},production:{expires:1,domain:process.env.API_URL,sameSite:"none",secure:!0}};function J(r,e,t=process.env.NODE_ENV){process.env.MOBILE_APP?ee.setCookie({url:process.env.API_URL,key:r,value:JSON.stringify(e)}):R.set(r,JSON.stringify(e),Le[t])}function Ee(r,e=process.env.NODE_ENV){if(process.env.MOBILE_APP)ee.deleteCookie({url:process.env.API_URL,key:r});else{const t=e==="production"?{domain:process.env.API_URL}:{};R.remove(r,t)}}H.watch(m,(r,e)=>{});const ke=Object.freeze(Object.defineProperty({__proto__:null,actions:re,state:m},Symbol.toStringTag,{value:"Module"}));exports.Cookies=R;exports.actions=re;exports.auth=ke;exports.sendCode=te;exports.state=m;exports.state$1=U;exports.twofa=Oe;
|