@tracktor/shared-module 2.26.0 → 2.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/context/ChatProvider.d.ts +1 -1
- package/dist/hooks/useChat.d.ts +1 -1
- package/dist/main.js +130 -130
- package/dist/main.umd.cjs +2 -2
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ export interface ChatContextValue {
|
|
|
11
11
|
isConnected: boolean;
|
|
12
12
|
isReady: boolean;
|
|
13
13
|
unreadCount: number;
|
|
14
|
-
|
|
14
|
+
subscribe: (callback: EventListener) => () => void;
|
|
15
15
|
joinThread: (threadId: string) => void;
|
|
16
16
|
leaveThread: (threadId: string) => void;
|
|
17
17
|
listThreads: (limit?: number, offset?: number) => void;
|
package/dist/hooks/useChat.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UseChatParams } from '../chat/types';
|
|
2
2
|
import { ChatContextValue } from '../context/ChatProvider';
|
|
3
|
-
type UseChatReturn = Omit<ChatContextValue, "
|
|
3
|
+
type UseChatReturn = Omit<ChatContextValue, "subscribe">;
|
|
4
4
|
/**
|
|
5
5
|
* Hook to access the shared WebSocket chat connection.
|
|
6
6
|
* Provides methods to join/leave threads, send messages, mark as read, and list threads.
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import oe from "axios";
|
|
2
|
-
import me, { useMemo as H, createContext as fe, useContext as j, useEffect as N, useState as D, Suspense as ye, useRef as B, useCallback as
|
|
2
|
+
import me, { useMemo as H, createContext as fe, useContext as j, useEffect as N, useState as D, Suspense as ye, useRef as B, useCallback as O } from "react";
|
|
3
3
|
const Je = (e, t) => {
|
|
4
4
|
const n = oe.CancelToken.source(), s = oe({
|
|
5
5
|
...e,
|
|
@@ -102,10 +102,10 @@ class ve {
|
|
|
102
102
|
this.reconnectTimer !== null && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
var
|
|
105
|
+
var V = { exports: {} }, M = {};
|
|
106
106
|
var ae;
|
|
107
107
|
function Ee() {
|
|
108
|
-
if (ae) return
|
|
108
|
+
if (ae) return M;
|
|
109
109
|
ae = 1;
|
|
110
110
|
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
111
111
|
function n(s, o, a) {
|
|
@@ -123,9 +123,9 @@ function Ee() {
|
|
|
123
123
|
props: a
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
return
|
|
126
|
+
return M.Fragment = t, M.jsx = n, M.jsxs = n, M;
|
|
127
127
|
}
|
|
128
|
-
var
|
|
128
|
+
var U = {};
|
|
129
129
|
var ie;
|
|
130
130
|
function Re() {
|
|
131
131
|
return ie || (ie = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
@@ -141,11 +141,11 @@ function Re() {
|
|
|
141
141
|
return "Profiler";
|
|
142
142
|
case g:
|
|
143
143
|
return "StrictMode";
|
|
144
|
-
case
|
|
144
|
+
case x:
|
|
145
145
|
return "Suspense";
|
|
146
|
-
case
|
|
146
|
+
case S:
|
|
147
147
|
return "SuspenseList";
|
|
148
|
-
case
|
|
148
|
+
case J:
|
|
149
149
|
return "Activity";
|
|
150
150
|
}
|
|
151
151
|
if (typeof r == "object")
|
|
@@ -158,7 +158,7 @@ function Re() {
|
|
|
158
158
|
return r.displayName || "Context";
|
|
159
159
|
case b:
|
|
160
160
|
return (r._context.displayName || "Context") + ".Consumer";
|
|
161
|
-
case
|
|
161
|
+
case T:
|
|
162
162
|
var p = r.render;
|
|
163
163
|
return r = r.displayName, r || (r = p.displayName || p.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
164
164
|
case $:
|
|
@@ -204,7 +204,7 @@ function Re() {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
function o() {
|
|
207
|
-
var r =
|
|
207
|
+
var r = P.A;
|
|
208
208
|
return r === null ? null : r.getOwner();
|
|
209
209
|
}
|
|
210
210
|
function a() {
|
|
@@ -235,7 +235,7 @@ function Re() {
|
|
|
235
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."
|
|
236
236
|
)), r = this.props.ref, r !== void 0 ? r : null;
|
|
237
237
|
}
|
|
238
|
-
function f(r, p, w, R,
|
|
238
|
+
function f(r, p, w, R, W, K) {
|
|
239
239
|
var _ = w.ref;
|
|
240
240
|
return r = {
|
|
241
241
|
$$typeof: v,
|
|
@@ -260,7 +260,7 @@ function Re() {
|
|
|
260
260
|
configurable: !1,
|
|
261
261
|
enumerable: !1,
|
|
262
262
|
writable: !0,
|
|
263
|
-
value:
|
|
263
|
+
value: W
|
|
264
264
|
}), Object.defineProperty(r, "_debugTask", {
|
|
265
265
|
configurable: !1,
|
|
266
266
|
enumerable: !1,
|
|
@@ -268,7 +268,7 @@ function Re() {
|
|
|
268
268
|
value: K
|
|
269
269
|
}), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
|
|
270
270
|
}
|
|
271
|
-
function i(r, p, w, R,
|
|
271
|
+
function i(r, p, w, R, W, K) {
|
|
272
272
|
var _ = p.children;
|
|
273
273
|
if (_ !== void 0)
|
|
274
274
|
if (R)
|
|
@@ -312,7 +312,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
312
312
|
_,
|
|
313
313
|
w,
|
|
314
314
|
o(),
|
|
315
|
-
|
|
315
|
+
W,
|
|
316
316
|
K
|
|
317
317
|
);
|
|
318
318
|
}
|
|
@@ -322,7 +322,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
322
322
|
function m(r) {
|
|
323
323
|
return typeof r == "object" && r !== null && r.$$typeof === v;
|
|
324
324
|
}
|
|
325
|
-
var y = me, v = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), k = /* @__PURE__ */ Symbol.for("react.fragment"), g = /* @__PURE__ */ Symbol.for("react.strict_mode"), d = /* @__PURE__ */ Symbol.for("react.profiler"), b = /* @__PURE__ */ Symbol.for("react.consumer"), E = /* @__PURE__ */ Symbol.for("react.context"),
|
|
325
|
+
var y = me, v = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), k = /* @__PURE__ */ Symbol.for("react.fragment"), g = /* @__PURE__ */ Symbol.for("react.strict_mode"), d = /* @__PURE__ */ Symbol.for("react.profiler"), b = /* @__PURE__ */ Symbol.for("react.consumer"), E = /* @__PURE__ */ Symbol.for("react.context"), T = /* @__PURE__ */ Symbol.for("react.forward_ref"), x = /* @__PURE__ */ Symbol.for("react.suspense"), S = /* @__PURE__ */ Symbol.for("react.suspense_list"), $ = /* @__PURE__ */ Symbol.for("react.memo"), Y = /* @__PURE__ */ Symbol.for("react.lazy"), J = /* @__PURE__ */ Symbol.for("react.activity"), L = /* @__PURE__ */ Symbol.for("react.client.reference"), P = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, X = Object.prototype.hasOwnProperty, he = Array.isArray, G = console.createTask ? console.createTask : function() {
|
|
326
326
|
return null;
|
|
327
327
|
};
|
|
328
328
|
y = {
|
|
@@ -334,8 +334,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
334
334
|
y,
|
|
335
335
|
a
|
|
336
336
|
)(), re = G(s(a)), ne = {};
|
|
337
|
-
|
|
338
|
-
var R = 1e4 >
|
|
337
|
+
U.Fragment = k, U.jsx = function(r, p, w) {
|
|
338
|
+
var R = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
339
339
|
return i(
|
|
340
340
|
r,
|
|
341
341
|
p,
|
|
@@ -344,8 +344,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
344
344
|
R ? Error("react-stack-top-frame") : te,
|
|
345
345
|
R ? G(s(r)) : re
|
|
346
346
|
);
|
|
347
|
-
},
|
|
348
|
-
var R = 1e4 >
|
|
347
|
+
}, U.jsxs = function(r, p, w) {
|
|
348
|
+
var R = 1e4 > P.recentlyCreatedOwnerStacks++;
|
|
349
349
|
return i(
|
|
350
350
|
r,
|
|
351
351
|
p,
|
|
@@ -355,20 +355,20 @@ React keys must be passed directly to JSX without using spread:
|
|
|
355
355
|
R ? G(s(r)) : re
|
|
356
356
|
);
|
|
357
357
|
};
|
|
358
|
-
})()),
|
|
358
|
+
})()), U;
|
|
359
359
|
}
|
|
360
360
|
var ce;
|
|
361
361
|
function _e() {
|
|
362
|
-
return ce || (ce = 1, process.env.NODE_ENV === "production" ?
|
|
362
|
+
return ce || (ce = 1, process.env.NODE_ENV === "production" ? V.exports = Ee() : V.exports = Re()), V.exports;
|
|
363
363
|
}
|
|
364
|
-
var
|
|
364
|
+
var I = _e();
|
|
365
365
|
const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
366
366
|
const n = H(
|
|
367
367
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
368
|
-
() => e(({ TextField: s, ...o }) => /* @__PURE__ */
|
|
368
|
+
() => e(({ TextField: s, ...o }) => /* @__PURE__ */ I.jsx(s, { ...o })),
|
|
369
369
|
[e]
|
|
370
370
|
);
|
|
371
|
-
return /* @__PURE__ */
|
|
371
|
+
return /* @__PURE__ */ I.jsx(n, { ...t });
|
|
372
372
|
}, C = fe({}), Ke = ({ children: e, apiURL: t, libraries: n, localStorageKeys: s }) => {
|
|
373
373
|
const o = H(
|
|
374
374
|
() => ({
|
|
@@ -378,7 +378,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
378
378
|
}),
|
|
379
379
|
[t, n, s]
|
|
380
380
|
);
|
|
381
|
-
return /* @__PURE__ */
|
|
381
|
+
return /* @__PURE__ */ I.jsx(C.Provider, { value: o, children: e });
|
|
382
382
|
}, qe = ({ data: e, ...t }) => {
|
|
383
383
|
const { libraries: n } = j(C), s = t?.reactRouter || n?.reactRouter, o = t?.gtm || n?.gtm;
|
|
384
384
|
if (!s)
|
|
@@ -394,8 +394,8 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
394
394
|
pathname: l,
|
|
395
395
|
...e
|
|
396
396
|
});
|
|
397
|
-
}, [e, l, f]), /* @__PURE__ */
|
|
398
|
-
},
|
|
397
|
+
}, [e, l, f]), /* @__PURE__ */ I.jsx(u, {});
|
|
398
|
+
}, z = (() => {
|
|
399
399
|
try {
|
|
400
400
|
return typeof global == "object" && global !== null && ("HermesInternal" in global || // Hermes JS engine
|
|
401
401
|
"__fbBatchedBridge" in global || // RN Bridge
|
|
@@ -412,7 +412,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
412
412
|
const { apiURL: o = s.apiURL, libraries: a, localStorageKeys: c } = j(C), u = s?.userLocalStorageKey || c?.user || be, l = s?.axios || a?.axios;
|
|
413
413
|
if (!l)
|
|
414
414
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
415
|
-
if (!l?.defaults ||
|
|
415
|
+
if (!l?.defaults || z)
|
|
416
416
|
return null;
|
|
417
417
|
if (typeof window < "u" && window.localStorage) {
|
|
418
418
|
const f = localStorage.getItem(u), i = f ? JSON.parse(f) : null, h = i?.[e] ? i[e] : null, m = i?.[t] ? i[t] : null, y = f ? `${h} ${m}` : null;
|
|
@@ -435,7 +435,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
435
435
|
}, [s, o, e]), null;
|
|
436
436
|
}, Xe = ({ debug: e, resources: t, ...n }) => {
|
|
437
437
|
const { libraries: s } = j(C), o = n?.i18 || s?.i18, { i18next: a, initReactI18next: c, languageDetector: u } = o || {};
|
|
438
|
-
if (
|
|
438
|
+
if (z)
|
|
439
439
|
return null;
|
|
440
440
|
if (!o)
|
|
441
441
|
throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
@@ -508,7 +508,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
508
508
|
tracesSampleRate: n || 1
|
|
509
509
|
}), null;
|
|
510
510
|
}, et = () => (N(() => {
|
|
511
|
-
if (
|
|
511
|
+
if (z)
|
|
512
512
|
return;
|
|
513
513
|
const e = (t) => {
|
|
514
514
|
try {
|
|
@@ -529,7 +529,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
529
529
|
(d) => d,
|
|
530
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 && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(f)), h(s)), Promise.reject(d))
|
|
531
531
|
));
|
|
532
|
-
}, [l, f, s]), g && !i ? /* @__PURE__ */
|
|
532
|
+
}, [l, f, s]), g && !i ? /* @__PURE__ */ I.jsx(ye, { fallback: e, children: A.state?.from?.state && A.state?.from?.pathname === n ? /* @__PURE__ */ I.jsx(y, { to: A.state.from.state.from.pathname + A.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ I.jsx(v, {}) }) : /* @__PURE__ */ I.jsx(y, { to: n + A.search, state: { from: A }, replace: !0 });
|
|
533
533
|
}, Se = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), Ae = (e) => {
|
|
534
534
|
const t = e.split(/[/\\]/).pop() || "";
|
|
535
535
|
return t.substring(0, t.lastIndexOf("."));
|
|
@@ -603,10 +603,10 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
603
603
|
}, pe = fe(null), nt = ({ children: e, reconnect: t = !0, enabled: n = !0, url: s, token: o }) => {
|
|
604
604
|
const [a, c] = D(!1), [u, l] = D(!1), [f, i] = D(0), { apiURL: h, localStorageKeys: m } = j(C), y = m?.user || xe, v = B(null), A = B(/* @__PURE__ */ new Set());
|
|
605
605
|
N(() => {
|
|
606
|
-
if (!n
|
|
606
|
+
if (!n)
|
|
607
607
|
return;
|
|
608
|
-
const
|
|
609
|
-
if (!
|
|
608
|
+
const S = s || (h ? Oe(h) : null);
|
|
609
|
+
if (!S)
|
|
610
610
|
return;
|
|
611
611
|
const $ = () => o ?? Ie(y), Y = (L) => {
|
|
612
612
|
switch (L.type) {
|
|
@@ -614,41 +614,43 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
614
614
|
l(!0), i(L.unreadCount ?? 0);
|
|
615
615
|
break;
|
|
616
616
|
case "new_message_notification":
|
|
617
|
-
i((
|
|
617
|
+
i((P) => P + 1);
|
|
618
618
|
break;
|
|
619
619
|
case "marked_read":
|
|
620
|
-
i((
|
|
620
|
+
i((P) => Math.max(0, P - 1));
|
|
621
621
|
break;
|
|
622
622
|
}
|
|
623
|
-
for (const
|
|
624
|
-
|
|
625
|
-
},
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
623
|
+
for (const P of A.current)
|
|
624
|
+
P(L);
|
|
625
|
+
}, J = setTimeout(() => {
|
|
626
|
+
const L = new ve({
|
|
627
|
+
getToken: $,
|
|
628
|
+
onConnectionChange: (P) => {
|
|
629
|
+
c(P), P || l(!1);
|
|
630
|
+
},
|
|
631
|
+
onEvent: Y,
|
|
632
|
+
reconnect: t,
|
|
633
|
+
url: S
|
|
634
|
+
});
|
|
635
|
+
v.current = L, L.connect();
|
|
636
|
+
}, 0);
|
|
637
|
+
return () => {
|
|
638
|
+
clearTimeout(J), v.current?.disconnect(), v.current = null;
|
|
636
639
|
};
|
|
637
640
|
}, [n, s, o, h, t, y]);
|
|
638
|
-
const k =
|
|
639
|
-
v.current?.joinThread(
|
|
640
|
-
}, []), g =
|
|
641
|
-
v.current?.leaveThread(
|
|
642
|
-
}, []), d =
|
|
643
|
-
v.current?.sendMessage(
|
|
644
|
-
}, []), b =
|
|
645
|
-
v.current?.markRead(
|
|
646
|
-
}, []), E =
|
|
647
|
-
v.current?.listThreads(
|
|
648
|
-
}, []),
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}), []),
|
|
641
|
+
const k = O((S) => {
|
|
642
|
+
v.current?.joinThread(S);
|
|
643
|
+
}, []), g = O((S) => {
|
|
644
|
+
v.current?.leaveThread(S);
|
|
645
|
+
}, []), d = O((S, $) => {
|
|
646
|
+
v.current?.sendMessage(S, $);
|
|
647
|
+
}, []), b = O((S) => {
|
|
648
|
+
v.current?.markRead(S);
|
|
649
|
+
}, []), E = O((S, $) => {
|
|
650
|
+
v.current?.listThreads(S, $);
|
|
651
|
+
}, []), T = O((S) => (A.current.add(S), () => {
|
|
652
|
+
A.current.delete(S);
|
|
653
|
+
}), []), x = {
|
|
652
654
|
isConnected: a,
|
|
653
655
|
isReady: u,
|
|
654
656
|
joinThread: k,
|
|
@@ -656,9 +658,10 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
656
658
|
listThreads: E,
|
|
657
659
|
markRead: b,
|
|
658
660
|
sendMessage: d,
|
|
661
|
+
subscribe: T,
|
|
659
662
|
unreadCount: f
|
|
660
663
|
};
|
|
661
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ I.jsx(pe.Provider, { value: x, children: e });
|
|
662
665
|
}, Ne = (e) => e && typeof e == "function", Le = (e) => e && typeof e == "function", ot = ({
|
|
663
666
|
children: e,
|
|
664
667
|
defaultQueriesOptions: t,
|
|
@@ -687,7 +690,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
687
690
|
}
|
|
688
691
|
}
|
|
689
692
|
});
|
|
690
|
-
return /* @__PURE__ */
|
|
693
|
+
return /* @__PURE__ */ I.jsx(c, { client: u, children: e });
|
|
691
694
|
}, $e = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), Fe = (e, t) => {
|
|
692
695
|
const { fractionDigits: n = 0, metric: s = "km", spacingBetween: o = !0 } = t || {}, a = Number(e), c = o ? " " : "";
|
|
693
696
|
return Number.isNaN(a) ? `0${c}${s}` : `${a.toFixed(n)}${c}${s}`;
|
|
@@ -726,7 +729,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
726
729
|
const { libraries: t, localStorageKeys: n } = j(C), s = e?.axios || t?.axios, o = e?.localStorageKey || n?.user || "user";
|
|
727
730
|
if (!s)
|
|
728
731
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
|
|
729
|
-
const a =
|
|
732
|
+
const a = O(
|
|
730
733
|
({ tokenType: u, accessToken: l }) => {
|
|
731
734
|
s.defaults.headers.common.Authorization = `${u} ${l}`;
|
|
732
735
|
},
|
|
@@ -735,7 +738,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
735
738
|
s.defaults.headers.common.Authorization = null;
|
|
736
739
|
};
|
|
737
740
|
return N(() => {
|
|
738
|
-
if (
|
|
741
|
+
if (z)
|
|
739
742
|
return;
|
|
740
743
|
const u = ({ newValue: l, key: f }) => {
|
|
741
744
|
if (f === o && l)
|
|
@@ -757,61 +760,58 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
757
760
|
const t = j(pe);
|
|
758
761
|
if (!t)
|
|
759
762
|
throw new Error("useChat must be used within ChatProvider");
|
|
760
|
-
const {
|
|
761
|
-
return o.current = e, N(
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
[n]
|
|
805
|
-
), s;
|
|
806
|
-
}, J = (e, t) => t === "short" ? e.split("-")[0] : e, ct = (e, t = "full") => {
|
|
763
|
+
const { subscribe: n, ...s } = t, o = B(e);
|
|
764
|
+
return o.current = e, N(() => n((a) => {
|
|
765
|
+
const {
|
|
766
|
+
onReady: c,
|
|
767
|
+
onNewMessage: u,
|
|
768
|
+
onNewMessageNotification: l,
|
|
769
|
+
onPresence: f,
|
|
770
|
+
onError: i,
|
|
771
|
+
onJoinedThread: h,
|
|
772
|
+
onLeftThread: m,
|
|
773
|
+
onMarkedRead: y,
|
|
774
|
+
onThreadsList: v
|
|
775
|
+
} = o.current ?? {};
|
|
776
|
+
switch (a.type) {
|
|
777
|
+
case "ready":
|
|
778
|
+
c?.(a);
|
|
779
|
+
break;
|
|
780
|
+
case "new_message":
|
|
781
|
+
u?.(a);
|
|
782
|
+
break;
|
|
783
|
+
case "new_message_notification":
|
|
784
|
+
l?.(a);
|
|
785
|
+
break;
|
|
786
|
+
case "presence":
|
|
787
|
+
f?.(a);
|
|
788
|
+
break;
|
|
789
|
+
case "error":
|
|
790
|
+
i?.(a);
|
|
791
|
+
break;
|
|
792
|
+
case "joined_thread":
|
|
793
|
+
h?.(a);
|
|
794
|
+
break;
|
|
795
|
+
case "left_thread":
|
|
796
|
+
m?.(a);
|
|
797
|
+
break;
|
|
798
|
+
case "marked_read":
|
|
799
|
+
y?.(a);
|
|
800
|
+
break;
|
|
801
|
+
case "threads_list":
|
|
802
|
+
v?.(a);
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
805
|
+
}), [n]), s;
|
|
806
|
+
}, Q = (e, t) => t === "short" ? e.split("-")[0] : e, ct = (e, t = "full") => {
|
|
807
807
|
const [n, s] = D(() => {
|
|
808
808
|
const o = e?.language || navigator.language;
|
|
809
|
-
return e && "isInitialized" in e && e.isInitialized,
|
|
809
|
+
return e && "isInitialized" in e && e.isInitialized, Q(o, t);
|
|
810
810
|
});
|
|
811
811
|
return N(() => {
|
|
812
|
-
e && "isInitialized" in e && e.isInitialized && e.language && s(
|
|
812
|
+
e && "isInitialized" in e && e.isInitialized && e.language && s(Q(e.language, t));
|
|
813
813
|
const o = (a) => {
|
|
814
|
-
s(
|
|
814
|
+
s(Q(a, t));
|
|
815
815
|
};
|
|
816
816
|
return e?.on?.("languageChanged", o), () => {
|
|
817
817
|
e?.off?.("languageChanged", o);
|
|
@@ -843,7 +843,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
843
843
|
}, {}), lt = (e) => {
|
|
844
844
|
const { libraries: t, localStorageKeys: n } = j(C), s = e?.reactRouter || t?.reactRouter, { pathname: o } = s?.useLocation?.() ?? { pathname: "/" }, [a, c] = s?.useSearchParams?.() ?? [new URLSearchParams(), () => {
|
|
845
845
|
}], [u, l] = D({}), f = n?.filter || Ue, i = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, h = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
|
|
846
|
-
if (
|
|
846
|
+
if (z)
|
|
847
847
|
return ze;
|
|
848
848
|
if (!s)
|
|
849
849
|
throw new Error(
|
|
@@ -854,13 +854,13 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
854
854
|
), y = (g, d, b = !0) => {
|
|
855
855
|
const E = de(g, e?.pathname || o, f);
|
|
856
856
|
if (!d || Array.isArray(d) && !d.length) {
|
|
857
|
-
i ? (a.delete(g), c(a)) : l((
|
|
858
|
-
const
|
|
859
|
-
return delete
|
|
857
|
+
i ? (a.delete(g), c(a)) : l((T) => {
|
|
858
|
+
const x = { ...T };
|
|
859
|
+
return delete x[g], x;
|
|
860
860
|
}), h && localStorage.removeItem(E);
|
|
861
861
|
return;
|
|
862
862
|
}
|
|
863
|
-
h && b && d && localStorage.setItem(E, JSON.stringify({ ...a, [g]: d })), i && d ? (a.set(g, JSON.stringify(d)), c(a)) : !i && d && l((
|
|
863
|
+
h && b && d && localStorage.setItem(E, JSON.stringify({ ...a, [g]: d })), i && d ? (a.set(g, JSON.stringify(d)), c(a)) : !i && d && l((T) => ({ ...T, [g]: d }));
|
|
864
864
|
};
|
|
865
865
|
return {
|
|
866
866
|
getFilter: (g, d) => {
|
|
@@ -877,8 +877,8 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
877
877
|
const b = de(g, e?.pathname || o, f), E = localStorage.getItem(b);
|
|
878
878
|
if (E)
|
|
879
879
|
try {
|
|
880
|
-
const
|
|
881
|
-
return !i &&
|
|
880
|
+
const T = JSON.parse(E)[g];
|
|
881
|
+
return !i && T !== void 0 && l((x) => ({ ...x, [g]: T })), T;
|
|
882
882
|
} catch {
|
|
883
883
|
}
|
|
884
884
|
}
|
|
@@ -887,7 +887,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
887
887
|
getFilters: () => {
|
|
888
888
|
const g = h ? We(m()) : {};
|
|
889
889
|
if (i) {
|
|
890
|
-
const d = Array.from(a.entries()).reduce((b, [E,
|
|
890
|
+
const d = Array.from(a.entries()).reduce((b, [E, T]) => (b[E] = ue(T), b), {});
|
|
891
891
|
return {
|
|
892
892
|
...g,
|
|
893
893
|
...d
|
|
@@ -900,8 +900,8 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
900
900
|
},
|
|
901
901
|
handleFilter: (g, d) => (b, E) => {
|
|
902
902
|
if (E || Array.isArray(E) && E.length === 0) {
|
|
903
|
-
const
|
|
904
|
-
y(g,
|
|
903
|
+
const T = d || "value", x = typeof E == "object" && T in E ? E[T] : E;
|
|
904
|
+
y(g, x);
|
|
905
905
|
return;
|
|
906
906
|
}
|
|
907
907
|
y(g, void 0);
|
|
@@ -916,7 +916,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
916
916
|
isLoading: o,
|
|
917
917
|
enabled: a = !0
|
|
918
918
|
}) => {
|
|
919
|
-
const c =
|
|
919
|
+
const c = O(
|
|
920
920
|
async (l) => {
|
|
921
921
|
n || !a || await t({ pageParam: l?.pageParam || l.visibleRowsCount });
|
|
922
922
|
},
|
|
@@ -932,7 +932,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
932
932
|
rows: u
|
|
933
933
|
};
|
|
934
934
|
}, dt = (e) => {
|
|
935
|
-
const { libraries: t } = j(C), 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), u =
|
|
935
|
+
const { libraries: t } = j(C), 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), u = O(
|
|
936
936
|
(f) => {
|
|
937
937
|
if (f && typeof f == "object" && "response" in f) {
|
|
938
938
|
const { response: i } = f || {};
|
|
@@ -955,7 +955,7 @@ const Ge = ({ IMaskMixin: e, ...t }) => {
|
|
|
955
955
|
},
|
|
956
956
|
[c]
|
|
957
957
|
);
|
|
958
|
-
return { getErrorCode:
|
|
958
|
+
return { getErrorCode: O((f) => {
|
|
959
959
|
const { response: i } = f || {};
|
|
960
960
|
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";
|
|
961
961
|
}, []), printError: u };
|
package/dist/main.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(g,F){typeof exports=="object"&&typeof module<"u"?F(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],F):(g=typeof globalThis<"u"?globalThis:g||self,F(g["@tracktor/shared-module"]={},g.axios,g.React))})(this,(function(g,F,l){"use strict";const fe=(e,t)=>{const r=F.CancelToken.source(),s=F({...e,...t,cancelToken:r.token}).then(({data:o})=>o);return s.cancel=()=>{r.cancel("Query was cancelled")},s};class X{url;getToken;onEvent;onConnectionChange;shouldReconnect;maxReconnectAttempts;reconnectBaseDelay;ws=null;reconnectAttempt=0;reconnectTimer=null;intentionalClose=!1;joinedThreads=new Set;pendingMessages=[];_connected=!1;_ready=!1;constructor(t){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}get connected(){return this._connected}get ready(){return this._ready}connect(){const t=this.getToken();if(!t)return;this.intentionalClose=!1;const r=this.url.includes("?")?"&":"?",s=`${this.url}${r}token=${t}`;this.ws=new WebSocket(s),this.ws.onopen=()=>{this._connected=!0,this.reconnectAttempt=0,this.onConnectionChange?.(!0),this.rejoinThreads(),this.flushPendingMessages()},this.ws.onmessage=o=>{try{const a=JSON.parse(o.data);a.type==="ready"&&(this._ready=!0),this.onEvent?.(a)}catch{}},this.ws.onclose=()=>{this._connected=!1,this._ready=!1,this.onConnectionChange?.(!1),!this.intentionalClose&&this.shouldReconnect&&this.reconnectAttempt<this.maxReconnectAttempts&&this.scheduleReconnect()},this.ws.onerror=()=>{}}disconnect(){this.intentionalClose=!0,this.pendingMessages=[],this.clearReconnectTimer(),this.ws&&(this.ws.close(),this.ws=null)}joinThread(t){this.joinedThreads.add(t),this.send({threadId:t,type:"join_thread"})}leaveThread(t){this.joinedThreads.delete(t),this.send({threadId:t,type:"leave_thread"})}sendMessage(t,r){if(r.length>1e3)throw new Error("Message body exceeds maximum length of 1000 characters");this.send({body:r,threadId:t,type:"send_message"})}markRead(t){this.send({threadId:t,type:"mark_read"})}listThreads(t,r){this.send({limit:t,offset:r,type:"list_threads"})}send(t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN){this.pendingMessages.push(t);return}this.ws.send(JSON.stringify(t))}flushPendingMessages(){const t=[...this.pendingMessages];this.pendingMessages=[];for(const r of t)this.send(r)}rejoinThreads(){for(const t of this.joinedThreads)this.send({threadId:t,type:"join_thread"})}scheduleReconnect(){this.clearReconnectTimer();const t=Math.min(this.reconnectBaseDelay*2**this.reconnectAttempt,3e4);this.reconnectAttempt++,this.reconnectTimer=setTimeout(()=>{this.connect()},t)}clearReconnectTimer(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}}var
|
|
1
|
+
(function(g,F){typeof exports=="object"&&typeof module<"u"?F(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],F):(g=typeof globalThis<"u"?globalThis:g||self,F(g["@tracktor/shared-module"]={},g.axios,g.React))})(this,(function(g,F,l){"use strict";const fe=(e,t)=>{const r=F.CancelToken.source(),s=F({...e,...t,cancelToken:r.token}).then(({data:o})=>o);return s.cancel=()=>{r.cancel("Query was cancelled")},s};class X{url;getToken;onEvent;onConnectionChange;shouldReconnect;maxReconnectAttempts;reconnectBaseDelay;ws=null;reconnectAttempt=0;reconnectTimer=null;intentionalClose=!1;joinedThreads=new Set;pendingMessages=[];_connected=!1;_ready=!1;constructor(t){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}get connected(){return this._connected}get ready(){return this._ready}connect(){const t=this.getToken();if(!t)return;this.intentionalClose=!1;const r=this.url.includes("?")?"&":"?",s=`${this.url}${r}token=${t}`;this.ws=new WebSocket(s),this.ws.onopen=()=>{this._connected=!0,this.reconnectAttempt=0,this.onConnectionChange?.(!0),this.rejoinThreads(),this.flushPendingMessages()},this.ws.onmessage=o=>{try{const a=JSON.parse(o.data);a.type==="ready"&&(this._ready=!0),this.onEvent?.(a)}catch{}},this.ws.onclose=()=>{this._connected=!1,this._ready=!1,this.onConnectionChange?.(!1),!this.intentionalClose&&this.shouldReconnect&&this.reconnectAttempt<this.maxReconnectAttempts&&this.scheduleReconnect()},this.ws.onerror=()=>{}}disconnect(){this.intentionalClose=!0,this.pendingMessages=[],this.clearReconnectTimer(),this.ws&&(this.ws.close(),this.ws=null)}joinThread(t){this.joinedThreads.add(t),this.send({threadId:t,type:"join_thread"})}leaveThread(t){this.joinedThreads.delete(t),this.send({threadId:t,type:"leave_thread"})}sendMessage(t,r){if(r.length>1e3)throw new Error("Message body exceeds maximum length of 1000 characters");this.send({body:r,threadId:t,type:"send_message"})}markRead(t){this.send({threadId:t,type:"mark_read"})}listThreads(t,r){this.send({limit:t,offset:r,type:"list_threads"})}send(t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN){this.pendingMessages.push(t);return}this.ws.send(JSON.stringify(t))}flushPendingMessages(){const t=[...this.pendingMessages];this.pendingMessages=[];for(const r of t)this.send(r)}rejoinThreads(){for(const t of this.joinedThreads)this.send({threadId:t,type:"join_thread"})}scheduleReconnect(){this.clearReconnectTimer();const t=Math.min(this.reconnectBaseDelay*2**this.reconnectAttempt,3e4);this.reconnectAttempt++,this.reconnectTimer=setTimeout(()=>{this.connect()},t)}clearReconnectTimer(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}}var W={exports:{}},M={};var Z;function he(){if(Z)return M;Z=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(s,o,a){var c=null;if(a!==void 0&&(c=""+a),o.key!==void 0&&(c=""+o.key),"key"in o){a={};for(var d in o)d!=="key"&&(a[d]=o[d])}else a=o;return o=a.ref,{$$typeof:e,type:s,key:c,ref:o!==void 0?o:null,props:a}}return M.Fragment=t,M.jsx=r,M.jsxs=r,M}var Y={};var q;function pe(){return q||(q=1,process.env.NODE_ENV!=="production"&&(function(){function e(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===x?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case P:return"Fragment";case f:return"Profiler";case y:return"StrictMode";case N:return"Suspense";case A:return"SuspenseList";case J:return"Activity"}if(typeof n=="object")switch(typeof n.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),n.$$typeof){case j:return"Portal";case C:return n.displayName||"Context";case T:return(n._context.displayName||"Context")+".Consumer";case S:var p=n.render;return n=n.displayName,n||(n=p.displayName||p.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case L:return p=n.displayName||null,p!==null?p:e(n.type)||"Memo";case U:p=n._payload,n=n._init;try{return e(n(p))}catch{}}return null}function t(n){return""+n}function r(n){try{t(n);var p=!1}catch{p=!0}if(p){p=console;var w=p.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&n[Symbol.toStringTag]||n.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),t(n)}}function s(n){if(n===P)return"<>";if(typeof n=="object"&&n!==null&&n.$$typeof===U)return"<...>";try{var p=e(n);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function o(){var n=I.A;return n===null?null:n.getOwner()}function a(){return Error("react-stack-top-frame")}function c(n){if(ae.call(n,"key")){var p=Object.getOwnPropertyDescriptor(n,"key").get;if(p&&p.isReactWarning)return!1}return n.key!==void 0}function d(n,p){function w(){ie||(ie=!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(n,"key",{get:w,configurable:!0})}function u(){var n=e(this.type);return ce[n]||(ce[n]=!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.")),n=this.props.ref,n!==void 0?n:null}function h(n,p,w,R,V,B){var b=w.ref;return n={$$typeof:_,type:n,key:p,props:w,_owner:R},(b!==void 0?b:null)!==null?Object.defineProperty(n,"ref",{enumerable:!1,get:u}):Object.defineProperty(n,"ref",{enumerable:!1,value:null}),n._store={},Object.defineProperty(n._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(n,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(n,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:V}),Object.defineProperty(n,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:B}),Object.freeze&&(Object.freeze(n.props),Object.freeze(n)),n}function i(n,p,w,R,V,B){var b=p.children;if(b!==void 0)if(R)if($e(b)){for(R=0;R<b.length;R++)m(b[R]);Object.freeze&&Object.freeze(b)}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 m(b);if(ae.call(p,"key")){b=e(n);var D=Object.keys(p).filter(function(et){return et!=="key"});R=0<D.length?"{key: someKey, "+D.join(": ..., ")+": ...}":"{key: someKey}",de[b+R]||(D=0<D.length?"{"+D.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,R,b,D,b),de[b+R]=!0)}if(b=null,w!==void 0&&(r(w),b=""+w),c(p)&&(r(p.key),b=""+p.key),"key"in p){w={};for(var H in p)H!=="key"&&(w[H]=p[H])}else w=p;return b&&d(w,typeof n=="function"?n.displayName||n.name||"Unknown":n),h(n,b,w,o(),Q,B)}function m(n){E(n)?n._store&&(n._store.validated=1):typeof n=="object"&&n!==null&&n.$$typeof===U&&(n._payload.status==="fulfilled"?E(n._payload.value)&&n._payload.value._store&&(n._payload.value._store.validated=1):n._store&&(n._store.validated=1))}function E(n){return typeof n=="object"&&n!==null&&n.$$typeof===_}var v=l,_=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),C=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),S=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),x=Symbol.for("react.client.reference"),N=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae=Object.prototype.hasOwnProperty,$e=Array.isArray,K=console.createTask?console.createTask:function(){return null};v={react_stack_bottom_frame:function(n){return n()}};var ie,ce={},le=v.react_stack_bottom_frame.bind(v,a)(),ue=K(s(a)),de={};Y.Fragment=P,Y.jsx=function(n,p,w){var R=1e4>N.recentlyCreatedOwnerStacks++;return i(n,p,w,!1,R?Error("react-stack-top-frame"):le,R?K(s(n)):ue)},Y.jsxs=function(n,p,w){var R=1e4>N.recentlyCreatedOwnerStacks++;return i(n,p,w,!0,R?Error("react-stack-top-frame"):le,R?K(s(n)):ue)}})()),Y}var $;function ge(){return $||($=1,process.env.NODE_ENV==="production"?G.exports=he():G.exports=pe()),G.exports}var I=ge();const me=({IMaskMixin:e,...t})=>{const r=l.useMemo(()=>e(({TextField:s,...o})=>I.jsx(s,{...o})),[e]);return I.jsx(r,{...t})},k=l.createContext({}),ye=({children:e,apiURL:t,libraries:r,localStorageKeys:s})=>{const o=l.useMemo(()=>({apiURL:t,libraries:r,localStorageKeys:s}),[t,r,s]);return I.jsx(k.Provider,{value:o,children:e})},Ee=({data:e,...t})=>{const{libraries:r}=l.useContext(k),s=t?.reactRouter||r?.reactRouter,o=t?.gtm||r?.gtm;if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!o)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:a}=o,{useLocation:c,Outlet:d}=s,{pathname:u}=c(),{sendEvent:h}=a();return l.useEffect(()=>{h({event:"pageView",pathname:u,...e})},[e,u,h]),I.jsx(d,{})},z=(()=>{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}})(),ve="user",we=({tokenTypeKey:e="tokenType",tokenKey:t="accessToken",postContentType:r="application/json",...s})=>{const{apiURL:o=s.apiURL,libraries:a,localStorageKeys:c}=l.useContext(k),d=s?.userLocalStorageKey||c?.user||ve,u=s?.axios||a?.axios;if(!u)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!u?.defaults||z)return null;if(typeof window<"u"&&window.localStorage){const h=localStorage.getItem(d),i=h?JSON.parse(h):null,m=i?.[e]?i[e]:null,E=i?.[t]?i[t]:null,v=h?`${m} ${E}`:null;v&&(u.defaults.headers.common.Authorization=v)}return u.defaults.baseURL=o,u.defaults.headers.post["Content-Type"]=r,null},_e=({language:e,...t})=>{const{libraries:r}=l.useContext(k),s=t?.dayjs||r?.dayjs,o=t?.plugin||r?.dayjsPlugin;if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return l.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";o&&o.forEach(d=>{d&&s.extend(d)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),s.locale(c)})().then()},[s,o,e]),null},Ce=({debug:e,resources:t,...r})=>{const{libraries:s}=l.useContext(k),o=r?.i18||s?.i18,{i18next:a,initReactI18next:c,languageDetector:d}=o||{};if(z)return null;if(!o)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return a?.isInitialized||(a.use(d).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:t,returnNull:!1}).then(()=>{document.documentElement.lang!==a.resolvedLanguage&&a.resolvedLanguage&&document.documentElement.setAttribute("lang",a.resolvedLanguage)}),a.on("languageChanged",u=>{document.documentElement.setAttribute("lang",u)})),null},Re=({dsn:e,integrations:t,tracesSampleRate:r,replaysSessionSampleRate:s,replaysOnErrorSampleRate:o,tracePropagationTargets:a,ignoreErrors:c,debug:d,environment:u,release:h,...i})=>{const{libraries:m}=l.useContext(k),E=i?.sentry||m?.sentry,v=i?.reactRouter||m?.reactRouter;if(!E)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!v)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(E.isInitialized())return null;const{createRoutesFromChildren:_,matchRoutes:j,useLocation:P,useNavigationType:y}=v;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&E.init({debug:d,dsn:e,environment:u||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[E.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:_,matchRoutes:j,useEffect:l.useEffect,useLocation:P,useNavigationType:y}),...t||[]],release:h,replaysOnErrorSampleRate:o||1,replaysSessionSampleRate:s||.1,tracePropagationTargets:a,tracesSampleRate:r||1}),null},be=()=>(l.useEffect(()=>{if(z)return;const e=t=>{try{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),ee=new WeakMap,Te="user",Se=({Fallback:e,isLogged:t,loginPath:r="/login",redirect401Path:s="/login",...o})=>{const{libraries:a,localStorageKeys:c}=l.useContext(k),d=o?.reactRouter||a?.reactRouter,u=o?.axios||a?.axios,h=o?.localStorageKey||c?.user||Te;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,m]=l.useState(null),{useLocation:E,Navigate:v,Outlet:_}=d,j=E(),P=typeof t=="function"?t():!!t,y=typeof P=="boolean"?P:P?.isLogged;return l.useEffect(()=>{ee.has(u)||(ee.set(u,!0),u.interceptors.response.use(f=>f,f=>(typeof f=="object"&&f&&"response"in f&&f.response&&typeof f.response=="object"&&"status"in f.response&&f.response&&typeof f.response=="object"&&"status"in f.response&&f?.response?.status===401&&(typeof f=="object"&&f&&"config"in f&&f.config&&typeof f.config=="object"&&"headers"in f.config&&f.config.headers&&typeof f.config.headers=="object"&&"Authorization"in f.config.headers&&f.config.headers.Authorization&&(u.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(h)),m(s)),Promise.reject(f))))},[u,h,s]),y&&!i?I.jsx(l.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===r?I.jsx(v,{to:j.state.from.state.from.pathname+j.state.from.state.from.search,replace:!0}):I.jsx(_,{})}):I.jsx(v,{to:r+j.search,state:{from:j},replace:!0})},Ae=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),je=e=>{const t=e.split(/[/\\]/).pop()||"";return t.substring(0,t.lastIndexOf("."))},ke=e=>{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("");return s.charAt(0).toLowerCase()+s.slice(1)},Pe=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Ie=(e,t,r,s)=>{const o=ke(t),a=Ae(r),c=`${o}${a}`;return e&&typeof e=="object"&&"operationId"in e&&s?.includes(String(e.operationId))?`${c}AsQuery`:c},Oe=(e,t)=>{const r={};return e?.forEach(s=>{r[s]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),t?.filter(s=>!r[s]).forEach(s=>{r[s]={query:{useQuery:!0}}}),Object.keys(r).length?r:void 0},Ne=e=>(Array.isArray(e)?e:[e]).reduce((r,s)=>{const{output:o,useInfiniteIds:a,useQueryIds:c,input:d="./openapi.json",customAxiosInstancePath:u,overrideApiName:h}=s||{},i=h||Pe(d),m=u||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...r,[i]:{input:d,output:{baseUrl:o?.baseUrl,client:"react-query",mode:"tags-split",override:{...(a?.length||c?.length)&&{operations:Oe(a,c)},header:E=>["Generated by orval 🍺",...E.title?[E.title]:[],...E.description?[E.description]:[]],mutator:{name:je(m),path:m},operationName:(E,v,_)=>Ie(E,v,_,c),query:{useQuery:!0}},schemas:o?.schemas||`src/api/${i}/model`,target:o?.target||`src/api/${i}/services/api.ts`,...o}}}},{}),xe="user",Le=e=>{const t=e.startsWith("https")?"wss":"ws",r=e.replace(/^https?:\/\//,"");return`${t}://${r}/v2/threads/ws`},Fe=e=>{try{const t=localStorage.getItem(e);return t?JSON.parse(t)?.accessToken??null:null}catch{return null}},J=l.createContext(null),De=({children:e,reconnect:t=!0,enabled:r=!0,url:s,token:o})=>{const[a,c]=l.useState(!1),[d,u]=l.useState(!1),[h,i]=l.useState(0),{apiURL:m,localStorageKeys:E}=l.useContext(k),v=E?.user||xe,_=l.useRef(null),j=l.useRef(new Set);l.useEffect(()=>{if(!r||_.current?.connected)return;const S=s||(m?Le(m):null);if(!S)return;const L=()=>o??Fe(v),U=x=>{switch(x.type){case"ready":u(!0),i(x.unreadCount??0);break;case"new_message_notification":i(N=>N+1);break;case"marked_read":i(N=>Math.max(0,N-1));break}for(const N of j.current)N(x)},W=new X({getToken:L,onConnectionChange:x=>{c(x),x||u(!1)},onEvent:U,reconnect:t,url:S});return _.current=W,W.connect(),()=>{W.disconnect(),_.current=null}},[r,s,o,m,t,v]);const P=l.useCallback(S=>{_.current?.joinThread(S)},[]),y=l.useCallback(S=>{_.current?.leaveThread(S)},[]),f=l.useCallback((S,L)=>{_.current?.sendMessage(S,L)},[]),T=l.useCallback(S=>{_.current?.markRead(S)},[]),C=l.useCallback((S,L)=>{_.current?.listThreads(S,L)},[]),O={addListener:l.useCallback(S=>(j.current.add(S),()=>{j.current.delete(S)}),[]),isConnected:a,isReady:d,joinThread:P,leaveThread:y,listThreads:C,markRead:T,sendMessage:f,unreadCount:h};return I.jsx(J.Provider,{value:O,children:e})},Me=e=>e&&typeof e=="function",Ye=e=>e&&typeof e=="function",ze=({children:e,defaultQueriesOptions:t,defaultMutationsOptions:r,...s})=>{const{libraries:o}=l.useContext(k),a=s?.QueryClient||o?.reactQuery?.QueryClient,c=s?.QueryClientProvider||o?.reactQuery?.QueryClientProvider;if(!a)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(!Me(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ye(a))throw new Error("Provided QueryClient dependencies are not valid.");const d=new a({defaultOptions:{mutations:{...r},queries:{getNextPageParam:(u,h,i)=>u.length+(i||0),refetchOnWindowFocus:!1,retry:3,...t}}});return I.jsx(c,{client:d,children:e})},te=({library:e,date:t,format:r="ll"})=>e(t).format(r),ne=(e,t)=>{const{fractionDigits:r=0,metric:s="km",spacingBetween:o=!0}=t||{},a=Number(e),c=o?" ":"";return Number.isNaN(a)?`0${c}${s}`:`${a.toFixed(r)}${c}${s}`},re=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(r=>r.length>0?r.charAt(0).toUpperCase()+r.slice(1):r).join(" "),Ue=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,We=({path:e,size:t,apiURL:r})=>{if(!e)return"";const s=Ue(e),o=`${r}${s}`,a=o.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof t=="number"&&a?`${o.replace("/files",`/thumbs/${t}`)}`:o},Ge=e=>{const{apiURL:t,libraries:r}=l.useContext(k),s=e?.dayjs||r?.dayjs;return{dateAdapter:(c,d)=>{if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return te({date:c,format:d,library:s})},distanceAdapter:ne,filePathAdapter:(c,d)=>{if(!t)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:We({apiURL:t,path:c,size:d})},worksiteNameAdapter:re}},Ve=e=>{const{libraries:t,localStorageKeys:r}=l.useContext(k),s=e?.axios||t?.axios,o=e?.localStorageKey||r?.user||"user";if(!s)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const a=l.useCallback(({tokenType:d,accessToken:u})=>{s.defaults.headers.common.Authorization=`${d} ${u}`},[s.defaults.headers.common]),c=()=>{s.defaults.headers.common.Authorization=null};return l.useEffect(()=>{if(z)return;const d=({newValue:u,key:h})=>{if(h===o&&u)try{const{accessToken:i,tokenType:m}=JSON.parse(u);a({accessToken:i,tokenType:m})}catch(i){console.error("Failed to parse newValue from localStorage:",i)}};return window.addEventListener("storage",d),()=>{window.removeEventListener("storage",d)}},[o,a]),{clearAuthenticationToken:c,setAuthenticationToken:a}},Qe=e=>{const t=l.useContext(J);if(!t)throw new Error("useChat must be used within ChatProvider");const{addListener:r,...s}=t,o=l.useRef(e);return o.current=e,l.useEffect(()=>r(a=>{const{onReady:c,onNewMessage:d,onNewMessageNotification:u,onPresence:h,onError:i,onJoinedThread:m,onLeftThread:E,onMarkedRead:v,onThreadsList:_}=o.current??{};switch(a.type){case"ready":c?.(a);break;case"new_message":d?.(a);break;case"new_message_notification":u?.(a);break;case"presence":h?.(a);break;case"error":i?.(a);break;case"joined_thread":m?.(a);break;case"left_thread":E?.(a);break;case"marked_read":v?.(a);break;case"threads_list":_?.(a);break}}),[r]),s},V=(e,t)=>t==="short"?e.split("-")[0]:e,Je=(e,t="full")=>{const[r,s]=l.useState(()=>{const o=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,V(o,t)});return l.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&s(V(e.language,t));const o=a=>{s(V(a,t))};return e?.on?.("languageChanged",o),()=>{e?.off?.("languageChanged",o)}},[e,t]),r},Ke="tracktor.filter",Be={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},oe=e=>{try{return JSON.parse(e)}catch{return e}},se=(e,t,r)=>`${r}_${e}=>${t}`,He=e=>e.reduce((t,r)=>{const s=localStorage.getItem(r);if(s)try{const o=JSON.parse(s),a=Object.keys(o)?.[0];a&&(t[a]=Object.values(o)?.[0])}catch{}return t},{}),Xe=e=>{const{libraries:t,localStorageKeys:r}=l.useContext(k),s=e?.reactRouter||t?.reactRouter,{pathname:o}=s?.useLocation?.()??{pathname:"/"},[a,c]=s?.useSearchParams?.()??[new URLSearchParams,()=>{}],[d,u]=l.useState({}),h=r?.filter||Ke,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,m=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(z)return Be;if(!s)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(y=>y.startsWith(h)&&y.endsWith(e?.pathname||o)),v=(y,f,T=!0)=>{const C=se(y,e?.pathname||o,h);if(!f||Array.isArray(f)&&!f.length){i?(a.delete(y),c(a)):u(A=>{const O={...A};return delete O[y],O}),m&&localStorage.removeItem(C);return}m&&T&&f&&localStorage.setItem(C,JSON.stringify({...a,[y]:f})),i&&f?(a.set(y,JSON.stringify(f)),c(a)):!i&&f&&u(A=>({...A,[y]:f}))};return{getFilter:(y,f)=>{if(i){const T=a.get(y);if(T)return oe(T)}else{const T=d[y];if(T!==void 0)return T}if(m){const T=se(y,e?.pathname||o,h),C=localStorage.getItem(T);if(C)try{const A=JSON.parse(C)[y];return!i&&A!==void 0&&u(O=>({...O,[y]:A})),A}catch{}}return f},getFilters:()=>{const y=m?He(E()):{};if(i){const f=Array.from(a.entries()).reduce((T,[C,A])=>(T[C]=oe(A),T),{});return{...y,...f}}return{...y,...d}},handleFilter:(y,f)=>(T,C)=>{if(C||Array.isArray(C)&&C.length===0){const A=f||"value",O=typeof C=="object"&&A in C?C[A]:C;v(y,O);return}v(y,void 0)},setFilter:v}},Ze=({data:e,fetchNextPage:t,isFetchingNextPage:r,isInitialLoading:s,isLoading:o,enabled:a=!0})=>{const c=l.useCallback(async u=>{r||!a||await t({pageParam:u?.pageParam||u.visibleRowsCount})},[a,t,r]),d=l.useMemo(()=>{if(e)return e.pages.reduce((u,h)=>[...u,...h],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:r||o,loadingVariant:s?"skeleton":"linear-progress",rows:d}},qe=e=>{const{libraries:t}=l.useContext(k),r=e?.i18||t?.i18,s=e?.i18?.translateFunction||t?.i18?.translateFunction,o=r?.i18next?.t||s||(h=>h),{unknownErrorTranslationKey:a="error.unknownError"}=e||{},c=o(a),d=l.useCallback(h=>{if(h&&typeof h=="object"&&"response"in h){const{response:i}=h||{};if(i&&typeof i=="object"&&"reason"in i&&i.reason)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data&&i.data.reason)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data&&i.data.message)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:m}=i.data;if(Array.isArray(m)&&m.length>0&&typeof m[0]=="object"&&m[0]!==null&&"msg"in m[0]){const{msg:E}=m[0];if(typeof E=="string")return String(E)}}}return h instanceof Error?h.message:c},[c]);return{getErrorCode:l.useCallback(h=>{const{response:i}=h||{};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}};g.ChatClient=X,g.ChatContext=J,g.ChatProvider=De,g.GTMSendPageView=Ee,g.InitializeAxiosConfig=we,g.InitializeDaysJSConfig=_e,g.InitializeI18nConfig=Ce,g.InitializeSentryConfig=Re,g.InjectDependenciesContext=k,g.InjectDependenciesProvider=ye,g.MaskTextField=me,g.PreloadErrorHandler=be,g.QueryClientProviderWithConfig=ze,g.RequireAuth=Se,g.axiosCustomInstance=fe,g.dateAdapter=te,g.distanceAdapter=ne,g.getOrvalConfig=Ne,g.useAdapter=Ge,g.useAuth=Ve,g.useChat=Qe,g.useCurrentLanguage=Je,g.useFilters=Xe,g.useInfiniteDataGrid=Ze,g.useResponseError=qe,g.worksiteNameAdapter=re,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
<%s key={someKey} {...props} />`,R,b,D,b),de[b+R]=!0)}if(b=null,w!==void 0&&(r(w),b=""+w),c(p)&&(r(p.key),b=""+p.key),"key"in p){w={};for(var H in p)H!=="key"&&(w[H]=p[H])}else w=p;return b&&d(w,typeof n=="function"?n.displayName||n.name||"Unknown":n),h(n,b,w,o(),V,B)}function m(n){E(n)?n._store&&(n._store.validated=1):typeof n=="object"&&n!==null&&n.$$typeof===U&&(n._payload.status==="fulfilled"?E(n._payload.value)&&n._payload.value._store&&(n._payload.value._store.validated=1):n._store&&(n._store.validated=1))}function E(n){return typeof n=="object"&&n!==null&&n.$$typeof===_}var v=l,_=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),C=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),x=Symbol.for("react.client.reference"),I=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ae=Object.prototype.hasOwnProperty,$e=Array.isArray,K=console.createTask?console.createTask:function(){return null};v={react_stack_bottom_frame:function(n){return n()}};var ie,ce={},le=v.react_stack_bottom_frame.bind(v,a)(),ue=K(s(a)),de={};Y.Fragment=P,Y.jsx=function(n,p,w){var R=1e4>I.recentlyCreatedOwnerStacks++;return i(n,p,w,!1,R?Error("react-stack-top-frame"):le,R?K(s(n)):ue)},Y.jsxs=function(n,p,w){var R=1e4>I.recentlyCreatedOwnerStacks++;return i(n,p,w,!0,R?Error("react-stack-top-frame"):le,R?K(s(n)):ue)}})()),Y}var $;function ge(){return $||($=1,process.env.NODE_ENV==="production"?W.exports=he():W.exports=pe()),W.exports}var O=ge();const me=({IMaskMixin:e,...t})=>{const r=l.useMemo(()=>e(({TextField:s,...o})=>O.jsx(s,{...o})),[e]);return O.jsx(r,{...t})},k=l.createContext({}),ye=({children:e,apiURL:t,libraries:r,localStorageKeys:s})=>{const o=l.useMemo(()=>({apiURL:t,libraries:r,localStorageKeys:s}),[t,r,s]);return O.jsx(k.Provider,{value:o,children:e})},Ee=({data:e,...t})=>{const{libraries:r}=l.useContext(k),s=t?.reactRouter||r?.reactRouter,o=t?.gtm||r?.gtm;if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!o)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:a}=o,{useLocation:c,Outlet:d}=s,{pathname:u}=c(),{sendEvent:h}=a();return l.useEffect(()=>{h({event:"pageView",pathname:u,...e})},[e,u,h]),O.jsx(d,{})},z=(()=>{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}})(),ve="user",we=({tokenTypeKey:e="tokenType",tokenKey:t="accessToken",postContentType:r="application/json",...s})=>{const{apiURL:o=s.apiURL,libraries:a,localStorageKeys:c}=l.useContext(k),d=s?.userLocalStorageKey||c?.user||ve,u=s?.axios||a?.axios;if(!u)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!u?.defaults||z)return null;if(typeof window<"u"&&window.localStorage){const h=localStorage.getItem(d),i=h?JSON.parse(h):null,m=i?.[e]?i[e]:null,E=i?.[t]?i[t]:null,v=h?`${m} ${E}`:null;v&&(u.defaults.headers.common.Authorization=v)}return u.defaults.baseURL=o,u.defaults.headers.post["Content-Type"]=r,null},_e=({language:e,...t})=>{const{libraries:r}=l.useContext(k),s=t?.dayjs||r?.dayjs,o=t?.plugin||r?.dayjsPlugin;if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return l.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";o&&o.forEach(d=>{d&&s.extend(d)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),s.locale(c)})().then()},[s,o,e]),null},Ce=({debug:e,resources:t,...r})=>{const{libraries:s}=l.useContext(k),o=r?.i18||s?.i18,{i18next:a,initReactI18next:c,languageDetector:d}=o||{};if(z)return null;if(!o)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return a?.isInitialized||(a.use(d).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:t,returnNull:!1}).then(()=>{document.documentElement.lang!==a.resolvedLanguage&&a.resolvedLanguage&&document.documentElement.setAttribute("lang",a.resolvedLanguage)}),a.on("languageChanged",u=>{document.documentElement.setAttribute("lang",u)})),null},Re=({dsn:e,integrations:t,tracesSampleRate:r,replaysSessionSampleRate:s,replaysOnErrorSampleRate:o,tracePropagationTargets:a,ignoreErrors:c,debug:d,environment:u,release:h,...i})=>{const{libraries:m}=l.useContext(k),E=i?.sentry||m?.sentry,v=i?.reactRouter||m?.reactRouter;if(!E)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!v)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(E.isInitialized())return null;const{createRoutesFromChildren:_,matchRoutes:j,useLocation:P,useNavigationType:y}=v;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&E.init({debug:d,dsn:e,environment:u||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[E.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:_,matchRoutes:j,useEffect:l.useEffect,useLocation:P,useNavigationType:y}),...t||[]],release:h,replaysOnErrorSampleRate:o||1,replaysSessionSampleRate:s||.1,tracePropagationTargets:a,tracesSampleRate:r||1}),null},be=()=>(l.useEffect(()=>{if(z)return;const e=t=>{try{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),ee=new WeakMap,Te="user",Se=({Fallback:e,isLogged:t,loginPath:r="/login",redirect401Path:s="/login",...o})=>{const{libraries:a,localStorageKeys:c}=l.useContext(k),d=o?.reactRouter||a?.reactRouter,u=o?.axios||a?.axios,h=o?.localStorageKey||c?.user||Te;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,m]=l.useState(null),{useLocation:E,Navigate:v,Outlet:_}=d,j=E(),P=typeof t=="function"?t():!!t,y=typeof P=="boolean"?P:P?.isLogged;return l.useEffect(()=>{ee.has(u)||(ee.set(u,!0),u.interceptors.response.use(f=>f,f=>(typeof f=="object"&&f&&"response"in f&&f.response&&typeof f.response=="object"&&"status"in f.response&&f.response&&typeof f.response=="object"&&"status"in f.response&&f?.response?.status===401&&(typeof f=="object"&&f&&"config"in f&&f.config&&typeof f.config=="object"&&"headers"in f.config&&f.config.headers&&typeof f.config.headers=="object"&&"Authorization"in f.config.headers&&f.config.headers.Authorization&&(u.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(h)),m(s)),Promise.reject(f))))},[u,h,s]),y&&!i?O.jsx(l.Suspense,{fallback:e,children:j.state?.from?.state&&j.state?.from?.pathname===r?O.jsx(v,{to:j.state.from.state.from.pathname+j.state.from.state.from.search,replace:!0}):O.jsx(_,{})}):O.jsx(v,{to:r+j.search,state:{from:j},replace:!0})},Ae=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),je=e=>{const t=e.split(/[/\\]/).pop()||"";return t.substring(0,t.lastIndexOf("."))},ke=e=>{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("");return s.charAt(0).toLowerCase()+s.slice(1)},Pe=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Ie=(e,t,r,s)=>{const o=ke(t),a=Ae(r),c=`${o}${a}`;return e&&typeof e=="object"&&"operationId"in e&&s?.includes(String(e.operationId))?`${c}AsQuery`:c},Oe=(e,t)=>{const r={};return e?.forEach(s=>{r[s]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),t?.filter(s=>!r[s]).forEach(s=>{r[s]={query:{useQuery:!0}}}),Object.keys(r).length?r:void 0},Ne=e=>(Array.isArray(e)?e:[e]).reduce((r,s)=>{const{output:o,useInfiniteIds:a,useQueryIds:c,input:d="./openapi.json",customAxiosInstancePath:u,overrideApiName:h}=s||{},i=h||Pe(d),m=u||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...r,[i]:{input:d,output:{baseUrl:o?.baseUrl,client:"react-query",mode:"tags-split",override:{...(a?.length||c?.length)&&{operations:Oe(a,c)},header:E=>["Generated by orval 🍺",...E.title?[E.title]:[],...E.description?[E.description]:[]],mutator:{name:je(m),path:m},operationName:(E,v,_)=>Ie(E,v,_,c),query:{useQuery:!0}},schemas:o?.schemas||`src/api/${i}/model`,target:o?.target||`src/api/${i}/services/api.ts`,...o}}}},{}),xe="user",Le=e=>{const t=e.startsWith("https")?"wss":"ws",r=e.replace(/^https?:\/\//,"");return`${t}://${r}/v2/threads/ws`},Fe=e=>{try{const t=localStorage.getItem(e);return t?JSON.parse(t)?.accessToken??null:null}catch{return null}},Q=l.createContext(null),De=({children:e,reconnect:t=!0,enabled:r=!0,url:s,token:o})=>{const[a,c]=l.useState(!1),[d,u]=l.useState(!1),[h,i]=l.useState(0),{apiURL:m,localStorageKeys:E}=l.useContext(k),v=E?.user||xe,_=l.useRef(null),j=l.useRef(new Set);l.useEffect(()=>{if(!r)return;const A=s||(m?Le(m):null);if(!A)return;const L=()=>o??Fe(v),U=x=>{switch(x.type){case"ready":u(!0),i(x.unreadCount??0);break;case"new_message_notification":i(I=>I+1);break;case"marked_read":i(I=>Math.max(0,I-1));break}for(const I of j.current)I(x)},J=setTimeout(()=>{const x=new X({getToken:L,onConnectionChange:I=>{c(I),I||u(!1)},onEvent:U,reconnect:t,url:A});_.current=x,x.connect()},0);return()=>{clearTimeout(J),_.current?.disconnect(),_.current=null}},[r,s,o,m,t,v]);const P=l.useCallback(A=>{_.current?.joinThread(A)},[]),y=l.useCallback(A=>{_.current?.leaveThread(A)},[]),f=l.useCallback((A,L)=>{_.current?.sendMessage(A,L)},[]),T=l.useCallback(A=>{_.current?.markRead(A)},[]),C=l.useCallback((A,L)=>{_.current?.listThreads(A,L)},[]),S=l.useCallback(A=>(j.current.add(A),()=>{j.current.delete(A)}),[]),N={isConnected:a,isReady:d,joinThread:P,leaveThread:y,listThreads:C,markRead:T,sendMessage:f,subscribe:S,unreadCount:h};return O.jsx(Q.Provider,{value:N,children:e})},Me=e=>e&&typeof e=="function",Ye=e=>e&&typeof e=="function",ze=({children:e,defaultQueriesOptions:t,defaultMutationsOptions:r,...s})=>{const{libraries:o}=l.useContext(k),a=s?.QueryClient||o?.reactQuery?.QueryClient,c=s?.QueryClientProvider||o?.reactQuery?.QueryClientProvider;if(!a)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(!Me(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ye(a))throw new Error("Provided QueryClient dependencies are not valid.");const d=new a({defaultOptions:{mutations:{...r},queries:{getNextPageParam:(u,h,i)=>u.length+(i||0),refetchOnWindowFocus:!1,retry:3,...t}}});return O.jsx(c,{client:d,children:e})},te=({library:e,date:t,format:r="ll"})=>e(t).format(r),ne=(e,t)=>{const{fractionDigits:r=0,metric:s="km",spacingBetween:o=!0}=t||{},a=Number(e),c=o?" ":"";return Number.isNaN(a)?`0${c}${s}`:`${a.toFixed(r)}${c}${s}`},re=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(r=>r.length>0?r.charAt(0).toUpperCase()+r.slice(1):r).join(" "),Ue=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,We=({path:e,size:t,apiURL:r})=>{if(!e)return"";const s=Ue(e),o=`${r}${s}`,a=o.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof t=="number"&&a?`${o.replace("/files",`/thumbs/${t}`)}`:o},Ge=e=>{const{apiURL:t,libraries:r}=l.useContext(k),s=e?.dayjs||r?.dayjs;return{dateAdapter:(c,d)=>{if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return te({date:c,format:d,library:s})},distanceAdapter:ne,filePathAdapter:(c,d)=>{if(!t)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:We({apiURL:t,path:c,size:d})},worksiteNameAdapter:re}},Ve=e=>{const{libraries:t,localStorageKeys:r}=l.useContext(k),s=e?.axios||t?.axios,o=e?.localStorageKey||r?.user||"user";if(!s)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const a=l.useCallback(({tokenType:d,accessToken:u})=>{s.defaults.headers.common.Authorization=`${d} ${u}`},[s.defaults.headers.common]),c=()=>{s.defaults.headers.common.Authorization=null};return l.useEffect(()=>{if(z)return;const d=({newValue:u,key:h})=>{if(h===o&&u)try{const{accessToken:i,tokenType:m}=JSON.parse(u);a({accessToken:i,tokenType:m})}catch(i){console.error("Failed to parse newValue from localStorage:",i)}};return window.addEventListener("storage",d),()=>{window.removeEventListener("storage",d)}},[o,a]),{clearAuthenticationToken:c,setAuthenticationToken:a}},Qe=e=>{const t=l.useContext(Q);if(!t)throw new Error("useChat must be used within ChatProvider");const{subscribe:r,...s}=t,o=l.useRef(e);return o.current=e,l.useEffect(()=>r(a=>{const{onReady:c,onNewMessage:d,onNewMessageNotification:u,onPresence:h,onError:i,onJoinedThread:m,onLeftThread:E,onMarkedRead:v,onThreadsList:_}=o.current??{};switch(a.type){case"ready":c?.(a);break;case"new_message":d?.(a);break;case"new_message_notification":u?.(a);break;case"presence":h?.(a);break;case"error":i?.(a);break;case"joined_thread":m?.(a);break;case"left_thread":E?.(a);break;case"marked_read":v?.(a);break;case"threads_list":_?.(a);break}}),[r]),s},G=(e,t)=>t==="short"?e.split("-")[0]:e,Je=(e,t="full")=>{const[r,s]=l.useState(()=>{const o=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,G(o,t)});return l.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&s(G(e.language,t));const o=a=>{s(G(a,t))};return e?.on?.("languageChanged",o),()=>{e?.off?.("languageChanged",o)}},[e,t]),r},Ke="tracktor.filter",Be={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},oe=e=>{try{return JSON.parse(e)}catch{return e}},se=(e,t,r)=>`${r}_${e}=>${t}`,He=e=>e.reduce((t,r)=>{const s=localStorage.getItem(r);if(s)try{const o=JSON.parse(s),a=Object.keys(o)?.[0];a&&(t[a]=Object.values(o)?.[0])}catch{}return t},{}),Xe=e=>{const{libraries:t,localStorageKeys:r}=l.useContext(k),s=e?.reactRouter||t?.reactRouter,{pathname:o}=s?.useLocation?.()??{pathname:"/"},[a,c]=s?.useSearchParams?.()??[new URLSearchParams,()=>{}],[d,u]=l.useState({}),h=r?.filter||Ke,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,m=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(z)return Be;if(!s)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(y=>y.startsWith(h)&&y.endsWith(e?.pathname||o)),v=(y,f,T=!0)=>{const C=se(y,e?.pathname||o,h);if(!f||Array.isArray(f)&&!f.length){i?(a.delete(y),c(a)):u(S=>{const N={...S};return delete N[y],N}),m&&localStorage.removeItem(C);return}m&&T&&f&&localStorage.setItem(C,JSON.stringify({...a,[y]:f})),i&&f?(a.set(y,JSON.stringify(f)),c(a)):!i&&f&&u(S=>({...S,[y]:f}))};return{getFilter:(y,f)=>{if(i){const T=a.get(y);if(T)return oe(T)}else{const T=d[y];if(T!==void 0)return T}if(m){const T=se(y,e?.pathname||o,h),C=localStorage.getItem(T);if(C)try{const S=JSON.parse(C)[y];return!i&&S!==void 0&&u(N=>({...N,[y]:S})),S}catch{}}return f},getFilters:()=>{const y=m?He(E()):{};if(i){const f=Array.from(a.entries()).reduce((T,[C,S])=>(T[C]=oe(S),T),{});return{...y,...f}}return{...y,...d}},handleFilter:(y,f)=>(T,C)=>{if(C||Array.isArray(C)&&C.length===0){const S=f||"value",N=typeof C=="object"&&S in C?C[S]:C;v(y,N);return}v(y,void 0)},setFilter:v}},Ze=({data:e,fetchNextPage:t,isFetchingNextPage:r,isInitialLoading:s,isLoading:o,enabled:a=!0})=>{const c=l.useCallback(async u=>{r||!a||await t({pageParam:u?.pageParam||u.visibleRowsCount})},[a,t,r]),d=l.useMemo(()=>{if(e)return e.pages.reduce((u,h)=>[...u,...h],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:r||o,loadingVariant:s?"skeleton":"linear-progress",rows:d}},qe=e=>{const{libraries:t}=l.useContext(k),r=e?.i18||t?.i18,s=e?.i18?.translateFunction||t?.i18?.translateFunction,o=r?.i18next?.t||s||(h=>h),{unknownErrorTranslationKey:a="error.unknownError"}=e||{},c=o(a),d=l.useCallback(h=>{if(h&&typeof h=="object"&&"response"in h){const{response:i}=h||{};if(i&&typeof i=="object"&&"reason"in i&&i.reason)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data&&i.data.reason)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data&&i.data.message)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:m}=i.data;if(Array.isArray(m)&&m.length>0&&typeof m[0]=="object"&&m[0]!==null&&"msg"in m[0]){const{msg:E}=m[0];if(typeof E=="string")return String(E)}}}return h instanceof Error?h.message:c},[c]);return{getErrorCode:l.useCallback(h=>{const{response:i}=h||{};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}};g.ChatClient=X,g.ChatContext=Q,g.ChatProvider=De,g.GTMSendPageView=Ee,g.InitializeAxiosConfig=we,g.InitializeDaysJSConfig=_e,g.InitializeI18nConfig=Ce,g.InitializeSentryConfig=Re,g.InjectDependenciesContext=k,g.InjectDependenciesProvider=ye,g.MaskTextField=me,g.PreloadErrorHandler=be,g.QueryClientProviderWithConfig=ze,g.RequireAuth=Se,g.axiosCustomInstance=fe,g.dateAdapter=te,g.distanceAdapter=ne,g.getOrvalConfig=Ne,g.useAdapter=Ge,g.useAuth=Ve,g.useChat=Qe,g.useCurrentLanguage=Je,g.useFilters=Xe,g.useInfiniteDataGrid=Ze,g.useResponseError=qe,g.worksiteNameAdapter=re,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|