@tracktor/shared-module 2.22.0 → 2.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,309 +1,401 @@
1
- import Z from "axios";
2
- import fe, { useMemo as M, createContext as pe, useContext as j, useEffect as k, useState as J, Suspense as ge, useCallback as Y } from "react";
3
- const De = (e, r) => {
4
- const a = Z.CancelToken.source(), o = Z({
1
+ import oe from "axios";
2
+ import he, { useMemo as Z, createContext as ge, useContext as k, useEffect as I, useState as M, Suspense as me, useCallback as x, useRef as se } from "react";
3
+ const Qe = (e, t) => {
4
+ const n = oe.CancelToken.source(), s = oe({
5
5
  ...e,
6
- ...r,
7
- cancelToken: a.token
8
- }).then(({ data: n }) => n);
9
- return o.cancel = () => {
10
- a.cancel("Query was cancelled");
11
- }, o;
12
- };
13
- var $ = { exports: {} }, I = {};
14
- var ee;
15
- function me() {
16
- if (ee) return I;
17
- ee = 1;
18
- var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), r = /* @__PURE__ */ Symbol.for("react.fragment");
19
- function a(o, n, i) {
6
+ ...t,
7
+ cancelToken: n.token
8
+ }).then(({ data: o }) => o);
9
+ return s.cancel = () => {
10
+ n.cancel("Query was cancelled");
11
+ }, s;
12
+ }, ye = 3e4, ae = 1e3;
13
+ class Ee {
14
+ url;
15
+ getToken;
16
+ onEvent;
17
+ onConnectionChange;
18
+ shouldReconnect;
19
+ maxReconnectAttempts;
20
+ reconnectBaseDelay;
21
+ ws = null;
22
+ reconnectAttempt = 0;
23
+ reconnectTimer = null;
24
+ intentionalClose = !1;
25
+ joinedThreads = /* @__PURE__ */ new Set();
26
+ pendingMessages = [];
27
+ _connected = !1;
28
+ _ready = !1;
29
+ constructor(t) {
30
+ this.url = t.url, this.getToken = t.getToken, this.onEvent = t.onEvent, this.onConnectionChange = t.onConnectionChange, this.shouldReconnect = t.reconnect ?? !0, this.maxReconnectAttempts = t.maxReconnectAttempts ?? Number.POSITIVE_INFINITY, this.reconnectBaseDelay = t.reconnectBaseDelay ?? 1e3;
31
+ }
32
+ get connected() {
33
+ return this._connected;
34
+ }
35
+ get ready() {
36
+ return this._ready;
37
+ }
38
+ connect() {
39
+ const t = this.getToken();
40
+ if (!t)
41
+ return;
42
+ this.intentionalClose = !1;
43
+ const n = this.url.includes("?") ? "&" : "?", s = `${this.url}${n}token=${t}`;
44
+ this.ws = new WebSocket(s), this.ws.onopen = () => {
45
+ this._connected = !0, this.reconnectAttempt = 0, this.onConnectionChange?.(!0), this.rejoinThreads(), this.flushPendingMessages();
46
+ }, this.ws.onmessage = (o) => {
47
+ try {
48
+ const a = JSON.parse(o.data);
49
+ a.type === "ready" && (this._ready = !0), this.onEvent?.(a);
50
+ } catch {
51
+ }
52
+ }, this.ws.onclose = () => {
53
+ this._connected = !1, this._ready = !1, this.onConnectionChange?.(!1), !this.intentionalClose && this.shouldReconnect && this.reconnectAttempt < this.maxReconnectAttempts && this.scheduleReconnect();
54
+ }, this.ws.onerror = () => {
55
+ };
56
+ }
57
+ disconnect() {
58
+ this.intentionalClose = !0, this.pendingMessages = [], this.clearReconnectTimer(), this.ws && (this.ws.close(), this.ws = null);
59
+ }
60
+ joinThread(t) {
61
+ this.joinedThreads.add(t), this.send({ threadId: t, type: "join_thread" });
62
+ }
63
+ leaveThread(t) {
64
+ this.joinedThreads.delete(t), this.send({ threadId: t, type: "leave_thread" });
65
+ }
66
+ sendMessage(t, n) {
67
+ if (n.length > ae)
68
+ throw new Error(`Message body exceeds maximum length of ${ae} characters`);
69
+ this.send({ body: n, threadId: t, type: "send_message" });
70
+ }
71
+ markRead(t) {
72
+ this.send({ threadId: t, type: "mark_read" });
73
+ }
74
+ listThreads(t, n) {
75
+ this.send({ limit: t, offset: n, type: "list_threads" });
76
+ }
77
+ send(t) {
78
+ if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
79
+ this.pendingMessages.push(t);
80
+ return;
81
+ }
82
+ this.ws.send(JSON.stringify(t));
83
+ }
84
+ flushPendingMessages() {
85
+ const t = [...this.pendingMessages];
86
+ this.pendingMessages = [];
87
+ for (const n of t)
88
+ this.send(n);
89
+ }
90
+ rejoinThreads() {
91
+ for (const t of this.joinedThreads)
92
+ this.send({ threadId: t, type: "join_thread" });
93
+ }
94
+ scheduleReconnect() {
95
+ this.clearReconnectTimer();
96
+ const t = Math.min(this.reconnectBaseDelay * 2 ** this.reconnectAttempt, ye);
97
+ this.reconnectAttempt++, this.reconnectTimer = setTimeout(() => {
98
+ this.connect();
99
+ }, t);
100
+ }
101
+ clearReconnectTimer() {
102
+ this.reconnectTimer !== null && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null);
103
+ }
104
+ }
105
+ var Q = { exports: {} }, D = {};
106
+ var ie;
107
+ function ve() {
108
+ if (ie) return D;
109
+ ie = 1;
110
+ var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
111
+ function n(s, o, a) {
20
112
  var c = null;
21
- if (i !== void 0 && (c = "" + i), n.key !== void 0 && (c = "" + n.key), "key" in n) {
22
- i = {};
23
- for (var l in n)
24
- l !== "key" && (i[l] = n[l]);
25
- } else i = n;
26
- return n = i.ref, {
113
+ if (a !== void 0 && (c = "" + a), o.key !== void 0 && (c = "" + o.key), "key" in o) {
114
+ a = {};
115
+ for (var l in o)
116
+ l !== "key" && (a[l] = o[l]);
117
+ } else a = o;
118
+ return o = a.ref, {
27
119
  $$typeof: e,
28
- type: o,
120
+ type: s,
29
121
  key: c,
30
- ref: n !== void 0 ? n : null,
31
- props: i
122
+ ref: o !== void 0 ? o : null,
123
+ props: a
32
124
  };
33
125
  }
34
- return I.Fragment = r, I.jsx = a, I.jsxs = a, I;
126
+ return D.Fragment = t, D.jsx = n, D.jsxs = n, D;
35
127
  }
36
- var N = {};
37
- var te;
38
- function ye() {
39
- return te || (te = 1, process.env.NODE_ENV !== "production" && (function() {
40
- function e(t) {
41
- if (t == null) return null;
42
- if (typeof t == "function")
43
- return t.$$typeof === le ? null : t.displayName || t.name || null;
44
- if (typeof t == "string") return t;
45
- switch (t) {
46
- case P:
128
+ var Y = {};
129
+ var ce;
130
+ function we() {
131
+ return ce || (ce = 1, process.env.NODE_ENV !== "production" && (function() {
132
+ function e(r) {
133
+ if (r == null) return null;
134
+ if (typeof r == "function")
135
+ return r.$$typeof === q ? null : r.displayName || r.name || null;
136
+ if (typeof r == "string") return r;
137
+ switch (r) {
138
+ case j:
47
139
  return "Fragment";
48
140
  case d:
49
141
  return "Profiler";
50
- case g:
142
+ case m:
51
143
  return "StrictMode";
52
- case x:
144
+ case C:
53
145
  return "Suspense";
54
- case se:
146
+ case T:
55
147
  return "SuspenseList";
56
- case ce:
148
+ case K:
57
149
  return "Activity";
58
150
  }
59
- if (typeof t == "object")
60
- switch (typeof t.tag == "number" && console.error(
151
+ if (typeof r == "object")
152
+ switch (typeof r.tag == "number" && console.error(
61
153
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
62
- ), t.$$typeof) {
63
- case A:
154
+ ), r.$$typeof) {
155
+ case S:
64
156
  return "Portal";
157
+ case E:
158
+ return r.displayName || "Context";
159
+ case y:
160
+ return (r._context.displayName || "Context") + ".Consumer";
65
161
  case b:
66
- return t.displayName || "Context";
67
- case R:
68
- return (t._context.displayName || "Context") + ".Consumer";
69
- case _:
70
- var f = t.render;
71
- return t = t.displayName, t || (t = f.displayName || f.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
72
- case ie:
73
- return f = t.displayName || null, f !== null ? f : e(t.type) || "Memo";
74
- case z:
75
- f = t._payload, t = t._init;
162
+ var p = r.render;
163
+ return r = r.displayName, r || (r = p.displayName || p.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
164
+ case G:
165
+ return p = r.displayName || null, p !== null ? p : e(r.type) || "Memo";
166
+ case L:
167
+ p = r._payload, r = r._init;
76
168
  try {
77
- return e(t(f));
169
+ return e(r(p));
78
170
  } catch {
79
171
  }
80
172
  }
81
173
  return null;
82
174
  }
83
- function r(t) {
84
- return "" + t;
175
+ function t(r) {
176
+ return "" + r;
85
177
  }
86
- function a(t) {
178
+ function n(r) {
87
179
  try {
88
- r(t);
89
- var f = !1;
180
+ t(r);
181
+ var p = !1;
90
182
  } catch {
91
- f = !0;
183
+ p = !0;
92
184
  }
93
- if (f) {
94
- f = console;
95
- var h = f.error, E = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
96
- return h.call(
97
- f,
185
+ if (p) {
186
+ p = console;
187
+ var w = p.error, R = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
188
+ return w.call(
189
+ p,
98
190
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
99
- E
100
- ), r(t);
191
+ R
192
+ ), t(r);
101
193
  }
102
194
  }
103
- function o(t) {
104
- if (t === P) return "<>";
105
- if (typeof t == "object" && t !== null && t.$$typeof === z)
195
+ function s(r) {
196
+ if (r === j) return "<>";
197
+ if (typeof r == "object" && r !== null && r.$$typeof === L)
106
198
  return "<...>";
107
199
  try {
108
- var f = e(t);
109
- return f ? "<" + f + ">" : "<...>";
200
+ var p = e(r);
201
+ return p ? "<" + p + ">" : "<...>";
110
202
  } catch {
111
203
  return "<...>";
112
204
  }
113
205
  }
114
- function n() {
115
- var t = U.A;
116
- return t === null ? null : t.getOwner();
206
+ function o() {
207
+ var r = $.A;
208
+ return r === null ? null : r.getOwner();
117
209
  }
118
- function i() {
210
+ function a() {
119
211
  return Error("react-stack-top-frame");
120
212
  }
121
- function c(t) {
122
- if (q.call(t, "key")) {
123
- var f = Object.getOwnPropertyDescriptor(t, "key").get;
124
- if (f && f.isReactWarning) return !1;
213
+ function c(r) {
214
+ if (z.call(r, "key")) {
215
+ var p = Object.getOwnPropertyDescriptor(r, "key").get;
216
+ if (p && p.isReactWarning) return !1;
125
217
  }
126
- return t.key !== void 0;
218
+ return r.key !== void 0;
127
219
  }
128
- function l(t, f) {
129
- function h() {
130
- G || (G = !0, console.error(
220
+ function l(r, p) {
221
+ function w() {
222
+ W || (W = !0, console.error(
131
223
  "%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)",
132
- f
224
+ p
133
225
  ));
134
226
  }
135
- h.isReactWarning = !0, Object.defineProperty(t, "key", {
136
- get: h,
227
+ w.isReactWarning = !0, Object.defineProperty(r, "key", {
228
+ get: w,
137
229
  configurable: !0
138
230
  });
139
231
  }
140
232
  function u() {
141
- var t = e(this.type);
142
- return K[t] || (K[t] = !0, console.error(
233
+ var r = e(this.type);
234
+ return ee[r] || (ee[r] = !0, console.error(
143
235
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
144
- )), t = this.props.ref, t !== void 0 ? t : null;
236
+ )), r = this.props.ref, r !== void 0 ? r : null;
145
237
  }
146
- function p(t, f, h, E, F, Q) {
147
- var w = h.ref;
148
- return t = {
149
- $$typeof: T,
150
- type: t,
151
- key: f,
152
- props: h,
153
- _owner: E
154
- }, (w !== void 0 ? w : null) !== null ? Object.defineProperty(t, "ref", {
238
+ function f(r, p, w, R, V, H) {
239
+ var _ = w.ref;
240
+ return r = {
241
+ $$typeof: P,
242
+ type: r,
243
+ key: p,
244
+ props: w,
245
+ _owner: R
246
+ }, (_ !== void 0 ? _ : null) !== null ? Object.defineProperty(r, "ref", {
155
247
  enumerable: !1,
156
248
  get: u
157
- }) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
249
+ }) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
158
250
  configurable: !1,
159
251
  enumerable: !1,
160
252
  writable: !0,
161
253
  value: 0
162
- }), Object.defineProperty(t, "_debugInfo", {
254
+ }), Object.defineProperty(r, "_debugInfo", {
163
255
  configurable: !1,
164
256
  enumerable: !1,
165
257
  writable: !0,
166
258
  value: null
167
- }), Object.defineProperty(t, "_debugStack", {
259
+ }), Object.defineProperty(r, "_debugStack", {
168
260
  configurable: !1,
169
261
  enumerable: !1,
170
262
  writable: !0,
171
- value: F
172
- }), Object.defineProperty(t, "_debugTask", {
263
+ value: V
264
+ }), Object.defineProperty(r, "_debugTask", {
173
265
  configurable: !1,
174
266
  enumerable: !1,
175
267
  writable: !0,
176
- value: Q
177
- }), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
268
+ value: H
269
+ }), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
178
270
  }
179
- function s(t, f, h, E, F, Q) {
180
- var w = f.children;
181
- if (w !== void 0)
182
- if (E)
183
- if (ue(w)) {
184
- for (E = 0; E < w.length; E++)
185
- m(w[E]);
186
- Object.freeze && Object.freeze(w);
271
+ function i(r, p, w, R, V, H) {
272
+ var _ = p.children;
273
+ if (_ !== void 0)
274
+ if (R)
275
+ if (B(_)) {
276
+ for (R = 0; R < _.length; R++)
277
+ g(_[R]);
278
+ Object.freeze && Object.freeze(_);
187
279
  } else
188
280
  console.error(
189
281
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
190
282
  );
191
- else m(w);
192
- if (q.call(f, "key")) {
193
- w = e(t);
194
- var O = Object.keys(f).filter(function(de) {
195
- return de !== "key";
283
+ else g(_);
284
+ if (z.call(p, "key")) {
285
+ _ = e(r);
286
+ var N = Object.keys(p).filter(function(pe) {
287
+ return pe !== "key";
196
288
  });
197
- E = 0 < O.length ? "{key: someKey, " + O.join(": ..., ") + ": ...}" : "{key: someKey}", X[w + E] || (O = 0 < O.length ? "{" + O.join(": ..., ") + ": ...}" : "{}", console.error(
289
+ R = 0 < N.length ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}", ne[_ + R] || (N = 0 < N.length ? "{" + N.join(": ..., ") + ": ...}" : "{}", console.error(
198
290
  `A props object containing a "key" prop is being spread into JSX:
199
291
  let props = %s;
200
292
  <%s {...props} />
201
293
  React keys must be passed directly to JSX without using spread:
202
294
  let props = %s;
203
295
  <%s key={someKey} {...props} />`,
204
- E,
205
- w,
206
- O,
207
- w
208
- ), X[w + E] = !0);
296
+ R,
297
+ _,
298
+ N,
299
+ _
300
+ ), ne[_ + R] = !0);
209
301
  }
210
- if (w = null, h !== void 0 && (a(h), w = "" + h), c(f) && (a(f.key), w = "" + f.key), "key" in f) {
211
- h = {};
212
- for (var V in f)
213
- V !== "key" && (h[V] = f[V]);
214
- } else h = f;
215
- return w && l(
216
- h,
217
- typeof t == "function" ? t.displayName || t.name || "Unknown" : t
218
- ), p(
219
- t,
302
+ if (_ = null, w !== void 0 && (n(w), _ = "" + w), c(p) && (n(p.key), _ = "" + p.key), "key" in p) {
303
+ w = {};
304
+ for (var X in p)
305
+ X !== "key" && (w[X] = p[X]);
306
+ } else w = p;
307
+ return _ && l(
308
+ w,
309
+ typeof r == "function" ? r.displayName || r.name || "Unknown" : r
310
+ ), f(
311
+ r,
312
+ _,
220
313
  w,
221
- h,
222
- n(),
223
- F,
224
- Q
314
+ o(),
315
+ V,
316
+ H
225
317
  );
226
318
  }
227
- function m(t) {
228
- y(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === z && (t._payload.status === "fulfilled" ? y(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
319
+ function g(r) {
320
+ h(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === L && (r._payload.status === "fulfilled" ? h(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
229
321
  }
230
- function y(t) {
231
- return typeof t == "object" && t !== null && t.$$typeof === T;
322
+ function h(r) {
323
+ return typeof r == "object" && r !== null && r.$$typeof === P;
232
324
  }
233
- var v = fe, T = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), P = /* @__PURE__ */ Symbol.for("react.fragment"), g = /* @__PURE__ */ Symbol.for("react.strict_mode"), d = /* @__PURE__ */ Symbol.for("react.profiler"), R = /* @__PURE__ */ Symbol.for("react.consumer"), b = /* @__PURE__ */ Symbol.for("react.context"), _ = /* @__PURE__ */ Symbol.for("react.forward_ref"), x = /* @__PURE__ */ Symbol.for("react.suspense"), se = /* @__PURE__ */ Symbol.for("react.suspense_list"), ie = /* @__PURE__ */ Symbol.for("react.memo"), z = /* @__PURE__ */ Symbol.for("react.lazy"), ce = /* @__PURE__ */ Symbol.for("react.activity"), le = /* @__PURE__ */ Symbol.for("react.client.reference"), U = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, q = Object.prototype.hasOwnProperty, ue = Array.isArray, W = console.createTask ? console.createTask : function() {
325
+ var v = he, P = /* @__PURE__ */ Symbol.for("react.transitional.element"), S = /* @__PURE__ */ Symbol.for("react.portal"), j = /* @__PURE__ */ Symbol.for("react.fragment"), m = /* @__PURE__ */ Symbol.for("react.strict_mode"), d = /* @__PURE__ */ Symbol.for("react.profiler"), y = /* @__PURE__ */ Symbol.for("react.consumer"), E = /* @__PURE__ */ Symbol.for("react.context"), b = /* @__PURE__ */ Symbol.for("react.forward_ref"), C = /* @__PURE__ */ Symbol.for("react.suspense"), T = /* @__PURE__ */ Symbol.for("react.suspense_list"), G = /* @__PURE__ */ Symbol.for("react.memo"), L = /* @__PURE__ */ Symbol.for("react.lazy"), K = /* @__PURE__ */ Symbol.for("react.activity"), q = /* @__PURE__ */ Symbol.for("react.client.reference"), $ = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, z = Object.prototype.hasOwnProperty, B = Array.isArray, F = console.createTask ? console.createTask : function() {
234
326
  return null;
235
327
  };
236
328
  v = {
237
- react_stack_bottom_frame: function(t) {
238
- return t();
329
+ react_stack_bottom_frame: function(r) {
330
+ return r();
239
331
  }
240
332
  };
241
- var G, K = {}, B = v.react_stack_bottom_frame.bind(
333
+ var W, ee = {}, te = v.react_stack_bottom_frame.bind(
242
334
  v,
243
- i
244
- )(), H = W(o(i)), X = {};
245
- N.Fragment = P, N.jsx = function(t, f, h) {
246
- var E = 1e4 > U.recentlyCreatedOwnerStacks++;
247
- return s(
248
- t,
249
- f,
250
- h,
335
+ a
336
+ )(), re = F(s(a)), ne = {};
337
+ Y.Fragment = j, Y.jsx = function(r, p, w) {
338
+ var R = 1e4 > $.recentlyCreatedOwnerStacks++;
339
+ return i(
340
+ r,
341
+ p,
342
+ w,
251
343
  !1,
252
- E ? Error("react-stack-top-frame") : B,
253
- E ? W(o(t)) : H
344
+ R ? Error("react-stack-top-frame") : te,
345
+ R ? F(s(r)) : re
254
346
  );
255
- }, N.jsxs = function(t, f, h) {
256
- var E = 1e4 > U.recentlyCreatedOwnerStacks++;
257
- return s(
258
- t,
259
- f,
260
- h,
347
+ }, Y.jsxs = function(r, p, w) {
348
+ var R = 1e4 > $.recentlyCreatedOwnerStacks++;
349
+ return i(
350
+ r,
351
+ p,
352
+ w,
261
353
  !0,
262
- E ? Error("react-stack-top-frame") : B,
263
- E ? W(o(t)) : H
354
+ R ? Error("react-stack-top-frame") : te,
355
+ R ? F(s(r)) : re
264
356
  );
265
357
  };
266
- })()), N;
358
+ })()), Y;
267
359
  }
268
- var re;
269
- function he() {
270
- return re || (re = 1, process.env.NODE_ENV === "production" ? $.exports = me() : $.exports = ye()), $.exports;
360
+ var le;
361
+ function Re() {
362
+ return le || (le = 1, process.env.NODE_ENV === "production" ? Q.exports = ve() : Q.exports = we()), Q.exports;
271
363
  }
272
- var C = he();
273
- const Ye = ({ IMaskMixin: e, ...r }) => {
274
- const a = M(
364
+ var O = Re();
365
+ const Je = ({ IMaskMixin: e, ...t }) => {
366
+ const n = Z(
275
367
  // eslint-disable-next-line react/jsx-props-no-spreading
276
- () => e(({ TextField: o, ...n }) => /* @__PURE__ */ C.jsx(o, { ...n })),
368
+ () => e(({ TextField: s, ...o }) => /* @__PURE__ */ O.jsx(s, { ...o })),
277
369
  [e]
278
370
  );
279
- return /* @__PURE__ */ C.jsx(a, { ...r });
280
- }, S = pe({}), ze = ({ children: e, apiURL: r, libraries: a, localStorageKeys: o }) => {
281
- const n = M(
371
+ return /* @__PURE__ */ O.jsx(n, { ...t });
372
+ }, A = ge({}), Ge = ({ children: e, apiURL: t, libraries: n, localStorageKeys: s }) => {
373
+ const o = Z(
282
374
  () => ({
283
- apiURL: r,
284
- libraries: a,
285
- localStorageKeys: o
375
+ apiURL: t,
376
+ libraries: n,
377
+ localStorageKeys: s
286
378
  }),
287
- [r, a, o]
379
+ [t, n, s]
288
380
  );
289
- return /* @__PURE__ */ C.jsx(S.Provider, { value: n, children: e });
290
- }, Ue = ({ data: e, ...r }) => {
291
- const { libraries: a } = j(S), o = r?.reactRouter || a?.reactRouter, n = r?.gtm || a?.gtm;
292
- if (!o)
381
+ return /* @__PURE__ */ O.jsx(A.Provider, { value: o, children: e });
382
+ }, Ke = ({ data: e, ...t }) => {
383
+ const { libraries: n } = k(A), s = t?.reactRouter || n?.reactRouter, o = t?.gtm || n?.gtm;
384
+ if (!s)
293
385
  throw new Error(
294
386
  "React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView."
295
387
  );
296
- if (!n)
388
+ if (!o)
297
389
  throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
298
- const { useGoogleTagManager: i } = n, { useLocation: c, Outlet: l } = o, { pathname: u } = c(), { sendEvent: p } = i();
299
- return k(() => {
300
- p({
390
+ const { useGoogleTagManager: a } = o, { useLocation: c, Outlet: l } = s, { pathname: u } = c(), { sendEvent: f } = a();
391
+ return I(() => {
392
+ f({
301
393
  event: "pageView",
302
394
  pathname: u,
303
395
  ...e
304
396
  });
305
- }, [e, u, p]), /* @__PURE__ */ C.jsx(l, {});
306
- }, L = (() => {
397
+ }, [e, u, f]), /* @__PURE__ */ O.jsx(l, {});
398
+ }, U = (() => {
307
399
  try {
308
400
  return typeof global == "object" && global !== null && ("HermesInternal" in global || // Hermes JS engine
309
401
  "__fbBatchedBridge" in global || // RN Bridge
@@ -311,43 +403,43 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
311
403
  } catch {
312
404
  return !1;
313
405
  }
314
- })(), ve = "user", We = ({
406
+ })(), _e = "user", qe = ({
315
407
  tokenTypeKey: e = "tokenType",
316
- tokenKey: r = "accessToken",
317
- postContentType: a = "application/json",
318
- ...o
408
+ tokenKey: t = "accessToken",
409
+ postContentType: n = "application/json",
410
+ ...s
319
411
  }) => {
320
- const { apiURL: n = o.apiURL, libraries: i, localStorageKeys: c } = j(S), l = o?.userLocalStorageKey || c?.user || ve, u = o?.axios || i?.axios;
412
+ const { apiURL: o = s.apiURL, libraries: a, localStorageKeys: c } = k(A), l = s?.userLocalStorageKey || c?.user || _e, u = s?.axios || a?.axios;
321
413
  if (!u)
322
414
  throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
323
- if (!u?.defaults || L)
415
+ if (!u?.defaults || U)
324
416
  return null;
325
417
  if (typeof window < "u" && window.localStorage) {
326
- const p = localStorage.getItem(l), s = p ? JSON.parse(p) : null, m = s?.[e] ? s[e] : null, y = s?.[r] ? s[r] : null, v = p ? `${m} ${y}` : null;
418
+ const f = localStorage.getItem(l), i = f ? JSON.parse(f) : null, g = i?.[e] ? i[e] : null, h = i?.[t] ? i[t] : null, v = f ? `${g} ${h}` : null;
327
419
  v && (u.defaults.headers.common.Authorization = v);
328
420
  }
329
- return u.defaults.baseURL = n, u.defaults.headers.post["Content-Type"] = a, null;
330
- }, Qe = ({ language: e, ...r }) => {
331
- const { libraries: a } = j(S), o = r?.dayjs || a?.dayjs, n = r?.plugin || a?.dayjsPlugin;
332
- if (!o)
421
+ return u.defaults.baseURL = o, u.defaults.headers.post["Content-Type"] = n, null;
422
+ }, Be = ({ language: e, ...t }) => {
423
+ const { libraries: n } = k(A), s = t?.dayjs || n?.dayjs, o = t?.plugin || n?.dayjsPlugin;
424
+ if (!s)
333
425
  throw new Error(
334
426
  "Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig."
335
427
  );
336
- return k(() => {
428
+ return I(() => {
337
429
  (async () => {
338
430
  const c = e || navigator.language?.slice(0, 2) || "en";
339
- n && n.forEach((l) => {
340
- l && o.extend(l);
341
- }), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), o.locale(c);
431
+ o && o.forEach((l) => {
432
+ l && s.extend(l);
433
+ }), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), s.locale(c);
342
434
  })().then();
343
- }, [o, n, e]), null;
344
- }, Ve = ({ debug: e, resources: r, ...a }) => {
345
- const { libraries: o } = j(S), n = a?.i18 || o?.i18, { i18next: i, initReactI18next: c, languageDetector: l } = n || {};
346
- if (L)
435
+ }, [s, o, e]), null;
436
+ }, He = ({ debug: e, resources: t, ...n }) => {
437
+ const { libraries: s } = k(A), o = n?.i18 || s?.i18, { i18next: a, initReactI18next: c, languageDetector: l } = o || {};
438
+ if (U)
347
439
  return null;
348
- if (!n)
440
+ if (!o)
349
441
  throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
350
- return i?.isInitialized || (i.use(l).use(c).init({
442
+ return a?.isInitialized || (a.use(l).use(c).init({
351
443
  debug: e,
352
444
  fallbackLng: "en",
353
445
  interpolation: {
@@ -358,35 +450,35 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
358
450
  bindI18n: "languageChanged loaded",
359
451
  useSuspense: !0
360
452
  },
361
- resources: r,
453
+ resources: t,
362
454
  returnNull: !1
363
455
  }).then(() => {
364
- document.documentElement.lang !== i.resolvedLanguage && i.resolvedLanguage && document.documentElement.setAttribute("lang", i.resolvedLanguage);
365
- }), i.on("languageChanged", (u) => {
456
+ document.documentElement.lang !== a.resolvedLanguage && a.resolvedLanguage && document.documentElement.setAttribute("lang", a.resolvedLanguage);
457
+ }), a.on("languageChanged", (u) => {
366
458
  document.documentElement.setAttribute("lang", u);
367
459
  })), null;
368
- }, Me = ({
460
+ }, Xe = ({
369
461
  dsn: e,
370
- integrations: r,
371
- tracesSampleRate: a,
372
- replaysSessionSampleRate: o,
373
- replaysOnErrorSampleRate: n,
374
- tracePropagationTargets: i,
462
+ integrations: t,
463
+ tracesSampleRate: n,
464
+ replaysSessionSampleRate: s,
465
+ replaysOnErrorSampleRate: o,
466
+ tracePropagationTargets: a,
375
467
  ignoreErrors: c,
376
468
  debug: l,
377
469
  environment: u,
378
- release: p,
379
- ...s
470
+ release: f,
471
+ ...i
380
472
  }) => {
381
- const { libraries: m } = j(S), y = s?.sentry || m?.sentry, v = s?.reactRouter || m?.reactRouter;
382
- if (!y)
473
+ const { libraries: g } = k(A), h = i?.sentry || g?.sentry, v = i?.reactRouter || g?.reactRouter;
474
+ if (!h)
383
475
  throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
384
476
  if (!v)
385
477
  throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
386
- if (y.isInitialized())
478
+ if (h.isInitialized())
387
479
  return null;
388
- const { createRoutesFromChildren: T, matchRoutes: A, useLocation: P, useNavigationType: g } = v;
389
- return (l || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && y.init({
480
+ const { createRoutesFromChildren: P, matchRoutes: S, useLocation: j, useNavigationType: m } = v;
481
+ return (l || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && h.init({
390
482
  debug: l,
391
483
  dsn: e,
392
484
  environment: u || "production",
@@ -400,213 +492,305 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
400
492
  /vite:preloadError/
401
493
  ],
402
494
  integrations: [
403
- y.reactRouterV6BrowserTracingIntegration({
404
- createRoutesFromChildren: T,
405
- matchRoutes: A,
406
- useEffect: k,
407
- useLocation: P,
408
- useNavigationType: g
495
+ h.reactRouterV6BrowserTracingIntegration({
496
+ createRoutesFromChildren: P,
497
+ matchRoutes: S,
498
+ useEffect: I,
499
+ useLocation: j,
500
+ useNavigationType: m
409
501
  }),
410
- ...r || []
502
+ ...t || []
411
503
  ],
412
- release: p,
413
- replaysOnErrorSampleRate: n || 1,
414
- replaysSessionSampleRate: o || 0.1,
415
- tracePropagationTargets: i,
416
- tracesSampleRate: a || 1
504
+ release: f,
505
+ replaysOnErrorSampleRate: o || 1,
506
+ replaysSessionSampleRate: s || 0.1,
507
+ tracePropagationTargets: a,
508
+ tracesSampleRate: n || 1
417
509
  }), null;
418
- }, Je = () => (k(() => {
419
- if (L)
510
+ }, Ze = () => (I(() => {
511
+ if (U)
420
512
  return;
421
- const e = (r) => {
513
+ const e = (t) => {
422
514
  try {
423
- r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), window.location.reload();
515
+ t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation(), window.location.reload();
424
516
  } catch {
425
517
  }
426
518
  };
427
519
  return window.addEventListener("vite:preloadError", e), () => {
428
520
  window.removeEventListener("vite:preloadError", e);
429
521
  };
430
- }, []), null), ne = /* @__PURE__ */ new WeakMap(), Ee = "user", qe = ({ Fallback: e, isLogged: r, loginPath: a = "/login", redirect401Path: o = "/login", ...n }) => {
431
- const { libraries: i, localStorageKeys: c } = j(S), l = n?.reactRouter || i?.reactRouter, u = n?.axios || i?.axios, p = n?.localStorageKey || c?.user || Ee;
522
+ }, []), null), ue = /* @__PURE__ */ new WeakMap(), be = "user", et = ({ Fallback: e, isLogged: t, loginPath: n = "/login", redirect401Path: s = "/login", ...o }) => {
523
+ const { libraries: a, localStorageKeys: c } = k(A), l = o?.reactRouter || a?.reactRouter, u = o?.axios || a?.axios, f = o?.localStorageKey || c?.user || be;
432
524
  if (!l)
433
525
  throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
434
- const [s, m] = J(null), { useLocation: y, Navigate: v, Outlet: T } = l, A = y(), P = typeof r == "function" ? r() : !!r, g = typeof P == "boolean" ? P : P?.isLogged;
435
- return k(() => {
436
- ne.has(u) || (ne.set(u, !0), u.interceptors.response.use(
526
+ const [i, g] = M(null), { useLocation: h, Navigate: v, Outlet: P } = l, S = h(), j = typeof t == "function" ? t() : !!t, m = typeof j == "boolean" ? j : j?.isLogged;
527
+ return I(() => {
528
+ ue.has(u) || (ue.set(u, !0), u.interceptors.response.use(
437
529
  (d) => d,
438
- (d) => (typeof d == "object" && d && "response" in d && d.response && typeof d.response == "object" && "status" in d.response && d.response && typeof d.response == "object" && "status" in d.response && d?.response?.status === 401 && (typeof d == "object" && d && "config" in d && d.config && typeof d.config == "object" && "headers" in d.config && d.config.headers && typeof d.config.headers == "object" && "Authorization" in d.config.headers && d.config.headers.Authorization && (u.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(p)), m(o)), Promise.reject(d))
530
+ (d) => (typeof d == "object" && d && "response" in d && d.response && typeof d.response == "object" && "status" in d.response && d.response && typeof d.response == "object" && "status" in d.response && d?.response?.status === 401 && (typeof d == "object" && d && "config" in d && d.config && typeof d.config == "object" && "headers" in d.config && d.config.headers && typeof d.config.headers == "object" && "Authorization" in d.config.headers && d.config.headers.Authorization && (u.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(f)), g(s)), Promise.reject(d))
439
531
  ));
440
- }, [u, p, o]), g && !s ? /* @__PURE__ */ C.jsx(ge, { fallback: e, children: A.state?.from?.state && A.state?.from?.pathname === a ? /* @__PURE__ */ C.jsx(v, { to: A.state.from.state.from.pathname + A.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ C.jsx(T, {}) }) : /* @__PURE__ */ C.jsx(v, { to: a + A.search, state: { from: A }, replace: !0 });
441
- }, we = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), be = (e) => {
442
- const r = e.split(/[/\\]/).pop() || "";
443
- return r.substring(0, r.lastIndexOf("."));
444
- }, Re = (e) => {
445
- const o = e.split("/").filter((n) => n.length > 0).map((n) => n.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((u) => u.charAt(0).toUpperCase() + u.slice(1)).join("")).join("");
446
- return o.charAt(0).toLowerCase() + o.slice(1);
447
- }, _e = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), Se = (e, r, a, o) => {
448
- const n = Re(r), i = we(a), c = `${n}${i}`;
449
- return e && typeof e == "object" && "operationId" in e && o?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
450
- }, Ae = (e, r) => {
451
- const a = {};
452
- return e?.forEach((o) => {
453
- a[o] = {
532
+ }, [u, f, s]), m && !i ? /* @__PURE__ */ O.jsx(me, { fallback: e, children: S.state?.from?.state && S.state?.from?.pathname === n ? /* @__PURE__ */ O.jsx(v, { to: S.state.from.state.from.pathname + S.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ O.jsx(P, {}) }) : /* @__PURE__ */ O.jsx(v, { to: n + S.search, state: { from: S }, replace: !0 });
533
+ }, Te = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), Se = (e) => {
534
+ const t = e.split(/[/\\]/).pop() || "";
535
+ return t.substring(0, t.lastIndexOf("."));
536
+ }, Ae = (e) => {
537
+ const s = e.split("/").filter((o) => o.length > 0).map((o) => o.replace(/\${([^}]*)}/g, "$1").split(/[_-]/).map((u) => u.charAt(0).toUpperCase() + u.slice(1)).join("")).join("");
538
+ return s.charAt(0).toLowerCase() + s.slice(1);
539
+ }, je = (e) => (e.split("/").pop() || e).replace(/\.json$/, "").replace(/^openapi\./, ""), Ce = (e, t, n, s) => {
540
+ const o = Ae(t), a = Te(n), c = `${o}${a}`;
541
+ return e && typeof e == "object" && "operationId" in e && s?.includes(String(e.operationId)) ? `${c}AsQuery` : c;
542
+ }, ke = (e, t) => {
543
+ const n = {};
544
+ return e?.forEach((s) => {
545
+ n[s] = {
454
546
  query: {
455
547
  useInfinite: !0,
456
548
  useInfiniteQueryParam: "offset",
457
549
  useQuery: !0
458
550
  }
459
551
  };
460
- }), r?.filter((o) => !a[o]).forEach((o) => {
461
- a[o] = {
552
+ }), t?.filter((s) => !n[s]).forEach((s) => {
553
+ n[s] = {
462
554
  query: {
463
555
  useQuery: !0
464
556
  }
465
557
  };
466
- }), Object.keys(a).length ? a : void 0;
467
- }, Ge = (e) => (Array.isArray(e) ? e : [e]).reduce((a, o) => {
468
- const { output: n, useInfiniteIds: i, useQueryIds: c, input: l = "./openapi.json", customAxiosInstancePath: u, overrideApiName: p } = o || {}, s = p || _e(l), m = u || "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";
558
+ }), Object.keys(n).length ? n : void 0;
559
+ }, tt = (e) => (Array.isArray(e) ? e : [e]).reduce((n, s) => {
560
+ const { output: o, useInfiniteIds: a, useQueryIds: c, input: l = "./openapi.json", customAxiosInstancePath: u, overrideApiName: f } = s || {}, i = f || je(l), g = u || "./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";
469
561
  return {
470
- ...a,
471
- [s]: {
562
+ ...n,
563
+ [i]: {
472
564
  input: l,
473
565
  output: {
474
- baseUrl: n?.baseUrl,
566
+ baseUrl: o?.baseUrl,
475
567
  client: "react-query",
476
568
  mode: "tags-split",
477
569
  override: {
478
- ...(i?.length || c?.length) && {
479
- operations: Ae(i, c)
570
+ ...(a?.length || c?.length) && {
571
+ operations: ke(a, c)
480
572
  },
481
- header: (y) => [
573
+ header: (h) => [
482
574
  "Generated by orval 🍺",
483
- ...y.title ? [y.title] : [],
484
- ...y.description ? [y.description] : []
575
+ ...h.title ? [h.title] : [],
576
+ ...h.description ? [h.description] : []
485
577
  ],
486
578
  mutator: {
487
- name: be(m),
488
- path: m
579
+ name: Se(g),
580
+ path: g
489
581
  },
490
- operationName: (y, v, T) => Se(y, v, T, c),
582
+ operationName: (h, v, P) => Ce(h, v, P, c),
491
583
  query: {
492
584
  useQuery: !0
493
585
  }
494
586
  },
495
- schemas: n?.schemas || `src/api/${s}/model`,
496
- target: n?.target || `src/api/${s}/services/api.ts`,
497
- ...n
587
+ schemas: o?.schemas || `src/api/${i}/model`,
588
+ target: o?.target || `src/api/${i}/services/api.ts`,
589
+ ...o
498
590
  }
499
591
  }
500
592
  };
501
- }, {}), je = (e) => e && typeof e == "function", Pe = (e) => e && typeof e == "function", Ke = ({
593
+ }, {}), Pe = (e) => e && typeof e == "function", xe = (e) => e && typeof e == "function", rt = ({
502
594
  children: e,
503
- defaultQueriesOptions: r,
504
- defaultMutationsOptions: a,
505
- ...o
595
+ defaultQueriesOptions: t,
596
+ defaultMutationsOptions: n,
597
+ ...s
506
598
  }) => {
507
- const { libraries: n } = j(S), i = o?.QueryClient || n?.reactQuery?.QueryClient, c = o?.QueryClientProvider || n?.reactQuery?.QueryClientProvider;
508
- if (!i)
599
+ const { libraries: o } = k(A), a = s?.QueryClient || o?.reactQuery?.QueryClient, c = s?.QueryClientProvider || o?.reactQuery?.QueryClientProvider;
600
+ if (!a)
509
601
  throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
510
602
  if (!c)
511
603
  throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
512
- if (!je(c))
604
+ if (!Pe(c))
513
605
  throw new Error("Provided QueryClientProvider dependencies are not valid.");
514
- if (!Pe(i))
606
+ if (!xe(a))
515
607
  throw new Error("Provided QueryClient dependencies are not valid.");
516
- const l = new i({
608
+ const l = new a({
517
609
  defaultOptions: {
518
610
  mutations: {
519
- ...a
611
+ ...n
520
612
  },
521
613
  queries: {
522
- getNextPageParam: (u, p, s) => u.length + (s || 0),
614
+ getNextPageParam: (u, f, i) => u.length + (i || 0),
523
615
  refetchOnWindowFocus: !1,
524
616
  retry: 3,
525
- ...r
617
+ ...t
526
618
  }
527
619
  }
528
620
  });
529
- return /* @__PURE__ */ C.jsx(c, { client: l, children: e });
530
- }, Te = ({ library: e, date: r, format: a = "ll" }) => e(r).format(a), Ce = (e, r) => {
531
- const { fractionDigits: a = 0, metric: o = "km", spacingBetween: n = !0 } = r || {}, i = Number(e), c = n ? " " : "";
532
- return Number.isNaN(i) ? `0${c}${o}` : `${i.toFixed(a)}${c}${o}`;
533
- }, xe = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((a) => a.length > 0 ? a.charAt(0).toUpperCase() + a.slice(1) : a).join(" "), ke = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Oe = ({ path: e, size: r, apiURL: a }) => {
621
+ return /* @__PURE__ */ O.jsx(c, { client: l, children: e });
622
+ }, Oe = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), Ie = (e, t) => {
623
+ const { fractionDigits: n = 0, metric: s = "km", spacingBetween: o = !0 } = t || {}, a = Number(e), c = o ? " " : "";
624
+ return Number.isNaN(a) ? `0${c}${s}` : `${a.toFixed(n)}${c}${s}`;
625
+ }, Ne = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((n) => n.length > 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n).join(" "), Le = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, $e = ({ path: e, size: t, apiURL: n }) => {
534
626
  if (!e)
535
627
  return "";
536
- const o = ke(e), n = `${a}${o}`, i = n.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
537
- return typeof r == "number" && i ? `${n.replace("/files", `/thumbs/${r}`)}` : n;
538
- }, Be = (e) => {
539
- const { apiURL: r, libraries: a } = j(S), o = e?.dayjs || a?.dayjs;
628
+ const s = Le(e), o = `${n}${s}`, a = o.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
629
+ return typeof t == "number" && a ? `${o.replace("/files", `/thumbs/${t}`)}` : o;
630
+ }, nt = (e) => {
631
+ const { apiURL: t, libraries: n } = k(A), s = e?.dayjs || n?.dayjs;
540
632
  return {
541
633
  dateAdapter: (c, l) => {
542
- if (!o)
634
+ if (!s)
543
635
  throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
544
- return Te({
636
+ return Oe({
545
637
  date: c,
546
638
  format: l,
547
- library: o
639
+ library: s
548
640
  });
549
641
  },
550
- distanceAdapter: Ce,
642
+ distanceAdapter: Ie,
551
643
  filePathAdapter: (c, l) => {
552
- if (!r)
644
+ if (!t)
553
645
  throw new Error(
554
646
  "API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter."
555
647
  );
556
- return typeof c == "string" && /^https?:\/\//.test(c) ? c : Oe({
557
- apiURL: r,
648
+ return typeof c == "string" && /^https?:\/\//.test(c) ? c : $e({
649
+ apiURL: t,
558
650
  path: c,
559
651
  size: l
560
652
  });
561
653
  },
562
- worksiteNameAdapter: xe
654
+ worksiteNameAdapter: Ne
563
655
  };
564
- }, He = (e) => {
565
- const { libraries: r, localStorageKeys: a } = j(S), o = e?.axios || r?.axios, n = e?.localStorageKey || a?.user || "user";
566
- if (!o)
656
+ }, ot = (e) => {
657
+ const { libraries: t, localStorageKeys: n } = k(A), s = e?.axios || t?.axios, o = e?.localStorageKey || n?.user || "user";
658
+ if (!s)
567
659
  throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
568
- const i = Y(
660
+ const a = x(
569
661
  ({ tokenType: l, accessToken: u }) => {
570
- o.defaults.headers.common.Authorization = `${l} ${u}`;
662
+ s.defaults.headers.common.Authorization = `${l} ${u}`;
571
663
  },
572
- [o.defaults.headers.common]
664
+ [s.defaults.headers.common]
573
665
  ), c = () => {
574
- o.defaults.headers.common.Authorization = null;
666
+ s.defaults.headers.common.Authorization = null;
575
667
  };
576
- return k(() => {
577
- if (L)
668
+ return I(() => {
669
+ if (U)
578
670
  return;
579
- const l = ({ newValue: u, key: p }) => {
580
- if (p === n && u)
671
+ const l = ({ newValue: u, key: f }) => {
672
+ if (f === o && u)
581
673
  try {
582
- const { accessToken: s, tokenType: m } = JSON.parse(u);
583
- i({ accessToken: s, tokenType: m });
584
- } catch (s) {
585
- console.error("Failed to parse newValue from localStorage:", s);
674
+ const { accessToken: i, tokenType: g } = JSON.parse(u);
675
+ a({ accessToken: i, tokenType: g });
676
+ } catch (i) {
677
+ console.error("Failed to parse newValue from localStorage:", i);
586
678
  }
587
679
  };
588
680
  return window.addEventListener("storage", l), () => {
589
681
  window.removeEventListener("storage", l);
590
682
  };
591
- }, [n, i]), {
683
+ }, [o, a]), {
592
684
  clearAuthenticationToken: c,
593
- setAuthenticationToken: i
685
+ setAuthenticationToken: a
594
686
  };
595
- }, D = (e, r) => r === "short" ? e.split("-")[0] : e, Xe = (e, r = "full") => {
596
- const [a, o] = J(() => {
597
- const n = e?.language || navigator.language;
598
- return e && "isInitialized" in e && e.isInitialized, D(n, r);
687
+ }, Fe = "user", De = (e) => {
688
+ const t = e.startsWith("https") ? "wss" : "ws", n = e.replace(/^https?:\/\//, "");
689
+ return `${t}://${n}/v2/threads/ws`;
690
+ }, Ye = (e) => {
691
+ try {
692
+ const t = localStorage.getItem(e);
693
+ return t ? JSON.parse(t)?.accessToken ?? null : null;
694
+ } catch {
695
+ return null;
696
+ }
697
+ }, st = (e) => {
698
+ const [t, n] = M(!1), [s, o] = M(!1), { apiURL: a, localStorageKeys: c } = k(A), { reconnect: l = !0, enabled: u = !0, url: f, token: i } = e || {}, g = c?.user || Fe, h = se(null), v = se(e);
699
+ v.current = e, I(() => {
700
+ if (!u)
701
+ return;
702
+ const y = f || (a ? De(a) : null);
703
+ if (!y)
704
+ return;
705
+ const E = () => i ?? Ye(g), b = (T) => {
706
+ const {
707
+ onError: G,
708
+ onReady: L,
709
+ onNewMessage: K,
710
+ onNewMessageNotification: q,
711
+ onPresence: $,
712
+ onJoinedThread: z,
713
+ onLeftThread: B,
714
+ onMarkedRead: F,
715
+ onThreadsList: W
716
+ } = v.current || {};
717
+ switch (T.type) {
718
+ case "ready":
719
+ o(!0), L?.(T);
720
+ break;
721
+ case "new_message":
722
+ K?.(T);
723
+ break;
724
+ case "new_message_notification":
725
+ q?.(T);
726
+ break;
727
+ case "presence":
728
+ $?.(T);
729
+ break;
730
+ case "error":
731
+ G?.(T);
732
+ break;
733
+ case "joined_thread":
734
+ z?.(T);
735
+ break;
736
+ case "left_thread":
737
+ B?.(T);
738
+ break;
739
+ case "marked_read":
740
+ F?.(T);
741
+ break;
742
+ case "threads_list":
743
+ W?.(T);
744
+ break;
745
+ }
746
+ }, C = new Ee({
747
+ getToken: E,
748
+ onConnectionChange: (T) => {
749
+ n(T), T || o(!1);
750
+ },
751
+ onEvent: b,
752
+ reconnect: l,
753
+ url: y
754
+ });
755
+ return h.current = C, C.connect(), () => {
756
+ C.disconnect(), h.current = null;
757
+ };
758
+ }, [u, f, i, a, l, g]);
759
+ const P = x((y) => {
760
+ h.current?.joinThread(y);
761
+ }, []), S = x((y) => {
762
+ h.current?.leaveThread(y);
763
+ }, []), j = x((y, E) => {
764
+ h.current?.sendMessage(y, E);
765
+ }, []), m = x((y) => {
766
+ h.current?.markRead(y);
767
+ }, []), d = x((y, E) => {
768
+ h.current?.listThreads(y, E);
769
+ }, []);
770
+ return {
771
+ isConnected: t,
772
+ isReady: s,
773
+ joinThread: P,
774
+ leaveThread: S,
775
+ listThreads: d,
776
+ markRead: m,
777
+ sendMessage: j
778
+ };
779
+ }, J = (e, t) => t === "short" ? e.split("-")[0] : e, at = (e, t = "full") => {
780
+ const [n, s] = M(() => {
781
+ const o = e?.language || navigator.language;
782
+ return e && "isInitialized" in e && e.isInitialized, J(o, t);
599
783
  });
600
- return k(() => {
601
- e && "isInitialized" in e && e.isInitialized && e.language && o(D(e.language, r));
602
- const n = (i) => {
603
- o(D(i, r));
784
+ return I(() => {
785
+ e && "isInitialized" in e && e.isInitialized && e.language && s(J(e.language, t));
786
+ const o = (a) => {
787
+ s(J(a, t));
604
788
  };
605
- return e?.on?.("languageChanged", n), () => {
606
- e?.off?.("languageChanged", n);
789
+ return e?.on?.("languageChanged", o), () => {
790
+ e?.off?.("languageChanged", o);
607
791
  };
608
- }, [e, r]), a;
609
- }, Ie = "tracktor.filter", Ne = {
792
+ }, [e, t]), n;
793
+ }, Me = "tracktor.filter", Ue = {
610
794
  getFilter: () => {
611
795
  },
612
796
  getFilters: () => ({}),
@@ -614,162 +798,164 @@ const Ye = ({ IMaskMixin: e, ...r }) => {
614
798
  },
615
799
  setFilter: () => {
616
800
  }
617
- }, oe = (e) => {
801
+ }, de = (e) => {
618
802
  try {
619
803
  return JSON.parse(e);
620
804
  } catch {
621
805
  return e;
622
806
  }
623
- }, ae = (e, r, a) => `${a}_${e}=>${r}`, Le = (e) => e.reduce((r, a) => {
624
- const o = localStorage.getItem(a);
625
- if (o)
807
+ }, fe = (e, t, n) => `${n}_${e}=>${t}`, ze = (e) => e.reduce((t, n) => {
808
+ const s = localStorage.getItem(n);
809
+ if (s)
626
810
  try {
627
- const n = JSON.parse(o), i = Object.keys(n)?.[0];
628
- i && (r[i] = Object.values(n)?.[0]);
811
+ const o = JSON.parse(s), a = Object.keys(o)?.[0];
812
+ a && (t[a] = Object.values(o)?.[0]);
629
813
  } catch {
630
814
  }
631
- return r;
632
- }, {}), Ze = (e) => {
633
- const { libraries: r, localStorageKeys: a } = j(S), o = e?.reactRouter || r?.reactRouter, { pathname: n } = o?.useLocation?.() ?? { pathname: "/" }, [i, c] = o?.useSearchParams?.() ?? [new URLSearchParams(), () => {
634
- }], [l, u] = J({}), p = a?.filter || Ie, s = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, m = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
635
- if (L)
636
- return Ne;
637
- if (!o)
815
+ return t;
816
+ }, {}), it = (e) => {
817
+ const { libraries: t, localStorageKeys: n } = k(A), s = e?.reactRouter || t?.reactRouter, { pathname: o } = s?.useLocation?.() ?? { pathname: "/" }, [a, c] = s?.useSearchParams?.() ?? [new URLSearchParams(), () => {
818
+ }], [l, u] = M({}), f = n?.filter || Me, i = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, g = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
819
+ if (U)
820
+ return Ue;
821
+ if (!s)
638
822
  throw new Error(
639
823
  "React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter."
640
824
  );
641
- const y = () => Object.keys(localStorage).filter(
642
- (g) => g.startsWith(p) && g.endsWith(e?.pathname || n)
643
- ), v = (g, d, R = !0) => {
644
- const b = ae(g, e?.pathname || n, p);
825
+ const h = () => Object.keys(localStorage).filter(
826
+ (m) => m.startsWith(f) && m.endsWith(e?.pathname || o)
827
+ ), v = (m, d, y = !0) => {
828
+ const E = fe(m, e?.pathname || o, f);
645
829
  if (!d || Array.isArray(d) && !d.length) {
646
- s ? (i.delete(g), c(i)) : u((_) => {
647
- const x = { ..._ };
648
- return delete x[g], x;
649
- }), m && localStorage.removeItem(b);
830
+ i ? (a.delete(m), c(a)) : u((b) => {
831
+ const C = { ...b };
832
+ return delete C[m], C;
833
+ }), g && localStorage.removeItem(E);
650
834
  return;
651
835
  }
652
- m && R && d && localStorage.setItem(b, JSON.stringify({ ...i, [g]: d })), s && d ? (i.set(g, JSON.stringify(d)), c(i)) : !s && d && u((_) => ({ ..._, [g]: d }));
836
+ g && y && d && localStorage.setItem(E, JSON.stringify({ ...a, [m]: d })), i && d ? (a.set(m, JSON.stringify(d)), c(a)) : !i && d && u((b) => ({ ...b, [m]: d }));
653
837
  };
654
838
  return {
655
- getFilter: (g, d) => {
656
- if (s) {
657
- const R = i.get(g);
658
- if (R)
659
- return oe(R);
839
+ getFilter: (m, d) => {
840
+ if (i) {
841
+ const y = a.get(m);
842
+ if (y)
843
+ return de(y);
660
844
  } else {
661
- const R = l[g];
662
- if (R !== void 0)
663
- return R;
845
+ const y = l[m];
846
+ if (y !== void 0)
847
+ return y;
664
848
  }
665
- if (m) {
666
- const R = ae(g, e?.pathname || n, p), b = localStorage.getItem(R);
667
- if (b)
849
+ if (g) {
850
+ const y = fe(m, e?.pathname || o, f), E = localStorage.getItem(y);
851
+ if (E)
668
852
  try {
669
- const _ = JSON.parse(b)[g];
670
- return !s && _ !== void 0 && u((x) => ({ ...x, [g]: _ })), _;
853
+ const b = JSON.parse(E)[m];
854
+ return !i && b !== void 0 && u((C) => ({ ...C, [m]: b })), b;
671
855
  } catch {
672
856
  }
673
857
  }
674
858
  return d;
675
859
  },
676
860
  getFilters: () => {
677
- const g = m ? Le(y()) : {};
678
- if (s) {
679
- const d = Array.from(i.entries()).reduce((R, [b, _]) => (R[b] = oe(_), R), {});
861
+ const m = g ? ze(h()) : {};
862
+ if (i) {
863
+ const d = Array.from(a.entries()).reduce((y, [E, b]) => (y[E] = de(b), y), {});
680
864
  return {
681
- ...g,
865
+ ...m,
682
866
  ...d
683
867
  };
684
868
  }
685
869
  return {
686
- ...g,
870
+ ...m,
687
871
  ...l
688
872
  };
689
873
  },
690
- handleFilter: (g, d) => (R, b) => {
691
- if (b || Array.isArray(b) && b.length === 0) {
692
- const _ = d || "value", x = typeof b == "object" && _ in b ? b[_] : b;
693
- v(g, x);
874
+ handleFilter: (m, d) => (y, E) => {
875
+ if (E || Array.isArray(E) && E.length === 0) {
876
+ const b = d || "value", C = typeof E == "object" && b in E ? E[b] : E;
877
+ v(m, C);
694
878
  return;
695
879
  }
696
- v(g, void 0);
880
+ v(m, void 0);
697
881
  },
698
882
  setFilter: v
699
883
  };
700
- }, et = ({
884
+ }, ct = ({
701
885
  data: e,
702
- fetchNextPage: r,
703
- isFetchingNextPage: a,
704
- isInitialLoading: o,
705
- isLoading: n,
706
- enabled: i = !0
886
+ fetchNextPage: t,
887
+ isFetchingNextPage: n,
888
+ isInitialLoading: s,
889
+ isLoading: o,
890
+ enabled: a = !0
707
891
  }) => {
708
- const c = Y(
892
+ const c = x(
709
893
  async (u) => {
710
- a || !i || await r({ pageParam: u?.pageParam || u.visibleRowsCount });
894
+ n || !a || await t({ pageParam: u?.pageParam || u.visibleRowsCount });
711
895
  },
712
- [i, r, a]
713
- ), l = M(() => {
896
+ [a, t, n]
897
+ ), l = Z(() => {
714
898
  if (e)
715
- return e.pages.reduce((u, p) => [...u, ...p], []);
899
+ return e.pages.reduce((u, f) => [...u, ...f], []);
716
900
  }, [e]);
717
901
  return {
718
902
  fetchNextPageOnRowsScrollEnd: c,
719
- isLoading: a || n,
720
- loadingVariant: o ? "skeleton" : "linear-progress",
903
+ isLoading: n || o,
904
+ loadingVariant: s ? "skeleton" : "linear-progress",
721
905
  rows: l
722
906
  };
723
- }, tt = (e) => {
724
- const { libraries: r } = j(S), a = e?.i18 || r?.i18, o = e?.i18?.translateFunction || r?.i18?.translateFunction, n = a?.i18next?.t || o || ((p) => p), { unknownErrorTranslationKey: i = "error.unknownError" } = e || {}, c = n(i), l = Y(
725
- (p) => {
726
- if (p && typeof p == "object" && "response" in p) {
727
- const { response: s } = p || {};
728
- if (s && typeof s == "object" && "reason" in s && s.reason)
729
- return String(s.reason);
730
- if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "reason" in s.data && s.data.reason)
731
- return String(s.data.reason);
732
- if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "message" in s.data && s.data.message)
733
- return String(s.data.message);
734
- if (s && typeof s == "object" && "data" in s && s.data && typeof s.data == "object" && "detail" in s.data) {
735
- const { detail: m } = s.data;
736
- if (Array.isArray(m) && m.length > 0 && typeof m[0] == "object" && m[0] !== null && "msg" in m[0]) {
737
- const { msg: y } = m[0];
738
- if (typeof y == "string")
739
- return String(y);
907
+ }, lt = (e) => {
908
+ const { libraries: t } = k(A), n = e?.i18 || t?.i18, s = e?.i18?.translateFunction || t?.i18?.translateFunction, o = n?.i18next?.t || s || ((f) => f), { unknownErrorTranslationKey: a = "error.unknownError" } = e || {}, c = o(a), l = x(
909
+ (f) => {
910
+ if (f && typeof f == "object" && "response" in f) {
911
+ const { response: i } = f || {};
912
+ if (i && typeof i == "object" && "reason" in i && i.reason)
913
+ return String(i.reason);
914
+ if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "reason" in i.data && i.data.reason)
915
+ return String(i.data.reason);
916
+ if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "message" in i.data && i.data.message)
917
+ return String(i.data.message);
918
+ if (i && typeof i == "object" && "data" in i && i.data && typeof i.data == "object" && "detail" in i.data) {
919
+ const { detail: g } = i.data;
920
+ if (Array.isArray(g) && g.length > 0 && typeof g[0] == "object" && g[0] !== null && "msg" in g[0]) {
921
+ const { msg: h } = g[0];
922
+ if (typeof h == "string")
923
+ return String(h);
740
924
  }
741
925
  }
742
926
  }
743
- return p instanceof Error ? p.message : c;
927
+ return f instanceof Error ? f.message : c;
744
928
  },
745
929
  [c]
746
930
  );
747
- return { getErrorCode: Y((p) => {
748
- const { response: s } = p || {};
749
- 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";
931
+ return { getErrorCode: x((f) => {
932
+ const { response: i } = f || {};
933
+ 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";
750
934
  }, []), printError: l };
751
935
  };
752
936
  export {
753
- Ue as GTMSendPageView,
754
- We as InitializeAxiosConfig,
755
- Qe as InitializeDaysJSConfig,
756
- Ve as InitializeI18nConfig,
757
- Me as InitializeSentryConfig,
758
- S as InjectDependenciesContext,
759
- ze as InjectDependenciesProvider,
760
- Ye as MaskTextField,
761
- Je as PreloadErrorHandler,
762
- Ke as QueryClientProviderWithConfig,
763
- qe as RequireAuth,
764
- De as axiosCustomInstance,
765
- Te as dateAdapter,
766
- Ce as distanceAdapter,
767
- Ge as getOrvalConfig,
768
- Be as useAdapter,
769
- He as useAuth,
770
- Xe as useCurrentLanguage,
771
- Ze as useFilters,
772
- et as useInfiniteDataGrid,
773
- tt as useResponseError,
774
- xe as worksiteNameAdapter
937
+ Ee as ChatClient,
938
+ Ke as GTMSendPageView,
939
+ qe as InitializeAxiosConfig,
940
+ Be as InitializeDaysJSConfig,
941
+ He as InitializeI18nConfig,
942
+ Xe as InitializeSentryConfig,
943
+ A as InjectDependenciesContext,
944
+ Ge as InjectDependenciesProvider,
945
+ Je as MaskTextField,
946
+ Ze as PreloadErrorHandler,
947
+ rt as QueryClientProviderWithConfig,
948
+ et as RequireAuth,
949
+ Qe as axiosCustomInstance,
950
+ Oe as dateAdapter,
951
+ Ie as distanceAdapter,
952
+ tt as getOrvalConfig,
953
+ nt as useAdapter,
954
+ ot as useAuth,
955
+ st as useChat,
956
+ at as useCurrentLanguage,
957
+ it as useFilters,
958
+ ct as useInfiniteDataGrid,
959
+ lt as useResponseError,
960
+ Ne as worksiteNameAdapter
775
961
  };