@tracktor/shared-module 2.19.3 → 2.19.4
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/UpdateNotifier.d.ts +2 -18
- package/dist/main.js +95 -90
- package/dist/main.umd.cjs +2 -2
- package/package.json +1 -1
|
@@ -26,27 +26,11 @@ export interface UpdateNotifierProps {
|
|
|
26
26
|
* and will receive an `onReload` callback to trigger the reload flow.
|
|
27
27
|
* - If no `renderDialog` is provided, a default `window.confirm` prompt is shown,
|
|
28
28
|
* and the app reloads automatically after user confirmation.
|
|
29
|
-
* - If `clearCachesOnReload` is true, all entries in CacheStorage will be cleared
|
|
30
|
-
*
|
|
31
|
-
* - If `autoUpdate` is true, the app will reload automatically when an update is detected,
|
|
32
|
-
* bypassing both `window.confirm` and any custom UI.
|
|
29
|
+
* - If `clearCachesOnReload` is true, all entries in CacheStorage will be cleared,
|
|
30
|
+
* but *safely on next load*, not before reload (avoids crashes or race conditions).
|
|
33
31
|
*
|
|
34
32
|
* Usage:
|
|
35
33
|
* Place <UpdateNotifier /> once at the root of your app (e.g., in App.tsx).
|
|
36
|
-
*
|
|
37
|
-
* Example with a custom banner:
|
|
38
|
-
* ```tsx
|
|
39
|
-
* <UpdateNotifier
|
|
40
|
-
* renderDialog={(handleReloadApp) => (
|
|
41
|
-
* <div style={{ position: "fixed", bottom: 0, width: "100%", background: "orange", padding: "1rem" }}>
|
|
42
|
-
* <span>A new version is available.</span>
|
|
43
|
-
* <button onClick={onReload} style={{ marginLeft: "1rem" }}>
|
|
44
|
-
* Reload now
|
|
45
|
-
* </button>
|
|
46
|
-
* </div>
|
|
47
|
-
* )}
|
|
48
|
-
* />
|
|
49
|
-
* ```
|
|
50
34
|
*/
|
|
51
35
|
declare const UpdateNotifier: ({ autoUpdate, renderDialog, clearCachesOnReload }: UpdateNotifierProps) => ReactNode;
|
|
52
36
|
export default UpdateNotifier;
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import X from "axios";
|
|
2
|
-
import de, { useMemo as M, createContext as fe, useContext as
|
|
2
|
+
import de, { useMemo as M, createContext as fe, useContext as j, useEffect as A, useState as Y, useRef as ne, Suspense as pe, useCallback as x } from "react";
|
|
3
3
|
const De = (e, r) => {
|
|
4
4
|
const o = X.CancelToken.source(), a = X({
|
|
5
5
|
...e,
|
|
@@ -45,7 +45,7 @@ function me() {
|
|
|
45
45
|
switch (t) {
|
|
46
46
|
case g:
|
|
47
47
|
return "Fragment";
|
|
48
|
-
case
|
|
48
|
+
case P:
|
|
49
49
|
return "Profiler";
|
|
50
50
|
case h:
|
|
51
51
|
return "StrictMode";
|
|
@@ -60,13 +60,13 @@ function me() {
|
|
|
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 S:
|
|
64
64
|
return "Portal";
|
|
65
|
-
case
|
|
65
|
+
case E:
|
|
66
66
|
return t.displayName || "Context";
|
|
67
67
|
case m:
|
|
68
68
|
return (t._context.displayName || "Context") + ".Consumer";
|
|
69
|
-
case
|
|
69
|
+
case T:
|
|
70
70
|
var f = t.render;
|
|
71
71
|
return t = t.displayName, t || (t = f.displayName || f.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
72
72
|
case se:
|
|
@@ -92,11 +92,11 @@ function me() {
|
|
|
92
92
|
}
|
|
93
93
|
if (f) {
|
|
94
94
|
f = console;
|
|
95
|
-
var v = f.error,
|
|
95
|
+
var v = f.error, w = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
|
|
96
96
|
return v.call(
|
|
97
97
|
f,
|
|
98
98
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
99
|
-
|
|
99
|
+
w
|
|
100
100
|
), r(t);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -143,14 +143,14 @@ function me() {
|
|
|
143
143
|
"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."
|
|
144
144
|
)), t = this.props.ref, t !== void 0 ? t : null;
|
|
145
145
|
}
|
|
146
|
-
function d(t, f, v,
|
|
146
|
+
function d(t, f, v, w, F, Q) {
|
|
147
147
|
var R = v.ref;
|
|
148
148
|
return t = {
|
|
149
149
|
$$typeof: k,
|
|
150
150
|
type: t,
|
|
151
151
|
key: f,
|
|
152
152
|
props: v,
|
|
153
|
-
_owner:
|
|
153
|
+
_owner: w
|
|
154
154
|
}, (R !== void 0 ? R : null) !== null ? Object.defineProperty(t, "ref", {
|
|
155
155
|
enumerable: !1,
|
|
156
156
|
get: l
|
|
@@ -176,13 +176,13 @@ function me() {
|
|
|
176
176
|
value: Q
|
|
177
177
|
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
178
178
|
}
|
|
179
|
-
function s(t, f, v,
|
|
179
|
+
function s(t, f, v, w, F, Q) {
|
|
180
180
|
var R = f.children;
|
|
181
181
|
if (R !== void 0)
|
|
182
|
-
if (
|
|
182
|
+
if (w)
|
|
183
183
|
if (le(R)) {
|
|
184
|
-
for (
|
|
185
|
-
y(R[
|
|
184
|
+
for (w = 0; w < R.length; w++)
|
|
185
|
+
y(R[w]);
|
|
186
186
|
Object.freeze && Object.freeze(R);
|
|
187
187
|
} else
|
|
188
188
|
console.error(
|
|
@@ -191,21 +191,21 @@ function me() {
|
|
|
191
191
|
else y(R);
|
|
192
192
|
if (G.call(f, "key")) {
|
|
193
193
|
R = e(t);
|
|
194
|
-
var
|
|
194
|
+
var I = Object.keys(f).filter(function(ue) {
|
|
195
195
|
return ue !== "key";
|
|
196
196
|
});
|
|
197
|
-
|
|
197
|
+
w = 0 < I.length ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}", H[R + w] || (I = 0 < I.length ? "{" + I.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
198
198
|
`A props object containing a "key" prop is being spread into JSX:
|
|
199
199
|
let props = %s;
|
|
200
200
|
<%s {...props} />
|
|
201
201
|
React keys must be passed directly to JSX without using spread:
|
|
202
202
|
let props = %s;
|
|
203
203
|
<%s key={someKey} {...props} />`,
|
|
204
|
-
|
|
204
|
+
w,
|
|
205
205
|
R,
|
|
206
|
-
|
|
206
|
+
I,
|
|
207
207
|
R
|
|
208
|
-
), H[R +
|
|
208
|
+
), H[R + w] = !0);
|
|
209
209
|
}
|
|
210
210
|
if (R = null, v !== void 0 && (o(v), R = "" + v), c(f) && (o(f.key), R = "" + f.key), "key" in f) {
|
|
211
211
|
v = {};
|
|
@@ -230,7 +230,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
230
230
|
function p(t) {
|
|
231
231
|
return typeof t == "object" && t !== null && t.$$typeof === k;
|
|
232
232
|
}
|
|
233
|
-
var b = de, k = Symbol.for("react.transitional.element"),
|
|
233
|
+
var b = de, k = Symbol.for("react.transitional.element"), S = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), h = Symbol.for("react.strict_mode"), P = Symbol.for("react.profiler"), m = Symbol.for("react.consumer"), E = Symbol.for("react.context"), T = Symbol.for("react.forward_ref"), oe = Symbol.for("react.suspense"), ae = Symbol.for("react.suspense_list"), se = Symbol.for("react.memo"), W = Symbol.for("react.lazy"), ie = Symbol.for("react.activity"), ce = Symbol.for("react.client.reference"), z = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, G = Object.prototype.hasOwnProperty, le = Array.isArray, U = console.createTask ? console.createTask : function() {
|
|
234
234
|
return null;
|
|
235
235
|
};
|
|
236
236
|
b = {
|
|
@@ -243,24 +243,24 @@ React keys must be passed directly to JSX without using spread:
|
|
|
243
243
|
i
|
|
244
244
|
)(), B = U(a(i)), H = {};
|
|
245
245
|
N.Fragment = g, N.jsx = function(t, f, v) {
|
|
246
|
-
var
|
|
246
|
+
var w = 1e4 > z.recentlyCreatedOwnerStacks++;
|
|
247
247
|
return s(
|
|
248
248
|
t,
|
|
249
249
|
f,
|
|
250
250
|
v,
|
|
251
251
|
!1,
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
w ? Error("react-stack-top-frame") : q,
|
|
253
|
+
w ? U(a(t)) : B
|
|
254
254
|
);
|
|
255
255
|
}, N.jsxs = function(t, f, v) {
|
|
256
|
-
var
|
|
256
|
+
var w = 1e4 > z.recentlyCreatedOwnerStacks++;
|
|
257
257
|
return s(
|
|
258
258
|
t,
|
|
259
259
|
f,
|
|
260
260
|
v,
|
|
261
261
|
!0,
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
w ? Error("react-stack-top-frame") : q,
|
|
263
|
+
w ? U(a(t)) : B
|
|
264
264
|
);
|
|
265
265
|
};
|
|
266
266
|
})()), N;
|
|
@@ -288,7 +288,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
288
288
|
);
|
|
289
289
|
return /* @__PURE__ */ C.jsx(_.Provider, { value: n, children: e });
|
|
290
290
|
}, ze = ({ data: e, ...r }) => {
|
|
291
|
-
const { libraries: o } =
|
|
291
|
+
const { libraries: o } = j(_), a = r?.reactRouter || o?.reactRouter, n = r?.gtm || o?.gtm;
|
|
292
292
|
if (!a)
|
|
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 Ye = ({ 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: i } = n, { useLocation: c, Outlet: u } = a, { pathname: l } = c(), { sendEvent: d } = i();
|
|
299
|
-
return
|
|
299
|
+
return A(() => {
|
|
300
300
|
d({
|
|
301
301
|
event: "pageView",
|
|
302
302
|
pathname: l,
|
|
@@ -317,7 +317,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
317
317
|
postContentType: o = "application/json",
|
|
318
318
|
...a
|
|
319
319
|
}) => {
|
|
320
|
-
const { apiURL: n = a.apiURL, libraries: i, localStorageKeys: c } =
|
|
320
|
+
const { apiURL: n = a.apiURL, libraries: i, localStorageKeys: c } = j(_), u = a?.userLocalStorageKey || c?.user || he, l = a?.axios || i?.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 || L)
|
|
@@ -328,12 +328,12 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
328
328
|
}
|
|
329
329
|
return l.defaults.baseURL = n, l.defaults.headers.post["Content-Type"] = o, null;
|
|
330
330
|
}, Qe = ({ language: e, ...r }) => {
|
|
331
|
-
const { libraries: o } =
|
|
331
|
+
const { libraries: o } = j(_), a = r?.dayjs || o?.dayjs, n = r?.plugin || o?.dayjsPlugin;
|
|
332
332
|
if (!a)
|
|
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 A(() => {
|
|
337
337
|
(async () => {
|
|
338
338
|
const c = e || navigator.language?.slice(0, 2) || "en";
|
|
339
339
|
n && n.forEach((u) => {
|
|
@@ -342,7 +342,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
342
342
|
})().then();
|
|
343
343
|
}, [a, n, e]), null;
|
|
344
344
|
}, Ve = ({ debug: e, resources: r, ...o }) => {
|
|
345
|
-
const { libraries: a } =
|
|
345
|
+
const { libraries: a } = j(_), n = o?.i18 || a?.i18, { i18next: i, initReactI18next: c, languageDetector: u } = n || {};
|
|
346
346
|
if (L)
|
|
347
347
|
return null;
|
|
348
348
|
if (!n)
|
|
@@ -378,14 +378,14 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
378
378
|
release: d,
|
|
379
379
|
...s
|
|
380
380
|
}) => {
|
|
381
|
-
const { libraries: y } =
|
|
381
|
+
const { libraries: y } = j(_), p = s?.sentry || y?.sentry, b = s?.reactRouter || y?.reactRouter;
|
|
382
382
|
if (!p)
|
|
383
383
|
throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
384
384
|
if (!b)
|
|
385
385
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
386
386
|
if (p.isInitialized())
|
|
387
387
|
return null;
|
|
388
|
-
const { createRoutesFromChildren: k, matchRoutes:
|
|
388
|
+
const { createRoutesFromChildren: k, matchRoutes: S, useLocation: g, useNavigationType: h } = b;
|
|
389
389
|
return (u || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && p.init({
|
|
390
390
|
debug: u,
|
|
391
391
|
dsn: e,
|
|
@@ -402,8 +402,8 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
402
402
|
integrations: [
|
|
403
403
|
p.reactRouterV6BrowserTracingIntegration({
|
|
404
404
|
createRoutesFromChildren: k,
|
|
405
|
-
matchRoutes:
|
|
406
|
-
useEffect:
|
|
405
|
+
matchRoutes: S,
|
|
406
|
+
useEffect: A,
|
|
407
407
|
useLocation: g,
|
|
408
408
|
useNavigationType: h
|
|
409
409
|
}),
|
|
@@ -415,7 +415,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
415
415
|
tracePropagationTargets: i,
|
|
416
416
|
tracesSampleRate: o || 1
|
|
417
417
|
}), null;
|
|
418
|
-
}, Ge = () => (
|
|
418
|
+
}, Ge = () => (A(() => {
|
|
419
419
|
if (L)
|
|
420
420
|
return;
|
|
421
421
|
const e = (r) => {
|
|
@@ -428,17 +428,17 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
428
428
|
window.removeEventListener("vite:preloadError", e);
|
|
429
429
|
};
|
|
430
430
|
}, []), null), ve = "user", Je = ({ Fallback: e, isLogged: r, loginPath: o = "/login", redirect401Path: a = "/login", ...n }) => {
|
|
431
|
-
const { libraries: i, localStorageKeys: c } =
|
|
431
|
+
const { libraries: i, localStorageKeys: c } = j(_), u = n?.reactRouter || i?.reactRouter, l = n?.axios || i?.axios, d = n?.localStorageKey || c?.user || ve;
|
|
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 [s, y] = Y(null), { useLocation: p, Navigate: b, Outlet: k } = u,
|
|
435
|
-
return
|
|
434
|
+
const [s, y] = Y(null), { useLocation: p, Navigate: b, Outlet: k } = u, S = p(), g = ne(!1), h = typeof r == "function" ? r() : !!r, P = typeof h == "boolean" ? h : h?.isLogged;
|
|
435
|
+
return A(() => {
|
|
436
436
|
g.current || (g.current = !0, l.interceptors.response.use(
|
|
437
437
|
(m) => m,
|
|
438
438
|
async (m) => (typeof m == "object" && m && "response" in m && m.response && typeof m.response == "object" && "status" in m.response && m.response && typeof m.response == "object" && "status" in m.response && m?.response?.status === 401 && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(d), y(a)), Promise.reject(m))
|
|
439
439
|
));
|
|
440
|
-
}, [l.defaults.headers.common, l.interceptors.response, d, a]),
|
|
441
|
-
},
|
|
440
|
+
}, [l.defaults.headers.common, l.interceptors.response, d, a]), P && !s ? /* @__PURE__ */ C.jsx(pe, { fallback: e, children: S.state?.from?.state && S.state?.from?.pathname === o ? /* @__PURE__ */ C.jsx(b, { to: S.state.from.state.from.pathname + S.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ C.jsx(k, {}) }) : /* @__PURE__ */ C.jsx(b, { to: o + S.search, state: { from: S }, replace: !0 });
|
|
441
|
+
}, Ee = async () => {
|
|
442
442
|
if ("caches" in window)
|
|
443
443
|
try {
|
|
444
444
|
const e = await caches.keys();
|
|
@@ -447,13 +447,18 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
447
447
|
console.error("Failed to clear caches:", e);
|
|
448
448
|
}
|
|
449
449
|
}, Ke = ({ autoUpdate: e, renderDialog: r, clearCachesOnReload: o }) => {
|
|
450
|
-
const a = ne(null), [n, i] = Y(!1), c =
|
|
451
|
-
a.current && a.current.postMessage({ type: "SKIP_WAITING" }), o &&
|
|
452
|
-
}, [o])
|
|
453
|
-
|
|
450
|
+
const a = ne(null), [n, i] = Y(!1), c = x(() => {
|
|
451
|
+
a.current && a.current.postMessage({ type: "SKIP_WAITING" }), o && localStorage.setItem("tracktor_clear_caches", "1"), window.location.reload();
|
|
452
|
+
}, [o]);
|
|
453
|
+
A(() => {
|
|
454
|
+
localStorage.getItem("tracktor_clear_caches") === "1" && (localStorage.removeItem("tracktor_clear_caches"), Ee().catch(console.error));
|
|
455
|
+
}, []);
|
|
456
|
+
const u = x(() => {
|
|
457
|
+
window.confirm("A new version is available. The app will reload now.") && c();
|
|
454
458
|
}, [c]);
|
|
455
|
-
return
|
|
456
|
-
if (!("serviceWorker" in navigator))
|
|
459
|
+
return A(() => {
|
|
460
|
+
if (!("serviceWorker" in navigator))
|
|
461
|
+
return;
|
|
457
462
|
let l, d;
|
|
458
463
|
const s = (p) => {
|
|
459
464
|
p && navigator.serviceWorker.controller && (a.current = p, i(!0));
|
|
@@ -468,21 +473,21 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
468
473
|
})().catch(console.error), () => {
|
|
469
474
|
l?.removeEventListener("updatefound", y), d && l?.installing && l.installing.removeEventListener("statechange", d);
|
|
470
475
|
};
|
|
471
|
-
}, []),
|
|
472
|
-
n && e && c()
|
|
473
|
-
}, [e, n, c]),
|
|
474
|
-
n && !e && !r && u()
|
|
476
|
+
}, []), A(() => {
|
|
477
|
+
n && e && c();
|
|
478
|
+
}, [e, n, c]), A(() => {
|
|
479
|
+
n && !e && !r && u();
|
|
475
480
|
}, [r, u, n, e]), n && !e && r ? r(c) : null;
|
|
476
|
-
},
|
|
481
|
+
}, we = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), Re = (e) => {
|
|
477
482
|
const r = e.split(/[/\\]/).pop() || "";
|
|
478
483
|
return r.substring(0, r.lastIndexOf("."));
|
|
479
484
|
}, be = (e) => {
|
|
480
485
|
const a = 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("");
|
|
481
486
|
return a.charAt(0).toLowerCase() + a.slice(1);
|
|
482
|
-
}, _e = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""),
|
|
483
|
-
const n = be(r), i =
|
|
487
|
+
}, _e = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), Se = (e, r, o, a) => {
|
|
488
|
+
const n = be(r), i = we(o), c = `${n}${i}`;
|
|
484
489
|
return e && typeof e == "object" && "operationId" in e && a?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
|
|
485
|
-
},
|
|
490
|
+
}, Ae = (e, r) => {
|
|
486
491
|
const o = {};
|
|
487
492
|
return e?.forEach((a) => {
|
|
488
493
|
o[a] = {
|
|
@@ -511,7 +516,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
511
516
|
mode: "tags-split",
|
|
512
517
|
override: {
|
|
513
518
|
...(i?.length || c?.length) && {
|
|
514
|
-
operations:
|
|
519
|
+
operations: Ae(i, c)
|
|
515
520
|
},
|
|
516
521
|
header: (p) => [
|
|
517
522
|
"Generated by orval 🍺",
|
|
@@ -522,7 +527,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
522
527
|
name: Re(y),
|
|
523
528
|
path: y
|
|
524
529
|
},
|
|
525
|
-
operationName: (p, b, k) =>
|
|
530
|
+
operationName: (p, b, k) => Se(p, b, k, c),
|
|
526
531
|
query: {
|
|
527
532
|
useQuery: !0
|
|
528
533
|
}
|
|
@@ -539,7 +544,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
539
544
|
defaultMutationsOptions: o,
|
|
540
545
|
...a
|
|
541
546
|
}) => {
|
|
542
|
-
const { libraries: n } =
|
|
547
|
+
const { libraries: n } = j(_), i = a?.QueryClient || n?.reactQuery?.QueryClient, c = a?.QueryClientProvider || n?.reactQuery?.QueryClientProvider;
|
|
543
548
|
if (!i)
|
|
544
549
|
throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
545
550
|
if (!c)
|
|
@@ -565,13 +570,13 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
565
570
|
}, Te = ({ library: e, date: r, format: o = "ll" }) => e(r).format(o), ke = (e, r) => {
|
|
566
571
|
const { fractionDigits: o = 0, metric: a = "km", spacingBetween: n = !0 } = r || {}, i = Number(e), c = n ? " " : "";
|
|
567
572
|
return Number.isNaN(i) ? `0${c}${a}` : `${i.toFixed(o)}${c}${a}`;
|
|
568
|
-
}, Ce = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((o) => o.length > 0 ? o.charAt(0).toUpperCase() + o.slice(1) : o).join(" "),
|
|
573
|
+
}, Ce = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((o) => o.length > 0 ? o.charAt(0).toUpperCase() + o.slice(1) : o).join(" "), Ie = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, xe = ({ path: e, size: r, apiURL: o }) => {
|
|
569
574
|
if (!e)
|
|
570
575
|
return "";
|
|
571
|
-
const a =
|
|
576
|
+
const a = Ie(e), n = `${o}${a}`, i = n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
|
|
572
577
|
return typeof r == "number" && i ? `${n.replace("/files", `/thumbs/${r}`)}` : n;
|
|
573
578
|
}, He = (e) => {
|
|
574
|
-
const { apiURL: r, libraries: o } =
|
|
579
|
+
const { apiURL: r, libraries: o } = j(_), a = e?.dayjs || o?.dayjs;
|
|
575
580
|
return {
|
|
576
581
|
dateAdapter: (c, u) => {
|
|
577
582
|
if (!a)
|
|
@@ -588,7 +593,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
588
593
|
throw new Error(
|
|
589
594
|
"API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
|
|
590
595
|
);
|
|
591
|
-
return typeof c == "string" && /^https?:\/\//.test(c) ? c :
|
|
596
|
+
return typeof c == "string" && /^https?:\/\//.test(c) ? c : xe({
|
|
592
597
|
apiURL: r,
|
|
593
598
|
path: c,
|
|
594
599
|
size: u
|
|
@@ -597,10 +602,10 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
597
602
|
worksiteNameAdapter: Ce
|
|
598
603
|
};
|
|
599
604
|
}, Xe = (e) => {
|
|
600
|
-
const { libraries: r } =
|
|
605
|
+
const { libraries: r } = j(_), o = e?.axios || r?.axios, a = e?.localStorageKey || "user";
|
|
601
606
|
if (!o)
|
|
602
607
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
|
|
603
|
-
const n =
|
|
608
|
+
const n = x(
|
|
604
609
|
({ tokenType: c, accessToken: u }) => {
|
|
605
610
|
o.defaults.headers.common.Authorization = `${c} ${u}`;
|
|
606
611
|
},
|
|
@@ -608,7 +613,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
608
613
|
), i = () => {
|
|
609
614
|
o.defaults.headers.common.Authorization = null;
|
|
610
615
|
};
|
|
611
|
-
return
|
|
616
|
+
return A(() => {
|
|
612
617
|
if (L)
|
|
613
618
|
return;
|
|
614
619
|
const c = ({ newValue: u, key: l }) => {
|
|
@@ -632,7 +637,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
632
637
|
const n = e?.language || navigator.language;
|
|
633
638
|
return e && "isInitialized" in e && e.isInitialized, D(n, r);
|
|
634
639
|
});
|
|
635
|
-
return
|
|
640
|
+
return A(() => {
|
|
636
641
|
e && "isInitialized" in e && e.isInitialized && e.language && a(D(e.language, r));
|
|
637
642
|
const n = (i) => {
|
|
638
643
|
a(D(i, r));
|
|
@@ -659,7 +664,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
659
664
|
}
|
|
660
665
|
return r;
|
|
661
666
|
}, {}), et = (e) => {
|
|
662
|
-
const { libraries: r, localStorageKeys: o } =
|
|
667
|
+
const { libraries: r, localStorageKeys: o } = j(_), a = e?.reactRouter || r?.reactRouter, { pathname: n } = a?.useLocation?.() ?? { pathname: "/" }, [i, c] = a?.useSearchParams?.() ?? [new URLSearchParams(), () => {
|
|
663
668
|
}], [u, l] = Y({}), d = o?.filter || Oe, s = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl;
|
|
664
669
|
if (L)
|
|
665
670
|
return Ne;
|
|
@@ -669,38 +674,38 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
669
674
|
);
|
|
670
675
|
const y = () => Object.keys(localStorage).filter(
|
|
671
676
|
(g) => g.startsWith(d) && g.endsWith(e?.pathname || n)
|
|
672
|
-
), p = (g, h,
|
|
677
|
+
), p = (g, h, P = !0) => {
|
|
673
678
|
const m = re(g, e?.pathname || n, d);
|
|
674
679
|
if (!h || Array.isArray(h) && !h.length) {
|
|
675
|
-
s ? (i.delete(g), c(i)) : l((
|
|
676
|
-
const
|
|
677
|
-
return delete
|
|
680
|
+
s ? (i.delete(g), c(i)) : l((E) => {
|
|
681
|
+
const T = { ...E };
|
|
682
|
+
return delete T[g], T;
|
|
678
683
|
}), localStorage.removeItem(m);
|
|
679
684
|
return;
|
|
680
685
|
}
|
|
681
|
-
|
|
686
|
+
P && h && localStorage.setItem(m, JSON.stringify({ ...i, [g]: h })), s && h ? (i.set(g, JSON.stringify(h)), c(i)) : !s && h && l((E) => ({ ...E, [g]: h }));
|
|
682
687
|
};
|
|
683
688
|
return {
|
|
684
689
|
getFilter: (g, h) => {
|
|
685
690
|
if (!s) {
|
|
686
|
-
const
|
|
687
|
-
if (
|
|
688
|
-
return
|
|
691
|
+
const E = u[g];
|
|
692
|
+
if (E !== void 0)
|
|
693
|
+
return E;
|
|
689
694
|
}
|
|
690
695
|
if (s) {
|
|
691
|
-
const
|
|
692
|
-
if (
|
|
696
|
+
const E = i.get(g);
|
|
697
|
+
if (E)
|
|
693
698
|
try {
|
|
694
|
-
return JSON.parse(
|
|
699
|
+
return JSON.parse(E);
|
|
695
700
|
} catch {
|
|
696
|
-
return
|
|
701
|
+
return E;
|
|
697
702
|
}
|
|
698
703
|
}
|
|
699
|
-
const
|
|
704
|
+
const P = re(g, e?.pathname || n, d), m = localStorage.getItem(P);
|
|
700
705
|
if (m)
|
|
701
706
|
try {
|
|
702
|
-
const
|
|
703
|
-
return !s &&
|
|
707
|
+
const E = JSON.parse(m)[g];
|
|
708
|
+
return !s && E !== void 0 && l((T) => ({ ...T, [g]: E })), E;
|
|
704
709
|
} catch {
|
|
705
710
|
}
|
|
706
711
|
return h;
|
|
@@ -708,10 +713,10 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
708
713
|
getFilters: () => {
|
|
709
714
|
const g = y(), h = Le(g);
|
|
710
715
|
if (s) {
|
|
711
|
-
const
|
|
716
|
+
const P = Object.fromEntries(i.entries());
|
|
712
717
|
return {
|
|
713
718
|
...h,
|
|
714
|
-
...
|
|
719
|
+
...P
|
|
715
720
|
};
|
|
716
721
|
}
|
|
717
722
|
return {
|
|
@@ -719,10 +724,10 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
719
724
|
...u
|
|
720
725
|
};
|
|
721
726
|
},
|
|
722
|
-
handleFilter: (g, h) => (
|
|
727
|
+
handleFilter: (g, h) => (P, m) => {
|
|
723
728
|
if (m || Array.isArray(m) && m.length === 0) {
|
|
724
|
-
const
|
|
725
|
-
p(g,
|
|
729
|
+
const E = h || "value", T = typeof m == "object" && E in m ? m[E] : m;
|
|
730
|
+
p(g, T);
|
|
726
731
|
return;
|
|
727
732
|
}
|
|
728
733
|
p(g, void 0);
|
|
@@ -737,7 +742,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
737
742
|
isLoading: n,
|
|
738
743
|
enabled: i = !0
|
|
739
744
|
}) => {
|
|
740
|
-
const c =
|
|
745
|
+
const c = x(
|
|
741
746
|
async (l) => {
|
|
742
747
|
o || !i || await r({ pageParam: l?.pageParam || l.visibleRowsCount });
|
|
743
748
|
},
|
|
@@ -753,7 +758,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
753
758
|
rows: u
|
|
754
759
|
};
|
|
755
760
|
}, rt = (e) => {
|
|
756
|
-
const { libraries: r } =
|
|
761
|
+
const { libraries: r } = j(_), o = e?.i18 || r?.i18, a = e?.i18?.translateFunction || r?.i18?.translateFunction, n = o?.i18next?.t || a || ((d) => d), { unknownErrorTranslationKey: i = "error.unknownError" } = e || {}, c = n(i), u = x(
|
|
757
762
|
(d) => {
|
|
758
763
|
if (d && typeof d == "object" && "response" in d) {
|
|
759
764
|
const { response: s } = d || {};
|
|
@@ -776,7 +781,7 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
|
|
|
776
781
|
},
|
|
777
782
|
[c]
|
|
778
783
|
);
|
|
779
|
-
return { getErrorCode:
|
|
784
|
+
return { getErrorCode: x((d) => {
|
|
780
785
|
const { response: s } = d || {};
|
|
781
786
|
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";
|
|
782
787
|
}, []), printError: u };
|
package/dist/main.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(m,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],I):(m=typeof globalThis<"u"?globalThis:m||self,I(m["@tracktor/shared-module"]={},m.axios,m.React))})(this,(function(m,I,f){"use strict";const ne=(e,r)=>{const o=I.CancelToken.source(),a=I({...e,...r,cancelToken:o.token}).then(({data:n})=>n);return a.cancel=()=>{o.cancel("Query was cancelled")},a};var F={exports:{}},x={};var V;function oe(){if(V)return x;V=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(a,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:a,key:c,ref:n!==void 0?n:null,props:i}}return x.Fragment=r,x.jsx=o,x.jsxs=o,x}var N={};var G;function ae(){return G||(G=1,process.env.NODE_ENV!=="production"&&(function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Ge?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case y:return"Fragment";case j:return"Profiler";case E:return"StrictMode";case Ue:return"Suspense";case Me:return"SuspenseList";case Ve: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 C:return"Portal";case b:return t.displayName||"Context";case h:return(t._context.displayName||"Context")+".Consumer";case P:var p=t.render;return t=t.displayName,t||(t=p.displayName||p.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Qe:return p=t.displayName||null,p!==null?p:e(t.type)||"Memo";case W:p=t._payload,t=t._init;try{return e(t(p))}catch{}}return null}function r(t){return""+t}function o(t){try{r(t);var p=!1}catch{p=!0}if(p){p=console;var w=p.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return w.call(p,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),r(t)}}function a(t){if(t===y)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===W)return"<...>";try{var p=e(t);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function n(){var t=z.A;return t===null?null:t.getOwner()}function i(){return Error("react-stack-top-frame")}function c(t){if(Z.call(t,"key")){var p=Object.getOwnPropertyDescriptor(t,"key").get;if(p&&p.isReactWarning)return!1}return t.key!==void 0}function u(t,p){function w(){q||(q=!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)",p))}w.isReactWarning=!0,Object.defineProperty(t,"key",{get:w,configurable:!0})}function l(){var t=e(this.type);return $[t]||($[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 d(t,p,w,R,Y,M){var
|
|
1
|
+
(function(m,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],I):(m=typeof globalThis<"u"?globalThis:m||self,I(m["@tracktor/shared-module"]={},m.axios,m.React))})(this,(function(m,I,f){"use strict";const ne=(e,r)=>{const o=I.CancelToken.source(),a=I({...e,...r,cancelToken:o.token}).then(({data:n})=>n);return a.cancel=()=>{o.cancel("Query was cancelled")},a};var F={exports:{}},x={};var V;function oe(){if(V)return x;V=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(a,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:a,key:c,ref:n!==void 0?n:null,props:i}}return x.Fragment=r,x.jsx=o,x.jsxs=o,x}var N={};var G;function ae(){return G||(G=1,process.env.NODE_ENV!=="production"&&(function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Ge?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case y:return"Fragment";case j:return"Profiler";case E:return"StrictMode";case Ue:return"Suspense";case Me:return"SuspenseList";case Ve: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 C:return"Portal";case b:return t.displayName||"Context";case h:return(t._context.displayName||"Context")+".Consumer";case P:var p=t.render;return t=t.displayName,t||(t=p.displayName||p.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Qe:return p=t.displayName||null,p!==null?p:e(t.type)||"Memo";case W:p=t._payload,t=t._init;try{return e(t(p))}catch{}}return null}function r(t){return""+t}function o(t){try{r(t);var p=!1}catch{p=!0}if(p){p=console;var w=p.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return w.call(p,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),r(t)}}function a(t){if(t===y)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===W)return"<...>";try{var p=e(t);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function n(){var t=z.A;return t===null?null:t.getOwner()}function i(){return Error("react-stack-top-frame")}function c(t){if(Z.call(t,"key")){var p=Object.getOwnPropertyDescriptor(t,"key").get;if(p&&p.isReactWarning)return!1}return t.key!==void 0}function u(t,p){function w(){q||(q=!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)",p))}w.isReactWarning=!0,Object.defineProperty(t,"key",{get:w,configurable:!0})}function l(){var t=e(this.type);return $[t]||($[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 d(t,p,w,R,Y,M){var _=w.ref;return t={$$typeof:k,type:t,key:p,props:w,_owner:R},(_!==void 0?_: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:M}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function s(t,p,w,R,Y,M){var _=p.children;if(_!==void 0)if(R)if(Je(_)){for(R=0;R<_.length;R++)v(_[R]);Object.freeze&&Object.freeze(_)}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 v(_);if(Z.call(p,"key")){_=e(t);var O=Object.keys(p).filter(function(Ke){return Ke!=="key"});R=0<O.length?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}",re[_+R]||(O=0<O.length?"{"+O.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} />`,R,S,O,S),re[S+R]=!0)}if(S=null,w!==void 0&&(o(w),S=""+w),c(p)&&(o(p.key),S=""+p.key),"key"in p){w={};for(var Q in p)Q!=="key"&&(w[Q]=p[Q])}else w=p;return S&&u(w,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,S,w,n(),Y,M)}function v(t){g(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===W&&(t._payload.status==="fulfilled"?g(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function g(t){return typeof t=="object"&&t!==null&&t.$$typeof===k}var _=f,k=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),h=Symbol.for("react.consumer"),b=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),Ue=Symbol.for("react.suspense"),Me=Symbol.for("react.suspense_list"),Qe=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),Ve=Symbol.for("react.activity"),Ge=Symbol.for("react.client.reference"),z=_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=Object.prototype.hasOwnProperty,Je=Array.isArray,U=console.createTask?console.createTask:function(){return null};_={react_stack_bottom_frame:function(t){return t()}};var q,$={},ee=_.react_stack_bottom_frame.bind(_,i)(),te=U(a(i)),re={};N.Fragment=y,N.jsx=function(t,p,w){var R=1e4>z.recentlyCreatedOwnerStacks++;return s(t,p,w,!1,R?Error("react-stack-top-frame"):ee,R?U(a(t)):te)},N.jsxs=function(t,p,w){var R=1e4>z.recentlyCreatedOwnerStacks++;return s(t,p,w,!0,R?Error("react-stack-top-frame"):ee,R?U(a(t)):te)}})()),N}var J;function se(){return J||(J=1,process.env.NODE_ENV==="production"?F.exports=oe():F.exports=ae()),F.exports}var T=se();const ie=({IMaskMixin:e,...r})=>{const o=f.useMemo(()=>e(({TextField:a,...n})=>T.jsx(a,{...n})),[e]);return T.jsx(o,{...r})},A=f.createContext({}),ce=({children:e,apiURL:r,libraries:o,localStorageKeys:a})=>{const n=f.useMemo(()=>({apiURL:r,libraries:o,localStorageKeys:a}),[r,o,a]);return T.jsx(A.Provider,{value:n,children:e})},le=({data:e,...r})=>{const{libraries:o}=f.useContext(A),a=r?.reactRouter||o?.reactRouter,n=r?.gtm||o?.gtm;if(!a)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}=a,{pathname:l}=c(),{sendEvent:d}=i();return f.useEffect(()=>{d({event:"pageView",pathname:l,...e})},[e,l,d]),T.jsx(u,{})},L=(()=>{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}})(),ue="user",de=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:n=a.apiURL,libraries:i,localStorageKeys:c}=f.useContext(A),u=a?.userLocalStorageKey||c?.user||ue,l=a?.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||L)return null;if(typeof window<"u"&&window.localStorage){const d=localStorage.getItem(u),s=d?JSON.parse(d):null,v=s?.[e]?s[e]:null,g=s?.[r]?s[r]:null,_=d?`${v} ${g}`:null;_&&(l.defaults.headers.common.Authorization=_)}return l.defaults.baseURL=n,l.defaults.headers.post["Content-Type"]=o,null},fe=({language:e,...r})=>{const{libraries:o}=f.useContext(A),a=r?.dayjs||o?.dayjs,n=r?.plugin||o?.dayjsPlugin;if(!a)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&&a.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),a.locale(c)})().then()},[a,n,e]),null},pe=({debug:e,resources:r,...o})=>{const{libraries:a}=f.useContext(A),n=o?.i18||a?.i18,{i18next:i,initReactI18next:c,languageDetector:u}=n||{};if(L)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},ge=({dsn:e,integrations:r,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:n,tracePropagationTargets:i,ignoreErrors:c,debug:u,environment:l,release:d,...s})=>{const{libraries:v}=f.useContext(A),g=s?.sentry||v?.sentry,_=s?.reactRouter||v?.reactRouter;if(!g)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!_)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(g.isInitialized())return null;const{createRoutesFromChildren:k,matchRoutes:C,useLocation:y,useNavigationType:E}=_;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&g.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:[g.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:k,matchRoutes:C,useEffect:f.useEffect,useLocation:y,useNavigationType:E}),...r||[]],release:d,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:i,tracesSampleRate:o||1}),null},me=()=>(f.useEffect(()=>{if(L)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),ye="user",he=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:i,localStorageKeys:c}=f.useContext(A),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,d=n?.localStorageKey||c?.user||ye;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[s,v]=f.useState(null),{useLocation:g,Navigate:_,Outlet:k}=u,C=g(),y=f.useRef(!1),E=typeof r=="function"?r():!!r,j=typeof E=="boolean"?E:E?.isLogged;return f.useEffect(()=>{y.current||(y.current=!0,l.interceptors.response.use(h=>h,async h=>(typeof h=="object"&&h&&"response"in h&&h.response&&typeof h.response=="object"&&"status"in h.response&&h.response&&typeof h.response=="object"&&"status"in h.response&&h?.response?.status===401&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(d),v(a)),Promise.reject(h))))},[l.defaults.headers.common,l.interceptors.response,d,a]),j&&!s?T.jsx(f.Suspense,{fallback:e,children:C.state?.from?.state&&C.state?.from?.pathname===o?T.jsx(_,{to:C.state.from.state.from.pathname+C.state.from.state.from.search,replace:!0}):T.jsx(k,{})}):T.jsx(_,{to:o+C.search,state:{from:C},replace:!0})},ve=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)}},Ee=({autoUpdate:e,renderDialog:r,clearCachesOnReload:o})=>{const a=f.useRef(null),[n,i]=f.useState(!1),c=f.useCallback(async()=>{a.current&&a.current.postMessage({type:"SKIP_WAITING"}),o&&await ve(),window.location.reload()},[o]),u=f.useCallback(async()=>{window.confirm("A new version is available. The app will reload now.")&&await c()},[c]);return f.useEffect(()=>{if(!("serviceWorker"in navigator))return;let l,d;const s=g=>{g&&navigator.serviceWorker.controller&&(a.current=g,i(!0))},v=()=>{const g=l?.installing;g&&(d=()=>{g.state==="installed"&&s(g)},g.addEventListener("statechange",d))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(s(l.waiting),l.addEventListener("updatefound",v))})().catch(console.error),()=>{l?.removeEventListener("updatefound",v),d&&l?.installing&&l.installing.removeEventListener("statechange",d)}},[]),f.useEffect(()=>{n&&e&&c().catch(console.error)},[e,n,c]),f.useEffect(()=>{n&&!e&&!r&&u().catch(console.error)},[r,u,n,e]),n&&!e&&r?r(c):null},we=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),be=e=>{const r=e.split(/[/\\]/).pop()||"";return r.substring(0,r.lastIndexOf("."))},Re=e=>{const a=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 a.charAt(0).toLowerCase()+a.slice(1)},Se=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),_e=(e,r,o,a)=>{const n=Re(r),i=we(o),c=`${n}${i}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},Ae=(e,r)=>{const o={};return e?.forEach(a=>{o[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),r?.filter(a=>!o[a]).forEach(a=>{o[a]={query:{useQuery:!0}}}),Object.keys(o).length?o:void 0},Ce=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:n,useInfiniteIds:i,useQueryIds:c,input:u="./openapi.json",customAxiosInstancePath:l,overrideApiName:d}=a||{},s=d||Se(u),v=l||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...o,[s]:{input:u,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(i?.length||c?.length)&&{operations:Ae(i,c)},header:g=>["Generated by orval 🍺",...g.title?[g.title]:[],...g.description?[g.description]:[]],mutator:{name:be(v),path:v},operationName:(g,_,k)=>_e(g,_,k,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${s}/model`,target:n?.target||`src/api/${s}/services/api.ts`,...n}}}},{}),je=e=>e&&typeof e=="function",Pe=e=>e&&typeof e=="function",Te=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=f.useContext(A),i=a?.QueryClient||n?.reactQuery?.QueryClient,c=a?.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(!je(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Pe(i))throw new Error("Provided QueryClient dependencies are not valid.");const u=new i({defaultOptions:{mutations:{...o},queries:{getNextPageParam:(l,d,s)=>l.length+(s||0),refetchOnWindowFocus:!1,retry:3,...r}}});return T.jsx(c,{client:u,children:e})},K=({library:e,date:r,format:o="ll"})=>e(r).format(o),B=(e,r)=>{const{fractionDigits:o=0,metric:a="km",spacingBetween:n=!0}=r||{},i=Number(e),c=n?" ":"";return Number.isNaN(i)?`0${c}${a}`:`${i.toFixed(o)}${c}${a}`},H=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(o=>o.length>0?o.charAt(0).toUpperCase()+o.slice(1):o).join(" "),ke=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Ie=({path:e,size:r,apiURL:o})=>{if(!e)return"";const a=ke(e),n=`${o}${a}`,i=n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof r=="number"&&i?`${n.replace("/files",`/thumbs/${r}`)}`:n},Oe=e=>{const{apiURL:r,libraries:o}=f.useContext(A),a=e?.dayjs||o?.dayjs;return{dateAdapter:(c,u)=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return K({date:c,format:u,library:a})},distanceAdapter:B,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:Ie({apiURL:r,path:c,size:u})},worksiteNameAdapter:H}},xe=e=>{const{libraries:r}=f.useContext(A),o=e?.axios||r?.axios,a=e?.localStorageKey||"user";if(!o)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const n=f.useCallback(({tokenType:c,accessToken:u})=>{o.defaults.headers.common.Authorization=`${c} ${u}`},[o.defaults.headers.common]),i=()=>{o.defaults.headers.common.Authorization=null};return f.useEffect(()=>{if(L)return;const c=({newValue:u,key:l})=>{if(l===a&&u)try{const{accessToken:d,tokenType:s}=JSON.parse(u);n({accessToken:d,tokenType:s})}catch(d){console.error("Failed to parse newValue from localStorage:",d)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}},[a,n]),{clearAuthenticationToken:i,setAuthenticationToken:n}},D=(e,r)=>r==="short"?e.split("-")[0]:e,Ne=(e,r="full")=>{const[o,a]=f.useState(()=>{const n=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,D(n,r)});return f.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(D(e.language,r));const n=i=>{a(D(i,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),o},Le="tracktor.filter",Fe={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},X=(e,r,o)=>`${o}_${e}=>${r}`,De=e=>e.reduce((r,o)=>{const a=localStorage.getItem(o);if(a)try{const n=JSON.parse(a),i=Object.keys(n)?.[0];i&&(r[i]=Object.values(n)?.[0])}catch{}return r},{}),Ye=e=>{const{libraries:r,localStorageKeys:o}=f.useContext(A),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[i,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,l]=f.useState({}),d=o?.filter||Le,s=e?.syncWithUrl===void 0?!0:e?.syncWithUrl;if(L)return Fe;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const v=()=>Object.keys(localStorage).filter(y=>y.startsWith(d)&&y.endsWith(e?.pathname||n)),g=(y,E,j=!0)=>{const h=X(y,e?.pathname||n,d);if(!E||Array.isArray(E)&&!E.length){s?(i.delete(y),c(i)):l(b=>{const P={...b};return delete P[y],P}),localStorage.removeItem(h);return}j&&E&&localStorage.setItem(h,JSON.stringify({...i,[y]:E})),s&&E?(i.set(y,JSON.stringify(E)),c(i)):!s&&E&&l(b=>({...b,[y]:E}))};return{getFilter:(y,E)=>{if(!s){const b=u[y];if(b!==void 0)return b}if(s){const b=i.get(y);if(b)try{return JSON.parse(b)}catch{return b}}const j=X(y,e?.pathname||n,d),h=localStorage.getItem(j);if(h)try{const b=JSON.parse(h)[y];return!s&&b!==void 0&&l(P=>({...P,[y]:b})),b}catch{}return E},getFilters:()=>{const y=v(),E=De(y);if(s){const j=Object.fromEntries(i.entries());return{...E,...j}}return{...E,...u}},handleFilter:(y,E)=>(j,h)=>{if(h||Array.isArray(h)&&h.length===0){const b=E||"value",P=typeof h=="object"&&b in h?h[b]:h;g(y,P);return}g(y,void 0)},setFilter:g}},We=({data:e,fetchNextPage:r,isFetchingNextPage:o,isInitialLoading:a,isLoading:n,enabled:i=!0})=>{const c=f.useCallback(async l=>{o||!i||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[i,r,o]),u=f.useMemo(()=>{if(e)return e.pages.reduce((l,d)=>[...l,...d],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:o||n,loadingVariant:a?"skeleton":"linear-progress",rows:u}},ze=e=>{const{libraries:r}=f.useContext(A),o=e?.i18||r?.i18,a=e?.i18?.translateFunction||r?.i18?.translateFunction,n=o?.i18next?.t||a||(d=>d),{unknownErrorTranslationKey:i="error.unknownError"}=e||{},c=n(i),u=f.useCallback(d=>{if(d&&typeof d=="object"&&"response"in d){const{response:s}=d||{};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:v}=s.data;if(Array.isArray(v)&&v.length>0&&typeof v[0]=="object"&&v[0]!==null&&"msg"in v[0]){const{msg:g}=v[0];if(typeof g=="string")return String(g)}}}return d instanceof Error?d.message:c},[c]);return{getErrorCode:f.useCallback(d=>{const{response:s}=d||{};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=le,m.InitializeAxiosConfig=de,m.InitializeDaysJSConfig=fe,m.InitializeI18nConfig=pe,m.InitializeSentryConfig=ge,m.InjectDependenciesContext=A,m.InjectDependenciesProvider=ce,m.MaskTextField=ie,m.PreloadErrorHandler=me,m.QueryClientProviderWithConfig=Te,m.RequireAuth=he,m.UpdateNotifier=Ee,m.axiosCustomInstance=ne,m.dateAdapter=K,m.distanceAdapter=B,m.getOrvalConfig=Ce,m.useAdapter=Oe,m.useAuth=xe,m.useCurrentLanguage=Ne,m.useFilters=Ye,m.useInfiniteDataGrid=We,m.useResponseError=ze,m.worksiteNameAdapter=H,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
<%s key={someKey} {...props} />`,R,_,O,_),re[_+R]=!0)}if(_=null,w!==void 0&&(o(w),_=""+w),c(p)&&(o(p.key),_=""+p.key),"key"in p){w={};for(var Q in p)Q!=="key"&&(w[Q]=p[Q])}else w=p;return _&&u(w,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,_,w,n(),Y,M)}function v(t){g(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===W&&(t._payload.status==="fulfilled"?g(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function g(t){return typeof t=="object"&&t!==null&&t.$$typeof===k}var S=f,k=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),h=Symbol.for("react.consumer"),b=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),Ue=Symbol.for("react.suspense"),Me=Symbol.for("react.suspense_list"),Qe=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),Ve=Symbol.for("react.activity"),Ge=Symbol.for("react.client.reference"),z=S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=Object.prototype.hasOwnProperty,Je=Array.isArray,U=console.createTask?console.createTask:function(){return null};S={react_stack_bottom_frame:function(t){return t()}};var q,$={},ee=S.react_stack_bottom_frame.bind(S,i)(),te=U(a(i)),re={};N.Fragment=y,N.jsx=function(t,p,w){var R=1e4>z.recentlyCreatedOwnerStacks++;return s(t,p,w,!1,R?Error("react-stack-top-frame"):ee,R?U(a(t)):te)},N.jsxs=function(t,p,w){var R=1e4>z.recentlyCreatedOwnerStacks++;return s(t,p,w,!0,R?Error("react-stack-top-frame"):ee,R?U(a(t)):te)}})()),N}var J;function se(){return J||(J=1,process.env.NODE_ENV==="production"?F.exports=oe():F.exports=ae()),F.exports}var T=se();const ie=({IMaskMixin:e,...r})=>{const o=f.useMemo(()=>e(({TextField:a,...n})=>T.jsx(a,{...n})),[e]);return T.jsx(o,{...r})},A=f.createContext({}),ce=({children:e,apiURL:r,libraries:o,localStorageKeys:a})=>{const n=f.useMemo(()=>({apiURL:r,libraries:o,localStorageKeys:a}),[r,o,a]);return T.jsx(A.Provider,{value:n,children:e})},le=({data:e,...r})=>{const{libraries:o}=f.useContext(A),a=r?.reactRouter||o?.reactRouter,n=r?.gtm||o?.gtm;if(!a)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}=a,{pathname:l}=c(),{sendEvent:d}=i();return f.useEffect(()=>{d({event:"pageView",pathname:l,...e})},[e,l,d]),T.jsx(u,{})},L=(()=>{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}})(),ue="user",de=({tokenTypeKey:e="tokenType",tokenKey:r="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:n=a.apiURL,libraries:i,localStorageKeys:c}=f.useContext(A),u=a?.userLocalStorageKey||c?.user||ue,l=a?.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||L)return null;if(typeof window<"u"&&window.localStorage){const d=localStorage.getItem(u),s=d?JSON.parse(d):null,v=s?.[e]?s[e]:null,g=s?.[r]?s[r]:null,S=d?`${v} ${g}`:null;S&&(l.defaults.headers.common.Authorization=S)}return l.defaults.baseURL=n,l.defaults.headers.post["Content-Type"]=o,null},fe=({language:e,...r})=>{const{libraries:o}=f.useContext(A),a=r?.dayjs||o?.dayjs,n=r?.plugin||o?.dayjsPlugin;if(!a)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&&a.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),a.locale(c)})().then()},[a,n,e]),null},pe=({debug:e,resources:r,...o})=>{const{libraries:a}=f.useContext(A),n=o?.i18||a?.i18,{i18next:i,initReactI18next:c,languageDetector:u}=n||{};if(L)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},ge=({dsn:e,integrations:r,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:n,tracePropagationTargets:i,ignoreErrors:c,debug:u,environment:l,release:d,...s})=>{const{libraries:v}=f.useContext(A),g=s?.sentry||v?.sentry,S=s?.reactRouter||v?.reactRouter;if(!g)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!S)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(g.isInitialized())return null;const{createRoutesFromChildren:k,matchRoutes:C,useLocation:y,useNavigationType:E}=S;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&g.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:[g.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:k,matchRoutes:C,useEffect:f.useEffect,useLocation:y,useNavigationType:E}),...r||[]],release:d,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:i,tracesSampleRate:o||1}),null},me=()=>(f.useEffect(()=>{if(L)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),ye="user",he=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:i,localStorageKeys:c}=f.useContext(A),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,d=n?.localStorageKey||c?.user||ye;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[s,v]=f.useState(null),{useLocation:g,Navigate:S,Outlet:k}=u,C=g(),y=f.useRef(!1),E=typeof r=="function"?r():!!r,j=typeof E=="boolean"?E:E?.isLogged;return f.useEffect(()=>{y.current||(y.current=!0,l.interceptors.response.use(h=>h,async h=>(typeof h=="object"&&h&&"response"in h&&h.response&&typeof h.response=="object"&&"status"in h.response&&h.response&&typeof h.response=="object"&&"status"in h.response&&h?.response?.status===401&&(l.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(d),v(a)),Promise.reject(h))))},[l.defaults.headers.common,l.interceptors.response,d,a]),j&&!s?T.jsx(f.Suspense,{fallback:e,children:C.state?.from?.state&&C.state?.from?.pathname===o?T.jsx(S,{to:C.state.from.state.from.pathname+C.state.from.state.from.search,replace:!0}):T.jsx(k,{})}):T.jsx(S,{to:o+C.search,state:{from:C},replace:!0})},ve=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)}},Ee=({autoUpdate:e,renderDialog:r,clearCachesOnReload:o})=>{const a=f.useRef(null),[n,i]=f.useState(!1),c=f.useCallback(()=>{a.current&&a.current.postMessage({type:"SKIP_WAITING"}),o&&localStorage.setItem("tracktor_clear_caches","1"),window.location.reload()},[o]);f.useEffect(()=>{localStorage.getItem("tracktor_clear_caches")==="1"&&(localStorage.removeItem("tracktor_clear_caches"),ve().catch(console.error))},[]);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,d;const s=g=>{g&&navigator.serviceWorker.controller&&(a.current=g,i(!0))},v=()=>{const g=l?.installing;g&&(d=()=>{g.state==="installed"&&s(g)},g.addEventListener("statechange",d))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(s(l.waiting),l.addEventListener("updatefound",v))})().catch(console.error),()=>{l?.removeEventListener("updatefound",v),d&&l?.installing&&l.installing.removeEventListener("statechange",d)}},[]),f.useEffect(()=>{n&&e&&c()},[e,n,c]),f.useEffect(()=>{n&&!e&&!r&&u()},[r,u,n,e]),n&&!e&&r?r(c):null},we=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),be=e=>{const r=e.split(/[/\\]/).pop()||"";return r.substring(0,r.lastIndexOf("."))},Re=e=>{const a=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 a.charAt(0).toLowerCase()+a.slice(1)},_e=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Se=(e,r,o,a)=>{const n=Re(r),i=we(o),c=`${n}${i}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},Ae=(e,r)=>{const o={};return e?.forEach(a=>{o[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),r?.filter(a=>!o[a]).forEach(a=>{o[a]={query:{useQuery:!0}}}),Object.keys(o).length?o:void 0},Ce=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:n,useInfiniteIds:i,useQueryIds:c,input:u="./openapi.json",customAxiosInstancePath:l,overrideApiName:d}=a||{},s=d||_e(u),v=l||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...o,[s]:{input:u,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(i?.length||c?.length)&&{operations:Ae(i,c)},header:g=>["Generated by orval 🍺",...g.title?[g.title]:[],...g.description?[g.description]:[]],mutator:{name:be(v),path:v},operationName:(g,S,k)=>Se(g,S,k,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${s}/model`,target:n?.target||`src/api/${s}/services/api.ts`,...n}}}},{}),je=e=>e&&typeof e=="function",Pe=e=>e&&typeof e=="function",Te=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=f.useContext(A),i=a?.QueryClient||n?.reactQuery?.QueryClient,c=a?.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(!je(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Pe(i))throw new Error("Provided QueryClient dependencies are not valid.");const u=new i({defaultOptions:{mutations:{...o},queries:{getNextPageParam:(l,d,s)=>l.length+(s||0),refetchOnWindowFocus:!1,retry:3,...r}}});return T.jsx(c,{client:u,children:e})},K=({library:e,date:r,format:o="ll"})=>e(r).format(o),B=(e,r)=>{const{fractionDigits:o=0,metric:a="km",spacingBetween:n=!0}=r||{},i=Number(e),c=n?" ":"";return Number.isNaN(i)?`0${c}${a}`:`${i.toFixed(o)}${c}${a}`},H=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(o=>o.length>0?o.charAt(0).toUpperCase()+o.slice(1):o).join(" "),ke=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Ie=({path:e,size:r,apiURL:o})=>{if(!e)return"";const a=ke(e),n=`${o}${a}`,i=n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof r=="number"&&i?`${n.replace("/files",`/thumbs/${r}`)}`:n},Oe=e=>{const{apiURL:r,libraries:o}=f.useContext(A),a=e?.dayjs||o?.dayjs;return{dateAdapter:(c,u)=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return K({date:c,format:u,library:a})},distanceAdapter:B,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:Ie({apiURL:r,path:c,size:u})},worksiteNameAdapter:H}},xe=e=>{const{libraries:r}=f.useContext(A),o=e?.axios||r?.axios,a=e?.localStorageKey||"user";if(!o)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const n=f.useCallback(({tokenType:c,accessToken:u})=>{o.defaults.headers.common.Authorization=`${c} ${u}`},[o.defaults.headers.common]),i=()=>{o.defaults.headers.common.Authorization=null};return f.useEffect(()=>{if(L)return;const c=({newValue:u,key:l})=>{if(l===a&&u)try{const{accessToken:d,tokenType:s}=JSON.parse(u);n({accessToken:d,tokenType:s})}catch(d){console.error("Failed to parse newValue from localStorage:",d)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}},[a,n]),{clearAuthenticationToken:i,setAuthenticationToken:n}},D=(e,r)=>r==="short"?e.split("-")[0]:e,Ne=(e,r="full")=>{const[o,a]=f.useState(()=>{const n=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,D(n,r)});return f.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(D(e.language,r));const n=i=>{a(D(i,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),o},Le="tracktor.filter",Fe={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},X=(e,r,o)=>`${o}_${e}=>${r}`,De=e=>e.reduce((r,o)=>{const a=localStorage.getItem(o);if(a)try{const n=JSON.parse(a),i=Object.keys(n)?.[0];i&&(r[i]=Object.values(n)?.[0])}catch{}return r},{}),Ye=e=>{const{libraries:r,localStorageKeys:o}=f.useContext(A),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[i,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,l]=f.useState({}),d=o?.filter||Le,s=e?.syncWithUrl===void 0?!0:e?.syncWithUrl;if(L)return Fe;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const v=()=>Object.keys(localStorage).filter(y=>y.startsWith(d)&&y.endsWith(e?.pathname||n)),g=(y,E,j=!0)=>{const h=X(y,e?.pathname||n,d);if(!E||Array.isArray(E)&&!E.length){s?(i.delete(y),c(i)):l(b=>{const P={...b};return delete P[y],P}),localStorage.removeItem(h);return}j&&E&&localStorage.setItem(h,JSON.stringify({...i,[y]:E})),s&&E?(i.set(y,JSON.stringify(E)),c(i)):!s&&E&&l(b=>({...b,[y]:E}))};return{getFilter:(y,E)=>{if(!s){const b=u[y];if(b!==void 0)return b}if(s){const b=i.get(y);if(b)try{return JSON.parse(b)}catch{return b}}const j=X(y,e?.pathname||n,d),h=localStorage.getItem(j);if(h)try{const b=JSON.parse(h)[y];return!s&&b!==void 0&&l(P=>({...P,[y]:b})),b}catch{}return E},getFilters:()=>{const y=v(),E=De(y);if(s){const j=Object.fromEntries(i.entries());return{...E,...j}}return{...E,...u}},handleFilter:(y,E)=>(j,h)=>{if(h||Array.isArray(h)&&h.length===0){const b=E||"value",P=typeof h=="object"&&b in h?h[b]:h;g(y,P);return}g(y,void 0)},setFilter:g}},We=({data:e,fetchNextPage:r,isFetchingNextPage:o,isInitialLoading:a,isLoading:n,enabled:i=!0})=>{const c=f.useCallback(async l=>{o||!i||await r({pageParam:l?.pageParam||l.visibleRowsCount})},[i,r,o]),u=f.useMemo(()=>{if(e)return e.pages.reduce((l,d)=>[...l,...d],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:o||n,loadingVariant:a?"skeleton":"linear-progress",rows:u}},ze=e=>{const{libraries:r}=f.useContext(A),o=e?.i18||r?.i18,a=e?.i18?.translateFunction||r?.i18?.translateFunction,n=o?.i18next?.t||a||(d=>d),{unknownErrorTranslationKey:i="error.unknownError"}=e||{},c=n(i),u=f.useCallback(d=>{if(d&&typeof d=="object"&&"response"in d){const{response:s}=d||{};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:v}=s.data;if(Array.isArray(v)&&v.length>0&&typeof v[0]=="object"&&v[0]!==null&&"msg"in v[0]){const{msg:g}=v[0];if(typeof g=="string")return String(g)}}}return d instanceof Error?d.message:c},[c]);return{getErrorCode:f.useCallback(d=>{const{response:s}=d||{};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=le,m.InitializeAxiosConfig=de,m.InitializeDaysJSConfig=fe,m.InitializeI18nConfig=pe,m.InitializeSentryConfig=ge,m.InjectDependenciesContext=A,m.InjectDependenciesProvider=ce,m.MaskTextField=ie,m.PreloadErrorHandler=me,m.QueryClientProviderWithConfig=Te,m.RequireAuth=he,m.UpdateNotifier=Ee,m.axiosCustomInstance=ne,m.dateAdapter=K,m.distanceAdapter=B,m.getOrvalConfig=Ce,m.useAdapter=Oe,m.useAuth=xe,m.useCurrentLanguage=Ne,m.useFilters=Ye,m.useInfiniteDataGrid=We,m.useResponseError=ze,m.worksiteNameAdapter=H,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
|