@getsoren/shared-module 2.69.0 → 2.69.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/documentImport.js +2 -2
  2. package/dist/events.js +1 -1
  3. package/dist/hourSheets.js +2 -2
  4. package/dist/main.d.ts +6 -6
  5. package/dist/main.js +371 -371
  6. package/dist/{context → modules/chat/context}/ChatProvider.d.ts +1 -1
  7. package/dist/{hooks → modules/chat/hooks}/useChat.d.ts +1 -1
  8. package/dist/{sheetLines-DzQEyJOO.js → sheetLines-DECsEz55.js} +1 -1
  9. package/package.json +4 -4
  10. /package/dist/{chat → modules/chat}/ChatClient.d.ts +0 -0
  11. /package/dist/{chat → modules/chat}/tests/ChatClient.test.d.ts +0 -0
  12. /package/dist/{chat → modules/chat}/types.d.ts +0 -0
  13. /package/dist/{documentImport → modules/documentImport}/index.d.ts +0 -0
  14. /package/dist/{documentImport → modules/documentImport}/types.d.ts +0 -0
  15. /package/dist/{documentImport → modules/documentImport}/utils/matching/matching.d.ts +0 -0
  16. /package/dist/{documentImport → modules/documentImport}/utils/matching/matching.test.d.ts +0 -0
  17. /package/dist/{documentImport → modules/documentImport}/utils/proposals/proposals.d.ts +0 -0
  18. /package/dist/{documentImport → modules/documentImport}/utils/proposals/proposals.test.d.ts +0 -0
  19. /package/dist/{documentImport → modules/documentImport}/utils/reading/reading.d.ts +0 -0
  20. /package/dist/{documentImport → modules/documentImport}/utils/reading/reading.test.d.ts +0 -0
  21. /package/dist/{events → modules/events}/catalog/clientEvents.d.ts +0 -0
  22. /package/dist/{events → modules/events}/catalog/supplierEvents.d.ts +0 -0
  23. /package/dist/{events → modules/events}/constants.d.ts +0 -0
  24. /package/dist/{events → modules/events}/hooks/useEventDeclaration/useEventDeclaration.d.ts +0 -0
  25. /package/dist/{events → modules/events}/hooks/useEventDeclaration/useEventDeclaration.test.d.ts +0 -0
  26. /package/dist/{events → modules/events}/index.d.ts +0 -0
  27. /package/dist/{events → modules/events}/locales/ar.d.ts +0 -0
  28. /package/dist/{events → modules/events}/locales/de.d.ts +0 -0
  29. /package/dist/{events → modules/events}/locales/en.d.ts +0 -0
  30. /package/dist/{events → modules/events}/locales/es.d.ts +0 -0
  31. /package/dist/{events → modules/events}/locales/fr.d.ts +0 -0
  32. /package/dist/{events → modules/events}/locales/it.d.ts +0 -0
  33. /package/dist/{events → modules/events}/locales/locales.d.ts +0 -0
  34. /package/dist/{events → modules/events}/locales/pt.d.ts +0 -0
  35. /package/dist/{events → modules/events}/tenants/bouygues/bouygues.d.ts +0 -0
  36. /package/dist/{events → modules/events}/tenants/index.d.ts +0 -0
  37. /package/dist/{events → modules/events}/tenants/tenants.test.d.ts +0 -0
  38. /package/dist/{events → modules/events}/types.d.ts +0 -0
  39. /package/dist/{events → modules/events}/utils/amounts/amounts.d.ts +0 -0
  40. /package/dist/{events → modules/events}/utils/amounts/amounts.test.d.ts +0 -0
  41. /package/dist/{events → modules/events}/utils/credits/credits.d.ts +0 -0
  42. /package/dist/{events → modules/events}/utils/credits/credits.test.d.ts +0 -0
  43. /package/dist/{events → modules/events}/utils/lineFunnel/lineFunnel.d.ts +0 -0
  44. /package/dist/{events → modules/events}/utils/lineFunnel/lineFunnel.test.d.ts +0 -0
  45. /package/dist/{events → modules/events}/utils/payload/payload.d.ts +0 -0
  46. /package/dist/{events → modules/events}/utils/payload/payload.test.d.ts +0 -0
  47. /package/dist/{events → modules/events}/utils/readEvent/readEvent.d.ts +0 -0
  48. /package/dist/{events → modules/events}/utils/readEvent/readEvent.test.d.ts +0 -0
  49. /package/dist/{events → modules/events}/utils/steps/steps.d.ts +0 -0
  50. /package/dist/{events → modules/events}/utils/steps/steps.test.d.ts +0 -0
  51. /package/dist/{hourSheets → modules/hourSheets}/constants.d.ts +0 -0
  52. /package/dist/{hourSheets → modules/hourSheets}/index.d.ts +0 -0
  53. /package/dist/{hourSheets → modules/hourSheets}/types.d.ts +0 -0
  54. /package/dist/{hourSheets → modules/hourSheets}/utils/billingReferences/billingReferences.d.ts +0 -0
  55. /package/dist/{hourSheets → modules/hourSheets}/utils/billingReferences/billingReferences.test.d.ts +0 -0
  56. /package/dist/{hourSheets → modules/hourSheets}/utils/imputation/imputation.d.ts +0 -0
  57. /package/dist/{hourSheets → modules/hourSheets}/utils/imputation/imputation.test.d.ts +0 -0
  58. /package/dist/{hourSheets → modules/hourSheets}/utils/readCostCentres/readCostCentres.d.ts +0 -0
  59. /package/dist/{hourSheets → modules/hourSheets}/utils/readCostCentres/readCostCentres.test.d.ts +0 -0
  60. /package/dist/{hourSheets → modules/hourSheets}/utils/sheetBlocker/sheetBlocker.d.ts +0 -0
  61. /package/dist/{hourSheets → modules/hourSheets}/utils/sheetBlocker/sheetBlocker.test.d.ts +0 -0
  62. /package/dist/{hourSheets → modules/hourSheets}/utils/sheetDays/sheetDays.d.ts +0 -0
  63. /package/dist/{hourSheets → modules/hourSheets}/utils/sheetDays/sheetDays.test.d.ts +0 -0
  64. /package/dist/{hourSheets → modules/hourSheets}/utils/sheetLines/sheetLines.d.ts +0 -0
  65. /package/dist/{hourSheets → modules/hourSheets}/utils/sheetLines/sheetLines.test.d.ts +0 -0
package/dist/main.js CHANGED
@@ -9,114 +9,8 @@ import "dayjs/locale/es";
9
9
  import "dayjs/locale/fr";
10
10
  import "dayjs/locale/it";
11
11
  import "dayjs/locale/pt";
