@getsoren/shared-module 2.44.0 → 2.45.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.
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import { InjectDependenciesContextProps } from '../../context/InjectDependenciesProvider';
|
|
3
|
+
export interface AutoReloadOnNewVersionProps extends PropsWithChildren {
|
|
4
|
+
/**
|
|
5
|
+
* Version of the currently running bundle, usually imported from the app's package.json.
|
|
6
|
+
* Compared against the meta[name="version"] tag of the remote index.html.
|
|
7
|
+
*/
|
|
8
|
+
version: string;
|
|
9
|
+
/**
|
|
10
|
+
* React Router library
|
|
11
|
+
*/
|
|
12
|
+
reactRouter?: NonNullable<InjectDependenciesContextProps["libraries"]>["reactRouter"];
|
|
13
|
+
/**
|
|
14
|
+
* Interval in ms between version checks (also checked when the tab regains visibility)
|
|
15
|
+
*/
|
|
16
|
+
checkInterval?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Silently reloads the app when a new version has been deployed.
|
|
20
|
+
*
|
|
21
|
+
* Fetches the remote index.html (bypassing caches) when the tab regains visibility
|
|
22
|
+
* and on a fixed interval, then compares its meta[name="version"] with the running
|
|
23
|
+
* bundle version. When they differ, the page is reloaded on the NEXT route change:
|
|
24
|
+
* the user is navigating anyway, so no in-progress work (forms, dialogs) can be lost,
|
|
25
|
+
* and the reload is indistinguishable from a regular page load.
|
|
26
|
+
*
|
|
27
|
+
* Use it as a layout route element (like GTMSendPageView) or wrap an existing one:
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <Route element={<AutoReloadOnNewVersion version={version}><GTMSendPageView /></AutoReloadOnNewVersion>}>
|
|
30
|
+
* ```
|
|
31
|
+
* @constructor
|
|
32
|
+
*/
|
|
33
|
+
declare const AutoReloadOnNewVersion: ({ version, checkInterval, children, ...props }: AutoReloadOnNewVersionProps) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element;
|
|
34
|
+
export default AutoReloadOnNewVersion;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/main.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export { default as ChatClient } from './chat/ChatClient';
|
|
|
2
2
|
export * from './chat/types';
|
|
3
3
|
export * from './components/Inputs/MaskTextField';
|
|
4
4
|
export { default as MaskTextField } from './components/Inputs/MaskTextField';
|
|
5
|
+
export * from './components/Utils/AutoReloadOnNewVersion';
|
|
6
|
+
export { default as AutoReloadOnNewVersion } from './components/Utils/AutoReloadOnNewVersion';
|
|
5
7
|
export * from './components/Utils/GTMSendPageView';
|
|
6
8
|
export { default as GTMSendPageView } from './components/Utils/GTMSendPageView';
|
|
7
9
|
export * from './components/Utils/InitializeAmplitude';
|
package/dist/main.js
CHANGED
|
@@ -122,7 +122,45 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
122
122
|
value: i,
|
|
123
123
|
children: e
|
|
124
124
|
});
|
|
125
|
-
}, b =
|
|
125
|
+
}, b = 900 * 1e3, x = 60 * 1e3, S = 600 * 1e3, C = "auto-reload-on-new-version-timestamp", w = /<meta[^>]*name="version"[^>]*content="([^"]*)"/, T = (e) => {
|
|
126
|
+
try {
|
|
127
|
+
return sessionStorage.getItem(e);
|
|
128
|
+
} catch {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
}, E = (e, t) => {
|
|
132
|
+
try {
|
|
133
|
+
sessionStorage.setItem(e, t);
|
|
134
|
+
} catch {}
|
|
135
|
+
}, D = ({ version: e, checkInterval: t = b, children: n, ...r }) => {
|
|
136
|
+
let { libraries: i } = a(v), s = r?.reactRouter || i?.reactRouter, l = c(!1), d = c(0);
|
|
137
|
+
if (!s) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of AutoReloadOnNewVersion.");
|
|
138
|
+
let { useLocation: f, Outlet: p } = s, { pathname: m } = f(), h = c(m);
|
|
139
|
+
return o(() => {
|
|
140
|
+
if (!e || typeof window > "u") return;
|
|
141
|
+
let n = async () => {
|
|
142
|
+
if (!(l.current || Date.now() - d.current < x)) {
|
|
143
|
+
d.current = Date.now();
|
|
144
|
+
try {
|
|
145
|
+
let t = await fetch("/index.html", { cache: "no-store" });
|
|
146
|
+
if (!t.ok) return;
|
|
147
|
+
let n = (await t.text()).match(w)?.[1];
|
|
148
|
+
n && n !== "%VERSION%" && n !== e && (l.current = !0);
|
|
149
|
+
} catch {}
|
|
150
|
+
}
|
|
151
|
+
}, r = () => {
|
|
152
|
+
document.visibilityState === "visible" && n();
|
|
153
|
+
}, i = setInterval(n, t);
|
|
154
|
+
return document.addEventListener("visibilitychange", r), () => {
|
|
155
|
+
clearInterval(i), document.removeEventListener("visibilitychange", r);
|
|
156
|
+
};
|
|
157
|
+
}, [e, t]), o(() => {
|
|
158
|
+
if (m === h.current || (h.current = m, !l.current)) return;
|
|
159
|
+
l.current = !1;
|
|
160
|
+
let e = Number(T(C) || "0");
|
|
161
|
+
Date.now() - e < S || (E(C, String(Date.now())), window.location.reload());
|
|
162
|
+
}, [m]), n ?? /* @__PURE__ */ u(p, {});
|
|
163
|
+
}, O = ({ data: e, ...t }) => {
|
|
126
164
|
let { libraries: n } = a(v), r = t?.reactRouter || n?.reactRouter, i = t?.gtm || n?.gtm;
|
|
127
165
|
if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
|
|
128
166
|
if (!i) throw Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
|
|
@@ -138,7 +176,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
138
176
|
d,
|
|
139
177
|
f
|
|
140
178
|
]), /* @__PURE__ */ u(l, {});
|
|
141
|
-
},
|
|
179
|
+
}, k = ({ apiKey: e, platform: t = "desktop", sessionReplaySampleRate: n = .25, ...r }) => {
|
|
142
180
|
let { libraries: i } = a(v), s = r.amplitude || i?.amplitude;
|
|
143
181
|
return o(() => {
|
|
144
182
|
let r = s?.analytics, i = s?.sessionReplayPlugin;
|
|
@@ -163,22 +201,22 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
163
201
|
t,
|
|
164
202
|
n
|
|
165
203
|
]), null;
|
|
166
|
-
},
|
|
204
|
+
}, A = (() => {
|
|
167
205
|
try {
|
|
168
206
|
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;
|
|
169
207
|
} catch {
|
|
170
208
|
return !1;
|
|
171
209
|
}
|
|
172
|
-
})(),
|
|
173
|
-
let { apiURL: i = r.apiURL, libraries: o, localStorageKeys: s } = a(v), c = r?.userLocalStorageKey || s?.user ||
|
|
210
|
+
})(), j = "user", M = ({ tokenTypeKey: e = "tokenType", tokenKey: t = "accessToken", postContentType: n = "application/json", ...r }) => {
|
|
211
|
+
let { apiURL: i = r.apiURL, libraries: o, localStorageKeys: s } = a(v), c = r?.userLocalStorageKey || s?.user || j, l = r?.axios || o?.axios;
|
|
174
212
|
if (!l) throw Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
175
|
-
if (!l?.defaults ||
|
|
213
|
+
if (!l?.defaults || A) return null;
|
|
176
214
|
if (typeof window < "u" && window.localStorage) {
|
|
177
215
|
let n = localStorage.getItem(c), r = n ? JSON.parse(n) : null, i = r?.[e] ? r[e] : null, a = r?.[t] ? r[t] : null, o = n ? `${i} ${a}` : null;
|
|
178
216
|
o && (l.defaults.headers.common.Authorization = o);
|
|
179
217
|
}
|
|
180
218
|
return l.defaults.baseURL = i, l.defaults.headers.post["Content-Type"] = n, null;
|
|
181
|
-
},
|
|
219
|
+
}, N = ({ language: e, ...t }) => {
|
|
182
220
|
let { libraries: n } = a(v), r = t?.dayjs || n?.dayjs, i = t?.plugin || n?.dayjsPlugin;
|
|
183
221
|
if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");
|
|
184
222
|
return o(() => {
|
|
@@ -194,7 +232,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
194
232
|
e,
|
|
195
233
|
t.localizedFormat
|
|
196
234
|
]), null;
|
|
197
|
-
},
|
|
235
|
+
}, P = "hubspot-messages-iframe-container", F = "hs-show", I = "data-hs-hidden", L = ({ hubId: e }) => (o(() => {
|
|
198
236
|
if (!e) return;
|
|
199
237
|
let t = document.createElement("script");
|
|
200
238
|
return t.id = "hs-script-loader", t.src = `//js-eu1.hs-scripts.com/${e}.js`, t.async = !0, t.defer = !0, document.body.appendChild(t), () => {
|
|
@@ -203,14 +241,14 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
203
241
|
}, [e]), o(() => {
|
|
204
242
|
let e = document.createElement("style");
|
|
205
243
|
return e.textContent = `
|
|
206
|
-
html[${
|
|
207
|
-
html[${
|
|
208
|
-
`, document.head.appendChild(e), document.documentElement.setAttribute(
|
|
209
|
-
e.remove(), document.documentElement.removeAttribute(
|
|
244
|
+
html[${I}] div#${P} { display: none !important; }
|
|
245
|
+
html[${I}] div#${P}.${F} { display: initial !important; }
|
|
246
|
+
`, document.head.appendChild(e), document.documentElement.setAttribute(I, ""), () => {
|
|
247
|
+
e.remove(), document.documentElement.removeAttribute(I);
|
|
210
248
|
};
|
|
211
|
-
}, []), null),
|
|
249
|
+
}, []), null), R = ({ debug: e, resources: t, ...n }) => {
|
|
212
250
|
let { libraries: r } = a(v), i = n?.i18 || r?.i18, { i18next: o, initReactI18next: s, languageDetector: c } = i || {};
|
|
213
|
-
if (
|
|
251
|
+
if (A) return null;
|
|
214
252
|
if (!(i && o && c && s)) throw Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
215
253
|
return o.isInitialized ? null : (o.use(c).use(s).init({
|
|
216
254
|
debug: e,
|
|
@@ -228,7 +266,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
228
266
|
}), o.on("languageChanged", (e) => {
|
|
229
267
|
document.documentElement.setAttribute("lang", e);
|
|
230
268
|
}), null);
|
|
231
|
-
},
|
|
269
|
+
}, ee = ({ dsn: e, integrations: t, tracesSampleRate: n, replaysSessionSampleRate: r, replaysOnErrorSampleRate: i, tracePropagationTargets: s, ignoreErrors: c, debug: l, environment: u, release: d, ...f }) => {
|
|
232
270
|
let { libraries: p } = a(v), m = f?.sentry || p?.sentry, h = f?.reactRouter || p?.reactRouter;
|
|
233
271
|
if (!m) throw Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
234
272
|
if (!h) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
@@ -260,12 +298,12 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
260
298
|
tracePropagationTargets: s,
|
|
261
299
|
tracesSampleRate: n || 1
|
|
262
300
|
}), null;
|
|
263
|
-
},
|
|
264
|
-
let { libraries: c, localStorageKeys: d } = a(v), f = s?.reactRouter || c?.reactRouter, p = s?.axios || c?.axios, m = s?.localStorageKey || d?.user ||
|
|
301
|
+
}, z = /* @__PURE__ */ new WeakMap(), te = "user", ne = ({ Fallback: e, isLogged: n, loginPath: r = "/login", redirect401Path: i = "/login", ...s }) => {
|
|
302
|
+
let { libraries: c, localStorageKeys: d } = a(v), f = s?.reactRouter || c?.reactRouter, p = s?.axios || c?.axios, m = s?.localStorageKey || d?.user || te;
|
|
265
303
|
if (!f) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
266
304
|
let [h, g] = l(null), { useLocation: _, Navigate: y, Outlet: b } = f, x = _(), S = typeof n == "function" ? n() : !!n, C = typeof S == "boolean" ? S : S?.isLogged;
|
|
267
305
|
return o(() => {
|
|
268
|
-
p && (
|
|
306
|
+
p && (z.has(p) || (z.set(p, !0), p.interceptors.response.use((e) => e, (e) => (typeof e == "object" && e && "response" in e && e.response && typeof e.response == "object" && "status" in e.response && e.response && typeof e.response == "object" && "status" in e.response && e?.response?.status === 401 && (typeof e == "object" && e && "config" in e && e.config && typeof e.config == "object" && "headers" in e.config && e.config.headers && typeof e.config.headers == "object" && "Authorization" in e.config.headers && e.config.headers.Authorization && (p.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(m)), g(i)), Promise.reject(e)))));
|
|
269
307
|
}, [
|
|
270
308
|
p,
|
|
271
309
|
m,
|
|
@@ -281,28 +319,28 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
281
319
|
state: { from: x },
|
|
282
320
|
replace: !0
|
|
283
321
|
});
|
|
284
|
-
},
|
|
322
|
+
}, B = /* @__PURE__ */ new Set(), re = () => (o(() => {
|
|
285
323
|
let e = Symbol();
|
|
286
|
-
return
|
|
287
|
-
|
|
324
|
+
return B.add(e), document.documentElement.removeAttribute(I), () => {
|
|
325
|
+
B.delete(e), B.size === 0 && document.documentElement.setAttribute(I, "");
|
|
288
326
|
};
|
|
289
|
-
}, []), null),
|
|
327
|
+
}, []), null), ie = "user", ae = {
|
|
290
328
|
client: "/v2/threads/ws",
|
|
291
329
|
supplier: "/v1/threads/ws"
|
|
292
|
-
},
|
|
330
|
+
}, oe = (e, t) => `${e.startsWith("https") ? "wss" : "ws"}://${e.replace(/^https?:\/\//, "")}${t}`, se = (e) => {
|
|
293
331
|
try {
|
|
294
332
|
let t = localStorage.getItem(e);
|
|
295
333
|
return t ? JSON.parse(t)?.accessToken ?? null : null;
|
|
296
334
|
} catch {
|
|
297
335
|
return null;
|
|
298
336
|
}
|
|
299
|
-
},
|
|
300
|
-
let [_, y] = l(!1), [b, x] = l(!1), [S, C] = l(0), [w, T] = l(m), E = m && w, { apiURL: D, localStorageKeys: O } = a(v), k = O?.user ||
|
|
337
|
+
}, V = n(null), ce = ({ children: e, token: t, url: n, wsPath: r, maxReconnectAttempts: s, reconnectBaseDelay: d, maxMessageBodyLength: f = 1e4, reconnect: p = !0, enabled: m = !0, context: h = "client" }) => {
|
|
338
|
+
let [_, y] = l(!1), [b, x] = l(!1), [S, C] = l(0), [w, T] = l(m), E = m && w, { apiURL: D, localStorageKeys: O } = a(v), k = O?.user || ie, A = c(null), j = c(/* @__PURE__ */ new Set());
|
|
301
339
|
o(() => {
|
|
302
340
|
if (!E) return;
|
|
303
|
-
let e = r ??
|
|
341
|
+
let e = r ?? ae[h], i = n || (D ? oe(D, e) : null);
|
|
304
342
|
if (!i) return;
|
|
305
|
-
let a = () => t ??
|
|
343
|
+
let a = () => t ?? se(k), o = (e) => {
|
|
306
344
|
switch (e.type) {
|
|
307
345
|
case "ready":
|
|
308
346
|
x(!0), C(e.unreadCount ?? 0);
|
|
@@ -350,16 +388,16 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
350
388
|
A.current?.markRead(e);
|
|
351
389
|
}, []), I = i((e, t) => {
|
|
352
390
|
A.current?.listThreads(e, t);
|
|
353
|
-
}, []),
|
|
391
|
+
}, []), L = i((e = 1) => {
|
|
354
392
|
C((t) => t + e);
|
|
355
|
-
}, []),
|
|
393
|
+
}, []), R = {
|
|
356
394
|
decrementUnreadCount: i((e = 1) => {
|
|
357
395
|
C((t) => Math.max(0, t - e));
|
|
358
396
|
}, []),
|
|
359
397
|
disconnect: i(() => {
|
|
360
398
|
A.current?.disconnect(), A.current = null;
|
|
361
399
|
}, []),
|
|
362
|
-
incrementUnreadCount:
|
|
400
|
+
incrementUnreadCount: L,
|
|
363
401
|
isConnected: _,
|
|
364
402
|
isReady: b,
|
|
365
403
|
joinThread: M,
|
|
@@ -375,16 +413,16 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
375
413
|
}), []),
|
|
376
414
|
unreadCount: S
|
|
377
415
|
};
|
|
378
|
-
return /* @__PURE__ */ u(
|
|
379
|
-
value:
|
|
416
|
+
return /* @__PURE__ */ u(V.Provider, {
|
|
417
|
+
value: R,
|
|
380
418
|
children: e
|
|
381
419
|
});
|
|
382
|
-
},
|
|
420
|
+
}, le = (e) => e && typeof e == "function", ue = (e) => e && typeof e == "function", de = ({ children: e, defaultQueriesOptions: t, defaultMutationsOptions: n, ...r }) => {
|
|
383
421
|
let { libraries: i } = a(v), o = r?.QueryClient || i?.reactQuery?.QueryClient, s = r?.QueryClientProvider || i?.reactQuery?.QueryClientProvider;
|
|
384
422
|
if (!o) throw Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
385
423
|
if (!s) throw Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
386
|
-
if (!
|
|
387
|
-
if (!
|
|
424
|
+
if (!le(s)) throw Error("Provided QueryClientProvider dependencies are not valid.");
|
|
425
|
+
if (!ue(o)) throw Error("Provided QueryClient dependencies are not valid.");
|
|
388
426
|
let l = c(null);
|
|
389
427
|
return l.current ||= new o({ defaultOptions: {
|
|
390
428
|
mutations: { ...n },
|
|
@@ -398,36 +436,36 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
398
436
|
client: l.current,
|
|
399
437
|
children: e
|
|
400
438
|
});
|
|
401
|
-
},
|
|
439
|
+
}, H = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), U = (e, t) => {
|
|
402
440
|
let { fractionDigits: n = 0, metric: r = "km", spacingBetween: i = !0 } = t || {}, a = Number(e), o = i ? " " : "";
|
|
403
441
|
return Number.isNaN(a) ? `0${o}${r}` : `${a.toFixed(n)}${o}${r}`;
|
|
404
|
-
},
|
|
442
|
+
}, W = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((e) => e.length > 0 ? e.charAt(0).toUpperCase() + e.slice(1) : e).join(" "), fe = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, pe = ({ path: e, size: t, apiURL: n }) => {
|
|
405
443
|
if (!e) return "";
|
|
406
|
-
let r = `${n}${
|
|
444
|
+
let r = `${n}${fe(e)}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
|
|
407
445
|
return typeof t == "number" && i ? `${r.replace("/files", `/thumbs/${t}`)}` : r;
|
|
408
|
-
},
|
|
446
|
+
}, me = (e) => {
|
|
409
447
|
let { apiURL: t, libraries: n } = a(v), r = e?.dayjs || n?.dayjs;
|
|
410
448
|
return {
|
|
411
449
|
dateAdapter: (e, t) => {
|
|
412
450
|
if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
413
|
-
return
|
|
451
|
+
return H({
|
|
414
452
|
date: e,
|
|
415
453
|
format: t,
|
|
416
454
|
library: r
|
|
417
455
|
});
|
|
418
456
|
},
|
|
419
|
-
distanceAdapter:
|
|
457
|
+
distanceAdapter: U,
|
|
420
458
|
filePathAdapter: (e, n) => {
|
|
421
459
|
if (!t) throw Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");
|
|
422
|
-
return typeof e == "string" && /^https?:\/\//.test(e) ? e :
|
|
460
|
+
return typeof e == "string" && /^https?:\/\//.test(e) ? e : pe({
|
|
423
461
|
apiURL: t,
|
|
424
462
|
path: e,
|
|
425
463
|
size: n
|
|
426
464
|
});
|
|
427
465
|
},
|
|
428
|
-
worksiteNameAdapter:
|
|
466
|
+
worksiteNameAdapter: W
|
|
429
467
|
};
|
|
430
|
-
},
|
|
468
|
+
}, he = () => {
|
|
431
469
|
let { libraries: e } = a(v), t = e?.amplitude?.analytics, n = i((e, n) => {
|
|
432
470
|
if (!t || (t.setUserId(e), !n)) return;
|
|
433
471
|
let r = new t.Identify();
|
|
@@ -451,14 +489,14 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
451
489
|
setGroup: r,
|
|
452
490
|
track: o
|
|
453
491
|
};
|
|
454
|
-
},
|
|
492
|
+
}, ge = (e) => {
|
|
455
493
|
let { libraries: t, localStorageKeys: n } = a(v), r = e?.axios || t?.axios, s = e?.localStorageKey || n?.user || "user";
|
|
456
494
|
if (!r) throw Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
|
|
457
495
|
let c = i(({ tokenType: e, accessToken: t }) => {
|
|
458
496
|
r.defaults.headers.common.Authorization = `${e} ${t}`;
|
|
459
497
|
}, [r.defaults.headers.common]);
|
|
460
498
|
return o(() => {
|
|
461
|
-
if (
|
|
499
|
+
if (A) return;
|
|
462
500
|
let e = ({ newValue: e, key: t }) => {
|
|
463
501
|
if (t === s && e) try {
|
|
464
502
|
let { accessToken: t, tokenType: n } = JSON.parse(e);
|
|
@@ -479,9 +517,9 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
479
517
|
},
|
|
480
518
|
setAuthenticationToken: c
|
|
481
519
|
};
|
|
482
|
-
},
|
|
520
|
+
}, _e = "New message", ve = (e, t) => {
|
|
483
521
|
if (!("Notification" in window) || typeof Notification != "function" || Notification.permission !== "granted" || !document.hidden) return;
|
|
484
|
-
let n = new Notification(t.title ??
|
|
522
|
+
let n = new Notification(t.title ?? _e, {
|
|
485
523
|
badge: t?.badge,
|
|
486
524
|
body: t?.body || e.bodyPreview,
|
|
487
525
|
data: t?.data,
|
|
@@ -496,8 +534,8 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
496
534
|
let { onClick: r } = t;
|
|
497
535
|
n.onclick = () => r(e);
|
|
498
536
|
}
|
|
499
|
-
},
|
|
500
|
-
let t = a(
|
|
537
|
+
}, ye = (e) => {
|
|
538
|
+
let t = a(V);
|
|
501
539
|
if (!t) throw Error("useChat must be used within ChatProvider");
|
|
502
540
|
let { subscribe: n, setEnabled: r, ...i } = t, s = c(e);
|
|
503
541
|
return s.current = e, o(() => {
|
|
@@ -514,7 +552,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
514
552
|
r?.(e);
|
|
515
553
|
break;
|
|
516
554
|
case "new_message_notification":
|
|
517
|
-
i?.(e), t && t.enabled !== !1 &&
|
|
555
|
+
i?.(e), t && t.enabled !== !1 && ve(e, t);
|
|
518
556
|
break;
|
|
519
557
|
case "presence":
|
|
520
558
|
a?.(e);
|
|
@@ -539,44 +577,44 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
539
577
|
break;
|
|
540
578
|
}
|
|
541
579
|
}), [n]), i;
|
|
542
|
-
},
|
|
580
|
+
}, G = (e, t) => t === "short" ? e.split("-")[0] : e, be = (e, t = "full") => {
|
|
543
581
|
let [n, r] = l(() => {
|
|
544
582
|
let n = e?.language || navigator.language;
|
|
545
|
-
return e && "isInitialized" in e && e.isInitialized,
|
|
583
|
+
return e && "isInitialized" in e && e.isInitialized, G(n, t);
|
|
546
584
|
});
|
|
547
585
|
return o(() => {
|
|
548
|
-
e && "isInitialized" in e && e.isInitialized && e.language && r(
|
|
586
|
+
e && "isInitialized" in e && e.isInitialized && e.language && r(G(e.language, t));
|
|
549
587
|
let n = (e) => {
|
|
550
|
-
r(
|
|
588
|
+
r(G(e, t));
|
|
551
589
|
};
|
|
552
590
|
return e?.on?.("languageChanged", n), () => {
|
|
553
591
|
e?.off?.("languageChanged", n);
|
|
554
592
|
};
|
|
555
593
|
}, [e, t]), n;
|
|
556
|
-
},
|
|
594
|
+
}, xe = "tracktor.filter", Se = {
|
|
557
595
|
getFilter: () => void 0,
|
|
558
596
|
getFilters: () => ({}),
|
|
559
597
|
handleFilter: () => () => {},
|
|
560
598
|
setFilter: () => {}
|
|
561
|
-
},
|
|
599
|
+
}, K = (e) => {
|
|
562
600
|
try {
|
|
563
601
|
return JSON.parse(e);
|
|
564
602
|
} catch {
|
|
565
603
|
return e;
|
|
566
604
|
}
|
|
567
|
-
},
|
|
605
|
+
}, q = (e, t, n) => `${n}_${e}=>${t}`, Ce = (e) => e.reduce((e, t) => {
|
|
568
606
|
let n = localStorage.getItem(t);
|
|
569
607
|
if (n) try {
|
|
570
608
|
let t = JSON.parse(n), r = Object.keys(t)?.[0];
|
|
571
609
|
r && (e[r] = Object.values(t)?.[0]);
|
|
572
610
|
} catch {}
|
|
573
611
|
return e;
|
|
574
|
-
}, {}),
|
|
575
|
-
let { libraries: t, localStorageKeys: n } = a(v), r = e?.reactRouter || t?.reactRouter, { pathname: i } = r?.useLocation?.() ?? { pathname: "/" }, [o, s] = r?.useSearchParams?.() ?? [new URLSearchParams(), () => {}], [c, u] = l({}), d = n?.filter ||
|
|
576
|
-
if (
|
|
612
|
+
}, {}), we = (e) => {
|
|
613
|
+
let { libraries: t, localStorageKeys: n } = a(v), r = e?.reactRouter || t?.reactRouter, { pathname: i } = r?.useLocation?.() ?? { pathname: "/" }, [o, s] = r?.useSearchParams?.() ?? [new URLSearchParams(), () => {}], [c, u] = l({}), d = n?.filter || xe, f = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, p = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
|
|
614
|
+
if (A) return Se;
|
|
577
615
|
if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");
|
|
578
616
|
let m = () => Object.keys(localStorage).filter((t) => t.startsWith(d) && t.endsWith(e?.pathname || i)), h = (t, n, r = !0) => {
|
|
579
|
-
let a =
|
|
617
|
+
let a = q(t, e?.pathname || i, d);
|
|
580
618
|
if (!n || Array.isArray(n) && !n.length) {
|
|
581
619
|
f ? (o.delete(t), s(o)) : u((e) => {
|
|
582
620
|
let n = { ...e };
|
|
@@ -596,13 +634,13 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
596
634
|
getFilter: (t, n) => {
|
|
597
635
|
if (f) {
|
|
598
636
|
let e = o.get(t);
|
|
599
|
-
if (e) return
|
|
637
|
+
if (e) return K(e);
|
|
600
638
|
} else {
|
|
601
639
|
let e = c[t];
|
|
602
640
|
if (e !== void 0) return e;
|
|
603
641
|
}
|
|
604
642
|
if (p) {
|
|
605
|
-
let n =
|
|
643
|
+
let n = q(t, e?.pathname || i, d), r = localStorage.getItem(n);
|
|
606
644
|
if (r) try {
|
|
607
645
|
let e = JSON.parse(r)[t];
|
|
608
646
|
return !f && e !== void 0 && u((n) => ({
|
|
@@ -614,9 +652,9 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
614
652
|
return n;
|
|
615
653
|
},
|
|
616
654
|
getFilters: () => {
|
|
617
|
-
let e = p ?
|
|
655
|
+
let e = p ? Ce(m()) : {};
|
|
618
656
|
if (f) {
|
|
619
|
-
let t = Array.from(o.entries()).reduce((e, [t, n]) => (e[t] =
|
|
657
|
+
let t = Array.from(o.entries()).reduce((e, [t, n]) => (e[t] = K(n), e), {});
|
|
620
658
|
return {
|
|
621
659
|
...e,
|
|
622
660
|
...t
|
|
@@ -637,7 +675,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
637
675
|
},
|
|
638
676
|
setFilter: h
|
|
639
677
|
};
|
|
640
|
-
},
|
|
678
|
+
}, J = () => document.getElementById(P), Te = () => {
|
|
641
679
|
let [e, t] = l(() => !!window.HubSpotConversations);
|
|
642
680
|
return o(() => {
|
|
643
681
|
if (window.HubSpotConversations) {
|
|
@@ -647,16 +685,16 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
647
685
|
window.hsConversationsOnReady = [() => t(!0)];
|
|
648
686
|
}, []), o(() => {
|
|
649
687
|
e && window.HubSpotConversations?.on("widgetClosed", () => {
|
|
650
|
-
|
|
688
|
+
J()?.classList.remove(F);
|
|
651
689
|
});
|
|
652
690
|
}, [e]), {
|
|
653
691
|
isAvailable: e,
|
|
654
692
|
toggle: i(() => {
|
|
655
|
-
let e = window.HubSpotConversations, t =
|
|
656
|
-
e && t && (t.classList.contains("hs-show") ? (e.widget.close(), t.classList.remove(
|
|
693
|
+
let e = window.HubSpotConversations, t = J();
|
|
694
|
+
e && t && (t.classList.contains("hs-show") ? (e.widget.close(), t.classList.remove(F)) : (t.classList.add(F), e.widget.open()));
|
|
657
695
|
}, [])
|
|
658
696
|
};
|
|
659
|
-
},
|
|
697
|
+
}, Ee = ({ data: e, fetchNextPage: t, isFetchingNextPage: n, isInitialLoading: r, isLoading: a, enabled: o = !0 }) => {
|
|
660
698
|
let c = i(async (e) => {
|
|
661
699
|
n || !o || await t({ pageParam: e?.pageParam || e.visibleRowsCount });
|
|
662
700
|
}, [
|
|
@@ -672,7 +710,7 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
672
710
|
loadingVariant: r ? "skeleton" : "linear-progress",
|
|
673
711
|
rows: l
|
|
674
712
|
};
|
|
675
|
-
},
|
|
713
|
+
}, De = (e) => {
|
|
676
714
|
let { libraries: t } = a(v), n = e?.i18 || t?.i18, r = e?.i18?.translateFunction || t?.i18?.translateFunction, o = n?.i18next?.t || r || ((e) => e), { unknownErrorTranslationKey: s = "error.unknownError" } = e || {}, c = o(s), l = i((e) => {
|
|
677
715
|
if (e && typeof e == "object" && "response" in e) {
|
|
678
716
|
let { response: t } = e || {};
|
|
@@ -696,38 +734,38 @@ var d = 3e4, f = 1e3, p = 1e4, m = (e) => Array.isArray(e) ? e.map(m) : typeof e
|
|
|
696
734
|
}, []),
|
|
697
735
|
printError: l
|
|
698
736
|
};
|
|
699
|
-
},
|
|
700
|
-
if (!
|
|
737
|
+
}, Y = "chunk-reload-timestamp", X = "chunk-reload", Oe = 1e4, Z = 2, Q = !1;
|
|
738
|
+
if (!A && typeof window < "u") {
|
|
701
739
|
try {
|
|
702
740
|
let e = new URL(window.location.href);
|
|
703
|
-
e.searchParams.has(
|
|
741
|
+
e.searchParams.has(X) && (Q = !0, e.searchParams.delete(X), window.history.replaceState(null, "", e.toString()));
|
|
704
742
|
} catch {}
|
|
705
743
|
window.addEventListener("vite:preloadError", (e) => {
|
|
706
744
|
e.preventDefault();
|
|
707
745
|
});
|
|
708
746
|
}
|
|
709
|
-
var
|
|
747
|
+
var ke = (e) => {
|
|
710
748
|
if (!(e instanceof Error)) return !1;
|
|
711
749
|
let t = e.message.toLowerCase();
|
|
712
750
|
return t.includes("dynamically imported module") || t.includes("importing a module script failed") || t.includes("loading chunk") || t.includes("loading css chunk") || t.includes("unable to preload css") || t.includes("failed to fetch") || t.includes("error loading dynamically imported module") || t.includes("load failed") || t.includes("without a valid default export") || e.name === "ChunkLoadError";
|
|
713
|
-
},
|
|
751
|
+
}, Ae = /import\s*\(\s*(['"])((\w+:(\/?\/?))?[^\s,]+)\1/, je = (e) => e.toString().match(Ae)?.[2] ?? null, Me = (e) => {
|
|
714
752
|
try {
|
|
715
753
|
return sessionStorage.getItem(e);
|
|
716
754
|
} catch {
|
|
717
755
|
return null;
|
|
718
756
|
}
|
|
719
|
-
},
|
|
757
|
+
}, Ne = (e, t) => {
|
|
720
758
|
try {
|
|
721
759
|
sessionStorage.setItem(e, t);
|
|
722
760
|
} catch {}
|
|
723
|
-
},
|
|
724
|
-
for (let t = 0; t <
|
|
725
|
-
return await
|
|
761
|
+
}, Pe = (e) => Function("url", "return import(url)")(e), Fe = async (e) => {
|
|
762
|
+
for (let t = 0; t < Z; t++) try {
|
|
763
|
+
return await Pe(`${e}?t=${Date.now()}`);
|
|
726
764
|
} catch {
|
|
727
|
-
t <
|
|
765
|
+
t < Z - 1 && await new Promise((e) => setTimeout(e, 500 * 2 ** t));
|
|
728
766
|
}
|
|
729
|
-
throw Error(`Failed to import ${e} after ${
|
|
730
|
-
},
|
|
767
|
+
throw Error(`Failed to import ${e} after ${Z} retries`);
|
|
768
|
+
}, Ie = async () => {
|
|
731
769
|
try {
|
|
732
770
|
if (typeof navigator < "u" && "serviceWorker" in navigator) {
|
|
733
771
|
let e = await navigator.serviceWorker.getRegistrations();
|
|
@@ -738,11 +776,11 @@ var Se = (e) => {
|
|
|
738
776
|
await Promise.all(e.map((e) => caches.delete(e)));
|
|
739
777
|
}
|
|
740
778
|
} catch {}
|
|
741
|
-
},
|
|
742
|
-
await
|
|
779
|
+
}, Le = async () => {
|
|
780
|
+
await Ie();
|
|
743
781
|
let e = new URL(window.location.href);
|
|
744
|
-
e.searchParams.set(
|
|
745
|
-
}, $ = (e) => e != null && e.default !== void 0,
|
|
782
|
+
e.searchParams.set(X, String(Date.now())), window.location.replace(e.toString());
|
|
783
|
+
}, $ = (e) => e != null && e.default !== void 0, Re = (e) => r(async () => {
|
|
746
784
|
let t;
|
|
747
785
|
try {
|
|
748
786
|
let n = await e();
|
|
@@ -751,14 +789,14 @@ var Se = (e) => {
|
|
|
751
789
|
} catch (e) {
|
|
752
790
|
t = e;
|
|
753
791
|
}
|
|
754
|
-
if (
|
|
755
|
-
let n =
|
|
792
|
+
if (A || !ke(t)) throw t;
|
|
793
|
+
let n = je(e);
|
|
756
794
|
if (n) try {
|
|
757
|
-
let e = await
|
|
795
|
+
let e = await Fe(n);
|
|
758
796
|
if ($(e)) return e;
|
|
759
797
|
} catch {}
|
|
760
|
-
let r = Number(
|
|
761
|
-
return Date.now() - r <
|
|
798
|
+
let r = Number(Me(Y) || "0");
|
|
799
|
+
return Date.now() - r < Oe || Q || (Ne(Y, String(Date.now())), await Le()), { default: () => null };
|
|
762
800
|
});
|
|
763
801
|
//#endregion
|
|
764
|
-
export { g as ChatClient,
|
|
802
|
+
export { D as AutoReloadOnNewVersion, g as ChatClient, V as ChatContext, ce as ChatProvider, O as GTMSendPageView, k as InitializeAmplitude, M as InitializeAxiosConfig, N as InitializeDaysJSConfig, L as InitializeHubSpot, R as InitializeI18nConfig, ee as InitializeSentryConfig, v as InjectDependenciesContext, y as InjectDependenciesProvider, _ as MaskTextField, de as QueryProvider, ne as RequireAuth, re as ShowHubSpotBubble, H as dateAdapter, U as distanceAdapter, e as getOrvalConfig, Re as lazyWithRetry, me as useAdapter, he as useAmplitude, ge as useAuth, ye as useChat, be as useCurrentLanguage, we as useFilters, Te as useHubSpot, Ee as useInfiniteDataGrid, De as useResponseError, W as worksiteNameAdapter };
|