@tracktor/shared-module 2.29.0 → 2.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/types.d.ts +6 -1
- package/dist/main.js +27 -23
- package/dist/main.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/chat/types.d.ts
CHANGED
|
@@ -74,12 +74,16 @@ export interface PresenceEvent {
|
|
|
74
74
|
userId: string;
|
|
75
75
|
online: boolean;
|
|
76
76
|
}
|
|
77
|
+
export interface ThreadArchivedEvent {
|
|
78
|
+
type: "thread_archived";
|
|
79
|
+
threadId: string;
|
|
80
|
+
}
|
|
77
81
|
export interface ErrorEvent {
|
|
78
82
|
type: "error";
|
|
79
83
|
code: string;
|
|
80
84
|
message: string;
|
|
81
85
|
}
|
|
82
|
-
export type ServerEvent = ReadyEvent | JoinedThread | LeftThread | NewMessageEvent | NewMessageNotification | MarkedRead | ThreadsListEvent | PresenceEvent | ErrorEvent;
|
|
86
|
+
export type ServerEvent = ReadyEvent | JoinedThread | LeftThread | NewMessageEvent | NewMessageNotification | MarkedRead | ThreadsListEvent | PresenceEvent | ThreadArchivedEvent | ErrorEvent;
|
|
83
87
|
export interface ChatClientOptions {
|
|
84
88
|
url: string;
|
|
85
89
|
getToken: () => string | null;
|
|
@@ -98,5 +102,6 @@ export interface UseChatParams {
|
|
|
98
102
|
onJoinedThread?: (event: JoinedThread) => void;
|
|
99
103
|
onLeftThread?: (event: LeftThread) => void;
|
|
100
104
|
onMarkedRead?: (event: MarkedRead) => void;
|
|
105
|
+
onThreadArchived?: (event: ThreadArchivedEvent) => void;
|
|
101
106
|
onThreadsList?: (event: ThreadsListEvent) => void;
|
|
102
107
|
}
|
package/dist/main.js
CHANGED
|
@@ -162,13 +162,13 @@ function be() {
|
|
|
162
162
|
switch (typeof r.tag == "number" && console.error(
|
|
163
163
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
164
164
|
), r.$$typeof) {
|
|
165
|
-
case
|
|
165
|
+
case S:
|
|
166
166
|
return "Portal";
|
|
167
167
|
case R:
|
|
168
168
|
return r.displayName || "Context";
|
|
169
169
|
case T:
|
|
170
170
|
return (r._context.displayName || "Context") + ".Consumer";
|
|
171
|
-
case
|
|
171
|
+
case A:
|
|
172
172
|
var p = r.render;
|
|
173
173
|
return r = r.displayName, r || (r = p.displayName || p.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
|
|
174
174
|
case G:
|
|
@@ -332,7 +332,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
332
332
|
function m(r) {
|
|
333
333
|
return typeof r == "object" && r !== null && r.$$typeof === v;
|
|
334
334
|
}
|
|
335
|
-
var y = we, v = /* @__PURE__ */ Symbol.for("react.transitional.element"),
|
|
335
|
+
var y = we, v = /* @__PURE__ */ Symbol.for("react.transitional.element"), S = /* @__PURE__ */ Symbol.for("react.portal"), k = /* @__PURE__ */ Symbol.for("react.fragment"), g = /* @__PURE__ */ Symbol.for("react.strict_mode"), d = /* @__PURE__ */ Symbol.for("react.profiler"), T = /* @__PURE__ */ Symbol.for("react.consumer"), R = /* @__PURE__ */ Symbol.for("react.context"), A = /* @__PURE__ */ Symbol.for("react.forward_ref"), O = /* @__PURE__ */ Symbol.for("react.suspense"), J = /* @__PURE__ */ Symbol.for("react.suspense_list"), G = /* @__PURE__ */ Symbol.for("react.memo"), w = /* @__PURE__ */ Symbol.for("react.lazy"), x = /* @__PURE__ */ Symbol.for("react.activity"), K = /* @__PURE__ */ Symbol.for("react.client.reference"), Y = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, N = Object.prototype.hasOwnProperty, $ = Array.isArray, q = console.createTask ? console.createTask : function() {
|
|
336
336
|
return null;
|
|
337
337
|
};
|
|
338
338
|
y = {
|
|
@@ -487,7 +487,7 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
487
487
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
488
488
|
if (m.isInitialized())
|
|
489
489
|
return null;
|
|
490
|
-
const { createRoutesFromChildren: v, matchRoutes:
|
|
490
|
+
const { createRoutesFromChildren: v, matchRoutes: S, useLocation: k, useNavigationType: g } = y;
|
|
491
491
|
return (u || process.env.NODE_ENV === "prod" || process.env.NODE_ENV === "production") && m.init({
|
|
492
492
|
debug: u,
|
|
493
493
|
dsn: e,
|
|
@@ -504,7 +504,7 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
504
504
|
integrations: [
|
|
505
505
|
m.reactRouterV6BrowserTracingIntegration({
|
|
506
506
|
createRoutesFromChildren: v,
|
|
507
|
-
matchRoutes:
|
|
507
|
+
matchRoutes: S,
|
|
508
508
|
useEffect: L,
|
|
509
509
|
useLocation: k,
|
|
510
510
|
useNavigationType: g
|
|
@@ -522,7 +522,7 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
522
522
|
return;
|
|
523
523
|
const e = (t) => {
|
|
524
524
|
try {
|
|
525
|
-
t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation(), window.location.reload();
|
|
525
|
+
t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation(), sessionStorage.getItem("vite:preloadError:reloaded") || (sessionStorage.setItem("vite:preloadError:reloaded", "true"), window.location.reload());
|
|
526
526
|
} catch {
|
|
527
527
|
}
|
|
528
528
|
};
|
|
@@ -533,13 +533,13 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
533
533
|
const { libraries: a, localStorageKeys: c } = C(j), u = o?.reactRouter || a?.reactRouter, l = o?.axios || a?.axios, f = o?.localStorageKey || c?.user || Ae;
|
|
534
534
|
if (!u)
|
|
535
535
|
throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
536
|
-
const [i, h] = D(null), { useLocation: m, Navigate: y, Outlet: v } = u,
|
|
536
|
+
const [i, h] = D(null), { useLocation: m, Navigate: y, Outlet: v } = u, S = m(), k = typeof t == "function" ? t() : !!t, g = typeof k == "boolean" ? k : k?.isLogged;
|
|
537
537
|
return L(() => {
|
|
538
538
|
fe.has(l) || (fe.set(l, !0), l.interceptors.response.use(
|
|
539
539
|
(d) => d,
|
|
540
540
|
(d) => (typeof d == "object" && d && "response" in d && d.response && typeof d.response == "object" && "status" in d.response && d.response && typeof d.response == "object" && "status" in d.response && d?.response?.status === 401 && (typeof d == "object" && d && "config" in d && d.config && typeof d.config == "object" && "headers" in d.config && d.config.headers && typeof d.config.headers == "object" && "Authorization" in d.config.headers && d.config.headers.Authorization && (l.defaults.headers.common.Authorization = null, typeof window < "u" && window.localStorage && localStorage.removeItem(f)), h(s)), Promise.reject(d))
|
|
541
541
|
));
|
|
542
|
-
}, [l, f, s]), g && !i ? /* @__PURE__ */ I.jsx(Ee, { fallback: e, children:
|
|
542
|
+
}, [l, f, s]), g && !i ? /* @__PURE__ */ I.jsx(Ee, { fallback: e, children: S.state?.from?.state && S.state?.from?.pathname === n ? /* @__PURE__ */ I.jsx(y, { to: S.state.from.state.from.pathname + S.state.from.state.from.search, replace: !0 }) : /* @__PURE__ */ I.jsx(v, {}) }) : /* @__PURE__ */ I.jsx(y, { to: n + S.search, state: { from: S }, replace: !0 });
|
|
543
543
|
}, Ce = (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase(), je = (e) => {
|
|
544
544
|
const t = e.split(/[/\\]/).pop() || "";
|
|
545
545
|
return t.substring(0, t.lastIndexOf("."));
|
|
@@ -611,7 +611,7 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
611
611
|
return null;
|
|
612
612
|
}
|
|
613
613
|
}, me = ge(null), st = ({ children: e, reconnect: t = !0, enabled: n = !0, url: s, token: o }) => {
|
|
614
|
-
const [a, c] = D(!1), [u, l] = D(!1), [f, i] = D(0), { apiURL: h, localStorageKeys: m } = C(j), y = m?.user || Ie, v = X(null),
|
|
614
|
+
const [a, c] = D(!1), [u, l] = D(!1), [f, i] = D(0), { apiURL: h, localStorageKeys: m } = C(j), y = m?.user || Ie, v = X(null), S = X(/* @__PURE__ */ new Set());
|
|
615
615
|
L(() => {
|
|
616
616
|
if (!n)
|
|
617
617
|
return;
|
|
@@ -620,7 +620,7 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
620
620
|
return;
|
|
621
621
|
const x = () => o ?? Le(y), K = (N) => {
|
|
622
622
|
N.type === "ready" && (l(!0), i(N.unreadCount ?? 0));
|
|
623
|
-
for (const $ of
|
|
623
|
+
for (const $ of S.current)
|
|
624
624
|
$(N);
|
|
625
625
|
}, Y = setTimeout(() => {
|
|
626
626
|
const N = new Re({
|
|
@@ -648,15 +648,15 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
648
648
|
v.current?.markRead(w);
|
|
649
649
|
}, []), R = P((w, x) => {
|
|
650
650
|
v.current?.listThreads(w, x);
|
|
651
|
-
}, []),
|
|
651
|
+
}, []), A = P((w = 1) => {
|
|
652
652
|
i((x) => x + w);
|
|
653
653
|
}, []), O = P((w = 1) => {
|
|
654
654
|
i((x) => Math.max(0, x - w));
|
|
655
|
-
}, []), J = P((w) => (
|
|
656
|
-
|
|
655
|
+
}, []), J = P((w) => (S.current.add(w), () => {
|
|
656
|
+
S.current.delete(w);
|
|
657
657
|
}), []), G = {
|
|
658
658
|
decrementUnreadCount: O,
|
|
659
|
-
incrementUnreadCount:
|
|
659
|
+
incrementUnreadCount: A,
|
|
660
660
|
isConnected: a,
|
|
661
661
|
isReady: u,
|
|
662
662
|
joinThread: k,
|
|
@@ -777,7 +777,8 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
777
777
|
onJoinedThread: h,
|
|
778
778
|
onLeftThread: m,
|
|
779
779
|
onMarkedRead: y,
|
|
780
|
-
|
|
780
|
+
onThreadArchived: v,
|
|
781
|
+
onThreadsList: S
|
|
781
782
|
} = o.current ?? {};
|
|
782
783
|
switch (a.type) {
|
|
783
784
|
case "ready":
|
|
@@ -804,9 +805,12 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
804
805
|
case "marked_read":
|
|
805
806
|
y?.(a);
|
|
806
807
|
break;
|
|
807
|
-
case "
|
|
808
|
+
case "thread_archived":
|
|
808
809
|
v?.(a);
|
|
809
810
|
break;
|
|
811
|
+
case "threads_list":
|
|
812
|
+
S?.(a);
|
|
813
|
+
break;
|
|
810
814
|
}
|
|
811
815
|
}), [n]), s;
|
|
812
816
|
}, Q = (e, t) => t === "short" ? e.split("-")[0] : e, ut = (e, t = "full") => {
|
|
@@ -860,13 +864,13 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
860
864
|
), y = (g, d, T = !0) => {
|
|
861
865
|
const R = he(g, e?.pathname || o, f);
|
|
862
866
|
if (!d || Array.isArray(d) && !d.length) {
|
|
863
|
-
i ? (a.delete(g), c(a)) : l((
|
|
864
|
-
const O = { ...
|
|
867
|
+
i ? (a.delete(g), c(a)) : l((A) => {
|
|
868
|
+
const O = { ...A };
|
|
865
869
|
return delete O[g], O;
|
|
866
870
|
}), h && localStorage.removeItem(R);
|
|
867
871
|
return;
|
|
868
872
|
}
|
|
869
|
-
h && T && d && localStorage.setItem(R, JSON.stringify({ ...a, [g]: d })), i && d ? (a.set(g, JSON.stringify(d)), c(a)) : !i && d && l((
|
|
873
|
+
h && T && d && localStorage.setItem(R, JSON.stringify({ ...a, [g]: d })), i && d ? (a.set(g, JSON.stringify(d)), c(a)) : !i && d && l((A) => ({ ...A, [g]: d }));
|
|
870
874
|
};
|
|
871
875
|
return {
|
|
872
876
|
getFilter: (g, d) => {
|
|
@@ -883,8 +887,8 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
883
887
|
const T = he(g, e?.pathname || o, f), R = localStorage.getItem(T);
|
|
884
888
|
if (R)
|
|
885
889
|
try {
|
|
886
|
-
const
|
|
887
|
-
return !i &&
|
|
890
|
+
const A = JSON.parse(R)[g];
|
|
891
|
+
return !i && A !== void 0 && l((O) => ({ ...O, [g]: A })), A;
|
|
888
892
|
} catch {
|
|
889
893
|
}
|
|
890
894
|
}
|
|
@@ -893,7 +897,7 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
893
897
|
getFilters: () => {
|
|
894
898
|
const g = h ? Qe(m()) : {};
|
|
895
899
|
if (i) {
|
|
896
|
-
const d = Array.from(a.entries()).reduce((T, [R,
|
|
900
|
+
const d = Array.from(a.entries()).reduce((T, [R, A]) => (T[R] = pe(A), T), {});
|
|
897
901
|
return {
|
|
898
902
|
...g,
|
|
899
903
|
...d
|
|
@@ -906,7 +910,7 @@ const qe = ({ IMaskMixin: e, ...t }) => {
|
|
|
906
910
|
},
|
|
907
911
|
handleFilter: (g, d) => (T, R) => {
|
|
908
912
|
if (R || Array.isArray(R) && R.length === 0) {
|
|
909
|
-
const
|
|
913
|
+
const A = d || "value", O = typeof R == "object" && A in R ? R[A] : R;
|
|
910
914
|
y(g, O);
|
|
911
915
|
return;
|
|
912
916
|
}
|
package/dist/main.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(g,L){typeof exports=="object"&&typeof module<"u"?L(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],L):(g=typeof globalThis<"u"?globalThis:g||self,L(g["@tracktor/shared-module"]={},g.axios,g.React))})(this,(function(g,L,l){"use strict";const ge=(e,t)=>{const
|
|
1
|
+
(function(g,L){typeof exports=="object"&&typeof module<"u"?L(exports,require("axios"),require("react")):typeof define=="function"&&define.amd?define(["exports","axios","react"],L):(g=typeof globalThis<"u"?globalThis:g||self,L(g["@tracktor/shared-module"]={},g.axios,g.React))})(this,(function(g,L,l){"use strict";const ge=(e,t)=>{const n=L.CancelToken.source(),s=L({...e,...t,cancelToken:n.token}).then(({data:o})=>o);return s.cancel=()=>{n.cancel("Query was cancelled")},s},Q=e=>Array.isArray(e)?e.map(Q):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.replace(/_([a-z])/g,(s,o)=>o.toUpperCase()),Q(n)])):e,J=e=>Array.isArray(e)?e.map(J):e!==null&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t.replace(/[A-Z]/g,s=>`_${s.toLowerCase()}`),J(n)])):e;class ee{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("?")?"&":"?",s=`${this.url}${n}token=${t}`;this.ws=new WebSocket(s),this.ws.onopen=()=>{this._connected=!0,this.reconnectAttempt=0,this.onConnectionChange?.(!0),this.rejoinThreads(),this.flushPendingMessages()},this.ws.onmessage=o=>{try{const a=JSON.parse(o.data),c=Q(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(J(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 W={exports:{}},M={};var te;function me(){if(te)return M;te=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(s,o,a){var c=null;if(a!==void 0&&(c=""+a),o.key!==void 0&&(c=""+o.key),"key"in o){a={};for(var d in o)d!=="key"&&(a[d]=o[d])}else a=o;return o=a.ref,{$$typeof:e,type:s,key:c,ref:o!==void 0?o:null,props:a}}return M.Fragment=t,M.jsx=n,M.jsxs=n,M}var Y={};var re;function ye(){return re||(re=1,process.env.NODE_ENV!=="production"&&(function(){function e(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===X?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case P:return"Fragment";case f:return"Profiler";case y:return"StrictMode";case N:return"Suspense";case B:return"SuspenseList";case O: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 A:return"Portal";case R:return r.displayName||"Context";case S:return(r._context.displayName||"Context")+".Consumer";case k:var p=r.render;return r=r.displayName,r||(r=p.displayName||p.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case H:return p=r.displayName||null,p!==null?p:e(r.type)||"Memo";case w:p=r._payload,r=r._init;try{return e(r(p))}catch{}}return null}function t(r){return""+r}function n(r){try{t(r);var p=!1}catch{p=!0}if(p){p=console;var C=p.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&r[Symbol.toStringTag]||r.constructor.name||"Object";return C.call(p,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),t(r)}}function s(r){if(r===P)return"<>";if(typeof r=="object"&&r!==null&&r.$$typeof===w)return"<...>";try{var p=e(r);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function o(){var r=z.A;return r===null?null:r.getOwner()}function a(){return Error("react-stack-top-frame")}function c(r){if(x.call(r,"key")){var p=Object.getOwnPropertyDescriptor(r,"key").get;if(p&&p.isReactWarning)return!1}return r.key!==void 0}function d(r,p){function C(){ue||(ue=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",p))}C.isReactWarning=!0,Object.defineProperty(r,"key",{get:C,configurable:!0})}function u(){var r=e(this.type);return de[r]||(de[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 h(r,p,C,b,V,q){var T=C.ref;return r={$$typeof:_,type:r,key:p,props:C,_owner:b},(T!==void 0?T:null)!==null?Object.defineProperty(r,"ref",{enumerable:!1,get:u}):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:V}),Object.defineProperty(r,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:q}),Object.freeze&&(Object.freeze(r.props),Object.freeze(r)),r}function i(r,p,C,b,V,q){var T=p.children;if(T!==void 0)if(b)if(F(T)){for(b=0;b<T.length;b++)m(T[b]);Object.freeze&&Object.freeze(T)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(T);if(x.call(p,"key")){T=e(r);var D=Object.keys(p).filter(function(rt){return rt!=="key"});b=0<D.length?"{key: someKey, "+D.join(": ..., ")+": ...}":"{key: someKey}",pe[T+b]||(D=0<D.length?"{"+D.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,b,T,D,T),pe[T+b]=!0)}if(T=null,C!==void 0&&(r(C),T=""+C),c(p)&&(r(p.key),T=""+p.key),"key"in p){C={};for(var $ in p)$!=="key"&&(C[$]=p[$])}else C=p;return T&&d(C,typeof n=="function"?n.displayName||n.name||"Unknown":n),h(n,T,C,o(),V,q)}function m(n){E(n)?n._store&&(n._store.validated=1):typeof n=="object"&&n!==null&&n.$$typeof===v&&(n._payload.status==="fulfilled"?E(n._payload.value)&&n._payload.value._store&&(n._payload.value._store.validated=1):n._store&&(n._store.validated=1))}function E(n){return typeof n=="object"&&n!==null&&n.$$typeof===_}var w=l,_=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),R=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),X=Symbol.for("react.client.reference"),z=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,x=Object.prototype.hasOwnProperty,F=Array.isArray,Z=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(n){return n()}};var ue,de={},fe=w.react_stack_bottom_frame.bind(w,a)(),he=Z(s(a)),pe={};Y.Fragment=P,Y.jsx=function(n,p,C){var b=1e4>z.recentlyCreatedOwnerStacks++;return i(n,p,C,!1,b?Error("react-stack-top-frame"):fe,b?Z(s(n)):he)},Y.jsxs=function(n,p,C){var b=1e4>z.recentlyCreatedOwnerStacks++;return i(n,p,C,!0,b?Error("react-stack-top-frame"):fe,b?Z(s(n)):he)}})()),Y}var re;function Ee(){return re||(re=1,process.env.NODE_ENV==="production"?W.exports=me():W.exports=ye()),W.exports}var I=Ee();const we=({IMaskMixin:e,...t})=>{const r=l.useMemo(()=>e(({TextField:s,...o})=>I.jsx(s,{...o})),[e]);return I.jsx(r,{...t})},j=l.createContext({}),ve=({children:e,apiURL:t,libraries:r,localStorageKeys:s})=>{const o=l.useMemo(()=>({apiURL:t,libraries:r,localStorageKeys:s}),[t,r,s]);return I.jsx(j.Provider,{value:o,children:e})},Ce=({data:e,...t})=>{const{libraries:r}=l.useContext(j),s=t?.reactRouter||r?.reactRouter,o=t?.gtm||r?.gtm;if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!o)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:a}=o,{useLocation:c,Outlet:d}=s,{pathname:u}=c(),{sendEvent:h}=a();return l.useEffect(()=>{h({event:"pageView",pathname:u,...e})},[e,u,h]),I.jsx(d,{})},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}})(),_e="user",Re=({tokenTypeKey:e="tokenType",tokenKey:t="accessToken",postContentType:r="application/json",...s})=>{const{apiURL:o=s.apiURL,libraries:a,localStorageKeys:c}=l.useContext(j),d=s?.userLocalStorageKey||c?.user||_e,u=s?.axios||a?.axios;if(!u)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!u?.defaults||U)return null;if(typeof window<"u"&&window.localStorage){const h=localStorage.getItem(d),i=h?JSON.parse(h):null,m=i?.[e]?i[e]:null,E=i?.[t]?i[t]:null,w=h?`${m} ${E}`:null;w&&(u.defaults.headers.common.Authorization=w)}return u.defaults.baseURL=o,u.defaults.headers.post["Content-Type"]=r,null},be=({language:e,...t})=>{const{libraries:r}=l.useContext(j),s=t?.dayjs||r?.dayjs,o=t?.plugin||r?.dayjsPlugin;if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return l.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";o&&o.forEach(d=>{d&&s.extend(d)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),s.locale(c)})().then()},[s,o,e]),null},Te=({debug:e,resources:t,...r})=>{const{libraries:s}=l.useContext(j),o=r?.i18||s?.i18,{i18next:a,initReactI18next:c,languageDetector:d}=o||{};if(U)return null;if(!o)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return a?.isInitialized||(a.use(d).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:t,returnNull:!1}).then(()=>{document.documentElement.lang!==a.resolvedLanguage&&a.resolvedLanguage&&document.documentElement.setAttribute("lang",a.resolvedLanguage)}),a.on("languageChanged",u=>{document.documentElement.setAttribute("lang",u)})),null},Se=({dsn:e,integrations:t,tracesSampleRate:r,replaysSessionSampleRate:s,replaysOnErrorSampleRate:o,tracePropagationTargets:a,ignoreErrors:c,debug:d,environment:u,release:h,...i})=>{const{libraries:m}=l.useContext(j),E=i?.sentry||m?.sentry,w=i?.reactRouter||m?.reactRouter;if(!E)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!w)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(E.isInitialized())return null;const{createRoutesFromChildren:_,matchRoutes:k,useLocation:P,useNavigationType:y}=w;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&E.init({debug:d,dsn:e,environment:u||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[E.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:_,matchRoutes:k,useEffect:l.useEffect,useLocation:P,useNavigationType:y}),...t||[]],release:h,replaysOnErrorSampleRate:o||1,replaysSessionSampleRate:s||.1,tracePropagationTargets:a,tracesSampleRate:r||1}),null},Ae=()=>(l.useEffect(()=>{if(U)return;const e=t=>{try{t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),window.location.reload()}catch{}};return window.addEventListener("vite:preloadError",e),()=>{window.removeEventListener("vite:preloadError",e)}},[]),null),oe=new WeakMap,ke="user",je=({Fallback:e,isLogged:t,loginPath:r="/login",redirect401Path:s="/login",...o})=>{const{libraries:a,localStorageKeys:c}=l.useContext(j),d=o?.reactRouter||a?.reactRouter,u=o?.axios||a?.axios,h=o?.localStorageKey||c?.user||ke;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,m]=l.useState(null),{useLocation:E,Navigate:w,Outlet:_}=d,k=E(),P=typeof t=="function"?t():!!t,y=typeof P=="boolean"?P:P?.isLogged;return l.useEffect(()=>{oe.has(u)||(oe.set(u,!0),u.interceptors.response.use(f=>f,f=>(typeof f=="object"&&f&&"response"in f&&f.response&&typeof f.response=="object"&&"status"in f.response&&f.response&&typeof f.response=="object"&&"status"in f.response&&f?.response?.status===401&&(typeof f=="object"&&f&&"config"in f&&f.config&&typeof f.config=="object"&&"headers"in f.config&&f.config.headers&&typeof f.config.headers=="object"&&"Authorization"in f.config.headers&&f.config.headers.Authorization&&(u.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(h)),m(s)),Promise.reject(f))))},[u,h,s]),y&&!i?I.jsx(l.Suspense,{fallback:e,children:k.state?.from?.state&&k.state?.from?.pathname===r?I.jsx(w,{to:k.state.from.state.from.pathname+k.state.from.state.from.search,replace:!0}):I.jsx(_,{})}):I.jsx(w,{to:r+k.search,state:{from:k},replace:!0})},Pe=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Oe=e=>{const t=e.split(/[/\\]/).pop()||"";return t.substring(0,t.lastIndexOf("."))},Ie=e=>{const s=e.split("/").filter(o=>o.length>0).map(o=>o.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join("")).join("");return s.charAt(0).toLowerCase()+s.slice(1)},Ne=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),xe=(e,t,r,s)=>{const o=Ie(t),a=Pe(r),c=`${o}${a}`;return e&&typeof e=="object"&&"operationId"in e&&s?.includes(String(e.operationId))?`${c}AsQuery`:c},Le=(e,t)=>{const r={};return e?.forEach(s=>{r[s]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),t?.filter(s=>!r[s]).forEach(s=>{r[s]={query:{useQuery:!0}}}),Object.keys(r).length?r:void 0},Fe=e=>(Array.isArray(e)?e:[e]).reduce((r,s)=>{const{output:o,useInfiniteIds:a,useQueryIds:c,input:d="./openapi.json",customAxiosInstancePath:u,overrideApiName:h}=s||{},i=h||Ne(d),m=u||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...r,[i]:{input:d,output:{baseUrl:o?.baseUrl,client:"react-query",mode:"tags-split",override:{...(a?.length||c?.length)&&{operations:Le(a,c)},header:E=>["Generated by orval 🍺",...E.title?[E.title]:[],...E.description?[E.description]:[]],mutator:{name:Oe(m),path:m},operationName:(E,w,_)=>xe(E,w,_,c),query:{useQuery:!0}},schemas:o?.schemas||`src/api/${i}/model`,target:o?.target||`src/api/${i}/services/api.ts`,...o}}}},{}),De="user",Me=e=>{const t=e.startsWith("https")?"wss":"ws",r=e.replace(/^https?:\/\//,"");return`${t}://${r}/v2/threads/ws`},Ye=e=>{try{const t=localStorage.getItem(e);return t?JSON.parse(t)?.accessToken??null:null}catch{return null}},K=l.createContext(null),Ue=({children:e,reconnect:t=!0,enabled:r=!0,url:s,token:o})=>{const[a,c]=l.useState(!1),[d,u]=l.useState(!1),[h,i]=l.useState(0),{apiURL:m,localStorageKeys:E}=l.useContext(j),w=E?.user||De,_=l.useRef(null),k=l.useRef(new Set);l.useEffect(()=>{if(!r)return;const v=s||(m?Me(m):null);if(!v)return;const O=()=>o??Ye(w),X=x=>{x.type==="ready"&&(u(!0),i(x.unreadCount??0));for(const F of k.current)F(x)},z=setTimeout(()=>{const x=new ee({getToken:O,onConnectionChange:F=>{c(F),F||u(!1)},onEvent:X,reconnect:t,url:v});_.current=x,x.connect()},0);return()=>{clearTimeout(z),_.current?.disconnect(),_.current=null}},[r,s,o,m,t,w]);const P=l.useCallback(v=>{_.current?.joinThread(v)},[]),y=l.useCallback(v=>{_.current?.leaveThread(v)},[]),f=l.useCallback((v,O)=>{_.current?.sendMessage(v,O)},[]),S=l.useCallback(v=>{_.current?.markRead(v)},[]),R=l.useCallback((v,O)=>{_.current?.listThreads(v,O)},[]),A=l.useCallback((v=1)=>{i(O=>O+v)},[]),N=l.useCallback((v=1)=>{i(O=>Math.max(0,O-v))},[]),B=l.useCallback(v=>(k.current.add(v),()=>{k.current.delete(v)}),[]),H={decrementUnreadCount:N,incrementUnreadCount:A,isConnected:a,isReady:d,joinThread:P,leaveThread:y,listThreads:R,markRead:S,sendMessage:f,subscribe:B,unreadCount:h};return I.jsx(K.Provider,{value:H,children:e})},ze=e=>e&&typeof e=="function",We=e=>e&&typeof e=="function",Ge=({children:e,defaultQueriesOptions:t,defaultMutationsOptions:r,...s})=>{const{libraries:o}=l.useContext(j),a=s?.QueryClient||o?.reactQuery?.QueryClient,c=s?.QueryClientProvider||o?.reactQuery?.QueryClientProvider;if(!a)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!c)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!ze(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!We(a))throw new Error("Provided QueryClient dependencies are not valid.");const d=new a({defaultOptions:{mutations:{...r},queries:{getNextPageParam:(u,h,i)=>u.length+(i||0),refetchOnWindowFocus:!1,retry:3,...t}}});return I.jsx(c,{client:d,children:e})},se=({library:e,date:t,format:r="ll"})=>e(t).format(r),ae=(e,t)=>{const{fractionDigits:r=0,metric:s="km",spacingBetween:o=!0}=t||{},a=Number(e),c=o?" ":"";return Number.isNaN(a)?`0${c}${s}`:`${a.toFixed(r)}${c}${s}`},ie=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(r=>r.length>0?r.charAt(0).toUpperCase()+r.slice(1):r).join(" "),Ve=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Qe=({path:e,size:t,apiURL:r})=>{if(!e)return"";const s=Ve(e),o=`${r}${s}`,a=o.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof t=="number"&&a?`${o.replace("/files",`/thumbs/${t}`)}`:o},Je=e=>{const{apiURL:t,libraries:r}=l.useContext(j),s=e?.dayjs||r?.dayjs;return{dateAdapter:(c,d)=>{if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return se({date:c,format:d,library:s})},distanceAdapter:ae,filePathAdapter:(c,d)=>{if(!t)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return typeof c=="string"&&/^https?:\/\//.test(c)?c:Qe({apiURL:t,path:c,size:d})},worksiteNameAdapter:ie}},Ke=e=>{const{libraries:t,localStorageKeys:r}=l.useContext(j),s=e?.axios||t?.axios,o=e?.localStorageKey||r?.user||"user";if(!s)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const a=l.useCallback(({tokenType:d,accessToken:u})=>{s.defaults.headers.common.Authorization=`${d} ${u}`},[s.defaults.headers.common]),c=()=>{s.defaults.headers.common.Authorization=null};return l.useEffect(()=>{if(U)return;const d=({newValue:u,key:h})=>{if(h===o&&u)try{const{accessToken:i,tokenType:m}=JSON.parse(u);a({accessToken:i,tokenType:m})}catch(i){console.error("Failed to parse newValue from localStorage:",i)}};return window.addEventListener("storage",d),()=>{window.removeEventListener("storage",d)}},[o,a]),{clearAuthenticationToken:c,setAuthenticationToken:a}},Be=e=>{const t=l.useContext(K);if(!t)throw new Error("useChat must be used within ChatProvider");const{subscribe:r,...s}=t,o=l.useRef(e);return o.current=e,l.useEffect(()=>r(a=>{const{onReady:c,onNewMessage:d,onNewMessageNotification:u,onPresence:h,onError:i,onJoinedThread:m,onLeftThread:E,onMarkedRead:w,onThreadsList:_}=o.current??{};switch(a.type){case"ready":c?.(a);break;case"new_message":d?.(a);break;case"new_message_notification":u?.(a);break;case"presence":h?.(a);break;case"error":i?.(a);break;case"joined_thread":m?.(a);break;case"left_thread":E?.(a);break;case"marked_read":w?.(a);break;case"threads_list":_?.(a);break}}),[r]),s},G=(e,t)=>t==="short"?e.split("-")[0]:e,He=(e,t="full")=>{const[r,s]=l.useState(()=>{const o=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,G(o,t)});return l.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&s(G(e.language,t));const o=a=>{s(G(a,t))};return e?.on?.("languageChanged",o),()=>{e?.off?.("languageChanged",o)}},[e,t]),r},Xe="tracktor.filter",Ze={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},ce=e=>{try{return JSON.parse(e)}catch{return e}},le=(e,t,r)=>`${r}_${e}=>${t}`,qe=e=>e.reduce((t,r)=>{const s=localStorage.getItem(r);if(s)try{const o=JSON.parse(s),a=Object.keys(o)?.[0];a&&(t[a]=Object.values(o)?.[0])}catch{}return t},{}),$e=e=>{const{libraries:t,localStorageKeys:r}=l.useContext(j),s=e?.reactRouter||t?.reactRouter,{pathname:o}=s?.useLocation?.()??{pathname:"/"},[a,c]=s?.useSearchParams?.()??[new URLSearchParams,()=>{}],[d,u]=l.useState({}),h=r?.filter||Xe,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,m=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(U)return Ze;if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const E=()=>Object.keys(localStorage).filter(y=>y.startsWith(h)&&y.endsWith(e?.pathname||o)),w=(y,f,S=!0)=>{const R=le(y,e?.pathname||o,h);if(!f||Array.isArray(f)&&!f.length){i?(a.delete(y),c(a)):u(A=>{const N={...A};return delete N[y],N}),m&&localStorage.removeItem(R);return}m&&S&&f&&localStorage.setItem(R,JSON.stringify({...a,[y]:f})),i&&f?(a.set(y,JSON.stringify(f)),c(a)):!i&&f&&u(A=>({...A,[y]:f}))};return{getFilter:(y,f)=>{if(i){const S=a.get(y);if(S)return ce(S)}else{const S=d[y];if(S!==void 0)return S}if(m){const S=le(y,e?.pathname||o,h),R=localStorage.getItem(S);if(R)try{const A=JSON.parse(R)[y];return!i&&A!==void 0&&u(N=>({...N,[y]:A})),A}catch{}}return f},getFilters:()=>{const y=m?qe(E()):{};if(i){const f=Array.from(a.entries()).reduce((S,[R,A])=>(S[R]=ce(A),S),{});return{...y,...f}}return{...y,...d}},handleFilter:(y,f)=>(S,R)=>{if(R||Array.isArray(R)&&R.length===0){const A=f||"value",N=typeof R=="object"&&A in R?R[A]:R;w(y,N);return}w(y,void 0)},setFilter:w}},et=({data:e,fetchNextPage:t,isFetchingNextPage:r,isInitialLoading:s,isLoading:o,enabled:a=!0})=>{const c=l.useCallback(async u=>{r||!a||await t({pageParam:u?.pageParam||u.visibleRowsCount})},[a,t,r]),d=l.useMemo(()=>{if(e)return e.pages.reduce((u,h)=>[...u,...h],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:r||o,loadingVariant:s?"skeleton":"linear-progress",rows:d}},tt=e=>{const{libraries:t}=l.useContext(j),r=e?.i18||t?.i18,s=e?.i18?.translateFunction||t?.i18?.translateFunction,o=r?.i18next?.t||s||(h=>h),{unknownErrorTranslationKey:a="error.unknownError"}=e||{},c=o(a),d=l.useCallback(h=>{if(h&&typeof h=="object"&&"response"in h){const{response:i}=h||{};if(i&&typeof i=="object"&&"reason"in i&&i.reason)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data&&i.data.reason)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data&&i.data.message)return String(i.data.message);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"detail"in i.data){const{detail:m}=i.data;if(Array.isArray(m)&&m.length>0&&typeof m[0]=="object"&&m[0]!==null&&"msg"in m[0]){const{msg:E}=m[0];if(typeof E=="string")return String(E)}}}return h instanceof Error?h.message:c},[c]);return{getErrorCode:l.useCallback(h=>{const{response:i}=h||{};return i?.error_code?String(i?.error_code):i?.data?.error_code?String(i?.data?.error_code):i?.error_code?String(i?.error_code):i?.data?.error_code?String(i.data.error_code):"unknown_error_code"},[]),printError:d}};g.ChatClient=ee,g.ChatContext=K,g.ChatProvider=Ue,g.GTMSendPageView=Ce,g.InitializeAxiosConfig=Re,g.InitializeDaysJSConfig=be,g.InitializeI18nConfig=Te,g.InitializeSentryConfig=Se,g.InjectDependenciesContext=j,g.InjectDependenciesProvider=ve,g.MaskTextField=we,g.PreloadErrorHandler=Ae,g.QueryClientProviderWithConfig=Ge,g.RequireAuth=je,g.axiosCustomInstance=ge,g.dateAdapter=se,g.distanceAdapter=ae,g.getOrvalConfig=Fe,g.useAdapter=Je,g.useAuth=Ke,g.useChat=Be,g.useCurrentLanguage=He,g.useFilters=$e,g.useInfiniteDataGrid=et,g.useResponseError=tt,g.worksiteNameAdapter=ie,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
<%s key={someKey} {...props} />`,b,T,D,T),pe[T+b]=!0)}if(T=null,C!==void 0&&(n(C),T=""+C),c(p)&&(n(p.key),T=""+p.key),"key"in p){C={};for(var $ in p)$!=="key"&&(C[$]=p[$])}else C=p;return T&&d(C,typeof r=="function"?r.displayName||r.name||"Unknown":r),h(r,T,C,o(),V,q)}function m(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===_}var v=l,_=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),R=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),X=Symbol.for("react.client.reference"),z=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,x=Object.prototype.hasOwnProperty,F=Array.isArray,Z=console.createTask?console.createTask:function(){return null};v={react_stack_bottom_frame:function(r){return r()}};var ue,de={},fe=v.react_stack_bottom_frame.bind(v,a)(),he=Z(s(a)),pe={};Y.Fragment=P,Y.jsx=function(r,p,C){var b=1e4>z.recentlyCreatedOwnerStacks++;return i(r,p,C,!1,b?Error("react-stack-top-frame"):fe,b?Z(s(r)):he)},Y.jsxs=function(r,p,C){var b=1e4>z.recentlyCreatedOwnerStacks++;return i(r,p,C,!0,b?Error("react-stack-top-frame"):fe,b?Z(s(r)):he)}})()),Y}var ne;function Ee(){return ne||(ne=1,process.env.NODE_ENV==="production"?W.exports=me():W.exports=ye()),W.exports}var I=Ee();const ve=({IMaskMixin:e,...t})=>{const n=l.useMemo(()=>e(({TextField:s,...o})=>I.jsx(s,{...o})),[e]);return I.jsx(n,{...t})},j=l.createContext({}),we=({children:e,apiURL:t,libraries:n,localStorageKeys:s})=>{const o=l.useMemo(()=>({apiURL:t,libraries:n,localStorageKeys:s}),[t,n,s]);return I.jsx(j.Provider,{value:o,children:e})},Ce=({data:e,...t})=>{const{libraries:n}=l.useContext(j),s=t?.reactRouter||n?.reactRouter,o=t?.gtm||n?.gtm;if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!o)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:a}=o,{useLocation:c,Outlet:d}=s,{pathname:u}=c(),{sendEvent:h}=a();return l.useEffect(()=>{h({event:"pageView",pathname:u,...e})},[e,u,h]),I.jsx(d,{})},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}})(),_e="user",Re=({tokenTypeKey:e="tokenType",tokenKey:t="accessToken",postContentType:n="application/json",...s})=>{const{apiURL:o=s.apiURL,libraries:a,localStorageKeys:c}=l.useContext(j),d=s?.userLocalStorageKey||c?.user||_e,u=s?.axios||a?.axios;if(!u)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!u?.defaults||U)return null;if(typeof window<"u"&&window.localStorage){const h=localStorage.getItem(d),i=h?JSON.parse(h):null,m=i?.[e]?i[e]:null,E=i?.[t]?i[t]:null,v=h?`${m} ${E}`:null;v&&(u.defaults.headers.common.Authorization=v)}return u.defaults.baseURL=o,u.defaults.headers.post["Content-Type"]=n,null},be=({language:e,...t})=>{const{libraries:n}=l.useContext(j),s=t?.dayjs||n?.dayjs,o=t?.plugin||n?.dayjsPlugin;if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return l.useEffect(()=>{(async()=>{const c=e||navigator.language?.slice(0,2)||"en";o&&o.forEach(d=>{d&&s.extend(d)}),await import("dayjs/locale/en"),await import("dayjs/locale/fr"),s.locale(c)})().then()},[s,o,e]),null},Te=({debug:e,resources:t,...n})=>{const{libraries:s}=l.useContext(j),o=n?.i18||s?.i18,{i18next:a,initReactI18next:c,languageDetector:d}=o||{};if(U)return null;if(!o)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return a?.isInitialized||(a.use(d).use(c).init({debug:e,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:"languageChanged loaded",useSuspense:!0},resources:t,returnNull:!1}).then(()=>{document.documentElement.lang!==a.resolvedLanguage&&a.resolvedLanguage&&document.documentElement.setAttribute("lang",a.resolvedLanguage)}),a.on("languageChanged",u=>{document.documentElement.setAttribute("lang",u)})),null},Se=({dsn:e,integrations:t,tracesSampleRate:n,replaysSessionSampleRate:s,replaysOnErrorSampleRate:o,tracePropagationTargets:a,ignoreErrors:c,debug:d,environment:u,release:h,...i})=>{const{libraries:m}=l.useContext(j),E=i?.sentry||m?.sentry,v=i?.reactRouter||m?.reactRouter;if(!E)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!v)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(E.isInitialized())return null;const{createRoutesFromChildren:_,matchRoutes:A,useLocation:P,useNavigationType:y}=v;return(d||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&E.init({debug:d,dsn:e,environment:u||"production",ignoreErrors:[...c||[],/dynamically imported module/,/Cannot read properties of undefined \(reading 'default'\)/,/Loading chunk \d+ failed/,/ChunkLoadError/,/Failed to fetch dynamically imported module/,/vite:preloadError/],integrations:[E.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:_,matchRoutes:A,useEffect:l.useEffect,useLocation:P,useNavigationType:y}),...t||[]],release:h,replaysOnErrorSampleRate:o||1,replaysSessionSampleRate:s||.1,tracePropagationTargets:a,tracesSampleRate:n||1}),null},Ae=()=>(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),oe=new WeakMap,ke="user",je=({Fallback:e,isLogged:t,loginPath:n="/login",redirect401Path:s="/login",...o})=>{const{libraries:a,localStorageKeys:c}=l.useContext(j),d=o?.reactRouter||a?.reactRouter,u=o?.axios||a?.axios,h=o?.localStorageKey||c?.user||ke;if(!d)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[i,m]=l.useState(null),{useLocation:E,Navigate:v,Outlet:_}=d,A=E(),P=typeof t=="function"?t():!!t,y=typeof P=="boolean"?P:P?.isLogged;return l.useEffect(()=>{oe.has(u)||(oe.set(u,!0),u.interceptors.response.use(f=>f,f=>(typeof f=="object"&&f&&"response"in f&&f.response&&typeof f.response=="object"&&"status"in f.response&&f.response&&typeof f.response=="object"&&"status"in f.response&&f?.response?.status===401&&(typeof f=="object"&&f&&"config"in f&&f.config&&typeof f.config=="object"&&"headers"in f.config&&f.config.headers&&typeof f.config.headers=="object"&&"Authorization"in f.config.headers&&f.config.headers.Authorization&&(u.defaults.headers.common.Authorization=null,typeof window<"u"&&window.localStorage&&localStorage.removeItem(h)),m(s)),Promise.reject(f))))},[u,h,s]),y&&!i?I.jsx(l.Suspense,{fallback:e,children:A.state?.from?.state&&A.state?.from?.pathname===n?I.jsx(v,{to:A.state.from.state.from.pathname+A.state.from.state.from.search,replace:!0}):I.jsx(_,{})}):I.jsx(v,{to:n+A.search,state:{from:A},replace:!0})},Pe=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Oe=e=>{const t=e.split(/[/\\]/).pop()||"";return t.substring(0,t.lastIndexOf("."))},Ie=e=>{const s=e.split("/").filter(o=>o.length>0).map(o=>o.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join("")).join("");return s.charAt(0).toLowerCase()+s.slice(1)},Ne=e=>(e.split("/").pop()||e).replace(/\.json$/,"").replace(/^openapi\./,""),xe=(e,t,n,s)=>{const o=Ie(t),a=Pe(n),c=`${o}${a}`;return e&&typeof e=="object"&&"operationId"in e&&s?.includes(String(e.operationId))?`${c}AsQuery`:c},Le=(e,t)=>{const n={};return e?.forEach(s=>{n[s]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}}}),t?.filter(s=>!n[s]).forEach(s=>{n[s]={query:{useQuery:!0}}}),Object.keys(n).length?n:void 0},Fe=e=>(Array.isArray(e)?e:[e]).reduce((n,s)=>{const{output:o,useInfiniteIds:a,useQueryIds:c,input:d="./openapi.json",customAxiosInstancePath:u,overrideApiName:h}=s||{},i=h||Ne(d),m=u||"./node_modules/@tracktor/shared-module/dist/axiosCustomInstance.ts";return{...n,[i]:{input:d,output:{baseUrl:o?.baseUrl,client:"react-query",mode:"tags-split",override:{...(a?.length||c?.length)&&{operations:Le(a,c)},header:E=>["Generated by orval 🍺",...E.title?[E.title]:[],...E.description?[E.description]:[]],mutator:{name:Oe(m),path:m},operationName:(E,v,_)=>xe(E,v,_,c),query:{useQuery:!0}},schemas:o?.schemas||`src/api/${i}/model`,target:o?.target||`src/api/${i}/services/api.ts`,...o}}}},{}),De="user",Me=e=>{const t=e.startsWith("https")?"wss":"ws",n=e.replace(/^https?:\/\//,"");return`${t}://${n}/v2/threads/ws`},Ye=e=>{try{const t=localStorage.getItem(e);return t?JSON.parse(t)?.accessToken??null:null}catch{return null}},K=l.createContext(null),Ue=({children:e,reconnect:t=!0,enabled:n=!0,url:s,token:o})=>{const[a,c]=l.useState(!1),[d,u]=l.useState(!1),[h,i]=l.useState(0),{apiURL:m,localStorageKeys:E}=l.useContext(j),v=E?.user||De,_=l.useRef(null),A=l.useRef(new Set);l.useEffect(()=>{if(!n)return;const w=s||(m?Me(m):null);if(!w)return;const O=()=>o??Ye(v),X=x=>{x.type==="ready"&&(u(!0),i(x.unreadCount??0));for(const F of A.current)F(x)},z=setTimeout(()=>{const x=new ee({getToken:O,onConnectionChange:F=>{c(F),F||u(!1)},onEvent:X,reconnect:t,url:w});_.current=x,x.connect()},0);return()=>{clearTimeout(z),_.current?.disconnect(),_.current=null}},[n,s,o,m,t,v]);const P=l.useCallback(w=>{_.current?.joinThread(w)},[]),y=l.useCallback(w=>{_.current?.leaveThread(w)},[]),f=l.useCallback((w,O)=>{_.current?.sendMessage(w,O)},[]),S=l.useCallback(w=>{_.current?.markRead(w)},[]),R=l.useCallback((w,O)=>{_.current?.listThreads(w,O)},[]),k=l.useCallback((w=1)=>{i(O=>O+w)},[]),N=l.useCallback((w=1)=>{i(O=>Math.max(0,O-w))},[]),B=l.useCallback(w=>(A.current.add(w),()=>{A.current.delete(w)}),[]),H={decrementUnreadCount:N,incrementUnreadCount:k,isConnected:a,isReady:d,joinThread:P,leaveThread:y,listThreads:R,markRead:S,sendMessage:f,subscribe:B,unreadCount:h};return I.jsx(K.Provider,{value:H,children:e})},ze=e=>e&&typeof e=="function",We=e=>e&&typeof e=="function",Ge=({children:e,defaultQueriesOptions:t,defaultMutationsOptions:n,...s})=>{const{libraries:o}=l.useContext(j),a=s?.QueryClient||o?.reactQuery?.QueryClient,c=s?.QueryClientProvider||o?.reactQuery?.QueryClientProvider;if(!a)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!c)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!ze(c))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!We(a))throw new Error("Provided QueryClient dependencies are not valid.");const d=new a({defaultOptions:{mutations:{...n},queries:{getNextPageParam:(u,h,i)=>u.length+(i||0),refetchOnWindowFocus:!1,retry:3,...t}}});return I.jsx(c,{client:d,children:e})},se=({library:e,date:t,format:n="ll"})=>e(t).format(n),ae=(e,t)=>{const{fractionDigits:n=0,metric:s="km",spacingBetween:o=!0}=t||{},a=Number(e),c=o?" ":"";return Number.isNaN(a)?`0${c}${s}`:`${a.toFixed(n)}${c}${s}`},ie=e=>!e||typeof e!="string"?"":e.replace(/_/g," ").toLowerCase().split(" ").map(n=>n.length>0?n.charAt(0).toUpperCase()+n.slice(1):n).join(" "),Ve=e=>e?.startsWith("/")?e?.startsWith("/files")?e:`/files${e}`:e?.startsWith("files")?`/${e}`:`/files/${e}`,Qe=({path:e,size:t,apiURL:n})=>{if(!e)return"";const s=Ve(e),o=`${n}${s}`,a=o.match(/\.(jpeg|jpg|png|gif|bmp|webp|svg|avif)$/)!==null;return typeof t=="number"&&a?`${o.replace("/files",`/thumbs/${t}`)}`:o},Je=e=>{const{apiURL:t,libraries:n}=l.useContext(j),s=e?.dayjs||n?.dayjs;return{dateAdapter:(c,d)=>{if(!s)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return se({date:c,format:d,library:s})},distanceAdapter:ae,filePathAdapter:(c,d)=>{if(!t)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return typeof c=="string"&&/^https?:\/\//.test(c)?c:Qe({apiURL:t,path:c,size:d})},worksiteNameAdapter:ie}},Ke=e=>{const{libraries:t,localStorageKeys:n}=l.useContext(j),s=e?.axios||t?.axios,o=e?.localStorageKey||n?.user||"user";if(!s)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");const a=l.useCallback(({tokenType:d,accessToken:u})=>{s.defaults.headers.common.Authorization=`${d} ${u}`},[s.defaults.headers.common]),c=()=>{s.defaults.headers.common.Authorization=null};return l.useEffect(()=>{if(U)return;const d=({newValue:u,key:h})=>{if(h===o&&u)try{const{accessToken:i,tokenType:m}=JSON.parse(u);a({accessToken:i,tokenType:m})}catch(i){console.error("Failed to parse newValue from localStorage:",i)}};return window.addEventListener("storage",d),()=>{window.removeEventListener("storage",d)}},[o,a]),{clearAuthenticationToken:c,setAuthenticationToken:a}},Be=e=>{const t=l.useContext(K);if(!t)throw new Error("useChat must be used within ChatProvider");const{subscribe:n,...s}=t,o=l.useRef(e);return o.current=e,l.useEffect(()=>n(a=>{const{onReady:c,onNewMessage:d,onNewMessageNotification:u,onPresence:h,onError:i,onJoinedThread:m,onLeftThread:E,onMarkedRead:v,onThreadArchived:_,onThreadsList:A}=o.current??{};switch(a.type){case"ready":c?.(a);break;case"new_message":d?.(a);break;case"new_message_notification":u?.(a);break;case"presence":h?.(a);break;case"error":i?.(a);break;case"joined_thread":m?.(a);break;case"left_thread":E?.(a);break;case"marked_read":v?.(a);break;case"thread_archived":_?.(a);break;case"threads_list":A?.(a);break}}),[n]),s},G=(e,t)=>t==="short"?e.split("-")[0]:e,He=(e,t="full")=>{const[n,s]=l.useState(()=>{const o=e?.language||navigator.language;return e&&"isInitialized"in e&&e.isInitialized,G(o,t)});return l.useEffect(()=>{e&&"isInitialized"in e&&e.isInitialized&&e.language&&s(G(e.language,t));const o=a=>{s(G(a,t))};return e?.on?.("languageChanged",o),()=>{e?.off?.("languageChanged",o)}},[e,t]),n},Xe="tracktor.filter",Ze={getFilter:()=>{},getFilters:()=>({}),handleFilter:()=>()=>{},setFilter:()=>{}},ce=e=>{try{return JSON.parse(e)}catch{return e}},le=(e,t,n)=>`${n}_${e}=>${t}`,qe=e=>e.reduce((t,n)=>{const s=localStorage.getItem(n);if(s)try{const o=JSON.parse(s),a=Object.keys(o)?.[0];a&&(t[a]=Object.values(o)?.[0])}catch{}return t},{}),$e=e=>{const{libraries:t,localStorageKeys:n}=l.useContext(j),s=e?.reactRouter||t?.reactRouter,{pathname:o}=s?.useLocation?.()??{pathname:"/"},[a,c]=s?.useSearchParams?.()??[new URLSearchParams,()=>{}],[d,u]=l.useState({}),h=n?.filter||Xe,i=e?.syncWithUrl===void 0?!0:e?.syncWithUrl,m=e?.persistToLocalStorage===void 0?!0:e?.persistToLocalStorage;if(U)return Ze;if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of reactRouter.");const E=()=>Object.keys(localStorage).filter(y=>y.startsWith(h)&&y.endsWith(e?.pathname||o)),v=(y,f,S=!0)=>{const R=le(y,e?.pathname||o,h);if(!f||Array.isArray(f)&&!f.length){i?(a.delete(y),c(a)):u(k=>{const N={...k};return delete N[y],N}),m&&localStorage.removeItem(R);return}m&&S&&f&&localStorage.setItem(R,JSON.stringify({...a,[y]:f})),i&&f?(a.set(y,JSON.stringify(f)),c(a)):!i&&f&&u(k=>({...k,[y]:f}))};return{getFilter:(y,f)=>{if(i){const S=a.get(y);if(S)return ce(S)}else{const S=d[y];if(S!==void 0)return S}if(m){const S=le(y,e?.pathname||o,h),R=localStorage.getItem(S);if(R)try{const k=JSON.parse(R)[y];return!i&&k!==void 0&&u(N=>({...N,[y]:k})),k}catch{}}return f},getFilters:()=>{const y=m?qe(E()):{};if(i){const f=Array.from(a.entries()).reduce((S,[R,k])=>(S[R]=ce(k),S),{});return{...y,...f}}return{...y,...d}},handleFilter:(y,f)=>(S,R)=>{if(R||Array.isArray(R)&&R.length===0){const k=f||"value",N=typeof R=="object"&&k in R?R[k]:R;v(y,N);return}v(y,void 0)},setFilter:v}},et=({data:e,fetchNextPage:t,isFetchingNextPage:n,isInitialLoading:s,isLoading:o,enabled:a=!0})=>{const c=l.useCallback(async u=>{n||!a||await t({pageParam:u?.pageParam||u.visibleRowsCount})},[a,t,n]),d=l.useMemo(()=>{if(e)return e.pages.reduce((u,h)=>[...u,...h],[])},[e]);return{fetchNextPageOnRowsScrollEnd:c,isLoading:n||o,loadingVariant:s?"skeleton":"linear-progress",rows:d}},tt=e=>{const{libraries:t}=l.useContext(j),n=e?.i18||t?.i18,s=e?.i18?.translateFunction||t?.i18?.translateFunction,o=n?.i18next?.t||s||(h=>h),{unknownErrorTranslationKey:a="error.unknownError"}=e||{},c=o(a),d=l.useCallback(h=>{if(h&&typeof h=="object"&&"response"in h){const{response:i}=h||{};if(i&&typeof i=="object"&&"reason"in i&&i.reason)return String(i.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"reason"in i.data&&i.data.reason)return String(i.data.reason);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"message"in i.data&&i.data.message)return String(i.data.message);if(i&&typeof i=="object"&&"data"in i&&i.data&&typeof i.data=="object"&&"detail"in i.data){const{detail:m}=i.data;if(Array.isArray(m)&&m.length>0&&typeof m[0]=="object"&&m[0]!==null&&"msg"in m[0]){const{msg:E}=m[0];if(typeof E=="string")return String(E)}}}return h instanceof Error?h.message:c},[c]);return{getErrorCode:l.useCallback(h=>{const{response:i}=h||{};return i?.error_code?String(i?.error_code):i?.data?.error_code?String(i?.data?.error_code):i?.error_code?String(i?.error_code):i?.data?.error_code?String(i.data.error_code):"unknown_error_code"},[]),printError:d}};g.ChatClient=ee,g.ChatContext=K,g.ChatProvider=Ue,g.GTMSendPageView=Ce,g.InitializeAxiosConfig=Re,g.InitializeDaysJSConfig=be,g.InitializeI18nConfig=Te,g.InitializeSentryConfig=Se,g.InjectDependenciesContext=j,g.InjectDependenciesProvider=we,g.MaskTextField=ve,g.PreloadErrorHandler=Ae,g.QueryClientProviderWithConfig=Ge,g.RequireAuth=je,g.axiosCustomInstance=ge,g.dateAdapter=se,g.distanceAdapter=ae,g.getOrvalConfig=Fe,g.useAdapter=Je,g.useAuth=Ke,g.useChat=Be,g.useCurrentLanguage=He,g.useFilters=$e,g.useInfiniteDataGrid=et,g.useResponseError=tt,g.worksiteNameAdapter=ie,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|