12
- //#region src/chat/ChatClient.ts
13
- var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e.replace(/_([a-z])/g, (e, t) => t.toUpperCase()), T(t)])) : e, E = (e) => Array.isArray(e) ? e.map(E) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`), E(t)])) : e, ee = class {
14
- url;
15
- getToken;
16
- onEvent;
17
- onConnectionChange;
18
- shouldReconnect;
19
- maxReconnectAttempts;
20
- reconnectBaseDelay;
21
- maxMessageBodyLength;
22
- ws = null;
23
- reconnectAttempt = 0;
24
- reconnectTimer = null;
25
- intentionalClose = !1;
26
- joinedThreads = /* @__PURE__ */ new Set();
27
- pendingMessages = [];
28
- _connected = !1;
29
- _ready = !1;
30
- constructor(e) {
31
- this.url = e.url, this.getToken = e.getToken, this.onEvent = e.onEvent, this.onConnectionChange = e.onConnectionChange, this.shouldReconnect = e.reconnect ?? !0, this.maxReconnectAttempts = e.maxReconnectAttempts ?? Infinity, this.reconnectBaseDelay = e.reconnectBaseDelay ?? C, this.maxMessageBodyLength = e.maxMessageBodyLength ?? w;
32
- }
33
- get connected() {
34
- return this._connected;
35
- }
36
- get ready() {
37
- return this._ready;
38
- }
39
- connect() {
40
- let e = this.getToken();
41
- if (!e) return;
42
- this.intentionalClose = !1;
43
- let t = this.url.includes("?") ? "&" : "?", n = `${this.url}${t}token=${e}`;
44
- this.ws = new WebSocket(n), this.ws.onopen = () => {
45
- this._connected = !0, this.reconnectAttempt = 0, this.onConnectionChange?.(!0), this.rejoinThreads(), this.flushPendingMessages();
46
- }, this.ws.onmessage = (e) => {
47
- try {
48
- let t = T(JSON.parse(e.data));
49
- t.type === "ready" && (this._ready = !0), this.onEvent?.(t);
50
- } catch {}
51
- }, this.ws.onclose = () => {
52
- this._connected = !1, this._ready = !1, this.onConnectionChange?.(!1), !this.intentionalClose && this.shouldReconnect && this.reconnectAttempt < this.maxReconnectAttempts && this.scheduleReconnect();
53
- }, this.ws.onerror = () => {};
54
- }
55
- disconnect() {
56
- this.intentionalClose = !0, this.pendingMessages = [], this.clearReconnectTimer(), this.ws &&= (this.ws.close(), null);
57
- }
58
- joinThread(e) {
59
- this.joinedThreads.add(e), this.send({
60
- threadId: e,
61
- type: "join_thread"
62
- });
63
- }
64
- leaveThread(e) {
65
- this.joinedThreads.delete(e), this.send({
66
- threadId: e,
67
- type: "leave_thread"
68
- });
69
- }
70
- sendMessage(e, t) {
71
- if (t.length > this.maxMessageBodyLength) throw Error(`Message body exceeds maximum length of ${this.maxMessageBodyLength} characters`);
72
- this.send({
73
- body: t,
74
- threadId: e,
75
- type: "send_message"
76
- });
77
- }
78
- markRead(e) {
79
- this.send({
80
- threadId: e,
81
- type: "mark_read"
82
- });
83
- }
84
- listThreads(e, t) {
85
- this.send({
86
- limit: e,
87
- offset: t,
88
- type: "list_threads"
89
- });
90
- }
91
- send(e) {
92
- if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
93
- this.pendingMessages.push(e);
94
- return;
95
- }
96
- this.ws.send(JSON.stringify(E(e)));
97
- }
98
- flushPendingMessages() {
99
- let e = [...this.pendingMessages];
100
- this.pendingMessages = [];
101
- for (let t of e) this.send(t);
102
- }
103
- rejoinThreads() {
104
- for (let e of this.joinedThreads) this.send({
105
- threadId: e,
106
- type: "join_thread"
107
- });
108
- }
109
- scheduleReconnect() {
110
- this.clearReconnectTimer();
111
- let e = Math.min(this.reconnectBaseDelay * 2 ** this.reconnectAttempt, S);
112
- this.reconnectAttempt++, this.reconnectTimer = setTimeout(() => {
113
- this.connect();
114
- }, e);
115
- }
116
- clearReconnectTimer() {
117
- this.reconnectTimer !== null && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null);
118
- }
119
- }, D = ({ IMaskMixin: e, ...t }) => /* @__PURE__ */ x(v(() => e(({ TextField: e, ...t }) => /* @__PURE__ */ x(e, { ...t })), [e]), { ...t }), O = f({}), k = ({ children: e, apiURL: t, libraries: n, localStorageKeys: r }) => {
12
+ //#region src/components/Inputs/MaskTextField.tsx
13
+ var S = ({ IMaskMixin: e, ...t }) => /* @__PURE__ */ x(v(() => e(({ TextField: e, ...t }) => /* @__PURE__ */ x(e, { ...t })), [e]), { ...t }), C = f({}), w = ({ children: e, apiURL: t, libraries: n, localStorageKeys: r }) => {
120
14
  let i = v(() => ({
121
15
  apiURL: t,
122
16
  libraries: n,
@@ -126,33 +20,33 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
126
20
  n,
127
21
  r
128
22
  ]);
129
- return /* @__PURE__ */ x(O.Provider, {
23
+ return /* @__PURE__ */ x(C.Provider, {
130
24
  value: i,
131
25
  children: e
132
26
  });
133
- }, A = 900 * 1e3, te = 60 * 1e3, ne = 600 * 1e3, j = "auto-reload-on-new-version-timestamp", M = /<meta[^>]*name="version"[^>]*content="([^"]*)"/, N = (e) => {
27
+ }, T = 900 * 1e3, E = 60 * 1e3, ee = 600 * 1e3, D = "auto-reload-on-new-version-timestamp", O = /<meta[^>]*name="version"[^>]*content="([^"]*)"/, k = (e) => {
134
28
  try {
135
29
  return sessionStorage.getItem(e);
136
30
  } catch {
137
31
  return null;
138
32
  }
139
- }, P = (e, t) => {
33
+ }, te = (e, t) => {
140
34
  try {
141
35
  sessionStorage.setItem(e, t);
142
36
  } catch {}
143
- }, re = ({ version: e, checkInterval: t = A, children: n, ...r }) => {
144
- let { libraries: i } = h(O), a = r?.reactRouter || i?.reactRouter, o = y(!1), s = y(0);
37
+ }, ne = ({ version: e, checkInterval: t = T, children: n, ...r }) => {
38
+ let { libraries: i } = h(C), a = r?.reactRouter || i?.reactRouter, o = y(!1), s = y(0);
145
39
  if (!a) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of AutoReloadOnNewVersion.");
146
40
  let { useLocation: c, Outlet: l } = a, { pathname: u } = c(), d = y(u);
147
41
  return g(() => {
148
42
  if (!e || typeof window > "u") return;
149
43
  let n = async () => {
150
- if (!(o.current || Date.now() - s.current < te)) {
44
+ if (!(o.current || Date.now() - s.current < E)) {
151
45
  s.current = Date.now();
152
46
  try {
153
47
  let t = await fetch("/index.html", { cache: "no-store" });
154
48
  if (!t.ok) return;
155
- let n = (await t.text()).match(M)?.[1];
49
+ let n = (await t.text()).match(O)?.[1];
156
50
  n && n !== "%VERSION%" && n !== e && (o.current = !0);
157
51
  } catch {}
158
52
  }
@@ -165,11 +59,11 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
165
59
  }, [e, t]), g(() => {
166
60
  if (u === d.current || (d.current = u, !o.current)) return;
167
61
  o.current = !1;
168
- let e = Number(N(j) || "0");
169
- Date.now() - e < ne || (P(j, String(Date.now())), window.location.reload());
62
+ let e = Number(k(D) || "0");
63
+ Date.now() - e < ee || (te(D, String(Date.now())), window.location.reload());
170
64
  }, [u]), n ?? /* @__PURE__ */ x(l, {});
171
- }, ie = ({ data: e, ...t }) => {
172
- let { libraries: n } = h(O), r = t?.reactRouter || n?.reactRouter, i = t?.gtm || n?.gtm;
65
+ }, re = ({ data: e, ...t }) => {
66
+ let { libraries: n } = h(C), r = t?.reactRouter || n?.reactRouter, i = t?.gtm || n?.gtm;
173
67
  if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
174
68
  if (!i) throw Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");
175
69
  let { useGoogleTagManager: a } = i, { useLocation: o, Outlet: s } = r, { pathname: c } = o(), { sendEvent: l } = a();
@@ -184,7 +78,7 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
184
78
  c,
185
79
  l
186
80
  ]), /* @__PURE__ */ x(s, {});
187
- }, ae = "[data-amp-track-feature]", oe = [
81
+ }, A = "[data-amp-track-feature]", j = [
188
82
  "a",
189
83
  "button",
190
84
  "input",
@@ -196,19 +90,19 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
196
90
  "[contenteditable=\"true\" i]",
197
91
  "[data-amp-default-track]",
198
92
  ".amp-default-track"
199
- ], se = { defaultMaskLevel: "medium" }, ce = (e, t) => {
93
+ ], M = { defaultMaskLevel: "medium" }, ie = (e, t) => {
200
94
  if (e === !1) return !1;
201
95
  let n = e === !0 ? {} : e;
202
96
  return {
203
- cssSelectorAllowlist: [...t, ae],
97
+ cssSelectorAllowlist: [...t, A],
204
98
  ...n
205
99
  };
206
- }, le = (e, t) => !t || e === !1 ? !1 : {
100
+ }, ae = (e, t) => !t || e === !1 ? !1 : {
207
101
  deadClicks: !0,
208
102
  rageClicks: !0,
209
103
  ...e === !0 ? {} : e
210
- }, ue = ({ apiKey: e, appVersion: t, sessionReplaySampleRate: n, serverZone: r, elementInteractions: i = !0, frustrationInteractions: a = !0, platform: o = "desktop", sessionReplayPrivacy: s = se, userId: c, ...l }) => {
211
- let [u, d] = b(!!c), { libraries: f } = h(O), p = l.amplitude || f?.amplitude, m = y({
104
+ }, oe = ({ apiKey: e, appVersion: t, sessionReplaySampleRate: n, serverZone: r, elementInteractions: i = !0, frustrationInteractions: a = !0, platform: o = "desktop", sessionReplayPrivacy: s = M, userId: c, ...l }) => {
105
+ let [u, d] = b(!!c), { libraries: f } = h(C), p = l.amplitude || f?.amplitude, m = y({
212
106
  elementInteractions: i,
213
107
  frustrationInteractions: a,
214
108
  sessionReplayPrivacy: s
@@ -222,12 +116,12 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
222
116
  }), g(() => {
223
117
  let i = p?.analytics, a = p?.sessionReplayPlugin;
224
118
  if (!(e && i && u)) return;
225
- let { elementInteractions: s, frustrationInteractions: c, sessionReplayPrivacy: l } = m.current, d = v.current, f = !d, h = "platform-enrichment", g = ce(s, i.Types?.DEFAULT_CSS_SELECTOR_ALLOWLIST ?? oe);
119
+ let { elementInteractions: s, frustrationInteractions: c, sessionReplayPrivacy: l } = m.current, d = v.current, f = !d, h = "platform-enrichment", g = ie(s, i.Types?.DEFAULT_CSS_SELECTOR_ALLOWLIST ?? j);
226
120
  return i.init(e, d, {
227
121
  appVersion: t,
228
122
  autocapture: {
229
123
  elementInteractions: g,
230
- frustrationInteractions: le(c, g !== !1),
124
+ frustrationInteractions: ae(c, g !== !1),
231
125
  pageViews: { trackHistoryChanges: "pathOnly" }
232
126
  },
233
127
  optOut: f,
@@ -271,22 +165,22 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
271
165
  u,
272
166
  c
273
167
  ]), null;
274
- }, F = (() => {
168
+ }, N = (() => {
275
169
  try {
276
170
  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;
277
171
  } catch {
278
172
  return !1;
279
173
  }
280
- })(), de = "user", fe = ({ tokenTypeKey: e = "tokenType", tokenKey: t = "accessToken", postContentType: n = "application/json", ...r }) => {
281
- let { apiURL: i = r.apiURL, libraries: a, localStorageKeys: o } = h(O), s = r?.userLocalStorageKey || o?.user || de, c = r?.axios || a?.axios;
174
+ })(), se = "user", ce = ({ tokenTypeKey: e = "tokenType", tokenKey: t = "accessToken", postContentType: n = "application/json", ...r }) => {
175
+ let { apiURL: i = r.apiURL, libraries: a, localStorageKeys: o } = h(C), s = r?.userLocalStorageKey || o?.user || se, c = r?.axios || a?.axios;
282
176
  if (!c) throw Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
283
- if (!c?.defaults || F) return null;
177
+ if (!c?.defaults || N) return null;
284
178
  if (typeof window < "u" && window.localStorage) {
285
179
  let n = localStorage.getItem(s), r = n ? JSON.parse(n) : null, i = r?.[e] ? r[e] : null, a = r?.[t] ? r[t] : null, o = n ? `${i} ${a}` : null;
286
180
  o && (c.defaults.headers.common.Authorization = o);
287
181
  }
288
182
  return c.defaults.baseURL = i, c.defaults.headers.post["Content-Type"] = n, null;
289
- }, pe = [
183
+ }, le = [
290
184
  "ar",
291
185
  "de",
292
186
  "en",
@@ -294,15 +188,15 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
294
188
  "fr",
295
189
  "it",
296
190
  "pt"
297
- ], me = (e) => pe.includes(e), he = ({ language: e, ...t }) => {
298
- let { libraries: n } = h(O), r = t?.dayjs || n?.dayjs, i = t?.plugin || n?.dayjsPlugin;
191
+ ], ue = (e) => le.includes(e), de = ({ language: e, ...t }) => {
192
+ let { libraries: n } = h(C), r = t?.dayjs || n?.dayjs, i = t?.plugin || n?.dayjsPlugin;
299
193
  if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");
300
194
  r.extend(t.localizedFormat), i && i.forEach((e) => {
301
195
  e && r.extend(e);
302
196
  });
303
- let a = e || navigator.language?.slice(0, 2) || "en", o = me(a) ? a : "en";
197
+ let a = e || navigator.language?.slice(0, 2) || "en", o = ue(a) ? a : "en";
304
198
  return r.locale() !== o && r.locale(o), null;
305
- }, I = "hubspot-messages-iframe-container", L = "hs-show", R = "data-hs-hidden", ge = ({ hubId: e }) => (g(() => {
199
+ }, P = "hubspot-messages-iframe-container", F = "hs-show", I = "data-hs-hidden", fe = ({ hubId: e }) => (g(() => {
306
200
  if (!e) return;
307
201
  let t = document.createElement("script");
308
202
  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), () => {
@@ -311,14 +205,14 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
311
205
  }, [e]), g(() => {
312
206
  let e = document.createElement("style");
313
207
  return e.textContent = `
