@choosemycompany/lib 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/http/buildUrl.d.ts +12 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +152 -142
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the `{name}` placeholders of a URI template.
|
|
3
|
+
*
|
|
4
|
+
* Every placeholder is replaced, each value is passed through
|
|
5
|
+
* `encodeURIComponent`, and a placeholder the params do not provide throws
|
|
6
|
+
* instead of sending a request to a wrong path.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* buildUrl('/v3/forms/{id}/periods/{period}', { id: 42, period: '2026' })
|
|
10
|
+
* // → '/v3/forms/42/periods/2026'
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildUrl(template: string, params: Record<string, string | number>): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Grouped by concern:
|
|
8
8
|
* - **HTTP** — {@link configureHttp}: the app declares its base URLs;
|
|
9
|
-
* {@link useHttp}: thin `mande` wrapper bound to one of them
|
|
9
|
+
* {@link useHttp}: thin `mande` wrapper bound to one of them;
|
|
10
|
+
* {@link buildUrl}: resolves the `{name}` placeholders of a URI template.
|
|
10
11
|
* - **Store** — {@link useStore}, {@link getViewKey}: typed cache for `retrieve` /
|
|
11
12
|
* `list` workflows with single-flight, per-key errors, and CRUD mutations.
|
|
12
13
|
* - **i18n** — locale-aware translators for plain strings, country names,
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
*/
|
|
22
23
|
export { useHttp } from './http/useHttp';
|
|
23
24
|
export { configureHttp, type HttpConfig } from './http/config';
|
|
25
|
+
export { buildUrl } from './http/buildUrl';
|
|
24
26
|
export { useAuthSession } from './auth/useAuthSession';
|
|
25
27
|
export { useStore, getViewKey, CREATE_PENDING_KEY, type Store } from './store/useStore';
|
|
26
28
|
export { useClickOutside } from './ui/useClickOutside';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { mande as N } from "mande";
|
|
2
|
-
import { ref as w, computed as
|
|
2
|
+
import { ref as w, computed as R, onMounted as z, onBeforeUnmount as H, onUnmounted as K } from "vue";
|
|
3
3
|
import { defineStore as F } from "pinia";
|
|
4
|
-
import { useI18n as
|
|
4
|
+
import { useI18n as E } from "vue-i18n";
|
|
5
5
|
import { createError as O } from "h3";
|
|
6
6
|
import { showError as x, useRuntimeConfig as q, useState as Z } from "nuxt/app";
|
|
7
7
|
let I;
|
|
8
|
-
function
|
|
8
|
+
function ce(e) {
|
|
9
9
|
if (!e.baseUrl)
|
|
10
10
|
throw new Error("@choosemycompany/lib: configureHttp() needs a non-empty baseUrl");
|
|
11
11
|
I = e;
|
|
@@ -16,30 +16,30 @@ function D(e) {
|
|
|
16
16
|
"@choosemycompany/lib: useHttp() was called before configureHttp(). Declare the base URLs from an app plugin."
|
|
17
17
|
);
|
|
18
18
|
if (e === void 0) return I.baseUrl;
|
|
19
|
-
const a = I.targets ?? {},
|
|
20
|
-
if (typeof
|
|
21
|
-
const t = Object.keys(a),
|
|
19
|
+
const a = I.targets ?? {}, i = Object.hasOwn(a, e) ? a[e] : void 0;
|
|
20
|
+
if (typeof i != "string" || !i) {
|
|
21
|
+
const t = Object.keys(a), n = t.length > 0 ? t.join(", ") : "none";
|
|
22
22
|
throw new Error(
|
|
23
|
-
`@choosemycompany/lib: no HTTP target named "${e}". Declared targets: ${
|
|
23
|
+
`@choosemycompany/lib: no HTTP target named "${e}". Declared targets: ${n}.`
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
|
-
return
|
|
26
|
+
return i;
|
|
27
27
|
}
|
|
28
28
|
const V = "/auth/api/v2/login/token/refresh", J = "/auth/api/v2/", j = "cmc-auth-session-refresh", _ = F("cmc-auth-session", () => {
|
|
29
|
-
const e = w(!1), a = w(!1),
|
|
30
|
-
let t,
|
|
31
|
-
const s =
|
|
29
|
+
const e = w(!1), a = w(!1), i = w(void 0);
|
|
30
|
+
let t, n = 0;
|
|
31
|
+
const s = R(() => e.value && !a.value);
|
|
32
32
|
function d() {
|
|
33
|
-
e.value = !0, a.value = !1,
|
|
33
|
+
e.value = !0, a.value = !1, i.value = void 0;
|
|
34
34
|
}
|
|
35
35
|
function l() {
|
|
36
|
-
|
|
36
|
+
n += 1, e.value = !1, a.value = !1, i.value = void 0;
|
|
37
37
|
}
|
|
38
38
|
function p() {
|
|
39
|
-
|
|
39
|
+
n += 1, e.value = !1, a.value = !0, i.value = "logout";
|
|
40
40
|
}
|
|
41
41
|
function c(h) {
|
|
42
|
-
|
|
42
|
+
n += 1, e.value = !1, a.value = !0, i.value = h;
|
|
43
43
|
}
|
|
44
44
|
async function m() {
|
|
45
45
|
if (a.value)
|
|
@@ -54,7 +54,7 @@ const V = "/auth/api/v2/login/token/refresh", J = "/auth/api/v2/", j = "cmc-auth
|
|
|
54
54
|
await b.request(j, h);
|
|
55
55
|
}
|
|
56
56
|
async function g() {
|
|
57
|
-
const h =
|
|
57
|
+
const h = n, b = () => h !== n, r = new URL(V, D()).href;
|
|
58
58
|
let u;
|
|
59
59
|
try {
|
|
60
60
|
u = await fetch(r, {
|
|
@@ -71,12 +71,12 @@ const V = "/auth/api/v2/login/token/refresh", J = "/auth/api/v2/", j = "cmc-auth
|
|
|
71
71
|
d();
|
|
72
72
|
}
|
|
73
73
|
function C() {
|
|
74
|
-
|
|
74
|
+
i.value = "refresh-unreachable";
|
|
75
75
|
}
|
|
76
76
|
return {
|
|
77
77
|
isOpen: e,
|
|
78
78
|
isExpired: a,
|
|
79
|
-
expiryReason:
|
|
79
|
+
expiryReason: i,
|
|
80
80
|
isAuthenticated: s,
|
|
81
81
|
open: d,
|
|
82
82
|
expire: c,
|
|
@@ -94,44 +94,53 @@ function W(e) {
|
|
|
94
94
|
function Q() {
|
|
95
95
|
return async (e, a) => {
|
|
96
96
|
if ($()) return fetch(e, a);
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
97
|
+
const i = await fetch(e, a);
|
|
98
|
+
if (i.status !== 401 || W(e) || new Headers(a?.headers).has("Authorization")) return i;
|
|
99
99
|
let t;
|
|
100
100
|
try {
|
|
101
101
|
t = _();
|
|
102
102
|
} catch {
|
|
103
|
-
return
|
|
103
|
+
return i;
|
|
104
104
|
}
|
|
105
|
-
if (t.isExpired) return
|
|
105
|
+
if (t.isExpired) return i;
|
|
106
106
|
try {
|
|
107
107
|
await t.refresh();
|
|
108
|
-
} catch (
|
|
109
|
-
return t.isExpired || console.warn("[cmc-lib] token refresh failed, returning the original 401",
|
|
108
|
+
} catch (n) {
|
|
109
|
+
return t.isExpired || console.warn("[cmc-lib] token refresh failed, returning the original 401", n), i;
|
|
110
110
|
}
|
|
111
111
|
return fetch(e, a);
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function fe(e) {
|
|
115
115
|
const a = N(D(e), {
|
|
116
116
|
headers: {}
|
|
117
117
|
}, Q());
|
|
118
|
-
function n
|
|
118
|
+
function i(n) {
|
|
119
119
|
a.options.headers = {
|
|
120
120
|
...a.options.headers ?? {},
|
|
121
|
-
Authorization: `Bearer ${
|
|
121
|
+
Authorization: `Bearer ${n}`
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
function t() {
|
|
125
125
|
a.options.headers && delete a.options.headers.Authorization;
|
|
126
126
|
}
|
|
127
|
-
return { http: a, setToken:
|
|
127
|
+
return { http: a, setToken: i, clearToken: t };
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
return
|
|
129
|
+
function pe(e, a) {
|
|
130
|
+
return e.replace(Y, (i, t) => {
|
|
131
|
+
const n = Object.hasOwn(a, t) ? a[t] : void 0;
|
|
132
|
+
if (typeof n != "string" && typeof n != "number")
|
|
133
|
+
throw new Error(`Missing URL parameter "${t}" for template "${e}"`);
|
|
134
|
+
return encodeURIComponent(String(n));
|
|
135
|
+
});
|
|
131
136
|
}
|
|
132
|
-
const Y =
|
|
133
|
-
function
|
|
134
|
-
|
|
137
|
+
const Y = /\{(\w+)\}/g;
|
|
138
|
+
function T(e) {
|
|
139
|
+
return Object.entries(e).sort(([a], [i]) => a.localeCompare(i)).map(([a, i]) => `${a}=${i}`).join("|");
|
|
140
|
+
}
|
|
141
|
+
const X = "create";
|
|
142
|
+
function ge(e) {
|
|
143
|
+
const a = w({}), i = w({}), t = w({}), n = w({}), s = e.getItemId ?? ((r) => {
|
|
135
144
|
const u = r.id;
|
|
136
145
|
if (u === void 0)
|
|
137
146
|
throw new Error(
|
|
@@ -140,17 +149,17 @@ function fe(e) {
|
|
|
140
149
|
return u;
|
|
141
150
|
});
|
|
142
151
|
function d(r) {
|
|
143
|
-
return !!
|
|
152
|
+
return !!n.value[r];
|
|
144
153
|
}
|
|
145
154
|
async function l(r, u) {
|
|
146
|
-
|
|
155
|
+
n.value[r] = u;
|
|
147
156
|
try {
|
|
148
157
|
const o = await u;
|
|
149
158
|
return delete t.value[r], o;
|
|
150
159
|
} catch (o) {
|
|
151
160
|
throw t.value[r] = o, o;
|
|
152
161
|
} finally {
|
|
153
|
-
|
|
162
|
+
n.value[r] === u && delete n.value[r];
|
|
154
163
|
}
|
|
155
164
|
}
|
|
156
165
|
async function p(r, u = {}) {
|
|
@@ -159,7 +168,7 @@ function fe(e) {
|
|
|
159
168
|
const { force: o = !1 } = u;
|
|
160
169
|
if (a.value[r] && !o)
|
|
161
170
|
return a.value[r];
|
|
162
|
-
const f =
|
|
171
|
+
const f = n.value[r];
|
|
163
172
|
if (f)
|
|
164
173
|
return f;
|
|
165
174
|
const B = e.fetchOne, S = (async () => {
|
|
@@ -170,13 +179,13 @@ function fe(e) {
|
|
|
170
179
|
t.value[r] = M;
|
|
171
180
|
return;
|
|
172
181
|
} finally {
|
|
173
|
-
delete
|
|
182
|
+
delete n.value[r];
|
|
174
183
|
}
|
|
175
184
|
})();
|
|
176
|
-
return
|
|
185
|
+
return n.value[r] = S, S;
|
|
177
186
|
}
|
|
178
187
|
function c(r) {
|
|
179
|
-
const u =
|
|
188
|
+
const u = T(r), o = i.value[u];
|
|
180
189
|
if (o)
|
|
181
190
|
return {
|
|
182
191
|
items: o.itemIds.map((f) => a.value[f]).filter((f) => f !== void 0),
|
|
@@ -189,21 +198,21 @@ function fe(e) {
|
|
|
189
198
|
async function m(r, u = {}) {
|
|
190
199
|
if (!e.fetchPage)
|
|
191
200
|
throw new Error("useStore.list called but fetchPage is not defined in store options");
|
|
192
|
-
const o =
|
|
193
|
-
if (
|
|
201
|
+
const o = T(r), { force: f = !1 } = u;
|
|
202
|
+
if (i.value[o] && !f)
|
|
194
203
|
return c(r);
|
|
195
|
-
const B =
|
|
204
|
+
const B = n.value[o];
|
|
196
205
|
if (B)
|
|
197
206
|
return await B, c(r);
|
|
198
207
|
const S = e.fetchPage, M = (async () => {
|
|
199
208
|
try {
|
|
200
|
-
const A = await S(r),
|
|
209
|
+
const A = await S(r), k = [];
|
|
201
210
|
for (const y of A.items) {
|
|
202
|
-
const P = e.enrichItem ? e.enrichItem(y) : y,
|
|
203
|
-
a.value[
|
|
211
|
+
const P = e.enrichItem ? e.enrichItem(y) : y, U = s(P);
|
|
212
|
+
a.value[U] = P, k.push(U);
|
|
204
213
|
}
|
|
205
|
-
|
|
206
|
-
itemIds:
|
|
214
|
+
i.value[o] = {
|
|
215
|
+
itemIds: k,
|
|
207
216
|
total: A.total,
|
|
208
217
|
hasMore: A.hasMore,
|
|
209
218
|
page: A.page,
|
|
@@ -212,16 +221,16 @@ function fe(e) {
|
|
|
212
221
|
} catch (A) {
|
|
213
222
|
t.value[o] = A;
|
|
214
223
|
} finally {
|
|
215
|
-
delete
|
|
224
|
+
delete n.value[o];
|
|
216
225
|
}
|
|
217
226
|
})();
|
|
218
|
-
return
|
|
227
|
+
return n.value[o] = M, await M, c(r);
|
|
219
228
|
}
|
|
220
|
-
async function v(r, u =
|
|
229
|
+
async function v(r, u = X) {
|
|
221
230
|
if (!e.createMutation)
|
|
222
231
|
throw new Error("useStore.create called but createMutation is not defined in store options");
|
|
223
232
|
const o = e.createMutation, f = await l(u, (async () => o(r))()), B = e.enrichItem ? e.enrichItem(f) : f, S = s(B);
|
|
224
|
-
return a.value[S] = B,
|
|
233
|
+
return a.value[S] = B, i.value = {}, B;
|
|
225
234
|
}
|
|
226
235
|
async function g(r, u) {
|
|
227
236
|
if (!e.updateMutation)
|
|
@@ -234,7 +243,7 @@ function fe(e) {
|
|
|
234
243
|
throw new Error("useStore.remove called but removeMutation is not defined in store options");
|
|
235
244
|
const u = e.removeMutation;
|
|
236
245
|
await l(r, (async () => u(r))()), delete a.value[r];
|
|
237
|
-
for (const o of Object.values(
|
|
246
|
+
for (const o of Object.values(i.value)) {
|
|
238
247
|
const f = o.itemIds.indexOf(r);
|
|
239
248
|
f !== -1 && (o.itemIds.splice(f, 1), o.total = Math.max(0, o.total - 1));
|
|
240
249
|
}
|
|
@@ -243,38 +252,38 @@ function fe(e) {
|
|
|
243
252
|
t.value = {};
|
|
244
253
|
}
|
|
245
254
|
function b() {
|
|
246
|
-
a.value = {},
|
|
255
|
+
a.value = {}, i.value = {}, t.value = {}, n.value = {};
|
|
247
256
|
}
|
|
248
|
-
return { items: a, views:
|
|
257
|
+
return { items: a, views: i, errors: t, isPending: d, list: m, reset: b, retrieve: p, getView: c, withPending: l, create: v, update: g, remove: C, clearErrors: h };
|
|
249
258
|
}
|
|
250
|
-
function
|
|
251
|
-
const
|
|
252
|
-
const
|
|
253
|
-
!
|
|
259
|
+
function me(e, a) {
|
|
260
|
+
const i = (t) => {
|
|
261
|
+
const n = e.value, s = t.target;
|
|
262
|
+
!n || !s || n.contains(s) || a();
|
|
254
263
|
};
|
|
255
264
|
z(() => {
|
|
256
|
-
document.addEventListener("click",
|
|
257
|
-
}),
|
|
258
|
-
document.removeEventListener("click",
|
|
265
|
+
document.addEventListener("click", i);
|
|
266
|
+
}), H(() => {
|
|
267
|
+
document.removeEventListener("click", i);
|
|
259
268
|
});
|
|
260
269
|
}
|
|
261
|
-
function
|
|
262
|
-
const { locale: e } =
|
|
263
|
-
function a(
|
|
264
|
-
const
|
|
265
|
-
if (!
|
|
266
|
-
throw new Error(`Unknown country code: ${
|
|
267
|
-
if (t &&
|
|
268
|
-
return
|
|
269
|
-
if (
|
|
270
|
-
return
|
|
271
|
-
if (e.value !== "en" &&
|
|
272
|
-
return
|
|
273
|
-
throw new Error(`Unknown country code: ${
|
|
270
|
+
function he() {
|
|
271
|
+
const { locale: e } = E();
|
|
272
|
+
function a(i, t = null) {
|
|
273
|
+
const n = ee[i.trim().toUpperCase()];
|
|
274
|
+
if (!n)
|
|
275
|
+
throw new Error(`Unknown country code: ${i}`);
|
|
276
|
+
if (t && n[t])
|
|
277
|
+
return n[t];
|
|
278
|
+
if (n[e.value])
|
|
279
|
+
return n[e.value];
|
|
280
|
+
if (e.value !== "en" && n.en)
|
|
281
|
+
return n.en;
|
|
282
|
+
throw new Error(`Unknown country code: ${i}`);
|
|
274
283
|
}
|
|
275
284
|
return a;
|
|
276
285
|
}
|
|
277
|
-
const
|
|
286
|
+
const ee = {
|
|
278
287
|
AD: { en: "Andorra", fr: "Andorre", es: "Andorra", de: "Andorra", it: "Andorra", pt: "Andorra", da: "Andorra" },
|
|
279
288
|
AE: { en: "United Arab Emirates", fr: "Émirats arabes unis", es: "Emiratos Árabes Unidos", de: "Vereinigte Arabische Emirate", it: "Emirati Arabi Uniti", pt: "Emirados Árabes Unidos", da: "De Forenede Arabiske Emirater" },
|
|
280
289
|
AF: { en: "Afghanistan", fr: "Afghanistan", es: "Afganistán", de: "Afghanistan", it: "Afghanistan", pt: "Afeganistão", da: "Afghanistan" },
|
|
@@ -412,53 +421,53 @@ const X = {
|
|
|
412
421
|
ZA: { en: "South Africa", fr: "Afrique Du Sud", es: "Sudáfrica", de: "Südafrika", it: "Sudafrica", pt: "África Do Sul", da: "Sydafrika" },
|
|
413
422
|
ZM: { en: "Zambia", fr: "Zambie", es: "Zambia", de: "Sambia", it: "Zambia", pt: "Zâmbia", da: "Zambia" },
|
|
414
423
|
ZW: { en: "Zimbabwe", fr: "Zimbabwe", es: "Zimbabue", de: "Simbabwe", it: "Zimbabwe", pt: "Zimbábue", da: "Zimbabwe" }
|
|
415
|
-
},
|
|
416
|
-
const t = a || "An unexpected error occurred",
|
|
424
|
+
}, be = ({ code: e, message: a, data: i }) => {
|
|
425
|
+
const t = a || "An unexpected error occurred", n = O({
|
|
417
426
|
statusCode: e,
|
|
418
427
|
statusMessage: t,
|
|
419
428
|
message: t,
|
|
420
|
-
data:
|
|
429
|
+
data: i
|
|
421
430
|
});
|
|
422
|
-
throw x(
|
|
423
|
-
},
|
|
424
|
-
function
|
|
431
|
+
throw x(n), n;
|
|
432
|
+
}, ae = "ilcJCL_lmpwcEJfSkKND";
|
|
433
|
+
function Be() {
|
|
425
434
|
const { gtagId: e } = q().public;
|
|
426
435
|
return { reportConversion: () => {
|
|
427
436
|
if (typeof window > "u" || typeof window.gtag > "u" || !e)
|
|
428
437
|
return;
|
|
429
|
-
const
|
|
438
|
+
const i = `${e}/${ae}`;
|
|
430
439
|
window.gtag("event", "conversion", {
|
|
431
|
-
send_to:
|
|
440
|
+
send_to: i
|
|
432
441
|
});
|
|
433
442
|
} };
|
|
434
443
|
}
|
|
435
444
|
const L = "https://5509641.hs-sites-eu1.com";
|
|
436
|
-
function
|
|
437
|
-
const { locale: e } =
|
|
438
|
-
return { contactUrl:
|
|
445
|
+
function ve() {
|
|
446
|
+
const { locale: e } = E();
|
|
447
|
+
return { contactUrl: R(() => e.value === "fr" ? `${L}/contact` : `${L}/${e.value}/contact`) };
|
|
439
448
|
}
|
|
440
|
-
function
|
|
449
|
+
function Ae() {
|
|
441
450
|
async function e(t) {
|
|
442
451
|
await Promise.all(
|
|
443
452
|
t.map(
|
|
444
|
-
(
|
|
445
|
-
if (!
|
|
453
|
+
(n) => new Promise((s) => {
|
|
454
|
+
if (!n) return s(null);
|
|
446
455
|
const d = new Image();
|
|
447
|
-
d.onload = () => s(null), d.onerror = () => s(null), d.src =
|
|
456
|
+
d.onload = () => s(null), d.onerror = () => s(null), d.src = n;
|
|
448
457
|
})
|
|
449
458
|
)
|
|
450
459
|
);
|
|
451
460
|
}
|
|
452
|
-
function a(t,
|
|
453
|
-
return
|
|
461
|
+
function a(t, n) {
|
|
462
|
+
return n.split(".").reduce((s, d) => s && typeof s == "object" && d in s ? s[d] : "", t) ?? "";
|
|
454
463
|
}
|
|
455
|
-
function
|
|
464
|
+
function i(t, n, s) {
|
|
456
465
|
if (import.meta.server)
|
|
457
466
|
return async (l) => {
|
|
458
467
|
t.value = !0;
|
|
459
468
|
};
|
|
460
469
|
const d = Z(
|
|
461
|
-
`${
|
|
470
|
+
`${n}LoadedImageCache`,
|
|
462
471
|
() => ({})
|
|
463
472
|
);
|
|
464
473
|
return async (l) => {
|
|
@@ -466,7 +475,7 @@ function Be() {
|
|
|
466
475
|
t.value = !1;
|
|
467
476
|
return;
|
|
468
477
|
}
|
|
469
|
-
const p = s.map((v) => a(l, v)), c = `${
|
|
478
|
+
const p = s.map((v) => a(l, v)), c = `${n}|${p.join("|")}`;
|
|
470
479
|
if (d.value[c]) {
|
|
471
480
|
t.value = !0;
|
|
472
481
|
return;
|
|
@@ -476,51 +485,51 @@ function Be() {
|
|
|
476
485
|
await e(m), d.value[c] = !0, t.value = !0;
|
|
477
486
|
};
|
|
478
487
|
}
|
|
479
|
-
return
|
|
488
|
+
return i;
|
|
480
489
|
}
|
|
481
|
-
const
|
|
490
|
+
const ne = {
|
|
482
491
|
en: ["US", "UK"]
|
|
483
|
-
},
|
|
484
|
-
function
|
|
485
|
-
const a = e.trim().replace("_", "-"), [
|
|
492
|
+
}, ie = "FR";
|
|
493
|
+
function te(e) {
|
|
494
|
+
const a = e.trim().replace("_", "-"), [i, t] = a.split("-");
|
|
486
495
|
return {
|
|
487
|
-
language:
|
|
496
|
+
language: i?.toLowerCase() ?? "",
|
|
488
497
|
region: t?.toUpperCase() ?? ""
|
|
489
498
|
};
|
|
490
499
|
}
|
|
491
500
|
function G(e) {
|
|
492
501
|
return e.toString().trim().toUpperCase();
|
|
493
502
|
}
|
|
494
|
-
function
|
|
495
|
-
function e(a,
|
|
496
|
-
if (!
|
|
497
|
-
const t =
|
|
503
|
+
function Ce() {
|
|
504
|
+
function e(a, i) {
|
|
505
|
+
if (!i.length) return;
|
|
506
|
+
const t = i.map(G), n = new Set(t), { language: s, region: d } = te(a), l = [];
|
|
498
507
|
d && l.push(d);
|
|
499
|
-
const p =
|
|
500
|
-
p?.length && l.push(...p.map(G)), s && l.push(s.toUpperCase()), l.push(
|
|
508
|
+
const p = ne[s];
|
|
509
|
+
p?.length && l.push(...p.map(G)), s && l.push(s.toUpperCase()), l.push(ie);
|
|
501
510
|
for (const c of l)
|
|
502
|
-
if (
|
|
511
|
+
if (n.has(c))
|
|
503
512
|
return c;
|
|
504
513
|
return t[0];
|
|
505
514
|
}
|
|
506
515
|
return { getRegionFromLocale: e };
|
|
507
516
|
}
|
|
508
|
-
function
|
|
509
|
-
const { t: e } =
|
|
510
|
-
function a(
|
|
511
|
-
const
|
|
512
|
-
let m = 0, v = p.exec(
|
|
517
|
+
function we() {
|
|
518
|
+
const { t: e } = E();
|
|
519
|
+
function a(i, t) {
|
|
520
|
+
const n = e(i), s = [], l = t.map((g) => g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), p = new RegExp(`\\[(${l})\\]([\\s\\S]*?)\\[\\/\\1\\]`, "g"), c = t.reduce((g, C) => (g[C] = !1, g), {});
|
|
521
|
+
let m = 0, v = p.exec(n);
|
|
513
522
|
for (; v; ) {
|
|
514
523
|
const { index: g, 0: C, 1: h, 2: b } = v;
|
|
515
|
-
g > m && s.push({ text:
|
|
524
|
+
g > m && s.push({ text: n.slice(m, g), ...c }), b && h && s.push({ text: b, ...c, [h]: !0 }), m = g + C.length, v = p.exec(n);
|
|
516
525
|
}
|
|
517
|
-
return m <
|
|
526
|
+
return m < n.length && s.push({ text: n.slice(m), ...c }), s;
|
|
518
527
|
}
|
|
519
528
|
return { parse: a };
|
|
520
529
|
}
|
|
521
|
-
function
|
|
522
|
-
const t = w(
|
|
523
|
-
() => t.value >=
|
|
530
|
+
function Me(e, a, i = 768) {
|
|
531
|
+
const t = w(i - 1), n = R(
|
|
532
|
+
() => t.value >= i ? a : e
|
|
524
533
|
);
|
|
525
534
|
if (import.meta.client) {
|
|
526
535
|
const s = () => {
|
|
@@ -528,36 +537,37 @@ function Ce(e, a, n = 768) {
|
|
|
528
537
|
};
|
|
529
538
|
z(() => {
|
|
530
539
|
s(), window.addEventListener("resize", s);
|
|
531
|
-
}),
|
|
540
|
+
}), K(() => {
|
|
532
541
|
window.removeEventListener("resize", s);
|
|
533
542
|
});
|
|
534
543
|
}
|
|
535
|
-
return { size:
|
|
544
|
+
return { size: n, windowWidth: t };
|
|
536
545
|
}
|
|
537
|
-
function
|
|
538
|
-
const { locale: e } =
|
|
539
|
-
function a(
|
|
540
|
-
if (!
|
|
541
|
-
const
|
|
542
|
-
return n
|
|
546
|
+
function Se() {
|
|
547
|
+
const { locale: e } = E();
|
|
548
|
+
function a(i, t = "fr") {
|
|
549
|
+
if (!i) return "";
|
|
550
|
+
const n = e.value;
|
|
551
|
+
return i[n] ?? i[t] ?? "";
|
|
543
552
|
}
|
|
544
553
|
return a;
|
|
545
554
|
}
|
|
546
555
|
export {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
556
|
+
X as CREATE_PENDING_KEY,
|
|
557
|
+
pe as buildUrl,
|
|
558
|
+
ce as configureHttp,
|
|
559
|
+
T as getViewKey,
|
|
560
|
+
be as showAndThrowError,
|
|
551
561
|
_ as useAuthSession,
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
562
|
+
me as useClickOutside,
|
|
563
|
+
he as useCountriesTranslation,
|
|
564
|
+
Be as useGtagConversion,
|
|
565
|
+
fe as useHttp,
|
|
566
|
+
ve as useHubspotContactUrl,
|
|
567
|
+
Ae as useImageCacheWatcherCallback,
|
|
568
|
+
Ce as useLocaleHelpers,
|
|
569
|
+
we as useParseTranslation,
|
|
570
|
+
Me as useResponsiveSize,
|
|
571
|
+
ge as useStore,
|
|
572
|
+
Se as useTranslate
|
|
563
573
|
};
|
package/package.json
CHANGED