@tracktor/shared-module 2.32.0 → 2.33.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/context/ChatProvider.d.ts +1 -0
- package/dist/main.js +104 -101
- package/dist/main.umd.cjs +3 -3
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@ export interface ChatContextValue {
|
|
|
22
22
|
listThreads: (limit?: number, offset?: number) => void;
|
|
23
23
|
markRead: (threadId: string) => void;
|
|
24
24
|
sendMessage: (threadId: string, body: string) => void;
|
|
25
|
+
disconnect: () => void;
|
|
25
26
|
}
|
|
26
27
|
export declare const ChatContext: import('react').Context<ChatContextValue | null>;
|
|
27
28
|
declare const ChatProvider: ({ children, token, url, wsPath, reconnect, enabled, context, }: PropsWithChildren<ChatProviderProps>) => import("react/jsx-runtime").JSX.Element;
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import le from "axios";
|
|
2
|
-
import _e, { useMemo as
|
|
2
|
+
import _e, { useMemo as ae, createContext as ve, useContext as k, useEffect as x, useState as F, Suspense as Re, useRef as re, useCallback as A } from "react";
|
|
3
3
|
const Xe = (e, t) => {
|
|
4
4
|
const r = le.CancelToken.source(), o = le({
|
|
5
5
|
...e,
|
|
@@ -9,15 +9,15 @@ const Xe = (e, t) => {
|
|
|
9
9
|
return o.cancel = () => {
|
|
10
10
|
r.cancel("Query was cancelled");
|
|
11
11
|
}, o;
|
|
12
|
-
}, be = 3e4, ue = 1e3,
|
|
12
|
+
}, be = 3e4, ue = 1e3, ne = (e) => Array.isArray(e) ? e.map(ne) : e !== null && typeof e == "object" ? Object.fromEntries(
|
|
13
13
|
Object.entries(e).map(([t, r]) => [
|
|
14
14
|
t.replace(/_([a-z])/g, (o, s) => s.toUpperCase()),
|
|
15
|
-
|
|
15
|
+
ne(r)
|
|
16
16
|
])
|
|
17
|
-
) : e,
|
|
17
|
+
) : e, oe = (e) => Array.isArray(e) ? e.map(oe) : e !== null && typeof e == "object" ? Object.fromEntries(
|
|
18
18
|
Object.entries(e).map(([t, r]) => [
|
|
19
19
|
t.replace(/[A-Z]/g, (o) => `_${o.toLowerCase()}`),
|
|
20
|
-
|
|
20
|
+
oe(r)
|
|
21
21
|
])
|
|
22
22
|
) : e;
|
|
23
23
|
class Se {
|
|
@@ -55,7 +55,7 @@ class Se {
|
|
|
55
55
|
this._connected = !0, this.reconnectAttempt = 0, this.onConnectionChange?.(!0), this.rejoinThreads(), this.flushPendingMessages();
|
|
56
56
|
}, this.ws.onmessage = (s) => {
|
|
57
57
|
try {
|
|
58
|
-
const a = JSON.parse(s.data), c =
|
|
58
|
+
const a = JSON.parse(s.data), c = ne(a);
|
|
59
59
|
c.type === "ready" && (this._ready = !0), this.onEvent?.(c);
|
|
60
60
|
} catch {
|
|
61
61
|
}
|
|
@@ -89,7 +89,7 @@ class Se {
|
|
|
89
89
|
this.pendingMessages.push(t);
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
|
-
this.ws.send(JSON.stringify(
|
|
92
|
+
this.ws.send(JSON.stringify(oe(t)));
|
|
93
93
|
}
|
|
94
94
|
flushPendingMessages() {
|
|
95
95
|
const t = [...this.pendingMessages];
|
|
@@ -142,10 +142,10 @@ function Ce() {
|
|
|
142
142
|
function e(n) {
|
|
143
143
|
if (n == null) return null;
|
|
144
144
|
if (typeof n == "function")
|
|
145
|
-
return n.$$typeof ===
|
|
145
|
+
return n.$$typeof === X ? null : n.displayName || n.name || null;
|
|
146
146
|
if (typeof n == "string") return n;
|
|
147
147
|
switch (n) {
|
|
148
|
-
case
|
|
148
|
+
case E:
|
|
149
149
|
return "Fragment";
|
|
150
150
|
case d:
|
|
151
151
|
return "Profiler";
|
|
@@ -164,7 +164,7 @@ function Ce() {
|
|
|
164
164
|
), n.$$typeof) {
|
|
165
165
|
case C:
|
|
166
166
|
return "Portal";
|
|
167
|
-
case
|
|
167
|
+
case _:
|
|
168
168
|
return n.displayName || "Context";
|
|
169
169
|
case S:
|
|
170
170
|
return (n._context.displayName || "Context") + ".Consumer";
|
|
@@ -194,8 +194,8 @@ function Ce() {
|
|
|
194
194
|
}
|
|
195
195
|
if (p) {
|
|
196
196
|
p = console;
|
|
197
|
-
var
|
|
198
|
-
return
|
|
197
|
+
var w = p.error, R = typeof Symbol == "function" && Symbol.toStringTag && n[Symbol.toStringTag] || n.constructor.name || "Object";
|
|
198
|
+
return w.call(
|
|
199
199
|
p,
|
|
200
200
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
201
201
|
R
|
|
@@ -203,7 +203,7 @@ function Ce() {
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
function o(n) {
|
|
206
|
-
if (n ===
|
|
206
|
+
if (n === E) return "<>";
|
|
207
207
|
if (typeof n == "object" && n !== null && n.$$typeof === Y)
|
|
208
208
|
return "<...>";
|
|
209
209
|
try {
|
|
@@ -214,44 +214,44 @@ function Ce() {
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
function s() {
|
|
217
|
-
var n =
|
|
217
|
+
var n = v.A;
|
|
218
218
|
return n === null ? null : n.getOwner();
|
|
219
219
|
}
|
|
220
220
|
function a() {
|
|
221
221
|
return Error("react-stack-top-frame");
|
|
222
222
|
}
|
|
223
223
|
function c(n) {
|
|
224
|
-
if (
|
|
224
|
+
if (P.call(n, "key")) {
|
|
225
225
|
var p = Object.getOwnPropertyDescriptor(n, "key").get;
|
|
226
226
|
if (p && p.isReactWarning) return !1;
|
|
227
227
|
}
|
|
228
228
|
return n.key !== void 0;
|
|
229
229
|
}
|
|
230
230
|
function l(n, p) {
|
|
231
|
-
function
|
|
232
|
-
|
|
231
|
+
function w() {
|
|
232
|
+
Q || (Q = !0, console.error(
|
|
233
233
|
"%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)",
|
|
234
234
|
p
|
|
235
235
|
));
|
|
236
236
|
}
|
|
237
|
-
|
|
238
|
-
get:
|
|
237
|
+
w.isReactWarning = !0, Object.defineProperty(n, "key", {
|
|
238
|
+
get: w,
|
|
239
239
|
configurable: !0
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
242
|
function u() {
|
|
243
243
|
var n = e(this.type);
|
|
244
|
-
return
|
|
244
|
+
return L[n] || (L[n] = !0, console.error(
|
|
245
245
|
"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."
|
|
246
246
|
)), n = this.props.ref, n !== void 0 ? n : null;
|
|
247
247
|
}
|
|
248
|
-
function f(n, p,
|
|
249
|
-
var b =
|
|
248
|
+
function f(n, p, w, R, J, ee) {
|
|
249
|
+
var b = w.ref;
|
|
250
250
|
return n = {
|
|
251
251
|
$$typeof: j,
|
|
252
252
|
type: n,
|
|
253
253
|
key: p,
|
|
254
|
-
props:
|
|
254
|
+
props: w,
|
|
255
255
|
_owner: R
|
|
256
256
|
}, (b !== void 0 ? b : null) !== null ? Object.defineProperty(n, "ref", {
|
|
257
257
|
enumerable: !1,
|
|
@@ -275,14 +275,14 @@ function Ce() {
|
|
|
275
275
|
configurable: !1,
|
|
276
276
|
enumerable: !1,
|
|
277
277
|
writable: !0,
|
|
278
|
-
value:
|
|
278
|
+
value: ee
|
|
279
279
|
}), Object.freeze && (Object.freeze(n.props), Object.freeze(n)), n;
|
|
280
280
|
}
|
|
281
|
-
function i(n, p,
|
|
281
|
+
function i(n, p, w, R, J, ee) {
|
|
282
282
|
var b = p.children;
|
|
283
283
|
if (b !== void 0)
|
|
284
284
|
if (R)
|
|
285
|
-
if (
|
|
285
|
+
if (Z(b)) {
|
|
286
286
|
for (R = 0; R < b.length; R++)
|
|
287
287
|
g(b[R]);
|
|
288
288
|
Object.freeze && Object.freeze(b);
|
|
@@ -291,7 +291,7 @@ function Ce() {
|
|
|
291
291
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
292
292
|
);
|
|
293
293
|
else g(b);
|
|
294
|
-
if (
|
|
294
|
+
if (P.call(p, "key")) {
|
|
295
295
|
b = e(n);
|
|
296
296
|
var D = Object.keys(p).filter(function(Ee) {
|
|
297
297
|
return Ee !== "key";
|
|
@@ -309,21 +309,21 @@ React keys must be passed directly to JSX without using spread:
|
|
|
309
309
|
b
|
|
310
310
|
), ce[b + R] = !0);
|
|
311
311
|
}
|
|
312
|
-
if (b = null,
|
|
313
|
-
|
|
314
|
-
for (var
|
|
315
|
-
|
|
316
|
-
} else
|
|
312
|
+
if (b = null, w !== void 0 && (r(w), b = "" + w), c(p) && (r(p.key), b = "" + p.key), "key" in p) {
|
|
313
|
+
w = {};
|
|
314
|
+
for (var te in p)
|
|
315
|
+
te !== "key" && (w[te] = p[te]);
|
|
316
|
+
} else w = p;
|
|
317
317
|
return b && l(
|
|
318
|
-
|
|
318
|
+
w,
|
|
319
319
|
typeof n == "function" ? n.displayName || n.name || "Unknown" : n
|
|
320
320
|
), f(
|
|
321
321
|
n,
|
|
322
322
|
b,
|
|
323
|
-
|
|
323
|
+
w,
|
|
324
324
|
s(),
|
|
325
325
|
J,
|
|
326
|
-
|
|
326
|
+
ee
|
|
327
327
|
);
|
|
328
328
|
}
|
|
329
329
|
function g(n) {
|
|
@@ -332,7 +332,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
332
332
|
function m(n) {
|
|
333
333
|
return typeof n == "object" && n !== null && n.$$typeof === j;
|
|
334
334
|
}
|
|
335
|
-
var y = _e, j = /* @__PURE__ */ Symbol.for("react.transitional.element"), C = /* @__PURE__ */ Symbol.for("react.portal"),
|
|
335
|
+
var y = _e, j = /* @__PURE__ */ Symbol.for("react.transitional.element"), C = /* @__PURE__ */ Symbol.for("react.portal"), E = /* @__PURE__ */ Symbol.for("react.fragment"), h = /* @__PURE__ */ Symbol.for("react.strict_mode"), d = /* @__PURE__ */ Symbol.for("react.profiler"), S = /* @__PURE__ */ Symbol.for("react.consumer"), _ = /* @__PURE__ */ Symbol.for("react.context"), T = /* @__PURE__ */ Symbol.for("react.forward_ref"), I = /* @__PURE__ */ Symbol.for("react.suspense"), B = /* @__PURE__ */ Symbol.for("react.suspense_list"), K = /* @__PURE__ */ Symbol.for("react.memo"), Y = /* @__PURE__ */ Symbol.for("react.lazy"), q = /* @__PURE__ */ Symbol.for("react.activity"), X = /* @__PURE__ */ Symbol.for("react.client.reference"), v = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, P = Object.prototype.hasOwnProperty, Z = Array.isArray, U = console.createTask ? console.createTask : function() {
|
|
336
336
|
return null;
|
|
337
337
|
};
|
|
338
338
|
y = {
|
|
@@ -340,28 +340,28 @@ React keys must be passed directly to JSX without using spread:
|
|
|
340
340
|
return n();
|
|
341
341
|
}
|
|
342
342
|
};
|
|
343
|
-
var
|
|
343
|
+
var Q, L = {}, $ = y.react_stack_bottom_frame.bind(
|
|
344
344
|
y,
|
|
345
345
|
a
|
|
346
346
|
)(), ie = U(o(a)), ce = {};
|
|
347
|
-
z.Fragment =
|
|
348
|
-
var R = 1e4 >
|
|
347
|
+
z.Fragment = E, z.jsx = function(n, p, w) {
|
|
348
|
+
var R = 1e4 > v.recentlyCreatedOwnerStacks++;
|
|
349
349
|
return i(
|
|
350
350
|
n,
|
|
351
351
|
p,
|
|
352
|
-
|
|
352
|
+
w,
|
|
353
353
|
!1,
|
|
354
|
-
R ? Error("react-stack-top-frame") :
|
|
354
|
+
R ? Error("react-stack-top-frame") : $,
|
|
355
355
|
R ? U(o(n)) : ie
|
|
356
356
|
);
|
|
357
|
-
}, z.jsxs = function(n, p,
|
|
358
|
-
var R = 1e4 >
|
|
357
|
+
}, z.jsxs = function(n, p, w) {
|
|
358
|
+
var R = 1e4 > v.recentlyCreatedOwnerStacks++;
|
|
359
359
|
return i(
|
|
360
360
|
n,
|
|
361
361
|
p,
|
|
362
|
-
|
|
362
|
+
w,
|
|
363
363
|
!0,
|
|
364
|
-
R ? Error("react-stack-top-frame") :
|
|
364
|
+
R ? Error("react-stack-top-frame") : $,
|
|
365
365
|
R ? U(o(n)) : ie
|
|
366
366
|
);
|
|
367
367
|
};
|
|
@@ -373,14 +373,14 @@ function Ae() {
|
|
|
373
373
|
}
|
|
374
374
|
var N = Ae();
|
|
375
375
|
const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
376
|
-
const r =
|
|
376
|
+
const r = ae(
|
|
377
377
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
378
378
|
() => e(({ TextField: o, ...s }) => /* @__PURE__ */ N.jsx(o, { ...s })),
|
|
379
379
|
[e]
|
|
380
380
|
);
|
|
381
381
|
return /* @__PURE__ */ N.jsx(r, { ...t });
|
|
382
382
|
}, O = ve({}), et = ({ children: e, apiURL: t, libraries: r, localStorageKeys: o }) => {
|
|
383
|
-
const s =
|
|
383
|
+
const s = ae(
|
|
384
384
|
() => ({
|
|
385
385
|
apiURL: t,
|
|
386
386
|
libraries: r,
|
|
@@ -443,13 +443,13 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
443
443
|
}), await import("dayjs/locale/en"), await import("dayjs/locale/fr"), o.locale(c);
|
|
444
444
|
})().then();
|
|
445
445
|
}, [o, s, e]), null;
|
|
446
|
-
},
|
|
446
|
+
}, se = "hubspot-messages-iframe-container", W = "hs-show", ot = ({ hubId: e }) => (x(() => {
|
|
447
447
|
if (!e)
|
|
448
448
|
return;
|
|
449
449
|
const t = document.createElement("style");
|
|
450
450
|
t.textContent = `
|
|
451
|
-
div#${
|
|
452
|
-
div#${
|
|
451
|
+
div#${se} { display: none !important; }
|
|
452
|
+
div#${se}.${W} { display: initial !important; }
|
|
453
453
|
`, document.head.appendChild(t);
|
|
454
454
|
const r = document.createElement("script");
|
|
455
455
|
return r.id = "hs-script-loader", r.src = `//js-eu1.hs-scripts.com/${e}.js`, r.async = !0, r.defer = !0, document.body.appendChild(r), () => {
|
|
@@ -499,7 +499,7 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
499
499
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
500
500
|
if (m.isInitialized())
|
|
501
501
|
return null;
|
|
502
|
-
const { createRoutesFromChildren: j, matchRoutes: C, useLocation:
|
|
502
|
+
const { createRoutesFromChildren: j, matchRoutes: C, useLocation: E, useNavigationType: h } = y;
|
|
503
503
|
return (l || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && m.init({
|
|
504
504
|
debug: l,
|
|
505
505
|
dsn: e,
|
|
@@ -518,7 +518,7 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
518
518
|
createRoutesFromChildren: j,
|
|
519
519
|
matchRoutes: C,
|
|
520
520
|
useEffect: x,
|
|
521
|
-
useLocation:
|
|
521
|
+
useLocation: E,
|
|
522
522
|
useNavigationType: h
|
|
523
523
|
}),
|
|
524
524
|
...t || []
|
|
@@ -545,7 +545,7 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
545
545
|
const { libraries: a, localStorageKeys: c } = k(O), l = s?.reactRouter || a?.reactRouter, u = s?.axios || a?.axios, f = s?.localStorageKey || c?.user || Pe;
|
|
546
546
|
if (!l)
|
|
547
547
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
548
|
-
const [i, g] = F(null), { useLocation: m, Navigate: y, Outlet: j } = l, C = m(),
|
|
548
|
+
const [i, g] = F(null), { useLocation: m, Navigate: y, Outlet: j } = l, C = m(), E = typeof t == "function" ? t() : !!t, h = typeof E == "boolean" ? E : E?.isLogged;
|
|
549
549
|
return x(() => {
|
|
550
550
|
he.has(u) || (he.set(u, !0), u.interceptors.response.use(
|
|
551
551
|
(d) => d,
|
|
@@ -634,51 +634,54 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
634
634
|
enabled: a = !0,
|
|
635
635
|
context: c = "client"
|
|
636
636
|
}) => {
|
|
637
|
-
const [l, u] = F(!1), [f, i] = F(!1), [g, m] = F(0), { apiURL: y, localStorageKeys: j } = k(O), C = j?.user || $e,
|
|
637
|
+
const [l, u] = F(!1), [f, i] = F(!1), [g, m] = F(0), { apiURL: y, localStorageKeys: j } = k(O), C = j?.user || $e, E = re(null), h = re(/* @__PURE__ */ new Set());
|
|
638
638
|
x(() => {
|
|
639
639
|
if (!a)
|
|
640
640
|
return;
|
|
641
|
-
const
|
|
642
|
-
if (!
|
|
641
|
+
const v = o ?? Fe[c], P = r || (y ? De(y, v) : null);
|
|
642
|
+
if (!P)
|
|
643
643
|
return;
|
|
644
|
-
const
|
|
644
|
+
const Z = () => t ?? Ye(C), U = (L) => {
|
|
645
645
|
L.type === "ready" && (i(!0), m(L.unreadCount ?? 0));
|
|
646
646
|
for (const $ of h.current)
|
|
647
647
|
$(L);
|
|
648
|
-
},
|
|
648
|
+
}, Q = setTimeout(() => {
|
|
649
649
|
const L = new Se({
|
|
650
|
-
getToken:
|
|
650
|
+
getToken: Z,
|
|
651
651
|
onConnectionChange: ($) => {
|
|
652
652
|
u($), $ || i(!1);
|
|
653
653
|
},
|
|
654
|
-
onEvent:
|
|
654
|
+
onEvent: U,
|
|
655
655
|
reconnect: s,
|
|
656
|
-
url:
|
|
656
|
+
url: P
|
|
657
657
|
});
|
|
658
|
-
|
|
658
|
+
E.current = L, L.connect();
|
|
659
659
|
}, 0);
|
|
660
660
|
return () => {
|
|
661
|
-
clearTimeout(
|
|
661
|
+
clearTimeout(Q), E.current?.disconnect(), E.current = null;
|
|
662
662
|
};
|
|
663
663
|
}, [a, r, o, c, t, s, y, C]);
|
|
664
|
-
const d =
|
|
665
|
-
|
|
666
|
-
}, []), S =
|
|
667
|
-
|
|
668
|
-
}, []),
|
|
669
|
-
|
|
670
|
-
}, []), T =
|
|
671
|
-
|
|
672
|
-
}, []), I =
|
|
673
|
-
|
|
674
|
-
}, []), B =
|
|
675
|
-
m((
|
|
676
|
-
}, []), K =
|
|
677
|
-
m((
|
|
678
|
-
}, []), Y =
|
|
679
|
-
|
|
680
|
-
}
|
|
664
|
+
const d = A((v) => {
|
|
665
|
+
E.current?.joinThread(v);
|
|
666
|
+
}, []), S = A((v) => {
|
|
667
|
+
E.current?.leaveThread(v);
|
|
668
|
+
}, []), _ = A((v, P) => {
|
|
669
|
+
E.current?.sendMessage(v, P);
|
|
670
|
+
}, []), T = A((v) => {
|
|
671
|
+
E.current?.markRead(v);
|
|
672
|
+
}, []), I = A((v, P) => {
|
|
673
|
+
E.current?.listThreads(v, P);
|
|
674
|
+
}, []), B = A((v = 1) => {
|
|
675
|
+
m((P) => P + v);
|
|
676
|
+
}, []), K = A((v = 1) => {
|
|
677
|
+
m((P) => Math.max(0, P - v));
|
|
678
|
+
}, []), Y = A(() => {
|
|
679
|
+
E.current?.disconnect(), E.current = null;
|
|
680
|
+
}, []), q = A((v) => (h.current.add(v), () => {
|
|
681
|
+
h.current.delete(v);
|
|
682
|
+
}), []), X = {
|
|
681
683
|
decrementUnreadCount: K,
|
|
684
|
+
disconnect: Y,
|
|
682
685
|
incrementUnreadCount: B,
|
|
683
686
|
isConnected: l,
|
|
684
687
|
isReady: f,
|
|
@@ -686,11 +689,11 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
686
689
|
leaveThread: S,
|
|
687
690
|
listThreads: I,
|
|
688
691
|
markRead: T,
|
|
689
|
-
sendMessage:
|
|
690
|
-
subscribe:
|
|
692
|
+
sendMessage: _,
|
|
693
|
+
subscribe: q,
|
|
691
694
|
unreadCount: g
|
|
692
695
|
};
|
|
693
|
-
return /* @__PURE__ */ N.jsx(we.Provider, { value:
|
|
696
|
+
return /* @__PURE__ */ N.jsx(we.Provider, { value: X, children: e });
|
|
694
697
|
}, Ue = (e) => e && typeof e == "function", Me = (e) => e && typeof e == "function", dt = ({
|
|
695
698
|
children: e,
|
|
696
699
|
defaultQueriesOptions: t,
|
|
@@ -758,7 +761,7 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
758
761
|
const { libraries: t, localStorageKeys: r } = k(O), o = e?.axios || t?.axios, s = e?.localStorageKey || r?.user || "user";
|
|
759
762
|
if (!o)
|
|
760
763
|
throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
|
|
761
|
-
const a =
|
|
764
|
+
const a = A(
|
|
762
765
|
({ tokenType: l, accessToken: u }) => {
|
|
763
766
|
o.defaults.headers.common.Authorization = `${l} ${u}`;
|
|
764
767
|
},
|
|
@@ -789,7 +792,7 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
789
792
|
const t = k(we);
|
|
790
793
|
if (!t)
|
|
791
794
|
throw new Error("useChat must be used within ChatProvider");
|
|
792
|
-
const { subscribe: r, ...o } = t, s =
|
|
795
|
+
const { subscribe: r, ...o } = t, s = re(e);
|
|
793
796
|
return s.current = e, x(() => r((a) => {
|
|
794
797
|
const {
|
|
795
798
|
onReady: c,
|
|
@@ -885,15 +888,15 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
885
888
|
const m = () => Object.keys(localStorage).filter(
|
|
886
889
|
(h) => h.startsWith(f) && h.endsWith(e?.pathname || s)
|
|
887
890
|
), y = (h, d, S = !0) => {
|
|
888
|
-
const
|
|
891
|
+
const _ = me(h, e?.pathname || s, f);
|
|
889
892
|
if (!d || Array.isArray(d) && !d.length) {
|
|
890
893
|
i ? (a.delete(h), c(a)) : u((T) => {
|
|
891
894
|
const I = { ...T };
|
|
892
895
|
return delete I[h], I;
|
|
893
|
-
}), g && localStorage.removeItem(
|
|
896
|
+
}), g && localStorage.removeItem(_);
|
|
894
897
|
return;
|
|
895
898
|
}
|
|
896
|
-
g && S && d && localStorage.setItem(
|
|
899
|
+
g && S && d && localStorage.setItem(_, JSON.stringify({ ...a, [h]: d })), i && d ? (a.set(h, JSON.stringify(d)), c(a)) : !i && d && u((T) => ({ ...T, [h]: d }));
|
|
897
900
|
};
|
|
898
901
|
return {
|
|
899
902
|
getFilter: (h, d) => {
|
|
@@ -907,10 +910,10 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
907
910
|
return S;
|
|
908
911
|
}
|
|
909
912
|
if (g) {
|
|
910
|
-
const S = me(h, e?.pathname || s, f),
|
|
911
|
-
if (
|
|
913
|
+
const S = me(h, e?.pathname || s, f), _ = localStorage.getItem(S);
|
|
914
|
+
if (_)
|
|
912
915
|
try {
|
|
913
|
-
const T = JSON.parse(
|
|
916
|
+
const T = JSON.parse(_)[h];
|
|
914
917
|
return !i && T !== void 0 && u((I) => ({ ...I, [h]: T })), T;
|
|
915
918
|
} catch {
|
|
916
919
|
}
|
|
@@ -920,7 +923,7 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
920
923
|
getFilters: () => {
|
|
921
924
|
const h = g ? Be(m()) : {};
|
|
922
925
|
if (i) {
|
|
923
|
-
const d = Array.from(a.entries()).reduce((S, [
|
|
926
|
+
const d = Array.from(a.entries()).reduce((S, [_, T]) => (S[_] = ge(T), S), {});
|
|
924
927
|
return {
|
|
925
928
|
...h,
|
|
926
929
|
...d
|
|
@@ -931,9 +934,9 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
931
934
|
...l
|
|
932
935
|
};
|
|
933
936
|
},
|
|
934
|
-
handleFilter: (h, d) => (S,
|
|
935
|
-
if (
|
|
936
|
-
const T = d || "value", I = typeof
|
|
937
|
+
handleFilter: (h, d) => (S, _) => {
|
|
938
|
+
if (_ || Array.isArray(_) && _.length === 0) {
|
|
939
|
+
const T = d || "value", I = typeof _ == "object" && T in _ ? _[T] : _;
|
|
937
940
|
y(h, I);
|
|
938
941
|
return;
|
|
939
942
|
}
|
|
@@ -941,7 +944,7 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
941
944
|
},
|
|
942
945
|
setFilter: y
|
|
943
946
|
};
|
|
944
|
-
}, ye = () => document.getElementById(
|
|
947
|
+
}, ye = () => document.getElementById(se), yt = () => {
|
|
945
948
|
const [e, t] = F(() => !!window.HubSpotConversations);
|
|
946
949
|
x(() => {
|
|
947
950
|
if (window.HubSpotConversations) {
|
|
@@ -954,7 +957,7 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
954
957
|
ye()?.classList.remove(W);
|
|
955
958
|
});
|
|
956
959
|
}, [e]);
|
|
957
|
-
const r =
|
|
960
|
+
const r = A(() => {
|
|
958
961
|
const o = window.HubSpotConversations, s = ye();
|
|
959
962
|
o && s && (s.classList.contains(W) ? (o.widget.close(), s.classList.remove(W)) : (s.classList.add(W), o.widget.open()));
|
|
960
963
|
}, []);
|
|
@@ -967,12 +970,12 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
967
970
|
isLoading: s,
|
|
968
971
|
enabled: a = !0
|
|
969
972
|
}) => {
|
|
970
|
-
const c =
|
|
973
|
+
const c = A(
|
|
971
974
|
async (u) => {
|
|
972
975
|
r || !a || await t({ pageParam: u?.pageParam || u.visibleRowsCount });
|
|
973
976
|
},
|
|
974
977
|
[a, t, r]
|
|
975
|
-
), l =
|
|
978
|
+
), l = ae(() => {
|
|
976
979
|
if (e)
|
|
977
980
|
return e.pages.reduce((u, f) => [...u, ...f], []);
|
|
978
981
|
}, [e]);
|
|
@@ -983,7 +986,7 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
983
986
|
rows: l
|
|
984
987
|
};
|
|
985
988
|
}, wt = (e) => {
|
|
986
|
-
const { libraries: t } = k(O), r = e?.i18 || t?.i18, o = e?.i18?.translateFunction || t?.i18?.translateFunction, s = r?.i18next?.t || o || ((f) => f), { unknownErrorTranslationKey: a = "error.unknownError" } = e || {}, c = s(a), l =
|
|
989
|
+
const { libraries: t } = k(O), r = e?.i18 || t?.i18, o = e?.i18?.translateFunction || t?.i18?.translateFunction, s = r?.i18next?.t || o || ((f) => f), { unknownErrorTranslationKey: a = "error.unknownError" } = e || {}, c = s(a), l = A(
|
|
987
990
|
(f) => {
|
|
988
991
|
if (f && typeof f == "object" && "response" in f) {
|
|
989
992
|
const { response: i } = f || {};
|
|
@@ -1006,7 +1009,7 @@ const Ze = ({ IMaskMixin: e, ...t }) => {
|
|
|
1006
1009
|
},
|
|
1007
1010
|
[c]
|
|
1008
1011
|
);
|
|
1009
|
-
return { getErrorCode:
|
|
1012
|
+
return { getErrorCode: A((f) => {
|
|
1010
1013
|
const { response: i } = f || {};
|
|
1011
1014
|
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";
|
|
1012
1015
|
}, []), printError: l };
|
package/dist/main.umd.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(g,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],D):(g=typeof globalThis<"u"?globalThis:g||self,D(g["@tracktor/shared-module"]={},g.axios,g.React))})(this,(function(g,D,l){"use strict";const Ee=(e,t)=>{const n=D.CancelToken.source(),o=D({...e,...t,cancelToken:n.token}).then(({data:s})=>s);return o.cancel=()=>{n.cancel("Query was cancelled")},o},B=e=>Array.isArray(e)?e.map(B):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.replace(/_([a-z])/g,(o,s)=>s.toUpperCase()),B(n)])):e,K=e=>Array.isArray(e)?e.map(K):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.replace(/[A-Z]/g,o=>`_${o.toLowerCase()}`),K(n)])):e;class
|
|
1
|
+
(function(g,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],D):(g=typeof globalThis<"u"?globalThis:g||self,D(g["@tracktor/shared-module"]={},g.axios,g.React))})(this,(function(g,D,l){"use strict";const Ee=(e,t)=>{const n=D.CancelToken.source(),o=D({...e,...t,cancelToken:n.token}).then(({data:s})=>s);return o.cancel=()=>{n.cancel("Query was cancelled")},o},B=e=>Array.isArray(e)?e.map(B):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.replace(/_([a-z])/g,(o,s)=>s.toUpperCase()),B(n)])):e,K=e=>Array.isArray(e)?e.map(K):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.replace(/[A-Z]/g,o=>`_${o.toLowerCase()}`),K(n)])):e;class se{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 n=this.url.includes("?")?"&":"?",o=`${this.url}${n}token=${t}`;this.ws=new WebSocket(o),this.ws.onopen=()=>{this._connected=!0,this.reconnectAttempt=0,this.onConnectionChange?.(!0),this.rejoinThreads(),this.flushPendingMessages()},this.ws.onmessage=s=>{try{const a=JSON.parse(s.data),c=B(a);c.type==="ready"&&(this._ready=!0),this.onEvent?.(c)}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,n){if(n.length>1e3)throw new Error("Message body exceeds maximum length of 1000 characters");this.send({body:n,threadId:t,type:"send_message"})}markRead(t){this.send({threadId:t,type:"mark_read"})}listThreads(t,n){this.send({limit:t,offset:n,type:"list_threads"})}send(t){if(!this.ws||this.ws.readyState!==WebSocket.OPEN){this.pendingMessages.push(t);return}this.ws.send(JSON.stringify(K(t)))}flushPendingMessages(){const t=[...this.pendingMessages];this.pendingMessages=[];for(const n of t)this.send(n)}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 V={exports:{}},M={};var ae;function ve(){if(ae)return M;ae=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(o,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:e,type:o,key:c,ref:s!==void 0?s:null,props:a}}return M.Fragment=t,M.jsx=n,M.jsxs=n,M}var Y={};var ie;function we(){return ie||(ie=1,process.env.NODE_ENV!=="production"&&(function(){function e(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===te?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case _:return"Fragment";case f:return"Profiler";case m:return"StrictMode";case N:return"Suspense";case q:return"SuspenseList";case ee:return"Activity"}if(typeof r=="object")switch(typeof r.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),r.$$typeof){case k:return"Portal";case b:return r.displayName||"Context";case T:return(r._context.displayName||"Context")+".Consumer";case A:var h=r.render;return r=r.displayName,r||(r=h.displayName||h.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case $:return h=r.displayName||null,h!==null?h:e(r.type)||"Memo";case W:h=r._payload,r=r._init;try{return e(r(h))}catch{}}return null}function t(r){return""+r}function n(r){try{t(r);var h=!1}catch{h=!0}if(h){h=console;var C=h.error,S=typeof Symbol=="function"&&Symbol.toStringTag&&r[Symbol.toStringTag]||r.constructor.name||"Object";return C.call(h,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",S),t(r)}}function o(r){if(r===_)return"<>";if(typeof r=="object"&&r!==null&&r.$$typeof===W)return"<...>";try{var h=e(r);return h?"<"+h+">":"<...>"}catch{return"<...>"}}function s(){var r=w.A;return r===null?null:r.getOwner()}function a(){return Error("react-stack-top-frame")}function c(r){if(O.call(r,"key")){var h=Object.getOwnPropertyDescriptor(r,"key").get;if(h&&h.isReactWarning)return!1}return r.key!==void 0}function u(r,h){function C(){Q||(Q=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",h))}C.isReactWarning=!0,Object.defineProperty(r,"key",{get:C,configurable:!0})}function d(){var r=e(this.type);return L[r]||(L[r]=!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.")),r=this.props.ref,r!==void 0?r:null}function p(r,h,C,S,J,re){var R=C.ref;return r={$$typeof:P,type:r,key:h,props:C,_owner:S},(R!==void 0?R:null)!==null?Object.defineProperty(r,"ref",{enumerable:!1,get:d}):Object.defineProperty(r,"ref",{enumerable:!1,value:null}),r._store={},Object.defineProperty(r._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(r,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.defineProperty(r,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:re}),Object.freeze&&(Object.freeze(r.props),Object.freeze(r)),r}function i(r,h,C,S,J,re){var R=h.children;if(R!==void 0)if(S)if(ne(R)){for(S=0;S<R.length;S++)y(R[S]);Object.freeze&&Object.freeze(R)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else y(R);if(O.call(h,"key")){R=e(r);var F=Object.keys(h).filter(function(ct){return ct!=="key"});S=0<F.length?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}",ye[R+S]||(F=0<F.length?"{"+F.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} />`,S,R,F,R),ye[R+S]=!0)}if(R=null,
|
|
6
|
+
<%s key={someKey} {...props} />`,S,R,F,R),ye[R+S]=!0)}if(R=null,C!==void 0&&(n(C),R=""+C),c(h)&&(n(h.key),R=""+h.key),"key"in h){C={};for(var oe in h)oe!=="key"&&(C[oe]=h[oe])}else C=h;return R&&u(C,typeof r=="function"?r.displayName||r.name||"Unknown":r),p(r,R,C,s(),J,re)}function y(r){E(r)?r._store&&(r._store.validated=1):typeof r=="object"&&r!==null&&r.$$typeof===W&&(r._payload.status==="fulfilled"?E(r._payload.value)&&r._payload.value._store&&(r._payload.value._store.validated=1):r._store&&(r._store.validated=1))}function E(r){return typeof r=="object"&&r!==null&&r.$$typeof===P}var v=l,P=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),b=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),ee=Symbol.for("react.activity"),te=Symbol.for("react.client.reference"),w=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=Object.prototype.hasOwnProperty,ne=Array.isArray,G=console.createTask?console.createTask:function(){return null};v={react_stack_bottom_frame:function(r){return r()}};var Q,L={},x=v.react_stack_bottom_frame.bind(v,a)(),me=G(o(a)),ye={};Y.Fragment=_,Y.jsx=function(r,h,C){var S=1e4>w.recentlyCreatedOwnerStacks++;return i(r,h,C,!1,S?Error("react-stack-top-frame"):x,S?G(o(r)):me)},Y.jsxs=function(r,h,C){var S=1e4>w.recentlyCreatedOwnerStacks++;return i(r,h,C,!0,S?Error("react-stack-top-frame"):x,S?G(o(r)):me)}})()),Y}var ce;function Ce(){return ce||(ce=1,process.env.NODE_ENV==="production"?V.exports=ve():V.exports=we()),V.exports}var I=Ce();const _e=({IMaskMixin:e,...t})=>{const n=l.useMemo(()=>e(({TextField:o,...s})=>I.jsx(o,{...s})),[e]);return I.jsx(n,{...t})},j=l.createContext({}),be=({children:e,apiURL:t,libraries:n,localStorageKeys:o})=>{const s=l.useMemo(()=>({apiURL:t,libraries:n,localStorageKeys:o}),[t,n,o]);return I.jsx(j.Provider,{value:s,children:e})},Se=({data:e,...t})=>{const{libraries:n}=l.useContext(j),o=t?.reactRouter||n?.reactRouter,s=t?.gtm||n?.gtm;if(!o)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!s)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:a}=s,{useLocation:c,Outlet:u}=o,{pathname:d}=c(),{sendEvent:p}=a();return l.useEffect(()=>{p({event:"pageView",pathname:d,...e})},[e,d,p]),I.jsx(u,{})},U=(()=>{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}})(),Re="user",Te=({tokenTypeKey:e="tokenType",tokenKey:t="accessToken",postContentType:n="application/json",...o})=>{const{apiURL:s=o.apiURL,libraries:a,localStorageKeys:c}=l.useContext(j),u=o?.userLocalStorageKey||c?.user||Re,d=o?.axios||a?.axios;if(!d)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!d?.defaults||U)return null;if(typeof window<"u"&&window.localStorage){const p=localStorage.getItem(u),i=p?JSON.parse(p):null,y=i?.[e]?i[e]:null,E=i?.[t]?i[t]:null,v=p?`${y} ${E}`:null;v&&(d.defaults.headers.common.Authorization=v)}return d.defaults.baseURL=s,d.defaults.headers.post["Content-Type"]=n,null},Ae=({language:e,...t})=>{const{libraries:n}=l.useContext(j),o=t?.dayjs||n?.dayjs,s=t?.plugin||n?.dayjsPlugin;if(!o)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";s&&s.forEach(u=>{u&&o.extend(u)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),o.locale(c)})().then()},[o,s,e]),null},X="hubspot-messages-iframe-container",z="hs-show",ke=({hubId:e})=>(l.useEffect(()=>{if(!e)return;const t=document.createElement("style");t.textContent=`
|
|
7
7
|
div#${X} { display: none !important; }
|
|
8
8
|
div#${X}.${z} { display: initial !important; }
|
|
9
|
-
`,document.head.appendChild(t);const n=document.createElement("script");return n.id="hs-script-loader",n.src=`//js-eu1.hs-scripts.com/${e}.js`,n.async=!0,n.defer=!0,document.body.appendChild(n),()=>{t.remove(),n.remove()}},[e]),null),je=({debug:e,resources:t,...n})=>{const{libraries:o}=l.useContext(j),s=n?.i18||o?.i18,{i18next:a,initReactI18next:c,languageDetector:u}=s||{};if(U)return null;if(!s)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return a?.isInitialized||(a.use(u).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",d=>{document.documentElement.setAttribute("lang",d)})),null},Pe=({dsn:e,integrations:t,tracesSampleRate:n,replaysSessionSampleRate:o,replaysOnErrorSampleRate:s,tracePropagationTargets:a,ignoreErrors:c,debug:u,environment:d,release:p,...i})=>{const{libraries:y}=l.useContext(j),E=i?.sentry||y?.sentry,v=i?.reactRouter||y?.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:O,matchRoutes:k,useLocation:b,useNavigationType:m}=v;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&E.init({debug:u,dsn:e,environment:d||"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:O,matchRoutes:k,useEffect:l.useEffect,useLocation:b,useNavigationType:m}),...t||[]],release:p,replaysOnErrorSampleRate:s||1,replaysSessionSampleRate:o||.1,tracePropagationTargets:a,tracesSampleRate:n||1}),null},Oe=()=>(l.useEffect(()=>{if(U)return;const e=t=>{try{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),sessionStorage.getItem("vite:preloadError:reloaded")||(sessionStorage.setItem("vite:preloadError:reloaded","true"),window.location.reload())}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),ce=new WeakMap,Ie="user",Ne=({Fallback:e,isLogged:t,loginPath:n="/login",redirect401Path:o="/login",...s})=>{const{libraries:a,localStorageKeys:c}=l.useContext(j),u=s?.reactRouter||a?.reactRouter,d=s?.axios||a?.axios,p=s?.localStorageKey||c?.user||Ie;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,y]=l.useState(null),{useLocation:E,Navigate:v,Outlet:O}=u,k=E(),b=typeof t=="function"?t():!!t,m=typeof b=="boolean"?b:b?.isLogged;return l.useEffect(()=>{ce.has(d)||(ce.set(d,!0),d.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&&(d.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(p)),y(o)),Promise.reject(f))))},[d,p,o]),m&&!i?I.jsx(l.Suspense,{fallback:e,children:k.state?.from?.state&&k.state?.from?.pathname===n?I.jsx(v,{to:k.state.from.state.from.pathname+k.state.from.state.from.search,replace:!0}):I.jsx(O,{})}):I.jsx(v,{to:n+k.search,state:{from:k},replace:!0})},Le=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),xe=e=>{const t=e.split(/[/\\]/).pop()||"";return t.substring(0,t.lastIndexOf("."))},De=e=>{const o=e.split("/").filter(s=>s.length>0).map(s=>s.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(d=>d.charAt(0).toUpperCase()+d.slice(1)).join("")).join("");return o.charAt(0).toLowerCase()+o.slice(1)},Fe=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Me=(e,t,n,o)=>{const s=De(t),a=Le(n),c=`${s}${a}`;return e&&typeof e=="object"&&"operationId"in e&&o?.includes(String(e.operationId))?`${c}AsQuery`:c},Ye=(e,t)=>{const n={};return e?.forEach(o=>{n[o]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),t?.filter(o=>!n[o]).forEach(o=>{n[o]={query:{useQuery:!0}}}),Object.keys(n).length?n:void 0},Ue=e=>(Array.isArray(e)?e:[e]).reduce((n,o)=>{const{output:s,useInfiniteIds:a,useQueryIds:c,input:u="./openapi.json",customAxiosInstancePath:d,overrideApiName:p}=o||{},i=p||Fe(u),y=d||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...n,[i]:{input:u,output:{baseUrl:s?.baseUrl,client:"react-query",mode:"tags-split",override:{...(a?.length||c?.length)&&{operations:Ye(a,c)},header:E=>["Generated by orval 🍺",...E.title?[E.title]:[],...E.description?[E.description]:[]],mutator:{name:xe(y),path:y},operationName:(E,v,O)=>Me(E,v,O,c),query:{useQuery:!0}},schemas:s?.schemas||`src/api/${i}/model`,target:s?.target||`src/api/${i}/services/api.ts`,...s}}}},{}),ze="user",We={client:"/v2/threads/ws",supplier:"/v1/threads/ws"},Ge=(e,t)=>{const n=e.startsWith("https")?"wss":"ws",o=e.replace(/^https?:\/\//,"");return`${n}://${o}${t}`},Ve=e=>{try{const t=localStorage.getItem(e);return t?JSON.parse(t)?.accessToken??null:null}catch{return null}},Z=l.createContext(null),He=({children:e,token:t,url:n,wsPath:o,reconnect:s=!0,enabled:a=!0,context:c="client"})=>{const[u,d]=l.useState(!1),[p,i]=l.useState(!1),[y,E]=l.useState(0),{apiURL:v,localStorageKeys:O}=l.useContext(j),k=O?.user||ze,b=l.useRef(null),m=l.useRef(new Set);l.useEffect(()=>{if(!a)return;const _=o??We[c],P=n||(v?Ge(v,_):null);if(!P)return;const Q=()=>t??Ve(k),te=L=>{L.type==="ready"&&(i(!0),E(L.unreadCount??0));for(const x of m.current)x(L)},G=setTimeout(()=>{const L=new oe({getToken:Q,onConnectionChange:x=>{d(x),x||i(!1)},onEvent:te,reconnect:s,url:P});b.current=L,L.connect()},0);return()=>{clearTimeout(G),b.current?.disconnect(),b.current=null}},[a,n,o,c,t,s,v,k]);const f=l.useCallback(_=>{b.current?.joinThread(_)},[]),T=l.useCallback(_=>{b.current?.leaveThread(_)},[]),C=l.useCallback((_,P)=>{b.current?.sendMessage(_,P)},[]),A=l.useCallback(_=>{b.current?.markRead(_)},[]),N=l.useCallback((_,P)=>{b.current?.listThreads(_,P)},[]),q=l.useCallback((_=1)=>{E(P=>P+_)},[]),$=l.useCallback((_=1)=>{E(P=>Math.max(0,P-_))},[]),W=l.useCallback(_=>(m.current.add(_),()=>{m.current.delete(_)}),[]),ee={decrementUnreadCount:$,incrementUnreadCount:q,isConnected:u,isReady:p,joinThread:f,leaveThread:T,listThreads:N,markRead:A,sendMessage:C,subscribe:W,unreadCount:y};return I.jsx(Z.Provider,{value:ee,children:e})},Qe=e=>e&&typeof e=="function",Je=e=>e&&typeof e=="function",Be=({children:e,defaultQueriesOptions:t,defaultMutationsOptions:n,...o})=>{const{libraries:s}=l.useContext(j),a=o?.QueryClient||s?.reactQuery?.QueryClient,c=o?.QueryClientProvider||s?.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(!Qe(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Je(a))throw new Error("Provided QueryClient dependencies are not valid.");const u=new a({defaultOptions:{mutations:{...n},queries:{getNextPageParam:(d,p,i)=>d.length+(i||0),refetchOnWindowFocus:!1,retry:3,...t}}});return I.jsx(c,{client:u,children:e})},le=({library:e,date:t,format:n="ll"})=>e(t).format(n),ue=(e,t)=>{const{fractionDigits:n=0,metric:o="km",spacingBetween:s=!0}=t||{},a=Number(e),c=s?" ":"";return Number.isNaN(a)?`0${c}${o}`:`${a.toFixed(n)}${c}${o}`},de=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(n=>n.length>0?n.charAt(0).toUpperCase()+n.slice(1):n).join(" "),Ke=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Xe=({path:e,size:t,apiURL:n})=>{if(!e)return"";const o=Ke(e),s=`${n}${o}`,a=s.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof t=="number"&&a?`${s.replace("/files",`/thumbs/${t}`)}`:s},Ze=e=>{const{apiURL:t,libraries:n}=l.useContext(j),o=e?.dayjs||n?.dayjs;return{dateAdapter:(c,u)=>{if(!o)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return le({date:c,format:u,library:o})},distanceAdapter:ue,filePathAdapter:(c,u)=>{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:Xe({apiURL:t,path:c,size:u})},worksiteNameAdapter:de}},qe=e=>{const{libraries:t,localStorageKeys:n}=l.useContext(j),o=e?.axios||t?.axios,s=e?.localStorageKey||n?.user||"user";if(!o)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const a=l.useCallback(({tokenType:u,accessToken:d})=>{o.defaults.headers.common.Authorization=`${u} ${d}`},[o.defaults.headers.common]),c=()=>{o.defaults.headers.common.Authorization=null};return l.useEffect(()=>{if(U)return;const u=({newValue:d,key:p})=>{if(p===s&&d)try{const{accessToken:i,tokenType:y}=JSON.parse(d);a({accessToken:i,tokenType:y})}catch(i){console.error("Failed to parse newValue from localStorage:",i)}};return window.addEventListener("storage",u),()=>{window.removeEventListener("storage",u)}},[s,a]),{clearAuthenticationToken:c,setAuthenticationToken:a}},$e=e=>{const t=l.useContext(Z);if(!t)throw new Error("useChat must be used within ChatProvider");const{subscribe:n,...o}=t,s=l.useRef(e);return s.current=e,l.useEffect(()=>n(a=>{const{onReady:c,onNewMessage:u,onNewMessageNotification:d,onPresence:p,onError:i,onJoinedThread:y,onLeftThread:E,onMarkedRead:v,onThreadArchived:O,onThreadsList:k}=s.current??{};switch(a.type){case"ready":c?.(a);break;case"new_message":u?.(a);break;case"new_message_notification":d?.(a);break;case"presence":p?.(a);break;case"error":i?.(a);break;case"joined_thread":y?.(a);break;case"left_thread":E?.(a);break;case"marked_read":v?.(a);break;case"thread_archived":O?.(a);break;case"threads_list":k?.(a);break}}),[n]),o},H=(e,t)=>t==="short"?e.split("-")[0]:e,et=(e,t="full")=>{const[n,o]=l.useState(()=>{const s=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,H(s,t)});return l.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&o(H(e.language,t));const s=a=>{o(H(a,t))};return e?.on?.("languageChanged",s),()=>{e?.off?.("languageChanged",s)}},[e,t]),n},tt="tracktor.filter",nt={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},fe=e=>{try{return JSON.parse(e)}catch{return e}},pe=(e,t,n)=>`${n}_${e}=>${t}`,rt=e=>e.reduce((t,n)=>{const o=localStorage.getItem(n);if(o)try{const s=JSON.parse(o),a=Object.keys(s)?.[0];a&&(t[a]=Object.values(s)?.[0])}catch{}return t},{}),ot=e=>{const{libraries:t,localStorageKeys:n}=l.useContext(j),o=e?.reactRouter||t?.reactRouter,{pathname:s}=o?.useLocation?.()??{pathname:"/"},[a,c]=o?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,d]=l.useState({}),p=n?.filter||tt,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,y=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(U)return nt;if(!o)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(m=>m.startsWith(p)&&m.endsWith(e?.pathname||s)),v=(m,f,T=!0)=>{const C=pe(m,e?.pathname||s,p);if(!f||Array.isArray(f)&&!f.length){i?(a.delete(m),c(a)):d(A=>{const N={...A};return delete N[m],N}),y&&localStorage.removeItem(C);return}y&&T&&f&&localStorage.setItem(C,JSON.stringify({...a,[m]:f})),i&&f?(a.set(m,JSON.stringify(f)),c(a)):!i&&f&&d(A=>({...A,[m]:f}))};return{getFilter:(m,f)=>{if(i){const T=a.get(m);if(T)return fe(T)}else{const T=u[m];if(T!==void 0)return T}if(y){const T=pe(m,e?.pathname||s,p),C=localStorage.getItem(T);if(C)try{const A=JSON.parse(C)[m];return!i&&A!==void 0&&d(N=>({...N,[m]:A})),A}catch{}}return f},getFilters:()=>{const m=y?rt(E()):{};if(i){const f=Array.from(a.entries()).reduce((T,[C,A])=>(T[C]=fe(A),T),{});return{...m,...f}}return{...m,...u}},handleFilter:(m,f)=>(T,C)=>{if(C||Array.isArray(C)&&C.length===0){const A=f||"value",N=typeof C=="object"&&A in C?C[A]:C;v(m,N);return}v(m,void 0)},setFilter:v}},he=()=>document.getElementById(X),st=()=>{const[e,t]=l.useState(()=>!!window.HubSpotConversations);l.useEffect(()=>{if(window.HubSpotConversations){t(!0);return}window.hsConversationsOnReady=[()=>t(!0)]},[]),l.useEffect(()=>{e&&window.HubSpotConversations?.on("widgetClosed",()=>{he()?.classList.remove(z)})},[e]);const n=l.useCallback(()=>{const o=window.HubSpotConversations,s=he();o&&s&&(s.classList.contains(z)?(o.widget.close(),s.classList.remove(z)):(s.classList.add(z),o.widget.open()))},[]);return{isAvailable:e,toggle:n}},at=({data:e,fetchNextPage:t,isFetchingNextPage:n,isInitialLoading:o,isLoading:s,enabled:a=!0})=>{const c=l.useCallback(async d=>{n||!a||await t({pageParam:d?.pageParam||d.visibleRowsCount})},[a,t,n]),u=l.useMemo(()=>{if(e)return e.pages.reduce((d,p)=>[...d,...p],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:n||s,loadingVariant:o?"skeleton":"linear-progress",rows:u}},it=e=>{const{libraries:t}=l.useContext(j),n=e?.i18||t?.i18,o=e?.i18?.translateFunction||t?.i18?.translateFunction,s=n?.i18next?.t||o||(p=>p),{unknownErrorTranslationKey:a="error.unknownError"}=e||{},c=s(a),u=l.useCallback(p=>{if(p&&typeof p=="object"&&"response"in p){const{response:i}=p||{};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:y}=i.data;if(Array.isArray(y)&&y.length>0&&typeof y[0]=="object"&&y[0]!==null&&"msg"in y[0]){const{msg:E}=y[0];if(typeof E=="string")return String(E)}}}return p instanceof Error?p.message:c},[c]);return{getErrorCode:l.useCallback(p=>{const{response:i}=p||{};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:u}};g.ChatClient=oe,g.ChatContext=Z,g.ChatProvider=He,g.GTMSendPageView=Se,g.InitializeAxiosConfig=Te,g.InitializeDaysJSConfig=Ae,g.InitializeHubSpot=ke,g.InitializeI18nConfig=je,g.InitializeSentryConfig=Pe,g.InjectDependenciesContext=j,g.InjectDependenciesProvider=be,g.MaskTextField=_e,g.PreloadErrorHandler=Oe,g.QueryClientProviderWithConfig=Be,g.RequireAuth=Ne,g.axiosCustomInstance=Ee,g.dateAdapter=le,g.distanceAdapter=ue,g.getOrvalConfig=Ue,g.useAdapter=Ze,g.useAuth=qe,g.useChat=$e,g.useCurrentLanguage=et,g.useFilters=ot,g.useHubSpot=st,g.useInfiniteDataGrid=at,g.useResponseError=it,g.worksiteNameAdapter=de,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
9
|
+
`,document.head.appendChild(t);const n=document.createElement("script");return n.id="hs-script-loader",n.src=`//js-eu1.hs-scripts.com/${e}.js`,n.async=!0,n.defer=!0,document.body.appendChild(n),()=>{t.remove(),n.remove()}},[e]),null),je=({debug:e,resources:t,...n})=>{const{libraries:o}=l.useContext(j),s=n?.i18||o?.i18,{i18next:a,initReactI18next:c,languageDetector:u}=s||{};if(U)return null;if(!s)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return a?.isInitialized||(a.use(u).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",d=>{document.documentElement.setAttribute("lang",d)})),null},Pe=({dsn:e,integrations:t,tracesSampleRate:n,replaysSessionSampleRate:o,replaysOnErrorSampleRate:s,tracePropagationTargets:a,ignoreErrors:c,debug:u,environment:d,release:p,...i})=>{const{libraries:y}=l.useContext(j),E=i?.sentry||y?.sentry,v=i?.reactRouter||y?.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:P,matchRoutes:k,useLocation:_,useNavigationType:m}=v;return(u||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&E.init({debug:u,dsn:e,environment:d||"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:P,matchRoutes:k,useEffect:l.useEffect,useLocation:_,useNavigationType:m}),...t||[]],release:p,replaysOnErrorSampleRate:s||1,replaysSessionSampleRate:o||.1,tracePropagationTargets:a,tracesSampleRate:n||1}),null},Oe=()=>(l.useEffect(()=>{if(U)return;const e=t=>{try{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),sessionStorage.getItem("vite:preloadError:reloaded")||(sessionStorage.setItem("vite:preloadError:reloaded","true"),window.location.reload())}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),le=new WeakMap,Ie="user",Ne=({Fallback:e,isLogged:t,loginPath:n="/login",redirect401Path:o="/login",...s})=>{const{libraries:a,localStorageKeys:c}=l.useContext(j),u=s?.reactRouter||a?.reactRouter,d=s?.axios||a?.axios,p=s?.localStorageKey||c?.user||Ie;if(!u)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,y]=l.useState(null),{useLocation:E,Navigate:v,Outlet:P}=u,k=E(),_=typeof t=="function"?t():!!t,m=typeof _=="boolean"?_:_?.isLogged;return l.useEffect(()=>{le.has(d)||(le.set(d,!0),d.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&&(d.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(p)),y(o)),Promise.reject(f))))},[d,p,o]),m&&!i?I.jsx(l.Suspense,{fallback:e,children:k.state?.from?.state&&k.state?.from?.pathname===n?I.jsx(v,{to:k.state.from.state.from.pathname+k.state.from.state.from.search,replace:!0}):I.jsx(P,{})}):I.jsx(v,{to:n+k.search,state:{from:k},replace:!0})},Le=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),xe=e=>{const t=e.split(/[/\\]/).pop()||"";return t.substring(0,t.lastIndexOf("."))},De=e=>{const o=e.split("/").filter(s=>s.length>0).map(s=>s.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(d=>d.charAt(0).toUpperCase()+d.slice(1)).join("")).join("");return o.charAt(0).toLowerCase()+o.slice(1)},Fe=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),Me=(e,t,n,o)=>{const s=De(t),a=Le(n),c=`${s}${a}`;return e&&typeof e=="object"&&"operationId"in e&&o?.includes(String(e.operationId))?`${c}AsQuery`:c},Ye=(e,t)=>{const n={};return e?.forEach(o=>{n[o]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),t?.filter(o=>!n[o]).forEach(o=>{n[o]={query:{useQuery:!0}}}),Object.keys(n).length?n:void 0},Ue=e=>(Array.isArray(e)?e:[e]).reduce((n,o)=>{const{output:s,useInfiniteIds:a,useQueryIds:c,input:u="./openapi.json",customAxiosInstancePath:d,overrideApiName:p}=o||{},i=p||Fe(u),y=d||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...n,[i]:{input:u,output:{baseUrl:s?.baseUrl,client:"react-query",mode:"tags-split",override:{...(a?.length||c?.length)&&{operations:Ye(a,c)},header:E=>["Generated by orval 🍺",...E.title?[E.title]:[],...E.description?[E.description]:[]],mutator:{name:xe(y),path:y},operationName:(E,v,P)=>Me(E,v,P,c),query:{useQuery:!0}},schemas:s?.schemas||`src/api/${i}/model`,target:s?.target||`src/api/${i}/services/api.ts`,...s}}}},{}),ze="user",We={client:"/v2/threads/ws",supplier:"/v1/threads/ws"},Ge=(e,t)=>{const n=e.startsWith("https")?"wss":"ws",o=e.replace(/^https?:\/\//,"");return`${n}://${o}${t}`},Ve=e=>{try{const t=localStorage.getItem(e);return t?JSON.parse(t)?.accessToken??null:null}catch{return null}},Z=l.createContext(null),He=({children:e,token:t,url:n,wsPath:o,reconnect:s=!0,enabled:a=!0,context:c="client"})=>{const[u,d]=l.useState(!1),[p,i]=l.useState(!1),[y,E]=l.useState(0),{apiURL:v,localStorageKeys:P}=l.useContext(j),k=P?.user||ze,_=l.useRef(null),m=l.useRef(new Set);l.useEffect(()=>{if(!a)return;const w=o??We[c],O=n||(v?Ge(v,w):null);if(!O)return;const ne=()=>t??Ve(k),G=L=>{L.type==="ready"&&(i(!0),E(L.unreadCount??0));for(const x of m.current)x(L)},Q=setTimeout(()=>{const L=new se({getToken:ne,onConnectionChange:x=>{d(x),x||i(!1)},onEvent:G,reconnect:s,url:O});_.current=L,L.connect()},0);return()=>{clearTimeout(Q),_.current?.disconnect(),_.current=null}},[a,n,o,c,t,s,v,k]);const f=l.useCallback(w=>{_.current?.joinThread(w)},[]),T=l.useCallback(w=>{_.current?.leaveThread(w)},[]),b=l.useCallback((w,O)=>{_.current?.sendMessage(w,O)},[]),A=l.useCallback(w=>{_.current?.markRead(w)},[]),N=l.useCallback((w,O)=>{_.current?.listThreads(w,O)},[]),q=l.useCallback((w=1)=>{E(O=>O+w)},[]),$=l.useCallback((w=1)=>{E(O=>Math.max(0,O-w))},[]),W=l.useCallback(()=>{_.current?.disconnect(),_.current=null},[]),ee=l.useCallback(w=>(m.current.add(w),()=>{m.current.delete(w)}),[]),te={decrementUnreadCount:$,disconnect:W,incrementUnreadCount:q,isConnected:u,isReady:p,joinThread:f,leaveThread:T,listThreads:N,markRead:A,sendMessage:b,subscribe:ee,unreadCount:y};return I.jsx(Z.Provider,{value:te,children:e})},Qe=e=>e&&typeof e=="function",Je=e=>e&&typeof e=="function",Be=({children:e,defaultQueriesOptions:t,defaultMutationsOptions:n,...o})=>{const{libraries:s}=l.useContext(j),a=o?.QueryClient||s?.reactQuery?.QueryClient,c=o?.QueryClientProvider||s?.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(!Qe(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Je(a))throw new Error("Provided QueryClient dependencies are not valid.");const u=new a({defaultOptions:{mutations:{...n},queries:{getNextPageParam:(d,p,i)=>d.length+(i||0),refetchOnWindowFocus:!1,retry:3,...t}}});return I.jsx(c,{client:u,children:e})},ue=({library:e,date:t,format:n="ll"})=>e(t).format(n),de=(e,t)=>{const{fractionDigits:n=0,metric:o="km",spacingBetween:s=!0}=t||{},a=Number(e),c=s?" ":"";return Number.isNaN(a)?`0${c}${o}`:`${a.toFixed(n)}${c}${o}`},fe=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(n=>n.length>0?n.charAt(0).toUpperCase()+n.slice(1):n).join(" "),Ke=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Xe=({path:e,size:t,apiURL:n})=>{if(!e)return"";const o=Ke(e),s=`${n}${o}`,a=s.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof t=="number"&&a?`${s.replace("/files",`/thumbs/${t}`)}`:s},Ze=e=>{const{apiURL:t,libraries:n}=l.useContext(j),o=e?.dayjs||n?.dayjs;return{dateAdapter:(c,u)=>{if(!o)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return ue({date:c,format:u,library:o})},distanceAdapter:de,filePathAdapter:(c,u)=>{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:Xe({apiURL:t,path:c,size:u})},worksiteNameAdapter:fe}},qe=e=>{const{libraries:t,localStorageKeys:n}=l.useContext(j),o=e?.axios||t?.axios,s=e?.localStorageKey||n?.user||"user";if(!o)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const a=l.useCallback(({tokenType:u,accessToken:d})=>{o.defaults.headers.common.Authorization=`${u} ${d}`},[o.defaults.headers.common]),c=()=>{o.defaults.headers.common.Authorization=null};return l.useEffect(()=>{if(U)return;const u=({newValue:d,key:p})=>{if(p===s&&d)try{const{accessToken:i,tokenType:y}=JSON.parse(d);a({accessToken:i,tokenType:y})}catch(i){console.error("Failed to parse newValue from localStorage:",i)}};return window.addEventListener("storage",u),()=>{window.removeEventListener("storage",u)}},[s,a]),{clearAuthenticationToken:c,setAuthenticationToken:a}},$e=e=>{const t=l.useContext(Z);if(!t)throw new Error("useChat must be used within ChatProvider");const{subscribe:n,...o}=t,s=l.useRef(e);return s.current=e,l.useEffect(()=>n(a=>{const{onReady:c,onNewMessage:u,onNewMessageNotification:d,onPresence:p,onError:i,onJoinedThread:y,onLeftThread:E,onMarkedRead:v,onThreadArchived:P,onThreadsList:k}=s.current??{};switch(a.type){case"ready":c?.(a);break;case"new_message":u?.(a);break;case"new_message_notification":d?.(a);break;case"presence":p?.(a);break;case"error":i?.(a);break;case"joined_thread":y?.(a);break;case"left_thread":E?.(a);break;case"marked_read":v?.(a);break;case"thread_archived":P?.(a);break;case"threads_list":k?.(a);break}}),[n]),o},H=(e,t)=>t==="short"?e.split("-")[0]:e,et=(e,t="full")=>{const[n,o]=l.useState(()=>{const s=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,H(s,t)});return l.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&o(H(e.language,t));const s=a=>{o(H(a,t))};return e?.on?.("languageChanged",s),()=>{e?.off?.("languageChanged",s)}},[e,t]),n},tt="tracktor.filter",nt={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},pe=e=>{try{return JSON.parse(e)}catch{return e}},he=(e,t,n)=>`${n}_${e}=>${t}`,rt=e=>e.reduce((t,n)=>{const o=localStorage.getItem(n);if(o)try{const s=JSON.parse(o),a=Object.keys(s)?.[0];a&&(t[a]=Object.values(s)?.[0])}catch{}return t},{}),ot=e=>{const{libraries:t,localStorageKeys:n}=l.useContext(j),o=e?.reactRouter||t?.reactRouter,{pathname:s}=o?.useLocation?.()??{pathname:"/"},[a,c]=o?.useSearchParams?.()??[new URLSearchParams,()=>{}],[u,d]=l.useState({}),p=n?.filter||tt,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,y=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(U)return nt;if(!o)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(m=>m.startsWith(p)&&m.endsWith(e?.pathname||s)),v=(m,f,T=!0)=>{const b=he(m,e?.pathname||s,p);if(!f||Array.isArray(f)&&!f.length){i?(a.delete(m),c(a)):d(A=>{const N={...A};return delete N[m],N}),y&&localStorage.removeItem(b);return}y&&T&&f&&localStorage.setItem(b,JSON.stringify({...a,[m]:f})),i&&f?(a.set(m,JSON.stringify(f)),c(a)):!i&&f&&d(A=>({...A,[m]:f}))};return{getFilter:(m,f)=>{if(i){const T=a.get(m);if(T)return pe(T)}else{const T=u[m];if(T!==void 0)return T}if(y){const T=he(m,e?.pathname||s,p),b=localStorage.getItem(T);if(b)try{const A=JSON.parse(b)[m];return!i&&A!==void 0&&d(N=>({...N,[m]:A})),A}catch{}}return f},getFilters:()=>{const m=y?rt(E()):{};if(i){const f=Array.from(a.entries()).reduce((T,[b,A])=>(T[b]=pe(A),T),{});return{...m,...f}}return{...m,...u}},handleFilter:(m,f)=>(T,b)=>{if(b||Array.isArray(b)&&b.length===0){const A=f||"value",N=typeof b=="object"&&A in b?b[A]:b;v(m,N);return}v(m,void 0)},setFilter:v}},ge=()=>document.getElementById(X),st=()=>{const[e,t]=l.useState(()=>!!window.HubSpotConversations);l.useEffect(()=>{if(window.HubSpotConversations){t(!0);return}window.hsConversationsOnReady=[()=>t(!0)]},[]),l.useEffect(()=>{e&&window.HubSpotConversations?.on("widgetClosed",()=>{ge()?.classList.remove(z)})},[e]);const n=l.useCallback(()=>{const o=window.HubSpotConversations,s=ge();o&&s&&(s.classList.contains(z)?(o.widget.close(),s.classList.remove(z)):(s.classList.add(z),o.widget.open()))},[]);return{isAvailable:e,toggle:n}},at=({data:e,fetchNextPage:t,isFetchingNextPage:n,isInitialLoading:o,isLoading:s,enabled:a=!0})=>{const c=l.useCallback(async d=>{n||!a||await t({pageParam:d?.pageParam||d.visibleRowsCount})},[a,t,n]),u=l.useMemo(()=>{if(e)return e.pages.reduce((d,p)=>[...d,...p],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:n||s,loadingVariant:o?"skeleton":"linear-progress",rows:u}},it=e=>{const{libraries:t}=l.useContext(j),n=e?.i18||t?.i18,o=e?.i18?.translateFunction||t?.i18?.translateFunction,s=n?.i18next?.t||o||(p=>p),{unknownErrorTranslationKey:a="error.unknownError"}=e||{},c=s(a),u=l.useCallback(p=>{if(p&&typeof p=="object"&&"response"in p){const{response:i}=p||{};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:y}=i.data;if(Array.isArray(y)&&y.length>0&&typeof y[0]=="object"&&y[0]!==null&&"msg"in y[0]){const{msg:E}=y[0];if(typeof E=="string")return String(E)}}}return p instanceof Error?p.message:c},[c]);return{getErrorCode:l.useCallback(p=>{const{response:i}=p||{};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:u}};g.ChatClient=se,g.ChatContext=Z,g.ChatProvider=He,g.GTMSendPageView=Se,g.InitializeAxiosConfig=Te,g.InitializeDaysJSConfig=Ae,g.InitializeHubSpot=ke,g.InitializeI18nConfig=je,g.InitializeSentryConfig=Pe,g.InjectDependenciesContext=j,g.InjectDependenciesProvider=be,g.MaskTextField=_e,g.PreloadErrorHandler=Oe,g.QueryClientProviderWithConfig=Be,g.RequireAuth=Ne,g.axiosCustomInstance=Ee,g.dateAdapter=ue,g.distanceAdapter=de,g.getOrvalConfig=Ue,g.useAdapter=Ze,g.useAuth=qe,g.useChat=$e,g.useCurrentLanguage=et,g.useFilters=ot,g.useHubSpot=st,g.useInfiniteDataGrid=at,g.useResponseError=it,g.worksiteNameAdapter=fe,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|