314
- html[${R}] div#${I} { display: none !important; }
315
- html[${R}] div#${I}.${L} { display: initial !important; }
316
- `, document.head.appendChild(e), document.documentElement.setAttribute(R, ""), () => {
317
- e.remove(), document.documentElement.removeAttribute(R);
208
+ html[${I}] div#${P} { display: none !important; }
209
+ html[${I}] div#${P}.${F} { display: initial !important; }
210
+ `, document.head.appendChild(e), document.documentElement.setAttribute(I, ""), () => {
211
+ e.remove(), document.documentElement.removeAttribute(I);
318
212
  };
319
- }, []), null), _e = ({ debug: e, resources: t, ...n }) => {
320
- let { libraries: r } = h(O), i = n?.i18 || r?.i18, { i18next: a, initReactI18next: o, languageDetector: s } = i || {};
321
- if (F) return null;
213
+ }, []), null), pe = ({ debug: e, resources: t, ...n }) => {
214
+ let { libraries: r } = h(C), i = n?.i18 || r?.i18, { i18next: a, initReactI18next: o, languageDetector: s } = i || {};
215
+ if (N) return null;
322
216
  if (!(i && a && s && o)) throw Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
323
217
  return a.isInitialized ? null : (a.use(s).use(o).init({
324
218
  debug: e,
@@ -336,12 +230,12 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
336
230
  }), a.on("languageChanged", (e) => {
337
231
  document.documentElement.setAttribute("lang", e);
338
232
  }), null);
339
- }, z = { replay: "keep" }, B = (e) => e.tags?.replay === z.replay, V = [/^https:\/\/(api|events)\.mapbox\.com\//], H = (e, t) => t.some((t) => typeof t == "string" ? e.includes(t) : t.test(e)), ve = ({ dsn: e, integrations: t, tracesSampleRate: n, tracePropagationTargets: r, ignoreErrors: i, ignoreRequestUrls: a, debug: o, environment: s, release: c, replaysSessionSampleRate: l = 0, replaysOnErrorSampleRate: u = 1, replayBeforeErrorSampling: d = B, ...f }) => {
340
- let { libraries: p } = h(O), m = f?.sentry || p?.sentry, _ = f?.reactRouter || p?.reactRouter;
233
+ }, me = { replay: "keep" }, he = (e) => e.tags?.replay === me.replay, L = [/^https:\/\/(api|events)\.mapbox\.com\//], R = (e, t) => t.some((t) => typeof t == "string" ? e.includes(t) : t.test(e)), ge = ({ dsn: e, integrations: t, tracesSampleRate: n, tracePropagationTargets: r, ignoreErrors: i, ignoreRequestUrls: a, debug: o, environment: s, release: c, replaysSessionSampleRate: l = 0, replaysOnErrorSampleRate: u = 1, replayBeforeErrorSampling: d = he, ...f }) => {
234
+ let { libraries: p } = h(C), m = f?.sentry || p?.sentry, _ = f?.reactRouter || p?.reactRouter;
341
235
  if (!m) throw Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
342
236
  if (!_) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
343
237
  if (m.isInitialized()) return null;
344
- let { createRoutesFromChildren: v, matchRoutes: y, useLocation: b, useNavigationType: x } = _, S = l > 0 || u > 0, C = [...a || [], ...V];
238
+ let { createRoutesFromChildren: v, matchRoutes: y, useLocation: b, useNavigationType: x } = _, S = l > 0 || u > 0, w = [...a || [], ...L];
345
239
  return (o || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && m.init({
346
240
  debug: o,
347
241
  dsn: e,
@@ -359,7 +253,7 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
359
253
  m.reactRouterV6BrowserTracingIntegration({
360
254
  createRoutesFromChildren: v,
361
255
  matchRoutes: y,
362
- shouldCreateSpanForRequest: (e) => !H(e, C),
256
+ shouldCreateSpanForRequest: (e) => !R(e, w),
363
257
  useEffect: g,
364
258
  useLocation: b,
365
259
  useNavigationType: x
@@ -373,12 +267,12 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
373
267
  tracePropagationTargets: r,
374
268
  tracesSampleRate: n ?? 1
375
269
  }), null;
376
- }, U = /* @__PURE__ */ new WeakMap(), ye = "user", be = ({ Fallback: e, isLogged: t, loginPath: n = "/login", redirect401Path: r = "/login", ...i }) => {
377
- let { libraries: a, localStorageKeys: o } = h(O), s = i?.reactRouter || a?.reactRouter, c = i?.axios || a?.axios, l = i?.localStorageKey || o?.user || ye;
270
+ }, z = /* @__PURE__ */ new WeakMap(), _e = "user", ve = ({ Fallback: e, isLogged: t, loginPath: n = "/login", redirect401Path: r = "/login", ...i }) => {
271
+ let { libraries: a, localStorageKeys: o } = h(C), s = i?.reactRouter || a?.reactRouter, c = i?.axios || a?.axios, l = i?.localStorageKey || o?.user || _e;
378
272
  if (!s) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
379
273
  let [u, f] = b(null), { useLocation: p, Navigate: m, Outlet: _ } = s, v = p(), y = typeof t == "function" ? t() : !!t, S = typeof y == "boolean" ? y : y?.isLogged;
380
274
  return g(() => {
381
- c && (U.has(c) || (U.set(c, !0), c.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 && (c.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(l)), f(r)), Promise.reject(e)))));
275
+ c && (z.has(c) || (z.set(c, !0), c.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 && (c.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(l)), f(r)), Promise.reject(e)))));
382
276
  }, [
383
277
  c,
384
278
  l,
@@ -394,121 +288,28 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
394
288
  state: { from: v },
395
289
  replace: !0
396
290
  });
