@tracktor/shared-module 2.20.2 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Utils/ServiceWorkerCleaner.d.ts +10 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +120 -101
- package/dist/main.umd.cjs +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ServiceWorkerCleaner unregisters all existing service workers on mount.
|
|
3
|
+
*
|
|
4
|
+
* Use this component when a PWA has been disabled but users may still
|
|
5
|
+
* have stale service workers registered in their browsers.
|
|
6
|
+
*
|
|
7
|
+
* Renders nothing (returns null).
|
|
8
|
+
*/
|
|
9
|
+
declare const ServiceWorkerCleaner: () => null;
|
|
10
|
+
export default ServiceWorkerCleaner;
|
package/dist/main.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export * from './components/Utils/PreloadErrorHandler';
|
|
|
15
15
|
export { default as PreloadErrorHandler } from './components/Utils/PreloadErrorHandler';
|
|
16
16
|
export * from './components/Utils/RequireAuth';
|
|
17
17
|
export { default as RequireAuth } from './components/Utils/RequireAuth';
|
|
18
|
+
export * from './components/Utils/ServiceWorkerCleaner';
|
|
19
|
+
export { default as ServiceWorkerCleaner } from './components/Utils/ServiceWorkerCleaner';
|
|
18
20
|
export * from './components/Utils/UpdateNotifier';
|
|
19
21
|
export { default as UpdateNotifier } from './components/Utils/UpdateNotifier';
|
|
20
22
|
export * from './config/orval';
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Z from "axios";
|
|
2
|
-
import fe, { useMemo as G, createContext as pe, useContext as P, useEffect as
|
|
3
|
-
const
|
|
2
|
+
import fe, { useMemo as G, createContext as pe, useContext as P, useEffect as S, useState as Y, Suspense as ge, useRef as me, useCallback as O } from "react";
|
|
3
|
+
const ze = (e, r) => {
|
|
4
4
|
const a = Z.CancelToken.source(), o = Z({
|
|
5
5
|
...e,
|
|
6
6
|
...r,
|
|
@@ -60,7 +60,7 @@ function ye() {
|
|
|
60
60
|
switch (typeof t.tag == "number" && console.error(
|
|
61
61
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
62
62
|
), t.$$typeof) {
|
|
63
|
-
case
|
|
63
|
+
case j:
|
|
64
64
|
return "Portal";
|
|
65
65
|
case R:
|
|
66
66
|
return t.displayName || "Context";
|
|
@@ -230,7 +230,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
230
230
|
function g(t) {
|
|
231
231
|
return typeof t == "object" && t !== null && t.$$typeof === k;
|
|
232
232
|
}
|
|
233
|
-
var v = fe, k = /* @__PURE__ */ Symbol.for("react.transitional.element"),
|
|
233
|
+
var v = fe, k = /* @__PURE__ */ Symbol.for("react.transitional.element"), j = /* @__PURE__ */ Symbol.for("react.portal"), T = /* @__PURE__ */ Symbol.for("react.fragment"), h = /* @__PURE__ */ Symbol.for("react.strict_mode"), d = /* @__PURE__ */ Symbol.for("react.profiler"), b = /* @__PURE__ */ Symbol.for("react.consumer"), R = /* @__PURE__ */ Symbol.for("react.context"), _ = /* @__PURE__ */ Symbol.for("react.forward_ref"), I = /* @__PURE__ */ Symbol.for("react.suspense"), ie = /* @__PURE__ */ Symbol.for("react.suspense_list"), se = /* @__PURE__ */ Symbol.for("react.memo"), z = /* @__PURE__ */ Symbol.for("react.lazy"), ce = /* @__PURE__ */ Symbol.for("react.activity"), le = /* @__PURE__ */ Symbol.for("react.client.reference"), U = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, ue = Array.isArray, Q = console.createTask ? console.createTask : function() {
|
|
234
234
|
return null;
|
|
235
235
|
};
|
|
236
236
|
v = {
|
|
@@ -270,14 +270,14 @@ function ve() {
|
|
|
270
270
|
return re || (re = 1, process.env.NODE_ENV === "production" ? D.exports = he() : D.exports = ye()), D.exports;
|
|
271
271
|
}
|
|
272
272
|
var C = ve();
|
|
273
|
-
const
|
|
273
|
+
const Ue = ({ IMaskMixin: e, ...r }) => {
|
|
274
274
|
const a = G(
|
|
275
275
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
276
276
|
() => e(({ TextField: o, ...n }) => /* @__PURE__ */ C.jsx(o, { ...n })),
|
|
277
277
|
[e]
|
|
278
278
|
);
|
|
279
279
|
return /* @__PURE__ */ C.jsx(a, { ...r });
|
|
280
|
-
},
|
|
280
|
+
}, A = pe({}), Qe = ({ children: e, apiURL: r, libraries: a, localStorageKeys: o }) => {
|
|
281
281
|
const n = G(
|
|
282
282
|
() => ({
|
|
283
283
|
apiURL: r,
|
|
@@ -286,9 +286,9 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
286
286
|
}),
|
|
287
287
|
[r, a, o]
|
|
288
288
|
);
|
|
289
|
-
return /* @__PURE__ */ C.jsx(
|
|
290
|
-
},
|
|
291
|
-
const { libraries: a } = P(
|
|
289
|
+
return /* @__PURE__ */ C.jsx(A.Provider, { value: n, children: e });
|
|
290
|
+
}, Ve = ({ data: e, ...r }) => {
|
|
291
|
+
const { libraries: a } = P(A), o = r?.reactRouter || a?.reactRouter, n = r?.gtm || a?.gtm;
|
|
292
292
|
if (!o)
|
|
293
293
|
throw new Error(
|
|
294
294
|
"React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView."
|
|
@@ -296,7 +296,7 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
296
296
|
if (!n)
|
|
297
297
|
throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
|
|
298
298
|
const { useGoogleTagManager: s } = n, { useLocation: c, Outlet: u } = o, { pathname: l } = c(), { sendEvent: f } = s();
|
|
299
|
-
return
|
|
299
|
+
return S(() => {
|
|
300
300
|
f({
|
|
301
301
|
event: "pageView",
|
|
302
302
|
pathname: l,
|
|
@@ -311,13 +311,13 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
311
311
|
} catch {
|
|
312
312
|
return !1;
|
|
313
313
|
}
|
|
314
|
-
})(), we = "user",
|
|
314
|
+
})(), we = "user", Me = ({
|
|
315
315
|
tokenTypeKey: e = "tokenType",
|
|
316
316
|
tokenKey: r = "accessToken",
|
|
317
317
|
postContentType: a = "application/json",
|
|
318
318
|
...o
|
|
319
319
|
}) => {
|
|
320
|
-
const { apiURL: n = o.apiURL, libraries: s, localStorageKeys: c } = P(
|
|
320
|
+
const { apiURL: n = o.apiURL, libraries: s, localStorageKeys: c } = P(A), u = o?.userLocalStorageKey || c?.user || we, l = o?.axios || s?.axios;
|
|
321
321
|
if (!l)
|
|
322
322
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
323
323
|
if (!l?.defaults || F)
|
|
@@ -327,13 +327,13 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
327
327
|
v && (l.defaults.headers.common.Authorization = v);
|
|
328
328
|
}
|
|
329
329
|
return l.defaults.baseURL = n, l.defaults.headers.post["Content-Type"] = a, null;
|
|
330
|
-
},
|
|
331
|
-
const { libraries: a } = P(
|
|
330
|
+
}, Ge = ({ language: e, ...r }) => {
|
|
331
|
+
const { libraries: a } = P(A), o = r?.dayjs || a?.dayjs, n = r?.plugin || a?.dayjsPlugin;
|
|
332
332
|
if (!o)
|
|
333
333
|
throw new Error(
|
|
334
334
|
"Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig."
|
|
335
335
|
);
|
|
336
|
-
return
|
|
336
|
+
return S(() => {
|
|
337
337
|
(async () => {
|
|
338
338
|
const c = e || navigator.language?.slice(0, 2) || "en";
|
|
339
339
|
n && n.forEach((u) => {
|
|
@@ -341,8 +341,8 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
341
341
|
}), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), o.locale(c);
|
|
342
342
|
})().then();
|
|
343
343
|
}, [o, n, e]), null;
|
|
344
|
-
},
|
|
345
|
-
const { libraries: o } = P(
|
|
344
|
+
}, Je = ({ debug: e, resources: r, ...a }) => {
|
|
345
|
+
const { libraries: o } = P(A), n = a?.i18 || o?.i18, { i18next: s, initReactI18next: c, languageDetector: u } = n || {};
|
|
346
346
|
if (F)
|
|
347
347
|
return null;
|
|
348
348
|
if (!n)
|
|
@@ -365,7 +365,7 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
365
365
|
}), s.on("languageChanged", (l) => {
|
|
366
366
|
document.documentElement.setAttribute("lang", l);
|
|
367
367
|
})), null;
|
|
368
|
-
},
|
|
368
|
+
}, qe = ({
|
|
369
369
|
dsn: e,
|
|
370
370
|
integrations: r,
|
|
371
371
|
tracesSampleRate: a,
|
|
@@ -378,14 +378,14 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
378
378
|
release: f,
|
|
379
379
|
...i
|
|
380
380
|
}) => {
|
|
381
|
-
const { libraries: m } = P(
|
|
381
|
+
const { libraries: m } = P(A), g = i?.sentry || m?.sentry, v = i?.reactRouter || m?.reactRouter;
|
|
382
382
|
if (!g)
|
|
383
383
|
throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
384
384
|
if (!v)
|
|
385
385
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
386
386
|
if (g.isInitialized())
|
|
387
387
|
return null;
|
|
388
|
-
const { createRoutesFromChildren: k, matchRoutes:
|
|
388
|
+
const { createRoutesFromChildren: k, matchRoutes: j, useLocation: T, useNavigationType: h } = v;
|
|
389
389
|
return (u || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && g.init({
|
|
390
390
|
debug: u,
|
|
391
391
|
dsn: e,
|
|
@@ -402,8 +402,8 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
402
402
|
integrations: [
|
|
403
403
|
g.reactRouterV6BrowserTracingIntegration({
|
|
404
404
|
createRoutesFromChildren: k,
|
|
405
|
-
matchRoutes:
|
|
406
|
-
useEffect:
|
|
405
|
+
matchRoutes: j,
|
|
406
|
+
useEffect: S,
|
|
407
407
|
useLocation: T,
|
|
408
408
|
useNavigationType: h
|
|
409
409
|
}),
|
|
@@ -415,7 +415,7 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
415
415
|
tracePropagationTargets: s,
|
|
416
416
|
tracesSampleRate: a || 1
|
|
417
417
|
}), null;
|
|
418
|
-
},
|
|
418
|
+
}, Ke = () => (S(() => {
|
|
419
419
|
if (F)
|
|
420
420
|
return;
|
|
421
421
|
const e = (r) => {
|
|
@@ -427,18 +427,28 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
427
427
|
return window.addEventListener("vite:preloadError", e), () => {
|
|
428
428
|
window.removeEventListener("vite:preloadError", e);
|
|
429
429
|
};
|
|
430
|
-
}, []), null), ne = /* @__PURE__ */ new WeakMap(), Ee = "user",
|
|
431
|
-
const { libraries: s, localStorageKeys: c } = P(
|
|
430
|
+
}, []), null), ne = /* @__PURE__ */ new WeakMap(), Ee = "user", He = ({ Fallback: e, isLogged: r, loginPath: a = "/login", redirect401Path: o = "/login", ...n }) => {
|
|
431
|
+
const { libraries: s, localStorageKeys: c } = P(A), u = n?.reactRouter || s?.reactRouter, l = n?.axios || s?.axios, f = n?.localStorageKey || c?.user || Ee;
|
|
432
432
|
if (!u)
|
|
433
433
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
434
|
-
const [i, m] =
|
|
435
|
-
return
|
|
434
|
+
const [i, m] = Y(null), { useLocation: g, Navigate: v, Outlet: k } = u, j = g(), T = typeof r == "function" ? r() : !!r, h = typeof T == "boolean" ? T : T?.isLogged;
|
|
435
|
+
return S(() => {
|
|
436
436
|
ne.has(l) || (ne.set(l, !0), l.interceptors.response.use(
|
|
437
437
|
(d) => d,
|
|
438
438
|
(d) => (typeof d == "object" && d && "response" in d && d.response && typeof d.response == "object" && "status" in d.response && d.response && typeof d.response == "object" && "status" in d.response && d?.response?.status === 401 && (typeof d == "object" && d && "config" in d && d.config && typeof d.config == "object" && "headers" in d.config && d.config.headers && typeof d.config.headers == "object" && "Authorization" in d.config.headers && d.config.headers.Authorization && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(f)), m(o)), Promise.reject(d))
|
|
439
439
|
));
|
|
440
|
-
}, [l, f, o]), h && !i ? /* @__PURE__ */ C.jsx(ge, { fallback: e, children:
|
|
440
|
+
}, [l, f, o]), h && !i ? /* @__PURE__ */ C.jsx(ge, { fallback: e, children: j.state?.from?.state && j.state?.from?.pathname === a ? /* @__PURE__ */ C.jsx(v, { to: j.state.from.state.from.pathname + j.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ C.jsx(k, {}) }) : /* @__PURE__ */ C.jsx(v, { to: a + j.search, state: { from: j }, replace: !0 });
|
|
441
441
|
}, Re = async () => {
|
|
442
|
+
if ("serviceWorker" in navigator)
|
|
443
|
+
try {
|
|
444
|
+
const e = await navigator.serviceWorker.getRegistrations();
|
|
445
|
+
await Promise.all(e.map((r) => r.unregister()));
|
|
446
|
+
} catch (e) {
|
|
447
|
+
console.error("Failed to unregister service workers:", e);
|
|
448
|
+
}
|
|
449
|
+
}, Be = () => (S(() => {
|
|
450
|
+
Re();
|
|
451
|
+
}, []), null), be = async () => {
|
|
442
452
|
if ("caches" in window)
|
|
443
453
|
try {
|
|
444
454
|
const e = await caches.keys();
|
|
@@ -446,17 +456,25 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
446
456
|
} catch (e) {
|
|
447
457
|
console.error("Failed to clear caches:", e);
|
|
448
458
|
}
|
|
449
|
-
},
|
|
450
|
-
const o = me(null), [n, s] =
|
|
451
|
-
o.current && o.current.postMessage({ type: "SKIP_WAITING" }), a
|
|
459
|
+
}, Xe = ({ autoUpdate: e, renderDialog: r, clearCachesOnReload: a }) => {
|
|
460
|
+
const o = me(null), [n, s] = Y(!1), c = O(() => {
|
|
461
|
+
if (o.current && o.current.postMessage({ type: "SKIP_WAITING" }), a)
|
|
462
|
+
try {
|
|
463
|
+
localStorage.setItem("tracktor_clear_caches", "1");
|
|
464
|
+
} catch {
|
|
465
|
+
}
|
|
466
|
+
window.location.reload();
|
|
452
467
|
}, [a]);
|
|
453
|
-
|
|
454
|
-
|
|
468
|
+
S(() => {
|
|
469
|
+
try {
|
|
470
|
+
localStorage.getItem("tracktor_clear_caches") === "1" && (localStorage.removeItem("tracktor_clear_caches"), be().catch(console.error));
|
|
471
|
+
} catch {
|
|
472
|
+
}
|
|
455
473
|
}, []);
|
|
456
474
|
const u = O(() => {
|
|
457
475
|
window.confirm("A new version is available. The app will reload now.") && c();
|
|
458
476
|
}, [c]);
|
|
459
|
-
return
|
|
477
|
+
return S(() => {
|
|
460
478
|
if (!("serviceWorker" in navigator))
|
|
461
479
|
return;
|
|
462
480
|
let l, f;
|
|
@@ -473,21 +491,21 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
473
491
|
})().catch(console.error), () => {
|
|
474
492
|
l?.removeEventListener("updatefound", m), f && l?.installing && l.installing.removeEventListener("statechange", f);
|
|
475
493
|
};
|
|
476
|
-
}, []),
|
|
494
|
+
}, []), S(() => {
|
|
477
495
|
n && e && c();
|
|
478
|
-
}, [e, n, c]),
|
|
496
|
+
}, [e, n, c]), S(() => {
|
|
479
497
|
n && !e && !r && u();
|
|
480
498
|
}, [r, u, n, e]), n && !e && r ? r(c) : null;
|
|
481
|
-
},
|
|
499
|
+
}, _e = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), Se = (e) => {
|
|
482
500
|
const r = e.split(/[/\\]/).pop() || "";
|
|
483
501
|
return r.substring(0, r.lastIndexOf("."));
|
|
484
|
-
},
|
|
502
|
+
}, Ae = (e) => {
|
|
485
503
|
const o = e.split("/").filter((n) => n.length > 0).map((n) => n.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join("")).join("");
|
|
486
504
|
return o.charAt(0).toLowerCase() + o.slice(1);
|
|
487
|
-
},
|
|
488
|
-
const n =
|
|
505
|
+
}, je = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), Pe = (e, r, a, o) => {
|
|
506
|
+
const n = Ae(r), s = _e(a), c = `${n}${s}`;
|
|
489
507
|
return e && typeof e == "object" && "operationId" in e && o?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
|
|
490
|
-
},
|
|
508
|
+
}, Te = (e, r) => {
|
|
491
509
|
const a = {};
|
|
492
510
|
return e?.forEach((o) => {
|
|
493
511
|
a[o] = {
|
|
@@ -504,8 +522,8 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
504
522
|
}
|
|
505
523
|
};
|
|
506
524
|
}), Object.keys(a).length ? a : void 0;
|
|
507
|
-
},
|
|
508
|
-
const { output: n, useInfiniteIds: s, useQueryIds: c, input: u = "./openapi.json", customAxiosInstancePath: l, overrideApiName: f } = o || {}, i = f ||
|
|
525
|
+
}, Ze = (e) => (Array.isArray(e) ? e : [e]).reduce((a, o) => {
|
|
526
|
+
const { output: n, useInfiniteIds: s, useQueryIds: c, input: u = "./openapi.json", customAxiosInstancePath: l, overrideApiName: f } = o || {}, i = f || je(u), m = l || "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";
|
|
509
527
|
return {
|
|
510
528
|
...a,
|
|
511
529
|
[i]: {
|
|
@@ -516,7 +534,7 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
516
534
|
mode: "tags-split",
|
|
517
535
|
override: {
|
|
518
536
|
...(s?.length || c?.length) && {
|
|
519
|
-
operations:
|
|
537
|
+
operations: Te(s, c)
|
|
520
538
|
},
|
|
521
539
|
header: (g) => [
|
|
522
540
|
"Generated by orval 🍺",
|
|
@@ -524,10 +542,10 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
524
542
|
...g.description ? [g.description] : []
|
|
525
543
|
],
|
|
526
544
|
mutator: {
|
|
527
|
-
name:
|
|
545
|
+
name: Se(m),
|
|
528
546
|
path: m
|
|
529
547
|
},
|
|
530
|
-
operationName: (g, v, k) =>
|
|
548
|
+
operationName: (g, v, k) => Pe(g, v, k, c),
|
|
531
549
|
query: {
|
|
532
550
|
useQuery: !0
|
|
533
551
|
}
|
|
@@ -538,20 +556,20 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
538
556
|
}
|
|
539
557
|
}
|
|
540
558
|
};
|
|
541
|
-
}, {}),
|
|
559
|
+
}, {}), ke = (e) => e && typeof e == "function", Ce = (e) => e && typeof e == "function", et = ({
|
|
542
560
|
children: e,
|
|
543
561
|
defaultQueriesOptions: r,
|
|
544
562
|
defaultMutationsOptions: a,
|
|
545
563
|
...o
|
|
546
564
|
}) => {
|
|
547
|
-
const { libraries: n } = P(
|
|
565
|
+
const { libraries: n } = P(A), s = o?.QueryClient || n?.reactQuery?.QueryClient, c = o?.QueryClientProvider || n?.reactQuery?.QueryClientProvider;
|
|
548
566
|
if (!s)
|
|
549
567
|
throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
550
568
|
if (!c)
|
|
551
569
|
throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
552
|
-
if (!
|
|
570
|
+
if (!ke(c))
|
|
553
571
|
throw new Error("Provided QueryClientProvider dependencies are not valid.");
|
|
554
|
-
if (!
|
|
572
|
+
if (!Ce(s))
|
|
555
573
|
throw new Error("Provided QueryClient dependencies are not valid.");
|
|
556
574
|
const u = new s({
|
|
557
575
|
defaultOptions: {
|
|
@@ -567,42 +585,42 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
567
585
|
}
|
|
568
586
|
});
|
|
569
587
|
return /* @__PURE__ */ C.jsx(c, { client: u, children: e });
|
|
570
|
-
},
|
|
588
|
+
}, Ie = ({ library: e, date: r, format: a = "ll" }) => e(r).format(a), xe = (e, r) => {
|
|
571
589
|
const { fractionDigits: a = 0, metric: o = "km", spacingBetween: n = !0 } = r || {}, s = Number(e), c = n ? " " : "";
|
|
572
590
|
return Number.isNaN(s) ? `0${c}${o}` : `${s.toFixed(a)}${c}${o}`;
|
|
573
|
-
},
|
|
591
|
+
}, Oe = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((a) => a.length > 0 ? a.charAt(0).toUpperCase() + a.slice(1) : a).join(" "), Le = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Ne = ({ path: e, size: r, apiURL: a }) => {
|
|
574
592
|
if (!e)
|
|
575
593
|
return "";
|
|
576
|
-
const o =
|
|
594
|
+
const o = Le(e), n = `${a}${o}`, s = n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
|
|
577
595
|
return typeof r == "number" && s ? `${n.replace("/files", `/thumbs/${r}`)}` : n;
|
|
578
|
-
},
|
|
579
|
-
const { apiURL: r, libraries: a } = P(
|
|
596
|
+
}, tt = (e) => {
|
|
597
|
+
const { apiURL: r, libraries: a } = P(A), o = e?.dayjs || a?.dayjs;
|
|
580
598
|
return {
|
|
581
599
|
dateAdapter: (c, u) => {
|
|
582
600
|
if (!o)
|
|
583
601
|
throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
584
|
-
return
|
|
602
|
+
return Ie({
|
|
585
603
|
date: c,
|
|
586
604
|
format: u,
|
|
587
605
|
library: o
|
|
588
606
|
});
|
|
589
607
|
},
|
|
590
|
-
distanceAdapter:
|
|
608
|
+
distanceAdapter: xe,
|
|
591
609
|
filePathAdapter: (c, u) => {
|
|
592
610
|
if (!r)
|
|
593
611
|
throw new Error(
|
|
594
612
|
"API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
|
|
595
613
|
);
|
|
596
|
-
return typeof c == "string" && /^https?:\/\//.test(c) ? c :
|
|
614
|
+
return typeof c == "string" && /^https?:\/\//.test(c) ? c : Ne({
|
|
597
615
|
apiURL: r,
|
|
598
616
|
path: c,
|
|
599
617
|
size: u
|
|
600
618
|
});
|
|
601
619
|
},
|
|
602
|
-
worksiteNameAdapter:
|
|
620
|
+
worksiteNameAdapter: Oe
|
|
603
621
|
};
|
|
604
|
-
},
|
|
605
|
-
const { libraries: r, localStorageKeys: a } = P(
|
|
622
|
+
}, rt = (e) => {
|
|
623
|
+
const { libraries: r, localStorageKeys: a } = P(A), o = e?.axios || r?.axios, n = e?.localStorageKey || a?.user || "user";
|
|
606
624
|
if (!o)
|
|
607
625
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
|
|
608
626
|
const s = O(
|
|
@@ -613,7 +631,7 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
613
631
|
), c = () => {
|
|
614
632
|
o.defaults.headers.common.Authorization = null;
|
|
615
633
|
};
|
|
616
|
-
return
|
|
634
|
+
return S(() => {
|
|
617
635
|
if (F)
|
|
618
636
|
return;
|
|
619
637
|
const u = ({ newValue: l, key: f }) => {
|
|
@@ -632,21 +650,21 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
632
650
|
clearAuthenticationToken: c,
|
|
633
651
|
setAuthenticationToken: s
|
|
634
652
|
};
|
|
635
|
-
},
|
|
636
|
-
const [a, o] =
|
|
653
|
+
}, W = (e, r) => r === "short" ? e.split("-")[0] : e, nt = (e, r = "full") => {
|
|
654
|
+
const [a, o] = Y(() => {
|
|
637
655
|
const n = e?.language || navigator.language;
|
|
638
|
-
return e && "isInitialized" in e && e.isInitialized,
|
|
656
|
+
return e && "isInitialized" in e && e.isInitialized, W(n, r);
|
|
639
657
|
});
|
|
640
|
-
return
|
|
641
|
-
e && "isInitialized" in e && e.isInitialized && e.language && o(
|
|
658
|
+
return S(() => {
|
|
659
|
+
e && "isInitialized" in e && e.isInitialized && e.language && o(W(e.language, r));
|
|
642
660
|
const n = (s) => {
|
|
643
|
-
o(
|
|
661
|
+
o(W(s, r));
|
|
644
662
|
};
|
|
645
663
|
return e?.on?.("languageChanged", n), () => {
|
|
646
664
|
e?.off?.("languageChanged", n);
|
|
647
665
|
};
|
|
648
666
|
}, [e, r]), a;
|
|
649
|
-
},
|
|
667
|
+
}, Fe = "tracktor.filter", $e = {
|
|
650
668
|
getFilter: () => {
|
|
651
669
|
},
|
|
652
670
|
getFilters: () => ({}),
|
|
@@ -660,7 +678,7 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
660
678
|
} catch {
|
|
661
679
|
return e;
|
|
662
680
|
}
|
|
663
|
-
}, ae = (e, r, a) => `${a}_${e}=>${r}`,
|
|
681
|
+
}, ae = (e, r, a) => `${a}_${e}=>${r}`, De = (e) => e.reduce((r, a) => {
|
|
664
682
|
const o = localStorage.getItem(a);
|
|
665
683
|
if (o)
|
|
666
684
|
try {
|
|
@@ -669,11 +687,11 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
669
687
|
} catch {
|
|
670
688
|
}
|
|
671
689
|
return r;
|
|
672
|
-
}, {}),
|
|
673
|
-
const { libraries: r, localStorageKeys: a } = P(
|
|
674
|
-
}], [u, l] =
|
|
690
|
+
}, {}), ot = (e) => {
|
|
691
|
+
const { libraries: r, localStorageKeys: a } = P(A), o = e?.reactRouter || r?.reactRouter, { pathname: n } = o?.useLocation?.() ?? { pathname: "/" }, [s, c] = o?.useSearchParams?.() ?? [new URLSearchParams(), () => {
|
|
692
|
+
}], [u, l] = Y({}), f = a?.filter || Fe, i = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, m = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
|
|
675
693
|
if (F)
|
|
676
|
-
return
|
|
694
|
+
return $e;
|
|
677
695
|
if (!o)
|
|
678
696
|
throw new Error(
|
|
679
697
|
"React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter."
|
|
@@ -714,7 +732,7 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
714
732
|
return d;
|
|
715
733
|
},
|
|
716
734
|
getFilters: () => {
|
|
717
|
-
const h = m ?
|
|
735
|
+
const h = m ? De(g()) : {};
|
|
718
736
|
if (i) {
|
|
719
737
|
const d = Array.from(s.entries()).reduce((b, [R, _]) => (b[R] = oe(_), b), {});
|
|
720
738
|
return {
|
|
@@ -737,7 +755,7 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
737
755
|
},
|
|
738
756
|
setFilter: v
|
|
739
757
|
};
|
|
740
|
-
},
|
|
758
|
+
}, at = ({
|
|
741
759
|
data: e,
|
|
742
760
|
fetchNextPage: r,
|
|
743
761
|
isFetchingNextPage: a,
|
|
@@ -760,8 +778,8 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
760
778
|
loadingVariant: o ? "skeleton" : "linear-progress",
|
|
761
779
|
rows: u
|
|
762
780
|
};
|
|
763
|
-
},
|
|
764
|
-
const { libraries: r } = P(
|
|
781
|
+
}, it = (e) => {
|
|
782
|
+
const { libraries: r } = P(A), a = e?.i18 || r?.i18, o = e?.i18?.translateFunction || r?.i18?.translateFunction, n = a?.i18next?.t || o || ((f) => f), { unknownErrorTranslationKey: s = "error.unknownError" } = e || {}, c = n(s), u = O(
|
|
765
783
|
(f) => {
|
|
766
784
|
if (f && typeof f == "object" && "response" in f) {
|
|
767
785
|
const { response: i } = f || {};
|
|
@@ -790,27 +808,28 @@ const ze = ({ IMaskMixin: e, ...r }) => {
|
|
|
790
808
|
}, []), printError: u };
|
|
791
809
|
};
|
|
792
810
|
export {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
Ie as
|
|
808
|
-
|
|
809
|
-
Ze as
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
811
|
+
Ve as GTMSendPageView,
|
|
812
|
+
Me as InitializeAxiosConfig,
|
|
813
|
+
Ge as InitializeDaysJSConfig,
|
|
814
|
+
Je as InitializeI18nConfig,
|
|
815
|
+
qe as InitializeSentryConfig,
|
|
816
|
+
A as InjectDependenciesContext,
|
|
817
|
+
Qe as InjectDependenciesProvider,
|
|
818
|
+
Ue as MaskTextField,
|
|
819
|
+
Ke as PreloadErrorHandler,
|
|
820
|
+
et as QueryClientProviderWithConfig,
|
|
821
|
+
He as RequireAuth,
|
|
822
|
+
Be as ServiceWorkerCleaner,
|
|
823
|
+
Xe as UpdateNotifier,
|
|
824
|
+
ze as axiosCustomInstance,
|
|
825
|
+
Ie as dateAdapter,
|
|
826
|
+
xe as distanceAdapter,
|
|
827
|
+
Ze as getOrvalConfig,
|
|
828
|
+
tt as useAdapter,
|
|
829
|
+
rt as useAuth,
|
|
830
|
+
nt as useCurrentLanguage,
|
|
831
|
+
ot as useFilters,
|
|
832
|
+
at as useInfiniteDataGrid,
|
|
833
|
+
it as useResponseError,
|
|
834
|
+
Oe as worksiteNameAdapter
|
|
816
835
|
};
|
package/dist/main.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(m,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],O):(m=typeof globalThis<"u"?globalThis:m||self,O(m["@tracktor/shared-module"]={},m.axios,m.React))})(this,(function(m,O,f){"use strict";const se=(e,r)=>{const a=O.CancelToken.source(),o=O({...e,...r,cancelToken:a.token}).then(({data:n})=>n);return o.cancel=()=>{a.cancel("Query was cancelled")},o};var D={exports:{}},N={};var G;function ie(){if(G)return N;G=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function a(o,n,i){var c=null;if(i!==void 0&&(c=""+i),n.key!==void 0&&(c=""+n.key),"key"in n){i={};for(var u in n)u!=="key"&&(i[u]=n[u])}else i=n;return n=i.ref,{$$typeof:e,type:o,key:c,ref:n!==void 0?n:null,props:i}}return N.Fragment=r,N.jsx=a,N.jsxs=a,N}var L={};var J;function ce(){return J||(J=1,process.env.NODE_ENV!=="production"&&(function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Be?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case k:return"Fragment";case d:return"Profiler";case v:return"StrictMode";case I:return"Suspense";case Je:return"SuspenseList";case He:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case j:return"Portal";case S:return t.displayName||"Context";case _:return(t._context.displayName||"Context")+".Consumer";case A:var g=t.render;return t=t.displayName,t||(t=g.displayName||g.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Ke:return g=t.displayName||null,g!==null?g:e(t.type)||"Memo";case z:g=t._payload,t=t._init;try{return e(t(g))}catch{}}return null}function r(t){return""+t}function a(t){try{r(t);var g=!1}catch{g=!0}if(g){g=console;var E=g.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return E.call(g,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),r(t)}}function o(t){if(t===k)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===z)return"<...>";try{var g=e(t);return g?"<"+g+">":"<...>"}catch{return"<...>"}}function n(){var t=U.A;return t===null?null:t.getOwner()}function i(){return Error("react-stack-top-frame")}function c(t){if(ee.call(t,"key")){var g=Object.getOwnPropertyDescriptor(t,"key").get;if(g&&g.isReactWarning)return!1}return t.key!==void 0}function u(t,g){function E(){te||(te=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",g))}E.isReactWarning=!0,Object.defineProperty(t,"key",{get:E,configurable:!0})}function l(){var t=e(this.type);return re[t]||(re[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function p(t,g,E,b,Y,Q){var R=E.ref;return t={$$typeof:T,type:t,key:g,props:E,_owner:b},(R!==void 0?R:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:l}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function s(t,g,E,b,Y,Q){var R=g.children;if(R!==void 0)if(b)if(Xe(R)){for(b=0;b<R.length;b++)y(R[b]);Object.freeze&&Object.freeze(R)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else y(R);if(ee.call(g,"key")){R=e(t);var x=Object.keys(g).filter(function(Ze){return Ze!=="key"});b=0<x.length?"{key: someKey, "+x.join(": ..., ")+": ...}":"{key: someKey}",ae[R+b]||(x=0<x.length?"{"+x.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,b,R,x,R),ae[R+b]=!0)}if(R=null,E!==void 0&&(a(E),R=""+E),c(g)&&(a(g.key),R=""+g.key),"key"in g){E={};for(var V in g)V!=="key"&&(E[V]=g[V])}else E=g;return R&&u(E,typeof t=="function"?t.displayName||t.name||"Unknown":t),f(t,R,E,n(),z,Q)}function y(t){m(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===W&&(t._payload.status==="fulfilled"?m(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function m(t){return typeof t=="object"&&t!==null&&t.$$typeof===k}var w=p,k=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),_=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),Ve=Symbol.for("react.suspense_list"),Ge=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),Je=Symbol.for("react.activity"),Ke=Symbol.for("react.client.reference"),U=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=Object.prototype.hasOwnProperty,He=Array.isArray,M=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(t){return t()}};var te,re={},ne=w.react_stack_bottom_frame.bind(w,i)(),oe=M(o(i)),ae={};L.Fragment=P,L.jsx=function(t,g,E){var b=1e4>U.recentlyCreatedOwnerStacks++;return s(t,g,E,!1,b?Error("react-stack-top-frame"):ne,b?M(o(t)):oe)},L.jsxs=function(t,g,E){var b=1e4>U.recentlyCreatedOwnerStacks++;return s(t,g,E,!0,b?Error("react-stack-top-frame"):ne,b?M(o(t)):oe)}})()),L}var K;function le(){return K||(K=1,process.env.NODE_ENV==="production"?D.exports=ie():D.exports=ce()),D.exports}var T=le();const ue=({IMaskMixin:e,...r})=>{const a=p.useMemo(()=>e(({TextField:o,...n})=>T.jsx(o,{...n})),[e]);return T.jsx(a,{...r})},C=p.createContext({}),de=({children:e,apiURL:r,libraries:a,localStorageKeys:o})=>{const n=p.useMemo(()=>({apiURL:r,libraries:a,localStorageKeys:o}),[r,a,o]);return T.jsx(C.Provider,{value:n,children:e})},fe=({data:e,...r})=>{const{libraries:a}=p.useContext(C),o=r?.reactRouter||a?.reactRouter,n=r?.gtm||a?.gtm;if(!o)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!n)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:i}=n,{useLocation:c,Outlet:u}=o,{pathname:l}=c(),{sendEvent:f}=i();return p.useEffect(()=>{f({event:"pageView",pathname:l,...e})},[e,l,f]),T.jsx(u,{})},F=(()=>{try{return typeof global=="object"&&global!==null&&("HermesInternal"in global||"__fbBatchedBridge"in global||"__metro"in global)||typeof window>"u"&&typeof global<"u"?!0:typeof navigator<"u"&&navigator.userAgent?/react.native|ReactNative/i.test(navigator.userAgent):!1}catch{return!1}})(),pe="user",ge=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:a="application/json",...o})=>{const{apiURL:n=o.apiURL,libraries:i,localStorageKeys:c}=p.useContext(C),u=o?.userLocalStorageKey||c?.user||pe,l=o?.axios||i?.axios;if(!l)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!l?.defaults||F)return null;if(typeof window<"u"&&window.localStorage){const f=localStorage.getItem(u),s=f?JSON.parse(f):null,y=s?.[e]?s[e]:null,m=s?.[r]?s[r]:null,w=f?`${y} ${m}`:null;w&&(l.defaults.headers.common.Authorization=w)}return l.defaults.baseURL=n,l.defaults.headers.post["Content-Type"]=a,null},me=({language:e,...r})=>{const{libraries:a}=p.useContext(C),o=r?.dayjs||a?.dayjs,n=r?.plugin||a?.dayjsPlugin;if(!o)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return p.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";n&&n.forEach(u=>{u&&o.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),o.locale(c)})().then()},[o,n,e]),null},he=({debug:e,resources:r,...a})=>{const{libraries:o}=p.useContext(C),n=a?.i18||o?.i18,{i18next:i,initReactI18next:c,languageDetector:u}=n||{};if(F)return null;if(!n)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return i?.isInitialized||(i.use(u).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:r,returnNull:!1}).then(()=>{document.documentElement.lang!==i.resolvedLanguage&&i.resolvedLanguage&&document.documentElement.setAttribute("lang",i.resolvedLanguage)}),i.on("languageChanged",l=>{document.documentElement.setAttribute("lang",l)})),null},ye=({dsn:e,integrations:r,tracesSampleRate:a,replaysSessionSampleRate:o,replaysOnErrorSampleRate:n,tracePropagationTargets:i,ignoreErrors:c,debug:u,environment:l,release:f,...s})=>{const{libraries:y}=p.useContext(C),m=s?.sentry||y?.sentry,w=s?.reactRouter||y?.reactRouter;if(!m)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!w)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(m.isInitialized())return null;const{createRoutesFromChildren:k,matchRoutes:j,useLocation:P,useNavigationType:v}=w;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&m.init({debug:u,dsn:e,environment:l||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[m.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:k,matchRoutes:j,useEffect:p.useEffect,useLocation:P,useNavigationType:v}),...r||[]],release:f,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:o||.1,tracePropagationTargets:i,tracesSampleRate:a||1}),null},ve=()=>(p.useEffect(()=>{if(F)return;const e=r=>{try{r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),H=new WeakMap,Ee="user",we=({Fallback:e,isLogged:r,loginPath:a="/login",redirect401Path:o="/login",...n})=>{const{libraries:i,localStorageKeys:c}=p.useContext(C),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,f=n?.localStorageKey||c?.user||Ee;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[s,y]=p.useState(null),{useLocation:m,Navigate:w,Outlet:k}=u,j=m(),P=typeof r=="function"?r():!!r,v=typeof P=="boolean"?P:P?.isLogged;return p.useEffect(()=>{H.has(l)||(H.set(l,!0),l.interceptors.response.use(d=>d,d=>(typeof d=="object"&&d&&"response"in d&&d.response&&typeof d.response=="object"&&"status"in d.response&&d.response&&typeof d.response=="object"&&"status"in d.response&&d?.response?.status===401&&(typeof d=="object"&&d&&"config"in d&&d.config&&typeof d.config=="object"&&"headers"in d.config&&d.config.headers&&typeof d.config.headers=="object"&&"Authorization"in d.config.headers&&d.config.headers.Authorization&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(f)),y(o)),Promise.reject(d))))},[l,f,o]),v&&!s?T.jsx(p.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===a?T.jsx(w,{to:j.state.from.state.from.pathname+j.state.from.state.from.search,replace:!0}):T.jsx(k,{})}):T.jsx(w,{to:a+j.search,state:{from:j},replace:!0})},be=async()=>{if("caches"in window)try{const e=await caches.keys();await Promise.all(e.map(r=>caches.delete(r)))}catch(e){console.error("Failed to clear caches:",e)}},Re=({autoUpdate:e,renderDialog:r,clearCachesOnReload:a})=>{const o=p.useRef(null),[n,i]=p.useState(!1),c=p.useCallback(()=>{o.current&&o.current.postMessage({type:"SKIP_WAITING"}),a&&localStorage.setItem("tracktor_clear_caches","1"),window.location.reload()},[a]);p.useEffect(()=>{localStorage.getItem("tracktor_clear_caches")==="1"&&(localStorage.removeItem("tracktor_clear_caches"),be().catch(console.error))},[]);const u=p.useCallback(()=>{window.confirm("A new version is available. The app will reload now.")&&c()},[c]);return p.useEffect(()=>{if(!("serviceWorker"in navigator))return;let l,f;const s=m=>{m&&navigator.serviceWorker.controller&&(o.current=m,i(!0))},y=()=>{const m=l?.installing;m&&(f=()=>{m.state==="installed"&&s(m)},m.addEventListener("statechange",f))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(s(l.waiting),l.addEventListener("updatefound",y))})().catch(console.error),()=>{l?.removeEventListener("updatefound",y),f&&l?.installing&&l.installing.removeEventListener("statechange",f)}},[]),p.useEffect(()=>{n&&e&&c()},[e,n,c]),p.useEffect(()=>{n&&!e&&!r&&u()},[r,u,n,e]),n&&!e&&r?r(c):null},_e=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Se=e=>{const r=e.split(/[/\\]/).pop()||"";return r.substring(0,r.lastIndexOf("."))},Ae=e=>{const o=e.split("/").filter(n=>n.length>0).map(n=>n.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join("")).join("");return o.charAt(0).toLowerCase()+o.slice(1)},Ce=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),je=(e,r,a,o)=>{const n=Ae(r),i=_e(a),c=`${n}${i}`;return e&&typeof e=="object"&&"operationId"in e&&o?.includes(String(e.operationId))?`${c}AsQuery`:c},Pe=(e,r)=>{const a={};return e?.forEach(o=>{a[o]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),r?.filter(o=>!a[o]).forEach(o=>{a[o]={query:{useQuery:!0}}}),Object.keys(a).length?a:void 0},Te=e=>(Array.isArray(e)?e:[e]).reduce((a,o)=>{const{output:n,useInfiniteIds:i,useQueryIds:c,input:u="./openapi.json",customAxiosInstancePath:l,overrideApiName:f}=o||{},s=f||Ce(u),y=l||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...a,[s]:{input:u,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(i?.length||c?.length)&&{operations:Pe(i,c)},header:m=>["Generated by orval 🍺",...m.title?[m.title]:[],...m.description?[m.description]:[]],mutator:{name:Se(y),path:y},operationName:(m,w,k)=>je(m,w,k,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${s}/model`,target:n?.target||`src/api/${s}/services/api.ts`,...n}}}},{}),ke=e=>e&&typeof e=="function",Ie=e=>e&&typeof e=="function",Oe=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:a,...o})=>{const{libraries:n}=p.useContext(C),i=o?.QueryClient||n?.reactQuery?.QueryClient,c=o?.QueryClientProvider||n?.reactQuery?.QueryClientProvider;if(!i)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!c)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!ke(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ie(i))throw new Error("Provided QueryClient dependencies are not valid.");const u=new i({defaultOptions:{mutations:{...a},queries:{getNextPageParam:(l,f,s)=>l.length+(s||0),refetchOnWindowFocus:!1,retry:3,...r}}});return T.jsx(c,{client:u,children:e})},B=({library:e,date:r,format:a="ll"})=>e(r).format(a),X=(e,r)=>{const{fractionDigits:a=0,metric:o="km",spacingBetween:n=!0}=r||{},i=Number(e),c=n?" ":"";return Number.isNaN(i)?`0${c}${o}`:`${i.toFixed(a)}${c}${o}`},Z=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(a=>a.length>0?a.charAt(0).toUpperCase()+a.slice(1):a).join(" "),xe=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Ne=({path:e,size:r,apiURL:a})=>{if(!e)return"";const o=xe(e),n=`${a}${o}`,i=n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof r=="number"&&i?`${n.replace("/files",`/thumbs/${r}`)}`:n},Le=e=>{const{apiURL:r,libraries:a}=p.useContext(C),o=e?.dayjs||a?.dayjs;return{dateAdapter:(c,u)=>{if(!o)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return B({date:c,format:u,library:o})},distanceAdapter:X,filePathAdapter:(c,u)=>{if(!r)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return typeof c=="string"&&/^https?:\/\//.test(c)?c:Ne({apiURL:r,path:c,size:u})},worksiteNameAdapter:Z}},Fe=e=>{const{libraries:r,localStorageKeys:a}=p.useContext(C),o=e?.axios||r?.axios,n=e?.localStorageKey||a?.user||"user";if(!o)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const i=p.useCallback(({tokenType:u,accessToken:l})=>{o.defaults.headers.common.Authorization=`${u} ${l}`},[o.defaults.headers.common]),c=()=>{o.defaults.headers.common.Authorization=null};return p.useEffect(()=>{if(F)return;const u=({newValue:l,key:f})=>{if(f===n&&l)try{const{accessToken:s,tokenType:y}=JSON.parse(l);i({accessToken:s,tokenType:y})}catch(s){console.error("Failed to parse newValue from localStorage:",s)}};return window.addEventListener("storage",u),()=>{window.removeEventListener("storage",u)}},[n,i]),{clearAuthenticationToken:c,setAuthenticationToken:i}},Y=(e,r)=>r==="short"?e.split("-")[0]:e,De=(e,r="full")=>{const[a,o]=p.useState(()=>{const n=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,Y(n,r)});return p.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&o(Y(e.language,r));const n=i=>{o(Y(i,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),a},Ye="tracktor.filter",ze={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},q=e=>{try{return JSON.parse(e)}catch{return e}},$=(e,r,a)=>`${a}_${e}=>${r}`,We=e=>e.reduce((r,a)=>{const o=localStorage.getItem(a);if(o)try{const n=JSON.parse(o),i=Object.keys(n)?.[0];i&&(r[i]=Object.values(n)?.[0])}catch{}return r},{}),Ue=e=>{const{libraries:r,localStorageKeys:a}=p.useContext(C),o=e?.reactRouter||r?.reactRouter,{pathname:n}=o?.useLocation?.()??{pathname:"/"},[i,c]=o?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,l]=p.useState({}),f=a?.filter||Ye,s=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,y=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(F)return ze;if(!o)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const m=()=>Object.keys(localStorage).filter(v=>v.startsWith(f)&&v.endsWith(e?.pathname||n)),w=(v,d,S=!0)=>{const _=$(v,e?.pathname||n,f);if(!d||Array.isArray(d)&&!d.length){s?(i.delete(v),c(i)):l(A=>{const I={...A};return delete I[v],I}),y&&localStorage.removeItem(_);return}y&&S&&d&&localStorage.setItem(_,JSON.stringify({...i,[v]:d})),s&&d?(i.set(v,JSON.stringify(d)),c(i)):!s&&d&&l(A=>({...A,[v]:d}))};return{getFilter:(v,d)=>{if(s){const S=i.get(v);if(S)return q(S)}else{const S=u[v];if(S!==void 0)return S}if(y){const S=$(v,e?.pathname||n,f),_=localStorage.getItem(S);if(_)try{const A=JSON.parse(_)[v];return!s&&A!==void 0&&l(I=>({...I,[v]:A})),A}catch{}}return d},getFilters:()=>{const v=y?We(m()):{};if(s){const d=Array.from(i.entries()).reduce((S,[_,A])=>(S[_]=q(A),S),{});return{...v,...d}}return{...v,...u}},handleFilter:(v,d)=>(S,_)=>{if(_||Array.isArray(_)&&_.length===0){const A=d||"value",I=typeof _=="object"&&A in _?_[A]:_;w(v,I);return}w(v,void 0)},setFilter:w}},Me=({data:e,fetchNextPage:r,isFetchingNextPage:a,isInitialLoading:o,isLoading:n,enabled:i=!0})=>{const c=p.useCallback(async l=>{a||!i||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[i,r,a]),u=p.useMemo(()=>{if(e)return e.pages.reduce((l,f)=>[...l,...f],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:a||n,loadingVariant:o?"skeleton":"linear-progress",rows:u}},Qe=e=>{const{libraries:r}=p.useContext(C),a=e?.i18||r?.i18,o=e?.i18?.translateFunction||r?.i18?.translateFunction,n=a?.i18next?.t||o||(f=>f),{unknownErrorTranslationKey:i="error.unknownError"}=e||{},c=n(i),u=p.useCallback(f=>{if(f&&typeof f=="object"&&"response"in f){const{response:s}=f||{};if(s&&typeof s=="object"&&"reason"in s&&s.reason)return String(s.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"reason"in s.data&&s.data.reason)return String(s.data.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"message"in s.data&&s.data.message)return String(s.data.message);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"detail"in s.data){const{detail:y}=s.data;if(Array.isArray(y)&&y.length>0&&typeof y[0]=="object"&&y[0]!==null&&"msg"in y[0]){const{msg:m}=y[0];if(typeof m=="string")return String(m)}}}return f instanceof Error?f.message:c},[c]);return{getErrorCode:p.useCallback(f=>{const{response:s}=f||{};return s?.error_code?String(s?.error_code):s?.data?.error_code?String(s?.data?.error_code):s?.error_code?String(s?.error_code):s?.data?.error_code?String(s.data.error_code):"unknown_error_code"},[]),printError:u}};h.GTMSendPageView=fe,h.InitializeAxiosConfig=ge,h.InitializeDaysJSConfig=me,h.InitializeI18nConfig=he,h.InitializeSentryConfig=ye,h.InjectDependenciesContext=C,h.InjectDependenciesProvider=de,h.MaskTextField=ue,h.PreloadErrorHandler=ve,h.QueryClientProviderWithConfig=Oe,h.RequireAuth=we,h.UpdateNotifier=Re,h.axiosCustomInstance=se,h.dateAdapter=B,h.distanceAdapter=X,h.getOrvalConfig=Te,h.useAdapter=Le,h.useAuth=Fe,h.useCurrentLanguage=De,h.useFilters=Ue,h.useInfiniteDataGrid=Me,h.useResponseError=Qe,h.worksiteNameAdapter=Z,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
<%s key={someKey} {...props} />`,b,R,x,R),ae[R+b]=!0)}if(R=null,E!==void 0&&(a(E),R=""+E),c(g)&&(a(g.key),R=""+g.key),"key"in g){E={};for(var V in g)V!=="key"&&(E[V]=g[V])}else E=g;return R&&u(E,typeof t=="function"?t.displayName||t.name||"Unknown":t),p(t,R,E,n(),Y,Q)}function y(t){h(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===z&&(t._payload.status==="fulfilled"?h(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function h(t){return typeof t=="object"&&t!==null&&t.$$typeof===T}var w=f,T=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),S=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),Je=Symbol.for("react.suspense_list"),Ke=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),He=Symbol.for("react.activity"),Be=Symbol.for("react.client.reference"),U=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=Object.prototype.hasOwnProperty,Xe=Array.isArray,M=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(t){return t()}};var te,re={},ne=w.react_stack_bottom_frame.bind(w,i)(),oe=M(o(i)),ae={};L.Fragment=k,L.jsx=function(t,g,E){var b=1e4>U.recentlyCreatedOwnerStacks++;return s(t,g,E,!1,b?Error("react-stack-top-frame"):ne,b?M(o(t)):oe)},L.jsxs=function(t,g,E){var b=1e4>U.recentlyCreatedOwnerStacks++;return s(t,g,E,!0,b?Error("react-stack-top-frame"):ne,b?M(o(t)):oe)}})()),L}var K;function le(){return K||(K=1,process.env.NODE_ENV==="production"?D.exports=ie():D.exports=ce()),D.exports}var P=le();const ue=({IMaskMixin:e,...r})=>{const a=f.useMemo(()=>e(({TextField:o,...n})=>P.jsx(o,{...n})),[e]);return P.jsx(a,{...r})},C=f.createContext({}),de=({children:e,apiURL:r,libraries:a,localStorageKeys:o})=>{const n=f.useMemo(()=>({apiURL:r,libraries:a,localStorageKeys:o}),[r,a,o]);return P.jsx(C.Provider,{value:n,children:e})},fe=({data:e,...r})=>{const{libraries:a}=f.useContext(C),o=r?.reactRouter||a?.reactRouter,n=r?.gtm||a?.gtm;if(!o)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!n)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:i}=n,{useLocation:c,Outlet:u}=o,{pathname:l}=c(),{sendEvent:p}=i();return f.useEffect(()=>{p({event:"pageView",pathname:l,...e})},[e,l,p]),P.jsx(u,{})},F=(()=>{try{return typeof global=="object"&&global!==null&&("HermesInternal"in global||"__fbBatchedBridge"in global||"__metro"in global)||typeof window>"u"&&typeof global<"u"?!0:typeof navigator<"u"&&navigator.userAgent?/react.native|ReactNative/i.test(navigator.userAgent):!1}catch{return!1}})(),pe="user",ge=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:a="application/json",...o})=>{const{apiURL:n=o.apiURL,libraries:i,localStorageKeys:c}=f.useContext(C),u=o?.userLocalStorageKey||c?.user||pe,l=o?.axios||i?.axios;if(!l)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!l?.defaults||F)return null;if(typeof window<"u"&&window.localStorage){const p=localStorage.getItem(u),s=p?JSON.parse(p):null,y=s?.[e]?s[e]:null,h=s?.[r]?s[r]:null,w=p?`${y} ${h}`:null;w&&(l.defaults.headers.common.Authorization=w)}return l.defaults.baseURL=n,l.defaults.headers.post["Content-Type"]=a,null},me=({language:e,...r})=>{const{libraries:a}=f.useContext(C),o=r?.dayjs||a?.dayjs,n=r?.plugin||a?.dayjsPlugin;if(!o)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return f.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";n&&n.forEach(u=>{u&&o.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),o.locale(c)})().then()},[o,n,e]),null},he=({debug:e,resources:r,...a})=>{const{libraries:o}=f.useContext(C),n=a?.i18||o?.i18,{i18next:i,initReactI18next:c,languageDetector:u}=n||{};if(F)return null;if(!n)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return i?.isInitialized||(i.use(u).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:r,returnNull:!1}).then(()=>{document.documentElement.lang!==i.resolvedLanguage&&i.resolvedLanguage&&document.documentElement.setAttribute("lang",i.resolvedLanguage)}),i.on("languageChanged",l=>{document.documentElement.setAttribute("lang",l)})),null},ye=({dsn:e,integrations:r,tracesSampleRate:a,replaysSessionSampleRate:o,replaysOnErrorSampleRate:n,tracePropagationTargets:i,ignoreErrors:c,debug:u,environment:l,release:p,...s})=>{const{libraries:y}=f.useContext(C),h=s?.sentry||y?.sentry,w=s?.reactRouter||y?.reactRouter;if(!h)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!w)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(h.isInitialized())return null;const{createRoutesFromChildren:T,matchRoutes:j,useLocation:k,useNavigationType:v}=w;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&h.init({debug:u,dsn:e,environment:l||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[h.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:T,matchRoutes:j,useEffect:f.useEffect,useLocation:k,useNavigationType:v}),...r||[]],release:p,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:o||.1,tracePropagationTargets:i,tracesSampleRate:a||1}),null},ve=()=>(f.useEffect(()=>{if(F)return;const e=r=>{try{r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),H=new WeakMap,Ee="user",we=({Fallback:e,isLogged:r,loginPath:a="/login",redirect401Path:o="/login",...n})=>{const{libraries:i,localStorageKeys:c}=f.useContext(C),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,p=n?.localStorageKey||c?.user||Ee;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[s,y]=f.useState(null),{useLocation:h,Navigate:w,Outlet:T}=u,j=h(),k=typeof r=="function"?r():!!r,v=typeof k=="boolean"?k:k?.isLogged;return f.useEffect(()=>{H.has(l)||(H.set(l,!0),l.interceptors.response.use(d=>d,d=>(typeof d=="object"&&d&&"response"in d&&d.response&&typeof d.response=="object"&&"status"in d.response&&d.response&&typeof d.response=="object"&&"status"in d.response&&d?.response?.status===401&&(typeof d=="object"&&d&&"config"in d&&d.config&&typeof d.config=="object"&&"headers"in d.config&&d.config.headers&&typeof d.config.headers=="object"&&"Authorization"in d.config.headers&&d.config.headers.Authorization&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(p)),y(o)),Promise.reject(d))))},[l,p,o]),v&&!s?P.jsx(f.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===a?P.jsx(w,{to:j.state.from.state.from.pathname+j.state.from.state.from.search,replace:!0}):P.jsx(T,{})}):P.jsx(w,{to:a+j.search,state:{from:j},replace:!0})},be=async()=>{if("serviceWorker"in navigator)try{const e=await navigator.serviceWorker.getRegistrations();await Promise.all(e.map(r=>r.unregister()))}catch(e){console.error("Failed to unregister service workers:",e)}},Re=()=>(f.useEffect(()=>{be()},[]),null),Se=async()=>{if("caches"in window)try{const e=await caches.keys();await Promise.all(e.map(r=>caches.delete(r)))}catch(e){console.error("Failed to clear caches:",e)}},_e=({autoUpdate:e,renderDialog:r,clearCachesOnReload:a})=>{const o=f.useRef(null),[n,i]=f.useState(!1),c=f.useCallback(()=>{if(o.current&&o.current.postMessage({type:"SKIP_WAITING"}),a)try{localStorage.setItem("tracktor_clear_caches","1")}catch{}window.location.reload()},[a]);f.useEffect(()=>{try{localStorage.getItem("tracktor_clear_caches")==="1"&&(localStorage.removeItem("tracktor_clear_caches"),Se().catch(console.error))}catch{}},[]);const u=f.useCallback(()=>{window.confirm("A new version is available. The app will reload now.")&&c()},[c]);return f.useEffect(()=>{if(!("serviceWorker"in navigator))return;let l,p;const s=h=>{h&&navigator.serviceWorker.controller&&(o.current=h,i(!0))},y=()=>{const h=l?.installing;h&&(p=()=>{h.state==="installed"&&s(h)},h.addEventListener("statechange",p))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(s(l.waiting),l.addEventListener("updatefound",y))})().catch(console.error),()=>{l?.removeEventListener("updatefound",y),p&&l?.installing&&l.installing.removeEventListener("statechange",p)}},[]),f.useEffect(()=>{n&&e&&c()},[e,n,c]),f.useEffect(()=>{n&&!e&&!r&&u()},[r,u,n,e]),n&&!e&&r?r(c):null},Ae=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Ce=e=>{const r=e.split(/[/\\]/).pop()||"";return r.substring(0,r.lastIndexOf("."))},je=e=>{const o=e.split("/").filter(n=>n.length>0).map(n=>n.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join("")).join("");return o.charAt(0).toLowerCase()+o.slice(1)},ke=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Pe=(e,r,a,o)=>{const n=je(r),i=Ae(a),c=`${n}${i}`;return e&&typeof e=="object"&&"operationId"in e&&o?.includes(String(e.operationId))?`${c}AsQuery`:c},Te=(e,r)=>{const a={};return e?.forEach(o=>{a[o]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),r?.filter(o=>!a[o]).forEach(o=>{a[o]={query:{useQuery:!0}}}),Object.keys(a).length?a:void 0},Ie=e=>(Array.isArray(e)?e:[e]).reduce((a,o)=>{const{output:n,useInfiniteIds:i,useQueryIds:c,input:u="./openapi.json",customAxiosInstancePath:l,overrideApiName:p}=o||{},s=p||ke(u),y=l||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...a,[s]:{input:u,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(i?.length||c?.length)&&{operations:Te(i,c)},header:h=>["Generated by orval 🍺",...h.title?[h.title]:[],...h.description?[h.description]:[]],mutator:{name:Ce(y),path:y},operationName:(h,w,T)=>Pe(h,w,T,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${s}/model`,target:n?.target||`src/api/${s}/services/api.ts`,...n}}}},{}),Oe=e=>e&&typeof e=="function",xe=e=>e&&typeof e=="function",Ne=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:a,...o})=>{const{libraries:n}=f.useContext(C),i=o?.QueryClient||n?.reactQuery?.QueryClient,c=o?.QueryClientProvider||n?.reactQuery?.QueryClientProvider;if(!i)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!c)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!Oe(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!xe(i))throw new Error("Provided QueryClient dependencies are not valid.");const u=new i({defaultOptions:{mutations:{...a},queries:{getNextPageParam:(l,p,s)=>l.length+(s||0),refetchOnWindowFocus:!1,retry:3,...r}}});return P.jsx(c,{client:u,children:e})},B=({library:e,date:r,format:a="ll"})=>e(r).format(a),X=(e,r)=>{const{fractionDigits:a=0,metric:o="km",spacingBetween:n=!0}=r||{},i=Number(e),c=n?" ":"";return Number.isNaN(i)?`0${c}${o}`:`${i.toFixed(a)}${c}${o}`},Z=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(a=>a.length>0?a.charAt(0).toUpperCase()+a.slice(1):a).join(" "),Le=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Fe=({path:e,size:r,apiURL:a})=>{if(!e)return"";const o=Le(e),n=`${a}${o}`,i=n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof r=="number"&&i?`${n.replace("/files",`/thumbs/${r}`)}`:n},De=e=>{const{apiURL:r,libraries:a}=f.useContext(C),o=e?.dayjs||a?.dayjs;return{dateAdapter:(c,u)=>{if(!o)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return B({date:c,format:u,library:o})},distanceAdapter:X,filePathAdapter:(c,u)=>{if(!r)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return typeof c=="string"&&/^https?:\/\//.test(c)?c:Fe({apiURL:r,path:c,size:u})},worksiteNameAdapter:Z}},We=e=>{const{libraries:r,localStorageKeys:a}=f.useContext(C),o=e?.axios||r?.axios,n=e?.localStorageKey||a?.user||"user";if(!o)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const i=f.useCallback(({tokenType:u,accessToken:l})=>{o.defaults.headers.common.Authorization=`${u} ${l}`},[o.defaults.headers.common]),c=()=>{o.defaults.headers.common.Authorization=null};return f.useEffect(()=>{if(F)return;const u=({newValue:l,key:p})=>{if(p===n&&l)try{const{accessToken:s,tokenType:y}=JSON.parse(l);i({accessToken:s,tokenType:y})}catch(s){console.error("Failed to parse newValue from localStorage:",s)}};return window.addEventListener("storage",u),()=>{window.removeEventListener("storage",u)}},[n,i]),{clearAuthenticationToken:c,setAuthenticationToken:i}},W=(e,r)=>r==="short"?e.split("-")[0]:e,Ye=(e,r="full")=>{const[a,o]=f.useState(()=>{const n=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,W(n,r)});return f.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&o(W(e.language,r));const n=i=>{o(W(i,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),a},ze="tracktor.filter",Ue={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},q=e=>{try{return JSON.parse(e)}catch{return e}},$=(e,r,a)=>`${a}_${e}=>${r}`,Me=e=>e.reduce((r,a)=>{const o=localStorage.getItem(a);if(o)try{const n=JSON.parse(o),i=Object.keys(n)?.[0];i&&(r[i]=Object.values(n)?.[0])}catch{}return r},{}),Qe=e=>{const{libraries:r,localStorageKeys:a}=f.useContext(C),o=e?.reactRouter||r?.reactRouter,{pathname:n}=o?.useLocation?.()??{pathname:"/"},[i,c]=o?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,l]=f.useState({}),p=a?.filter||ze,s=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,y=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(F)return Ue;if(!o)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const h=()=>Object.keys(localStorage).filter(v=>v.startsWith(p)&&v.endsWith(e?.pathname||n)),w=(v,d,_=!0)=>{const S=$(v,e?.pathname||n,p);if(!d||Array.isArray(d)&&!d.length){s?(i.delete(v),c(i)):l(A=>{const I={...A};return delete I[v],I}),y&&localStorage.removeItem(S);return}y&&_&&d&&localStorage.setItem(S,JSON.stringify({...i,[v]:d})),s&&d?(i.set(v,JSON.stringify(d)),c(i)):!s&&d&&l(A=>({...A,[v]:d}))};return{getFilter:(v,d)=>{if(s){const _=i.get(v);if(_)return q(_)}else{const _=u[v];if(_!==void 0)return _}if(y){const _=$(v,e?.pathname||n,p),S=localStorage.getItem(_);if(S)try{const A=JSON.parse(S)[v];return!s&&A!==void 0&&l(I=>({...I,[v]:A})),A}catch{}}return d},getFilters:()=>{const v=y?Me(h()):{};if(s){const d=Array.from(i.entries()).reduce((_,[S,A])=>(_[S]=q(A),_),{});return{...v,...d}}return{...v,...u}},handleFilter:(v,d)=>(_,S)=>{if(S||Array.isArray(S)&&S.length===0){const A=d||"value",I=typeof S=="object"&&A in S?S[A]:S;w(v,I);return}w(v,void 0)},setFilter:w}},Ve=({data:e,fetchNextPage:r,isFetchingNextPage:a,isInitialLoading:o,isLoading:n,enabled:i=!0})=>{const c=f.useCallback(async l=>{a||!i||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[i,r,a]),u=f.useMemo(()=>{if(e)return e.pages.reduce((l,p)=>[...l,...p],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:a||n,loadingVariant:o?"skeleton":"linear-progress",rows:u}},Ge=e=>{const{libraries:r}=f.useContext(C),a=e?.i18||r?.i18,o=e?.i18?.translateFunction||r?.i18?.translateFunction,n=a?.i18next?.t||o||(p=>p),{unknownErrorTranslationKey:i="error.unknownError"}=e||{},c=n(i),u=f.useCallback(p=>{if(p&&typeof p=="object"&&"response"in p){const{response:s}=p||{};if(s&&typeof s=="object"&&"reason"in s&&s.reason)return String(s.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"reason"in s.data&&s.data.reason)return String(s.data.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"message"in s.data&&s.data.message)return String(s.data.message);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"detail"in s.data){const{detail:y}=s.data;if(Array.isArray(y)&&y.length>0&&typeof y[0]=="object"&&y[0]!==null&&"msg"in y[0]){const{msg:h}=y[0];if(typeof h=="string")return String(h)}}}return p instanceof Error?p.message:c},[c]);return{getErrorCode:f.useCallback(p=>{const{response:s}=p||{};return s?.error_code?String(s?.error_code):s?.data?.error_code?String(s?.data?.error_code):s?.error_code?String(s?.error_code):s?.data?.error_code?String(s.data.error_code):"unknown_error_code"},[]),printError:u}};m.GTMSendPageView=fe,m.InitializeAxiosConfig=ge,m.InitializeDaysJSConfig=me,m.InitializeI18nConfig=he,m.InitializeSentryConfig=ye,m.InjectDependenciesContext=C,m.InjectDependenciesProvider=de,m.MaskTextField=ue,m.PreloadErrorHandler=ve,m.QueryClientProviderWithConfig=Ne,m.RequireAuth=we,m.ServiceWorkerCleaner=Re,m.UpdateNotifier=_e,m.axiosCustomInstance=se,m.dateAdapter=B,m.distanceAdapter=X,m.getOrvalConfig=Ie,m.useAdapter=De,m.useAuth=We,m.useCurrentLanguage=Ye,m.useFilters=Qe,m.useInfiniteDataGrid=Ve,m.useResponseError=Ge,m.worksiteNameAdapter=Z,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
|