@tracktor/shared-module 2.18.1 → 2.18.3

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
@@ -1,12 +1,6 @@
1
1
  # Changelog
2
2
 
3
- ## [2.18.0] - 2025-09-30
3
+ ## [2.18.3] - 2025-10-03
4
4
 
5
- ### ✨ Features
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.
5
+ ### ✨ Bugfixes
6
+ - allow overriding the apiName when the target openapi schema is a http url.
@@ -32,6 +32,16 @@ interface CustomOrvalConfig {
32
32
  * Like POST requests that you want to use with useQuery instead of useMutation
33
33
  */
34
34
  useQueryIds?: string[];
35
+ /**
36
+ * A custom Axios instance to be used instead of the default one provided by us.
37
+ * This is useful to define dynamic baseUrl in the axios default instance.
38
+ */
39
+ customAxiosInstancePath?: string;
40
+ /**
41
+ * The default API name inferred from the "filename".
42
+ * Orval can also retrieve OAS from a fully formed URL.
43
+ */
44
+ overrideApiName?: string;
35
45
  }
36
46
  interface OrvalConfig {
37
47
  [key: string]: CustomOrvalConfig;
@@ -41,6 +51,11 @@ interface OrvalConfig {
41
51
  * @param method
42
52
  */
43
53
  export declare const convertToCapitalize: (method: string) => string;
54
+ /**
55
+ * Retrieve the filename in a given OS path minus the file extension.
56
+ * @param fullPath
57
+ */
58
+ export declare const getFileNameWithoutExtension: (fullPath: string) => string;
44
59
  /**
45
60
  * Convert a route to camelCase
46
61
  * @param route
package/dist/main.js CHANGED
@@ -1,16 +1,16 @@
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 k, Suspense as ge, useCallback as L } from "react";
3
- const De = (e, n) => {
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 N } from "react";
3
+ const Ye = (e, r) => {
4
4
  const o = ee.CancelToken.source(), a = ee({
5
5
  ...e,
6
- ...n,
6
+ ...r,
7
7
  cancelToken: o.token
8
- }).then(({ data: r }) => r);
8
+ }).then(({ data: n }) => n);
9
9
  return a.cancel = () => {
10
10
  o.cancel("Query was cancelled");
11
11
  }, a;
12
12
  };
13
- var D = { exports: {} }, N = {};
13
+ var D = { exports: {} }, L = {};
14
14
  /**
15
15
  * @license React
16
16
  * react-jsx-runtime.production.js
@@ -22,25 +22,25 @@ var D = { exports: {} }, N = {};
22
22
  */
23
23
  var te;
24
24
  function me() {
25
- if (te) return N;
25
+ if (te) return L;
26
26
  te = 1;
27
- var e = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
28
- function o(a, r, i) {
27
+ var e = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
28
+ function o(a, n, s) {
29
29
  var c = null;
30
- if (i !== void 0 && (c = "" + i), r.key !== void 0 && (c = "" + r.key), "key" in r) {
31
- i = {};
32
- for (var d in r)
33
- d !== "key" && (i[d] = r[d]);
34
- } else i = r;
35
- return r = i.ref, {
30
+ if (s !== void 0 && (c = "" + s), n.key !== void 0 && (c = "" + n.key), "key" in n) {
31
+ s = {};
32
+ for (var u in n)
33
+ u !== "key" && (s[u] = n[u]);
34
+ } else s = n;
35
+ return n = s.ref, {
36
36
  $$typeof: e,
37
37
  type: a,
38
38
  key: c,
39
- ref: r !== void 0 ? r : null,
40
- props: i
39
+ ref: n !== void 0 ? n : null,
40
+ props: s
41
41
  };
42
42
  }
43
- return N.Fragment = n, N.jsx = o, N.jsxs = o, N;
43
+ return L.Fragment = r, L.jsx = o, L.jsxs = o, L;
44
44
  }
45
45
  var F = {};
46
46
  /**
@@ -53,7 +53,7 @@ var F = {};
53
53
  * LICENSE file in the root directory of this source tree.
54
54
  */
55
55
  var re;
56
- function ye() {
56
+ function he() {
57
57
  return re || (re = 1, process.env.NODE_ENV !== "production" && function() {
58
58
  function e(t) {
59
59
  if (t == null) return null;
@@ -61,7 +61,7 @@ function ye() {
61
61
  return t.$$typeof === le ? null : t.displayName || t.name || null;
62
62
  if (typeof t == "string") return t;
63
63
  switch (t) {
64
- case b:
64
+ case A:
65
65
  return "Fragment";
66
66
  case y:
67
67
  return "Profiler";
@@ -78,9 +78,9 @@ function ye() {
78
78
  switch (typeof t.tag == "number" && console.error(
79
79
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
80
80
  ), t.$$typeof) {
81
- case O:
81
+ case x:
82
82
  return "Portal";
83
- case p:
83
+ case g:
84
84
  return (t.displayName || "Context") + ".Provider";
85
85
  case _:
86
86
  return (t._context.displayName || "Context") + ".Consumer";
@@ -98,12 +98,12 @@ function ye() {
98
98
  }
99
99
  return null;
100
100
  }
101
- function n(t) {
101
+ function r(t) {
102
102
  return "" + t;
103
103
  }
104
104
  function o(t) {
105
105
  try {
106
- n(t);
106
+ r(t);
107
107
  var f = !1;
108
108
  } catch {
109
109
  f = !0;
@@ -115,11 +115,11 @@ function ye() {
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
- ), n(t);
118
+ ), r(t);
119
119
  }
120
120
  }
121
121
  function a(t) {
122
- if (t === b) return "<>";
122
+ if (t === A) return "<>";
123
123
  if (typeof t == "object" && t !== null && t.$$typeof === J)
124
124
  return "<...>";
125
125
  try {
@@ -129,11 +129,11 @@ function ye() {
129
129
  return "<...>";
130
130
  }
131
131
  }
132
- function r() {
132
+ function n() {
133
133
  var t = z.A;
134
134
  return t === null ? null : t.getOwner();
135
135
  }
136
- function i() {
136
+ function s() {
137
137
  return Error("react-stack-top-frame");
138
138
  }
139
139
  function c(t) {
@@ -143,7 +143,7 @@ function ye() {
143
143
  }
144
144
  return t.key !== void 0;
145
145
  }
146
- function d(t, f) {
146
+ function u(t, f) {
147
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)",
@@ -161,13 +161,13 @@ function ye() {
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 u(t, f, v, E, x, T, Q, V) {
164
+ function d(t, f, v, E, I, T, Q, V) {
165
165
  return v = T.ref, t = {
166
- $$typeof: S,
166
+ $$typeof: b,
167
167
  type: t,
168
168
  key: f,
169
169
  props: T,
170
- _owner: x
170
+ _owner: I
171
171
  }, (v !== void 0 ? v : null) !== null ? Object.defineProperty(t, "ref", {
172
172
  enumerable: !1,
173
173
  get: l
@@ -193,7 +193,7 @@ 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, v, E, x, T, Q, V) {
196
+ function i(t, f, v, E, I, T, Q, V) {
197
197
  var R = f.children;
198
198
  if (R !== void 0)
199
199
  if (E)
@@ -208,10 +208,10 @@ function ye() {
208
208
  else h(R);
209
209
  if (K.call(f, "key")) {
210
210
  R = e(t);
211
- var I = Object.keys(f).filter(function(de) {
211
+ var O = Object.keys(f).filter(function(de) {
212
212
  return de !== "key";
213
213
  });
214
- E = 0 < I.length ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}", Z[R + E] || (I = 0 < I.length ? "{" + I.join(": ..., ") + ": ...}" : "{}", console.error(
214
+ E = 0 < O.length ? "{key: someKey, " + O.join(": ..., ") + ": ...}" : "{key: someKey}", Z[R + E] || (O = 0 < O.length ? "{" + O.join(": ..., ") + ": ...}" : "{}", console.error(
215
215
  `A props object containing a "key" prop is being spread into JSX:
216
216
  let props = %s;
217
217
  <%s {...props} />
@@ -220,7 +220,7 @@ React keys must be passed directly to JSX without using spread:
220
220
  <%s key={someKey} {...props} />`,
221
221
  E,
222
222
  R,
223
- I,
223
+ O,
224
224
  R
225
225
  ), Z[R + E] = !0);
226
226
  }
@@ -229,56 +229,56 @@ React keys must be passed directly to JSX without using spread:
229
229
  for (var M in f)
230
230
  M !== "key" && (v[M] = f[M]);
231
231
  } else v = f;
232
- return R && d(
232
+ return R && u(
233
233
  v,
234
234
  typeof t == "function" ? t.displayName || t.name || "Unknown" : t
235
- ), u(
235
+ ), d(
236
236
  t,
237
237
  R,
238
238
  T,
239
- x,
240
- r(),
239
+ I,
240
+ n(),
241
241
  v,
242
242
  Q,
243
243
  V
244
244
  );
245
245
  }
246
246
  function h(t) {
247
- typeof t == "object" && t !== null && t.$$typeof === S && t._store && (t._store.validated = 1);
247
+ typeof t == "object" && t !== null && t.$$typeof === b && t._store && (t._store.validated = 1);
248
248
  }
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() {
249
+ var p = fe, b = Symbol.for("react.transitional.element"), x = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), _ = Symbol.for("react.consumer"), g = 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 = p.__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
- g = {
252
+ p = {
253
253
  "react-stack-bottom-frame": function(t) {
254
254
  return t();
255
255
  }
256
256
  };
257
- var q, B = {}, H = g["react-stack-bottom-frame"].bind(
258
- g,
259
- i
260
- )(), X = U(a(i)), Z = {};
261
- F.Fragment = b, F.jsx = function(t, f, v, E, x) {
257
+ var q, B = {}, H = p["react-stack-bottom-frame"].bind(
258
+ p,
259
+ s
260
+ )(), X = U(a(s)), Z = {};
261
+ F.Fragment = A, F.jsx = function(t, f, v, E, I) {
262
262
  var T = 1e4 > z.recentlyCreatedOwnerStacks++;
263
- return s(
263
+ return i(
264
264
  t,
265
265
  f,
266
266
  v,
267
267
  !1,
268
268
  E,
269
- x,
269
+ I,
270
270
  T ? Error("react-stack-top-frame") : H,
271
271
  T ? U(a(t)) : X
272
272
  );
273
- }, F.jsxs = function(t, f, v, E, x) {
273
+ }, F.jsxs = function(t, f, v, E, I) {
274
274
  var T = 1e4 > z.recentlyCreatedOwnerStacks++;
275
- return s(
275
+ return i(
276
276
  t,
277
277
  f,
278
278
  v,
279
279
  !0,
280
280
  E,
281
- x,
281
+ I,
282
282
  T ? Error("react-stack-top-frame") : H,
283
283
  T ? U(a(t)) : X
284
284
  );
@@ -286,47 +286,47 @@ React keys must be passed directly to JSX without using spread:
286
286
  }()), F;
287
287
  }
288
288
  var ne;
289
- function he() {
290
- return ne || (ne = 1, process.env.NODE_ENV === "production" ? D.exports = me() : D.exports = ye()), D.exports;
289
+ function ye() {
290
+ return ne || (ne = 1, process.env.NODE_ENV === "production" ? D.exports = me() : D.exports = he()), D.exports;
291
291
  }
292
- var C = he();
293
- const A = pe({}), Ye = ({ children: e, apiURL: n, libraries: o, localStorageKeys: a }) => {
294
- const r = G(
292
+ var C = ye();
293
+ const S = pe({}), We = ({ children: e, apiURL: r, libraries: o, localStorageKeys: a }) => {
294
+ const n = G(
295
295
  () => ({
296
- apiURL: n,
296
+ apiURL: r,
297
297
  libraries: o,
298
298
  localStorageKeys: a
299
299
  }),
300
- [n, o, a]
300
+ [r, o, a]
301
301
  );
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)
302
+ return /* @__PURE__ */ C.jsx(S.Provider, { value: n, children: e });
303
+ }, ve = "user", ze = ({ Fallback: e, isLogged: r, loginPath: o = "/login", redirect401Path: a = "/login", ...n }) => {
304
+ const { libraries: s, localStorageKeys: c } = j(S), u = n?.reactRouter || s?.reactRouter, l = n?.axios || s?.axios, d = n?.localStorageKey || c?.user || ve;
305
+ if (!u)
306
306
  throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
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;
307
+ const [i, h] = W(null), { useLocation: p, Navigate: b, Outlet: x } = u, A = p(), m = ae(!1), y = typeof r == "function" ? r() : !!r, _ = typeof y == "boolean" ? y : y?.isLogged;
308
308
  return k(() => {
309
309
  m.current || (m.current = !0, l.interceptors.response.use(
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 && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(u), h(a)), Promise.reject(p))
310
+ (g) => g,
311
+ async (g) => (typeof g == "object" && g && "response" in g && g.response && typeof g.response == "object" && "status" in g.response && g.response && typeof g.response == "object" && "status" in g.response && g?.response?.status === 401 && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(d), h(a)), Promise.reject(g))
312
312
  ));
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;
313
+ }, [l.defaults.headers.common, l.interceptors.response, d, a]), _ && !i ? /* @__PURE__ */ C.jsx(ge, { fallback: e, children: A.state?.from?.state && A.state?.from?.pathname === o ? /* @__PURE__ */ C.jsx(b, { to: A.state.from.state.from.pathname + A.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ C.jsx(x, {}) }) : /* @__PURE__ */ C.jsx(b, { to: o + A.search, state: { from: A }, replace: !0 });
314
+ }, Ue = ({ data: e, ...r }) => {
315
+ const { libraries: o } = j(S), a = r?.reactRouter || o?.reactRouter, n = r?.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 (!r)
320
+ if (!n)
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 } = r, { useLocation: c, Outlet: d } = a, { pathname: l } = c(), { sendEvent: u } = i();
322
+ const { useGoogleTagManager: s } = n, { useLocation: c, Outlet: u } = a, { pathname: l } = c(), { sendEvent: d } = s();
323
323
  return k(() => {
324
- u({
324
+ d({
325
325
  event: "pageView",
326
326
  pathname: l,
327
327
  ...e
328
328
  });
329
- }, [e, l, u]), /* @__PURE__ */ C.jsx(d, {});
329
+ }, [e, l, d]), /* @__PURE__ */ C.jsx(u, {});
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: n, libraries: o, localStorageKeys
335
335
  } catch {
336
336
  return !1;
337
337
  }
338
- })(), we = "user", Ue = ({
338
+ })(), we = "user", Qe = ({
339
339
  tokenTypeKey: e = "tokenType",
340
- tokenKey: n = "accessToken",
340
+ tokenKey: r = "accessToken",
341
341
  postContentType: o = "application/json",
342
342
  ...a
343
343
  }) => {
344
- const { apiURL: r = a.apiURL, libraries: i, localStorageKeys: c } = j(A), d = a?.userLocalStorageKey || c?.user || we, l = a?.axios || i?.axios;
344
+ const { apiURL: n = a.apiURL, libraries: s, localStorageKeys: c } = j(S), u = a?.userLocalStorageKey || c?.user || we, l = a?.axios || s?.axios;
345
345
  if (!l)
346
346
  throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
347
347
  if (!l?.defaults || $)
348
348
  return null;
349
349
  if (typeof window < "u" && window.localStorage) {
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);
350
+ const d = localStorage.getItem(u), i = d ? JSON.parse(d) : null, h = i?.[e] ? i[e] : null, p = i?.[r] ? i[r] : null, b = d ? `${h} ${p}` : null;
351
+ b && (l.defaults.headers.common.Authorization = b);
352
352
  }
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 || {};
353
+ return l.defaults.baseURL = n, l.defaults.headers.post["Content-Type"] = o, null;
354
+ }, Ve = ({ debug: e, resources: r, ...o }) => {
355
+ const { libraries: a } = j(S), n = o?.i18 || a?.i18, { i18next: s, initReactI18next: c, languageDetector: u } = n || {};
356
356
  if ($)
357
357
  return null;
358
- if (!r)
358
+ if (!n)
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(d).use(c).init({
360
+ return s?.isInitialized || (s.use(u).use(c).init({
361
361
  debug: e,
362
362
  fallbackLng: "en",
363
363
  interpolation: {
@@ -368,36 +368,36 @@ const A = pe({}), Ye = ({ children: e, apiURL: n, libraries: o, localStorageKeys
368
368
  bindI18n: "languageChanged loaded",
369
369
  useSuspense: !0
370
370
  },
371
- resources: n,
371
+ resources: r,
372
372
  returnNull: !1
373
373
  }).then(() => {
374
- document.documentElement.lang !== i.resolvedLanguage && i.resolvedLanguage && document.documentElement.setAttribute("lang", i.resolvedLanguage);
375
- }), i.on("languageChanged", (l) => {
374
+ document.documentElement.lang !== s.resolvedLanguage && s.resolvedLanguage && document.documentElement.setAttribute("lang", s.resolvedLanguage);
375
+ }), s.on("languageChanged", (l) => {
376
376
  document.documentElement.setAttribute("lang", l);
377
377
  })), null;
378
- }, Ve = ({
378
+ }, Me = ({
379
379
  dsn: e,
380
- integrations: n,
380
+ integrations: r,
381
381
  tracesSampleRate: o,
382
382
  replaysSessionSampleRate: a,
383
- replaysOnErrorSampleRate: r,
384
- tracePropagationTargets: i,
383
+ replaysOnErrorSampleRate: n,
384
+ tracePropagationTargets: s,
385
385
  ignoreErrors: c,
386
- debug: d,
386
+ debug: u,
387
387
  environment: l,
388
- release: u,
389
- ...s
388
+ release: d,
389
+ ...i
390
390
  }) => {
391
- const { libraries: h } = j(A), g = s?.sentry || h?.sentry, S = s?.reactRouter || h?.reactRouter;
392
- if (!g)
391
+ const { libraries: h } = j(S), p = i?.sentry || h?.sentry, b = i?.reactRouter || h?.reactRouter;
392
+ if (!p)
393
393
  throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
394
- if (!S)
394
+ if (!b)
395
395
  throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
396
- if (g.isInitialized())
396
+ if (p.isInitialized())
397
397
  return null;
398
- const { createRoutesFromChildren: O, matchRoutes: b, useLocation: m, useNavigationType: y } = S;
399
- return (d || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && g.init({
400
- debug: d,
398
+ const { createRoutesFromChildren: x, matchRoutes: A, useLocation: m, useNavigationType: y } = b;
399
+ return (u || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && p.init({
400
+ debug: u,
401
401
  dsn: e,
402
402
  environment: l || "production",
403
403
  ignoreErrors: [
@@ -410,30 +410,30 @@ const A = pe({}), Ye = ({ children: e, apiURL: n, libraries: o, localStorageKeys
410
410
  /vite:preloadError/
411
411
  ],
412
412
  integrations: [
413
- g.reactRouterV6BrowserTracingIntegration({
414
- createRoutesFromChildren: O,
415
- matchRoutes: b,
413
+ p.reactRouterV6BrowserTracingIntegration({
414
+ createRoutesFromChildren: x,
415
+ matchRoutes: A,
416
416
  useEffect: k,
417
417
  useLocation: m,
418
418
  useNavigationType: y
419
419
  }),
420
- ...n || []
420
+ ...r || []
421
421
  ],
422
- release: u,
423
- replaysOnErrorSampleRate: r || 1,
422
+ release: d,
423
+ replaysOnErrorSampleRate: n || 1,
424
424
  replaysSessionSampleRate: a || 0.1,
425
- tracePropagationTargets: i,
425
+ tracePropagationTargets: s,
426
426
  tracesSampleRate: o || 1
427
427
  }), null;
428
- }, Me = ({ IMaskMixin: e, ...n }) => {
428
+ }, Ge = ({ IMaskMixin: e, ...r }) => {
429
429
  const o = G(
430
430
  // eslint-disable-next-line react/jsx-props-no-spreading
431
- () => e(({ TextField: a, ...r }) => /* @__PURE__ */ C.jsx(a, { ...r })),
431
+ () => e(({ TextField: a, ...n }) => /* @__PURE__ */ C.jsx(a, { ...n })),
432
432
  [e]
433
433
  );
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;
434
+ return /* @__PURE__ */ C.jsx(o, { ...r });
435
+ }, Je = ({ language: e, ...r }) => {
436
+ const { libraries: o } = j(S), a = r?.dayjs || o?.dayjs, n = r?.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."
@@ -441,17 +441,17 @@ const A = pe({}), Ye = ({ children: e, apiURL: n, libraries: o, localStorageKeys
441
441
  return k(() => {
442
442
  (async () => {
443
443
  const c = e || navigator.language?.slice(0, 2) || "en";
444
- r && r.forEach((d) => {
445
- d && a.extend(d);
444
+ n && n.forEach((u) => {
445
+ u && a.extend(u);
446
446
  }), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), a.locale(c);
447
447
  })().then();
448
- }, [a, r, e]), null;
449
- }, Je = () => (k(() => {
448
+ }, [a, n, e]), null;
449
+ }, Ke = () => (k(() => {
450
450
  if ($)
451
451
  return;
452
- const e = (n) => {
452
+ const e = (r) => {
453
453
  try {
454
- n.preventDefault(), n.stopPropagation(), n.stopImmediatePropagation(), window.location.reload();
454
+ r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), window.location.reload();
455
455
  } catch {
456
456
  }
457
457
  };
@@ -462,196 +462,196 @@ const A = pe({}), Ye = ({ children: e, apiURL: n, 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((n) => caches.delete(n)));
465
+ await Promise.all(e.map((r) => caches.delete(r)));
466
466
  } catch (e) {
467
467
  console.error("Failed to clear caches:", e);
468
468
  }
469
- }, Ke = ({ autoUpdate: e, renderDialog: n, clearCachesOnReload: o }) => {
470
- const a = ae(null), [r, i] = W(!1), c = L(async () => {
469
+ }, qe = ({ autoUpdate: e, renderDialog: r, clearCachesOnReload: o }) => {
470
+ const a = ae(null), [n, s] = W(!1), c = N(async () => {
471
471
  a.current && a.current.postMessage({ type: "SKIP_WAITING" }), o && await Ee(), window.location.reload();
472
- }, [o]), d = L(async () => {
472
+ }, [o]), u = N(async () => {
473
473
  window.confirm("A new version is available. The app will reload now.") && await c();
474
474
  }, [c]);
475
475
  return k(() => {
476
476
  if (!("serviceWorker" in navigator)) return;
477
- let l, u;
478
- const s = (g) => {
479
- g && navigator.serviceWorker.controller && (a.current = g, i(!0));
477
+ let l, d;
478
+ const i = (p) => {
479
+ p && navigator.serviceWorker.controller && (a.current = p, s(!0));
480
480
  }, h = () => {
481
- const g = l?.installing;
482
- g && (u = () => {
483
- g.state === "installed" && s(g);
484
- }, g.addEventListener("statechange", u));
481
+ const p = l?.installing;
482
+ p && (d = () => {
483
+ p.state === "installed" && i(p);
484
+ }, p.addEventListener("statechange", d));
485
485
  };
486
486
  return (async () => {
487
- l = await navigator.serviceWorker.getRegistration(), l && (s(l.waiting), l.addEventListener("updatefound", h));
487
+ l = await navigator.serviceWorker.getRegistration(), l && (i(l.waiting), l.addEventListener("updatefound", h));
488
488
  })().catch(console.error), () => {
489
- l?.removeEventListener("updatefound", h), u && l?.installing && l.installing.removeEventListener("statechange", u);
489
+ l?.removeEventListener("updatefound", h), d && l?.installing && l.installing.removeEventListener("statechange", d);
490
490
  };
491
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;
496
- }, Re = (e) => e && typeof e == "function", be = (e) => e && typeof e == "function", qe = ({
492
+ n && e && c().catch(console.error);
493
+ }, [e, n, c]), k(() => {
494
+ n && !e && !r && u().catch(console.error);
495
+ }, [r, u, n, e]), n && !e && r ? r(c) : null;
496
+ }, Re = (e) => e && typeof e == "function", be = (e) => e && typeof e == "function", Be = ({
497
497
  children: e,
498
- defaultQueriesOptions: n,
498
+ defaultQueriesOptions: r,
499
499
  defaultMutationsOptions: o,
500
500
  ...a
501
501
  }) => {
502
- const { libraries: r } = j(A), i = a?.QueryClient || r?.reactQuery?.QueryClient, c = a?.QueryClientProvider || r?.reactQuery?.QueryClientProvider;
503
- if (!i)
502
+ const { libraries: n } = j(S), s = a?.QueryClient || n?.reactQuery?.QueryClient, c = a?.QueryClientProvider || n?.reactQuery?.QueryClientProvider;
503
+ if (!s)
504
504
  throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
505
505
  if (!c)
506
506
  throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
507
507
  if (!Re(c))
508
508
  throw new Error("Provided QueryClientProvider dependencies are not valid.");
509
- if (!be(i))
509
+ if (!be(s))
510
510
  throw new Error("Provided QueryClient dependencies are not valid.");
511
- const d = new i({
511
+ const u = new s({
512
512
  defaultOptions: {
513
513
  mutations: {
514
514
  ...o
515
515
  },
516
516
  queries: {
517
- getNextPageParam: (l, u, s) => l.length + (s || 0),
517
+ getNextPageParam: (l, d, i) => l.length + (i || 0),
518
518
  refetchOnWindowFocus: !1,
519
519
  retry: 3,
520
- ...n
520
+ ...r
521
521
  }
522
522
  }
523
523
  });
524
- return /* @__PURE__ */ C.jsx(c, { client: d, children: e });
525
- }, Be = (e) => {
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 || {};
530
- if (s && typeof s == "object" && "reason" in s)
531
- return String(s.reason);
532
- if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "reason" in s.data)
533
- return String(s.data.reason);
534
- if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "message" in s.data)
535
- return String(s.data.message);
536
- if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "detail" in s.data) {
537
- const { detail: h } = s.data;
524
+ return /* @__PURE__ */ C.jsx(c, { client: u, children: e });
525
+ }, He = (e) => {
526
+ const { libraries: r } = j(S), 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), u = N(
527
+ (d) => {
528
+ if (d && typeof d == "object" && "response" in d) {
529
+ const { response: i } = d || {};
530
+ if (i && typeof i == "object" && "reason" in i)
531
+ return String(i.reason);
532
+ if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "reason" in i.data)
533
+ return String(i.data.reason);
534
+ if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "message" in i.data)
535
+ return String(i.data.message);
536
+ if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "detail" in i.data) {
537
+ const { detail: h } = i.data;
538
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);
539
+ const { msg: p } = h[0];
540
+ if (typeof p == "string")
541
+ return String(p);
542
542
  }
543
543
  }
544
544
  }
545
- return u instanceof Error ? u.message : c;
545
+ return d instanceof Error ? d.message : c;
546
546
  },
547
547
  [c]
548
548
  );
549
- return { getErrorCode: L((u) => {
550
- const { response: s } = u || {};
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";
552
- }, []), printError: d };
553
- }, He = ({
549
+ return { getErrorCode: N((d) => {
550
+ const { response: i } = d || {};
551
+ 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";
552
+ }, []), printError: u };
553
+ }, Xe = ({
554
554
  data: e,
555
- fetchNextPage: n,
555
+ fetchNextPage: r,
556
556
  isFetchingNextPage: o,
557
557
  isInitialLoading: a,
558
- isLoading: r,
559
- enabled: i = !0
558
+ isLoading: n,
559
+ enabled: s = !0
560
560
  }) => {
561
- const c = L(
561
+ const c = N(
562
562
  async (l) => {
563
- o || !i || await n({ pageParam: l?.pageParam || l.visibleRowsCount });
563
+ o || !s || await r({ pageParam: l?.pageParam || l.visibleRowsCount });
564
564
  },
565
- [i, n, o]
566
- ), d = G(() => {
565
+ [s, r, o]
566
+ ), u = G(() => {
567
567
  if (e)
568
- return e.pages.reduce((l, u) => [...l, ...u], []);
568
+ return e.pages.reduce((l, d) => [...l, ...d], []);
569
569
  }, [e]);
570
570
  return {
571
571
  fetchNextPageOnRowsScrollEnd: c,
572
- isLoading: o || r,
572
+ isLoading: o || n,
573
573
  loadingVariant: a ? "skeleton" : "linear-progress",
574
- rows: d
574
+ rows: u
575
575
  };
576
- }, Xe = (e) => {
577
- const { libraries: n } = j(A), o = e?.axios || n?.axios, a = e?.localStorageKey || "user";
576
+ }, Ze = (e) => {
577
+ const { libraries: r } = j(S), o = e?.axios || r?.axios, a = e?.localStorageKey || "user";
578
578
  if (!o)
579
579
  throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
580
- const r = L(
581
- ({ tokenType: c, accessToken: d }) => {
582
- o.defaults.headers.common.Authorization = `${c} ${d}`;
580
+ const n = N(
581
+ ({ tokenType: c, accessToken: u }) => {
582
+ o.defaults.headers.common.Authorization = `${c} ${u}`;
583
583
  },
584
584
  [o.defaults.headers.common]
585
- ), i = () => {
585
+ ), s = () => {
586
586
  o.defaults.headers.common.Authorization = null;
587
587
  };
588
588
  return k(() => {
589
589
  if ($)
590
590
  return;
591
- const c = ({ newValue: d, key: l }) => {
592
- if (l === a && d)
591
+ const c = ({ newValue: u, key: l }) => {
592
+ if (l === a && u)
593
593
  try {
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);
594
+ const { accessToken: d, tokenType: i } = JSON.parse(u);
595
+ n({ accessToken: d, tokenType: i });
596
+ } catch (d) {
597
+ console.error("Failed to parse newValue from localStorage:", d);
598
598
  }
599
599
  };
600
600
  return window.addEventListener("storage", c), () => {
601
601
  window.removeEventListener("storage", c);
602
602
  };
603
- }, [a, r]), {
604
- clearAuthenticationToken: i,
605
- setAuthenticationToken: r
603
+ }, [a, n]), {
604
+ clearAuthenticationToken: s,
605
+ setAuthenticationToken: n
606
606
  };
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 ? " " : "";
609
- return Number.isNaN(i) ? `0${c}${a}` : `${i.toFixed(o)}${c}${a}`;
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 }) => {
607
+ }, Ae = ({ library: e, date: r, format: o = "ll" }) => e(r).format(o), Se = (e, r) => {
608
+ const { fractionDigits: o = 0, metric: a = "km", spacingBetween: n = !0 } = r || {}, s = Number(e), c = n ? " " : "";
609
+ return Number.isNaN(s) ? `0${c}${a}` : `${s.toFixed(o)}${c}${a}`;
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: r, apiURL: o }) => {
611
611
  if (!e)
612
612
  return "";
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;
615
- }, Ze = (e) => {
616
- const { apiURL: n, libraries: o } = j(A), a = e?.dayjs || o?.dayjs;
613
+ const a = _e(e), n = `${o}${a}`, s = n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
614
+ return typeof r == "number" && s ? `${n.replace("/files", `/thumbs/${r}`)}` : n;
615
+ }, et = (e) => {
616
+ const { apiURL: r, libraries: o } = j(S), a = e?.dayjs || o?.dayjs;
617
617
  return {
618
- dateAdapter: (c, d) => {
618
+ dateAdapter: (c, u) => {
619
619
  if (!a)
620
620
  throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
621
- return Se({
621
+ return Ae({
622
622
  date: c,
623
- format: d,
623
+ format: u,
624
624
  library: a
625
625
  });
626
626
  },
627
- distanceAdapter: Ae,
628
- filePathAdapter: (c, d) => {
629
- if (!n)
627
+ distanceAdapter: Se,
628
+ filePathAdapter: (c, u) => {
629
+ if (!r)
630
630
  throw new Error(
631
631
  "API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
632
632
  );
633
633
  return typeof c == "string" && /^https?:\/\//.test(c) ? c : Pe({
634
- apiURL: n,
634
+ apiURL: r,
635
635
  path: c,
636
- size: d
636
+ size: u
637
637
  });
638
638
  },
639
639
  worksiteNameAdapter: je
640
640
  };
641
- }, Y = (e, n) => n === "short" ? e.split("-")[0] : e, et = (e, n = "full") => {
641
+ }, Y = (e, r) => r === "short" ? e.split("-")[0] : e, tt = (e, r = "full") => {
642
642
  const [o, a] = W(() => {
643
- const r = e?.language || navigator.language;
644
- return e && "isInitialized" in e && e.isInitialized, Y(r, n);
643
+ const n = e?.language || navigator.language;
644
+ return e && "isInitialized" in e && e.isInitialized, Y(n, r);
645
645
  });
646
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));
647
+ e && "isInitialized" in e && e.isInitialized && e.language && a(Y(e.language, r));
648
+ const n = (s) => {
649
+ a(Y(s, r));
650
650
  };
651
- return e?.on?.("languageChanged", r), () => {
652
- e?.off?.("languageChanged", r);
651
+ return e?.on?.("languageChanged", n), () => {
652
+ e?.off?.("languageChanged", n);
653
653
  };
654
- }, [e, n]), o;
654
+ }, [e, r]), o;
655
655
  }, Te = "tracktor.filter", ke = {
656
656
  getFilter: () => {
657
657
  },
@@ -660,18 +660,18 @@ const A = pe({}), Ye = ({ children: e, apiURL: n, libraries: o, localStorageKeys
660
660
  },
661
661
  setFilter: () => {
662
662
  }
663
- }, oe = (e, n, o) => `${o}_${e}=>${n}`, Ce = (e) => e.reduce((n, o) => {
663
+ }, oe = (e, r, o) => `${o}_${e}=>${r}`, Ce = (e) => e.reduce((r, o) => {
664
664
  const a = localStorage.getItem(o);
665
665
  if (a)
666
666
  try {
667
- const r = JSON.parse(a), i = Object.keys(r)?.[0];
668
- i && (n[i] = Object.values(r)?.[0]);
667
+ const n = JSON.parse(a), s = Object.keys(n)?.[0];
668
+ s && (r[s] = Object.values(n)?.[0]);
669
669
  } catch {
670
670
  }
671
- return n;
672
- }, {}), tt = (e) => {
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;
671
+ return r;
672
+ }, {}), rt = (e) => {
673
+ const { libraries: r, localStorageKeys: o } = j(S), a = e?.reactRouter || r?.reactRouter, { pathname: n } = a?.useLocation?.() ?? { pathname: "/" }, [s, c] = a?.useSearchParams?.() ?? [new URLSearchParams(), () => {
674
+ }], [u, l] = W({}), d = o?.filter || Te, i = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl;
675
675
  if ($)
676
676
  return ke;
677
677
  if (!a)
@@ -679,27 +679,27 @@ const A = pe({}), Ye = ({ children: e, apiURL: n, libraries: o, localStorageKeys
679
679
  "React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter."
680
680
  );
681
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);
682
+ (m) => m.startsWith(d) && m.endsWith(e?.pathname || n)
683
+ ), p = (m, y, _ = !0) => {
684
+ const g = oe(m, e?.pathname || n, d);
685
685
  if (!y || Array.isArray(y) && !y.length) {
686
- s ? (i.delete(m), c(i)) : l((w) => {
686
+ i ? (s.delete(m), c(s)) : l((w) => {
687
687
  const P = { ...w };
688
688
  return delete P[m], P;
689
- }), localStorage.removeItem(p);
689
+ }), localStorage.removeItem(g);
690
690
  return;
691
691
  }
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 }));
692
+ _ && y && localStorage.setItem(g, JSON.stringify({ ...s, [m]: y })), i && y ? (s.set(m, JSON.stringify(y)), c(s)) : !i && y && l((w) => ({ ...w, [m]: y }));
693
693
  };
694
694
  return {
695
695
  getFilter: (m, y) => {
696
- if (!s) {
697
- const w = d[m];
696
+ if (!i) {
697
+ const w = u[m];
698
698
  if (w !== void 0)
699
699
  return w;
700
700
  }
701
- if (s) {
702
- const w = i.get(m);
701
+ if (i) {
702
+ const w = s.get(m);
703
703
  if (w)
704
704
  try {
705
705
  return JSON.parse(w);
@@ -707,19 +707,19 @@ const A = pe({}), Ye = ({ children: e, apiURL: n, libraries: o, localStorageKeys
707
707
  return w;
708
708
  }
709
709
  }
710
- const _ = oe(m, e?.pathname || r, u), p = localStorage.getItem(_);
711
- if (p)
710
+ const _ = oe(m, e?.pathname || n, d), g = localStorage.getItem(_);
711
+ if (g)
712
712
  try {
713
- const w = JSON.parse(p)[m];
714
- return !s && w !== void 0 && l((P) => ({ ...P, [m]: w })), w;
713
+ const w = JSON.parse(g)[m];
714
+ return !i && w !== void 0 && l((P) => ({ ...P, [m]: w })), w;
715
715
  } catch {
716
716
  }
717
717
  return y;
718
718
  },
719
719
  getFilters: () => {
720
720
  const m = h(), y = Ce(m);
721
- if (s) {
722
- const _ = Object.fromEntries(i.entries());
721
+ if (i) {
722
+ const _ = Object.fromEntries(s.entries());
723
723
  return {
724
724
  ...y,
725
725
  ..._
@@ -727,26 +727,29 @@ const A = pe({}), Ye = ({ children: e, apiURL: n, libraries: o, localStorageKeys
727
727
  }
728
728
  return {
729
729
  ...y,
730
- ...d
730
+ ...u
731
731
  };
732
732
  },
733
- handleFilter: (m, y) => (_, p) => {
734
- if (p || Array.isArray(p) && p.length === 0) {
735
- const w = y || "value", P = typeof p == "object" && w in p ? p[w] : p;
736
- g(m, P);
733
+ handleFilter: (m, y) => (_, g) => {
734
+ if (g || Array.isArray(g) && g.length === 0) {
735
+ const w = y || "value", P = typeof g == "object" && w in g ? g[w] : g;
736
+ p(m, P);
737
737
  return;
738
738
  }
739
- g(m, void 0);
739
+ p(m, void 0);
740
740
  },
741
- setFilter: g
741
+ setFilter: p
742
742
  };
743
- }, xe = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), Oe = (e) => {
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
+ }, xe = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), Ie = (e) => {
744
+ const r = e.split(/[/\\]/).pop() || "";
745
+ return r.substring(0, r.lastIndexOf("."));
746
+ }, Oe = (e) => {
747
+ 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("");
745
748
  return a.charAt(0).toLowerCase() + a.slice(1);
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}`;
749
+ }, Ne = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), Le = (e, r, o, a) => {
750
+ const n = Oe(r), s = xe(o), c = `${n}${s}`;
748
751
  return e && typeof e == "object" && "operationId" in e && a?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
749
- }, Ne = (e, n) => {
752
+ }, Fe = (e, r) => {
750
753
  const o = {};
751
754
  return e?.forEach((a) => {
752
755
  o[a] = {
@@ -756,73 +759,73 @@ const A = pe({}), Ye = ({ children: e, apiURL: n, libraries: o, localStorageKeys
756
759
  useQuery: !0
757
760
  }
758
761
  };
759
- }), n?.filter((a) => !o[a]).forEach((a) => {
762
+ }), r?.filter((a) => !o[a]).forEach((a) => {
760
763
  o[a] = {
761
764
  query: {
762
765
  useQuery: !0
763
766
  }
764
767
  };
765
768
  }), Object.keys(o).length ? o : void 0;
766
- }, rt = (e) => (Array.isArray(e) ? e : [e]).reduce((o, a) => {
767
- const { output: r, useInfiniteIds: i, useQueryIds: c, input: d = "./openapi.json" } = a || {}, l = Ie(d);
769
+ }, nt = (e) => (Array.isArray(e) ? e : [e]).reduce((o, a) => {
770
+ const { output: n, useInfiniteIds: s, useQueryIds: c, input: u = "./openapi.json", customAxiosInstancePath: l, overrideApiName: d } = a || {}, i = d || Ne(u), h = l || "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";
768
771
  return {
769
772
  ...o,
770
- [l]: {
773
+ [i]: {
771
774
  hooks: {
772
- afterAllFilesWrite: "prettier src/api/ --write"
775
+ afterAllFilesWrite: `prettier src/api/${i} --write`
773
776
  },
774
- input: d,
777
+ input: u,
775
778
  output: {
776
- baseUrl: r?.baseUrl,
779
+ baseUrl: n?.baseUrl,
777
780
  client: "react-query",
778
781
  mode: "tags-split",
779
782
  override: {
780
- ...(i?.length || c?.length) && {
781
- operations: Ne(i, c)
783
+ ...(s?.length || c?.length) && {
784
+ operations: Fe(s, c)
782
785
  },
783
- header: (u) => [
786
+ header: (p) => [
784
787
  "Generated by orval 🍺",
785
- ...u.title ? [u.title] : [],
786
- ...u.description ? [u.description] : []
788
+ ...p.title ? [p.title] : [],
789
+ ...p.description ? [p.description] : []
787
790
  ],
788
791
  mutator: {
789
- name: "axiosCustomInstance",
790
- path: "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts"
792
+ name: Ie(h),
793
+ path: h
791
794
  },
792
- operationName: (u, s, h) => Le(u, s, h, c),
795
+ operationName: (p, b, x) => Le(p, b, x, c),
793
796
  query: {
794
797
  useQuery: !0
795
798
  }
796
799
  },
797
- schemas: r?.schemas || `src/api/${l}/model`,
798
- target: r?.target || `src/api/${l}/services/api.ts`,
799
- ...r
800
+ schemas: n?.schemas || `src/api/${i}/model`,
801
+ target: n?.target || `src/api/${i}/services/api.ts`,
802
+ ...n
800
803
  }
801
804
  }
802
805
  };
803
806
  }, {});
804
807
  export {
805
- ze as GTMSendPageView,
806
- Ue as InitializeAxiosConfig,
807
- Ge as InitializeDaysJSConfig,
808
- Qe as InitializeI18nConfig,
809
- Ve as InitializeSentryConfig,
810
- A as InjectDependenciesContext,
811
- Ye as InjectDependenciesProvider,
812
- Me as MaskTextField,
813
- Je as PreloadErrorHandler,
814
- qe as QueryClientProviderWithConfig,
815
- We as RequireAuth,
816
- Ke as UpdateNotifier,
817
- De as axiosCustomInstance,
818
- Se as dateAdapter,
819
- Ae as distanceAdapter,
820
- rt as getOrvalConfig,
821
- Ze as useAdapter,
822
- Xe as useAuth,
823
- et as useCurrentLanguage,
824
- tt as useFilters,
825
- He as useInfiniteDataGrid,
826
- Be as useResponseError,
808
+ Ue as GTMSendPageView,
809
+ Qe as InitializeAxiosConfig,
810
+ Je as InitializeDaysJSConfig,
811
+ Ve as InitializeI18nConfig,
812
+ Me as InitializeSentryConfig,
813
+ S as InjectDependenciesContext,
814
+ We as InjectDependenciesProvider,
815
+ Ge as MaskTextField,
816
+ Ke as PreloadErrorHandler,
817
+ Be as QueryClientProviderWithConfig,
818
+ ze as RequireAuth,
819
+ qe as UpdateNotifier,
820
+ Ye as axiosCustomInstance,
821
+ Ae as dateAdapter,
822
+ Se as distanceAdapter,
823
+ nt as getOrvalConfig,
824
+ et as useAdapter,
825
+ Ze as useAuth,
826
+ tt as useCurrentLanguage,
827
+ rt as useFilters,
828
+ Xe as useInfiniteDataGrid,
829
+ He as useResponseError,
827
830
  je as worksiteNameAdapter
828
831
  };
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,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={};/**
1
+ (function(m,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],x):(m=typeof globalThis<"u"?globalThis:m||self,x(m["@tracktor/shared-module"]={},m.axios,m.React))})(this,function(m,x,f){"use strict";const ae=(e,r)=>{const o=x.CancelToken.source(),a=x({...e,...r,cancelToken:o.token}).then(({data:n})=>n);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"),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={};/**
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,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 L.Fragment=r,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 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:
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===Je?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case j:return"Fragment";case E:return"Profiler";case y:return"StrictMode";case _:return"Suspense";case Qe:return"SuspenseList";case Ge: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 I:return"Portal";case h:return(t.displayName||"Context")+".Provider";case P: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 Ve: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 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===j)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 i(){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 u(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 d(t,p,w,R,O,T,M,Q){return w=T.ref,t={$$typeof:S,type:t,key:p,props:T,_owner:O},(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 s(t,p,w,R,O,T,M,Q){var A=p.children;if(A!==void 0)if(R)if(Ke(A)){for(R=0;R<A.length;R++)v(A[R]);Object.freeze&&Object.freeze(A)}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(A);if($.call(p,"key")){A=e(t);var N=Object.keys(p).filter(function(Be){return Be!=="key"});R=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",oe[A+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,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"})});
22
+ <%s key={someKey} {...props} />`,R,A,N,A),oe[A+R]=!0)}if(A=null,w!==void 0&&(o(w),A=""+w),c(p)&&(o(p.key),A=""+p.key),"key"in p){w={};for(var V in p)V!=="key"&&(w[V]=p[V])}else w=p;return A&&u(w,typeof t=="function"?t.displayName||t.name||"Unknown":t),d(t,A,T,O,n(),w,M,Q)}function v(t){typeof t=="object"&&t!==null&&t.$$typeof===S&&t._store&&(t._store.validated=1)}var g=f,S=Symbol.for("react.transitional.element"),I=Symbol.for("react.portal"),j=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),h=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),Qe=Symbol.for("react.suspense_list"),Ve=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),Ge=Symbol.for("react.activity"),Je=Symbol.for("react.client.reference"),z=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,Ke=Array.isArray,U=console.createTask?console.createTask:function(){return null};g={"react-stack-bottom-frame":function(t){return t()}};var ee,te={},re=g["react-stack-bottom-frame"].bind(g,i)(),ne=U(a(i)),oe={};F.Fragment=j,F.jsx=function(t,p,w,R,O){var T=1e4>z.recentlyCreatedOwnerStacks++;return s(t,p,w,!1,R,O,T?Error("react-stack-top-frame"):re,T?U(a(t)):ne)},F.jsxs=function(t,p,w,R,O){var T=1e4>z.recentlyCreatedOwnerStacks++;return s(t,p,w,!0,R,O,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 C=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(C.Provider,{value:n,children:e})},ue="user",de=({Fallback:e,isLogged:r,loginPath:o="/login",redirect401Path:a="/login",...n})=>{const{libraries:i,localStorageKeys:c}=f.useContext(C),u=n?.reactRouter||i?.reactRouter,l=n?.axios||i?.axios,d=n?.localStorageKey||c?.user||ue;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:I}=u,j=g(),y=f.useRef(!1),E=typeof r=="function"?r():!!r,P=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]),P&&!s?k.jsx(f.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===o?k.jsx(S,{to:j.state.from.state.from.pathname+j.state.from.state.from.search,replace:!0}):k.jsx(I,{})}):k.jsx(S,{to:o+j.search,state:{from:j},replace:!0})},fe=({data:e,...r})=>{const{libraries:o}=f.useContext(C),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]),k.jsx(u,{})},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:i,localStorageKeys:c}=f.useContext(C),u=a?.userLocalStorageKey||c?.user||pe,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||D)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},me=({debug:e,resources:r,...o})=>{const{libraries:a}=f.useContext(C),n=o?.i18||a?.i18,{i18next:i,initReactI18next:c,languageDetector:u}=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 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},he=({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(C),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:I,matchRoutes:j,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:I,matchRoutes:j,useEffect:f.useEffect,useLocation:y,useNavigationType:E}),...r||[]],release:d,replaysOnErrorSampleRate:n||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:i,tracesSampleRate:o||1}),null},ye=({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(C),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},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=({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 we(),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},Re=e=>e&&typeof e=="function",Ae=e=>e&&typeof e=="function",Se=({children:e,defaultQueriesOptions:r,defaultMutationsOptions:o,...a})=>{const{libraries:n}=f.useContext(C),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(!Re(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ae(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 k.jsx(c,{client:u,children:e})},Ce=e=>{const{libraries:r}=f.useContext(C),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)return String(s.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"reason"in s.data)return String(s.data.reason);if(s&&typeof s=="object"&&"data"in s&&s.data&&typeof s.data=="object"&&"message"in s.data)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}},je=({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}},Pe=e=>{const{libraries:r}=f.useContext(C),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(D)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}},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||{},i=Number(e),c=n?" ":"";return Number.isNaN(i)?`0${c}${a}`:`${i.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(" "),_e=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=_e(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},ke=e=>{const{apiURL:r,libraries:o}=f.useContext(C),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 B({date:c,format:u,library:a})},distanceAdapter:H,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:Te({apiURL:r,path:c,size:u})},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=i=>{a(W(i,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),i=Object.keys(n)?.[0];i&&(r[i]=Object.values(n)?.[0])}catch{}return r},{}),Le=e=>{const{libraries:r,localStorageKeys:o}=f.useContext(C),a=e?.reactRouter||r?.reactRouter,{pathname:n}=a?.useLocation?.()??{pathname:"/"},[i,c]=a?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,l]=f.useState({}),d=o?.filter||Oe,s=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 v=()=>Object.keys(localStorage).filter(y=>y.startsWith(d)&&y.endsWith(e?.pathname||n)),g=(y,E,P=!0)=>{const h=Z(y,e?.pathname||n,d);if(!E||Array.isArray(E)&&!E.length){s?(i.delete(y),c(i)):l(b=>{const _={...b};return delete _[y],_}),localStorage.removeItem(h);return}P&&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 P=Z(y,e?.pathname||n,d),h=localStorage.getItem(P);if(h)try{const b=JSON.parse(h)[y];return!s&&b!==void 0&&l(_=>({..._,[y]:b})),b}catch{}return E},getFilters:()=>{const y=v(),E=Ne(y);if(s){const P=Object.fromEntries(i.entries());return{...E,...P}}return{...E,...u}},handleFilter:(y,E)=>(P,h)=>{if(h||Array.isArray(h)&&h.length===0){const b=E||"value",_=typeof h=="object"&&b in h?h[b]:h;g(y,_);return}g(y,void 0)},setFilter:g}},Fe=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),De=e=>{const r=e.split(/[/\\]/).pop()||"";return r.substring(0,r.lastIndexOf("."))},Ye=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)},We=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),ze=(e,r,o,a)=>{const n=Ye(r),i=Fe(o),c=`${n}${i}`;return e&&typeof e=="object"&&"operationId"in e&&a?.includes(String(e.operationId))?`${c}AsQuery`:c},Ue=(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},Me=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||We(u),v=l||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...o,[s]:{hooks:{afterAllFilesWrite:`prettier src/api/${s} --write`},input:u,output:{baseUrl:n?.baseUrl,client:"react-query",mode:"tags-split",override:{...(i?.length||c?.length)&&{operations:Ue(i,c)},header:g=>["Generated by orval 🍺",...g.title?[g.title]:[],...g.description?[g.description]:[]],mutator:{name:De(v),path:v},operationName:(g,S,I)=>ze(g,S,I,c),query:{useQuery:!0}},schemas:n?.schemas||`src/api/${s}/model`,target:n?.target||`src/api/${s}/services/api.ts`,...n}}}},{});m.GTMSendPageView=fe,m.InitializeAxiosConfig=ge,m.InitializeDaysJSConfig=ve,m.InitializeI18nConfig=me,m.InitializeSentryConfig=he,m.InjectDependenciesContext=C,m.InjectDependenciesProvider=le,m.MaskTextField=ye,m.PreloadErrorHandler=Ee,m.QueryClientProviderWithConfig=Se,m.RequireAuth=de,m.UpdateNotifier=be,m.axiosCustomInstance=ae,m.dateAdapter=B,m.distanceAdapter=H,m.getOrvalConfig=Me,m.useAdapter=ke,m.useAuth=Pe,m.useCurrentLanguage=Ie,m.useFilters=Le,m.useInfiniteDataGrid=je,m.useResponseError=Ce,m.worksiteNameAdapter=X,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tracktor/shared-module",
3
- "version": "2.18.1",
3
+ "version": "2.18.3",
4
4
  "type": "module",
5
5
  "license": "UNLICENSED",
6
6
  "types": "./dist/main.d.ts",
@@ -27,6 +27,7 @@
27
27
  "dev": "vite",
28
28
  "build": "vite build",
29
29
  "lint": "eslint . --max-warnings=0 && tsc --noEmit",
30
+ "lint:fix": "eslint . --max-warnings=0 --fix",
30
31
  "preview": "vite preview",
31
32
  "test": "yarn lint && vitest",
32
33
  "prepare": "yarn run build && husky install"