397
- }, W = /* @__PURE__ */ new Set(), xe = () => (g(() => {
291
+ }, B = /* @__PURE__ */ new Set(), ye = () => (g(() => {
398
292
  let e = Symbol();
399
- return W.add(e), document.documentElement.removeAttribute(R), () => {
400
- W.delete(e), W.size === 0 && document.documentElement.setAttribute(R, "");
401
- };
402
- }, []), null), Se = "user", Ce = {
403
- client: "/v2/threads/ws",
404
- supplier: "/v1/threads/ws"
405
- }, we = (e, t) => `${e.startsWith("https") ? "wss" : "ws"}://${e.replace(/^https?:\/\//, "")}${t}`, Te = (e) => {
406
- try {
407
- let t = localStorage.getItem(e);
408
- return t ? JSON.parse(t)?.accessToken ?? null : null;
409
- } catch {
410
- return null;
411
- }
412
- }, G = f(null), Ee = ({ children: e, token: t, url: n, wsPath: r, maxReconnectAttempts: i, reconnectBaseDelay: a, maxMessageBodyLength: o = 1e4, reconnect: s = !0, enabled: c = !0, context: l = "client" }) => {
413
- let [u, d] = b(!1), [f, p] = b(!1), [_, v] = b(0), [S, C] = b(c), w = c && S, { apiURL: T, localStorageKeys: E } = h(O), D = E?.user || Se, k = y(null), A = y(/* @__PURE__ */ new Set());
414
- g(() => {
415
- if (!w) return;
416
- let e = r ?? Ce[l], c = n || (T ? we(T, e) : null);
417
- if (!c) return;
418
- let u = () => t ?? Te(D), f = (e) => {
419
- switch (e.type) {
420
- case "ready":
421
- p(!0), v(e.unreadCount ?? 0);
422
- break;
423
- }
424
- for (let t of A.current) t(e);
425
- }, m = setTimeout(() => {
426
- let e = new ee({
427
- getToken: u,
428
- maxMessageBodyLength: o,
429
- maxReconnectAttempts: i,
430
- onConnectionChange: (e) => {
431
- d(e), e || p(!1);
432
- },
433
- onEvent: f,
434
- reconnect: s,
435
- reconnectBaseDelay: a,
436
- url: c
437
- });
438
- k.current = e, e.connect();
439
- }, 0);
440
- return () => {
441
- clearTimeout(m), k.current?.disconnect(), k.current = null;
442
- };
443
- }, [
444
- w,
445
- n,
446
- r,
447
- l,
448
- t,
449
- s,
450
- T,
451
- D,
452
- o,
453
- i,
454
- a
455
- ]);
456
- let te = m((e) => {
457
- k.current?.joinThread(e);
458
- }, []), ne = m((e) => {
459
- k.current?.leaveThread(e);
460
- }, []), j = m((e, t) => {
461
- k.current?.sendMessage(e, t);
462
- }, []), M = m((e) => {
463
- k.current?.markRead(e);
464
- }, []), N = m((e, t) => {
465
- k.current?.listThreads(e, t);
466
- }, []), P = m((e = 1) => {
467
- v((t) => t + e);
468
- }, []), re = {
469
- decrementUnreadCount: m((e = 1) => {
470
- v((t) => Math.max(0, t - e));
471
- }, []),
472
- disconnect: m(() => {
473
- k.current?.disconnect(), k.current = null;
474
- }, []),
475
- incrementUnreadCount: P,
476
- isConnected: u,
477
- isReady: f,
478
- joinThread: te,
479
- leaveThread: ne,
480
- listThreads: N,
481
- markRead: M,
482
- sendMessage: j,
483
- setEnabled: m((e) => {
484
- C(e);
485
- }, []),
486
- subscribe: m((e) => (A.current.add(e), () => {
487
- A.current.delete(e);
488
- }), []),
489
- unreadCount: _
293
+ return B.add(e), document.documentElement.removeAttribute(I), () => {
294
+ B.delete(e), B.size === 0 && document.documentElement.setAttribute(I, "");
490
295
  };
491
- return /* @__PURE__ */ x(G.Provider, {
492
- value: re,
493
- children: e
494
- });
495
- }, De = 3, Oe = new Set([
296
+ }, []), null), be = 3, xe = new Set([
496
297
  400,
497
298
  401,
498
299
  403,
499
300
  404
500
- ]), ke = (e) => e?.response?.status, K = (e, t) => {
501
- let n = ke(t);
502
- return e < De && !(n !== void 0 && Oe.has(n));
503
- }, Ae = (e, t, n) => (Array.isArray(e) ? e.length : 0) + (typeof n == "number" ? n : 0), je = ({ children: e, defaultQueriesOptions: t, defaultMutationsOptions: n, ...r }) => {
504
- let { libraries: i } = h(O), a = r.QueryClient || i?.reactQuery?.QueryClient, o = r.QueryClientProvider || i?.reactQuery?.QueryClientProvider;
301
+ ]), Se = (e) => e?.response?.status, V = (e, t) => {
302
+ let n = Se(t);
303
+ return e < be && !(n !== void 0 && xe.has(n));
304
+ }, Ce = (e, t, n) => (Array.isArray(e) ? e.length : 0) + (typeof n == "number" ? n : 0), we = ({ children: e, defaultQueriesOptions: t, defaultMutationsOptions: n, ...r }) => {
305
+ let { libraries: i } = h(C), a = r.QueryClient || i?.reactQuery?.QueryClient, o = r.QueryClientProvider || i?.reactQuery?.QueryClientProvider;
505
306
  if (!a) throw Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
506
307
  if (!o) throw Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
507
308
  let [s] = b(() => new a({ defaultOptions: {
508
309
  mutations: n,
509
310
  queries: {
510
- getNextPageParam: Ae,
511
- retry: K,
311
+ getNextPageParam: Ce,
312
+ retry: V,
512
313
  ...t
513
314
  }
514
315
  } }));
@@ -516,17 +317,17 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
516
317
  client: s,
517
318
  children: e
518
319
  });
