@tracktor/shared-module 2.18.0 → 2.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,4 +3,10 @@
3
3
  ## [2.18.0] - 2025-09-30
4
4
 
5
5
  ### ✨ Features
6
- - introduce `AppUpdateHandler` component to monitor Service Worker updates and prompt users when a new version of the app is available
6
+ - introduce `UpdateNotifier` component to monitor Service Worker updates and prompt users when a new version of the app is available
7
+
8
+
9
+ ## [2.18.1] - 2025-10-01
10
+
11
+ ### ✨ Features
12
+ - `UpdateNotifier`: add `autoUpdate` prop to automatically reload the app when an update is detected, bypassing confirmation dialogs and custom UI.
@@ -1,5 +1,10 @@
1
1
  import { ReactNode } from 'react';
2
2
  export interface UpdateNotifierProps {
3
+ /**
4
+ * If true, automatically reloads the app when an update is detected,
5
+ * bypassing both window.confirm and custom UI.
6
+ */
7
+ autoUpdate?: boolean;
3
8
  /**
4
9
  * If true, clears all CacheStorage entries before reloading.
5
10
  * Default false to avoid wiping host-origin caches unexpectedly.
@@ -23,6 +28,8 @@ export interface UpdateNotifierProps {
23
28
  * and the app reloads automatically after user confirmation.
24
29
  * - If `clearCachesOnReload` is true, all entries in CacheStorage will be cleared before reloading
25
30
  * (use with caution, as this removes *all* caches for the current origin).
31
+ * - If `autoUpdate` is true, the app will reload automatically when an update is detected,
32
+ * bypassing both `window.confirm` and any custom UI.
26
33
  *
27
34
  * Usage:
28
35
  * Place <UpdateNotifier /> once at the root of your app (e.g., in App.tsx).
@@ -41,5 +48,5 @@ export interface UpdateNotifierProps {
41
48
  * />
42
49
  * ```
43
50
  */
44
- declare const UpdateNotifier: ({ renderDialog, clearCachesOnReload }: UpdateNotifierProps) => ReactNode;
51
+ declare const UpdateNotifier: ({ autoUpdate, renderDialog, clearCachesOnReload }: UpdateNotifierProps) => ReactNode;
45
52
  export default UpdateNotifier;
package/dist/main.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import ee from "axios";
2
- import fe, { createContext as pe, useMemo as G, useContext as j, useState as W, useRef as ae, useEffect as C, Suspense as ge, useCallback as L } from "react";
3
- const De = (e, r) => {
2
+ import fe, { createContext as pe, useMemo as G, useContext as j, useState as W, useRef as ae, useEffect as k, Suspense as ge, useCallback as L } from "react";
3
+ const De = (e, n) => {
4
4
  const o = ee.CancelToken.source(), a = ee({
5
5
  ...e,
6
- ...r,
6
+ ...n,
7
7
  cancelToken: o.token
8
- }).then(({ data: n }) => n);
8
+ }).then(({ data: r }) => r);
9
9
  return a.cancel = () => {
10
10
  o.cancel("Query was cancelled");
11
11
  }, a;
@@ -24,23 +24,23 @@ var te;
24
24
  function me() {
25
25
  if (te) return N;
26
26
  te = 1;
27
- var e = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
28
- function o(a, n, i) {
27
+ var e = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
28
+ function o(a, r, i) {
29
29
  var c = null;
30
- if (i !== void 0 && (c = "" + i), n.key !== void 0 && (c = "" + n.key), "key" in n) {
30
+ if (i !== void 0 && (c = "" + i), r.key !== void 0 && (c = "" + r.key), "key" in r) {
31
31
  i = {};
32
- for (var l in n)
33
- l !== "key" && (i[l] = n[l]);
34
- } else i = n;
35
- return n = i.ref, {
32
+ for (var d in r)
33
+ d !== "key" && (i[d] = r[d]);
34
+ } else i = r;
35
+ return r = i.ref, {
36
36
  $$typeof: e,
37
37
  type: a,
38
38
  key: c,
39
- ref: n !== void 0 ? n : null,
39
+ ref: r !== void 0 ? r : null,
40
40
  props: i
41
41
  };
42
42
  }
43
- return N.Fragment = r, N.jsx = o, N.jsxs = o, N;
43
+ return N.Fragment = n, N.jsx = o, N.jsxs = o, N;
44
44
  }
45
45
  var F = {};
46
46
  /**
@@ -84,7 +84,7 @@ function ye() {
84
84
  return (t.displayName || "Context") + ".Provider";
85
85
  case _:
86
86
  return (t._context.displayName || "Context") + ".Consumer";
87
- case v:
87
+ case w:
88
88
  var f = t.render;
89
89
  return t = t.displayName, t || (t = f.displayName || f.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
90
90
  case se:
@@ -98,24 +98,24 @@ function ye() {
98
98
  }
99
99
  return null;
100
100
  }
101
- function r(t) {
101
+ function n(t) {
102
102
  return "" + t;
103
103
  }
104
104
  function o(t) {
105
105
  try {
106
- r(t);
106
+ n(t);
107
107
  var f = !1;
108
108
  } catch {
109
109
  f = !0;
110
110
  }
111
111
  if (f) {
112
112
  f = console;
113
- var h = f.error, E = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
114
- return h.call(
113
+ var v = f.error, E = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
114
+ return v.call(
115
115
  f,
116
116
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
117
117
  E
118
- ), r(t);
118
+ ), n(t);
119
119
  }
120
120
  }
121
121
  function a(t) {
@@ -129,8 +129,8 @@ function ye() {
129
129
  return "<...>";
130
130
  }
131
131
  }
132
- function n() {
133
- var t = U.A;
132
+ function r() {
133
+ var t = z.A;
134
134
  return t === null ? null : t.getOwner();
135
135
  }
136
136
  function i() {
@@ -143,34 +143,34 @@ function ye() {
143
143
  }
144
144
  return t.key !== void 0;
145
145
  }
146
- function l(t, f) {
147
- function h() {
146
+ function d(t, f) {
147
+ function v() {
148
148
  q || (q = !0, console.error(
149
149
  "%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)",
150
150
  f
151
151
  ));
152
152
  }
153
- h.isReactWarning = !0, Object.defineProperty(t, "key", {
154
- get: h,
153
+ v.isReactWarning = !0, Object.defineProperty(t, "key", {
154
+ get: v,
155
155
  configurable: !0
156
156
  });
157
157
  }
158
- function u() {
158
+ function l() {
159
159
  var t = e(this.type);
160
160
  return B[t] || (B[t] = !0, console.error(
161
161
  "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."
162
162
  )), t = this.props.ref, t !== void 0 ? t : null;
163
163
  }
164
- function d(t, f, h, E, x, T, Q, V) {
165
- return h = T.ref, t = {
164
+ function u(t, f, v, E, x, T, Q, V) {
165
+ return v = T.ref, t = {
166
166
  $$typeof: S,
167
167
  type: t,
168
168
  key: f,
169
169
  props: T,
170
170
  _owner: x
171
- }, (h !== void 0 ? h : null) !== null ? Object.defineProperty(t, "ref", {
171
+ }, (v !== void 0 ? v : null) !== null ? Object.defineProperty(t, "ref", {
172
172
  enumerable: !1,
173
- get: u
173
+ get: l
174
174
  }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
175
175
  configurable: !1,
176
176
  enumerable: !1,
@@ -193,19 +193,19 @@ function ye() {
193
193
  value: V
194
194
  }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
195
195
  }
196
- function s(t, f, h, E, x, T, Q, V) {
196
+ function s(t, f, v, E, x, T, Q, V) {
197
197
  var R = f.children;
198
198
  if (R !== void 0)
199
199
  if (E)
200
200
  if (ue(R)) {
201
201
  for (E = 0; E < R.length; E++)
202
- g(R[E]);
202
+ h(R[E]);
203
203
  Object.freeze && Object.freeze(R);
204
204
  } else
205
205
  console.error(
206
206
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
207
207
  );
208
- else g(R);
208
+ else h(R);
209
209
  if (K.call(f, "key")) {
210
210
  R = e(t);
211
211
  var I = Object.keys(f).filter(function(de) {
@@ -224,63 +224,63 @@ React keys must be passed directly to JSX without using spread:
224
224
  R
225
225
  ), Z[R + E] = !0);
226
226
  }
227
- if (R = null, h !== void 0 && (o(h), R = "" + h), c(f) && (o(f.key), R = "" + f.key), "key" in f) {
228
- h = {};
227
+ if (R = null, v !== void 0 && (o(v), R = "" + v), c(f) && (o(f.key), R = "" + f.key), "key" in f) {
228
+ v = {};
229
229
  for (var M in f)
230
- M !== "key" && (h[M] = f[M]);
231
- } else h = f;
232
- return R && l(
233
- h,
230
+ M !== "key" && (v[M] = f[M]);
231
+ } else v = f;
232
+ return R && d(
233
+ v,
234
234
  typeof t == "function" ? t.displayName || t.name || "Unknown" : t
235
- ), d(
235
+ ), u(
236
236
  t,
237
237
  R,
238
238
  T,
239
239
  x,
240
- n(),
241
- h,
240
+ r(),
241
+ v,
242
242
  Q,
243
243
  V
244
244
  );
245
245
  }
246
- function g(t) {
246
+ function h(t) {
247
247
  typeof t == "object" && t !== null && t.$$typeof === S && t._store && (t._store.validated = 1);
248
248
  }
249
- var w = fe, S = Symbol.for("react.transitional.element"), O = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), _ = Symbol.for("react.consumer"), p = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"), ie = Symbol.for("react.suspense_list"), se = Symbol.for("react.memo"), J = Symbol.for("react.lazy"), ce = Symbol.for("react.activity"), le = Symbol.for("react.client.reference"), U = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, K = Object.prototype.hasOwnProperty, ue = Array.isArray, z = console.createTask ? console.createTask : function() {
249
+ var g = fe, S = Symbol.for("react.transitional.element"), O = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), _ = Symbol.for("react.consumer"), p = Symbol.for("react.context"), w = Symbol.for("react.forward_ref"), P = Symbol.for("react.suspense"), ie = Symbol.for("react.suspense_list"), se = Symbol.for("react.memo"), J = Symbol.for("react.lazy"), ce = Symbol.for("react.activity"), le = Symbol.for("react.client.reference"), z = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, K = Object.prototype.hasOwnProperty, ue = Array.isArray, U = console.createTask ? console.createTask : function() {
250
250
  return null;
251
251
  };
252
- w = {
252
+ g = {
253
253
  "react-stack-bottom-frame": function(t) {
254
254
  return t();
255
255
  }
256
256
  };
257
- var q, B = {}, H = w["react-stack-bottom-frame"].bind(
258
- w,
257
+ var q, B = {}, H = g["react-stack-bottom-frame"].bind(
258
+ g,
259
259
  i
260
- )(), X = z(a(i)), Z = {};
261
- F.Fragment = b, F.jsx = function(t, f, h, E, x) {
262
- var T = 1e4 > U.recentlyCreatedOwnerStacks++;
260
+ )(), X = U(a(i)), Z = {};
261
+ F.Fragment = b, F.jsx = function(t, f, v, E, x) {
262
+ var T = 1e4 > z.recentlyCreatedOwnerStacks++;
263
263
  return s(
264
264
  t,
265
265
  f,
266
- h,
266
+ v,
267
267
  !1,
268
268
  E,
269
269
  x,
270
270
  T ? Error("react-stack-top-frame") : H,
271
- T ? z(a(t)) : X
271
+ T ? U(a(t)) : X
272
272
  );
273
- }, F.jsxs = function(t, f, h, E, x) {
274
- var T = 1e4 > U.recentlyCreatedOwnerStacks++;
273
+ }, F.jsxs = function(t, f, v, E, x) {
274
+ var T = 1e4 > z.recentlyCreatedOwnerStacks++;
275
275
  return s(
276
276
  t,
277
277
  f,
278
- h,
278
+ v,
279
279
  !0,
280
280
  E,
281
281
  x,
282
282
  T ? Error("react-stack-top-frame") : H,
283
- T ? z(a(t)) : X
283
+ T ? U(a(t)) : X
284
284
  );
285
285
  };
286
286
  }()), F;
@@ -289,44 +289,44 @@ var ne;
289
289
  function he() {
290
290
  return ne || (ne = 1, process.env.NODE_ENV === "production" ? D.exports = me() : D.exports = ye()), D.exports;
291
291
  }
292
- var k = he();
293
- const A = pe({}), Ye = ({ children: e, apiURL: r, libraries: o, localStorageKeys: a }) => {
294
- const n = G(
292
+ var C = he();
293
+ const A = pe({}), Ye = ({ children: e, apiURL: n, libraries: o, localStorageKeys: a }) => {
294
+ const r = G(
295
295
  () => ({
296
- apiURL: r,
296
+ apiURL: n,
297
297
  libraries: o,
298
298
  localStorageKeys: a
299
299
  }),
300
- [r, o, a]
300
+ [n, o, a]
301
301
  );
302
- return /* @__PURE__ */ k.jsx(A.Provider, { value: n, children: e });
303
- }, ve = "user", We = ({ Fallback: e, isLogged: r, loginPath: o = "/login", redirect401Path: a = "/login", ...n }) => {
304
- const { libraries: i, localStorageKeys: c } = j(A), l = n?.reactRouter || i?.reactRouter, u = n?.axios || i?.axios, d = n?.localStorageKey || c?.user || ve;
305
- if (!l)
302
+ return /* @__PURE__ */ C.jsx(A.Provider, { value: r, children: e });
303
+ }, ve = "user", We = ({ Fallback: e, isLogged: n, loginPath: o = "/login", redirect401Path: a = "/login", ...r }) => {
304
+ const { libraries: i, localStorageKeys: c } = j(A), d = r?.reactRouter || i?.reactRouter, l = r?.axios || i?.axios, u = r?.localStorageKey || c?.user || ve;
305
+ if (!d)
306
306
  throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
307
- const [s, g] = W(null), { useLocation: w, Navigate: S, Outlet: O } = l, b = w(), m = ae(!1), y = typeof r == "function" ? r() : !!r, _ = typeof y == "boolean" ? y : y?.isLogged;
308
- return C(() => {
309
- m.current || (m.current = !0, u.interceptors.response.use(
307
+ const [s, h] = W(null), { useLocation: g, Navigate: S, Outlet: O } = d, b = g(), m = ae(!1), y = typeof n == "function" ? n() : !!n, _ = typeof y == "boolean" ? y : y?.isLogged;
308
+ return k(() => {
309
+ m.current || (m.current = !0, l.interceptors.response.use(
310
310
  (p) => p,
311
- async (p) => (typeof p == "object" && p && "response" in p && p.response && typeof p.response == "object" && "status" in p.response && p.response && typeof p.response == "object" && "status" in p.response && p?.response?.status === 401 && (u.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(d), g(a)), Promise.reject(p))
311
+ async (p) => (typeof p == "object" && p && "response" in p && p.response && typeof p.response == "object" && "status" in p.response && p.response && typeof p.response == "object" && "status" in p.response && p?.response?.status === 401 && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(u), h(a)), Promise.reject(p))
312
312
  ));
313
- }, [u.defaults.headers.common, u.interceptors.response, d, a]), _ && !s ? /* @__PURE__ */ k.jsx(ge, { fallback: e, children: b.state?.from?.state && b.state?.from?.pathname === o ? /* @__PURE__ */ k.jsx(S, { to: b.state.from.state.from.pathname + b.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ k.jsx(O, {}) }) : /* @__PURE__ */ k.jsx(S, { to: o + b.search, state: { from: b }, replace: !0 });
314
- }, Ue = ({ data: e, ...r }) => {
315
- const { libraries: o } = j(A), a = r?.reactRouter || o?.reactRouter, n = r?.gtm || o?.gtm;
313
+ }, [l.defaults.headers.common, l.interceptors.response, u, a]), _ && !s ? /* @__PURE__ */ C.jsx(ge, { fallback: e, children: b.state?.from?.state && b.state?.from?.pathname === o ? /* @__PURE__ */ C.jsx(S, { to: b.state.from.state.from.pathname + b.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ C.jsx(O, {}) }) : /* @__PURE__ */ C.jsx(S, { to: o + b.search, state: { from: b }, replace: !0 });
314
+ }, ze = ({ data: e, ...n }) => {
315
+ const { libraries: o } = j(A), a = n?.reactRouter || o?.reactRouter, r = n?.gtm || o?.gtm;
316
316
  if (!a)
317
317
  throw new Error(
318
318
  "React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView."
319
319
  );
320
- if (!n)
320
+ if (!r)
321
321
  throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
322
- const { useGoogleTagManager: i } = n, { useLocation: c, Outlet: l } = a, { pathname: u } = c(), { sendEvent: d } = i();
323
- return C(() => {
324
- d({
322
+ const { useGoogleTagManager: i } = r, { useLocation: c, Outlet: d } = a, { pathname: l } = c(), { sendEvent: u } = i();
323
+ return k(() => {
324
+ u({
325
325
  event: "pageView",
326
- pathname: u,
326
+ pathname: l,
327
327
  ...e
328
328
  });
329
- }, [e, u, d]), /* @__PURE__ */ k.jsx(l, {});
329
+ }, [e, l, u]), /* @__PURE__ */ C.jsx(d, {});
330
330
  }, $ = (() => {
331
331
  try {
332
332
  return typeof global == "object" && global !== null && ("HermesInternal" in global || // Hermes JS engine
@@ -335,29 +335,29 @@ const A = pe({}), Ye = ({ children: e, apiURL: r, libraries: o, localStorageKeys
335
335
  } catch {
336
336
  return !1;
337
337
  }
338
- })(), we = "user", ze = ({
338
+ })(), we = "user", Ue = ({
339
339
  tokenTypeKey: e = "tokenType",
340
- tokenKey: r = "accessToken",
340
+ tokenKey: n = "accessToken",
341
341
  postContentType: o = "application/json",
342
342
  ...a
343
343
  }) => {
344
- const { apiURL: n = a.apiURL, libraries: i, localStorageKeys: c } = j(A), l = a?.userLocalStorageKey || c?.user || we, u = a?.axios || i?.axios;
345
- if (!u)
344
+ const { apiURL: r = a.apiURL, libraries: i, localStorageKeys: c } = j(A), d = a?.userLocalStorageKey || c?.user || we, l = a?.axios || i?.axios;
345
+ if (!l)
346
346
  throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
347
- if (!u?.defaults || $)
347
+ if (!l?.defaults || $)
348
348
  return null;
349
349
  if (typeof window < "u" && window.localStorage) {
350
- const d = localStorage.getItem(l), s = d ? JSON.parse(d) : null, g = s?.[e] ? s[e] : null, w = s?.[r] ? s[r] : null, S = d ? `${g} ${w}` : null;
351
- S && (u.defaults.headers.common.Authorization = S);
350
+ const u = localStorage.getItem(d), s = u ? JSON.parse(u) : null, h = s?.[e] ? s[e] : null, g = s?.[n] ? s[n] : null, S = u ? `${h} ${g}` : null;
351
+ S && (l.defaults.headers.common.Authorization = S);
352
352
  }
353
- return u.defaults.baseURL = n, u.defaults.headers.post["Content-Type"] = o, null;
354
- }, Qe = ({ debug: e, resources: r, ...o }) => {
355
- const { libraries: a } = j(A), n = o?.i18 || a?.i18, { i18next: i, initReactI18next: c, languageDetector: l } = n || {};
353
+ return l.defaults.baseURL = r, l.defaults.headers.post["Content-Type"] = o, null;
354
+ }, Qe = ({ debug: e, resources: n, ...o }) => {
355
+ const { libraries: a } = j(A), r = o?.i18 || a?.i18, { i18next: i, initReactI18next: c, languageDetector: d } = r || {};
356
356
  if ($)
357
357
  return null;
358
- if (!n)
358
+ if (!r)
359
359
  throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
360
- return i?.isInitialized || (i.use(l).use(c).init({
360
+ return i?.isInitialized || (i.use(d).use(c).init({
361
361
  debug: e,
362
362
  fallbackLng: "en",
363
363
  interpolation: {
@@ -368,38 +368,38 @@ const A = pe({}), Ye = ({ children: e, apiURL: r, libraries: o, localStorageKeys
368
368
  bindI18n: "languageChanged loaded",
369
369
  useSuspense: !0
370
370
  },
371
- resources: r,
371
+ resources: n,
372
372
  returnNull: !1
373
373
  }).then(() => {
374
374
  document.documentElement.lang !== i.resolvedLanguage && i.resolvedLanguage && document.documentElement.setAttribute("lang", i.resolvedLanguage);
375
- }), i.on("languageChanged", (u) => {
376
- document.documentElement.setAttribute("lang", u);
375
+ }), i.on("languageChanged", (l) => {
376
+ document.documentElement.setAttribute("lang", l);
377
377
  })), null;
378
378
  }, Ve = ({
379
379
  dsn: e,
380
- integrations: r,
380
+ integrations: n,
381
381
  tracesSampleRate: o,
382
382
  replaysSessionSampleRate: a,
383
- replaysOnErrorSampleRate: n,
383
+ replaysOnErrorSampleRate: r,
384
384
  tracePropagationTargets: i,
385
385
  ignoreErrors: c,
386
- debug: l,
387
- environment: u,
388
- release: d,
386
+ debug: d,
387
+ environment: l,
388
+ release: u,
389
389
  ...s
390
390
  }) => {
391
- const { libraries: g } = j(A), w = s?.sentry || g?.sentry, S = s?.reactRouter || g?.reactRouter;
392
- if (!w)
391
+ const { libraries: h } = j(A), g = s?.sentry || h?.sentry, S = s?.reactRouter || h?.reactRouter;
392
+ if (!g)
393
393
  throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
394
394
  if (!S)
395
395
  throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
396
- if (w.isInitialized())
396
+ if (g.isInitialized())
397
397
  return null;
398
398
  const { createRoutesFromChildren: O, matchRoutes: b, useLocation: m, useNavigationType: y } = S;
399
- return (l || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && w.init({
400
- debug: l,
399
+ return (d || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && g.init({
400
+ debug: d,
401
401
  dsn: e,
402
- environment: u || "production",
402
+ environment: l || "production",
403
403
  ignoreErrors: [
404
404
  ...c || [],
405
405
  /dynamically imported module/,
@@ -410,48 +410,48 @@ const A = pe({}), Ye = ({ children: e, apiURL: r, libraries: o, localStorageKeys
410
410
  /vite:preloadError/
411
411
  ],
412
412
  integrations: [
413
- w.reactRouterV6BrowserTracingIntegration({
413
+ g.reactRouterV6BrowserTracingIntegration({
414
414
  createRoutesFromChildren: O,
415
415
  matchRoutes: b,
416
- useEffect: C,
416
+ useEffect: k,
417
417
  useLocation: m,
418
418
  useNavigationType: y
419
419
  }),
420
- ...r || []
420
+ ...n || []
421
421
  ],
422
- release: d,
423
- replaysOnErrorSampleRate: n || 1,
422
+ release: u,
423
+ replaysOnErrorSampleRate: r || 1,
424
424
  replaysSessionSampleRate: a || 0.1,
425
425
  tracePropagationTargets: i,
426
426
  tracesSampleRate: o || 1
427
427
  }), null;
428
- }, Me = ({ IMaskMixin: e, ...r }) => {
428
+ }, Me = ({ IMaskMixin: e, ...n }) => {
429
429
  const o = G(
430
430
  // eslint-disable-next-line react/jsx-props-no-spreading
431
- () => e(({ TextField: a, ...n }) => /* @__PURE__ */ k.jsx(a, { ...n })),
431
+ () => e(({ TextField: a, ...r }) => /* @__PURE__ */ C.jsx(a, { ...r })),
432
432
  [e]
433
433
  );
434
- return /* @__PURE__ */ k.jsx(o, { ...r });
435
- }, Ge = ({ language: e, ...r }) => {
436
- const { libraries: o } = j(A), a = r?.dayjs || o?.dayjs, n = r?.plugin || o?.dayjsPlugin;
434
+ return /* @__PURE__ */ C.jsx(o, { ...n });
435
+ }, Ge = ({ language: e, ...n }) => {
436
+ const { libraries: o } = j(A), a = n?.dayjs || o?.dayjs, r = n?.plugin || o?.dayjsPlugin;
437
437
  if (!a)
438
438
  throw new Error(
439
439
  "Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig."
440
440
  );
441
- return C(() => {
441
+ return k(() => {
442
442
  (async () => {
443
443
  const c = e || navigator.language?.slice(0, 2) || "en";
444
- n && n.forEach((l) => {
445
- l && a.extend(l);
444
+ r && r.forEach((d) => {
445
+ d && a.extend(d);
446
446
  }), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), a.locale(c);
447
447
  })().then();
448
- }, [a, n, e]), null;
449
- }, Je = () => (C(() => {
448
+ }, [a, r, e]), null;
449
+ }, Je = () => (k(() => {
450
450
  if ($)
451
451
  return;
452
- const e = (r) => {
452
+ const e = (n) => {
453
453
  try {
454
- r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), window.location.reload();
454
+ n.preventDefault(), n.stopPropagation(), n.stopImmediatePropagation(), window.location.reload();
455
455
  } catch {
456
456
  }
457
457
  };
@@ -462,42 +462,44 @@ const A = pe({}), Ye = ({ children: e, apiURL: r, libraries: o, localStorageKeys
462
462
  if ("caches" in window)
463
463
  try {
464
464
  const e = await caches.keys();
465
- await Promise.all(e.map((r) => caches.delete(r)));
465
+ await Promise.all(e.map((n) => caches.delete(n)));
466
466
  } catch (e) {
467
467
  console.error("Failed to clear caches:", e);
468
468
  }
469
- }, Ke = ({ renderDialog: e, clearCachesOnReload: r = !1 }) => {
470
- const o = ae(null), [a, n] = W(!1), i = L(async () => {
471
- o.current && o.current.postMessage({ type: "SKIP_WAITING" }), r && await Ee(), window.location.reload();
472
- }, [r]), c = L(async () => {
473
- window.confirm("A new version is available. The app will reload now.") && await i();
474
- }, [i]);
475
- return C(() => {
469
+ }, Ke = ({ autoUpdate: e, renderDialog: n, clearCachesOnReload: o }) => {
470
+ const a = ae(null), [r, i] = W(!1), c = L(async () => {
471
+ a.current && a.current.postMessage({ type: "SKIP_WAITING" }), o && await Ee(), window.location.reload();
472
+ }, [o]), d = L(async () => {
473
+ window.confirm("A new version is available. The app will reload now.") && await c();
474
+ }, [c]);
475
+ return k(() => {
476
476
  if (!("serviceWorker" in navigator)) return;
477
477
  let l, u;
478
- const d = (g) => {
479
- g && navigator.serviceWorker.controller && (o.current = g, n(!0));
480
- }, s = () => {
478
+ const s = (g) => {
479
+ g && navigator.serviceWorker.controller && (a.current = g, i(!0));
480
+ }, h = () => {
481
481
  const g = l?.installing;
482
482
  g && (u = () => {
483
- g.state === "installed" && d(g);
483
+ g.state === "installed" && s(g);
484
484
  }, g.addEventListener("statechange", u));
485
485
  };
486
486
  return (async () => {
487
- l = await navigator.serviceWorker.getRegistration(), l && (d(l.waiting), l.addEventListener("updatefound", s));
487
+ l = await navigator.serviceWorker.getRegistration(), l && (s(l.waiting), l.addEventListener("updatefound", h));
488
488
  })().catch(console.error), () => {
489
- l?.removeEventListener("updatefound", s), u && l?.installing && l.installing.removeEventListener("statechange", u);
489
+ l?.removeEventListener("updatefound", h), u && l?.installing && l.installing.removeEventListener("statechange", u);
490
490
  };
491
- }, []), C(() => {
492
- a && !e && c().catch(console.error);
493
- }, [e, c, a]), a && e ? e(i) : null;
491
+ }, []), k(() => {
492
+ r && e && c().catch(console.error);
493
+ }, [e, r, c]), k(() => {
494
+ r && !e && !n && d().catch(console.error);
495
+ }, [n, d, r, e]), r && !e && n ? n(c) : null;
494
496
  }, Re = (e) => e && typeof e == "function", be = (e) => e && typeof e == "function", qe = ({
495
497
  children: e,
496
- defaultQueriesOptions: r,
498
+ defaultQueriesOptions: n,
497
499
  defaultMutationsOptions: o,
498
500
  ...a
499
501
  }) => {
500
- const { libraries: n } = j(A), i = a?.QueryClient || n?.reactQuery?.QueryClient, c = a?.QueryClientProvider || n?.reactQuery?.QueryClientProvider;
502
+ const { libraries: r } = j(A), i = a?.QueryClient || r?.reactQuery?.QueryClient, c = a?.QueryClientProvider || r?.reactQuery?.QueryClientProvider;
501
503
  if (!i)
502
504
  throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
503
505
  if (!c)
@@ -506,25 +508,25 @@ const A = pe({}), Ye = ({ children: e, apiURL: r, libraries: o, localStorageKeys
506
508
  throw new Error("Provided QueryClientProvider dependencies are not valid.");
507
509
  if (!be(i))
508
510
  throw new Error("Provided QueryClient dependencies are not valid.");
509
- const l = new i({
511
+ const d = new i({
510
512
  defaultOptions: {
511
513
  mutations: {
512
514
  ...o
513
515
  },
514
516
  queries: {
515
- getNextPageParam: (u, d, s) => u.length + (s || 0),
517
+ getNextPageParam: (l, u, s) => l.length + (s || 0),
516
518
  refetchOnWindowFocus: !1,
517
519
  retry: 3,
518
- ...r
520
+ ...n
519
521
  }
520
522
  }
521
523
  });
522
- return /* @__PURE__ */ k.jsx(c, { client: l, children: e });
524
+ return /* @__PURE__ */ C.jsx(c, { client: d, children: e });
523
525
  }, Be = (e) => {
524
- const { libraries: r } = j(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), l = L(
525
- (d) => {
526
- if (d && typeof d == "object" && "response" in d) {
527
- const { response: s } = d || {};
526
+ const { libraries: n } = j(A), o = e?.i18 || n?.i18, a = e?.i18?.translateFunction || n?.i18?.translateFunction, r = o?.i18next?.t || a || ((u) => u), { unknownErrorTranslationKey: i = "error.unknownError" } = e || {}, c = r(i), d = L(
527
+ (u) => {
528
+ if (u && typeof u == "object" && "response" in u) {
529
+ const { response: s } = u || {};
528
530
  if (s && typeof s == "object" && "reason" in s)
529
531
  return String(s.reason);
530
532
  if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "reason" in s.data)
@@ -532,124 +534,124 @@ const A = pe({}), Ye = ({ children: e, apiURL: r, libraries: o, localStorageKeys
532
534
  if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "message" in s.data)
533
535
  return String(s.data.message);
534
536
  if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "detail" in s.data) {
535
- const { detail: g } = s.data;
536
- if (Array.isArray(g) && g.length > 0 && typeof g[0] == "object" && g[0] !== null && "msg" in g[0]) {
537
- const { msg: w } = g[0];
538
- if (typeof w == "string")
539
- return String(w);
537
+ const { detail: h } = s.data;
538
+ if (Array.isArray(h) && h.length > 0 && typeof h[0] == "object" && h[0] !== null && "msg" in h[0]) {
539
+ const { msg: g } = h[0];
540
+ if (typeof g == "string")
541
+ return String(g);
540
542
  }
541
543
  }
542
544
  }
543
- return d instanceof Error ? d.message : c;
545
+ return u instanceof Error ? u.message : c;
544
546
  },
545
547
  [c]
546
548
  );
547
- return { getErrorCode: L((d) => {
548
- const { response: s } = d || {};
549
+ return { getErrorCode: L((u) => {
550
+ const { response: s } = u || {};
549
551
  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";
550
- }, []), printError: l };
552
+ }, []), printError: d };
551
553
  }, He = ({
552
554
  data: e,
553
- fetchNextPage: r,
555
+ fetchNextPage: n,
554
556
  isFetchingNextPage: o,
555
557
  isInitialLoading: a,
556
- isLoading: n,
558
+ isLoading: r,
557
559
  enabled: i = !0
558
560
  }) => {
559
561
  const c = L(
560
- async (u) => {
561
- o || !i || await r({ pageParam: u?.pageParam || u.visibleRowsCount });
562
+ async (l) => {
563
+ o || !i || await n({ pageParam: l?.pageParam || l.visibleRowsCount });
562
564
  },
563
- [i, r, o]
564
- ), l = G(() => {
565
+ [i, n, o]
566
+ ), d = G(() => {
565
567
  if (e)
566
- return e.pages.reduce((u, d) => [...u, ...d], []);
568
+ return e.pages.reduce((l, u) => [...l, ...u], []);
567
569
  }, [e]);
568
570
  return {
569
571
  fetchNextPageOnRowsScrollEnd: c,
570
- isLoading: o || n,
572
+ isLoading: o || r,
571
573
  loadingVariant: a ? "skeleton" : "linear-progress",
572
- rows: l
574
+ rows: d
573
575
  };
574
576
  }, Xe = (e) => {
575
- const { libraries: r } = j(A), o = e?.axios || r?.axios, a = e?.localStorageKey || "user";
577
+ const { libraries: n } = j(A), o = e?.axios || n?.axios, a = e?.localStorageKey || "user";
576
578
  if (!o)
577
579
  throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
578
- const n = L(
579
- ({ tokenType: c, accessToken: l }) => {
580
- o.defaults.headers.common.Authorization = `${c} ${l}`;
580
+ const r = L(
581
+ ({ tokenType: c, accessToken: d }) => {
582
+ o.defaults.headers.common.Authorization = `${c} ${d}`;
581
583
  },
582
584
  [o.defaults.headers.common]
583
585
  ), i = () => {
584
586
  o.defaults.headers.common.Authorization = null;
585
587
  };
586
- return C(() => {
588
+ return k(() => {
587
589
  if ($)
588
590
  return;
589
- const c = ({ newValue: l, key: u }) => {
590
- if (u === a && l)
591
+ const c = ({ newValue: d, key: l }) => {
592
+ if (l === a && d)
591
593
  try {
592
- const { accessToken: d, tokenType: s } = JSON.parse(l);
593
- n({ accessToken: d, tokenType: s });
594
- } catch (d) {
595
- console.error("Failed to parse newValue from localStorage:", d);
594
+ const { accessToken: u, tokenType: s } = JSON.parse(d);
595
+ r({ accessToken: u, tokenType: s });
596
+ } catch (u) {
597
+ console.error("Failed to parse newValue from localStorage:", u);
596
598
  }
597
599
  };
598
600
  return window.addEventListener("storage", c), () => {
599
601
  window.removeEventListener("storage", c);
600
602
  };
601
- }, [a, n]), {
603
+ }, [a, r]), {
602
604
  clearAuthenticationToken: i,
603
- setAuthenticationToken: n
605
+ setAuthenticationToken: r
604
606
  };
605
- }, Se = ({ library: e, date: r, format: o = "ll" }) => e(r).format(o), Ae = (e, r) => {
606
- const { fractionDigits: o = 0, metric: a = "km", spacingBetween: n = !0 } = r || {}, i = Number(e), c = n ? " " : "";
607
+ }, Se = ({ library: e, date: n, format: o = "ll" }) => e(n).format(o), Ae = (e, n) => {
608
+ const { fractionDigits: o = 0, metric: a = "km", spacingBetween: r = !0 } = n || {}, i = Number(e), c = r ? " " : "";
607
609
  return Number.isNaN(i) ? `0${c}${a}` : `${i.toFixed(o)}${c}${a}`;
608
- }, je = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((o) => o.length > 0 ? o.charAt(0).toUpperCase() + o.slice(1) : o).join(" "), _e = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Pe = ({ path: e, size: r, apiURL: o }) => {
610
+ }, je = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((o) => o.length > 0 ? o.charAt(0).toUpperCase() + o.slice(1) : o).join(" "), _e = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Pe = ({ path: e, size: n, apiURL: o }) => {
609
611
  if (!e)
610
612
  return "";
611
- const a = _e(e), n = `${o}${a}`, i = n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
612
- return typeof r == "number" && i ? `${n.replace("/files", `/thumbs/${r}`)}` : n;
613
+ const a = _e(e), r = `${o}${a}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
614
+ return typeof n == "number" && i ? `${r.replace("/files", `/thumbs/${n}`)}` : r;
613
615
  }, Ze = (e) => {
614
- const { apiURL: r, libraries: o } = j(A), a = e?.dayjs || o?.dayjs;
616
+ const { apiURL: n, libraries: o } = j(A), a = e?.dayjs || o?.dayjs;
615
617
  return {
616
- dateAdapter: (c, l) => {
618
+ dateAdapter: (c, d) => {
617
619
  if (!a)
618
620
  throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
619
621
  return Se({
620
622
  date: c,
621
- format: l,
623
+ format: d,
622
624
  library: a
623
625
  });
624
626
  },
625
627
  distanceAdapter: Ae,
626
- filePathAdapter: (c, l) => {
627
- if (!r)
628
+ filePathAdapter: (c, d) => {
629
+ if (!n)
628
630
  throw new Error(
629
631
  "API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
630
632
  );
631
633
  return typeof c == "string" && /^https?:\/\//.test(c) ? c : Pe({
632
- apiURL: r,
634
+ apiURL: n,
633
635
  path: c,
634
- size: l
636
+ size: d
635
637
  });
636
638
  },
637
639
  worksiteNameAdapter: je
638
640
  };
639
- }, Y = (e, r) => r === "short" ? e.split("-")[0] : e, et = (e, r = "full") => {
641
+ }, Y = (e, n) => n === "short" ? e.split("-")[0] : e, et = (e, n = "full") => {
640
642
  const [o, a] = W(() => {
641
- const n = e?.language || navigator.language;
642
- return e && "isInitialized" in e && e.isInitialized, Y(n, r);
643
+ const r = e?.language || navigator.language;
644
+ return e && "isInitialized" in e && e.isInitialized, Y(r, n);
643
645
  });
644
- return C(() => {
645
- e && "isInitialized" in e && e.isInitialized && e.language && a(Y(e.language, r));
646
- const n = (i) => {
647
- a(Y(i, r));
646
+ return k(() => {
647
+ e && "isInitialized" in e && e.isInitialized && e.language && a(Y(e.language, n));
648
+ const r = (i) => {
649
+ a(Y(i, n));
648
650
  };
649
- return e?.on?.("languageChanged", n), () => {
650
- e?.off?.("languageChanged", n);
651
+ return e?.on?.("languageChanged", r), () => {
652
+ e?.off?.("languageChanged", r);
651
653
  };
652
- }, [e, r]), o;
654
+ }, [e, n]), o;
653
655
  }, Te = "tracktor.filter", ke = {
654
656
  getFilter: () => {
655
657
  },
@@ -658,64 +660,64 @@ const A = pe({}), Ye = ({ children: e, apiURL: r, libraries: o, localStorageKeys
658
660
  },
659
661
  setFilter: () => {
660
662
  }
661
- }, oe = (e, r, o) => `${o}_${e}=>${r}`, Ce = (e) => e.reduce((r, o) => {
663
+ }, oe = (e, n, o) => `${o}_${e}=>${n}`, Ce = (e) => e.reduce((n, o) => {
662
664
  const a = localStorage.getItem(o);
663
665
  if (a)
664
666
  try {
665
- const n = JSON.parse(a), i = Object.keys(n)?.[0];
666
- i && (r[i] = Object.values(n)?.[0]);
667
+ const r = JSON.parse(a), i = Object.keys(r)?.[0];
668
+ i && (n[i] = Object.values(r)?.[0]);
667
669
  } catch {
668
670
  }
669
- return r;
671
+ return n;
670
672
  }, {}), tt = (e) => {
671
- const { libraries: r, localStorageKeys: o } = j(A), a = e?.reactRouter || r?.reactRouter, { pathname: n } = a?.useLocation?.() ?? { pathname: "/" }, [i, c] = a?.useSearchParams?.() ?? [new URLSearchParams(), () => {
672
- }], [l, u] = W({}), d = o?.filter || Te, s = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl;
673
+ const { libraries: n, localStorageKeys: o } = j(A), a = e?.reactRouter || n?.reactRouter, { pathname: r } = a?.useLocation?.() ?? { pathname: "/" }, [i, c] = a?.useSearchParams?.() ?? [new URLSearchParams(), () => {
674
+ }], [d, l] = W({}), u = o?.filter || Te, s = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl;
673
675
  if ($)
674
676
  return ke;
675
677
  if (!a)
676
678
  throw new Error(
677
679
  "React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter."
678
680
  );
679
- const g = () => Object.keys(localStorage).filter(
680
- (m) => m.startsWith(d) && m.endsWith(e?.pathname || n)
681
- ), w = (m, y, _ = !0) => {
682
- const p = oe(m, e?.pathname || n, d);
681
+ const h = () => Object.keys(localStorage).filter(
682
+ (m) => m.startsWith(u) && m.endsWith(e?.pathname || r)
683
+ ), g = (m, y, _ = !0) => {
684
+ const p = oe(m, e?.pathname || r, u);
683
685
  if (!y || Array.isArray(y) && !y.length) {
684
- s ? (i.delete(m), c(i)) : u((v) => {
685
- const P = { ...v };
686
+ s ? (i.delete(m), c(i)) : l((w) => {
687
+ const P = { ...w };
686
688
  return delete P[m], P;
687
689
  }), localStorage.removeItem(p);
688
690
  return;
689
691
  }
690
- _ && y && localStorage.setItem(p, JSON.stringify({ ...i, [m]: y })), s && y ? (i.set(m, JSON.stringify(y)), c(i)) : !s && y && u((v) => ({ ...v, [m]: y }));
692
+ _ && y && localStorage.setItem(p, JSON.stringify({ ...i, [m]: y })), s && y ? (i.set(m, JSON.stringify(y)), c(i)) : !s && y && l((w) => ({ ...w, [m]: y }));
691
693
  };
692
694
  return {
693
695
  getFilter: (m, y) => {
694
696
  if (!s) {
695
- const v = l[m];
696
- if (v !== void 0)
697
- return v;
697
+ const w = d[m];
698
+ if (w !== void 0)
699
+ return w;
698
700
  }
699
701
  if (s) {
700
- const v = i.get(m);
701
- if (v)
702
+ const w = i.get(m);
703
+ if (w)
702
704
  try {
703
- return JSON.parse(v);
705
+ return JSON.parse(w);
704
706
  } catch {
705
- return v;
707
+ return w;
706
708
  }
707
709
  }
708
- const _ = oe(m, e?.pathname || n, d), p = localStorage.getItem(_);
710
+ const _ = oe(m, e?.pathname || r, u), p = localStorage.getItem(_);
709
711
  if (p)
710
712
  try {
711
- const v = JSON.parse(p)[m];
712
- return !s && v !== void 0 && u((P) => ({ ...P, [m]: v })), v;
713
+ const w = JSON.parse(p)[m];
714
+ return !s && w !== void 0 && l((P) => ({ ...P, [m]: w })), w;
713
715
  } catch {
714
716
  }
715
717
  return y;
716
718
  },
717
719
  getFilters: () => {
718
- const m = g(), y = Ce(m);
720
+ const m = h(), y = Ce(m);
719
721
  if (s) {
720
722
  const _ = Object.fromEntries(i.entries());
721
723
  return {
@@ -725,26 +727,26 @@ const A = pe({}), Ye = ({ children: e, apiURL: r, libraries: o, localStorageKeys
725
727
  }
726
728
  return {
727
729
  ...y,
728
- ...l
730
+ ...d
729
731
  };
730
732
  },
731
733
  handleFilter: (m, y) => (_, p) => {
732
734
  if (p || Array.isArray(p) && p.length === 0) {
733
- const v = y || "value", P = typeof p == "object" && v in p ? p[v] : p;
734
- w(m, P);
735
+ const w = y || "value", P = typeof p == "object" && w in p ? p[w] : p;
736
+ g(m, P);
735
737
  return;
736
738
  }
737
- w(m, void 0);
739
+ g(m, void 0);
738
740
  },
739
- setFilter: w
741
+ setFilter: g
740
742
  };
741
743
  }, xe = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), Oe = (e) => {
742
- const a = e.split("/").filter((n) => n.length > 0).map((n) => n.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((u) => u.charAt(0).toUpperCase() + u.slice(1)).join("")).join("");
744
+ const a = e.split("/").filter((r) => r.length > 0).map((r) => r.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join("")).join("");
743
745
  return a.charAt(0).toLowerCase() + a.slice(1);
744
- }, Ie = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), Le = (e, r, o, a) => {
745
- const n = Oe(r), i = xe(o), c = `${n}${i}`;
746
+ }, Ie = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), Le = (e, n, o, a) => {
747
+ const r = Oe(n), i = xe(o), c = `${r}${i}`;
746
748
  return e && typeof e == "object" && "operationId" in e && a?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
747
- }, Ne = (e, r) => {
749
+ }, Ne = (e, n) => {
748
750
  const o = {};
749
751
  return e?.forEach((a) => {
750
752
  o[a] = {
@@ -754,7 +756,7 @@ const A = pe({}), Ye = ({ children: e, apiURL: r, libraries: o, localStorageKeys
754
756
  useQuery: !0
755
757
  }
756
758
  };
757
- }), r?.filter((a) => !o[a]).forEach((a) => {
759
+ }), n?.filter((a) => !o[a]).forEach((a) => {
758
760
  o[a] = {
759
761
  query: {
760
762
  useQuery: !0
@@ -762,46 +764,46 @@ const A = pe({}), Ye = ({ children: e, apiURL: r, libraries: o, localStorageKeys
762
764
  };
763
765
  }), Object.keys(o).length ? o : void 0;
764
766
  }, rt = (e) => (Array.isArray(e) ? e : [e]).reduce((o, a) => {
765
- const { output: n, useInfiniteIds: i, useQueryIds: c, input: l = "./openapi.json" } = a || {}, u = Ie(l);
767
+ const { output: r, useInfiniteIds: i, useQueryIds: c, input: d = "./openapi.json" } = a || {}, l = Ie(d);
766
768
  return {
767
769
  ...o,
768
- [u]: {
770
+ [l]: {
769
771
  hooks: {
770
772
  afterAllFilesWrite: "prettier src/api/ --write"
771
773
  },
772
- input: l,
774
+ input: d,
773
775
  output: {
774
- baseUrl: n?.baseUrl,
776
+ baseUrl: r?.baseUrl,
775
777
  client: "react-query",
776
778
  mode: "tags-split",
777
779
  override: {
778
780
  ...(i?.length || c?.length) && {
779
781
  operations: Ne(i, c)
780
782
  },
781
- header: (d) => [
783
+ header: (u) => [
782
784
  "Generated by orval 🍺",
783
- ...d.title ? [d.title] : [],
784
- ...d.description ? [d.description] : []
785
+ ...u.title ? [u.title] : [],
786
+ ...u.description ? [u.description] : []
785
787
  ],
786
788
  mutator: {
787
789
  name: "axiosCustomInstance",
788
790
  path: "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts"
789
791
  },
790
- operationName: (d, s, g) => Le(d, s, g, c),
792
+ operationName: (u, s, h) => Le(u, s, h, c),
791
793
  query: {
792
794
  useQuery: !0
793
795
  }
794
796
  },
795
- schemas: n?.schemas || `src/api/${u}/model`,
796
- target: n?.target || `src/api/${u}/services/api.ts`,
797
- ...n
797
+ schemas: r?.schemas || `src/api/${l}/model`,
798
+ target: r?.target || `src/api/${l}/services/api.ts`,
799
+ ...r
798
800
  }
799
801
  }
800
802
  };
801
803
  }, {});
802
804
  export {
803
- Ue as GTMSendPageView,
804
- ze as InitializeAxiosConfig,
805
+ ze as GTMSendPageView,
806
+ Ue as InitializeAxiosConfig,
805
807
  Ge as InitializeDaysJSConfig,
806
808
  Qe as InitializeI18nConfig,
807
809
  Ve as InitializeSentryConfig,
package/dist/main.umd.cjs CHANGED
@@ -1,4 +1,4 @@
1
- (function(g,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],O):(g=typeof globalThis<"u"?globalThis:g||self,O(g["@tracktor/shared-module"]={},g.axios,g.React))})(this,function(g,O,f){"use strict";const ae=(e,r)=>{const o=O.CancelToken.source(),a=O({...e,...r,cancelToken:o.token}).then(({data:n})=>n);return a.cancel=()=>{o.cancel("Query was cancelled")},a};var Y={exports:{}},L={};/**
1
+ (function(g,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],O):(g=typeof globalThis<"u"?globalThis:g||self,O(g["@tracktor/shared-module"]={},g.axios,g.React))})(this,function(g,O,f){"use strict";const ae=(e,n)=>{const o=O.CancelToken.source(),a=O({...e,...n,cancelToken:o.token}).then(({data:r})=>r);return a.cancel=()=>{o.cancel("Query was cancelled")},a};var Y={exports:{}},L={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var G;function se(){if(G)return L;G=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function o(a,n,s){var c=null;if(s!==void 0&&(c=""+s),n.key!==void 0&&(c=""+n.key),"key"in n){s={};for(var l in n)l!=="key"&&(s[l]=n[l])}else s=n;return n=s.ref,{$$typeof:e,type:a,key:c,ref:n!==void 0?n:null,props:s}}return L.Fragment=r,L.jsx=o,L.jsxs=o,L}var F={};/**
9
+ */var G;function se(){if(G)return L;G=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function o(a,r,s){var c=null;if(s!==void 0&&(c=""+s),r.key!==void 0&&(c=""+r.key),"key"in r){s={};for(var d in r)d!=="key"&&(s[d]=r[d])}else s=r;return r=s.ref,{$$typeof:e,type:a,key:c,ref:r!==void 0?r:null,props:s}}return L.Fragment=n,L.jsx=o,L.jsxs=o,L}var F={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,9 +14,9 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var J;function ie(){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===Ge?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case C:return"Fragment";case v:return"Profiler";case h:return"StrictMode";case P: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 x:return"Portal";case m:return(t.displayName||"Context")+".Provider";case _:return(t._context.displayName||"Context")+".Consumer";case w: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 q: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 E=p.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return E.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===C)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===q)return"<...>";try{var p=e(t);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function n(){var t=z.A;return t===null?null:t.getOwner()}function s(){return Error("react-stack-top-frame")}function c(t){if($.call(t,"key")){var p=Object.getOwnPropertyDescriptor(t,"key").get;if(p&&p.isReactWarning)return!1}return t.key!==void 0}function l(t,p){function E(){ee||(ee=!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))}E.isReactWarning=!0,Object.defineProperty(t,"key",{get:E,configurable:!0})}function u(){var t=e(this.type);return te[t]||(te[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,E,R,I,T,M,Q){return E=T.ref,t={$$typeof:j,type:t,key:p,props:T,_owner:I},(E!==void 0?E:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:u}):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:M}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function i(t,p,E,R,I,T,M,Q){var S=p.children;if(S!==void 0)if(R)if(Je(S)){for(R=0;R<S.length;R++)y(S[R]);Object.freeze&&Object.freeze(S)}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(S);if($.call(p,"key")){S=e(t);var N=Object.keys(p).filter(function(Ke){return Ke!=="key"});R=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",oe[S+R]||(N=0<N.length?"{"+N.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var J;function ie(){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===Ge?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case C:return"Fragment";case v:return"Profiler";case h:return"StrictMode";case P: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 x:return"Portal";case m:return(t.displayName||"Context")+".Provider";case _:return(t._context.displayName||"Context")+".Consumer";case b: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 q:p=t._payload,t=t._init;try{return e(t(p))}catch{}}return null}function n(t){return""+t}function o(t){try{n(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),n(t)}}function a(t){if(t===C)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===q)return"<...>";try{var p=e(t);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function r(){var t=z.A;return t===null?null:t.getOwner()}function s(){return Error("react-stack-top-frame")}function c(t){if($.call(t,"key")){var p=Object.getOwnPropertyDescriptor(t,"key").get;if(p&&p.isReactWarning)return!1}return t.key!==void 0}function d(t,p){function w(){ee||(ee=!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 te[t]||(te[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 u(t,p,w,R,I,T,M,Q){return w=T.ref,t={$$typeof:j,type:t,key:p,props:T,_owner:I},(w!==void 0?w: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:M}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function i(t,p,w,R,I,T,M,Q){var S=p.children;if(S!==void 0)if(R)if(Je(S)){for(R=0;R<S.length;R++)E(S[R]);Object.freeze&&Object.freeze(S)}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 E(S);if($.call(p,"key")){S=e(t);var N=Object.keys(p).filter(function(Ke){return Ke!=="key"});R=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",oe[S+R]||(N=0<N.length?"{"+N.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,R,S,N,S),oe[S+R]=!0)}if(S=null,E!==void 0&&(o(E),S=""+E),c(p)&&(o(p.key),S=""+p.key),"key"in p){E={};for(var V in p)V!=="key"&&(E[V]=p[V])}else E=p;return S&&l(E,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,S,T,I,n(),E,M,Q)}function y(t){typeof t=="object"&&t!==null&&t.$$typeof===j&&t._store&&(t._store.validated=1)}var b=f,j=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),m=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),Me=Symbol.for("react.suspense_list"),Qe=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),Ve=Symbol.for("react.activity"),Ge=Symbol.for("react.client.reference"),z=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,Je=Array.isArray,U=console.createTask?console.createTask:function(){return null};b={"react-stack-bottom-frame":function(t){return t()}};var ee,te={},re=b["react-stack-bottom-frame"].bind(b,s)(),ne=U(a(s)),oe={};F.Fragment=C,F.jsx=function(t,p,E,R,I){var T=1e4>z.recentlyCreatedOwnerStacks++;return i(t,p,E,!1,R,I,T?Error("react-stack-top-frame"):re,T?U(a(t)):ne)},F.jsxs=function(t,p,E,R,I){var T=1e4>z.recentlyCreatedOwnerStacks++;return i(t,p,E,!0,R,I,T?Error("react-stack-top-frame"):re,T?U(a(t)):ne)}}()),F}var K;function ce(){return K||(K=1,process.env.NODE_ENV==="production"?Y.exports=se():Y.exports=ie()),Y.exports}var k=ce();const A=f.createContext({}),le=({children:e,apiURL:r,libraries:o,localStorageKeys:a})=>{const n=f.useMemo(()=>({apiURL:r,libraries:o,localStorageKeys:a}),[r,o,a]);return k.jsx(A.Provider,{value:n,children:e})},ue="user",de=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:s,localStorageKeys:c}=f.useContext(A),l=n?.reactRouter||s?.reactRouter,u=n?.axios||s?.axios,d=n?.localStorageKey||c?.user||ue;if(!l)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,y]=f.useState(null),{useLocation:b,Navigate:j,Outlet:x}=l,C=b(),h=f.useRef(!1),v=typeof r=="function"?r():!!r,_=typeof v=="boolean"?v:v?.isLogged;return f.useEffect(()=>{h.current||(h.current=!0,u.interceptors.response.use(m=>m,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&&(u.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(d),y(a)),Promise.reject(m))))},[u.defaults.headers.common,u.interceptors.response,d,a]),_&&!i?k.jsx(f.Suspense,{fallback:e,children:C.state?.from?.state&&C.state?.from?.pathname===o?k.jsx(j,{to:C.state.from.state.from.pathname+C.state.from.state.from.search,replace:!0}):k.jsx(x,{})}):k.jsx(j,{to:o+C.search,state:{from:C},replace:!0})},fe=({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:s}=n,{useLocation:c,Outlet:l}=a,{pathname:u}=c(),{sendEvent:d}=s();return f.useEffect(()=>{d({event:"pageView",pathname:u,...e})},[e,u,d]),k.jsx(l,{})},D=(()=>{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:o="application/json",...a})=>{const{apiURL:n=a.apiURL,libraries:s,localStorageKeys:c}=f.useContext(A),l=a?.userLocalStorageKey||c?.user||pe,u=a?.axios||s?.axios;if(!u)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!u?.defaults||D)return null;if(typeof window<"u"&&window.localStorage){const d=localStorage.getItem(l),i=d?JSON.parse(d):null,y=i?.[e]?i[e]:null,b=i?.[r]?i[r]:null,j=d?`${y} ${b}`:null;j&&(u.defaults.headers.common.Authorization=j)}return u.defaults.baseURL=n,u.defaults.headers.post["Content-Type"]=o,null},me=({debug:e,resources:r,...o})=>{const{libraries:a}=f.useContext(A),n=o?.i18||a?.i18,{i18next:s,initReactI18next:c,languageDetector:l}=n||{};if(D)return null;if(!n)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return s?.isInitialized||(s.use(l).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!==s.resolvedLanguage&&s.resolvedLanguage&&document.documentElement.setAttribute("lang",s.resolvedLanguage)}),s.on("languageChanged",u=>{document.documentElement.setAttribute("lang",u)})),null},ye=({dsn:e,integrations:r,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:n,tracePropagationTargets:s,ignoreErrors:c,debug:l,environment:u,release:d,...i})=>{const{libraries:y}=f.useContext(A),b=i?.sentry||y?.sentry,j=i?.reactRouter||y?.reactRouter;if(!b)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!j)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(b.isInitialized())return null;const{createRoutesFromChildren:x,matchRoutes:C,useLocation:h,useNavigationType:v}=j;return(l||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&b.init({debug:l,dsn:e,environment:u||"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:[b.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:x,matchRoutes:C,useEffect:f.useEffect,useLocation:h,useNavigationType:v}),...r||[]],release:d,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:s,tracesSampleRate:o||1}),null},he=({IMaskMixin:e,...r})=>{const o=f.useMemo(()=>e(({TextField:a,...n})=>k.jsx(a,{...n})),[e]);return k.jsx(o,{...r})},ve=({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(l=>{l&&a.extend(l)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),a.locale(c)})().then()},[a,n,e]),null},Ee=()=>(f.useEffect(()=>{if(D)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),we=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)}},be=({renderDialog:e,clearCachesOnReload:r=!1})=>{const o=f.useRef(null),[a,n]=f.useState(!1),s=f.useCallback(async()=>{o.current&&o.current.postMessage({type:"SKIP_WAITING"}),r&&await we(),window.location.reload()},[r]),c=f.useCallback(async()=>{window.confirm("A new version is available. The app will reload now.")&&await s()},[s]);return f.useEffect(()=>{if(!("serviceWorker"in navigator))return;let l,u;const d=y=>{y&&navigator.serviceWorker.controller&&(o.current=y,n(!0))},i=()=>{const y=l?.installing;y&&(u=()=>{y.state==="installed"&&d(y)},y.addEventListener("statechange",u))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(d(l.waiting),l.addEventListener("updatefound",i))})().catch(console.error),()=>{l?.removeEventListener("updatefound",i),u&&l?.installing&&l.installing.removeEventListener("statechange",u)}},[]),f.useEffect(()=>{a&&!e&&c().catch(console.error)},[e,c,a]),a&&e?e(s):null},Re=e=>e&&typeof e=="function",Se=e=>e&&typeof e=="function",Ae=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=f.useContext(A),s=a?.QueryClient||n?.reactQuery?.QueryClient,c=a?.QueryClientProvider||n?.reactQuery?.QueryClientProvider;if(!s)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(!Re(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Se(s))throw new Error("Provided QueryClient dependencies are not valid.");const l=new s({defaultOptions:{mutations:{...o},queries:{getNextPageParam:(u,d,i)=>u.length+(i||0),refetchOnWindowFocus:!1,retry:3,...r}}});return k.jsx(c,{client:l,children:e})},Ce=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:s="error.unknownError"}=e||{},c=n(s),l=f.useCallback(d=>{if(d&&typeof d=="object"&&"response"in d){const{response:i}=d||{};if(i&&typeof i=="object"&&"reason"in i)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data)return String(i.data.message);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"detail"in i.data){const{detail:y}=i.data;if(Array.isArray(y)&&y.length>0&&typeof y[0]=="object"&&y[0]!==null&&"msg"in y[0]){const{msg:b}=y[0];if(typeof b=="string")return String(b)}}}return d instanceof Error?d.message:c},[c]);return{getErrorCode:f.useCallback(d=>{const{response:i}=d||{};return i?.error_code?String(i?.error_code):i?.data?.error_code?String(i?.data?.error_code):i?.error_code?String(i?.error_code):i?.data?.error_code?String(i.data.error_code):"unknown_error_code"},[]),printError:l}},je=({data:e,fetchNextPage:r,isFetchingNextPage:o,isInitialLoading:a,isLoading:n,enabled:s=!0})=>{const c=f.useCallback(async u=>{o||!s||await r({pageParam:u?.pageParam||u.visibleRowsCount})},[s,r,o]),l=f.useMemo(()=>{if(e)return e.pages.reduce((u,d)=>[...u,...d],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:o||n,loadingVariant:a?"skeleton":"linear-progress",rows:l}},_e=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:l})=>{o.defaults.headers.common.Authorization=`${c} ${l}`},[o.defaults.headers.common]),s=()=>{o.defaults.headers.common.Authorization=null};return f.useEffect(()=>{if(D)return;const c=({newValue:l,key:u})=>{if(u===a&&l)try{const{accessToken:d,tokenType:i}=JSON.parse(l);n({accessToken:d,tokenType:i})}catch(d){console.error("Failed to parse newValue from localStorage:",d)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}},[a,n]),{clearAuthenticationToken:s,setAuthenticationToken:n}},B=({library:e,date:r,format:o="ll"})=>e(r).format(o),H=(e,r)=>{const{fractionDigits:o=0,metric:a="km",spacingBetween:n=!0}=r||{},s=Number(e),c=n?" ":"";return Number.isNaN(s)?`0${c}${a}`:`${s.toFixed(o)}${c}${a}`},X=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(o=>o.length>0?o.charAt(0).toUpperCase()+o.slice(1):o).join(" "),Pe=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Te=({path:e,size:r,apiURL:o})=>{if(!e)return"";const a=Pe(e),n=`${o}${a}`,s=n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof r=="number"&&s?`${n.replace("/files",`/thumbs/${r}`)}`:n},ke=e=>{const{apiURL:r,libraries:o}=f.useContext(A),a=e?.dayjs||o?.dayjs;return{dateAdapter:(c,l)=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return B({date:c,format:l,library:a})},distanceAdapter:H,filePathAdapter:(c,l)=>{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:Te({apiURL:r,path:c,size:l})},worksiteNameAdapter:X}},W=(e,r)=>r==="short"?e.split("-")[0]:e,Ie=(e,r="full")=>{const[o,a]=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&&a(W(e.language,r));const n=s=>{a(W(s,r))};return e?.on?.("languageChanged",n),()=>{e?.off?.("languageChanged",n)}},[e,r]),o},Oe="tracktor.filter",xe={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},Z=(e,r,o)=>`${o}_${e}=>${r}`,Ne=e=>e.reduce((r,o)=>{const a=localStorage.getItem(o);if(a)try{const n=JSON.parse(a),s=Object.keys(n)?.[0];s&&(r[s]=Object.values(n)?.[0])}catch{}return r},{}),Le=e=>{const{libraries:r,localStorageKeys:o}=f.useContext(A),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[s,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],[l,u]=f.useState({}),d=o?.filter||Oe,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl;if(D)return xe;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const y=()=>Object.keys(localStorage).filter(h=>h.startsWith(d)&&h.endsWith(e?.pathname||n)),b=(h,v,_=!0)=>{const m=Z(h,e?.pathname||n,d);if(!v||Array.isArray(v)&&!v.length){i?(s.delete(h),c(s)):u(w=>{const P={...w};return delete P[h],P}),localStorage.removeItem(m);return}_&&v&&localStorage.setItem(m,JSON.stringify({...s,[h]:v})),i&&v?(s.set(h,JSON.stringify(v)),c(s)):!i&&v&&u(w=>({...w,[h]:v}))};return{getFilter:(h,v)=>{if(!i){const w=l[h];if(w!==void 0)return w}if(i){const w=s.get(h);if(w)try{return JSON.parse(w)}catch{return w}}const _=Z(h,e?.pathname||n,d),m=localStorage.getItem(_);if(m)try{const w=JSON.parse(m)[h];return!i&&w!==void 0&&u(P=>({...P,[h]:w})),w}catch{}return v},getFilters:()=>{const h=y(),v=Ne(h);if(i){const _=Object.fromEntries(s.entries());return{...v,..._}}return{...v,...l}},handleFilter:(h,v)=>(_,m)=>{if(m||Array.isArray(m)&&m.length===0){const w=v||"value",P=typeof m=="object"&&w in m?m[w]:m;b(h,P);return}b(h,void 0)},setFilter:b}},Fe=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),De=e=>{const a=e.split("/").filter(n=>n.length>0).map(n=>n.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join("")).join("");return a.charAt(0).toLowerCase()+a.slice(1)},Ye=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),We=(e,r,o,a)=>{const n=De(r),s=Fe(o),c=`${n}${s}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},ze=(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},Ue=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:n,useInfiniteIds:s,useQueryIds:c,input:l="./openapi.json"}=a||{},u=Ye(l);return{...o,[u]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:l,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(s?.length||c?.length)&&{operations:ze(s,c)},header:d=>["Generated by orval 🍺",...d.title?[d.title]:[],...d.description?[d.description]:[]],mutator:{name:"axiosCustomInstance",path:"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts"},operationName:(d,i,y)=>We(d,i,y,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${u}/model`,target:n?.target||`src/api/${u}/services/api.ts`,...n}}}},{});g.GTMSendPageView=fe,g.InitializeAxiosConfig=ge,g.InitializeDaysJSConfig=ve,g.InitializeI18nConfig=me,g.InitializeSentryConfig=ye,g.InjectDependenciesContext=A,g.InjectDependenciesProvider=le,g.MaskTextField=he,g.PreloadErrorHandler=Ee,g.QueryClientProviderWithConfig=Ae,g.RequireAuth=de,g.UpdateNotifier=be,g.axiosCustomInstance=ae,g.dateAdapter=B,g.distanceAdapter=H,g.getOrvalConfig=Ue,g.useAdapter=ke,g.useAuth=_e,g.useCurrentLanguage=Ie,g.useFilters=Le,g.useInfiniteDataGrid=je,g.useResponseError=Ce,g.worksiteNameAdapter=X,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
22
+ <%s key={someKey} {...props} />`,R,S,N,S),oe[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 V in p)V!=="key"&&(w[V]=p[V])}else w=p;return S&&d(w,typeof t=="function"?t.displayName||t.name||"Unknown":t),u(t,S,T,I,r(),w,M,Q)}function E(t){typeof t=="object"&&t!==null&&t.$$typeof===j&&t._store&&(t._store.validated=1)}var y=f,j=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),m=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),Me=Symbol.for("react.suspense_list"),Qe=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),Ve=Symbol.for("react.activity"),Ge=Symbol.for("react.client.reference"),z=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,Je=Array.isArray,U=console.createTask?console.createTask:function(){return null};y={"react-stack-bottom-frame":function(t){return t()}};var ee,te={},re=y["react-stack-bottom-frame"].bind(y,s)(),ne=U(a(s)),oe={};F.Fragment=C,F.jsx=function(t,p,w,R,I){var T=1e4>z.recentlyCreatedOwnerStacks++;return i(t,p,w,!1,R,I,T?Error("react-stack-top-frame"):re,T?U(a(t)):ne)},F.jsxs=function(t,p,w,R,I){var T=1e4>z.recentlyCreatedOwnerStacks++;return i(t,p,w,!0,R,I,T?Error("react-stack-top-frame"):re,T?U(a(t)):ne)}}()),F}var K;function ce(){return K||(K=1,process.env.NODE_ENV==="production"?Y.exports=se():Y.exports=ie()),Y.exports}var k=ce();const A=f.createContext({}),le=({children:e,apiURL:n,libraries:o,localStorageKeys:a})=>{const r=f.useMemo(()=>({apiURL:n,libraries:o,localStorageKeys:a}),[n,o,a]);return k.jsx(A.Provider,{value:r,children:e})},ue="user",de=({Fallback:e,isLogged:n,loginPath:o="/login",redirect401Path:a="/login",...r})=>{const{libraries:s,localStorageKeys:c}=f.useContext(A),d=r?.reactRouter||s?.reactRouter,l=r?.axios||s?.axios,u=r?.localStorageKey||c?.user||ue;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,E]=f.useState(null),{useLocation:y,Navigate:j,Outlet:x}=d,C=y(),h=f.useRef(!1),v=typeof n=="function"?n():!!n,_=typeof v=="boolean"?v:v?.isLogged;return f.useEffect(()=>{h.current||(h.current=!0,l.interceptors.response.use(m=>m,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(u),E(a)),Promise.reject(m))))},[l.defaults.headers.common,l.interceptors.response,u,a]),_&&!i?k.jsx(f.Suspense,{fallback:e,children:C.state?.from?.state&&C.state?.from?.pathname===o?k.jsx(j,{to:C.state.from.state.from.pathname+C.state.from.state.from.search,replace:!0}):k.jsx(x,{})}):k.jsx(j,{to:o+C.search,state:{from:C},replace:!0})},fe=({data:e,...n})=>{const{libraries:o}=f.useContext(A),a=n?.reactRouter||o?.reactRouter,r=n?.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(!r)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:s}=r,{useLocation:c,Outlet:d}=a,{pathname:l}=c(),{sendEvent:u}=s();return f.useEffect(()=>{u({event:"pageView",pathname:l,...e})},[e,l,u]),k.jsx(d,{})},D=(()=>{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:n="accessToken",postContentType:o="application/json",...a})=>{const{apiURL:r=a.apiURL,libraries:s,localStorageKeys:c}=f.useContext(A),d=a?.userLocalStorageKey||c?.user||pe,l=a?.axios||s?.axios;if(!l)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!l?.defaults||D)return null;if(typeof window<"u"&&window.localStorage){const u=localStorage.getItem(d),i=u?JSON.parse(u):null,E=i?.[e]?i[e]:null,y=i?.[n]?i[n]:null,j=u?`${E} ${y}`:null;j&&(l.defaults.headers.common.Authorization=j)}return l.defaults.baseURL=r,l.defaults.headers.post["Content-Type"]=o,null},me=({debug:e,resources:n,...o})=>{const{libraries:a}=f.useContext(A),r=o?.i18||a?.i18,{i18next:s,initReactI18next:c,languageDetector:d}=r||{};if(D)return null;if(!r)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return s?.isInitialized||(s.use(d).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:n,returnNull:!1}).then(()=>{document.documentElement.lang!==s.resolvedLanguage&&s.resolvedLanguage&&document.documentElement.setAttribute("lang",s.resolvedLanguage)}),s.on("languageChanged",l=>{document.documentElement.setAttribute("lang",l)})),null},ye=({dsn:e,integrations:n,tracesSampleRate:o,replaysSessionSampleRate:a,replaysOnErrorSampleRate:r,tracePropagationTargets:s,ignoreErrors:c,debug:d,environment:l,release:u,...i})=>{const{libraries:E}=f.useContext(A),y=i?.sentry||E?.sentry,j=i?.reactRouter||E?.reactRouter;if(!y)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!j)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(y.isInitialized())return null;const{createRoutesFromChildren:x,matchRoutes:C,useLocation:h,useNavigationType:v}=j;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&y.init({debug:d,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:[y.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:x,matchRoutes:C,useEffect:f.useEffect,useLocation:h,useNavigationType:v}),...n||[]],release:u,replaysOnErrorSampleRate:r||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:s,tracesSampleRate:o||1}),null},he=({IMaskMixin:e,...n})=>{const o=f.useMemo(()=>e(({TextField:a,...r})=>k.jsx(a,{...r})),[e]);return k.jsx(o,{...n})},ve=({language:e,...n})=>{const{libraries:o}=f.useContext(A),a=n?.dayjs||o?.dayjs,r=n?.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";r&&r.forEach(d=>{d&&a.extend(d)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),a.locale(c)})().then()},[a,r,e]),null},Ee=()=>(f.useEffect(()=>{if(D)return;const e=n=>{try{n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),we=async()=>{if("caches"in window)try{const e=await caches.keys();await Promise.all(e.map(n=>caches.delete(n)))}catch(e){console.error("Failed to clear caches:",e)}},be=({autoUpdate:e,renderDialog:n,clearCachesOnReload:o})=>{const a=f.useRef(null),[r,s]=f.useState(!1),c=f.useCallback(async()=>{a.current&&a.current.postMessage({type:"SKIP_WAITING"}),o&&await we(),window.location.reload()},[o]),d=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,u;const i=y=>{y&&navigator.serviceWorker.controller&&(a.current=y,s(!0))},E=()=>{const y=l?.installing;y&&(u=()=>{y.state==="installed"&&i(y)},y.addEventListener("statechange",u))};return(async()=>{l=await navigator.serviceWorker.getRegistration(),l&&(i(l.waiting),l.addEventListener("updatefound",E))})().catch(console.error),()=>{l?.removeEventListener("updatefound",E),u&&l?.installing&&l.installing.removeEventListener("statechange",u)}},[]),f.useEffect(()=>{r&&e&&c().catch(console.error)},[e,r,c]),f.useEffect(()=>{r&&!e&&!n&&d().catch(console.error)},[n,d,r,e]),r&&!e&&n?n(c):null},Re=e=>e&&typeof e=="function",Se=e=>e&&typeof e=="function",Ae=({children:e,defaultQueriesOptions:n,defaultMutationsOptions:o,...a})=>{const{libraries:r}=f.useContext(A),s=a?.QueryClient||r?.reactQuery?.QueryClient,c=a?.QueryClientProvider||r?.reactQuery?.QueryClientProvider;if(!s)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(!Re(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Se(s))throw new Error("Provided QueryClient dependencies are not valid.");const d=new s({defaultOptions:{mutations:{...o},queries:{getNextPageParam:(l,u,i)=>l.length+(i||0),refetchOnWindowFocus:!1,retry:3,...n}}});return k.jsx(c,{client:d,children:e})},Ce=e=>{const{libraries:n}=f.useContext(A),o=e?.i18||n?.i18,a=e?.i18?.translateFunction||n?.i18?.translateFunction,r=o?.i18next?.t||a||(u=>u),{unknownErrorTranslationKey:s="error.unknownError"}=e||{},c=r(s),d=f.useCallback(u=>{if(u&&typeof u=="object"&&"response"in u){const{response:i}=u||{};if(i&&typeof i=="object"&&"reason"in i)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data)return String(i.data.message);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"detail"in i.data){const{detail:E}=i.data;if(Array.isArray(E)&&E.length>0&&typeof E[0]=="object"&&E[0]!==null&&"msg"in E[0]){const{msg:y}=E[0];if(typeof y=="string")return String(y)}}}return u instanceof Error?u.message:c},[c]);return{getErrorCode:f.useCallback(u=>{const{response:i}=u||{};return i?.error_code?String(i?.error_code):i?.data?.error_code?String(i?.data?.error_code):i?.error_code?String(i?.error_code):i?.data?.error_code?String(i.data.error_code):"unknown_error_code"},[]),printError:d}},je=({data:e,fetchNextPage:n,isFetchingNextPage:o,isInitialLoading:a,isLoading:r,enabled:s=!0})=>{const c=f.useCallback(async l=>{o||!s||await n({pageParam:l?.pageParam||l.visibleRowsCount})},[s,n,o]),d=f.useMemo(()=>{if(e)return e.pages.reduce((l,u)=>[...l,...u],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:o||r,loadingVariant:a?"skeleton":"linear-progress",rows:d}},_e=e=>{const{libraries:n}=f.useContext(A),o=e?.axios||n?.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 r=f.useCallback(({tokenType:c,accessToken:d})=>{o.defaults.headers.common.Authorization=`${c} ${d}`},[o.defaults.headers.common]),s=()=>{o.defaults.headers.common.Authorization=null};return f.useEffect(()=>{if(D)return;const c=({newValue:d,key:l})=>{if(l===a&&d)try{const{accessToken:u,tokenType:i}=JSON.parse(d);r({accessToken:u,tokenType:i})}catch(u){console.error("Failed to parse newValue from localStorage:",u)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}},[a,r]),{clearAuthenticationToken:s,setAuthenticationToken:r}},B=({library:e,date:n,format:o="ll"})=>e(n).format(o),H=(e,n)=>{const{fractionDigits:o=0,metric:a="km",spacingBetween:r=!0}=n||{},s=Number(e),c=r?" ":"";return Number.isNaN(s)?`0${c}${a}`:`${s.toFixed(o)}${c}${a}`},X=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(o=>o.length>0?o.charAt(0).toUpperCase()+o.slice(1):o).join(" "),Pe=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Te=({path:e,size:n,apiURL:o})=>{if(!e)return"";const a=Pe(e),r=`${o}${a}`,s=r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof n=="number"&&s?`${r.replace("/files",`/thumbs/${n}`)}`:r},ke=e=>{const{apiURL:n,libraries:o}=f.useContext(A),a=e?.dayjs||o?.dayjs;return{dateAdapter:(c,d)=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return B({date:c,format:d,library:a})},distanceAdapter:H,filePathAdapter:(c,d)=>{if(!n)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:Te({apiURL:n,path:c,size:d})},worksiteNameAdapter:X}},W=(e,n)=>n==="short"?e.split("-")[0]:e,Ie=(e,n="full")=>{const[o,a]=f.useState(()=>{const r=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,W(r,n)});return f.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&a(W(e.language,n));const r=s=>{a(W(s,n))};return e?.on?.("languageChanged",r),()=>{e?.off?.("languageChanged",r)}},[e,n]),o},Oe="tracktor.filter",xe={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},Z=(e,n,o)=>`${o}_${e}=>${n}`,Ne=e=>e.reduce((n,o)=>{const a=localStorage.getItem(o);if(a)try{const r=JSON.parse(a),s=Object.keys(r)?.[0];s&&(n[s]=Object.values(r)?.[0])}catch{}return n},{}),Le=e=>{const{libraries:n,localStorageKeys:o}=f.useContext(A),a=e?.reactRouter||n?.reactRouter,{pathname:r}=a?.useLocation?.()??{pathname:"/"},[s,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],[d,l]=f.useState({}),u=o?.filter||Oe,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl;if(D)return xe;if(!a)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const E=()=>Object.keys(localStorage).filter(h=>h.startsWith(u)&&h.endsWith(e?.pathname||r)),y=(h,v,_=!0)=>{const m=Z(h,e?.pathname||r,u);if(!v||Array.isArray(v)&&!v.length){i?(s.delete(h),c(s)):l(b=>{const P={...b};return delete P[h],P}),localStorage.removeItem(m);return}_&&v&&localStorage.setItem(m,JSON.stringify({...s,[h]:v})),i&&v?(s.set(h,JSON.stringify(v)),c(s)):!i&&v&&l(b=>({...b,[h]:v}))};return{getFilter:(h,v)=>{if(!i){const b=d[h];if(b!==void 0)return b}if(i){const b=s.get(h);if(b)try{return JSON.parse(b)}catch{return b}}const _=Z(h,e?.pathname||r,u),m=localStorage.getItem(_);if(m)try{const b=JSON.parse(m)[h];return!i&&b!==void 0&&l(P=>({...P,[h]:b})),b}catch{}return v},getFilters:()=>{const h=E(),v=Ne(h);if(i){const _=Object.fromEntries(s.entries());return{...v,..._}}return{...v,...d}},handleFilter:(h,v)=>(_,m)=>{if(m||Array.isArray(m)&&m.length===0){const b=v||"value",P=typeof m=="object"&&b in m?m[b]:m;y(h,P);return}y(h,void 0)},setFilter:y}},Fe=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),De=e=>{const a=e.split("/").filter(r=>r.length>0).map(r=>r.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(l=>l.charAt(0).toUpperCase()+l.slice(1)).join("")).join("");return a.charAt(0).toLowerCase()+a.slice(1)},Ye=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),We=(e,n,o,a)=>{const r=De(n),s=Fe(o),c=`${r}${s}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},ze=(e,n)=>{const o={};return e?.forEach(a=>{o[a]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),n?.filter(a=>!o[a]).forEach(a=>{o[a]={query:{useQuery:!0}}}),Object.keys(o).length?o:void 0},Ue=e=>(Array.isArray(e)?e:[e]).reduce((o,a)=>{const{output:r,useInfiniteIds:s,useQueryIds:c,input:d="./openapi.json"}=a||{},l=Ye(d);return{...o,[l]:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:d,output:{baseUrl:r?.baseUrl,client:"react-query",mode:"tags-split",override:{...(s?.length||c?.length)&&{operations:ze(s,c)},header:u=>["Generated by orval 🍺",...u.title?[u.title]:[],...u.description?[u.description]:[]],mutator:{name:"axiosCustomInstance",path:"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts"},operationName:(u,i,E)=>We(u,i,E,c),query:{useQuery:!0}},schemas:r?.schemas||`src/api/${l}/model`,target:r?.target||`src/api/${l}/services/api.ts`,...r}}}},{});g.GTMSendPageView=fe,g.InitializeAxiosConfig=ge,g.InitializeDaysJSConfig=ve,g.InitializeI18nConfig=me,g.InitializeSentryConfig=ye,g.InjectDependenciesContext=A,g.InjectDependenciesProvider=le,g.MaskTextField=he,g.PreloadErrorHandler=Ee,g.QueryClientProviderWithConfig=Ae,g.RequireAuth=de,g.UpdateNotifier=be,g.axiosCustomInstance=ae,g.dateAdapter=B,g.distanceAdapter=H,g.getOrvalConfig=Ue,g.useAdapter=ke,g.useAuth=_e,g.useCurrentLanguage=Ie,g.useFilters=Le,g.useInfiniteDataGrid=je,g.useResponseError=Ce,g.worksiteNameAdapter=X,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tracktor/shared-module",
3
- "version": "2.18.0",
3
+ "version": "2.18.1",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "types": "./dist/main.d.ts",