@tracktor/shared-module 2.0.0-beta.11 → 2.0.0-beta.12
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/CHANGELOG.md
CHANGED
|
@@ -10,7 +10,7 @@ export interface useAdapterParams {
|
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
12
|
export declare const useAdapter: (params?: useAdapterParams) => {
|
|
13
|
-
dateAdapter: (date: string | number | Date | null | undefined, format
|
|
13
|
+
dateAdapter: (date: string | number | Date | null | undefined, format: string) => string;
|
|
14
14
|
distanceAdapter: (distance?: string | number | null | undefined, metric?: string) => string;
|
|
15
15
|
filePathAdapter: (path: string, size?: number | "full") => string;
|
|
16
16
|
};
|
package/dist/main.js
CHANGED
|
@@ -854,7 +854,7 @@ const A = dt({}), xt = ({ children: r, apiURL: n, libraries: i }) => {
|
|
|
854
854
|
i.defaults.headers.common.Authorization = `${d} ${v}`;
|
|
855
855
|
}
|
|
856
856
|
};
|
|
857
|
-
}, pt = ({ library: r, date: n, format: i }) => r(n).format(i), wt = (r, n = "km") => {
|
|
857
|
+
}, pt = ({ library: r, date: n, format: i = "ll" }) => r(n).format(i), wt = (r, n = "km") => {
|
|
858
858
|
const i = Number(r);
|
|
859
859
|
return Number.isNaN(i) ? `0 ${n}` : `${i.toFixed(2)} ${n}`;
|
|
860
860
|
}, _t = (r) => r != null && r.startsWith("/") ? r != null && r.startsWith("/files") ? r : `/files${r}` : r != null && r.startsWith("files") ? `/${r}` : r != null && r.startsWith("files") ? `/${r}` : `/files/${r}`, Ct = ({ path: r, size: n, apiURL: i }) => {
|
|
@@ -863,7 +863,7 @@ const A = dt({}), xt = ({ children: r, apiURL: n, libraries: i }) => {
|
|
|
863
863
|
}, zt = (r) => {
|
|
864
864
|
const { apiURL: n, libraries: i } = k(A), a = (r == null ? void 0 : r.dayjs) || (i == null ? void 0 : i.dayjs);
|
|
865
865
|
return {
|
|
866
|
-
dateAdapter: (v, c
|
|
866
|
+
dateAdapter: (v, c) => {
|
|
867
867
|
if (!a)
|
|
868
868
|
throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");
|
|
869
869
|
return pt({
|
package/dist/main.umd.cjs
CHANGED
|
@@ -24,4 +24,4 @@ Check the top-level render call using <`+o+">.")}return t}}function ke(e,t){{if(
|
|
|
24
24
|
*
|
|
25
25
|
* This source code is licensed under the MIT license found in the
|
|
26
26
|
* LICENSE file in the root directory of this source tree.
|
|
27
|
-
*/var le;function Le(){if(le)return G;le=1;var r=m,n=Symbol.for("react.element"),i=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function v(c,s,h){var R,_={},C=null,u=null;h!==void 0&&(C=""+h),s.key!==void 0&&(C=""+s.key),s.ref!==void 0&&(u=s.ref);for(R in s)a.call(s,R)&&!d.hasOwnProperty(R)&&(_[R]=s[R]);if(c&&c.defaultProps)for(R in s=c.defaultProps,s)_[R]===void 0&&(_[R]=s[R]);return{$$typeof:n,type:c,key:C,ref:u,props:_,_owner:l.current}}return G.Fragment=i,G.jsx=v,G.jsxs=v,G}process.env.NODE_ENV==="production"?ee.exports=Le():ee.exports=Ne();var F=ee.exports;const A=m.createContext({}),Me=({children:r,apiURL:n,libraries:i})=>{const a=m.useMemo(()=>({apiURL:n,libraries:i}),[n,i]);return F.jsx(A.Provider,{value:a,children:r})},ze=({Fallback:r,isLogged:n,loginPath:i="/login",localStorageKey:a="user",redirect401Path:l="/login",...d})=>{var b,N,L,M;const{libraries:v}=m.useContext(A),c=(d==null?void 0:d.axios)||(v==null?void 0:v.axios),s=(d==null?void 0:d.reactRouter)||(v==null?void 0:v.reactRouter);if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!c)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[h,R]=m.useState(null),{useLocation:_,Navigate:C,Outlet:u}=s,S=_(),I=m.useRef(!1),O=typeof n=="function"?n():!!n,k=typeof O=="boolean"?O:O==null?void 0:O.isLogged;return m.useEffect(()=>{I.current||(I.current=!0,c==null||c.interceptors.response.use(j=>j,async j=>{var Q;return typeof j=="object"&&j&&"response"in j&&j.response&&typeof j.response=="object"&&"status"in j.response&&j.response&&typeof j.response=="object"&&"status"in j.response&&((Q=j==null?void 0:j.response)==null?void 0:Q.status)===401&&(c.defaults.headers.common.Authorization=null,localStorage.removeItem(a),R(l)),Promise.reject(j)}))},[c==null?void 0:c.defaults.headers.common,c==null?void 0:c.interceptors.response,a,l]),k&&!h?F.jsx(m.Suspense,{fallback:r,children:(N=(b=S.state)==null?void 0:b.from)!=null&&N.state&&((M=(L=S.state)==null?void 0:L.from)==null?void 0:M.pathname)===i?F.jsx(C,{to:S.state.from.state.from.pathname+S.state.from.state.from.search,replace:!0}):F.jsx(u,{})}):F.jsx(C,{to:i,state:{from:S},replace:!0})},Ve=({...r})=>{const{libraries:n}=m.useContext(A),i=(r==null?void 0:r.reactRouter)||(n==null?void 0:n.reactRouter),a=(r==null?void 0:r.gtm)||(n==null?void 0:n.gtm);if(!i)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!a)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:l}=a,{useLocation:d,Outlet:v}=i,{pathname:c}=d(),{sendEvent:s}=l();return m.useEffect(()=>{s({event:"pageView",pathname:c})},[c,s]),F.jsx(v,{})},Ue=({tokenTypeKey:r="tokenType",userLocalStorageKey:n="user",tokenKey:i="accessToken",postContentType:a="application/json",...l})=>{const{apiURL:d=l.apiURL,libraries:v}=m.useContext(A),c=(l==null?void 0:l.axios)||(v==null?void 0:v.axios);if(!c)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!(c!=null&&c.defaults))return null;const s=localStorage.getItem(n),h=s?JSON.parse(s):null,R=h!=null&&h[r]?h[r]:null,_=h!=null&&h[i]?h[i]:null,C=s?`${R} ${_}`:null;return c.defaults.baseURL=d,c.defaults.headers.post["Content-Type"]=a,C&&(c.defaults.headers.common.Authorization=C),null},Be=({debug:r,resources:n,...i})=>{const{libraries:a}=m.useContext(A),l=(i==null?void 0:i.i18)||(a==null?void 0:a.i18),{i18next:d,initReactI18next:v,languageDetector:c}=l||{};if(!l)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return d!=null&&d.isInitialized||(d.use(c).use(v).init({debug:r,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:!1,useSuspense:!0},resources:n,returnNull:!1}).then(()=>{document.documentElement.lang!==d.resolvedLanguage&&d.resolvedLanguage&&document.documentElement.setAttribute("lang",d.resolvedLanguage)}),d.on("languageChanged",s=>{document.documentElement.setAttribute("lang",s)})),null},Ge=({dsn:r,integrations:n,tracesSampleRate:i,replaysSessionSampleRate:a,replaysOnErrorSampleRate:l,tracePropagationTargets:d,ignoreErrors:v,debug:c,environment:s,...h})=>{const{libraries:R}=m.useContext(A),_=(h==null?void 0:h.sentry)||(R==null?void 0:R.sentry),C=(h==null?void 0:h.reactRouter)||(R==null?void 0:R.reactRouter);if(!_)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!C)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(_.isInitialized())return null;const{createRoutesFromChildren:u,matchRoutes:S,useLocation:I,useNavigationType:O}=C;return(c||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&_.init({debug:c,dsn:r,environment:s||"production",ignoreErrors:[...v||[],/dynamically imported module/],integrations:[_.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:u,matchRoutes:S,useEffect:m.useEffect,useLocation:I,useNavigationType:O}),...n||[]],replaysOnErrorSampleRate:l||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:d,tracesSampleRate:i||1}),null},Qe=({IMaskMixin:r,...n})=>{const i=m.useMemo(()=>r(({TextField:a,...l})=>F.jsx(a,{...l})),[r]);return F.jsx(i,{...n})},Je=({accessToken:r,...n})=>{const{libraries:i}=m.useContext(A),a=(n==null?void 0:n.mapbox)||(i==null?void 0:i.mapbox);if(!a)throw new Error("Mapbox is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return r&&(a.accessToken=r),null},Xe=({language:r,...n})=>{const{libraries:i}=m.useContext(A),a=(n==null?void 0:n.dayjs)||(i==null?void 0:i.dayjs),l=(n==null?void 0:n.dayjsPlugin)||(i==null?void 0:i.dayjsPlugin);if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return m.useEffect(()=>{(async()=>{var c;const v=r||((c=navigator.language)==null?void 0:c.slice(0,2))||"en";l&&l.forEach(s=>{s&&typeof s=="object"&&"default"in s&&a.extend(s.default)}),a.locale(v)})().then()},[a,l,r]),null},He=r=>r&&typeof r=="function",Ke=r=>r&&typeof r=="function",Ze=({children:r,defaultQueriesOptions:n,defaultMutationsOptions:i,...a})=>{var s,h;const{libraries:l}=m.useContext(A),d=(a==null?void 0:a.QueryClient)||((s=l==null?void 0:l.reactQuery)==null?void 0:s.QueryClient),v=(a==null?void 0:a.QueryClientProvider)||((h=l==null?void 0:l.reactQuery)==null?void 0:h.QueryClientProvider);if(!d)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!v)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!He(v))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ke(d))throw new Error("Provided QueryClient dependencies are not valid.");const c=new d({defaultOptions:{mutations:{...i},queries:{getNextPageParam:(R,_,C)=>R.length+(C||0),refetchOnWindowFocus:!1,retry:3,...n}}});return F.jsx(v,{client:c,children:r})},$e=r=>{var h,R,_;const{libraries:n}=m.useContext(A),i=(r==null?void 0:r.i18)||(n==null?void 0:n.i18),a=((h=r==null?void 0:r.i18)==null?void 0:h.translateFunction)||((R=n==null?void 0:n.i18)==null?void 0:R.translateFunction),l=((_=i==null?void 0:i.i18next)==null?void 0:_.t)||a||(C=>C),{unknownErrorTranslationKey:d="error.unknownError"}=r||{},v=l(d),c=m.useCallback(C=>{var S,I,O,k,b,N,L,M,j;const{response:u}=C||{};return u!=null&&u.reason?String(u.reason):(S=u==null?void 0:u.data)!=null&&S.reason?String(u.data.reason):(I=u==null?void 0:u.data)!=null&&I.message?String(u.data.message):(k=(O=u==null?void 0:u.data)==null?void 0:O.detail)!=null&&k.length&&Array.isArray((b=u==null?void 0:u.data)==null?void 0:b.detail)&&((L=(N=u==null?void 0:u.data)==null?void 0:N.detail[0])!=null&&L.msg)&&typeof((j=(M=u==null?void 0:u.data)==null?void 0:M.detail[0])==null?void 0:j.msg)=="string"?String(u.data.detail[0].msg):v},[v]);return{getErrorCode:m.useCallback(C=>{var S,I,O;const{response:u}=C||{};return u!=null&&u.error_code?String(u==null?void 0:u.error_code):(S=u==null?void 0:u.data)!=null&&S.error_code?String((I=u==null?void 0:u.data)==null?void 0:I.error_code):u!=null&&u.error_code?String(u==null?void 0:u.error_code):(O=u==null?void 0:u.data)!=null&&O.error_code?String(u.data.error_code):"unknown_error_code"},[]),printError:c}},qe=({data:r,fetchNextPage:n,isFetchingNextPage:i,isInitialLoading:a,isLoading:l,enabled:d=!0})=>{const v=m.useCallback(async s=>{i||!d||await n({pageParam:(s==null?void 0:s.pageParam)||s.visibleRowsCount})},[d,n,i]),c=m.useMemo(()=>{if(r)return r.pages.reduce((s,h)=>[...s,...h],[])},[r]);return{fetchNextPageOnRowsScrollEnd:v,isLoading:i||l,loadingVariant:a?"skeleton":"linear",rows:c}},et=r=>{const{libraries:n}=m.useContext(A),i=(r==null?void 0:r.axios)||(n==null?void 0:n.axios);if(!i)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");return{clearAuthenticationToken:()=>{i.defaults.headers.common.Authorization=null},setAuthenticationToken:({tokenType:d,accessToken:v})=>{i.defaults.headers.common.Authorization=`${d} ${v}`}}},fe=({library:r,date:n,format:i})=>r(n).format(i),de=(r,n="km")=>{const i=Number(r);return Number.isNaN(i)?`0 ${n}`:`${i.toFixed(2)} ${n}`},tt=r=>r!=null&&r.startsWith("/")?r!=null&&r.startsWith("/files")?r:`/files${r}`:r!=null&&r.startsWith("files")?`/${r}`:r!=null&&r.startsWith("files")?`/${r}`:`/files/${r}`,rt=({path:r,size:n,apiURL:i})=>{const a=tt(r),l=`${i}${a}`;return typeof n=="number"?`${l.replace("/files",`/thumbs/${n}`)}`:l},nt=r=>{const{apiURL:n,libraries:i}=m.useContext(A),a=(r==null?void 0:r.dayjs)||(i==null?void 0:i.dayjs);return{dateAdapter:(v,c="ll")=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return fe({date:v,format:c,library:a})},distanceAdapter:de,filePathAdapter:(v,c)=>{if(!n)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return rt({apiURL:n,path:v,size:c})}}},ot=r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase(),it=r=>{const a=r.split("/").filter(l=>l.length>0).map(l=>l.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join("")).join("");return a.charAt(0).toLowerCase()+a.slice(1)},at=(r,n,i)=>{const a=it(n),l=ot(i);return`${a}${l}`},ut=r=>{if(r)return(r==null?void 0:r.reduce((n,i)=>(n[i]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}},n),{}))||{}},ct=r=>{const{input:n="./openapi.json",operationsToGenerateInfiniteQueryHook:i=void 0}=r||{};return{api:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:n,output:{client:"react-query",mode:"tags-split",override:{header:a=>["Generated by orval 🍺",...a.title?[a.title]:[],...a.description?[a.description]:[]],mutator:{name:"axiosCustomInstance",path:`${__dirname}/config/orval/mutator/axiosCustomInstance.ts`},operationName:at,...(i==null?void 0:i.length)&&{operations:ut(i)},query:{useQuery:!0}},schemas:"src/api/model",target:"src/api/services/api.ts"}}}};w.GTMSendPageView=Ve,w.InitializeAxiosConfig=Ue,w.InitializeDaysJSConfig=Xe,w.InitializeI18nConfig=Be,w.InitializeMapBoxConfig=Je,w.InitializeSentryConfig=Ge,w.InjectDependenciesContext=A,w.InjectDependenciesProvider=Me,w.MaskTextField=Qe,w.QueryClientProviderWithConfig=Ze,w.RequireAuth=ze,w.dateAdapter=fe,w.distanceAdapter=de,w.getOrvalConfig=ct,w.useAdapter=nt,w.useAuth=et,w.useInfiniteDataGrid=qe,w.useResponseError=$e,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
|
27
|
+
*/var le;function Le(){if(le)return G;le=1;var r=m,n=Symbol.for("react.element"),i=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function v(c,s,h){var R,_={},C=null,u=null;h!==void 0&&(C=""+h),s.key!==void 0&&(C=""+s.key),s.ref!==void 0&&(u=s.ref);for(R in s)a.call(s,R)&&!d.hasOwnProperty(R)&&(_[R]=s[R]);if(c&&c.defaultProps)for(R in s=c.defaultProps,s)_[R]===void 0&&(_[R]=s[R]);return{$$typeof:n,type:c,key:C,ref:u,props:_,_owner:l.current}}return G.Fragment=i,G.jsx=v,G.jsxs=v,G}process.env.NODE_ENV==="production"?ee.exports=Le():ee.exports=Ne();var F=ee.exports;const A=m.createContext({}),Me=({children:r,apiURL:n,libraries:i})=>{const a=m.useMemo(()=>({apiURL:n,libraries:i}),[n,i]);return F.jsx(A.Provider,{value:a,children:r})},ze=({Fallback:r,isLogged:n,loginPath:i="/login",localStorageKey:a="user",redirect401Path:l="/login",...d})=>{var b,N,L,M;const{libraries:v}=m.useContext(A),c=(d==null?void 0:d.axios)||(v==null?void 0:v.axios),s=(d==null?void 0:d.reactRouter)||(v==null?void 0:v.reactRouter);if(!s)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!c)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");const[h,R]=m.useState(null),{useLocation:_,Navigate:C,Outlet:u}=s,S=_(),I=m.useRef(!1),O=typeof n=="function"?n():!!n,k=typeof O=="boolean"?O:O==null?void 0:O.isLogged;return m.useEffect(()=>{I.current||(I.current=!0,c==null||c.interceptors.response.use(j=>j,async j=>{var Q;return typeof j=="object"&&j&&"response"in j&&j.response&&typeof j.response=="object"&&"status"in j.response&&j.response&&typeof j.response=="object"&&"status"in j.response&&((Q=j==null?void 0:j.response)==null?void 0:Q.status)===401&&(c.defaults.headers.common.Authorization=null,localStorage.removeItem(a),R(l)),Promise.reject(j)}))},[c==null?void 0:c.defaults.headers.common,c==null?void 0:c.interceptors.response,a,l]),k&&!h?F.jsx(m.Suspense,{fallback:r,children:(N=(b=S.state)==null?void 0:b.from)!=null&&N.state&&((M=(L=S.state)==null?void 0:L.from)==null?void 0:M.pathname)===i?F.jsx(C,{to:S.state.from.state.from.pathname+S.state.from.state.from.search,replace:!0}):F.jsx(u,{})}):F.jsx(C,{to:i,state:{from:S},replace:!0})},Ve=({...r})=>{const{libraries:n}=m.useContext(A),i=(r==null?void 0:r.reactRouter)||(n==null?void 0:n.reactRouter),a=(r==null?void 0:r.gtm)||(n==null?void 0:n.gtm);if(!i)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");if(!a)throw new Error("GTM is not provided. You can provide it with InjectDependenciesProvider or directly in props of GTMSendPageView.");const{useGoogleTagManager:l}=a,{useLocation:d,Outlet:v}=i,{pathname:c}=d(),{sendEvent:s}=l();return m.useEffect(()=>{s({event:"pageView",pathname:c})},[c,s]),F.jsx(v,{})},Ue=({tokenTypeKey:r="tokenType",userLocalStorageKey:n="user",tokenKey:i="accessToken",postContentType:a="application/json",...l})=>{const{apiURL:d=l.apiURL,libraries:v}=m.useContext(A),c=(l==null?void 0:l.axios)||(v==null?void 0:v.axios);if(!c)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!(c!=null&&c.defaults))return null;const s=localStorage.getItem(n),h=s?JSON.parse(s):null,R=h!=null&&h[r]?h[r]:null,_=h!=null&&h[i]?h[i]:null,C=s?`${R} ${_}`:null;return c.defaults.baseURL=d,c.defaults.headers.post["Content-Type"]=a,C&&(c.defaults.headers.common.Authorization=C),null},Be=({debug:r,resources:n,...i})=>{const{libraries:a}=m.useContext(A),l=(i==null?void 0:i.i18)||(a==null?void 0:a.i18),{i18next:d,initReactI18next:v,languageDetector:c}=l||{};if(!l)throw new Error("i18 is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return d!=null&&d.isInitialized||(d.use(c).use(v).init({debug:r,fallbackLng:"en",interpolation:{escapeValue:!1},load:"languageOnly",react:{bindI18n:!1,useSuspense:!0},resources:n,returnNull:!1}).then(()=>{document.documentElement.lang!==d.resolvedLanguage&&d.resolvedLanguage&&document.documentElement.setAttribute("lang",d.resolvedLanguage)}),d.on("languageChanged",s=>{document.documentElement.setAttribute("lang",s)})),null},Ge=({dsn:r,integrations:n,tracesSampleRate:i,replaysSessionSampleRate:a,replaysOnErrorSampleRate:l,tracePropagationTargets:d,ignoreErrors:v,debug:c,environment:s,...h})=>{const{libraries:R}=m.useContext(A),_=(h==null?void 0:h.sentry)||(R==null?void 0:R.sentry),C=(h==null?void 0:h.reactRouter)||(R==null?void 0:R.reactRouter);if(!_)throw new Error("Sentry is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!C)throw new Error("React Router is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(_.isInitialized())return null;const{createRoutesFromChildren:u,matchRoutes:S,useLocation:I,useNavigationType:O}=C;return(c||process.env.NODE_ENV==="prod"||process.env.NODE_ENV==="production")&&_.init({debug:c,dsn:r,environment:s||"production",ignoreErrors:[...v||[],/dynamically imported module/],integrations:[_.reactRouterV6BrowserTracingIntegration({createRoutesFromChildren:u,matchRoutes:S,useEffect:m.useEffect,useLocation:I,useNavigationType:O}),...n||[]],replaysOnErrorSampleRate:l||1,replaysSessionSampleRate:a||.1,tracePropagationTargets:d,tracesSampleRate:i||1}),null},Qe=({IMaskMixin:r,...n})=>{const i=m.useMemo(()=>r(({TextField:a,...l})=>F.jsx(a,{...l})),[r]);return F.jsx(i,{...n})},Je=({accessToken:r,...n})=>{const{libraries:i}=m.useContext(A),a=(n==null?void 0:n.mapbox)||(i==null?void 0:i.mapbox);if(!a)throw new Error("Mapbox is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return r&&(a.accessToken=r),null},Xe=({language:r,...n})=>{const{libraries:i}=m.useContext(A),a=(n==null?void 0:n.dayjs)||(i==null?void 0:i.dayjs),l=(n==null?void 0:n.dayjsPlugin)||(i==null?void 0:i.dayjsPlugin);if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props of InitializeDaysJSConfig.");return m.useEffect(()=>{(async()=>{var c;const v=r||((c=navigator.language)==null?void 0:c.slice(0,2))||"en";l&&l.forEach(s=>{s&&typeof s=="object"&&"default"in s&&a.extend(s.default)}),a.locale(v)})().then()},[a,l,r]),null},He=r=>r&&typeof r=="function",Ke=r=>r&&typeof r=="function",Ze=({children:r,defaultQueriesOptions:n,defaultMutationsOptions:i,...a})=>{var s,h;const{libraries:l}=m.useContext(A),d=(a==null?void 0:a.QueryClient)||((s=l==null?void 0:l.reactQuery)==null?void 0:s.QueryClient),v=(a==null?void 0:a.QueryClientProvider)||((h=l==null?void 0:l.reactQuery)==null?void 0:h.QueryClientProvider);if(!d)throw new Error("QueryClient is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!v)throw new Error("QueryClientProvider is not provided. You can provide it with InjectDependenciesProvider or directly in props.");if(!He(v))throw new Error("Provided QueryClientProvider dependencies are not valid.");if(!Ke(d))throw new Error("Provided QueryClient dependencies are not valid.");const c=new d({defaultOptions:{mutations:{...i},queries:{getNextPageParam:(R,_,C)=>R.length+(C||0),refetchOnWindowFocus:!1,retry:3,...n}}});return F.jsx(v,{client:c,children:r})},$e=r=>{var h,R,_;const{libraries:n}=m.useContext(A),i=(r==null?void 0:r.i18)||(n==null?void 0:n.i18),a=((h=r==null?void 0:r.i18)==null?void 0:h.translateFunction)||((R=n==null?void 0:n.i18)==null?void 0:R.translateFunction),l=((_=i==null?void 0:i.i18next)==null?void 0:_.t)||a||(C=>C),{unknownErrorTranslationKey:d="error.unknownError"}=r||{},v=l(d),c=m.useCallback(C=>{var S,I,O,k,b,N,L,M,j;const{response:u}=C||{};return u!=null&&u.reason?String(u.reason):(S=u==null?void 0:u.data)!=null&&S.reason?String(u.data.reason):(I=u==null?void 0:u.data)!=null&&I.message?String(u.data.message):(k=(O=u==null?void 0:u.data)==null?void 0:O.detail)!=null&&k.length&&Array.isArray((b=u==null?void 0:u.data)==null?void 0:b.detail)&&((L=(N=u==null?void 0:u.data)==null?void 0:N.detail[0])!=null&&L.msg)&&typeof((j=(M=u==null?void 0:u.data)==null?void 0:M.detail[0])==null?void 0:j.msg)=="string"?String(u.data.detail[0].msg):v},[v]);return{getErrorCode:m.useCallback(C=>{var S,I,O;const{response:u}=C||{};return u!=null&&u.error_code?String(u==null?void 0:u.error_code):(S=u==null?void 0:u.data)!=null&&S.error_code?String((I=u==null?void 0:u.data)==null?void 0:I.error_code):u!=null&&u.error_code?String(u==null?void 0:u.error_code):(O=u==null?void 0:u.data)!=null&&O.error_code?String(u.data.error_code):"unknown_error_code"},[]),printError:c}},qe=({data:r,fetchNextPage:n,isFetchingNextPage:i,isInitialLoading:a,isLoading:l,enabled:d=!0})=>{const v=m.useCallback(async s=>{i||!d||await n({pageParam:(s==null?void 0:s.pageParam)||s.visibleRowsCount})},[d,n,i]),c=m.useMemo(()=>{if(r)return r.pages.reduce((s,h)=>[...s,...h],[])},[r]);return{fetchNextPageOnRowsScrollEnd:v,isLoading:i||l,loadingVariant:a?"skeleton":"linear",rows:c}},et=r=>{const{libraries:n}=m.useContext(A),i=(r==null?void 0:r.axios)||(n==null?void 0:n.axios);if(!i)throw new Error("Axios is not provided. You can provide it with InjectDependenciesProvider or directly in params of useAuth.");return{clearAuthenticationToken:()=>{i.defaults.headers.common.Authorization=null},setAuthenticationToken:({tokenType:d,accessToken:v})=>{i.defaults.headers.common.Authorization=`${d} ${v}`}}},fe=({library:r,date:n,format:i="ll"})=>r(n).format(i),de=(r,n="km")=>{const i=Number(r);return Number.isNaN(i)?`0 ${n}`:`${i.toFixed(2)} ${n}`},tt=r=>r!=null&&r.startsWith("/")?r!=null&&r.startsWith("/files")?r:`/files${r}`:r!=null&&r.startsWith("files")?`/${r}`:r!=null&&r.startsWith("files")?`/${r}`:`/files/${r}`,rt=({path:r,size:n,apiURL:i})=>{const a=tt(r),l=`${i}${a}`;return typeof n=="number"?`${l.replace("/files",`/thumbs/${n}`)}`:l},nt=r=>{const{apiURL:n,libraries:i}=m.useContext(A),a=(r==null?void 0:r.dayjs)||(i==null?void 0:i.dayjs);return{dateAdapter:(v,c)=>{if(!a)throw new Error("Dayjs is not provided. You can provide it with InjectDependenciesProvider or directly in props.");return fe({date:v,format:c,library:a})},distanceAdapter:de,filePathAdapter:(v,c)=>{if(!n)throw new Error("API URL is not provided. You can provide it with InjectDependenciesProvider or directly in props to filePathAdapter.");return rt({apiURL:n,path:v,size:c})}}},ot=r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase(),it=r=>{const a=r.split("/").filter(l=>l.length>0).map(l=>l.replace(/\${([^}]*)}/g,"$1").split(/[_-]/).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join("")).join("");return a.charAt(0).toLowerCase()+a.slice(1)},at=(r,n,i)=>{const a=it(n),l=ot(i);return`${a}${l}`},ut=r=>{if(r)return(r==null?void 0:r.reduce((n,i)=>(n[i]={query:{useInfinite:!0,useInfiniteQueryParam:"offset",useQuery:!0}},n),{}))||{}},ct=r=>{const{input:n="./openapi.json",operationsToGenerateInfiniteQueryHook:i=void 0}=r||{};return{api:{hooks:{afterAllFilesWrite:"prettier src/api/ --write"},input:n,output:{client:"react-query",mode:"tags-split",override:{header:a=>["Generated by orval 🍺",...a.title?[a.title]:[],...a.description?[a.description]:[]],mutator:{name:"axiosCustomInstance",path:`${__dirname}/config/orval/mutator/axiosCustomInstance.ts`},operationName:at,...(i==null?void 0:i.length)&&{operations:ut(i)},query:{useQuery:!0}},schemas:"src/api/model",target:"src/api/services/api.ts"}}}};w.GTMSendPageView=Ve,w.InitializeAxiosConfig=Ue,w.InitializeDaysJSConfig=Xe,w.InitializeI18nConfig=Be,w.InitializeMapBoxConfig=Je,w.InitializeSentryConfig=Ge,w.InjectDependenciesContext=A,w.InjectDependenciesProvider=Me,w.MaskTextField=Qe,w.QueryClientProviderWithConfig=Ze,w.RequireAuth=ze,w.dateAdapter=fe,w.distanceAdapter=de,w.getOrvalConfig=ct,w.useAdapter=nt,w.useAuth=et,w.useInfiniteDataGrid=qe,w.useResponseError=$e,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|