519
- }, q = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), J = (e, t) => {
320
+ }, H = ({ library: e, date: t, format: n = "ll" }) => e(t).format(n), U = (e, t) => {
520
321
  let { fractionDigits: n = 0, metric: r = "km", spacingBetween: i = !0 } = t || {}, a = Number(e), o = i ? " " : "";
521
322
  return Number.isNaN(a) ? `0${o}${r}` : `${a.toFixed(n)}${o}${r}`;
522
- }, Me = (e) => !e || typeof e != "string" ? "" : e.replace(/_/g, " ").toLowerCase().split(" ").map((e) => e.length > 0 ? e.charAt(0).toUpperCase() + e.slice(1) : e).join(" "), Ne = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Pe = ({ path: e, size: t, apiURL: n }) => {
323
+ }, 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(" "), Te = (e) => e?.startsWith("/") ? e?.startsWith("/files") ? e : `/files${e}` : e?.startsWith("files") ? `/${e}` : `/files/${e}`, Ee = ({ path: e, size: t, apiURL: n }) => {
523
324
  if (!e) return "";
524
- let r = `${n}${Ne(e)}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
325
+ let r = `${n}${Te(e)}`, i = r.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/) !== null;
525
326
  return typeof t == "number" && i ? `${r.replace("/files", `/thumbs/${t}`)}` : r;
526
- }, Fe = (e) => {
527
- let { apiURL: t, libraries: n } = h(O), r = e?.dayjs || n?.dayjs, i = m((e, n) => {
327
+ }, De = (e) => {
328
+ let { apiURL: t, libraries: n } = h(C), r = e?.dayjs || n?.dayjs, i = m((e, n) => {
528
329
  if (!t) throw Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");
529
- return typeof e == "string" && /^https?:\/\//.test(e) ? e : Pe({
330
+ return typeof e == "string" && /^https?:\/\//.test(e) ? e : Ee({
530
331
  apiURL: t,
531
332
  path: e,
532
333
  size: n
@@ -535,18 +336,18 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
535
336
  return {
536
337
  dateAdapter: m((e, t) => {
537
338
  if (!r) throw Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
538
- return q({
339
+ return H({
539
340
  date: e,
540
341
  format: t,
541
342
  library: r
542
343
  });
543
344
  }, [r]),
544
- distanceAdapter: J,
345
+ distanceAdapter: U,
545
346
  filePathAdapter: i,
546
- worksiteNameAdapter: Me
347
+ worksiteNameAdapter: W
547
348
  };
548
- }, Ie = () => {
549
- let { libraries: e } = h(O), t = e?.amplitude?.analytics, n = m((e, n) => {
349
+ }, Oe = () => {
350
+ let { libraries: e } = h(C), t = e?.amplitude?.analytics, n = m((e, n) => {
550
351
  if (!t || (t.setUserId(e), !n)) return;
551
352
  let r = new t.Identify();
552
353
  Object.entries(n).forEach(([e, t]) => {
@@ -569,8 +370,8 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
569
370
  setGroup: r,
570
371
  track: i
571
372
  };
572
- }, Le = (e) => {
573
- let { libraries: t, localStorageKeys: n } = h(O), r = e?.axios || t?.axios, i = e?.localStorageKey || n?.user || "user";
373
+ }, ke = (e) => {
374
+ let { libraries: t, localStorageKeys: n } = h(C), r = e?.axios || t?.axios, i = e?.localStorageKey || n?.user || "user";
574
375
  if (!r) throw Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");
575
376
  let a = m(({ tokenType: e, accessToken: t }) => {
576
377
  r.defaults.headers.common.Authorization = `${e} ${t}`;
@@ -578,7 +379,7 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
578
379
  r.defaults.headers.common.Authorization = null;
579
380
  }, [r.defaults.headers.common]);
580
381
  return g(() => {
581
- if (F) return;
382
+ if (N) return;
582
383
  let e = ({ newValue: e, key: t }) => {
583
384
  if (t === i) try {
584
385
  let { accessToken: t, tokenType: n } = JSON.parse(e ?? "null") ?? {};
@@ -605,104 +406,44 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
605
406
  clearAuthenticationToken: o,
606
407
  setAuthenticationToken: a
607
408
  };
608
- }, Re = "New message", ze = (e, t) => {
609
- if (!("Notification" in window) || typeof Notification != "function" || Notification.permission !== "granted" || !document.hidden) return;
610
- let n = new Notification(t.title ?? Re, {
611
- badge: t?.badge,
612
- body: t?.body || e.bodyPreview,
613
- data: t?.data,
614
- dir: t?.dir,
615
- icon: t?.icon,
616
- lang: t?.lang,
617
- requireInteraction: t?.requireInteraction,
618
- silent: t?.silent,
619
- tag: t?.tag || e.messageId
620
- });
621
- if (t.onClick) {
622
- let { onClick: r } = t;
623
- n.onclick = () => r(e);
624
- }
625
- }, Be = (e) => {
626
- let t = h(G);
627
- if (!t) throw Error("useChat must be used within ChatProvider");
628
- let { subscribe: n, setEnabled: r, ...i } = t, a = y(e);
629
- return a.current = e, g(() => {
630
- e?.enabled !== void 0 && r(e.enabled);
631
- }, [e?.enabled, r]), g(() => {
632
- e?.browserNotification && e.browserNotification.enabled !== !1 && "Notification" in window && Notification.permission === "default" && typeof Notification.requestPermission == "function" && Notification.requestPermission();
633
- }, [e?.browserNotification]), g(() => n((e) => {
634
- let { browserNotification: t, onReady: n, onNewMessage: r, onNewMessageNotification: i, onPresence: o, onError: s, onJoinedThread: c, onLeftThread: l, onMarkedRead: u, onThreadArchived: d, onThreadsList: f } = a.current ?? {};
635
- switch (e.type) {
636
- case "ready":
637
- n?.(e);
638
- break;
639
- case "new_message":
640
- r?.(e);
641
- break;
642
- case "new_message_notification":
643
- i?.(e), t && t.enabled !== !1 && ze(e, t);
644
- break;
645
- case "presence":
646
- o?.(e);
647
- break;
648
- case "error":
649
- s?.(e);
650
- break;
651
- case "joined_thread":
652
- c?.(e);
653
- break;
654
- case "left_thread":
655
- l?.(e);
656
- break;
657
- case "marked_read":
658
- u?.(e);
659
- break;
660
- case "thread_archived":
661
- d?.(e);
662
- break;
663
- case "threads_list":
664
- f?.(e);
665
- break;
666
- }
667
- }), [n]), i;
668
- }, Y = (e, t = "full") => {
409
+ }, G = (e, t = "full") => {
669
410
  let n = e || navigator.language;
670
411
  return t === "short" ? n.split("-")[0] : n;
671
- }, Ve = (e, t = "full") => {
672
- let [n, r] = b(() => Y(e?.language, t));
412
+ }, Ae = (e, t = "full") => {
413
+ let [n, r] = b(() => G(e?.language, t));
673
414
  return g(() => {
674
- e && "isInitialized" in e && e.isInitialized && e.language && r(Y(e.language, t));
415
+ e && "isInitialized" in e && e.isInitialized && e.language && r(G(e.language, t));
675
416
  let n = (e) => {
676
- r(Y(e, t));
417
+ r(G(e, t));
677
418
  };
678
419
  return e?.on?.("languageChanged", n), () => {
679
420
  e?.off?.("languageChanged", n);
680
421
  };
681
422
  }, [e, t]), n;
682
- }, He = "tracktor.filter", Ue = {
423
+ }, je = "tracktor.filter", Me = {
683
424
  getFilter: () => void 0,
684
425
  getFilters: () => ({}),
685
426
  handleFilter: () => () => {},
686
427
  setFilter: () => {}
687
- }, We = (e) => {
428
+ }, K = (e) => {
688
429
  try {
689
430
  return JSON.parse(e);
690
431
  } catch {
691
432
  return e;
692
433
  }
693
- }, Ge = (e, t, n) => `${n}_${e}=>${t}`, Ke = (e) => e.reduce((e, t) => {
434
+ }, Ne = (e, t, n) => `${n}_${e}=>${t}`, Pe = (e) => e.reduce((e, t) => {
694
435
  let n = localStorage.getItem(t);
695
436
  if (n) try {
696
437
  let t = JSON.parse(n), r = Object.keys(t)?.[0];
697
438
  r && (e[r] = Object.values(t)?.[0]);
698
439
  } catch {}
699
440
  return e;
700
- }, {}), qe = (e) => {
701
- let { libraries: t, localStorageKeys: n } = h(O), r = e?.reactRouter || t?.reactRouter, { pathname: i } = r?.useLocation?.() ?? { pathname: "/" }, [a, o] = r?.useSearchParams?.() ?? [new URLSearchParams(), () => {}], [s, c] = b({}), l = n?.filter || He, u = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, d = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
702
- if (F) return Ue;
441
+ }, {}), Fe = (e) => {
442
+ let { libraries: t, localStorageKeys: n } = h(C), r = e?.reactRouter || t?.reactRouter, { pathname: i } = r?.useLocation?.() ?? { pathname: "/" }, [a, o] = r?.useSearchParams?.() ?? [new URLSearchParams(), () => {}], [s, c] = b({}), l = n?.filter || je, u = e?.syncWithUrl === void 0 ? !0 : e?.syncWithUrl, d = e?.persistToLocalStorage === void 0 ? !0 : e?.persistToLocalStorage;
443
+ if (N) return Me;
703
444
  if (!r) throw Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");
704
445
  let f = () => Object.keys(localStorage).filter((t) => t.startsWith(l) && t.endsWith(e?.pathname || i)), p = (t, n, r = !0) => {
705
- let s = Ge(t, e?.pathname || i, l);
446
+ let s = Ne(t, e?.pathname || i, l);
706
447
  if (!n || Array.isArray(n) && !n.length) {
707
448
  u ? (a.delete(t), o(a)) : c((e) => {
708
449
  let n = { ...e };
@@ -722,13 +463,13 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
722
463
  getFilter: (t, n) => {
723
464
  if (u) {
724
465
  let e = a.get(t);
725
- if (e) return We(e);
466
+ if (e) return K(e);
726
467
  } else {
727
468
  let e = s[t];
728
469
  if (e !== void 0) return e;
729
470
  }
730
471
  if (d) {
731
- let n = Ge(t, e?.pathname || i, l), r = localStorage.getItem(n);
472
+ let n = Ne(t, e?.pathname || i, l), r = localStorage.getItem(n);
732
473
  if (r) try {
733
474
  let e = JSON.parse(r)[t];
734
475
  return !u && e !== void 0 && c((n) => ({
@@ -740,9 +481,9 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
740
481
  return n;
741
482
  },
742
483
  getFilters: () => {
743
- let e = d ? Ke(f()) : {};
484
+ let e = d ? Pe(f()) : {};
744
485
  if (u) {
745
- let t = Array.from(a.entries()).reduce((e, [t, n]) => (e[t] = We(n), e), {});
486
+ let t = Array.from(a.entries()).reduce((e, [t, n]) => (e[t] = K(n), e), {});
746
487
  return {
747
488
  ...e,
748
489
  ...t
@@ -763,7 +504,7 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
763
504
  },
764
505
  setFilter: p
765
506
  };
766
- }, Je = () => document.getElementById(I), Ye = () => {
507
+ }, Ie = () => document.getElementById(P), Le = () => {
767
508
  let [e, t] = b(() => !!window.HubSpotConversations);
768
509
  return g(() => {
769
510
  if (window.HubSpotConversations) {
@@ -773,16 +514,16 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
773
514
  window.hsConversationsOnReady = [() => t(!0)];
774
515
  }, []), g(() => {
775
516
  e && window.HubSpotConversations?.on("widgetClosed", () => {
776
- Je()?.classList.remove(L);
517
+ Ie()?.classList.remove(F);
777
518
  });
778
519
  }, [e]), {
779
520
  isAvailable: e,
780
521
  toggle: m(() => {
781
- let e = window.HubSpotConversations, t = Je();
782
- e && t && (t.classList.contains("hs-show") ? (e.widget.close(), t.classList.remove(L)) : (t.classList.add(L), e.widget.open()));
522
+ let e = window.HubSpotConversations, t = Ie();
523
+ e && t && (t.classList.contains("hs-show") ? (e.widget.close(), t.classList.remove(F)) : (t.classList.add(F), e.widget.open()));
783
524
  }, [])
784
525
  };
785
- }, Xe = ({ data: e, fetchNextPage: t, isFetchingNextPage: n, isInitialLoading: r, isLoading: i, enabled: a = !0 }) => {
526
+ }, Re = ({ data: e, fetchNextPage: t, isFetchingNextPage: n, isInitialLoading: r, isLoading: i, enabled: a = !0 }) => {
786
527
  let o = m(async (e) => {
787
528
  n || !a || await t({ pageParam: e?.pageParam || e.visibleRowsCount });
788
529
  }, [
@@ -798,8 +539,8 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
798
539
  loadingVariant: r ? "skeleton" : "linear-progress",
799
540
  rows: s
800
541
  };
801
- }, Ze = (e) => {
802
- let { libraries: t } = h(O), n = e?.i18 || t?.i18, r = e?.i18?.translateFunction || t?.i18?.translateFunction, i = n?.i18next?.t || r || ((e) => e), { unknownErrorTranslationKey: a = "error.unknownError" } = e || {}, o = i(a), s = m((e) => {
542
+ }, ze = (e) => {
543
+ let { libraries: t } = h(C), n = e?.i18 || t?.i18, r = e?.i18?.translateFunction || t?.i18?.translateFunction, i = n?.i18next?.t || r || ((e) => e), { unknownErrorTranslationKey: a = "error.unknownError" } = e || {}, o = i(a), s = m((e) => {
803
544
  if (e && typeof e == "object" && "response" in e) {
804
545
  let { response: t } = e || {};
805
546
  if (t && typeof t == "object" && "reason" in t && t.reason) return String(t.reason);
@@ -822,38 +563,297 @@ var S = 3e4, C = 1e3, w = 1e4, T = (e) => Array.isArray(e) ? e.map(T) : typeof e
822
563
  }, []),
823
564
  printError: s
824
565
  };
825
- }, Qe = "chunk-reload-timestamp", X = "chunk-reload", $e = 1e4, Z = 2, et = !1;
826
- if (!F && typeof window < "u") {
566
+ }, Be = 3e4, Ve = 1e3, He = 1e4, q = (e) => Array.isArray(e) ? e.map(q) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e.replace(/_([a-z])/g, (e, t) => t.toUpperCase()), q(t)])) : e, J = (e) => Array.isArray(e) ? e.map(J) : typeof e == "object" && e ? Object.fromEntries(Object.entries(e).map(([e, t]) => [e.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`), J(t)])) : e, Ue = class {
567
+ url;
568
+ getToken;
569
+ onEvent;
570
+ onConnectionChange;
571
+ shouldReconnect;
572
+ maxReconnectAttempts;
573
+ reconnectBaseDelay;
574
+ maxMessageBodyLength;
575
+ ws = null;
576
+ reconnectAttempt = 0;
577
+ reconnectTimer = null;
578
+ intentionalClose = !1;
579
+ joinedThreads = /* @__PURE__ */ new Set();
580
+ pendingMessages = [];
581
+ _connected = !1;
582
+ _ready = !1;
583
+ constructor(e) {
584
+ this.url = e.url, this.getToken = e.getToken, this.onEvent = e.onEvent, this.onConnectionChange = e.onConnectionChange, this.shouldReconnect = e.reconnect ?? !0, this.maxReconnectAttempts = e.maxReconnectAttempts ?? Infinity, this.reconnectBaseDelay = e.reconnectBaseDelay ?? Ve, this.maxMessageBodyLength = e.maxMessageBodyLength ?? He;
585
+ }
586
+ get connected() {
587
+ return this._connected;
588
+ }
589
+ get ready() {
590
+ return this._ready;
591
+ }
592
+ connect() {
593
+ let e = this.getToken();
594
+ if (!e) return;
595
+ this.intentionalClose = !1;
596
+ let t = this.url.includes("?") ? "&" : "?", n = `${this.url}${t}token=${e}`;
597
+ this.ws = new WebSocket(n), this.ws.onopen = () => {
598
+ this._connected = !0, this.reconnectAttempt = 0, this.onConnectionChange?.(!0), this.rejoinThreads(), this.flushPendingMessages();
599
+ }, this.ws.onmessage = (e) => {
600
+ try {
601
+ let t = q(JSON.parse(e.data));
602
+ t.type === "ready" && (this._ready = !0), this.onEvent?.(t);
603
+ } catch {}
604
+ }, this.ws.onclose = () => {
605
+ this._connected = !1, this._ready = !1, this.onConnectionChange?.(!1), !this.intentionalClose && this.shouldReconnect && this.reconnectAttempt < this.maxReconnectAttempts && this.scheduleReconnect();
606
+ }, this.ws.onerror = () => {};
607
+ }
608
+ disconnect() {
609
+ this.intentionalClose = !0, this.pendingMessages = [], this.clearReconnectTimer(), this.ws &&= (this.ws.close(), null);
610
+ }
611
+ joinThread(e) {
612
+ this.joinedThreads.add(e), this.send({
613
+ threadId: e,
614
+ type: "join_thread"
615
+ });
616
+ }
617
+ leaveThread(e) {
618
+ this.joinedThreads.delete(e), this.send({
619
+ threadId: e,
620
+ type: "leave_thread"
621
+ });
622
+ }
623
+ sendMessage(e, t) {
624
+ if (t.length > this.maxMessageBodyLength) throw Error(`Message body exceeds maximum length of ${this.maxMessageBodyLength} characters`);
625
+ this.send({
626
+ body: t,
627
+ threadId: e,
628
+ type: "send_message"
629
+ });
630
+ }
631
+ markRead(e) {
632
+ this.send({
633
+ threadId: e,
634
+ type: "mark_read"
635
+ });
636
+ }
637
+ listThreads(e, t) {
638
+ this.send({
639
+ limit: e,
640
+ offset: t,
641
+ type: "list_threads"
642
+ });
643
+ }
644
+ send(e) {
645
+ if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
646
+ this.pendingMessages.push(e);
647
+ return;
648
+ }
649
+ this.ws.send(JSON.stringify(J(e)));
650
+ }
651
+ flushPendingMessages() {
652
+ let e = [...this.pendingMessages];
653
+ this.pendingMessages = [];
654
+ for (let t of e) this.send(t);
655
+ }
656
+ rejoinThreads() {
657
+ for (let e of this.joinedThreads) this.send({
658
+ threadId: e,
659
+ type: "join_thread"
660
+ });
661
+ }
662
+ scheduleReconnect() {
663
+ this.clearReconnectTimer();
664
+ let e = Math.min(this.reconnectBaseDelay * 2 ** this.reconnectAttempt, Be);
665
+ this.reconnectAttempt++, this.reconnectTimer = setTimeout(() => {
666
+ this.connect();
667
+ }, e);
668
+ }
669
+ clearReconnectTimer() {
670
+ this.reconnectTimer !== null && (clearTimeout(this.reconnectTimer), this.reconnectTimer = null);
671
+ }
672
+ }, We = "user", Ge = {
673
+ client: "/v2/threads/ws",
674
+ supplier: "/v1/threads/ws"
675
+ }, Ke = (e, t) => `${e.startsWith("https") ? "wss" : "ws"}://${e.replace(/^https?:\/\//, "")}${t}`, qe = (e) => {
676
+ try {
677
+ let t = localStorage.getItem(e);
678
+ return t ? JSON.parse(t)?.accessToken ?? null : null;
679
+ } catch {
680
+ return null;
681
+ }
682
+ }, Y = f(null), Je = ({ children: e, token: t, url: n, wsPath: r, maxReconnectAttempts: i, reconnectBaseDelay: a, maxMessageBodyLength: o = 1e4, reconnect: s = !0, enabled: c = !0, context: l = "client" }) => {
683
+ let [u, d] = b(!1), [f, p] = b(!1), [_, v] = b(0), [S, w] = b(c), T = c && S, { apiURL: E, localStorageKeys: ee } = h(C), D = ee?.user || We, O = y(null), k = y(/* @__PURE__ */ new Set());
684
+ g(() => {
685
+ if (!T) return;
686
+ let e = r ?? Ge[l], c = n || (E ? Ke(E, e) : null);
687
+ if (!c) return;
688
+ let u = () => t ?? qe(D), f = (e) => {
689
+ switch (e.type) {
690
+ case "ready":
691
+ p(!0), v(e.unreadCount ?? 0);
692
+ break;
693
+ }
694
+ for (let t of k.current) t(e);
695
+ }, m = setTimeout(() => {
696
+ let e = new Ue({
697
+ getToken: u,
698
+ maxMessageBodyLength: o,
699
+ maxReconnectAttempts: i,
700
+ onConnectionChange: (e) => {
701
+ d(e), e || p(!1);
702
+ },
703
+ onEvent: f,
704
+ reconnect: s,
705
+ reconnectBaseDelay: a,
706
+ url: c
707
+ });
708
+ O.current = e, e.connect();
709
+ }, 0);
710
+ return () => {
711
+ clearTimeout(m), O.current?.disconnect(), O.current = null;
712
+ };
713
+ }, [
714
+ T,
715
+ n,
716
+ r,
717
+ l,
718
+ t,
719
+ s,
720
+ E,
721
+ D,
722
+ o,
723
+ i,
724
+ a
725
+ ]);
726
+ let te = m((e) => {
727
+ O.current?.joinThread(e);
728
+ }, []), ne = m((e) => {
729
+ O.current?.leaveThread(e);
730
+ }, []), re = m((e, t) => {
731
+ O.current?.sendMessage(e, t);
732
+ }, []), A = m((e) => {
733
+ O.current?.markRead(e);
734
+ }, []), j = m((e, t) => {
735
+ O.current?.listThreads(e, t);
736
+ }, []), M = m((e = 1) => {
737
+ v((t) => t + e);
738
+ }, []), ie = {
739
+ decrementUnreadCount: m((e = 1) => {
740
+ v((t) => Math.max(0, t - e));
741
+ }, []),
742
+ disconnect: m(() => {
743
+ O.current?.disconnect(), O.current = null;
744
+ }, []),
745
+ incrementUnreadCount: M,
746
+ isConnected: u,
747
+ isReady: f,
748
+ joinThread: te,
749
+ leaveThread: ne,
750
+ listThreads: j,
751
+ markRead: A,
752
+ sendMessage: re,
753
+ setEnabled: m((e) => {
754
+ w(e);
755
+ }, []),
756
+ subscribe: m((e) => (k.current.add(e), () => {
757
+ k.current.delete(e);
758
+ }), []),
759
+ unreadCount: _
760
+ };
761
+ return /* @__PURE__ */ x(Y.Provider, {
762
+ value: ie,
763
+ children: e
764
+ });
765
+ }, Ye = "New message", Xe = (e, t) => {
766
+ if (!("Notification" in window) || typeof Notification != "function" || Notification.permission !== "granted" || !document.hidden) return;
767
+ let n = new Notification(t.title ?? Ye, {
768
+ badge: t?.badge,
769
+ body: t?.body || e.bodyPreview,
770
+ data: t?.data,
771
+ dir: t?.dir,
772
+ icon: t?.icon,
773
+ lang: t?.lang,
774
+ requireInteraction: t?.requireInteraction,
775
+ silent: t?.silent,
776
+ tag: t?.tag || e.messageId
777
+ });
778
+ if (t.onClick) {
779
+ let { onClick: r } = t;
780
+ n.onclick = () => r(e);
781
+ }
782
+ }, Ze = (e) => {
783
+ let t = h(Y);
784
+ if (!t) throw Error("useChat must be used within ChatProvider");
785
+ let { subscribe: n, setEnabled: r, ...i } = t, a = y(e);
786
+ return a.current = e, g(() => {
787
+ e?.enabled !== void 0 && r(e.enabled);
788
+ }, [e?.enabled, r]), g(() => {
789
+ e?.browserNotification && e.browserNotification.enabled !== !1 && "Notification" in window && Notification.permission === "default" && typeof Notification.requestPermission == "function" && Notification.requestPermission();
790
+ }, [e?.browserNotification]), g(() => n((e) => {
791
+ let { browserNotification: t, onReady: n, onNewMessage: r, onNewMessageNotification: i, onPresence: o, onError: s, onJoinedThread: c, onLeftThread: l, onMarkedRead: u, onThreadArchived: d, onThreadsList: f } = a.current ?? {};
792
+ switch (e.type) {
793
+ case "ready":
794
+ n?.(e);
795
+ break;
796
+ case "new_message":
797
+ r?.(e);
798
+ break;
799
+ case "new_message_notification":
800
+ i?.(e), t && t.enabled !== !1 && Xe(e, t);
801
+ break;
802
+ case "presence":
803
+ o?.(e);
804
+ break;
805
+ case "error":
806
+ s?.(e);
807
+ break;
808
+ case "joined_thread":
809
+ c?.(e);
810
+ break;
811
+ case "left_thread":
812
+ l?.(e);
813
+ break;
814
+ case "marked_read":
815
+ u?.(e);
816
+ break;
817
+ case "thread_archived":
818
+ d?.(e);
819
+ break;
820
+ case "threads_list":
821
+ f?.(e);
822
+ break;
823
+ }
824
+ }), [n]), i;
825
+ }, Qe = "chunk-reload-timestamp", X = "chunk-reload", $e = 1e4, Z = 2, Q = !1;
826
+ if (!N && typeof window < "u") {
827
827
  try {
828
828
  let e = new URL(window.location.href);
829
- e.searchParams.has(X) && (et = !0, e.searchParams.delete(X), window.history.replaceState(null, "", e.toString()));
829
+ e.searchParams.has(X) && (Q = !0, e.searchParams.delete(X), window.history.replaceState(null, "", e.toString()));
830
830
  } catch {}
831
831
  window.addEventListener("vite:preloadError", (e) => {
832
832
  e.preventDefault();
833
833
  });
834
834
  }
835
- var tt = (e) => {
835
+ var et = (e) => {
836
836
  if (!(e instanceof Error)) return !1;
837
837
  let t = e.message.toLowerCase();
838
838
  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";
839
- }, nt = /import\s*\(\s*(['"])((\w+:(\/?\/?))?[^\s,]+)\1/, rt = (e) => e.toString().match(nt)?.[2] ?? null, it = (e) => {
839
+ }, tt = /import\s*\(\s*(['"])((\w+:(\/?\/?))?[^\s,]+)\1/, nt = (e) => e.toString().match(tt)?.[2] ?? null, rt = (e) => {
840
840
  try {
841
841
  return sessionStorage.getItem(e);
842
842
  } catch {
843
843
  return null;
844
844
  }
845
- }, at = (e, t) => {
845
+ }, it = (e, t) => {
846
846
  try {
847
847
  sessionStorage.setItem(e, t);
848
848
  } catch {}
849
- }, ot = (e) => Function("url", "return import(url)")(e), st = async (e) => {
849
+ }, at = (e) => Function("url", "return import(url)")(e), ot = async (e) => {
850
850
  for (let t = 0; t < Z; t++) try {
851
- return await ot(`${e}?t=${Date.now()}`);
851
+ return await at(`${e}?t=${Date.now()}`);
852
852
  } catch {
853
853
  t < Z - 1 && await new Promise((e) => setTimeout(e, 500 * 2 ** t));
854
854
  }
855
855
  throw Error(`Failed to import ${e} after ${Z} retries`);
856
- }, ct = async () => {
856
+ }, st = async () => {
857
857
  try {
858
858
  if (typeof navigator < "u" && "serviceWorker" in navigator) {
859
859
  let e = await navigator.serviceWorker.getRegistrations();
@@ -864,27 +864,27 @@ var tt = (e) => {
864
864
  await Promise.all(e.map((e) => caches.delete(e)));
865
865
  }
866
866
  } catch {}
867
- }, lt = async () => {
868
- await ct();
867
+ }, ct = async () => {
868
+ await st();
869
869
  let e = new URL(window.location.href);
870
870
  e.searchParams.set(X, String(Date.now())), window.location.replace(e.toString());
871
- }, Q = (e) => e != null && e.default !== void 0, ut = (e) => p(async () => {
871
+ }, lt = (e) => e != null && e.default !== void 0, ut = (e) => p(async () => {
872
872
  let t;
873
873
  try {
874
874
  let n = await e();
875
- if (Q(n)) return n;
875
+ if (lt(n)) return n;
876
876
  t = /* @__PURE__ */ Error("Module resolved without a valid default export");
877
877
  } catch (e) {
878
878
  t = e;
879
879
  }
880
- if (F || !tt(t)) throw t;
881
- let n = rt(e);
880
+ if (N || !et(t)) throw t;
881
+ let n = nt(e);
882
882
  if (n) try {
883
- let e = await st(n);
884
- if (Q(e)) return e;
883
+ let e = await ot(n);
884
+ if (lt(e)) return e;
885
885
  } catch {}
886
- let r = Number(it(Qe) || "0");
887
- return Date.now() - r < $e || et || (at(Qe, String(Date.now())), await lt()), { default: () => null };
886
+ let r = Number(rt(Qe) || "0");
887
+ return Date.now() - r < $e || Q || (it(Qe, String(Date.now())), await ct()), { default: () => null };
888
888
  }), dt = "Page Left", ft = 1800 * 1e3, pt = 1e3, mt = (e, t = !0) => {
889
889
  let n = 0, r = t ? e : null, i = !1, a = (e) => {
890
890
  r !== null && (n += Math.max(0, e - r), r = null);
@@ -931,4 +931,4 @@ var tt = (e) => {
931
931
  return `${n}.${await yt(t, n)}`;
932
932
  };
933
933
  //#endregion
934
- export { ae as AMPLITUDE_FEATURE_SELECTOR, re as AutoReloadOnNewVersion, ee as ChatClient, G as ChatContext, Ee as ChatProvider, c as DEFAULT_OPERATOR_HOURS_PER_DAY, ie as GTMSendPageView, ue as InitializeAmplitude, fe as InitializeAxiosConfig, he as InitializeDaysJSConfig, ge as InitializeHubSpot, _e as InitializeI18nConfig, ve as InitializeSentryConfig, O as InjectDependenciesContext, k as InjectDependenciesProvider, i as MAX_OPERATOR_HOURS_PER_DAY, D as MaskTextField, ft as PAGE_DURATION_CAP_MS, pt as PAGE_DURATION_MIN_MS, dt as PAGE_LEFT_EVENT, je as QueryProvider, be as RequireAuth, V as SENTRY_IGNORED_REQUEST_URLS, z as SENTRY_KEEP_REPLAY, pe as SUPPORTED_LANGUAGE, xe as ShowHubSpotBubble, l as articleNameAdapter, mt as createVisibleStopwatch, q as dateAdapter, vt as decodeToken, J as distanceAdapter, bt as encodeToken, o as findOperatorItem, Y as getCurrentLanguage, n as getOperatorHoursPerDay, u as getOrvalConfig, e as getUnitCount, a as isHourlyLine, s as isOperatorArticle, t as isOperatorRateMissing, r as isOrderedByTheHour, B as isReplayKeptForError, ut as lazyWithRetry, H as matchesRequestUrl, ht as pageLeftProperties, K as shouldRetryQuery, Fe as useAdapter, Ie as useAmplitude, Le as useAuth, Be as useChat, Ve as useCurrentLanguage, qe as useFilters, Ye as useHubSpot, Xe as useInfiniteDataGrid, Ze as useResponseError, Me as worksiteNameAdapter };
934
+ export { A as AMPLITUDE_FEATURE_SELECTOR, ne as AutoReloadOnNewVersion, Ue as ChatClient, Y as ChatContext, Je as ChatProvider, c as DEFAULT_OPERATOR_HOURS_PER_DAY, re as GTMSendPageView, oe as InitializeAmplitude, ce as InitializeAxiosConfig, de as InitializeDaysJSConfig, fe as InitializeHubSpot, pe as InitializeI18nConfig, ge as InitializeSentryConfig, C as InjectDependenciesContext, w as InjectDependenciesProvider, i as MAX_OPERATOR_HOURS_PER_DAY, S as MaskTextField, ft as PAGE_DURATION_CAP_MS, pt as PAGE_DURATION_MIN_MS, dt as PAGE_LEFT_EVENT, we as QueryProvider, ve as RequireAuth, L as SENTRY_IGNORED_REQUEST_URLS, me as SENTRY_KEEP_REPLAY, le as SUPPORTED_LANGUAGE, ye as ShowHubSpotBubble, l as articleNameAdapter, mt as createVisibleStopwatch, H as dateAdapter, vt as decodeToken, U as distanceAdapter, bt as encodeToken, o as findOperatorItem, G as getCurrentLanguage, n as getOperatorHoursPerDay, u as getOrvalConfig, e as getUnitCount, a as isHourlyLine, s as isOperatorArticle, t as isOperatorRateMissing, r as isOrderedByTheHour, he as isReplayKeptForError, ut as lazyWithRetry, R as matchesRequestUrl, ht as pageLeftProperties, V as shouldRetryQuery, De as useAdapter, Oe as useAmplitude, ke as useAuth, Ze as useChat, Ae as useCurrentLanguage, Fe as useFilters, Le as useHubSpot, Re as useInfiniteDataGrid, ze as useResponseError, W as worksiteNameAdapter };