@refinedev/core 4.26.3 → 4.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +134 -0
- package/dist/contexts/refine/IRefineContext.d.ts +7 -0
- package/dist/contexts/refine/IRefineContext.d.ts.map +1 -1
- package/dist/contexts/refine/index.d.ts.map +1 -1
- package/dist/definitions/helpers/handleRefineOptions/index.d.ts.map +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/hooks/data/useDelete.d.ts +28 -0
- package/dist/hooks/data/useDelete.d.ts.map +1 -1
- package/dist/hooks/data/useDeleteMany.d.ts +28 -0
- package/dist/hooks/data/useDeleteMany.d.ts.map +1 -1
- package/dist/hooks/data/useUpdate.d.ts +1 -1
- package/dist/hooks/data/useUpdateMany.d.ts +25 -0
- package/dist/hooks/data/useUpdateMany.d.ts.map +1 -1
- package/dist/hooks/form/useForm.d.ts +6 -6
- package/dist/hooks/form/useForm.d.ts.map +1 -1
- package/dist/iife/index.js +7 -7
- package/dist/iife/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/interfaces/autoSave.d.ts +28 -0
- package/dist/interfaces/autoSave.d.ts.map +1 -0
- package/dist/interfaces/errors/HttpError.d.ts +7 -0
- package/dist/interfaces/errors/HttpError.d.ts.map +1 -1
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/successErrorNotification.d.ts +2 -2
- package/dist/interfaces/successErrorNotification.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/contexts/refine/IRefineContext.ts +7 -0
- package/src/contexts/refine/index.tsx +1 -0
- package/src/definitions/helpers/handleRefineOptions/index.ts +3 -0
- package/src/hooks/data/useDelete.ts +28 -0
- package/src/hooks/data/useDeleteMany.ts +28 -0
- package/src/hooks/data/useUpdate.ts +1 -1
- package/src/hooks/data/useUpdateMany.ts +25 -0
- package/src/hooks/form/useForm.ts +59 -2
- package/src/index.tsx +2 -0
- package/src/interfaces/autoSave.ts +43 -0
- package/src/interfaces/errors/HttpError.ts +9 -0
- package/src/interfaces/index.ts +2 -0
- package/src/interfaces/successErrorNotification.ts +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import kt,{useEffect as Ya,useState as Ja}from"react";import dt from"react";var to=dt.createContext({}),ro=({children:e,isProvided:t,...r})=>{let{replace:o}=ue(),n=async p=>{var d;try{return await((d=r.login)==null?void 0:d.call(r,p))}catch(l){return Promise.reject(l)}},a=async p=>{var d;try{return await((d=r.register)==null?void 0:d.call(r,p))}catch(l){return Promise.reject(l)}},s=async p=>{var d;try{return await((d=r.logout)==null?void 0:d.call(r,p))}catch(l){return Promise.reject(l)}},u=async p=>{var d;try{return await((d=r.checkAuth)==null?void 0:d.call(r,p)),Promise.resolve()}catch(l){return l!=null&&l.redirectPath&&o(l.redirectPath),Promise.reject(l)}};return dt.createElement(to.Provider,{value:{...r,login:n,logout:s,checkAuth:u,register:a,isProvided:t}},e)},oo=dt.createContext({}),no=({children:e,isProvided:t,...r})=>{let o=async d=>{var l;try{return await((l=r.login)==null?void 0:l.call(r,d))}catch(c){return console.warn("Unhandled Error in login: refine always expects a resolved promise.",c),Promise.reject(c)}},n=async d=>{var l;try{return await((l=r.register)==null?void 0:l.call(r,d))}catch(c){return console.warn("Unhandled Error in register: refine always expects a resolved promise.",c),Promise.reject(c)}},a=async d=>{var l;try{return await((l=r.logout)==null?void 0:l.call(r,d))}catch(c){return console.warn("Unhandled Error in logout: refine always expects a resolved promise.",c),Promise.reject(c)}},s=async d=>{var l;try{let c=await((l=r.check)==null?void 0:l.call(r,d));return Promise.resolve(c)}catch(c){return console.warn("Unhandled Error in check: refine always expects a resolved promise.",c),Promise.reject(c)}},u=async d=>{var l;try{let c=await((l=r.forgotPassword)==null?void 0:l.call(r,d));return Promise.resolve(c)}catch(c){return console.warn("Unhandled Error in forgotPassword: refine always expects a resolved promise.",c),Promise.reject(c)}},p=async d=>{var l;try{let c=await((l=r.updatePassword)==null?void 0:l.call(r,d));return Promise.resolve(c)}catch(c){return console.warn("Unhandled Error in updatePassword: refine always expects a resolved promise.",c),Promise.reject(c)}};return dt.createElement(oo.Provider,{value:{...r,login:o,logout:a,check:s,register:n,forgotPassword:u,updatePassword:p,isProvided:t}},e)},ee=()=>dt.useContext(to),ie=()=>dt.useContext(oo);import{useQuery as so}from"@tanstack/react-query";function Bn({v3LegacyAuthProviderCompatible:e=!1,options:t}={}){let{getPermissions:r}=ee(),{getPermissions:o}=ie(),n=so(["usePermissions"],o??(()=>Promise.resolve(void 0)),{enabled:!e&&!!o,...e?{}:t}),a=so(["usePermissions","v3LegacyAuthProviderCompatible"],r??(()=>Promise.resolve(void 0)),{enabled:e&&!!r,...e?t:{}});return e?a:n}import{useQuery as ao}from"@tanstack/react-query";function dr({v3LegacyAuthProviderCompatible:e=!1,queryOptions:t}={}){let{getUserIdentity:r}=ee(),{getIdentity:o}=ie(),n=ao(["getUserIdentity"],o??(()=>Promise.resolve({})),{enabled:!e&&!!o,retry:!1,...e===!0?{}:t}),a=ao(["getUserIdentity","v3LegacyAuthProviderCompatible"],r??(()=>Promise.resolve({})),{enabled:e&&!!r,retry:!1,...e?t:{}});return e?a:n}import{useMutation as io}from"@tanstack/react-query";import{useQueryClient as Nn}from"@tanstack/react-query";var lt=()=>{let e=Nn();return async()=>{await Promise.all([e.invalidateQueries(["useAuthenticated"]),e.invalidateQueries(["getUserIdentity"]),e.invalidateQueries(["usePermissions"])])}};function Ot({v3LegacyAuthProviderCompatible:e,mutationOptions:t}={}){let r=lt(),o=z(),n=ce(),{push:a}=ue(),{open:s,close:u}=he(),{logout:p}=ee(),{logout:d}=ie(),l=io(["useLogout"],d,{onSuccess:async(m,P)=>{let{success:x,error:C,redirectTo:v}=m,{redirectPath:g}=P??{},U=g??v;x&&(u==null||u("useLogout-error")),(C||!x)&&(s==null||s(lr(C))),await r(),U!==!1&&(o==="legacy"?a(U??"/login"):U&&n({to:U}))},onError:m=>{s==null||s(lr(m))},...e===!0?{}:t}),c=io(["useLogout","v3LegacyAuthProviderCompatible"],p,{onSuccess:async(m,P)=>{let x=(P==null?void 0:P.redirectPath)??m;if(await r(),x!==!1){if(x){o==="legacy"?a(x):n({to:x});return}o==="legacy"?a("/login"):n({to:"/login"})}},onError:m=>{s==null||s(lr(m))},...e?t:{}});return e?c:l}var lr=e=>({key:"useLogout-error",type:"error",message:(e==null?void 0:e.name)||"Logout Error",description:(e==null?void 0:e.message)||"Something went wrong during logout"});import Hn from"react";import{useMutation as uo}from"@tanstack/react-query";import On from"qs";function bt({v3LegacyAuthProviderCompatible:e,mutationOptions:t}={}){let r=lt(),o=z(),n=ce(),{replace:a}=ue(),s=de(),{useLocation:u}=te(),{search:p}=u(),{close:d,open:l}=he(),{login:c}=ee(),{login:m}=ie(),P=Hn.useMemo(()=>{var v;return o==="legacy"?On.parse(p,{ignoreQueryPrefix:!0}).to:(v=s.params)==null?void 0:v.to},[o,s.params,p]),x=uo(["useLogin"],m,{onSuccess:async({success:v,redirectTo:g,error:U})=>{v&&(d==null||d("login-error")),(U||!v)&&(l==null||l(mr(U))),await r(),P&&v?o==="legacy"?a(P):n({to:P,type:"replace"}):g?o==="legacy"?a(g):n({to:g,type:"replace"}):o==="legacy"&&a("/")},onError:v=>{l==null||l(mr(v))},...e===!0?{}:t}),C=uo(["useLogin","v3LegacyAuthProviderCompatible"],c,{onSuccess:async v=>{await r(),P&&a(P),v!==!1&&!P&&(typeof v=="string"?o==="legacy"?a(v):n({to:v,type:"replace"}):o==="legacy"?a("/"):n({to:"/",type:"replace"})),d==null||d("login-error")},onError:v=>{l==null||l(mr(v))},...e?t:{}});return e?C:x}var mr=e=>({message:(e==null?void 0:e.name)||"Login Error",description:(e==null?void 0:e.message)||"Invalid credentials",key:"login-error",type:"error"});import{useMutation as co}from"@tanstack/react-query";function yr({v3LegacyAuthProviderCompatible:e,mutationOptions:t}={}){let r=lt(),o=z(),n=ce(),{replace:a}=ue(),{register:s}=ee(),{register:u}=ie(),{close:p,open:d}=he(),l=co(["useRegister"],u,{onSuccess:async({success:m,redirectTo:P,error:x})=>{m&&(p==null||p("register-error")),(x||!m)&&(d==null||d(fr(x))),await r(),P?o==="legacy"?a(P):n({to:P,type:"replace"}):o==="legacy"&&a("/")},onError:m=>{d==null||d(fr(m))},...e===!0?{}:t}),c=co(["useRegister","v3LegacyAuthProviderCompatible"],s,{onSuccess:async m=>{await r(),m!==!1&&(m?o==="legacy"?a(m):n({to:m,type:"replace"}):o==="legacy"?a("/"):n({to:"/",type:"replace"}),p==null||p("register-error"))},onError:m=>{d==null||d(fr(m))},...e?t:{}});return e?c:l}var fr=e=>({message:(e==null?void 0:e.name)||"Register Error",description:(e==null?void 0:e.message)||"Error while registering",key:"register-error",type:"error"});import{useMutation as po}from"@tanstack/react-query";function Tr({v3LegacyAuthProviderCompatible:e,mutationOptions:t}={}){let r=z(),o=ce(),{replace:n}=ue(),{forgotPassword:a}=ee(),{forgotPassword:s}=ie(),{close:u,open:p}=he(),d=po(["useForgotPassword"],s,{onSuccess:({success:c,redirectTo:m,error:P})=>{c&&(u==null||u("forgot-password-error")),(P||!c)&&(p==null||p(gr(P))),m&&(r==="legacy"?n(m):o({to:m,type:"replace"}))},onError:c=>{p==null||p(gr(c))},...e===!0?{}:t}),l=po(["useForgotPassword","v3LegacyAuthProviderCompatible"],a,{onSuccess:c=>{c!==!1&&c&&(r==="legacy"?n(c):o({to:c,type:"replace"})),u==null||u("forgot-password-error")},onError:c=>{p==null||p(gr(c))},...e?t:{}});return e?l:d}var gr=e=>({message:(e==null?void 0:e.name)||"Forgot Password Error",description:(e==null?void 0:e.message)||"Error while resetting password",key:"forgot-password-error",type:"error"});import $n from"react";import{useMutation as lo}from"@tanstack/react-query";import Gn from"qs";function Pr({v3LegacyAuthProviderCompatible:e,mutationOptions:t}={}){let r=z(),o=ce(),{replace:n}=ue(),{updatePassword:a}=ee(),{updatePassword:s}=ie(),{close:u,open:p}=he(),d=de(),{useLocation:l}=te(),{search:c}=l(),m=$n.useMemo(()=>r==="legacy"?Gn.parse(c,{ignoreQueryPrefix:!0})??{}:d.params??{},[c,d,r]),P=lo(["useUpdatePassword"],async C=>s==null?void 0:s({...m,...C}),{onSuccess:({success:C,redirectTo:v,error:g})=>{C&&(u==null||u("update-password-error")),(g||!C)&&(p==null||p(Rr(g))),v&&(r==="legacy"?n(v):o({to:v,type:"replace"}))},onError:C=>{p==null||p(Rr(C))},...e===!0?{}:t}),x=lo(["useUpdatePassword","v3LegacyAuthProviderCompatible"],async C=>a==null?void 0:a({...m,...C}),{onSuccess:C=>{C!==!1&&C&&(r==="legacy"?n(C):o({to:C,type:"replace"})),u==null||u("update-password-error")},onError:C=>{p==null||p(Rr(C))},...e?t:{}});return e?x:P}var Rr=e=>({message:(e==null?void 0:e.name)||"Update Password Error",description:(e==null?void 0:e.message)||"Error while updating password",key:"update-password-error",type:"error"});import{useQuery as mo}from"@tanstack/react-query";function $t({v3LegacyAuthProviderCompatible:e=!1,params:t}={}){let{checkAuth:r}=ee(),{check:o}=ie(),n=mo(["useAuthenticated",t],async()=>await(o==null?void 0:o(t))??{},{retry:!1,enabled:!e}),a=mo(["useAuthenticated",t,"v3LegacyAuthProviderCompatible"],async()=>await(r==null?void 0:r(t))??{},{retry:!1,enabled:e});return e?a:n}var Wn=$t;import{useMutation as fo}from"@tanstack/react-query";function re({v3LegacyAuthProviderCompatible:e=!1}={}){let t=z(),r=ce(),{replace:o}=ue(),{checkError:n}=ee(),{onError:a}=ie(),{mutate:s}=Ot({v3LegacyAuthProviderCompatible:!!e}),{mutate:u}=Ot({v3LegacyAuthProviderCompatible:!!e}),p=fo(["useCheckError"],a,{onSuccess:({logout:l,redirectTo:c})=>{if(l){u({redirectPath:c});return}if(c){t==="legacy"?o(c):r({to:c,type:"replace"});return}}}),d=fo(["useCheckError","v3LegacyAuthProviderCompatible"],n,{onError:l=>{s({redirectPath:l})}});return e?d:p}var Kn=re;var xr=()=>{let{isProvided:e}=ee(),{isProvided:t}=ie();return!!(t||e)};import{useQuery as cs}from"@tanstack/react-query";var vt=e=>e/1e3;import zn from"lodash/zip";import _n from"lodash/fromPairs";var Gt=(e,t=r=>r)=>{let[r,...o]=e;return o.map(n=>_n(zn(r,n))).map((n,a,s)=>t.call(void 0,n,a,s))};import Po from"pluralize";import Cr from"qs";import yo from"lodash/unionWith";import go from"lodash/differenceWith";import jn from"warn-once";var Wt=e=>{let{current:t,pageSize:r,sorter:o,sorters:n,filters:a}=Cr.parse(e.substring(1));return{parsedCurrent:t&&Number(t),parsedPageSize:r&&Number(r),parsedSorter:M(n,o)??[],parsedFilters:a??[]}},Zn=e=>{let t=Cr.stringify(e);return Wt(`/${t}`)},Kt=e=>{let t={skipNulls:!0,arrayFormat:"indices",encode:!1},{pagination:r,sorter:o,sorters:n,filters:a,...s}=e;return Cr.stringify({...s,...r||{},sorters:M(n,o),filters:a},t)},To=(e,t)=>e.operator!=="and"&&e.operator!=="or"&&t.operator!=="and"&&t.operator!=="or"?("field"in e?e.field:void 0)==("field"in t?t.field:void 0)&&e.operator==t.operator:("key"in e?e.key:void 0)==("key"in t?t.key:void 0)&&e.operator==t.operator,Ro=(e,t)=>e.field==t.field,mt=(e,t,r=[])=>(t.filter(n=>(n.operator==="or"||n.operator==="and")&&!n.key).length>1&&jn(!0,`[conditionalFilters]: You have created multiple Conditional Filters at the top level, this requires the key parameter.
|
|
2
|
-
For more information, see https://refine.dev/docs/advanced-tutorials/data-provider/handling-filters/#top-level-multiple-conditional-filters-usage`),yo(e,t,r,To).filter(n=>n.value!==void 0&&n.value!==null&&(n.operator!=="or"||n.operator==="or"&&n.value.length!==0)&&(n.operator!=="and"||n.operator==="and"&&n.value.length!==0))),zt=(e,t)=>yo(e,t,Ro).filter(r=>r.order!==void 0&&r.order!==null),_t=(e,t)=>[...go(t,e,To),...e],jt=(e,t)=>[...go(t,e,Ro),...e],Yn=(e,t)=>{if(!t)return;let r=t.find(o=>o.field===e);if(r)return r.order},Jn=(e,t,r="eq")=>{let o=t==null?void 0:t.find(n=>{if(n.operator!=="or"&&n.operator!=="and"&&"field"in n){let{operator:a,field:s}=n;return s===e&&a===r}});if(o)return o.value||[]};var Xn=e=>new Promise((t,r)=>{let o=new FileReader,n=()=>{o.result&&(o.removeEventListener("load",n,!1),t(o.result))};o.addEventListener("load",n,!1),o.readAsDataURL(e.originFileObj),o.onerror=a=>(o.removeEventListener("load",n,!1),r(a))});var Zt=(e="",t)=>{let r=Dt(e);return t==="singular"?Po.singular(r):Po.plural(r)};var xo=(e={})=>e!=null&&e.id?{...e,id:decodeURIComponent(e.id)}:e;var M=(...e)=>e.find(t=>typeof t<"u");var q=(e,t,r,o)=>{let n=t||"default",a={all:[n],resourceAll:[n,e||""],list:s=>[...a.resourceAll,"list",{...s,...M(r,o)||{}}],many:s=>[...a.resourceAll,"getMany",s&&s.map(String),{...M(r,o)||{}}].filter(u=>u!==void 0),detail:s=>[...a.resourceAll,"detail",s==null?void 0:s.toString(),{...M(r,o)||{}}],logList:s=>["logList",e,s,o].filter(u=>u!==void 0)};return a};var hr=(e,t)=>!e||!t?!1:!!e.find(r=>r===t);var rt=e=>e.startsWith(":");var Ne=e=>e.split("/").filter(r=>r!=="");var br=(e,t)=>{let r=Ne(e),o=Ne(t);return r.length===o.length};var Re=e=>e.replace(/^\/|\/$/g,"");var vr=(e,t)=>{let r=Re(e),o=Re(t);if(!br(r,o))return!1;let n=Ne(r);return Ne(o).every((s,u)=>rt(s)||s===n[u])};var Dr=(e,t,r)=>{let o=Re(r||""),n=`${o}${o?"/":""}${e}`;return t==="list"?n=`${n}`:t==="create"?n=`${n}/create`:t==="edit"?n=`${n}/edit/:id`:t==="show"?n=`${n}/show/:id`:t==="clone"&&(n=`${n}/clone/:id`),`/${n.replace(/^\//,"")}`};var De=(e,t)=>{var n,a;let r=M((n=e.meta)==null?void 0:n.parent,(a=e.options)==null?void 0:a.parent,e.parentName);return r?t.find(s=>(s.identifier??s.name)===r)??{name:r}:void 0};var Lt=(e,t,r)=>{let o=[],n=De(e,t);for(;n;)o.push(n),n=De(n,t);if(o.length!==0)return`/${o.reverse().map(a=>{var u;let s=r?((u=a.options)==null?void 0:u.route)??a.name:a.name;return Re(s)}).join("/")}`};var fe=(e,t,r)=>{let o=[],n=["list","show","edit","create","clone"],a=Lt(e,t,r);return n.forEach(s=>{var d,l;let u=r&&s==="clone"?e.create:e[s],p;typeof u=="function"||r?p=Dr(r?((d=e.meta)==null?void 0:d.route)??((l=e.options)==null?void 0:l.route)??e.name:e.name,s,r?a:void 0):typeof u=="string"?p=u:typeof u=="object"&&(p=u.path),p&&o.push({action:s,resource:e,route:`/${p.replace(/^\//,"")}`})}),o};var Co=e=>{var n;if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(a=>({...a,splitted:Ne(Re(a.route))})),r=((n=t[0])==null?void 0:n.splitted.length)??0,o=[...t];for(let a=0;a<r;a++){let s=o.filter(u=>!rt(u.splitted[a]));if(s.length!==0){if(s.length===1){o=s;break}o=s}}return o[0]};var Lr=(e,t)=>{let o=t.flatMap(a=>fe(a,t)).filter(a=>vr(e,a.route)),n=Co(o);return{found:!!n,resource:n==null?void 0:n.resource,action:n==null?void 0:n.action,matchedRoute:n==null?void 0:n.route}};var Yt=(e,t)=>{var n;let r,o=Lt(e,t,!0);if(o){let a=M(e.meta,e.options);r=`${o}/${(a==null?void 0:a.route)??e.name}`}else r=((n=e.options)==null?void 0:n.route)??e.name;return`/${r.replace(/^\//,"")}`};var ho=e=>{var s;let t=[],r={},o={},n,a;for(let u=0;u<e.length;u++){n=e[u];let p=n.route??((s=M(n==null?void 0:n.meta,n.options))==null?void 0:s.route)??"";r[p]=n,r[p].children=[],o[n.name]=n,o[n.name].children=[]}for(let u in r)r.hasOwnProperty(u)&&(a=r[u],a.parentName&&o[a.parentName]?o[a.parentName].children.push(a):t.push(a));return t};var Dt=e=>(e=e.replace(/([a-z]{1})([A-Z]{1})/g,"$1-$2"),e=e.replace(/([A-Z]{1})([A-Z]{1})([a-z]{1})/g,"$1-$2$3"),e=e.toLowerCase().replace(/[_-]+/g," ").replace(/\s{2,}/g," ").trim(),e=e.charAt(0).toUpperCase()+e.slice(1),e);import vo from"react";import bo from"pluralize";import qn from"react";var Er=({children:e})=>qn.createElement("div",null,e);var be={mutationMode:"pessimistic",syncWithLocation:!1,undoableTimeout:5e3,warnWhenUnsavedChanges:!1,liveMode:"off",redirect:{afterCreate:"list",afterClone:"list",afterEdit:"list"},overtime:{interval:1e3},textTransformers:{humanize:Dt,plural:bo.plural,singular:bo.singular}},Ce=vo.createContext({hasDashboard:!1,mutationMode:"pessimistic",warnWhenUnsavedChanges:!1,syncWithLocation:!1,undoableTimeout:5e3,Title:void 0,Sider:void 0,Header:void 0,Footer:void 0,Layout:Er,OffLayoutArea:void 0,liveMode:"off",onLiveEvent:void 0,options:be}),Do=({hasDashboard:e,mutationMode:t,warnWhenUnsavedChanges:r,syncWithLocation:o,undoableTimeout:n,children:a,DashboardPage:s,Title:u,Layout:p=Er,Header:d,Sider:l,Footer:c,OffLayoutArea:m,LoginPage:P=Ur,catchAll:x,liveMode:C="off",onLiveEvent:v,options:g})=>vo.createElement(Ce.Provider,{value:{hasDashboard:e,mutationMode:t,warnWhenUnsavedChanges:r,syncWithLocation:o,Title:u,undoableTimeout:n,Layout:p,Header:d,Sider:l,Footer:c,OffLayoutArea:m,DashboardPage:s,LoginPage:P,catchAll:x,liveMode:C,onLiveEvent:v,options:g}},a);var Mr=({options:e,disableTelemetry:t,liveMode:r,mutationMode:o,reactQueryClientConfig:n,reactQueryDevtoolConfig:a,syncWithLocation:s,undoableTimeout:u,warnWhenUnsavedChanges:p}={})=>{var m,P,x,C,v,g,U,S;let d={breadcrumb:e==null?void 0:e.breadcrumb,mutationMode:(e==null?void 0:e.mutationMode)??o??be.mutationMode,undoableTimeout:(e==null?void 0:e.undoableTimeout)??u??be.undoableTimeout,syncWithLocation:(e==null?void 0:e.syncWithLocation)??s??be.syncWithLocation,warnWhenUnsavedChanges:(e==null?void 0:e.warnWhenUnsavedChanges)??p??be.warnWhenUnsavedChanges,liveMode:(e==null?void 0:e.liveMode)??r??be.liveMode,redirect:{afterCreate:((m=e==null?void 0:e.redirect)==null?void 0:m.afterCreate)??be.redirect.afterCreate,afterClone:((P=e==null?void 0:e.redirect)==null?void 0:P.afterClone)??be.redirect.afterClone,afterEdit:((x=e==null?void 0:e.redirect)==null?void 0:x.afterEdit)??be.redirect.afterEdit},overtime:(e==null?void 0:e.overtime)??be.overtime,textTransformers:{humanize:((C=e==null?void 0:e.textTransformers)==null?void 0:C.humanize)??be.textTransformers.humanize,plural:((v=e==null?void 0:e.textTransformers)==null?void 0:v.plural)??be.textTransformers.plural,singular:((g=e==null?void 0:e.textTransformers)==null?void 0:g.singular)??be.textTransformers.singular}},l=(e==null?void 0:e.disableTelemetry)??t??!1,c={clientConfig:((U=e==null?void 0:e.reactQuery)==null?void 0:U.clientConfig)??n??{},devtoolConfig:((S=e==null?void 0:e.reactQuery)==null?void 0:S.devtoolConfig)??a??{}};return{optionsWithDefaults:d,disableTelemetryWithDefault:l,reactQueryWithDefaults:c}};var Ir=({redirectFromProps:e,action:t,redirectOptions:r})=>{if(e||e===!1)return e;switch(t){case"clone":return r.afterClone;case"create":return r.afterCreate;case"edit":return r.afterEdit;default:return!1}};var Jt=async(e,t,r)=>{let o=[];for(let[n,a]of e.entries())try{let s=await a();o.push(t(s,n))}catch(s){o.push(r(s,n))}return o};var pe=(e,t=[],r=!1)=>{if(!e)return;if(r){let n=t.find(s=>Re(s.route??"")===Re(e));return n||t.find(s=>s.name===e)}let o=t.find(n=>n.identifier===e);return o||(o=t.find(n=>n.name===e)),o};var N=(e,t,r)=>{if(t)return t;let o=pe(e,r),n=M(o==null?void 0:o.meta,o==null?void 0:o.options);return n!=null&&n.dataProviderName?n.dataProviderName:"default"};var Ge=async e=>({data:(await Promise.all(e)).map(t=>t.data)});var Xt=e=>{let{pagination:t,cursor:r}=e;if(r!=null&&r.next)return r.next;let o=(t==null?void 0:t.current)||1,n=(t==null?void 0:t.pageSize)||10,a=Math.ceil((e.total||0)/n);return o<a?Number(o)+1:void 0},qt=e=>{let{pagination:t,cursor:r}=e;if(r!=null&&r.prev)return r.prev;let o=(t==null?void 0:t.current)||1;return o===1?void 0:o-1};var er=e=>{let t=[];return e.forEach(r=>{var o,n;t.push({...r,label:((o=r.meta)==null?void 0:o.label)??((n=r.options)==null?void 0:n.label),route:Yt(r,e),canCreate:!!r.create,canEdit:!!r.edit,canShow:!!r.show,canDelete:r.canDelete})}),t};var Lo=e=>Ne(Re(e)).flatMap(r=>rt(r)?[r.slice(1)]:[]);var Eo=(e,t={})=>e.reduce((r,o)=>{let n=t[o];return typeof n<"u"&&(r[o]=n),r},{});var Pe=(e,t={},r={},o={})=>{let n=Lo(e),a=Eo(n,{...t,...typeof(r==null?void 0:r.id)<"u"?{id:r.id}:{},...typeof(r==null?void 0:r.action)<"u"?{action:r.action}:{},...typeof(r==null?void 0:r.resource)<"u"?{resource:r.resource}:{},...r==null?void 0:r.params,...o});return e.replace(/:([^\/]+)/g,(s,u)=>{let p=a[u];return typeof p<"u"?`${p}`:s})};var W=()=>{let e=ee(),t=ie();return t.isProvided?{isLegacy:!1,...t}:e.isProvided?{isLegacy:!0,...e,check:e.checkAuth,onError:e.checkError,getIdentity:e.getUserIdentity}:null};var Et=({hasPagination:e,pagination:t,configPagination:r}={})=>{let o=e===!1?"off":"server",n=(t==null?void 0:t.mode)??o,a=M(t==null?void 0:t.current,r==null?void 0:r.current)??1,s=M(t==null?void 0:t.pageSize,r==null?void 0:r.pageSize)??10;return{current:a,pageSize:s,mode:n}};import{useState as es,useEffect as ts}from"react";var tr=e=>{let[t,r]=es(!1);return ts(()=>{let o=window.matchMedia(e);o.matches!==t&&r(o.matches);let n=()=>r(o.matches);return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[t,e]),t};var rr=(e,t,r,o)=>{let n=o?e(t,o,r):e(t,r),a=r??t;return n===t||typeof n>"u"?a:n};function Uo(e,t,r,o,n){var m;let a={create:"Create new ",clone:`#${o??""} Clone `,edit:`#${o??""} Edit `,show:`#${o??""} Show `,list:""},s=(t==null?void 0:t.identifier)??(t==null?void 0:t.name),u=(t==null?void 0:t.label)??((m=t==null?void 0:t.meta)==null?void 0:m.label)??Zt(s,r==="list"?"plural":"singular"),p=n??u,d=rr(e,"documentTitle.default","refine"),l=rr(e,"documentTitle.suffix"," | refine"),c=d;return r&&s&&(c=rr(e,`documentTitle.${s}.${r}`,`${a[r]??""}${p}${l}`,{id:o})),c}import{useContext as rs}from"react";var ke=()=>{let{mutationMode:e,undoableTimeout:t}=rs(Ce);return{mutationMode:e,undoableTimeout:t}};import{useContext as wo}from"react";import Mo,{useState as os}from"react";var wr=Mo.createContext({}),Io=({children:e})=>{let[t,r]=os(!1);return Mo.createElement(wr.Provider,{value:{warnWhen:t,setWarnWhen:r}},e)};var Ut=()=>{let{warnWhenUnsavedChanges:e}=wo(Ce),{warnWhen:t,setWarnWhen:r}=wo(wr);return{warnWhenUnsavedChanges:e,warnWhen:!!t,setWarnWhen:r??(()=>{})}};import{useContext as ns}from"react";var Sr=()=>{let{syncWithLocation:e}=ns(Ce);return{syncWithLocation:e}};import{useContext as ss}from"react";var as=()=>{let{Title:e}=ss(Ce);return e};import{useContext as is}from"react";var ae=()=>{let{Footer:e,Header:t,Layout:r,OffLayoutArea:o,Sider:n,Title:a,hasDashboard:s,mutationMode:u,syncWithLocation:p,undoableTimeout:d,warnWhenUnsavedChanges:l,DashboardPage:c,LoginPage:m,catchAll:P,options:x}=is(Ce);return{Footer:e,Header:t,Layout:r,OffLayoutArea:o,Sider:n,Title:a,hasDashboard:s,mutationMode:u,syncWithLocation:p,undoableTimeout:d,warnWhenUnsavedChanges:l,DashboardPage:c,LoginPage:m,catchAll:P,options:x}};var ft=()=>{let{options:{textTransformers:e}}=ae();return(r="",o)=>{let n=e.humanize(r);return o==="singular"?e.singular(n):e.plural(n)}};import{useEffect as So,useState as us}from"react";var _=({isLoading:e,interval:t,onInterval:r})=>{let[o,n]=us(void 0),{options:a}=ae(),{overtime:s}=a,u=t??s.interval,p=r??(s==null?void 0:s.onInterval);return So(()=>{let d;return e&&(d=setInterval(()=>{n(l=>l===void 0?u:l+u)},u)),()=>{clearInterval(d),n(void 0)}},[e,u]),So(()=>{p&&o&&p(o)},[o]),{elapsedTime:o}};var Mt=({resource:e,config:t,filters:r,hasPagination:o,pagination:n,sorters:a,queryOptions:s,successNotification:u,errorNotification:p,meta:d,metaData:l,liveMode:c,onLiveEvent:m,liveParams:P,dataProviderName:x,overtimeOptions:C})=>{let{resources:v,resource:g,identifier:U}=k(e),S=Y(),h=B(),i=W(),{mutate:f}=re({v3LegacyAuthProviderCompatible:!!(i!=null&&i.isLegacy)}),R=oe(),b=K(),T=N(U,x,v),y=M(d,l),D=M(r,t==null?void 0:t.filters),L=M(a,t==null?void 0:t.sort),A=M(o,t==null?void 0:t.hasPagination),w=Et({pagination:n,configPagination:t==null?void 0:t.pagination,hasPagination:A}),E=w.mode==="server",I=b({resource:g,meta:y}),F={meta:I,metaData:I,filters:D,hasPagination:E,pagination:w,sorters:L,config:{...t,sort:L}},V=(s==null?void 0:s.enabled)===void 0||(s==null?void 0:s.enabled)===!0,O=q(U,T,y),{getList:G}=S(T);Ye({resource:U,types:["*"],params:{meta:I,metaData:I,pagination:w,hasPagination:E,sort:L,sorters:L,filters:D,subscriptionType:"useList",...P},channel:`resources/${g==null?void 0:g.name}`,enabled:V,liveMode:c,onLiveEvent:m});let X=cs(O.list({filters:D,hasPagination:E,...E&&{pagination:w},...a&&{sorters:a},...(t==null?void 0:t.sort)&&{sort:t==null?void 0:t.sort}}),({queryKey:Q,pageParam:$,signal:H})=>G({resource:(g==null?void 0:g.name)??"",pagination:w,hasPagination:E,filters:D,sort:L,sorters:L,meta:{...I,queryContext:{queryKey:Q,pageParam:$,signal:H}},metaData:{...I,queryContext:{queryKey:Q,pageParam:$,signal:H}}}),{...s,enabled:typeof(s==null?void 0:s.enabled)<"u"?s==null?void 0:s.enabled:!!(g!=null&&g.name),select:Q=>{var ge;let $=Q,{current:H,mode:Z,pageSize:se}=w;return Z==="client"&&($={...$,data:$.data.slice((H-1)*se,H*se),total:$.total}),s!=null&&s.select?(ge=s==null?void 0:s.select)==null?void 0:ge.call(s,$):$},onSuccess:Q=>{var H;(H=s==null?void 0:s.onSuccess)==null||H.call(s,Q);let $=typeof u=="function"?u(Q,F,U):u;R($)},onError:Q=>{var H;f(Q),(H=s==null?void 0:s.onError)==null||H.call(s,Q);let $=typeof p=="function"?p(Q,F,U):p;R($,{key:`${U}-useList-notification`,message:h("notifications.error",{statusCode:Q.statusCode},`Error (status code: ${Q.statusCode})`),description:Q.message,type:"error"})}}),{elapsedTime:j}=_({isLoading:X.isFetching,interval:C==null?void 0:C.interval,onInterval:C==null?void 0:C.onInterval});return{...X,overtime:{elapsedTime:j}}};import{useQuery as ps}from"@tanstack/react-query";var It=({resource:e,id:t,queryOptions:r,successNotification:o,errorNotification:n,meta:a,metaData:s,liveMode:u,onLiveEvent:p,liveParams:d,dataProviderName:l,overtimeOptions:c})=>{let{resources:m,resource:P,identifier:x}=k(e),C=Y(),v=B(),g=W(),{mutate:U}=re({v3LegacyAuthProviderCompatible:!!(g!=null&&g.isLegacy)}),S=oe(),h=K(),i=M(a,s),f=N(x,l,m),R=q(x,f,i),{getOne:b}=C(f),T=h({resource:P,meta:i});Ye({resource:x,types:["*"],channel:`resources/${P==null?void 0:P.name}`,params:{ids:t?[t]:[],id:t,meta:T,metaData:T,subscriptionType:"useOne",...d},enabled:typeof(r==null?void 0:r.enabled)<"u"?r==null?void 0:r.enabled:typeof(P==null?void 0:P.name)<"u"&&typeof t<"u",liveMode:u,onLiveEvent:p});let y=ps(R.detail(t),({queryKey:L,pageParam:A,signal:w})=>b({resource:(P==null?void 0:P.name)??"",id:t,meta:{...T,queryContext:{queryKey:L,pageParam:A,signal:w}},metaData:{...T,queryContext:{queryKey:L,pageParam:A,signal:w}}}),{...r,enabled:typeof(r==null?void 0:r.enabled)<"u"?r==null?void 0:r.enabled:typeof t<"u",onSuccess:L=>{var w;(w=r==null?void 0:r.onSuccess)==null||w.call(r,L);let A=typeof o=="function"?o(L,{id:t,...T},x):o;S(A)},onError:L=>{var w;U(L),(w=r==null?void 0:r.onError)==null||w.call(r,L);let A=typeof n=="function"?n(L,{id:t,...T},x):n;S(A,{key:`${t}-${x}-getOne-notification`,message:v("notifications.error",{statusCode:L.statusCode},`Error (status code: ${L.statusCode})`),description:L.message,type:"error"})}}),{elapsedTime:D}=_({isLoading:y.isFetching,interval:c==null?void 0:c.interval,onInterval:c==null?void 0:c.onInterval});return{...y,overtime:{elapsedTime:D}}};import{useQuery as ds}from"@tanstack/react-query";var Ar=({resource:e,ids:t,queryOptions:r,successNotification:o,errorNotification:n,meta:a,metaData:s,liveMode:u,onLiveEvent:p,liveParams:d,dataProviderName:l,overtimeOptions:c})=>{let{resources:m,resource:P,identifier:x}=k(e),C=Y(),v=B(),g=W(),{mutate:U}=re({v3LegacyAuthProviderCompatible:!!(g!=null&&g.isLegacy)}),S=oe(),h=K(),i=M(a,s),f=N(x,l,m),R=(r==null?void 0:r.enabled)===void 0||(r==null?void 0:r.enabled)===!0,b=q(x,f,i),{getMany:T,getOne:y}=C(f),D=h({resource:P,meta:i});Ye({resource:x,types:["*"],params:{ids:t,meta:D,metaData:D,subscriptionType:"useMany",...d},channel:`resources/${P.name}`,enabled:R,liveMode:u,onLiveEvent:p});let L=ds(b.many(t),({queryKey:w,pageParam:E,signal:I})=>T?T({resource:P==null?void 0:P.name,ids:t,meta:{...D,queryContext:{queryKey:w,pageParam:E,signal:I}},metaData:{...D,queryContext:{queryKey:w,pageParam:E,signal:I}}}):Ge(t.map(F=>y({resource:P==null?void 0:P.name,id:F,meta:{...D,queryContext:{queryKey:w,pageParam:E,signal:I}},metaData:{...D,queryContext:{queryKey:w,pageParam:E,signal:I}}}))),{...r,onSuccess:w=>{var I;(I=r==null?void 0:r.onSuccess)==null||I.call(r,w);let E=typeof o=="function"?o(w,t,x):o;S(E)},onError:w=>{var I;U(w),(I=r==null?void 0:r.onError)==null||I.call(r,w);let E=typeof n=="function"?n(w,t,x):n;S(E,{key:`${t[0]}-${x}-getMany-notification`,message:v("notifications.error",{statusCode:w.statusCode},`Error (status code: ${w.statusCode})`),description:w.message,type:"error"})}}),{elapsedTime:A}=_({isLoading:L.isFetching,interval:c==null?void 0:c.interval,onInterval:c==null?void 0:c.onInterval});return{...L,overtime:{elapsedTime:A}}};import{useMutation as ys,useQueryClient as gs}from"@tanstack/react-query";import Qr,{useReducer as ls}from"react";import Fr from"lodash-es/isEqual";var or=Qr.createContext({notifications:[],notificationDispatch:()=>!1}),ms=[],fs=(e,t)=>{switch(t.type){case"ADD":return[...e.filter(o=>!(Fr(o.id,t.payload.id)&&o.resource==t.payload.resource)),{...t.payload,isRunning:!0}];case"REMOVE":return e.filter(o=>!(Fr(o.id,t.payload.id)&&o.resource==t.payload.resource));case"DECREASE_NOTIFICATION_SECOND":return e.map(o=>Fr(o.id,t.payload.id)&&o.resource==t.payload.resource?{...o,seconds:t.payload.seconds-1e3}:o);default:return e}},kr=({children:e})=>{let[t,r]=ls(fs,ms),o={notifications:t,notificationDispatch:r};return Qr.createElement(or.Provider,{value:o},e,typeof window<"u"&&t.map(n=>Qr.createElement(Ao,{key:`${n.id}-${n.resource}-queue`,notification:n})))};var Vr=({mutationOptions:e,overtimeOptions:t}={})=>{let{resources:r,select:o}=k(),n=gs(),a=Y(),{mutationMode:s,undoableTimeout:u}=ke(),p=B(),d=W(),{mutate:l}=re({v3LegacyAuthProviderCompatible:!!(d!=null&&d.isLegacy)}),c=we(),{log:m}=Se(),{notificationDispatch:P}=He(),x=oe(),C=Ae(),v=K(),{options:{textTransformers:g}}=ae(),U=ys(({id:h,values:i,resource:f,mutationMode:R,undoableTimeout:b,onCancel:T,meta:y,metaData:D,dataProviderName:L})=>{let{resource:A,identifier:w}=o(f),E=v({resource:A,meta:M(y,D)}),I=R??s,F=b??u;return I!=="undoable"?a(N(w,L,r)).update({resource:A.name,id:h,variables:i,meta:E,metaData:E}):new Promise((O,G)=>{let X=()=>{a(N(w,L,r)).update({resource:A.name,id:h,variables:i,meta:E,metaData:E}).then(Q=>O(Q)).catch(Q=>G(Q))},j=()=>{G({message:"mutationCancelled"})};T&&T(j),P({type:"ADD",payload:{id:h,resource:w,cancelMutation:j,doMutation:X,seconds:F,isSilent:!!T}})})},{onMutate:async({resource:h,id:i,mutationMode:f,values:R,dataProviderName:b,meta:T,metaData:y})=>{let{identifier:D}=o(h),L=M(T,y),A=q(D,N(D,b,r),L),w=n.getQueriesData(A.resourceAll),E=f??s;return await n.cancelQueries(A.resourceAll,void 0,{silent:!0}),E!=="pessimistic"&&(n.setQueriesData(A.list(),I=>{if(!I)return null;let F=I.data.map(V=>{var O;return((O=V.id)==null?void 0:O.toString())===(i==null?void 0:i.toString())?{id:i,...V,...R}:V});return{...I,data:F}}),n.setQueriesData(A.many(),I=>{if(!I)return null;let F=I.data.map(V=>{var O;return((O=V.id)==null?void 0:O.toString())===(i==null?void 0:i.toString())&&(V={id:i,...V,...R}),V});return{...I,data:F}}),n.setQueriesData(A.detail(i),I=>I?{...I,data:{...I.data,...R}}:null)),{previousQueries:w,queryKey:A}},onSettled:(h,i,{id:f,resource:R,dataProviderName:b,invalidates:T=["list","many","detail"]})=>{let{identifier:y}=o(R);C({resource:y,dataProviderName:N(y,b,r),invalidates:T,id:f}),P({type:"REMOVE",payload:{id:f,resource:y}})},onSuccess:(h,{id:i,resource:f,successNotification:R,dataProviderName:b,values:T,meta:y,metaData:D},L)=>{var j;let{resource:A,identifier:w}=o(f),E=g.singular(w),I=typeof R=="function"?R(h,{id:i,values:T},w):R;x(I,{key:`${i}-${w}-notification`,description:p("notifications.success","Successful"),message:p("notifications.editSuccess",{resource:p(`${w}.${w}`,E)},`Successfully updated ${E}`),type:"success"}),c==null||c({channel:`resources/${A.name}`,type:"updated",payload:{ids:(j=h.data)!=null&&j.id?[h.data.id]:void 0},date:new Date});let F;if(L){let Q=n.getQueryData(L.queryKey.detail(i));F=Object.keys(T||{}).reduce(($,H)=>{var Z;return $[H]=(Z=Q==null?void 0:Q.data)==null?void 0:Z[H],$},{})}let{fields:V,operation:O,variables:G,...X}=M(y,D)||{};m==null||m.mutate({action:"update",resource:A.name,data:T,previousData:F,meta:{id:i,dataProviderName:N(w,b,r),...X}})},onError:(h,{id:i,resource:f,errorNotification:R,values:b},T)=>{let{identifier:y}=o(f);if(T)for(let D of T.previousQueries)n.setQueryData(D[0],D[1]);if(h.message!=="mutationCancelled"){l==null||l(h);let D=g.singular(y),L=typeof R=="function"?R(h,{id:i,values:b},y):R;x(L,{key:`${i}-${y}-notification`,message:p("notifications.editError",{resource:p(`${y}.${y}`,D),statusCode:h.statusCode},`Error when updating ${D} (status code: ${h.statusCode})`),description:h.message,type:"error"})}},...e}),{elapsedTime:S}=_({isLoading:U.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...U,overtime:{elapsedTime:S}}};import{useMutation as Ts}from"@tanstack/react-query";var wt=({mutationOptions:e,overtimeOptions:t}={})=>{let r=W(),{mutate:o}=re({v3LegacyAuthProviderCompatible:!!(r!=null&&r.isLegacy)}),n=Y(),a=Ae(),{resources:s,select:u}=k(),p=B(),d=we(),{log:l}=Se(),c=oe(),m=K(),{options:{textTransformers:P}}=ae(),x=Ts(({resource:v,values:g,meta:U,metaData:S,dataProviderName:h})=>{let{resource:i,identifier:f}=u(v),R=m({resource:i,meta:M(U,S)});return n(N(f,h,s)).create({resource:i.name,variables:g,meta:R,metaData:R})},{onSuccess:(v,{resource:g,successNotification:U,dataProviderName:S,invalidates:h=["list","many"],values:i,meta:f,metaData:R})=>{var F,V;let{resource:b,identifier:T}=u(g),y=P.singular(T),D=typeof U=="function"?U(v,i,T):U;c(D,{key:`create-${T}-notification`,message:p("notifications.createSuccess",{resource:p(`${T}.${T}`,y)},`Successfully created ${y}`),description:p("notifications.success","Success"),type:"success"}),a({resource:T,dataProviderName:N(T,S,s),invalidates:h}),d==null||d({channel:`resources/${b.name}`,type:"created",payload:{ids:(F=v==null?void 0:v.data)!=null&&F.id?[v.data.id]:void 0},date:new Date});let L=m({resource:b,meta:M(f,R)}),{fields:A,operation:w,variables:E,...I}=L||{};l==null||l.mutate({action:"create",resource:b.name,data:i,meta:{dataProviderName:N(T,S,s),id:((V=v==null?void 0:v.data)==null?void 0:V.id)??void 0,...I}})},onError:(v,{resource:g,errorNotification:U,values:S})=>{o(v);let{identifier:h}=u(g),i=P.singular(h),f=typeof U=="function"?U(v,S,h):U;c(f,{key:`create-${h}-notification`,description:v.message,message:p("notifications.createError",{resource:p(`${h}.${h}`,i),statusCode:v.statusCode},`There was an error creating ${i} (status code: ${v.statusCode})`),type:"error"})},...e}),{elapsedTime:C}=_({isLoading:x.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...x,overtime:{elapsedTime:C}}};import{useQueryClient as Rs,useMutation as Ps}from"@tanstack/react-query";var xs=({mutationOptions:e,overtimeOptions:t}={})=>{let r=W(),{mutate:o}=re({v3LegacyAuthProviderCompatible:!!(r!=null&&r.isLegacy)}),n=Y(),{resources:a,select:s}=k(),u=Rs(),{mutationMode:p,undoableTimeout:d}=ke(),{notificationDispatch:l}=He(),c=B(),m=we(),{log:P}=Se(),x=oe(),C=Ae(),v=K(),{options:{textTransformers:g}}=ae(),U=Ps(({id:h,mutationMode:i,undoableTimeout:f,resource:R,onCancel:b,meta:T,metaData:y,dataProviderName:D,values:L})=>{let{resource:A,identifier:w}=s(R),E=v({resource:A,meta:M(T,y)}),I=i??p,F=f??d;return I!=="undoable"?n(N(w,D,a)).deleteOne({resource:A.name,id:h,meta:E,metaData:E,variables:L}):new Promise((O,G)=>{let X=()=>{n(N(w,D,a)).deleteOne({resource:A.name,id:h,meta:E,metaData:E,variables:L}).then(Q=>O(Q)).catch(Q=>G(Q))},j=()=>{G({message:"mutationCancelled"})};b&&b(j),l({type:"ADD",payload:{id:h,resource:w,cancelMutation:j,doMutation:X,seconds:F,isSilent:!!b}})})},{onMutate:async({id:h,resource:i,mutationMode:f,dataProviderName:R,meta:b,metaData:T})=>{let{identifier:y}=s(i),D=M(b,T),L=q(y,N(y,R,a),D),A=f??p;await u.cancelQueries(L.resourceAll,void 0,{silent:!0});let w=u.getQueriesData(L.resourceAll);return A!=="pessimistic"&&(u.setQueriesData(L.list(),E=>E?{data:E.data.filter(F=>{var V;return((V=F.id)==null?void 0:V.toString())!==h.toString()}),total:E.total-1}:null),u.setQueriesData(L.many(),E=>{if(!E)return null;let I=E.data.filter(F=>{var V;return((V=F.id)==null?void 0:V.toString())!==(h==null?void 0:h.toString())});return{...E,data:I}})),{previousQueries:w,queryKey:L}},onSettled:(h,i,{id:f,resource:R,dataProviderName:b,invalidates:T=["list","many"]})=>{let{identifier:y}=s(R);C({resource:y,dataProviderName:N(y,b,a),invalidates:T}),l({type:"REMOVE",payload:{id:f,resource:y}})},onSuccess:(h,{id:i,resource:f,successNotification:R,dataProviderName:b,meta:T,metaData:y},D)=>{let{resource:L,identifier:A}=s(f),w=g.singular(A);u.removeQueries(D==null?void 0:D.queryKey.detail(i));let E=typeof R=="function"?R(h,i,A):R;x(E,{key:`${i}-${A}-notification`,description:c("notifications.success","Success"),message:c("notifications.deleteSuccess",{resource:c(`${A}.${A}`,w)},`Successfully deleted a ${w}`),type:"success"}),m==null||m({channel:`resources/${L.name}`,type:"deleted",payload:{ids:[i]},date:new Date});let I=v({resource:L,meta:M(T,y)}),{fields:F,operation:V,variables:O,...G}=I||{};P==null||P.mutate({action:"delete",resource:L.name,meta:{id:i,dataProviderName:N(A,b,a),...G}}),u.removeQueries(D==null?void 0:D.queryKey.detail(i))},onError:(h,{id:i,resource:f,errorNotification:R},b)=>{let{identifier:T}=s(f);if(b)for(let y of b.previousQueries)u.setQueryData(y[0],y[1]);if(h.message!=="mutationCancelled"){o(h);let y=g.singular(T),D=typeof R=="function"?R(h,i,T):R;x(D,{key:`${i}-${T}-notification`,message:c("notifications.deleteError",{resource:y,statusCode:h.statusCode},`Error (status code: ${h.statusCode})`),description:h.message,type:"error"})}},...e}),{elapsedTime:S}=_({isLoading:U.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...U,overtime:{elapsedTime:S}}};import{useMutation as Cs}from"@tanstack/react-query";var Br=({mutationOptions:e,overtimeOptions:t}={})=>{let r=Y(),{resources:o,select:n}=k(),a=B(),s=we(),u=oe(),p=Ae(),{log:d}=Se(),l=K(),{options:{textTransformers:c}}=ae(),m=Cs(({resource:x,values:C,meta:v,metaData:g,dataProviderName:U})=>{let{resource:S,identifier:h}=n(x),i=l({resource:S,meta:M(v,g)}),f=r(N(h,U,o));return f.createMany?f.createMany({resource:S.name,variables:C,meta:i,metaData:i}):Ge(C.map(R=>f.create({resource:S.name,variables:R,meta:i,metaData:i})))},{onSuccess:(x,{resource:C,successNotification:v,dataProviderName:g,invalidates:U=["list","many"],values:S,meta:h,metaData:i})=>{let{resource:f,identifier:R}=n(C),b=c.plural(R),T=typeof v=="function"?v(x,S,R):v;u(T,{key:`createMany-${R}-notification`,message:a("notifications.createSuccess",{resource:a(`${R}.${R}`,R)},`Successfully created ${b}`),description:a("notifications.success","Success"),type:"success"}),p({resource:R,dataProviderName:N(R,g,o),invalidates:U});let y=x==null?void 0:x.data.filter(I=>(I==null?void 0:I.id)!==void 0).map(I=>I.id);s==null||s({channel:`resources/${f.name}`,type:"created",payload:{ids:y},date:new Date});let D=l({resource:f,meta:M(h,i)}),{fields:L,operation:A,variables:w,...E}=D||{};d==null||d.mutate({action:"createMany",resource:f.name,data:S,meta:{dataProviderName:N(R,g,o),ids:y,...E}})},onError:(x,{resource:C,errorNotification:v,values:g})=>{let{identifier:U}=n(C),S=typeof v=="function"?v(x,g,U):v;u(S,{key:`createMany-${U}-notification`,description:x.message,message:a("notifications.createError",{resource:a(`${U}.${U}`,U),statusCode:x.statusCode},`There was an error creating ${U} (status code: ${x.statusCode}`),type:"error"})},...e}),{elapsedTime:P}=_({isLoading:m.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...m,overtime:{elapsedTime:P}}};import{useMutation as hs,useQueryClient as bs}from"@tanstack/react-query";var vs=({mutationOptions:e,overtimeOptions:t}={})=>{let{resources:r,select:o}=k(),n=bs(),a=Y(),s=B(),{mutationMode:u,undoableTimeout:p}=ke(),d=W(),{mutate:l}=re({v3LegacyAuthProviderCompatible:!!(d!=null&&d.isLegacy)}),{notificationDispatch:c}=He(),m=we(),P=oe(),x=Ae(),{log:C}=Se(),v=K(),{options:{textTransformers:g}}=ae(),U=hs(({ids:h,values:i,resource:f,onCancel:R,mutationMode:b,undoableTimeout:T,meta:y,metaData:D,dataProviderName:L})=>{let{resource:A,identifier:w}=o(f),E=v({resource:A,meta:M(y,D)}),I=b??u,F=T??p,V=a(N(w,L,r)),O=()=>V.updateMany?V.updateMany({resource:A.name,ids:h,variables:i,meta:E,metaData:E}):Ge(h.map(X=>V.update({resource:A.name,id:X,variables:i,meta:E,metaData:E})));return I!=="undoable"?O():new Promise((X,j)=>{let Q=()=>{O().then(H=>X(H)).catch(H=>j(H))},$=()=>{j({message:"mutationCancelled"})};R&&R($),c({type:"ADD",payload:{id:h,resource:w,cancelMutation:$,doMutation:Q,seconds:F,isSilent:!!R}})})},{onMutate:async({resource:h,ids:i,values:f,mutationMode:R,dataProviderName:b,meta:T,metaData:y})=>{let{identifier:D}=o(h),L=q(D,N(D,b,r),M(T,y)),A=R??u;await n.cancelQueries(L.resourceAll,void 0,{silent:!0});let w=n.getQueriesData(L.resourceAll);if(A!=="pessimistic"){n.setQueriesData(L.list(),E=>{if(!E)return null;let I=E.data.map(F=>F.id!==void 0&&i.filter(V=>V!==void 0).map(String).includes(F.id.toString())?{...F,...f}:F);return{...E,data:I}}),n.setQueriesData(L.many(),E=>{if(!E)return null;let I=E.data.map(F=>F.id!==void 0&&i.filter(V=>V!==void 0).map(String).includes(F.id.toString())?{...F,...f}:F);return{...E,data:I}});for(let E of i)n.setQueriesData(L.detail(E),I=>{if(!I)return null;let F={...I.data,...f};return{...I,data:F}})}return{previousQueries:w,queryKey:L}},onSettled:(h,i,{ids:f,resource:R,dataProviderName:b})=>{let{identifier:T}=o(R);x({resource:T,invalidates:["list","many"],dataProviderName:N(T,b,r)}),f.forEach(y=>x({resource:T,invalidates:["detail"],dataProviderName:N(T,b,r),id:y})),c({type:"REMOVE",payload:{id:f,resource:T}})},onSuccess:(h,{ids:i,resource:f,meta:R,metaData:b,dataProviderName:T,successNotification:y,values:D},L)=>{let{resource:A,identifier:w}=o(f),E=g.singular(w),I=typeof y=="function"?y(h,{ids:i,values:D},w):y;P(I,{key:`${i}-${w}-notification`,description:s("notifications.success","Successful"),message:s("notifications.editSuccess",{resource:s(`${w}.${w}`,w)},`Successfully updated ${E}`),type:"success"}),m==null||m({channel:`resources/${A.name}`,type:"updated",payload:{ids:i.map(String)},date:new Date});let F=[];L&&i.forEach(Q=>{let $=n.getQueryData(L.queryKey.detail(Q));F.push(Object.keys(D||{}).reduce((H,Z)=>{var se;return H[Z]=(se=$==null?void 0:$.data)==null?void 0:se[Z],H},{}))});let V=v({resource:A,meta:M(R,b)}),{fields:O,operation:G,variables:X,...j}=V||{};C==null||C.mutate({action:"updateMany",resource:A.name,data:D,previousData:F,meta:{ids:i,dataProviderName:N(w,T,r),...j}})},onError:(h,{ids:i,resource:f,errorNotification:R,values:b},T)=>{let{identifier:y}=o(f);if(T)for(let D of T.previousQueries)n.setQueryData(D[0],D[1]);if(h.message!=="mutationCancelled"){l==null||l(h);let D=g.singular(y),L=typeof R=="function"?R(h,{ids:i,values:b},y):R;P(L,{key:`${i}-${y}-updateMany-error-notification`,message:s("notifications.editError",{resource:D,statusCode:h.statusCode},`Error when updating ${D} (status code: ${h.statusCode})`),description:h.message,type:"error"})}},...e}),{elapsedTime:S}=_({isLoading:U.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...U,overtime:{elapsedTime:S}}};import{useQueryClient as Ds,useMutation as Ls}from"@tanstack/react-query";var Es=({mutationOptions:e,overtimeOptions:t}={})=>{let r=W(),{mutate:o}=re({v3LegacyAuthProviderCompatible:!!(r!=null&&r.isLegacy)}),{mutationMode:n,undoableTimeout:a}=ke(),s=Y(),{notificationDispatch:u}=He(),p=B(),d=we(),l=oe(),c=Ae(),{log:m}=Se(),{resources:P,select:x}=k(),C=Ds(),v=K(),{options:{textTransformers:g}}=ae(),U=Ls(({resource:h,ids:i,mutationMode:f,undoableTimeout:R,onCancel:b,meta:T,metaData:y,dataProviderName:D,values:L})=>{let{resource:A,identifier:w}=x(h),E=v({resource:A,meta:M(T,y)}),I=f??n,F=R??a,V=s(N(w,D,P)),O=()=>V.deleteMany?V.deleteMany({resource:A.name,ids:i,meta:E,metaData:E,variables:L}):Ge(i.map(X=>V.deleteOne({resource:A.name,id:X,meta:E,metaData:E,variables:L})));return I!=="undoable"?O():new Promise((X,j)=>{let Q=()=>{O().then(H=>X(H)).catch(H=>j(H))},$=()=>{j({message:"mutationCancelled"})};b&&b($),u({type:"ADD",payload:{id:i,resource:w,cancelMutation:$,doMutation:Q,seconds:F,isSilent:!!b}})})},{onMutate:async({ids:h,resource:i,mutationMode:f,dataProviderName:R,meta:b,metaData:T})=>{let{identifier:y}=x(i),D=M(b,T),L=q(y,N(y,R,P),D),A=f??n;await C.cancelQueries(L.resourceAll,void 0,{silent:!0});let w=C.getQueriesData(L.resourceAll);if(A!=="pessimistic"){C.setQueriesData(L.list(),E=>E?{data:E.data.filter(F=>F.id&&!h.map(String).includes(F.id.toString())),total:E.total-1}:null),C.setQueriesData(L.many(),E=>{if(!E)return null;let I=E.data.filter(F=>F.id?!h.map(String).includes(F.id.toString()):!1);return{...E,data:I}});for(let E of h)C.setQueriesData(L.detail(E),I=>!I||I.data.id==E?null:{...I})}return{previousQueries:w,queryKey:L}},onSettled:(h,i,{resource:f,ids:R,dataProviderName:b,invalidates:T=["list","many"]})=>{let{identifier:y}=x(f);c({resource:y,dataProviderName:N(y,b,P),invalidates:T}),u({type:"REMOVE",payload:{id:R,resource:y}})},onSuccess:(h,{ids:i,resource:f,meta:R,metaData:b,dataProviderName:T,successNotification:y},D)=>{let{resource:L,identifier:A}=x(f);i.forEach(G=>C.removeQueries(D==null?void 0:D.queryKey.detail(G)));let w=typeof y=="function"?y(h,i,A):y;l(w,{key:`${i}-${A}-notification`,description:p("notifications.success","Success"),message:p("notifications.deleteSuccess",{resource:p(`${A}.${A}`,A)},`Successfully deleted ${A}`),type:"success"}),d==null||d({channel:`resources/${L.name}`,type:"deleted",payload:{ids:i},date:new Date});let E=v({resource:L,meta:M(R,b)}),{fields:I,operation:F,variables:V,...O}=E||{};m==null||m.mutate({action:"deleteMany",resource:L.name,meta:{ids:i,dataProviderName:N(A,T,P),...O}}),i.forEach(G=>C.removeQueries(D==null?void 0:D.queryKey.detail(G)))},onError:(h,{ids:i,resource:f,errorNotification:R},b)=>{let{identifier:T}=x(f);if(b)for(let y of b.previousQueries)C.setQueryData(y[0],y[1]);if(h.message!=="mutationCancelled"){o(h);let y=g.singular(T),D=typeof R=="function"?R(h,i,T):R;l(D,{key:`${i}-${T}-notification`,message:p("notifications.deleteError",{resource:y,statusCode:h.statusCode},`Error (status code: ${h.statusCode})`),description:h.message,type:"error"})}},...e}),{elapsedTime:S}=_({isLoading:U.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...U,overtime:{elapsedTime:S}}};var Us=e=>{var n;let t=Y(),{resource:r}=k(),{getApiUrl:o}=t(e??((n=M(r==null?void 0:r.meta,r==null?void 0:r.options))==null?void 0:n.dataProviderName));return o()};import{useQuery as Ms}from"@tanstack/react-query";var Is=({url:e,method:t,config:r,queryOptions:o,successNotification:n,errorNotification:a,meta:s,metaData:u,dataProviderName:p,overtimeOptions:d})=>{let l=Y(),c=W(),{mutate:m}=re({v3LegacyAuthProviderCompatible:!!(c!=null&&c.isLegacy)}),P=B(),x=oe(),C=K(),v=M(s,u),{custom:g}=l(p),U=C({meta:v});if(g){let S=Ms({queryKey:[p,"custom",t,e,{...r,...v||{}}],queryFn:({queryKey:i,pageParam:f,signal:R})=>g({url:e,method:t,...r,meta:{...U,queryContext:{queryKey:i,pageParam:f,signal:R}},metaData:{...U,queryContext:{queryKey:i,pageParam:f,signal:R}}}),...o,onSuccess:i=>{var R;(R=o==null?void 0:o.onSuccess)==null||R.call(o,i);let f=typeof n=="function"?n(i,{...r,...U}):n;x(f)},onError:i=>{var R;m(i),(R=o==null?void 0:o.onError)==null||R.call(o,i);let f=typeof a=="function"?a(i,{...r,...U}):a;x(f,{key:`${t}-notification`,message:P("notifications.error",{statusCode:i.statusCode},`Error (status code: ${i.statusCode})`),description:i.message,type:"error"})}}),{elapsedTime:h}=_({isLoading:S.isFetching,interval:d==null?void 0:d.interval,onInterval:d==null?void 0:d.onInterval});return{...S,overtime:{elapsedTime:h}}}else throw Error("Not implemented custom on data provider.")};import{useMutation as ws}from"@tanstack/react-query";var Ss=({mutationOptions:e,overtimeOptions:t}={})=>{let r=W(),{mutate:o}=re({v3LegacyAuthProviderCompatible:!!(r!=null&&r.isLegacy)}),n=oe(),a=Y(),s=B(),u=K(),p=ws(({url:l,method:c,values:m,meta:P,metaData:x,dataProviderName:C,config:v})=>{let g=u({meta:M(P,x)}),{custom:U}=a(C);if(U)return U({url:l,method:c,payload:m,meta:g,metaData:g,headers:{...v==null?void 0:v.headers}});throw Error("Not implemented custom on data provider.")},{onSuccess:(l,{successNotification:c,config:m,meta:P,metaData:x})=>{let C=typeof c=="function"?c(l,{...m,...M(P,x)||{}}):c;n(C)},onError:(l,{errorNotification:c,method:m,config:P,meta:x,metaData:C})=>{o(l);let v=typeof c=="function"?c(l,{...P,...M(x,C)||{}}):c;n(v,{key:`${m}-notification`,message:s("notifications.error",{statusCode:l.statusCode},`Error (status code: ${l.statusCode})`),description:l.message,type:"error"})},...e}),{elapsedTime:d}=_({isLoading:p.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...p,overtime:{elapsedTime:d}}};import{useCallback as Fs,useContext as Qs}from"react";import Fo from"react";var As=()=>({default:{create:()=>Promise.resolve({data:{id:1}}),createMany:()=>Promise.resolve({data:[]}),deleteOne:()=>Promise.resolve({data:{id:1}}),deleteMany:()=>Promise.resolve({data:[]}),getList:()=>Promise.resolve({data:[],total:0}),getMany:()=>Promise.resolve({data:[]}),getOne:()=>Promise.resolve({data:{id:1}}),update:()=>Promise.resolve({data:{id:1}}),updateMany:()=>Promise.resolve({data:[]}),custom:()=>Promise.resolve({data:{}}),getApiUrl:()=>""}}),St=Fo.createContext(As()),Qo=({children:e,...t})=>{let r;return!t.getList||!t.getOne?r=t:r={default:t},Fo.createElement(St.Provider,{value:r},e)};var Y=()=>{let e=Qs(St);return Fs(r=>{if(r){if(!e[r])throw new Error(`"${r}" Data provider not found`);return e[r]}if(e.default)return e.default;throw new Error('There is no "default" data provider. Please pass dataProviderName.')},[e])};import{useInfiniteQuery as ks}from"@tanstack/react-query";var Vs=({resource:e,config:t,filters:r,hasPagination:o,pagination:n,sorters:a,queryOptions:s,successNotification:u,errorNotification:p,meta:d,metaData:l,liveMode:c,onLiveEvent:m,liveParams:P,dataProviderName:x,overtimeOptions:C})=>{let{resources:v,resource:g,identifier:U}=k(e),S=Y(),h=B(),i=W(),{mutate:f}=re({v3LegacyAuthProviderCompatible:!!(i!=null&&i.isLegacy)}),R=oe(),b=K(),T=N(U,x,v),y=M(d,l),D=M(r,t==null?void 0:t.filters),L=M(a,t==null?void 0:t.sort),A=M(o,t==null?void 0:t.hasPagination),w=Et({pagination:n,configPagination:t==null?void 0:t.pagination,hasPagination:A}),E=w.mode==="server",I={meta:y,metaData:y,filters:D,hasPagination:E,pagination:w,sorters:L,config:{...t,sort:L}},F=(s==null?void 0:s.enabled)===void 0||(s==null?void 0:s.enabled)===!0,V=q(U,T,y,y),O=b({resource:g,meta:y}),{getList:G}=S(T);Ye({resource:U,types:["*"],params:{meta:O,metaData:O,pagination:w,hasPagination:E,sort:L,sorters:L,filters:D,subscriptionType:"useList",...P},channel:`resources/${g.name}`,enabled:F,liveMode:c,onLiveEvent:m});let X=ks(V.list({filters:D,hasPagination:E,...E&&{pagination:w},...a&&{sorters:a},...(t==null?void 0:t.sort)&&{sort:t==null?void 0:t.sort}}),({queryKey:Q,pageParam:$,signal:H})=>{let Z={...w,current:$};return G({resource:g.name,pagination:Z,hasPagination:E,filters:D,sort:L,sorters:L,meta:{...O,queryContext:{queryKey:Q,pageParam:$,signal:H}},metaData:{...O,queryContext:{queryKey:Q,pageParam:$,signal:H}}}).then(({data:se,total:ge,...qe})=>({data:se,total:ge,pagination:Z,...qe}))},{getNextPageParam:Q=>Xt(Q),getPreviousPageParam:Q=>qt(Q),...s,onSuccess:Q=>{var H;(H=s==null?void 0:s.onSuccess)==null||H.call(s,Q);let $=typeof u=="function"?u(Q,I,U):u;R($)},onError:Q=>{var H;f(Q),(H=s==null?void 0:s.onError)==null||H.call(s,Q);let $=typeof p=="function"?p(Q,I,U):p;R($,{key:`${U}-useInfiniteList-notification`,message:h("notifications.error",{statusCode:Q.statusCode},`Error (status code: ${Q.statusCode})`),description:Q.message,type:"error"})}}),{elapsedTime:j}=_({isLoading:X.isFetching,interval:C==null?void 0:C.interval,onInterval:C==null?void 0:C.onInterval});return{...X,overtime:{elapsedTime:j}}};import{useContext as _o,useEffect as Zs}from"react";import{useQueryClient as Ys}from"@tanstack/react-query";import ko from"react";var We=ko.createContext(void 0),Vo=({liveProvider:e,children:t})=>ko.createElement(We.Provider,{value:e},t);import{useContext as zs}from"react";import No from"react";import{useMemo as Hs}from"react";import{useRef as Bs}from"react";import Ns from"lodash-es/isEqual";var Bo=e=>{let t=Bs(e);return Ns(t.current,e)||(t.current=e),t.current};var nr=(e,t)=>{let r=Bo(t);return Hs(e,r)};var Je=No.createContext({resources:[]}),Ho=({resources:e,children:t})=>{let r=nr(()=>er(e??[]),[e]);return No.createElement(Je.Provider,{value:{resources:r}},t)};import Oo from"react";var $o=Oo.createContext("new"),Go=$o.Provider,z=()=>Oo.useContext($o);import Ks from"react";import Os,{createContext as $s}from"react";var Wo={},Ke=$s(Wo),Ko=({children:e,router:t})=>Os.createElement(Ke.Provider,{value:t??Wo},e);import Gs,{useContext as Ws}from"react";var Nr=()=>{let e=Ws(Ke);return Gs.useMemo(()=>(e==null?void 0:e.parse)??(()=>()=>({})),[e==null?void 0:e.parse])()};var de=()=>{let e=Nr();return Ks.useMemo(()=>e(),[e])};function k(e){let{resources:t}=zs(Je),r=z(),o=de(),n={resourceName:e&&typeof e!="string"?e.resourceName:e,resourceNameOrRouteName:e&&typeof e!="string"?e.resourceNameOrRouteName:e,recordItemId:e&&typeof e!="string"?e.recordItemId:void 0},a=(c,m=!0)=>{let x=pe(c,t,r==="legacy");if(x)return{resource:x,identifier:x.identifier??x.name};if(m){let C={name:c,identifier:c},v=C.identifier??C.name;return{resource:C,identifier:v}}},s=zo(),{useParams:u}=te(),p=u();if(r==="legacy"){let c=n.resourceNameOrRouteName?n.resourceNameOrRouteName:p.resource,m=c?s(c):void 0,P=(n==null?void 0:n.recordItemId)??p.id,x=p.action,C=(n==null?void 0:n.resourceName)??(m==null?void 0:m.name),v=(m==null?void 0:m.identifier)??(m==null?void 0:m.name);return{resources:t,resource:m,resourceName:C,id:P,action:x,select:a,identifier:v}}let d,l=typeof e=="string"?e:n==null?void 0:n.resourceNameOrRouteName;if(l){let c=pe(l,t);c?d=c:d={name:l}}else o!=null&&o.resource&&(d=o.resource);return{resources:t,resource:d,resourceName:d==null?void 0:d.name,id:o.id,action:o.action,select:a,identifier:(d==null?void 0:d.identifier)??(d==null?void 0:d.name)}}import{useContext as _s,useCallback as js}from"react";var zo=()=>{let{resources:e}=_s(Je);return js(r=>{let o=pe(r,e,!0);return o||{name:r,route:r}},[e])};var Ye=({resource:e,params:t,channel:r,types:o,enabled:n=!0,liveMode:a,onLiveEvent:s})=>{let u=Ys(),{resource:p,identifier:d}=k(e),l=q(d),c=_o(We),{liveMode:m,onLiveEvent:P}=_o(Ce),x=a??m;Zs(()=>{let C;return x&&x!=="off"&&n&&(C=c==null?void 0:c.subscribe({channel:r,params:{resource:p==null?void 0:p.name,...t},types:o,callback:v=>{x==="auto"&&u.invalidateQueries(l.resourceAll),s==null||s(v),P==null||P(v)}})),()=>{C&&(c==null||c.unsubscribe(C))}},[n])};import{useContext as Js}from"react";var jo=e=>{let{liveMode:t}=Js(Ce);return e??t};import{useContext as Xs,useEffect as qs}from"react";var Iy=({params:e,channel:t,types:r=["*"],enabled:o=!0,onLiveEvent:n})=>{let a=Xs(We);qs(()=>{let s;return o&&(s=a==null?void 0:a.subscribe({channel:t,params:e,types:r,callback:n})),()=>{s&&(a==null||a.unsubscribe(s))}},[o])};import{useContext as ea}from"react";var we=()=>{let e=ea(We);return e==null?void 0:e.publish};import{useContext as ta}from"react";var He=()=>{let{notifications:e,notificationDispatch:t}=ta(or);return{notifications:e,notificationDispatch:t}};import{useContext as na}from"react";import ra,{createContext as oa}from"react";var At=oa({}),Zo=({open:e,close:t,children:r})=>ra.createElement(At.Provider,{value:{open:e,close:t}},r);var he=()=>{let{open:e,close:t}=na(At);return{open:e,close:t}};import{useCallback as sa}from"react";var oe=()=>{let{open:e}=he();return sa((r,o)=>{r!==!1&&(r?e==null||e(r):o&&(e==null||e(o)))},[])};import{useCallback as aa,useContext as ia}from"react";import Yo from"react";var Fe=Yo.createContext({}),Jo=({children:e,i18nProvider:t})=>Yo.createElement(Fe.Provider,{value:{i18nProvider:t}},e);var ua=()=>{let{i18nProvider:e}=ia(Fe);return aa(t=>e==null?void 0:e.changeLocale(t),[])};import{useContext as ca,useMemo as pa}from"react";var B=()=>{let{i18nProvider:e}=ca(Fe);return pa(()=>{function r(o,n,a){return(e==null?void 0:e.translate(o,n,a))??a??(typeof n=="string"&&typeof a>"u"?n:o)}return r},[e])};import{useContext as da,useCallback as la}from"react";var ma=()=>{let{i18nProvider:e}=da(Fe);return la(()=>e==null?void 0:e.getLocale(),[])};import{useState as fa}from"react";import{ExportToCsv as ya}from"export-to-csv-fix-source-map";var Cg=({resourceName:e,resource:t,sorter:r,sorters:o,filters:n,maxItemCount:a,pageSize:s=20,mapData:u=P=>P,exportOptions:p,meta:d,metaData:l,dataProviderName:c,onError:m}={})=>{let[P,x]=fa(!1),C=Y(),v=K(),{resource:g,resources:U,identifier:S}=k(M(t,e)),i=`${ft()(S,"plural")}-${new Date().toLocaleString()}`,{getList:f}=C(N(S,c,U)),R=v({resource:g,meta:M(d,l)});return{isLoading:P,triggerExport:async()=>{x(!0);let T=[],y=1,D=!0;for(;D;)try{let{data:A,total:w}=await f({resource:(g==null?void 0:g.name)??"",filters:n,sort:M(o,r),sorters:M(o,r),pagination:{current:y,pageSize:s,mode:"server"},meta:R,metaData:R});y++,T.push(...A),a&&T.length>=a&&(T=T.slice(0,a),D=!1),w===T.length&&(D=!1)}catch(A){x(!1),D=!1,m==null||m(A);return}new ya({filename:i,useKeysAsHeaders:!0,...p}).generateCsv(T.map(u)),x(!1)}}};import Xo from"react";import ga from"warn-once";var Fg=({resource:e,action:t,id:r,onMutationSuccess:o,onMutationError:n,redirect:a,successNotification:s,errorNotification:u,meta:p,metaData:d,queryMeta:l,mutationMeta:c,mutationMode:m,liveMode:P,onLiveEvent:x,liveParams:C,undoableTimeout:v,dataProviderName:g,invalidates:U,queryOptions:S,createMutationOptions:h,updateMutationOptions:i,overtimeOptions:f}={})=>{let{options:R}=ae(),b=K(),{resource:T,id:y,action:D,identifier:L}=k(e),{identifier:A}=k(),E=(()=>{let Te=r??y;return e&&e!==A?r:Te})(),[I,F]=Xo.useState(E);Xo.useEffect(()=>{F(E)},[E]);let O=(()=>t||(D==="edit"||D==="clone"?D:"create"))(),G=b({resource:T,meta:M(p,d)}),{mutationMode:X}=ke(),j=m??X,Q=O==="create",$=O==="edit",H=O==="clone";ga((H||$)&&!!e&&!r,`[useForm]: action: "${O}", resource: "${L}", id: ${I}
|
|
1
|
+
import Ot,{useEffect as Ja,useState as Xa}from"react";import mt from"react";var no=mt.createContext({}),ao=({children:e,isProvided:t,...r})=>{let{replace:o}=ue(),s=async p=>{var d;try{return await((d=r.login)==null?void 0:d.call(r,p))}catch(l){return Promise.reject(l)}},a=async p=>{var d;try{return await((d=r.register)==null?void 0:d.call(r,p))}catch(l){return Promise.reject(l)}},n=async p=>{var d;try{return await((d=r.logout)==null?void 0:d.call(r,p))}catch(l){return Promise.reject(l)}},u=async p=>{var d;try{return await((d=r.checkAuth)==null?void 0:d.call(r,p)),Promise.resolve()}catch(l){return l!=null&&l.redirectPath&&o(l.redirectPath),Promise.reject(l)}};return mt.createElement(no.Provider,{value:{...r,login:s,logout:n,checkAuth:u,register:a,isProvided:t}},e)},io=mt.createContext({}),uo=({children:e,isProvided:t,...r})=>{let o=async d=>{var l;try{return await((l=r.login)==null?void 0:l.call(r,d))}catch(c){return console.warn("Unhandled Error in login: refine always expects a resolved promise.",c),Promise.reject(c)}},s=async d=>{var l;try{return await((l=r.register)==null?void 0:l.call(r,d))}catch(c){return console.warn("Unhandled Error in register: refine always expects a resolved promise.",c),Promise.reject(c)}},a=async d=>{var l;try{return await((l=r.logout)==null?void 0:l.call(r,d))}catch(c){return console.warn("Unhandled Error in logout: refine always expects a resolved promise.",c),Promise.reject(c)}},n=async d=>{var l;try{let c=await((l=r.check)==null?void 0:l.call(r,d));return Promise.resolve(c)}catch(c){return console.warn("Unhandled Error in check: refine always expects a resolved promise.",c),Promise.reject(c)}},u=async d=>{var l;try{let c=await((l=r.forgotPassword)==null?void 0:l.call(r,d));return Promise.resolve(c)}catch(c){return console.warn("Unhandled Error in forgotPassword: refine always expects a resolved promise.",c),Promise.reject(c)}},p=async d=>{var l;try{let c=await((l=r.updatePassword)==null?void 0:l.call(r,d));return Promise.resolve(c)}catch(c){return console.warn("Unhandled Error in updatePassword: refine always expects a resolved promise.",c),Promise.reject(c)}};return mt.createElement(io.Provider,{value:{...r,login:o,logout:a,check:n,register:s,forgotPassword:u,updatePassword:p,isProvided:t}},e)},te=()=>mt.useContext(no),ie=()=>mt.useContext(io);import{useQuery as co}from"@tanstack/react-query";function Vs({v3LegacyAuthProviderCompatible:e=!1,options:t}={}){let{getPermissions:r}=te(),{getPermissions:o}=ie(),s=co(["usePermissions"],o??(()=>Promise.resolve(void 0)),{enabled:!e&&!!o,...e?{}:t}),a=co(["usePermissions","v3LegacyAuthProviderCompatible"],r??(()=>Promise.resolve(void 0)),{enabled:e&&!!r,...e?t:{}});return e?a:s}import{useQuery as po}from"@tanstack/react-query";function Tr({v3LegacyAuthProviderCompatible:e=!1,queryOptions:t}={}){let{getUserIdentity:r}=te(),{getIdentity:o}=ie(),s=po(["getUserIdentity"],o??(()=>Promise.resolve({})),{enabled:!e&&!!o,retry:!1,...e===!0?{}:t}),a=po(["getUserIdentity","v3LegacyAuthProviderCompatible"],r??(()=>Promise.resolve({})),{enabled:e&&!!r,retry:!1,...e?t:{}});return e?a:s}import{useMutation as lo}from"@tanstack/react-query";import{useQueryClient as Bs}from"@tanstack/react-query";var ft=()=>{let e=Bs();return async()=>{await Promise.all([e.invalidateQueries(["useAuthenticated"]),e.invalidateQueries(["getUserIdentity"]),e.invalidateQueries(["usePermissions"])])}};function jt({v3LegacyAuthProviderCompatible:e,mutationOptions:t}={}){let r=ft(),o=_(),s=ce(),{push:a}=ue(),{open:n,close:u}=De(),{logout:p}=te(),{logout:d}=ie(),l=lo(["useLogout"],d,{onSuccess:async(m,P)=>{let{success:x,error:C,redirectTo:v}=m,{redirectPath:g}=P??{},E=g??v;x&&(u==null||u("useLogout-error")),(C||!x)&&(n==null||n(Rr(C))),await r(),E!==!1&&(o==="legacy"?a(E??"/login"):E&&s({to:E}))},onError:m=>{n==null||n(Rr(m))},...e===!0?{}:t}),c=lo(["useLogout","v3LegacyAuthProviderCompatible"],p,{onSuccess:async(m,P)=>{let x=(P==null?void 0:P.redirectPath)??m;if(await r(),x!==!1){if(x){o==="legacy"?a(x):s({to:x});return}o==="legacy"?a("/login"):s({to:"/login"})}},onError:m=>{n==null||n(Rr(m))},...e?t:{}});return e?c:l}var Rr=e=>({key:"useLogout-error",type:"error",message:(e==null?void 0:e.name)||"Logout Error",description:(e==null?void 0:e.message)||"Something went wrong during logout"});import Ns from"react";import{useMutation as mo}from"@tanstack/react-query";import Hs from"qs";function Ut({v3LegacyAuthProviderCompatible:e,mutationOptions:t}={}){let r=ft(),o=_(),s=ce(),{replace:a}=ue(),n=le(),{useLocation:u}=re(),{search:p}=u(),{close:d,open:l}=De(),{login:c}=te(),{login:m}=ie(),P=Ns.useMemo(()=>{var v;return o==="legacy"?Hs.parse(p,{ignoreQueryPrefix:!0}).to:(v=n.params)==null?void 0:v.to},[o,n.params,p]),x=mo(["useLogin"],m,{onSuccess:async({success:v,redirectTo:g,error:E})=>{v&&(d==null||d("login-error")),(E||!v)&&(l==null||l(Pr(E))),await r(),P&&v?o==="legacy"?a(P):s({to:P,type:"replace"}):g?o==="legacy"?a(g):s({to:g,type:"replace"}):o==="legacy"&&a("/")},onError:v=>{l==null||l(Pr(v))},...e===!0?{}:t}),C=mo(["useLogin","v3LegacyAuthProviderCompatible"],c,{onSuccess:async v=>{await r(),P&&a(P),v!==!1&&!P&&(typeof v=="string"?o==="legacy"?a(v):s({to:v,type:"replace"}):o==="legacy"?a("/"):s({to:"/",type:"replace"})),d==null||d("login-error")},onError:v=>{l==null||l(Pr(v))},...e?t:{}});return e?C:x}var Pr=e=>({message:(e==null?void 0:e.name)||"Login Error",description:(e==null?void 0:e.message)||"Invalid credentials",key:"login-error",type:"error"});import{useMutation as fo}from"@tanstack/react-query";function Cr({v3LegacyAuthProviderCompatible:e,mutationOptions:t}={}){let r=ft(),o=_(),s=ce(),{replace:a}=ue(),{register:n}=te(),{register:u}=ie(),{close:p,open:d}=De(),l=fo(["useRegister"],u,{onSuccess:async({success:m,redirectTo:P,error:x})=>{m&&(p==null||p("register-error")),(x||!m)&&(d==null||d(xr(x))),await r(),P?o==="legacy"?a(P):s({to:P,type:"replace"}):o==="legacy"&&a("/")},onError:m=>{d==null||d(xr(m))},...e===!0?{}:t}),c=fo(["useRegister","v3LegacyAuthProviderCompatible"],n,{onSuccess:async m=>{await r(),m!==!1&&(m?o==="legacy"?a(m):s({to:m,type:"replace"}):o==="legacy"?a("/"):s({to:"/",type:"replace"}),p==null||p("register-error"))},onError:m=>{d==null||d(xr(m))},...e?t:{}});return e?c:l}var xr=e=>({message:(e==null?void 0:e.name)||"Register Error",description:(e==null?void 0:e.message)||"Error while registering",key:"register-error",type:"error"});import{useMutation as yo}from"@tanstack/react-query";function hr({v3LegacyAuthProviderCompatible:e,mutationOptions:t}={}){let r=_(),o=ce(),{replace:s}=ue(),{forgotPassword:a}=te(),{forgotPassword:n}=ie(),{close:u,open:p}=De(),d=yo(["useForgotPassword"],n,{onSuccess:({success:c,redirectTo:m,error:P})=>{c&&(u==null||u("forgot-password-error")),(P||!c)&&(p==null||p(br(P))),m&&(r==="legacy"?s(m):o({to:m,type:"replace"}))},onError:c=>{p==null||p(br(c))},...e===!0?{}:t}),l=yo(["useForgotPassword","v3LegacyAuthProviderCompatible"],a,{onSuccess:c=>{c!==!1&&c&&(r==="legacy"?s(c):o({to:c,type:"replace"})),u==null||u("forgot-password-error")},onError:c=>{p==null||p(br(c))},...e?t:{}});return e?l:d}var br=e=>({message:(e==null?void 0:e.name)||"Forgot Password Error",description:(e==null?void 0:e.message)||"Error while resetting password",key:"forgot-password-error",type:"error"});import Os from"react";import{useMutation as go}from"@tanstack/react-query";import $s from"qs";function Dr({v3LegacyAuthProviderCompatible:e,mutationOptions:t}={}){let r=_(),o=ce(),{replace:s}=ue(),{updatePassword:a}=te(),{updatePassword:n}=ie(),{close:u,open:p}=De(),d=le(),{useLocation:l}=re(),{search:c}=l(),m=Os.useMemo(()=>r==="legacy"?$s.parse(c,{ignoreQueryPrefix:!0})??{}:d.params??{},[c,d,r]),P=go(["useUpdatePassword"],async C=>n==null?void 0:n({...m,...C}),{onSuccess:({success:C,redirectTo:v,error:g})=>{C&&(u==null||u("update-password-error")),(g||!C)&&(p==null||p(vr(g))),v&&(r==="legacy"?s(v):o({to:v,type:"replace"}))},onError:C=>{p==null||p(vr(C))},...e===!0?{}:t}),x=go(["useUpdatePassword","v3LegacyAuthProviderCompatible"],async C=>a==null?void 0:a({...m,...C}),{onSuccess:C=>{C!==!1&&C&&(r==="legacy"?s(C):o({to:C,type:"replace"})),u==null||u("update-password-error")},onError:C=>{p==null||p(vr(C))},...e?t:{}});return e?x:P}var vr=e=>({message:(e==null?void 0:e.name)||"Update Password Error",description:(e==null?void 0:e.message)||"Error while updating password",key:"update-password-error",type:"error"});import{useQuery as To}from"@tanstack/react-query";function Zt({v3LegacyAuthProviderCompatible:e=!1,params:t}={}){let{checkAuth:r}=te(),{check:o}=ie(),s=To(["useAuthenticated",t],async()=>await(o==null?void 0:o(t))??{},{retry:!1,enabled:!e}),a=To(["useAuthenticated",t,"v3LegacyAuthProviderCompatible"],async()=>await(r==null?void 0:r(t))??{},{retry:!1,enabled:e});return e?a:s}var Gs=Zt;import{useMutation as Ro}from"@tanstack/react-query";function oe({v3LegacyAuthProviderCompatible:e=!1}={}){let t=_(),r=ce(),{replace:o}=ue(),{checkError:s}=te(),{onError:a}=ie(),{mutate:n}=jt({v3LegacyAuthProviderCompatible:!!e}),{mutate:u}=jt({v3LegacyAuthProviderCompatible:!!e}),p=Ro(["useCheckError"],a,{onSuccess:({logout:l,redirectTo:c})=>{if(l){u({redirectPath:c});return}if(c){t==="legacy"?o(c):r({to:c,type:"replace"});return}}}),d=Ro(["useCheckError","v3LegacyAuthProviderCompatible"],s,{onError:l=>{n({redirectPath:l})}});return e?d:p}var Ws=oe;var Lr=()=>{let{isProvided:e}=te(),{isProvided:t}=ie();return!!(t||e)};import{useQuery as cn}from"@tanstack/react-query";var Mt=e=>e/1e3;import Ks from"lodash/zip";import zs from"lodash/fromPairs";var Yt=(e,t=r=>r)=>{let[r,...o]=e;return o.map(s=>zs(Ks(r,s))).map((s,a,n)=>t.call(void 0,s,a,n))};import ho from"pluralize";import Er from"qs";import Po from"lodash/unionWith";import xo from"lodash/differenceWith";import _s from"warn-once";var Jt=e=>{let{current:t,pageSize:r,sorter:o,sorters:s,filters:a}=Er.parse(e.substring(1));return{parsedCurrent:t&&Number(t),parsedPageSize:r&&Number(r),parsedSorter:M(s,o)??[],parsedFilters:a??[]}},js=e=>{let t=Er.stringify(e);return Jt(`/${t}`)},Xt=e=>{let t={skipNulls:!0,arrayFormat:"indices",encode:!1},{pagination:r,sorter:o,sorters:s,filters:a,...n}=e;return Er.stringify({...n,...r||{},sorters:M(s,o),filters:a},t)},Co=(e,t)=>e.operator!=="and"&&e.operator!=="or"&&t.operator!=="and"&&t.operator!=="or"?("field"in e?e.field:void 0)==("field"in t?t.field:void 0)&&e.operator==t.operator:("key"in e?e.key:void 0)==("key"in t?t.key:void 0)&&e.operator==t.operator,bo=(e,t)=>e.field==t.field,yt=(e,t,r=[])=>(t.filter(s=>(s.operator==="or"||s.operator==="and")&&!s.key).length>1&&_s(!0,`[conditionalFilters]: You have created multiple Conditional Filters at the top level, this requires the key parameter.
|
|
2
|
+
For more information, see https://refine.dev/docs/advanced-tutorials/data-provider/handling-filters/#top-level-multiple-conditional-filters-usage`),Po(e,t,r,Co).filter(s=>s.value!==void 0&&s.value!==null&&(s.operator!=="or"||s.operator==="or"&&s.value.length!==0)&&(s.operator!=="and"||s.operator==="and"&&s.value.length!==0))),qt=(e,t)=>Po(e,t,bo).filter(r=>r.order!==void 0&&r.order!==null),er=(e,t)=>[...xo(t,e,Co),...e],tr=(e,t)=>[...xo(t,e,bo),...e],Zs=(e,t)=>{if(!t)return;let r=t.find(o=>o.field===e);if(r)return r.order},Ys=(e,t,r="eq")=>{let o=t==null?void 0:t.find(s=>{if(s.operator!=="or"&&s.operator!=="and"&&"field"in s){let{operator:a,field:n}=s;return n===e&&a===r}});if(o)return o.value||[]};var Js=e=>new Promise((t,r)=>{let o=new FileReader,s=()=>{o.result&&(o.removeEventListener("load",s,!1),t(o.result))};o.addEventListener("load",s,!1),o.readAsDataURL(e.originFileObj),o.onerror=a=>(o.removeEventListener("load",s,!1),r(a))});var rr=(e="",t)=>{let r=It(e);return t==="singular"?ho.singular(r):ho.plural(r)};var vo=(e={})=>e!=null&&e.id?{...e,id:decodeURIComponent(e.id)}:e;var M=(...e)=>e.find(t=>typeof t<"u");var ee=(e,t,r,o)=>{let s=t||"default",a={all:[s],resourceAll:[s,e||""],list:n=>[...a.resourceAll,"list",{...n,...M(r,o)||{}}],many:n=>[...a.resourceAll,"getMany",n&&n.map(String),{...M(r,o)||{}}].filter(u=>u!==void 0),detail:n=>[...a.resourceAll,"detail",n==null?void 0:n.toString(),{...M(r,o)||{}}],logList:n=>["logList",e,n,o].filter(u=>u!==void 0)};return a};var Ur=(e,t)=>!e||!t?!1:!!e.find(r=>r===t);var st=e=>e.startsWith(":");var Ne=e=>e.split("/").filter(r=>r!=="");var Mr=(e,t)=>{let r=Ne(e),o=Ne(t);return r.length===o.length};var Te=e=>e.replace(/^\/|\/$/g,"");var Ir=(e,t)=>{let r=Te(e),o=Te(t);if(!Mr(r,o))return!1;let s=Ne(r);return Ne(o).every((n,u)=>st(n)||n===s[u])};var wr=(e,t,r)=>{let o=Te(r||""),s=`${o}${o?"/":""}${e}`;return t==="list"?s=`${s}`:t==="create"?s=`${s}/create`:t==="edit"?s=`${s}/edit/:id`:t==="show"?s=`${s}/show/:id`:t==="clone"&&(s=`${s}/clone/:id`),`/${s.replace(/^\//,"")}`};var Ee=(e,t)=>{var s,a;let r=M((s=e.meta)==null?void 0:s.parent,(a=e.options)==null?void 0:a.parent,e.parentName);return r?t.find(n=>(n.identifier??n.name)===r)??{name:r}:void 0};var wt=(e,t,r)=>{let o=[],s=Ee(e,t);for(;s;)o.push(s),s=Ee(s,t);if(o.length!==0)return`/${o.reverse().map(a=>{var u;let n=r?((u=a.options)==null?void 0:u.route)??a.name:a.name;return Te(n)}).join("/")}`};var ye=(e,t,r)=>{let o=[],s=["list","show","edit","create","clone"],a=wt(e,t,r);return s.forEach(n=>{var d,l;let u=r&&n==="clone"?e.create:e[n],p;typeof u=="function"||r?p=wr(r?((d=e.meta)==null?void 0:d.route)??((l=e.options)==null?void 0:l.route)??e.name:e.name,n,r?a:void 0):typeof u=="string"?p=u:typeof u=="object"&&(p=u.path),p&&o.push({action:n,resource:e,route:`/${p.replace(/^\//,"")}`})}),o};var Do=e=>{var s;if(e.length===0)return;if(e.length===1)return e[0];let t=e.map(a=>({...a,splitted:Ne(Te(a.route))})),r=((s=t[0])==null?void 0:s.splitted.length)??0,o=[...t];for(let a=0;a<r;a++){let n=o.filter(u=>!st(u.splitted[a]));if(n.length!==0){if(n.length===1){o=n;break}o=n}}return o[0]};var Sr=(e,t)=>{let o=t.flatMap(a=>ye(a,t)).filter(a=>Ir(e,a.route)),s=Do(o);return{found:!!s,resource:s==null?void 0:s.resource,action:s==null?void 0:s.action,matchedRoute:s==null?void 0:s.route}};var or=(e,t)=>{var s;let r,o=wt(e,t,!0);if(o){let a=M(e.meta,e.options);r=`${o}/${(a==null?void 0:a.route)??e.name}`}else r=((s=e.options)==null?void 0:s.route)??e.name;return`/${r.replace(/^\//,"")}`};var Lo=e=>{var n;let t=[],r={},o={},s,a;for(let u=0;u<e.length;u++){s=e[u];let p=s.route??((n=M(s==null?void 0:s.meta,s.options))==null?void 0:n.route)??"";r[p]=s,r[p].children=[],o[s.name]=s,o[s.name].children=[]}for(let u in r)r.hasOwnProperty(u)&&(a=r[u],a.parentName&&o[a.parentName]?o[a.parentName].children.push(a):t.push(a));return t};var It=e=>(e=e.replace(/([a-z]{1})([A-Z]{1})/g,"$1-$2"),e=e.replace(/([A-Z]{1})([A-Z]{1})([a-z]{1})/g,"$1-$2$3"),e=e.toLowerCase().replace(/[_-]+/g," ").replace(/\s{2,}/g," ").trim(),e=e.charAt(0).toUpperCase()+e.slice(1),e);import Uo from"react";import Eo from"pluralize";import Xs from"react";var Ar=({children:e})=>Xs.createElement("div",null,e);var Ce={mutationMode:"pessimistic",syncWithLocation:!1,undoableTimeout:5e3,warnWhenUnsavedChanges:!1,liveMode:"off",redirect:{afterCreate:"list",afterClone:"list",afterEdit:"list"},overtime:{interval:1e3},textTransformers:{humanize:It,plural:Eo.plural,singular:Eo.singular},disableServerSideValidation:!1},be=Uo.createContext({hasDashboard:!1,mutationMode:"pessimistic",warnWhenUnsavedChanges:!1,syncWithLocation:!1,undoableTimeout:5e3,Title:void 0,Sider:void 0,Header:void 0,Footer:void 0,Layout:Ar,OffLayoutArea:void 0,liveMode:"off",onLiveEvent:void 0,options:Ce}),Mo=({hasDashboard:e,mutationMode:t,warnWhenUnsavedChanges:r,syncWithLocation:o,undoableTimeout:s,children:a,DashboardPage:n,Title:u,Layout:p=Ar,Header:d,Sider:l,Footer:c,OffLayoutArea:m,LoginPage:P=Fr,catchAll:x,liveMode:C="off",onLiveEvent:v,options:g})=>Uo.createElement(be.Provider,{value:{hasDashboard:e,mutationMode:t,warnWhenUnsavedChanges:r,syncWithLocation:o,Title:u,undoableTimeout:s,Layout:p,Header:d,Sider:l,Footer:c,OffLayoutArea:m,DashboardPage:n,LoginPage:P,catchAll:x,liveMode:C,onLiveEvent:v,options:g}},a);var Qr=({options:e,disableTelemetry:t,liveMode:r,mutationMode:o,reactQueryClientConfig:s,reactQueryDevtoolConfig:a,syncWithLocation:n,undoableTimeout:u,warnWhenUnsavedChanges:p}={})=>{var m,P,x,C,v,g,E,A;let d={breadcrumb:e==null?void 0:e.breadcrumb,mutationMode:(e==null?void 0:e.mutationMode)??o??Ce.mutationMode,undoableTimeout:(e==null?void 0:e.undoableTimeout)??u??Ce.undoableTimeout,syncWithLocation:(e==null?void 0:e.syncWithLocation)??n??Ce.syncWithLocation,warnWhenUnsavedChanges:(e==null?void 0:e.warnWhenUnsavedChanges)??p??Ce.warnWhenUnsavedChanges,liveMode:(e==null?void 0:e.liveMode)??r??Ce.liveMode,redirect:{afterCreate:((m=e==null?void 0:e.redirect)==null?void 0:m.afterCreate)??Ce.redirect.afterCreate,afterClone:((P=e==null?void 0:e.redirect)==null?void 0:P.afterClone)??Ce.redirect.afterClone,afterEdit:((x=e==null?void 0:e.redirect)==null?void 0:x.afterEdit)??Ce.redirect.afterEdit},overtime:(e==null?void 0:e.overtime)??Ce.overtime,textTransformers:{humanize:((C=e==null?void 0:e.textTransformers)==null?void 0:C.humanize)??Ce.textTransformers.humanize,plural:((v=e==null?void 0:e.textTransformers)==null?void 0:v.plural)??Ce.textTransformers.plural,singular:((g=e==null?void 0:e.textTransformers)==null?void 0:g.singular)??Ce.textTransformers.singular},disableServerSideValidation:(e==null?void 0:e.disableServerSideValidation)??Ce.disableServerSideValidation},l=(e==null?void 0:e.disableTelemetry)??t??!1,c={clientConfig:((E=e==null?void 0:e.reactQuery)==null?void 0:E.clientConfig)??s??{},devtoolConfig:((A=e==null?void 0:e.reactQuery)==null?void 0:A.devtoolConfig)??a??{}};return{optionsWithDefaults:d,disableTelemetryWithDefault:l,reactQueryWithDefaults:c}};var kr=({redirectFromProps:e,action:t,redirectOptions:r})=>{if(e||e===!1)return e;switch(t){case"clone":return r.afterClone;case"create":return r.afterCreate;case"edit":return r.afterEdit;default:return!1}};var sr=async(e,t,r)=>{let o=[];for(let[s,a]of e.entries())try{let n=await a();o.push(t(n,s))}catch(n){o.push(r(n,s))}return o};var pe=(e,t=[],r=!1)=>{if(!e)return;if(r){let s=t.find(n=>Te(n.route??"")===Te(e));return s||t.find(n=>n.name===e)}let o=t.find(s=>s.identifier===e);return o||(o=t.find(s=>s.name===e)),o};var H=(e,t,r)=>{if(t)return t;let o=pe(e,r),s=M(o==null?void 0:o.meta,o==null?void 0:o.options);return s!=null&&s.dataProviderName?s.dataProviderName:"default"};var We=async e=>({data:(await Promise.all(e)).map(t=>t.data)});var nr=e=>{let{pagination:t,cursor:r}=e;if(r!=null&&r.next)return r.next;let o=(t==null?void 0:t.current)||1,s=(t==null?void 0:t.pageSize)||10,a=Math.ceil((e.total||0)/s);return o<a?Number(o)+1:void 0},ar=e=>{let{pagination:t,cursor:r}=e;if(r!=null&&r.prev)return r.prev;let o=(t==null?void 0:t.current)||1;return o===1?void 0:o-1};var ir=e=>{let t=[];return e.forEach(r=>{var o,s;t.push({...r,label:((o=r.meta)==null?void 0:o.label)??((s=r.options)==null?void 0:s.label),route:or(r,e),canCreate:!!r.create,canEdit:!!r.edit,canShow:!!r.show,canDelete:r.canDelete})}),t};var Io=e=>Ne(Te(e)).flatMap(r=>st(r)?[r.slice(1)]:[]);var wo=(e,t={})=>e.reduce((r,o)=>{let s=t[o];return typeof s<"u"&&(r[o]=s),r},{});var Re=(e,t={},r={},o={})=>{let s=Io(e),a=wo(s,{...t,...typeof(r==null?void 0:r.id)<"u"?{id:r.id}:{},...typeof(r==null?void 0:r.action)<"u"?{action:r.action}:{},...typeof(r==null?void 0:r.resource)<"u"?{resource:r.resource}:{},...r==null?void 0:r.params,...o});return e.replace(/:([^\/]+)/g,(n,u)=>{let p=a[u];return typeof p<"u"?`${p}`:n})};var W=()=>{let e=te(),t=ie();return t.isProvided?{isLegacy:!1,...t}:e.isProvided?{isLegacy:!0,...e,check:e.checkAuth,onError:e.checkError,getIdentity:e.getUserIdentity}:null};var St=({hasPagination:e,pagination:t,configPagination:r}={})=>{let o=e===!1?"off":"server",s=(t==null?void 0:t.mode)??o,a=M(t==null?void 0:t.current,r==null?void 0:r.current)??1,n=M(t==null?void 0:t.pageSize,r==null?void 0:r.pageSize)??10;return{current:a,pageSize:n,mode:s}};import{useState as qs,useEffect as en}from"react";var ur=e=>{let[t,r]=qs(!1);return en(()=>{let o=window.matchMedia(e);o.matches!==t&&r(o.matches);let s=()=>r(o.matches);return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[t,e]),t};var cr=(e,t,r,o)=>{let s=o?e(t,o,r):e(t,r),a=r??t;return s===t||typeof s>"u"?a:s};function So(e,t,r,o,s){var m;let a={create:"Create new ",clone:`#${o??""} Clone `,edit:`#${o??""} Edit `,show:`#${o??""} Show `,list:""},n=(t==null?void 0:t.identifier)??(t==null?void 0:t.name),u=(t==null?void 0:t.label)??((m=t==null?void 0:t.meta)==null?void 0:m.label)??rr(n,r==="list"?"plural":"singular"),p=s??u,d=cr(e,"documentTitle.default","refine"),l=cr(e,"documentTitle.suffix"," | refine"),c=d;return r&&n&&(c=cr(e,`documentTitle.${n}.${r}`,`${a[r]??""}${p}${l}`,{id:o})),c}import{useContext as tn}from"react";var Qe=()=>{let{mutationMode:e,undoableTimeout:t}=tn(be);return{mutationMode:e,undoableTimeout:t}};import{useContext as Qo}from"react";import Ao,{useState as rn}from"react";var Vr=Ao.createContext({}),Fo=({children:e})=>{let[t,r]=rn(!1);return Ao.createElement(Vr.Provider,{value:{warnWhen:t,setWarnWhen:r}},e)};var At=()=>{let{warnWhenUnsavedChanges:e}=Qo(be),{warnWhen:t,setWarnWhen:r}=Qo(Vr);return{warnWhenUnsavedChanges:e,warnWhen:!!t,setWarnWhen:r??(()=>{})}};import{useContext as on}from"react";var Br=()=>{let{syncWithLocation:e}=on(be);return{syncWithLocation:e}};import{useContext as sn}from"react";var nn=()=>{let{Title:e}=sn(be);return e};import{useContext as an}from"react";var ae=()=>{let{Footer:e,Header:t,Layout:r,OffLayoutArea:o,Sider:s,Title:a,hasDashboard:n,mutationMode:u,syncWithLocation:p,undoableTimeout:d,warnWhenUnsavedChanges:l,DashboardPage:c,LoginPage:m,catchAll:P,options:x}=an(be);return{Footer:e,Header:t,Layout:r,OffLayoutArea:o,Sider:s,Title:a,hasDashboard:n,mutationMode:u,syncWithLocation:p,undoableTimeout:d,warnWhenUnsavedChanges:l,DashboardPage:c,LoginPage:m,catchAll:P,options:x}};var gt=()=>{let{options:{textTransformers:e}}=ae();return(r="",o)=>{let s=e.humanize(r);return o==="singular"?e.singular(s):e.plural(s)}};import{useEffect as ko,useState as un}from"react";var j=({isLoading:e,interval:t,onInterval:r})=>{let[o,s]=un(void 0),{options:a}=ae(),{overtime:n}=a,u=t??n.interval,p=r??(n==null?void 0:n.onInterval);return ko(()=>{let d;return e&&(d=setInterval(()=>{s(l=>l===void 0?u:l+u)},u)),()=>{clearInterval(d),s(void 0)}},[e,u]),ko(()=>{p&&o&&p(o)},[o]),{elapsedTime:o}};var Ft=({resource:e,config:t,filters:r,hasPagination:o,pagination:s,sorters:a,queryOptions:n,successNotification:u,errorNotification:p,meta:d,metaData:l,liveMode:c,onLiveEvent:m,liveParams:P,dataProviderName:x,overtimeOptions:C})=>{let{resources:v,resource:g,identifier:E}=V(e),A=Y(),b=B(),i=W(),{mutate:f}=oe({v3LegacyAuthProviderCompatible:!!(i!=null&&i.isLegacy)}),T=se(),h=K(),R=H(E,x,v),y=M(d,l),D=M(r,t==null?void 0:t.filters),L=M(a,t==null?void 0:t.sort),w=M(o,t==null?void 0:t.hasPagination),I=St({pagination:s,configPagination:t==null?void 0:t.pagination,hasPagination:w}),U=I.mode==="server",S=h({resource:g,meta:y}),F={meta:S,metaData:S,filters:D,hasPagination:U,pagination:I,sorters:L,config:{...t,sort:L}},k=(n==null?void 0:n.enabled)===void 0||(n==null?void 0:n.enabled)===!0,G=ee(E,R,y),{getList:O}=A(R);Ye({resource:E,types:["*"],params:{meta:S,metaData:S,pagination:I,hasPagination:U,sort:L,sorters:L,filters:D,subscriptionType:"useList",...P},channel:`resources/${g==null?void 0:g.name}`,enabled:k,liveMode:c,onLiveEvent:m});let z=cn(G.list({filters:D,hasPagination:U,...U&&{pagination:I},...a&&{sorters:a},...(t==null?void 0:t.sort)&&{sort:t==null?void 0:t.sort}}),({queryKey:Q,pageParam:$,signal:N})=>O({resource:(g==null?void 0:g.name)??"",pagination:I,hasPagination:U,filters:D,sort:L,sorters:L,meta:{...S,queryContext:{queryKey:Q,pageParam:$,signal:N}},metaData:{...S,queryContext:{queryKey:Q,pageParam:$,signal:N}}}),{...n,enabled:typeof(n==null?void 0:n.enabled)<"u"?n==null?void 0:n.enabled:!!(g!=null&&g.name),select:Q=>{var he;let $=Q,{current:N,mode:Z,pageSize:q}=I;return Z==="client"&&($={...$,data:$.data.slice((N-1)*q,N*q),total:$.total}),n!=null&&n.select?(he=n==null?void 0:n.select)==null?void 0:he.call(n,$):$},onSuccess:Q=>{var N;(N=n==null?void 0:n.onSuccess)==null||N.call(n,Q);let $=typeof u=="function"?u(Q,F,E):u;T($)},onError:Q=>{var N;f(Q),(N=n==null?void 0:n.onError)==null||N.call(n,Q);let $=typeof p=="function"?p(Q,F,E):p;T($,{key:`${E}-useList-notification`,message:b("notifications.error",{statusCode:Q.statusCode},`Error (status code: ${Q.statusCode})`),description:Q.message,type:"error"})}}),{elapsedTime:X}=j({isLoading:z.isFetching,interval:C==null?void 0:C.interval,onInterval:C==null?void 0:C.onInterval});return{...z,overtime:{elapsedTime:X}}};import{useQuery as pn}from"@tanstack/react-query";var Qt=({resource:e,id:t,queryOptions:r,successNotification:o,errorNotification:s,meta:a,metaData:n,liveMode:u,onLiveEvent:p,liveParams:d,dataProviderName:l,overtimeOptions:c})=>{let{resources:m,resource:P,identifier:x}=V(e),C=Y(),v=B(),g=W(),{mutate:E}=oe({v3LegacyAuthProviderCompatible:!!(g!=null&&g.isLegacy)}),A=se(),b=K(),i=M(a,n),f=H(x,l,m),T=ee(x,f,i),{getOne:h}=C(f),R=b({resource:P,meta:i});Ye({resource:x,types:["*"],channel:`resources/${P==null?void 0:P.name}`,params:{ids:t?[t]:[],id:t,meta:R,metaData:R,subscriptionType:"useOne",...d},enabled:typeof(r==null?void 0:r.enabled)<"u"?r==null?void 0:r.enabled:typeof(P==null?void 0:P.name)<"u"&&typeof t<"u",liveMode:u,onLiveEvent:p});let y=pn(T.detail(t),({queryKey:L,pageParam:w,signal:I})=>h({resource:(P==null?void 0:P.name)??"",id:t,meta:{...R,queryContext:{queryKey:L,pageParam:w,signal:I}},metaData:{...R,queryContext:{queryKey:L,pageParam:w,signal:I}}}),{...r,enabled:typeof(r==null?void 0:r.enabled)<"u"?r==null?void 0:r.enabled:typeof t<"u",onSuccess:L=>{var I;(I=r==null?void 0:r.onSuccess)==null||I.call(r,L);let w=typeof o=="function"?o(L,{id:t,...R},x):o;A(w)},onError:L=>{var I;E(L),(I=r==null?void 0:r.onError)==null||I.call(r,L);let w=typeof s=="function"?s(L,{id:t,...R},x):s;A(w,{key:`${t}-${x}-getOne-notification`,message:v("notifications.error",{statusCode:L.statusCode},`Error (status code: ${L.statusCode})`),description:L.message,type:"error"})}}),{elapsedTime:D}=j({isLoading:y.isFetching,interval:c==null?void 0:c.interval,onInterval:c==null?void 0:c.onInterval});return{...y,overtime:{elapsedTime:D}}};import{useQuery as dn}from"@tanstack/react-query";var Nr=({resource:e,ids:t,queryOptions:r,successNotification:o,errorNotification:s,meta:a,metaData:n,liveMode:u,onLiveEvent:p,liveParams:d,dataProviderName:l,overtimeOptions:c})=>{let{resources:m,resource:P,identifier:x}=V(e),C=Y(),v=B(),g=W(),{mutate:E}=oe({v3LegacyAuthProviderCompatible:!!(g!=null&&g.isLegacy)}),A=se(),b=K(),i=M(a,n),f=H(x,l,m),T=(r==null?void 0:r.enabled)===void 0||(r==null?void 0:r.enabled)===!0,h=ee(x,f,i),{getMany:R,getOne:y}=C(f),D=b({resource:P,meta:i});Ye({resource:x,types:["*"],params:{ids:t,meta:D,metaData:D,subscriptionType:"useMany",...d},channel:`resources/${P.name}`,enabled:T,liveMode:u,onLiveEvent:p});let L=dn(h.many(t),({queryKey:I,pageParam:U,signal:S})=>R?R({resource:P==null?void 0:P.name,ids:t,meta:{...D,queryContext:{queryKey:I,pageParam:U,signal:S}},metaData:{...D,queryContext:{queryKey:I,pageParam:U,signal:S}}}):We(t.map(F=>y({resource:P==null?void 0:P.name,id:F,meta:{...D,queryContext:{queryKey:I,pageParam:U,signal:S}},metaData:{...D,queryContext:{queryKey:I,pageParam:U,signal:S}}}))),{...r,onSuccess:I=>{var S;(S=r==null?void 0:r.onSuccess)==null||S.call(r,I);let U=typeof o=="function"?o(I,t,x):o;A(U)},onError:I=>{var S;E(I),(S=r==null?void 0:r.onError)==null||S.call(r,I);let U=typeof s=="function"?s(I,t,x):s;A(U,{key:`${t[0]}-${x}-getMany-notification`,message:v("notifications.error",{statusCode:I.statusCode},`Error (status code: ${I.statusCode})`),description:I.message,type:"error"})}}),{elapsedTime:w}=j({isLoading:L.isFetching,interval:c==null?void 0:c.interval,onInterval:c==null?void 0:c.onInterval});return{...L,overtime:{elapsedTime:w}}};import{useMutation as yn,useQueryClient as gn}from"@tanstack/react-query";import Or,{useReducer as ln}from"react";import Hr from"lodash-es/isEqual";var pr=Or.createContext({notifications:[],notificationDispatch:()=>!1}),mn=[],fn=(e,t)=>{switch(t.type){case"ADD":return[...e.filter(o=>!(Hr(o.id,t.payload.id)&&o.resource==t.payload.resource)),{...t.payload,isRunning:!0}];case"REMOVE":return e.filter(o=>!(Hr(o.id,t.payload.id)&&o.resource==t.payload.resource));case"DECREASE_NOTIFICATION_SECOND":return e.map(o=>Hr(o.id,t.payload.id)&&o.resource==t.payload.resource?{...o,seconds:t.payload.seconds-1e3}:o);default:return e}},$r=({children:e})=>{let[t,r]=ln(fn,mn),o={notifications:t,notificationDispatch:r};return Or.createElement(pr.Provider,{value:o},e,typeof window<"u"&&t.map(s=>Or.createElement(Vo,{key:`${s.id}-${s.resource}-queue`,notification:s})))};var dr=({mutationOptions:e,overtimeOptions:t}={})=>{let{resources:r,select:o}=V(),s=gn(),a=Y(),{mutationMode:n,undoableTimeout:u}=Qe(),p=B(),d=W(),{mutate:l}=oe({v3LegacyAuthProviderCompatible:!!(d!=null&&d.isLegacy)}),c=Ie(),{log:m}=we(),{notificationDispatch:P}=He(),x=se(),C=Se(),v=K(),{options:{textTransformers:g}}=ae(),E=yn(({id:b,values:i,resource:f,mutationMode:T,undoableTimeout:h,onCancel:R,meta:y,metaData:D,dataProviderName:L})=>{let{resource:w,identifier:I}=o(f),U=v({resource:w,meta:M(y,D)}),S=T??n,F=h??u;return S!=="undoable"?a(H(I,L,r)).update({resource:w.name,id:b,variables:i,meta:U,metaData:U}):new Promise((G,O)=>{let z=()=>{a(H(I,L,r)).update({resource:w.name,id:b,variables:i,meta:U,metaData:U}).then(Q=>G(Q)).catch(Q=>O(Q))},X=()=>{O({message:"mutationCancelled"})};R&&R(X),P({type:"ADD",payload:{id:b,resource:I,cancelMutation:X,doMutation:z,seconds:F,isSilent:!!R}})})},{onMutate:async({resource:b,id:i,mutationMode:f,values:T,dataProviderName:h,meta:R,metaData:y})=>{let{identifier:D}=o(b),L=M(R,y),w=ee(D,H(D,h,r),L),I=s.getQueriesData(w.resourceAll),U=f??n;return await s.cancelQueries(w.resourceAll,void 0,{silent:!0}),U!=="pessimistic"&&(s.setQueriesData(w.list(),S=>{if(!S)return null;let F=S.data.map(k=>{var G;return((G=k.id)==null?void 0:G.toString())===(i==null?void 0:i.toString())?{id:i,...k,...T}:k});return{...S,data:F}}),s.setQueriesData(w.many(),S=>{if(!S)return null;let F=S.data.map(k=>{var G;return((G=k.id)==null?void 0:G.toString())===(i==null?void 0:i.toString())&&(k={id:i,...k,...T}),k});return{...S,data:F}}),s.setQueriesData(w.detail(i),S=>S?{...S,data:{...S.data,...T}}:null)),{previousQueries:I,queryKey:w}},onSettled:(b,i,{id:f,resource:T,dataProviderName:h,invalidates:R=["list","many","detail"]})=>{let{identifier:y}=o(T);C({resource:y,dataProviderName:H(y,h,r),invalidates:R,id:f}),P({type:"REMOVE",payload:{id:f,resource:y}})},onSuccess:(b,{id:i,resource:f,successNotification:T,dataProviderName:h,values:R,meta:y,metaData:D},L)=>{var X;let{resource:w,identifier:I}=o(f),U=g.singular(I),S=typeof T=="function"?T(b,{id:i,values:R},I):T;x(S,{key:`${i}-${I}-notification`,description:p("notifications.success","Successful"),message:p("notifications.editSuccess",{resource:p(`${I}.${I}`,U)},`Successfully updated ${U}`),type:"success"}),c==null||c({channel:`resources/${w.name}`,type:"updated",payload:{ids:(X=b.data)!=null&&X.id?[b.data.id]:void 0},date:new Date});let F;if(L){let Q=s.getQueryData(L.queryKey.detail(i));F=Object.keys(R||{}).reduce(($,N)=>{var Z;return $[N]=(Z=Q==null?void 0:Q.data)==null?void 0:Z[N],$},{})}let{fields:k,operation:G,variables:O,...z}=M(y,D)||{};m==null||m.mutate({action:"update",resource:w.name,data:R,previousData:F,meta:{id:i,dataProviderName:H(I,h,r),...z}})},onError:(b,{id:i,resource:f,errorNotification:T,values:h},R)=>{let{identifier:y}=o(f);if(R)for(let D of R.previousQueries)s.setQueryData(D[0],D[1]);if(b.message!=="mutationCancelled"){l==null||l(b);let D=g.singular(y),L=typeof T=="function"?T(b,{id:i,values:h},y):T;x(L,{key:`${i}-${y}-notification`,message:p("notifications.editError",{resource:p(`${y}.${y}`,D),statusCode:b.statusCode},`Error when updating ${D} (status code: ${b.statusCode})`),description:b.message,type:"error"})}},...e}),{elapsedTime:A}=j({isLoading:E.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...E,overtime:{elapsedTime:A}}};import{useMutation as Tn}from"@tanstack/react-query";var kt=({mutationOptions:e,overtimeOptions:t}={})=>{let r=W(),{mutate:o}=oe({v3LegacyAuthProviderCompatible:!!(r!=null&&r.isLegacy)}),s=Y(),a=Se(),{resources:n,select:u}=V(),p=B(),d=Ie(),{log:l}=we(),c=se(),m=K(),{options:{textTransformers:P}}=ae(),x=Tn(({resource:v,values:g,meta:E,metaData:A,dataProviderName:b})=>{let{resource:i,identifier:f}=u(v),T=m({resource:i,meta:M(E,A)});return s(H(f,b,n)).create({resource:i.name,variables:g,meta:T,metaData:T})},{onSuccess:(v,{resource:g,successNotification:E,dataProviderName:A,invalidates:b=["list","many"],values:i,meta:f,metaData:T})=>{var F,k;let{resource:h,identifier:R}=u(g),y=P.singular(R),D=typeof E=="function"?E(v,i,R):E;c(D,{key:`create-${R}-notification`,message:p("notifications.createSuccess",{resource:p(`${R}.${R}`,y)},`Successfully created ${y}`),description:p("notifications.success","Success"),type:"success"}),a({resource:R,dataProviderName:H(R,A,n),invalidates:b}),d==null||d({channel:`resources/${h.name}`,type:"created",payload:{ids:(F=v==null?void 0:v.data)!=null&&F.id?[v.data.id]:void 0},date:new Date});let L=m({resource:h,meta:M(f,T)}),{fields:w,operation:I,variables:U,...S}=L||{};l==null||l.mutate({action:"create",resource:h.name,data:i,meta:{dataProviderName:H(R,A,n),id:((k=v==null?void 0:v.data)==null?void 0:k.id)??void 0,...S}})},onError:(v,{resource:g,errorNotification:E,values:A})=>{o(v);let{identifier:b}=u(g),i=P.singular(b),f=typeof E=="function"?E(v,A,b):E;c(f,{key:`create-${b}-notification`,description:v.message,message:p("notifications.createError",{resource:p(`${b}.${b}`,i),statusCode:v.statusCode},`There was an error creating ${i} (status code: ${v.statusCode})`),type:"error"})},...e}),{elapsedTime:C}=j({isLoading:x.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...x,overtime:{elapsedTime:C}}};import{useQueryClient as Rn,useMutation as Pn}from"@tanstack/react-query";var xn=({mutationOptions:e,overtimeOptions:t}={})=>{let r=W(),{mutate:o}=oe({v3LegacyAuthProviderCompatible:!!(r!=null&&r.isLegacy)}),s=Y(),{resources:a,select:n}=V(),u=Rn(),{mutationMode:p,undoableTimeout:d}=Qe(),{notificationDispatch:l}=He(),c=B(),m=Ie(),{log:P}=we(),x=se(),C=Se(),v=K(),{options:{textTransformers:g}}=ae(),E=Pn(({id:b,mutationMode:i,undoableTimeout:f,resource:T,onCancel:h,meta:R,metaData:y,dataProviderName:D,values:L})=>{let{resource:w,identifier:I}=n(T),U=v({resource:w,meta:M(R,y)}),S=i??p,F=f??d;return S!=="undoable"?s(H(I,D,a)).deleteOne({resource:w.name,id:b,meta:U,metaData:U,variables:L}):new Promise((G,O)=>{let z=()=>{s(H(I,D,a)).deleteOne({resource:w.name,id:b,meta:U,metaData:U,variables:L}).then(Q=>G(Q)).catch(Q=>O(Q))},X=()=>{O({message:"mutationCancelled"})};h&&h(X),l({type:"ADD",payload:{id:b,resource:I,cancelMutation:X,doMutation:z,seconds:F,isSilent:!!h}})})},{onMutate:async({id:b,resource:i,mutationMode:f,dataProviderName:T,meta:h,metaData:R})=>{let{identifier:y}=n(i),D=M(h,R),L=ee(y,H(y,T,a),D),w=f??p;await u.cancelQueries(L.resourceAll,void 0,{silent:!0});let I=u.getQueriesData(L.resourceAll);return w!=="pessimistic"&&(u.setQueriesData(L.list(),U=>U?{data:U.data.filter(F=>{var k;return((k=F.id)==null?void 0:k.toString())!==b.toString()}),total:U.total-1}:null),u.setQueriesData(L.many(),U=>{if(!U)return null;let S=U.data.filter(F=>{var k;return((k=F.id)==null?void 0:k.toString())!==(b==null?void 0:b.toString())});return{...U,data:S}})),{previousQueries:I,queryKey:L}},onSettled:(b,i,{id:f,resource:T,dataProviderName:h,invalidates:R=["list","many"]})=>{let{identifier:y}=n(T);C({resource:y,dataProviderName:H(y,h,a),invalidates:R}),l({type:"REMOVE",payload:{id:f,resource:y}})},onSuccess:(b,{id:i,resource:f,successNotification:T,dataProviderName:h,meta:R,metaData:y},D)=>{let{resource:L,identifier:w}=n(f),I=g.singular(w);u.removeQueries(D==null?void 0:D.queryKey.detail(i));let U=typeof T=="function"?T(b,i,w):T;x(U,{key:`${i}-${w}-notification`,description:c("notifications.success","Success"),message:c("notifications.deleteSuccess",{resource:c(`${w}.${w}`,I)},`Successfully deleted a ${I}`),type:"success"}),m==null||m({channel:`resources/${L.name}`,type:"deleted",payload:{ids:[i]},date:new Date});let S=v({resource:L,meta:M(R,y)}),{fields:F,operation:k,variables:G,...O}=S||{};P==null||P.mutate({action:"delete",resource:L.name,meta:{id:i,dataProviderName:H(w,h,a),...O}}),u.removeQueries(D==null?void 0:D.queryKey.detail(i))},onError:(b,{id:i,resource:f,errorNotification:T},h)=>{let{identifier:R}=n(f);if(h)for(let y of h.previousQueries)u.setQueryData(y[0],y[1]);if(b.message!=="mutationCancelled"){o(b);let y=g.singular(R),D=typeof T=="function"?T(b,i,R):T;x(D,{key:`${i}-${R}-notification`,message:c("notifications.deleteError",{resource:y,statusCode:b.statusCode},`Error (status code: ${b.statusCode})`),description:b.message,type:"error"})}},...e}),{elapsedTime:A}=j({isLoading:E.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...E,overtime:{elapsedTime:A}}};import{useMutation as Cn}from"@tanstack/react-query";var Gr=({mutationOptions:e,overtimeOptions:t}={})=>{let r=Y(),{resources:o,select:s}=V(),a=B(),n=Ie(),u=se(),p=Se(),{log:d}=we(),l=K(),{options:{textTransformers:c}}=ae(),m=Cn(({resource:x,values:C,meta:v,metaData:g,dataProviderName:E})=>{let{resource:A,identifier:b}=s(x),i=l({resource:A,meta:M(v,g)}),f=r(H(b,E,o));return f.createMany?f.createMany({resource:A.name,variables:C,meta:i,metaData:i}):We(C.map(T=>f.create({resource:A.name,variables:T,meta:i,metaData:i})))},{onSuccess:(x,{resource:C,successNotification:v,dataProviderName:g,invalidates:E=["list","many"],values:A,meta:b,metaData:i})=>{let{resource:f,identifier:T}=s(C),h=c.plural(T),R=typeof v=="function"?v(x,A,T):v;u(R,{key:`createMany-${T}-notification`,message:a("notifications.createSuccess",{resource:a(`${T}.${T}`,T)},`Successfully created ${h}`),description:a("notifications.success","Success"),type:"success"}),p({resource:T,dataProviderName:H(T,g,o),invalidates:E});let y=x==null?void 0:x.data.filter(S=>(S==null?void 0:S.id)!==void 0).map(S=>S.id);n==null||n({channel:`resources/${f.name}`,type:"created",payload:{ids:y},date:new Date});let D=l({resource:f,meta:M(b,i)}),{fields:L,operation:w,variables:I,...U}=D||{};d==null||d.mutate({action:"createMany",resource:f.name,data:A,meta:{dataProviderName:H(T,g,o),ids:y,...U}})},onError:(x,{resource:C,errorNotification:v,values:g})=>{let{identifier:E}=s(C),A=typeof v=="function"?v(x,g,E):v;u(A,{key:`createMany-${E}-notification`,description:x.message,message:a("notifications.createError",{resource:a(`${E}.${E}`,E),statusCode:x.statusCode},`There was an error creating ${E} (status code: ${x.statusCode}`),type:"error"})},...e}),{elapsedTime:P}=j({isLoading:m.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...m,overtime:{elapsedTime:P}}};import{useMutation as bn,useQueryClient as hn}from"@tanstack/react-query";var vn=({mutationOptions:e,overtimeOptions:t}={})=>{let{resources:r,select:o}=V(),s=hn(),a=Y(),n=B(),{mutationMode:u,undoableTimeout:p}=Qe(),d=W(),{mutate:l}=oe({v3LegacyAuthProviderCompatible:!!(d!=null&&d.isLegacy)}),{notificationDispatch:c}=He(),m=Ie(),P=se(),x=Se(),{log:C}=we(),v=K(),{options:{textTransformers:g}}=ae(),E=bn(({ids:b,values:i,resource:f,onCancel:T,mutationMode:h,undoableTimeout:R,meta:y,metaData:D,dataProviderName:L})=>{let{resource:w,identifier:I}=o(f),U=v({resource:w,meta:M(y,D)}),S=h??u,F=R??p,k=a(H(I,L,r)),G=()=>k.updateMany?k.updateMany({resource:w.name,ids:b,variables:i,meta:U,metaData:U}):We(b.map(z=>k.update({resource:w.name,id:z,variables:i,meta:U,metaData:U})));return S!=="undoable"?G():new Promise((z,X)=>{let Q=()=>{G().then(N=>z(N)).catch(N=>X(N))},$=()=>{X({message:"mutationCancelled"})};T&&T($),c({type:"ADD",payload:{id:b,resource:I,cancelMutation:$,doMutation:Q,seconds:F,isSilent:!!T}})})},{onMutate:async({resource:b,ids:i,values:f,mutationMode:T,dataProviderName:h,meta:R,metaData:y})=>{let{identifier:D}=o(b),L=ee(D,H(D,h,r),M(R,y)),w=T??u;await s.cancelQueries(L.resourceAll,void 0,{silent:!0});let I=s.getQueriesData(L.resourceAll);if(w!=="pessimistic"){s.setQueriesData(L.list(),U=>{if(!U)return null;let S=U.data.map(F=>F.id!==void 0&&i.filter(k=>k!==void 0).map(String).includes(F.id.toString())?{...F,...f}:F);return{...U,data:S}}),s.setQueriesData(L.many(),U=>{if(!U)return null;let S=U.data.map(F=>F.id!==void 0&&i.filter(k=>k!==void 0).map(String).includes(F.id.toString())?{...F,...f}:F);return{...U,data:S}});for(let U of i)s.setQueriesData(L.detail(U),S=>{if(!S)return null;let F={...S.data,...f};return{...S,data:F}})}return{previousQueries:I,queryKey:L}},onSettled:(b,i,{ids:f,resource:T,dataProviderName:h})=>{let{identifier:R}=o(T);x({resource:R,invalidates:["list","many"],dataProviderName:H(R,h,r)}),f.forEach(y=>x({resource:R,invalidates:["detail"],dataProviderName:H(R,h,r),id:y})),c({type:"REMOVE",payload:{id:f,resource:R}})},onSuccess:(b,{ids:i,resource:f,meta:T,metaData:h,dataProviderName:R,successNotification:y,values:D},L)=>{let{resource:w,identifier:I}=o(f),U=g.singular(I),S=typeof y=="function"?y(b,{ids:i,values:D},I):y;P(S,{key:`${i}-${I}-notification`,description:n("notifications.success","Successful"),message:n("notifications.editSuccess",{resource:n(`${I}.${I}`,I)},`Successfully updated ${U}`),type:"success"}),m==null||m({channel:`resources/${w.name}`,type:"updated",payload:{ids:i.map(String)},date:new Date});let F=[];L&&i.forEach(Q=>{let $=s.getQueryData(L.queryKey.detail(Q));F.push(Object.keys(D||{}).reduce((N,Z)=>{var q;return N[Z]=(q=$==null?void 0:$.data)==null?void 0:q[Z],N},{}))});let k=v({resource:w,meta:M(T,h)}),{fields:G,operation:O,variables:z,...X}=k||{};C==null||C.mutate({action:"updateMany",resource:w.name,data:D,previousData:F,meta:{ids:i,dataProviderName:H(I,R,r),...X}})},onError:(b,{ids:i,resource:f,errorNotification:T,values:h},R)=>{let{identifier:y}=o(f);if(R)for(let D of R.previousQueries)s.setQueryData(D[0],D[1]);if(b.message!=="mutationCancelled"){l==null||l(b);let D=g.singular(y),L=typeof T=="function"?T(b,{ids:i,values:h},y):T;P(L,{key:`${i}-${y}-updateMany-error-notification`,message:n("notifications.editError",{resource:D,statusCode:b.statusCode},`Error when updating ${D} (status code: ${b.statusCode})`),description:b.message,type:"error"})}},...e}),{elapsedTime:A}=j({isLoading:E.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...E,overtime:{elapsedTime:A}}};import{useQueryClient as Dn,useMutation as Ln}from"@tanstack/react-query";var En=({mutationOptions:e,overtimeOptions:t}={})=>{let r=W(),{mutate:o}=oe({v3LegacyAuthProviderCompatible:!!(r!=null&&r.isLegacy)}),{mutationMode:s,undoableTimeout:a}=Qe(),n=Y(),{notificationDispatch:u}=He(),p=B(),d=Ie(),l=se(),c=Se(),{log:m}=we(),{resources:P,select:x}=V(),C=Dn(),v=K(),{options:{textTransformers:g}}=ae(),E=Ln(({resource:b,ids:i,mutationMode:f,undoableTimeout:T,onCancel:h,meta:R,metaData:y,dataProviderName:D,values:L})=>{let{resource:w,identifier:I}=x(b),U=v({resource:w,meta:M(R,y)}),S=f??s,F=T??a,k=n(H(I,D,P)),G=()=>k.deleteMany?k.deleteMany({resource:w.name,ids:i,meta:U,metaData:U,variables:L}):We(i.map(z=>k.deleteOne({resource:w.name,id:z,meta:U,metaData:U,variables:L})));return S!=="undoable"?G():new Promise((z,X)=>{let Q=()=>{G().then(N=>z(N)).catch(N=>X(N))},$=()=>{X({message:"mutationCancelled"})};h&&h($),u({type:"ADD",payload:{id:i,resource:I,cancelMutation:$,doMutation:Q,seconds:F,isSilent:!!h}})})},{onMutate:async({ids:b,resource:i,mutationMode:f,dataProviderName:T,meta:h,metaData:R})=>{let{identifier:y}=x(i),D=M(h,R),L=ee(y,H(y,T,P),D),w=f??s;await C.cancelQueries(L.resourceAll,void 0,{silent:!0});let I=C.getQueriesData(L.resourceAll);if(w!=="pessimistic"){C.setQueriesData(L.list(),U=>U?{data:U.data.filter(F=>F.id&&!b.map(String).includes(F.id.toString())),total:U.total-1}:null),C.setQueriesData(L.many(),U=>{if(!U)return null;let S=U.data.filter(F=>F.id?!b.map(String).includes(F.id.toString()):!1);return{...U,data:S}});for(let U of b)C.setQueriesData(L.detail(U),S=>!S||S.data.id==U?null:{...S})}return{previousQueries:I,queryKey:L}},onSettled:(b,i,{resource:f,ids:T,dataProviderName:h,invalidates:R=["list","many"]})=>{let{identifier:y}=x(f);c({resource:y,dataProviderName:H(y,h,P),invalidates:R}),u({type:"REMOVE",payload:{id:T,resource:y}})},onSuccess:(b,{ids:i,resource:f,meta:T,metaData:h,dataProviderName:R,successNotification:y},D)=>{let{resource:L,identifier:w}=x(f);i.forEach(O=>C.removeQueries(D==null?void 0:D.queryKey.detail(O)));let I=typeof y=="function"?y(b,i,w):y;l(I,{key:`${i}-${w}-notification`,description:p("notifications.success","Success"),message:p("notifications.deleteSuccess",{resource:p(`${w}.${w}`,w)},`Successfully deleted ${w}`),type:"success"}),d==null||d({channel:`resources/${L.name}`,type:"deleted",payload:{ids:i},date:new Date});let U=v({resource:L,meta:M(T,h)}),{fields:S,operation:F,variables:k,...G}=U||{};m==null||m.mutate({action:"deleteMany",resource:L.name,meta:{ids:i,dataProviderName:H(w,R,P),...G}}),i.forEach(O=>C.removeQueries(D==null?void 0:D.queryKey.detail(O)))},onError:(b,{ids:i,resource:f,errorNotification:T},h)=>{let{identifier:R}=x(f);if(h)for(let y of h.previousQueries)C.setQueryData(y[0],y[1]);if(b.message!=="mutationCancelled"){o(b);let y=g.singular(R),D=typeof T=="function"?T(b,i,R):T;l(D,{key:`${i}-${R}-notification`,message:p("notifications.deleteError",{resource:y,statusCode:b.statusCode},`Error (status code: ${b.statusCode})`),description:b.message,type:"error"})}},...e}),{elapsedTime:A}=j({isLoading:E.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...E,overtime:{elapsedTime:A}}};var Un=e=>{var s;let t=Y(),{resource:r}=V(),{getApiUrl:o}=t(e??((s=M(r==null?void 0:r.meta,r==null?void 0:r.options))==null?void 0:s.dataProviderName));return o()};import{useQuery as Mn}from"@tanstack/react-query";var In=({url:e,method:t,config:r,queryOptions:o,successNotification:s,errorNotification:a,meta:n,metaData:u,dataProviderName:p,overtimeOptions:d})=>{let l=Y(),c=W(),{mutate:m}=oe({v3LegacyAuthProviderCompatible:!!(c!=null&&c.isLegacy)}),P=B(),x=se(),C=K(),v=M(n,u),{custom:g}=l(p),E=C({meta:v});if(g){let A=Mn({queryKey:[p,"custom",t,e,{...r,...v||{}}],queryFn:({queryKey:i,pageParam:f,signal:T})=>g({url:e,method:t,...r,meta:{...E,queryContext:{queryKey:i,pageParam:f,signal:T}},metaData:{...E,queryContext:{queryKey:i,pageParam:f,signal:T}}}),...o,onSuccess:i=>{var T;(T=o==null?void 0:o.onSuccess)==null||T.call(o,i);let f=typeof s=="function"?s(i,{...r,...E}):s;x(f)},onError:i=>{var T;m(i),(T=o==null?void 0:o.onError)==null||T.call(o,i);let f=typeof a=="function"?a(i,{...r,...E}):a;x(f,{key:`${t}-notification`,message:P("notifications.error",{statusCode:i.statusCode},`Error (status code: ${i.statusCode})`),description:i.message,type:"error"})}}),{elapsedTime:b}=j({isLoading:A.isFetching,interval:d==null?void 0:d.interval,onInterval:d==null?void 0:d.onInterval});return{...A,overtime:{elapsedTime:b}}}else throw Error("Not implemented custom on data provider.")};import{useMutation as wn}from"@tanstack/react-query";var Sn=({mutationOptions:e,overtimeOptions:t}={})=>{let r=W(),{mutate:o}=oe({v3LegacyAuthProviderCompatible:!!(r!=null&&r.isLegacy)}),s=se(),a=Y(),n=B(),u=K(),p=wn(({url:l,method:c,values:m,meta:P,metaData:x,dataProviderName:C,config:v})=>{let g=u({meta:M(P,x)}),{custom:E}=a(C);if(E)return E({url:l,method:c,payload:m,meta:g,metaData:g,headers:{...v==null?void 0:v.headers}});throw Error("Not implemented custom on data provider.")},{onSuccess:(l,{successNotification:c,config:m,meta:P,metaData:x})=>{let C=typeof c=="function"?c(l,{...m,...M(P,x)||{}}):c;s(C)},onError:(l,{errorNotification:c,method:m,config:P,meta:x,metaData:C})=>{o(l);let v=typeof c=="function"?c(l,{...P,...M(x,C)||{}}):c;s(v,{key:`${m}-notification`,message:n("notifications.error",{statusCode:l.statusCode},`Error (status code: ${l.statusCode})`),description:l.message,type:"error"})},...e}),{elapsedTime:d}=j({isLoading:p.isLoading,interval:t==null?void 0:t.interval,onInterval:t==null?void 0:t.onInterval});return{...p,overtime:{elapsedTime:d}}};import{useCallback as Fn,useContext as Qn}from"react";import Bo from"react";var An=()=>({default:{create:()=>Promise.resolve({data:{id:1}}),createMany:()=>Promise.resolve({data:[]}),deleteOne:()=>Promise.resolve({data:{id:1}}),deleteMany:()=>Promise.resolve({data:[]}),getList:()=>Promise.resolve({data:[],total:0}),getMany:()=>Promise.resolve({data:[]}),getOne:()=>Promise.resolve({data:{id:1}}),update:()=>Promise.resolve({data:{id:1}}),updateMany:()=>Promise.resolve({data:[]}),custom:()=>Promise.resolve({data:{}}),getApiUrl:()=>""}}),Vt=Bo.createContext(An()),No=({children:e,...t})=>{let r;return!t.getList||!t.getOne?r=t:r={default:t},Bo.createElement(Vt.Provider,{value:r},e)};var Y=()=>{let e=Qn(Vt);return Fn(r=>{if(r){if(!e[r])throw new Error(`"${r}" Data provider not found`);return e[r]}if(e.default)return e.default;throw new Error('There is no "default" data provider. Please pass dataProviderName.')},[e])};import{useInfiniteQuery as kn}from"@tanstack/react-query";var Vn=({resource:e,config:t,filters:r,hasPagination:o,pagination:s,sorters:a,queryOptions:n,successNotification:u,errorNotification:p,meta:d,metaData:l,liveMode:c,onLiveEvent:m,liveParams:P,dataProviderName:x,overtimeOptions:C})=>{let{resources:v,resource:g,identifier:E}=V(e),A=Y(),b=B(),i=W(),{mutate:f}=oe({v3LegacyAuthProviderCompatible:!!(i!=null&&i.isLegacy)}),T=se(),h=K(),R=H(E,x,v),y=M(d,l),D=M(r,t==null?void 0:t.filters),L=M(a,t==null?void 0:t.sort),w=M(o,t==null?void 0:t.hasPagination),I=St({pagination:s,configPagination:t==null?void 0:t.pagination,hasPagination:w}),U=I.mode==="server",S={meta:y,metaData:y,filters:D,hasPagination:U,pagination:I,sorters:L,config:{...t,sort:L}},F=(n==null?void 0:n.enabled)===void 0||(n==null?void 0:n.enabled)===!0,k=ee(E,R,y,y),G=h({resource:g,meta:y}),{getList:O}=A(R);Ye({resource:E,types:["*"],params:{meta:G,metaData:G,pagination:I,hasPagination:U,sort:L,sorters:L,filters:D,subscriptionType:"useList",...P},channel:`resources/${g.name}`,enabled:F,liveMode:c,onLiveEvent:m});let z=kn(k.list({filters:D,hasPagination:U,...U&&{pagination:I},...a&&{sorters:a},...(t==null?void 0:t.sort)&&{sort:t==null?void 0:t.sort}}),({queryKey:Q,pageParam:$,signal:N})=>{let Z={...I,current:$};return O({resource:g.name,pagination:Z,hasPagination:U,filters:D,sort:L,sorters:L,meta:{...G,queryContext:{queryKey:Q,pageParam:$,signal:N}},metaData:{...G,queryContext:{queryKey:Q,pageParam:$,signal:N}}}).then(({data:q,total:he,...je})=>({data:q,total:he,pagination:Z,...je}))},{getNextPageParam:Q=>nr(Q),getPreviousPageParam:Q=>ar(Q),...n,onSuccess:Q=>{var N;(N=n==null?void 0:n.onSuccess)==null||N.call(n,Q);let $=typeof u=="function"?u(Q,S,E):u;T($)},onError:Q=>{var N;f(Q),(N=n==null?void 0:n.onError)==null||N.call(n,Q);let $=typeof p=="function"?p(Q,S,E):p;T($,{key:`${E}-useInfiniteList-notification`,message:b("notifications.error",{statusCode:Q.statusCode},`Error (status code: ${Q.statusCode})`),description:Q.message,type:"error"})}}),{elapsedTime:X}=j({isLoading:z.isFetching,interval:C==null?void 0:C.interval,onInterval:C==null?void 0:C.onInterval});return{...z,overtime:{elapsedTime:X}}};import{useContext as Jo,useEffect as Zn}from"react";import{useQueryClient as Yn}from"@tanstack/react-query";import Ho from"react";var Ke=Ho.createContext(void 0),Oo=({liveProvider:e,children:t})=>Ho.createElement(Ke.Provider,{value:e},t);import{useContext as zn}from"react";import Go from"react";import{useMemo as Hn}from"react";import{useRef as Bn}from"react";import Nn from"lodash-es/isEqual";var $o=e=>{let t=Bn(e);return Nn(t.current,e)||(t.current=e),t.current};var lr=(e,t)=>{let r=$o(t);return Hn(e,r)};var Je=Go.createContext({resources:[]}),Wo=({resources:e,children:t})=>{let r=lr(()=>ir(e??[]),[e]);return Go.createElement(Je.Provider,{value:{resources:r}},t)};import Ko from"react";var zo=Ko.createContext("new"),_o=zo.Provider,_=()=>Ko.useContext(zo);import Kn from"react";import On,{createContext as $n}from"react";var jo={},ze=$n(jo),Zo=({children:e,router:t})=>On.createElement(ze.Provider,{value:t??jo},e);import Gn,{useContext as Wn}from"react";var Wr=()=>{let e=Wn(ze);return Gn.useMemo(()=>(e==null?void 0:e.parse)??(()=>()=>({})),[e==null?void 0:e.parse])()};var le=()=>{let e=Wr();return Kn.useMemo(()=>e(),[e])};function V(e){let{resources:t}=zn(Je),r=_(),o=le(),s={resourceName:e&&typeof e!="string"?e.resourceName:e,resourceNameOrRouteName:e&&typeof e!="string"?e.resourceNameOrRouteName:e,recordItemId:e&&typeof e!="string"?e.recordItemId:void 0},a=(c,m=!0)=>{let x=pe(c,t,r==="legacy");if(x)return{resource:x,identifier:x.identifier??x.name};if(m){let C={name:c,identifier:c},v=C.identifier??C.name;return{resource:C,identifier:v}}},n=Yo(),{useParams:u}=re(),p=u();if(r==="legacy"){let c=s.resourceNameOrRouteName?s.resourceNameOrRouteName:p.resource,m=c?n(c):void 0,P=(s==null?void 0:s.recordItemId)??p.id,x=p.action,C=(s==null?void 0:s.resourceName)??(m==null?void 0:m.name),v=(m==null?void 0:m.identifier)??(m==null?void 0:m.name);return{resources:t,resource:m,resourceName:C,id:P,action:x,select:a,identifier:v}}let d,l=typeof e=="string"?e:s==null?void 0:s.resourceNameOrRouteName;if(l){let c=pe(l,t);c?d=c:d={name:l}}else o!=null&&o.resource&&(d=o.resource);return{resources:t,resource:d,resourceName:d==null?void 0:d.name,id:o.id,action:o.action,select:a,identifier:(d==null?void 0:d.identifier)??(d==null?void 0:d.name)}}import{useContext as _n,useCallback as jn}from"react";var Yo=()=>{let{resources:e}=_n(Je);return jn(r=>{let o=pe(r,e,!0);return o||{name:r,route:r}},[e])};var Ye=({resource:e,params:t,channel:r,types:o,enabled:s=!0,liveMode:a,onLiveEvent:n})=>{let u=Yn(),{resource:p,identifier:d}=V(e),l=ee(d),c=Jo(Ke),{liveMode:m,onLiveEvent:P}=Jo(be),x=a??m;Zn(()=>{let C;return x&&x!=="off"&&s&&(C=c==null?void 0:c.subscribe({channel:r,params:{resource:p==null?void 0:p.name,...t},types:o,callback:v=>{x==="auto"&&u.invalidateQueries(l.resourceAll),n==null||n(v),P==null||P(v)}})),()=>{C&&(c==null||c.unsubscribe(C))}},[s])};import{useContext as Jn}from"react";var Xo=e=>{let{liveMode:t}=Jn(be);return e??t};import{useContext as Xn,useEffect as qn}from"react";var wy=({params:e,channel:t,types:r=["*"],enabled:o=!0,onLiveEvent:s})=>{let a=Xn(Ke);qn(()=>{let n;return o&&(n=a==null?void 0:a.subscribe({channel:t,params:e,types:r,callback:s})),()=>{n&&(a==null||a.unsubscribe(n))}},[o])};import{useContext as ea}from"react";var Ie=()=>{let e=ea(Ke);return e==null?void 0:e.publish};import{useContext as ta}from"react";var He=()=>{let{notifications:e,notificationDispatch:t}=ta(pr);return{notifications:e,notificationDispatch:t}};import{useContext as sa}from"react";import ra,{createContext as oa}from"react";var Bt=oa({}),qo=({open:e,close:t,children:r})=>ra.createElement(Bt.Provider,{value:{open:e,close:t}},r);var De=()=>{let{open:e,close:t}=sa(Bt);return{open:e,close:t}};import{useCallback as na}from"react";var se=()=>{let{open:e}=De();return na((r,o)=>{r!==!1&&(r?e==null||e(r):o&&(e==null||e(o)))},[])};import{useCallback as aa,useContext as ia}from"react";import es from"react";var Ae=es.createContext({}),ts=({children:e,i18nProvider:t})=>es.createElement(Ae.Provider,{value:{i18nProvider:t}},e);var ua=()=>{let{i18nProvider:e}=ia(Ae);return aa(t=>e==null?void 0:e.changeLocale(t),[])};import{useContext as ca,useMemo as pa}from"react";var B=()=>{let{i18nProvider:e}=ca(Ae);return pa(()=>{function r(o,s,a){return(e==null?void 0:e.translate(o,s,a))??a??(typeof s=="string"&&typeof a>"u"?s:o)}return r},[e])};import{useContext as da,useCallback as la}from"react";var ma=()=>{let{i18nProvider:e}=da(Ae);return la(()=>e==null?void 0:e.getLocale(),[])};import{useState as fa}from"react";import{ExportToCsv as ya}from"export-to-csv-fix-source-map";var bg=({resourceName:e,resource:t,sorter:r,sorters:o,filters:s,maxItemCount:a,pageSize:n=20,mapData:u=P=>P,exportOptions:p,meta:d,metaData:l,dataProviderName:c,onError:m}={})=>{let[P,x]=fa(!1),C=Y(),v=K(),{resource:g,resources:E,identifier:A}=V(M(t,e)),i=`${gt()(A,"plural")}-${new Date().toLocaleString()}`,{getList:f}=C(H(A,c,E)),T=v({resource:g,meta:M(d,l)});return{isLoading:P,triggerExport:async()=>{x(!0);let R=[],y=1,D=!0;for(;D;)try{let{data:w,total:I}=await f({resource:(g==null?void 0:g.name)??"",filters:s,sort:M(o,r),sorters:M(o,r),pagination:{current:y,pageSize:n,mode:"server"},meta:T,metaData:T});y++,R.push(...w),a&&R.length>=a&&(R=R.slice(0,a),D=!1),I===R.length&&(D=!1)}catch(w){x(!1),D=!1,m==null||m(w);return}new ya({filename:i,useKeysAsHeaders:!0,...p}).generateCsv(R.map(u)),x(!1)}}};import Kr from"react";import ga from"warn-once";import Ta from"lodash/debounce";var kg=({resource:e,action:t,id:r,onMutationSuccess:o,onMutationError:s,redirect:a,successNotification:n,errorNotification:u,meta:p,metaData:d,queryMeta:l,mutationMeta:c,mutationMode:m,liveMode:P,onLiveEvent:x,liveParams:C,undoableTimeout:v,dataProviderName:g,invalidates:E,queryOptions:A,createMutationOptions:b,updateMutationOptions:i,overtimeOptions:f,autoSave:T}={})=>{let{options:h}=ae(),R=K(),{resource:y,id:D,action:L,identifier:w}=V(e),{identifier:I}=V(),S=(()=>{let de=r??D;return e&&e!==I?r:de})(),[F,k]=Kr.useState(S);Kr.useEffect(()=>{k(S)},[S]);let O=(()=>t||(L==="edit"||L==="clone"?L:"create"))(),z=R({resource:y,meta:M(p,d)}),{mutationMode:X}=Qe(),Q=m??X,$=O==="create",N=O==="edit",Z=O==="clone";ga((Z||N)&&!!e&&!r,`[useForm]: action: "${O}", resource: "${w}", id: ${F}
|
|
3
3
|
|
|
4
4
|
If you don't use the \`setId\` method to set the \`id\`, you should pass the \`id\` prop to \`useForm\`. Otherwise, \`useForm\` will not be able to infer the \`id\` from the current URL.
|
|
5
5
|
|
|
6
|
-
See https://refine.dev/docs/api-reference/core/hooks/useForm/#resource`);let
|
|
6
|
+
See https://refine.dev/docs/api-reference/core/hooks/useForm/#resource`);let q=kr({redirectFromProps:a,action:O,redirectOptions:h.redirect}),je=Qt({resource:w,id:F??"",queryOptions:{enabled:F!==void 0&&(N||Z),...A},liveMode:P,onLiveEvent:x,liveParams:C,meta:{...z,...l},metaData:{...z,...l},dataProviderName:g}),{isFetching:Oe}=je,$t=kt({mutationOptions:b}),{mutate:ut,isLoading:ct}=$t,qe=dr({mutationOptions:i}),{mutate:pt,isLoading:ht}=qe,et=dr({}),{setWarnWhen:Gt}=At(),tt=rs(),Wt=async de=>{Gt(!1);let Ve=ve=>{tt({redirect:q,resource:y,id:ve,meta:M(p,d)})};return Q!=="pessimistic"&&setTimeout(()=>{Ve()}),new Promise((ve,Be)=>{if(Q!=="pessimistic"&&ve(),!!y)return ut({values:de,resource:w??y.name,successNotification:n,errorNotification:u,meta:{...z,...c},metaData:{...z,...c},dataProviderName:g,invalidates:E},{onSuccess:(xe,Ze,rt)=>{var Lt;o&&o(xe,de,rt);let ot=(Lt=xe==null?void 0:xe.data)==null?void 0:Lt.id;Ve(ot),ve(xe)},onError:(xe,Ze,rt)=>{if(s)return s(xe,de,rt);Be()}})})},$e=de=>{if(!y||!N)return;let Ve={id:F??"",values:de,resource:w??y.name,successNotification:!1,errorNotification:!1,meta:{...z,...c},metaData:{...z,...c},dataProviderName:g,invalidates:[]};return et.mutate(Ve,{onSuccess:(ve,Be,xe)=>{o&&o(ve,de,xe,!0)},onError:(ve,Be,xe)=>{if(s)return s(ve,de,xe,!0)}})},Kt=Kr.useMemo(()=>Ta(de=>$e(de),(T==null?void 0:T.debounce)||1e3),[]),Dt=$||Z?{formLoading:Oe||ct,mutationResult:$t,onFinish:Wt}:{formLoading:Oe||ht,mutationResult:qe,onFinish:async de=>{if(Gt(!1),!y)return;let Ve={id:F??"",values:de,resource:w??y.name,mutationMode:Q,undoableTimeout:v,successNotification:n,errorNotification:u,meta:{...z,...c},metaData:{...z,...c},dataProviderName:g,invalidates:E},ve=()=>{tt({redirect:q,resource:y,id:F,meta:M(p,d)})};return Q!=="pessimistic"&&setTimeout(()=>{ve()}),new Promise((Be,xe)=>(Q!=="pessimistic"&&Be(),setTimeout(()=>{pt(Ve,{onSuccess:(Ze,rt,ot)=>{o&&o(Ze,de,ot),Q==="pessimistic"&&ve(),Be(Ze)},onError:(Ze,rt,ot)=>{if(s)return s(Ze,de,ot);xe()}})})))}},{elapsedTime:Ge}=j({isLoading:Dt.mutationResult.isLoading||je.isFetching,interval:f==null?void 0:f.interval,onInterval:f==null?void 0:f.onInterval});return{...Dt,queryResult:je,onFinishAutoSave:Kt,autoSaveProps:{status:et.status,data:et.data,error:et.error},id:F,setId:k,redirect:(de,Ve)=>{tt({redirect:de!==void 0?de:N?"list":"edit",resource:y,id:Ve??F,meta:M(p,d)})},overtime:{elapsedTime:Ge}}};import{useCallback as Ra}from"react";var rs=()=>{let{show:e,edit:t,list:r,create:o}=ue();return Ra(({redirect:a,resource:n,id:u,meta:p={}})=>{if(a&&n)return n.show&&a==="show"&&u?e(n,u,void 0,p):n.edit&&a==="edit"&&u?t(n,u,void 0,p):n.create&&a==="create"?o(n,void 0,p):r(n,"push",p)},[])};import Pa,{useContext as xa}from"react";var ce=()=>{let e=xa(ze);return Pa.useMemo(()=>(e==null?void 0:e.go)??(()=>()=>{}),[e==null?void 0:e.go])()};import Ca,{useContext as ba}from"react";var zr=()=>{let e=ba(ze);return Ca.useMemo(()=>(e==null?void 0:e.back)??(()=>()=>{}),[e==null?void 0:e.back])()};var ue=()=>{let{resources:e}=V(),t=_(),{useHistory:r}=re(),o=r(),s=le(),a=ce(),n=zr(),u=(i,f="push")=>{t==="legacy"?o[f](i):a({to:i,type:f})},p=(i,f={})=>{var T;if(t==="legacy"){let h=typeof i=="string"?pe(i,e,!0)??{name:i,route:i}:i,R=ye(h,e,!0).find(y=>y.action==="create");return R?Re(R.route,h==null?void 0:h.meta,s,f):""}else{let h=typeof i=="string"?pe(i,e)??{name:i}:i,R=(T=ye(h,e).find(y=>y.action==="create"))==null?void 0:T.route;return R?a({to:Re(R,h==null?void 0:h.meta,s,f),type:"path"}):""}},d=(i,f,T={})=>{var R;let h=encodeURIComponent(f);if(t==="legacy"){let y=typeof i=="string"?pe(i,e,!0)??{name:i,route:i}:i,D=ye(y,e,!0).find(L=>L.action==="edit");return D?Re(D.route,y==null?void 0:y.meta,s,{...T,id:h}):""}else{let y=typeof i=="string"?pe(i,e)??{name:i}:i,D=(R=ye(y,e).find(L=>L.action==="edit"))==null?void 0:R.route;return D?a({to:Re(D,y==null?void 0:y.meta,s,{...T,id:h}),type:"path"}):""}},l=(i,f,T={})=>{var R;let h=encodeURIComponent(f);if(t==="legacy"){let y=typeof i=="string"?pe(i,e,!0)??{name:i,route:i}:i,D=ye(y,e,!0).find(L=>L.action==="clone");return D?Re(D.route,y==null?void 0:y.meta,s,{...T,id:h}):""}else{let y=typeof i=="string"?pe(i,e)??{name:i}:i,D=(R=ye(y,e).find(L=>L.action==="clone"))==null?void 0:R.route;return D?a({to:Re(D,y==null?void 0:y.meta,s,{...T,id:h}),type:"path"}):""}},c=(i,f,T={})=>{var R;let h=encodeURIComponent(f);if(t==="legacy"){let y=typeof i=="string"?pe(i,e,!0)??{name:i,route:i}:i,D=ye(y,e,!0).find(L=>L.action==="show");return D?Re(D.route,y==null?void 0:y.meta,s,{...T,id:h}):""}else{let y=typeof i=="string"?pe(i,e)??{name:i}:i,D=(R=ye(y,e).find(L=>L.action==="show"))==null?void 0:R.route;return D?a({to:Re(D,y==null?void 0:y.meta,s,{...T,id:h}),type:"path"}):""}},m=(i,f={})=>{var T;if(t==="legacy"){let h=typeof i=="string"?pe(i,e,!0)??{name:i,route:i}:i,R=ye(h,e,!0).find(y=>y.action==="list");return R?Re(R.route,h==null?void 0:h.meta,s,f):""}else{let h=typeof i=="string"?pe(i,e)??{name:i}:i,R=(T=ye(h,e).find(y=>y.action==="list"))==null?void 0:T.route;return R?a({to:Re(R,h==null?void 0:h.meta,s,f),type:"path"}):""}};return{create:(i,f="push",T={})=>{u(p(i,T),f)},createUrl:p,edit:(i,f,T="push",h={})=>{u(d(i,f,h),T)},editUrl:d,clone:(i,f,T="push",h={})=>{u(l(i,f,h),T)},cloneUrl:l,show:(i,f,T="push",h={})=>{u(c(i,f,h),T)},showUrl:c,list:(i,f="push",T={})=>{u(m(i,T),f)},listUrl:m,push:(i,...f)=>{t==="legacy"?o.push(i,...f):a({to:i,type:"push"})},replace:(i,...f)=>{t==="legacy"?o.replace(i,...f):a({to:i,type:"replace"})},goBack:()=>{t==="legacy"?o.goBack():n()}}};import ha,{useState as va}from"react";import Da from"warn-once";var lT=({resource:e,id:t,successNotification:r,errorNotification:o,meta:s,metaData:a,liveMode:n,onLiveEvent:u,dataProviderName:p,queryOptions:d,overtimeOptions:l}={})=>{let{resource:c,id:m,identifier:P}=V(e),{identifier:x}=V(),C=K(),g=(()=>{let T=t??m;return e&&e!==x?t:T})(),[E,A]=va(g);ha.useEffect(()=>{A(g)},[g]);let b=C({resource:c,meta:M(s,a)});Da(!!e&&!t,`[useShow]: resource: "${P}", id: ${t}
|
|
7
7
|
|
|
8
8
|
If you don't use the \`setShowId\` method to set the \`showId\`, you should pass the \`id\` prop to \`useShow\`. Otherwise, \`useShow\` will not be able to infer the \`id\` from the current URL.
|
|
9
9
|
|
|
10
|
-
See https://refine.dev/docs/api-reference/core/hooks/show/useShow/#resource`);let i=It({resource:P,id:U??"",queryOptions:{enabled:U!==void 0,...d},successNotification:r,errorNotification:o,meta:h,metaData:h,liveMode:s,onLiveEvent:u,dataProviderName:p}),{elapsedTime:f}=_({isLoading:i.isFetching,interval:l==null?void 0:l.interval,onInterval:l==null?void 0:l.onInterval});return{queryResult:i,showId:U,setShowId:S,overtime:{elapsedTime:f}}};import{useEffect as Da,useState as Or}from"react";import{parse as La}from"papaparse";import Ea from"lodash-es/chunk";var xT=({resourceName:e,resource:t,mapData:r=l=>l,paparseOptions:o,batchSize:n=Number.MAX_SAFE_INTEGER,onFinish:a,meta:s,metaData:u,onProgress:p,dataProviderName:d}={})=>{let[l,c]=Or(0),[m,P]=Or(0),[x,C]=Or(!1),{resource:v,identifier:g}=k(t??e),U=K(),S=Br(),h=wt(),i=U({resource:v,meta:M(s,u)}),f;n===1?f=h:f=S;let R=()=>{P(0),c(0),C(!1)},b=y=>{let D={succeeded:y.filter(L=>L.type==="success"),errored:y.filter(L=>L.type==="error")};a==null||a(D),C(!1)};Da(()=>{p==null||p({totalAmount:m,processedAmount:l})},[m,l]);let T=({file:y})=>(R(),new Promise(D=>{C(!0),La(y,{complete:async({data:L})=>{let A=Gt(L,r);if(P(A.length),n===1){let w=A.map(I=>async()=>({response:await h.mutateAsync({resource:g??"",values:I,successNotification:!1,errorNotification:!1,dataProviderName:d,meta:i,metaData:i}),value:I})),E=await Jt(w,({response:I,value:F})=>(c(V=>V+1),{response:[I.data],type:"success",request:[F]}),(I,F)=>({response:[I],type:"error",request:[A[F]]}));D(E)}else{let w=Ea(A,n),E=w.map(F=>async()=>({response:await S.mutateAsync({resource:g??"",values:F,successNotification:!1,errorNotification:!1,dataProviderName:d,meta:i,metaData:i}),value:F,currentBatchLength:F.length})),I=await Jt(E,({response:F,currentBatchLength:V,value:O})=>(c(G=>G+V),{response:F.data,type:"success",request:O}),(F,V)=>({response:[F],type:"error",request:w[V]}));D(I)}},...o})}).then(D=>(b(D),D)));return{inputProps:{type:"file",accept:".csv",onChange:y=>{y.target.files&&y.target.files.length>0&&T({file:y.target.files[0]})}},mutationResult:f,isLoading:x,handleChange:T}};import{useCallback as en,useState as Ua}from"react";var bT=({defaultVisible:e=!1}={})=>{let[t,r]=Ua(e),o=en(()=>r(!0),[t]),n=en(()=>r(!1),[t]);return{visible:t,show:o,close:n}};import Ma from"react";var Ft=()=>{let e=z(),{resource:t,resources:r}=k(),o=de();return Ma.useCallback(({resource:a,action:s,meta:u})=>{var m;let p=a||t;if(!p)return;let l=(m=fe(p,r,e==="legacy").find(P=>P.action===s))==null?void 0:m.route;return l?Pe(l,p==null?void 0:p.meta,o,u):void 0},[r,t,o])};var Ia=({resource:e,action:t,meta:r,legacy:o})=>Ft()({resource:e,action:t,meta:r,legacy:o});import wa,{useContext as Sa}from"react";var ot=()=>{let e=Sa(Ke);return e!=null&&e.Link?e.Link:({to:r,...o})=>wa.createElement("a",{href:r,...o})};import{useContext as Fa}from"react";import tn from"react";var ze={useHistory:()=>!1,useLocation:()=>!1,useParams:()=>({}),Prompt:()=>null,Link:()=>null},Aa=tn.createContext(ze),Qt=Aa,rn=({children:e,useHistory:t,useLocation:r,useParams:o,Prompt:n,Link:a,routes:s})=>tn.createElement(Qt.Provider,{value:{useHistory:t??ze.useHistory,useLocation:r??ze.useLocation,useParams:o??ze.useParams,Prompt:n??ze.Prompt,Link:a??ze.Link,routes:s??ze.routes}},e);var te=()=>{let e=Fa(Qt),{useHistory:t,useLocation:r,useParams:o,Prompt:n,Link:a,routes:s}=e??ze;return{useHistory:t,useLocation:r,useParams:o,Prompt:n,Link:a,routes:s}};import{useQuery as Qa}from"@tanstack/react-query";import{useContext as ka}from"react";import on from"react";var Xe=on.createContext({options:{buttons:{enableAccessControl:!0,hideIfUnauthorized:!1}}});var nn=({can:e,children:t,options:r})=>on.createElement(Xe.Provider,{value:{can:e,options:r?{...r,buttons:{enableAccessControl:!0,hideIfUnauthorized:!1,...r.buttons}}:{buttons:{enableAccessControl:!0,hideIfUnauthorized:!1}}}},t);var gt=e=>{if(!e)return;let{icon:t,list:r,edit:o,create:n,show:a,clone:s,children:u,meta:p,options:d,...l}=e,{icon:c,...m}=p??{},{icon:P,...x}=d??{};return{...l,...p?{meta:m}:{},...d?{options:x}:{}}};var sn=({action:e,resource:t,params:r,queryOptions:o})=>{let{can:n}=ka(Xe),{resource:a,...s}=r??{},u=gt(a),p=Qa(["useCan",{action:e,resource:t,params:{...s,resource:u},enabled:o==null?void 0:o.enabled}],()=>(n==null?void 0:n({action:e,resource:t,params:{...s,resource:u}}))??Promise.resolve({can:!0}),{enabled:typeof n<"u",...o,retry:!1});return typeof n>"u"?{data:{can:!0}}:p};import an from"react";var mR=()=>{let{can:e}=an.useContext(Xe);return{can:an.useMemo(()=>e?async({params:o,...n})=>{let a=o!=null&&o.resource?gt(o.resource):void 0;return e({...n,...o?{params:{...o,resource:a}}:{}})}:void 0,[e])}};import{useCallback as un,useMemo as Va,useState as $r}from"react";import Ba from"lodash/uniqBy";import Na from"lodash/debounce";import sr from"lodash/get";var UR=e=>{let[t,r]=$r([]),[o,n]=$r([]),[a,s]=$r([]),{resource:u,sort:p,sorters:d,filters:l=[],optionLabel:c="title",optionValue:m="id",debounce:P=300,successNotification:x,errorNotification:C,defaultValueQueryOptions:v,queryOptions:g,fetchSize:U,pagination:S,hasPagination:h=!1,liveMode:i,defaultValue:f=[],onLiveEvent:R,onSearch:b,liveParams:T,meta:y,metaData:D,dataProviderName:L,overtimeOptions:A}=e,{resource:w,identifier:E}=k(u),F=K()({resource:w,meta:M(y,D)}),V=Array.isArray(f)?f:[f],O=un(Z=>{s(Z.data.map(se=>({label:sr(se,c),value:sr(se,m)})))},[c,m]),G=v??g,X=Ar({resource:E,ids:V,queryOptions:{...G,enabled:V.length>0&&((G==null?void 0:G.enabled)??!0),onSuccess:Z=>{var se;O(Z),(se=G==null?void 0:G.onSuccess)==null||se.call(G,Z)}},meta:F,metaData:F,liveMode:"off",dataProviderName:L}),j=un(Z=>{n(Z.data.map(se=>({label:sr(se,c),value:sr(se,m)})))},[c,m]),Q=Mt({resource:E,sorters:M(d,p),filters:l.concat(t),pagination:{current:S==null?void 0:S.current,pageSize:(S==null?void 0:S.pageSize)??U,mode:S==null?void 0:S.mode},hasPagination:h,queryOptions:{...g,onSuccess:Z=>{var se;j(Z),(se=g==null?void 0:g.onSuccess)==null||se.call(g,Z)}},successNotification:x,errorNotification:C,meta:F,metaData:F,liveMode:i,liveParams:T,onLiveEvent:R,dataProviderName:L}),$=Z=>{if(b){r(b(Z));return}if(Z)r([{field:c,operator:"contains",value:Z}]);else{r([]);return}},{elapsedTime:H}=_({isLoading:Q.isFetching||X.isFetching,interval:A==null?void 0:A.interval,onInterval:A==null?void 0:A.onInterval});return{queryResult:Q,defaultValueQueryResult:X,options:Va(()=>Ba([...o,...a],"value"),[o,a]),onSearch:Na($,P),overtime:{elapsedTime:H}}};import Ha,{useState as ar,useEffect as cn}from"react";import pn from"qs";import ir from"lodash/differenceWith";import ur from"lodash/isEqual";import Oa from"warn-once";var dn=[],ln=[];function $R({initialCurrent:e,initialPageSize:t,hasPagination:r=!0,pagination:o,initialSorter:n,permanentSorter:a=ln,defaultSetFilterBehavior:s,initialFilter:u,permanentFilter:p=dn,filters:d,sorters:l,syncWithLocation:c,resource:m,successNotification:P,errorNotification:x,queryOptions:C,liveMode:v,onLiveEvent:g,liveParams:U,meta:S,metaData:h,dataProviderName:i,overtimeOptions:f}={}){var Yr,Jr,Xr,qr,eo;let{syncWithLocation:R}=Sr(),b=c??R,T=jo(v),y=z(),{useLocation:D}=te(),{search:L,pathname:A}=D(),w=K(),E=de(),I=((d==null?void 0:d.mode)||"server")==="server",F=((l==null?void 0:l.mode)||"server")==="server",V=r===!1?"off":"server",O=((o==null?void 0:o.mode)??V)!=="off",G=M(o==null?void 0:o.current,e),X=M(o==null?void 0:o.pageSize,t),j=M(S,h),{parsedCurrent:Q,parsedPageSize:$,parsedSorter:H,parsedFilters:Z}=Wt(L??"?"),se=M(d==null?void 0:d.initial,u),ge=M(d==null?void 0:d.permanent,p)??dn,qe=M(l==null?void 0:l.initial,n),Oe=M(l==null?void 0:l.permanent,a)??ln,cr=M(d==null?void 0:d.defaultBehavior,s)??"merge",at,et,it,ut;b?(at=((Yr=E==null?void 0:E.params)==null?void 0:Yr.current)||Q||G||1,et=((Jr=E==null?void 0:E.params)==null?void 0:Jr.pageSize)||$||X||10,it=((Xr=E==null?void 0:E.params)==null?void 0:Xr.sorters)||(H.length?H:qe),ut=((qr=E==null?void 0:E.params)==null?void 0:qr.filters)||(Z.length?Z:se)):(at=G||1,et=X||10,it=qe,ut=se);let{replace:ct}=ue(),pt=ce(),{resource:jr,identifier:Vt}=k(m),pr=w({resource:jr,meta:j});Ha.useEffect(()=>{Oa(typeof Vt>"u","useTable: `resource` is not defined.")},[Vt]);let[_e,Ct]=ar(jt(Oe,it??[])),[tt,Te]=ar(_t(ge,ut??[])),[Ee,Be]=ar(at),[Ue,Me]=ar(et),je=({pagination:{current:me,pageSize:Ie},sorter:Nt,filters:Ht})=>{if(y==="new")return pt({type:"path",options:{keepHash:!0,keepQuery:!0},query:{...O?{current:me,pageSize:Ie}:{},sorters:Nt,filters:Ht,...Ze()}})??"";{let ht=pn.parse(L==null?void 0:L.substring(1)),Vn=Kt({pagination:{pageSize:Ie,current:me},sorters:_e??Nt,filters:Ht,...ht});return`${A??""}?${Vn??""}`}};cn(()=>{L===""&&(Be(at),Me(et),Ct(jt(Oe,it??[])),Te(_t(ge,ut??[])))},[L]);let Ze=()=>{if(y==="new"){let{sorters:me,filters:Ie,pageSize:Nt,current:Ht,...ht}=(E==null?void 0:E.params)??{};return ht}else{let{sorter:me,filters:Ie,pageSize:Nt,current:Ht,...ht}=pn.parse(L,{ignoreQueryPrefix:!0});return ht}};cn(()=>{if(b){let me=Ze();if(y==="new")pt({type:"replace",options:{keepQuery:!0},query:{...O?{pageSize:Ue,current:Ee}:{},sorters:ir(_e,Oe,ur),filters:ir(tt,ge,ur)}});else{let Ie=Kt({...O?{pagination:{pageSize:Ue,current:Ee}}:{},sorters:ir(_e,Oe,ur),filters:ir(tt,ge,ur),...me});return ct==null?void 0:ct(`${A}?${Ie}`,void 0,{shallow:!0})}}},[b,Ee,Ue,_e,tt]);let $e=Mt({resource:Vt,hasPagination:r,pagination:{current:Ee,pageSize:Ue,mode:o==null?void 0:o.mode},filters:I?mt(ge,tt):void 0,sorters:F?zt(Oe,_e):void 0,queryOptions:C,successNotification:P,errorNotification:x,meta:pr,metaData:pr,liveMode:T,liveParams:U,onLiveEvent:g,dataProviderName:i}),Bt=me=>{Te(Ie=>mt(ge,me,Ie))},An=me=>{Te(mt(ge,me))},Fn=me=>{Te(Ie=>mt(ge,me(Ie)))},Qn=(me,Ie=cr)=>{typeof me=="function"?Fn(me):Ie==="replace"?An(me):Bt(me)},Zr=me=>{Ct(()=>zt(Oe,me))},{elapsedTime:kn}=_({isLoading:$e.isFetching,interval:f==null?void 0:f.interval,onInterval:f==null?void 0:f.onInterval});return{tableQueryResult:$e,sorters:_e,setSorters:Zr,sorter:_e,setSorter:Zr,filters:tt,setFilters:Qn,current:Ee,setCurrent:Be,pageSize:Ue,setPageSize:Me,pageCount:Ue?Math.ceil((((eo=$e.data)==null?void 0:eo.total)??0)/Ue):1,createLinkForSyncWithLocation:je,overtime:{elapsedTime:kn}}}import{useContext as yn}from"react";import{useMutation as gn,useQueryClient as $a}from"@tanstack/react-query";import mn from"react";var nt=mn.createContext({}),fn=({create:e,get:t,update:r,children:o})=>mn.createElement(nt.Provider,{value:{create:e,get:t,update:r}},o);var Se=({logMutationOptions:e,renameMutationOptions:t}={})=>{let r=$a(),o=yn(nt),n=W(),{resources:a}=yn(Je),{data:s,refetch:u,isLoading:p}=dr({v3LegacyAuthProviderCompatible:!!(n!=null&&n.isLegacy),queryOptions:{enabled:!!o}}),d=gn(async c=>{var C,v,g,U,S;let m=pe(c.resource,a),P=M((C=m==null?void 0:m.meta)==null?void 0:C.audit,(v=m==null?void 0:m.options)==null?void 0:v.audit,(U=(g=m==null?void 0:m.options)==null?void 0:g.auditLog)==null?void 0:U.permissions);if(P&&!hr(P,c.action))return;let x;return p&&(x=await u()),await((S=o.create)==null?void 0:S.call(o,{...c,author:s??(x==null?void 0:x.data)}))},e),l=gn(async c=>{var m;return await((m=o.update)==null?void 0:m.call(o,c))},{onSuccess:c=>{if(c!=null&&c.resource){let m=q(c==null?void 0:c.resource);r.invalidateQueries(m.logList())}},...t});return{log:d,rename:l}};import{useContext as Ga}from"react";import{useQuery as Wa}from"@tanstack/react-query";var cP=({resource:e,action:t,meta:r,author:o,metaData:n,queryOptions:a})=>{let{get:s}=Ga(nt),u=q(e,void 0,n);return Wa(u.logList(r),()=>(s==null?void 0:s({resource:e,action:t,author:o,meta:r,metaData:n}))??Promise.resolve([]),{enabled:typeof s<"u",...a,retry:!1})};import{useCallback as Ka}from"react";import{useQueryClient as za}from"@tanstack/react-query";var Ae=()=>{let{resources:e}=k(),t=za();return Ka(({resource:o,dataProviderName:n,invalidates:a,id:s})=>{if(a===!1)return;let u=q(o,N(o,n,e));a.forEach(p=>{switch(p){case"all":t.invalidateQueries(u.all);break;case"list":t.invalidateQueries(u.list());break;case"many":t.invalidateQueries(u.many());break;case"resourceAll":t.invalidateQueries(u.resourceAll);break;case"detail":t.invalidateQueries(u.detail(s||""));break;default:break}})},[])};import{useContext as _a}from"react";import ja from"warn-once";var IP=({meta:e={}}={})=>{let t=z(),{i18nProvider:r}=_a(Fe),o=de(),n=B(),{resources:a,resource:s,action:u}=k(),{options:{textTransformers:p}}=ae(),d=[];if(!(s!=null&&s.name))return{breadcrumbs:d};let l=c=>{var P,x,C,v,g,U;let m=typeof c=="string"?pe(c,a,t==="legacy")??{name:c}:c;if(m){let S=M((P=m==null?void 0:m.meta)==null?void 0:P.parent,m==null?void 0:m.parentName);S&&l(S);let h=fe(m,a,t==="legacy").find(R=>R.action==="list"),i=(x=h==null?void 0:h.resource)!=null&&x.list?h==null?void 0:h.route:void 0,f=i?t==="legacy"?i:Pe(i,m==null?void 0:m.meta,o,e):void 0;d.push({label:M((C=m.meta)==null?void 0:C.label,(v=m.options)==null?void 0:v.label)??n(`${m.name}.${m.name}`,p.humanize(m.name)),href:f,icon:M((g=m.meta)==null?void 0:g.icon,(U=m.options)==null?void 0:U.icon,m.icon)})}};if(l(s),u&&u!=="list"){let c=`actions.${u}`,m=n(c);typeof r<"u"&&m===c?(ja(!0,`[useBreadcrumb]: Breadcrumb missing translate key for the "${u}" action. Please add "actions.${u}" key to your translation file.
|
|
11
|
-
For more information, see https://refine.dev/docs/api-reference/core/hooks/useBreadcrumb/#i18n-support`),d.push({label:n(`buttons.${u}`,p.humanize(u))})):d.push({label:n(c,p.humanize(u))})}return{breadcrumbs:d}};import Gr from"react";var Tt=(e,t,r=!1)=>{let o=[],n=De(e,t);for(;n;)o.push(n),n=De(n,t);return o.reverse(),`/${[...o,e].map(s=>Re((r?s.route:void 0)??s.identifier??s.name)).join("/").replace(/^\//,"")}`};var Tn=(e,t=!1)=>{let r={item:{name:"__root__"},children:{}};e.forEach(n=>{let a=[],s=De(n,e);for(;s;)a.push(s),s=De(s,e);a.reverse();let u=r;a.forEach(d=>{let l=(t?d.route:void 0)??d.identifier??d.name;u.children[l]||(u.children[l]={item:d,children:{}}),u=u.children[l]});let p=(t?n.route:void 0)??n.identifier??n.name;u.children[p]||(u.children[p]={item:n,children:{}})});let o=n=>{let a=[];return Object.keys(n.children).forEach(s=>{let u=Tt(n.children[s].item,e,t),p={...n.children[s].item,key:u,children:o(n.children[s])};a.push(p)}),a};return o(r)};var Rn=e=>e.split("?")[0].split("#")[0].replace(/(.+)(\/$)/,"$1"),Za=({meta:e,hideOnMissingParameter:t}={hideOnMissingParameter:!0})=>{let r=B(),o=Ft(),n=z(),{resource:a,resources:s}=k(),{pathname:u}=de(),{useLocation:p}=te(),{pathname:d}=p(),l=ft(),m=`/${((n==="legacy"?Rn(d):u?Rn(u):void 0)??"").replace(/^\//,"")}`,P=a?Tt(a,s,n==="legacy"):m??"",x=Gr.useMemo(()=>{if(!a)return[];let g=De(a,s),U=[Tt(a,s)];for(;g;)U.push(Tt(g,s)),g=De(g,s);return U},[]),C=Gr.useCallback(g=>{var S,h,i,f,R,b;if((((S=g==null?void 0:g.meta)==null?void 0:S.hide)??((h=g==null?void 0:g.options)==null?void 0:h.hide))||!(g!=null&&g.list)&&g.children.length===0)return;let U=g.list?o({resource:g,action:"list",legacy:n==="legacy",meta:e}):void 0;if(!(t&&U&&U.match(/(\/|^):(.+?)(\/|$){1}/)))return{...g,route:U,icon:M((i=g.meta)==null?void 0:i.icon,(f=g.options)==null?void 0:f.icon,g.icon),label:M((R=g==null?void 0:g.meta)==null?void 0:R.label,(b=g==null?void 0:g.options)==null?void 0:b.label)??r(`${g.name}.${g.name}`,l(g.name,"plural"))}},[n,e,r,t]),v=Gr.useMemo(()=>{let g=Tn(s,n==="legacy"),U=S=>S.flatMap(h=>{let i=U(h.children),f=C({...h,children:i});return f?[f]:[]});return U(g)},[s,n,C]);return{defaultOpenKeys:x,selectedKey:P,menuItems:v}};var K=()=>{let{params:e}=de();return({resource:r,meta:o}={})=>{let{meta:n}=gt(r)??{meta:{}},{filters:a,sorters:s,current:u,pageSize:p,...d}=e??{};return{...n,...d,...o}}};var Xa=()=>{let[e,t]=Ja(),r=B(),{push:o}=ue(),n=ce(),a=z(),{resource:s,action:u}=k();return Ya(()=>{s&&u&&t(r("pages.error.info",{action:u,resource:s.name},`You may have forgotten to add the "${u}" component to "${s.name}" resource.`))},[s,u]),kt.createElement(kt.Fragment,null,kt.createElement("h1",null,r("pages.error.404",void 0,"Sorry, the page you visited does not exist.")),e&&kt.createElement("p",null,e),kt.createElement("button",{onClick:()=>{a==="legacy"?o("/"):n({to:"/"})}},r("pages.error.backHome",void 0,"Back Home")))};import xe,{useState as Pn}from"react";var Ur=()=>{let[e,t]=Pn(""),[r,o]=Pn(""),n=B(),a=W(),{mutate:s}=bt({v3LegacyAuthProviderCompatible:!!(a!=null&&a.isLegacy)});return xe.createElement(xe.Fragment,null,xe.createElement("h1",null,n("pages.login.title","Sign in your account")),xe.createElement("form",{onSubmit:u=>{u.preventDefault(),s({username:e,password:r})}},xe.createElement("table",null,xe.createElement("tbody",null,xe.createElement("tr",null,xe.createElement("td",null,n("pages.login.username",void 0,"username"),":"),xe.createElement("td",null,xe.createElement("input",{type:"text",size:20,autoCorrect:"off",spellCheck:!1,autoCapitalize:"off",autoFocus:!0,required:!0,value:e,onChange:u=>t(u.target.value)}))),xe.createElement("tr",null,xe.createElement("td",null,n("pages.login.password",void 0,"password"),":"),xe.createElement("td",null,xe.createElement("input",{type:"password",required:!0,size:20,value:r,onChange:u=>o(u.target.value)}))))),xe.createElement("br",null),xe.createElement("input",{type:"submit",value:"login"})))};import Rt from"react";import le,{useState as Wr}from"react";var xn=({providers:e,registerLink:t,forgotPasswordLink:r,rememberMe:o,contentProps:n,wrapperProps:a,renderContent:s,formProps:u,title:p=void 0})=>{let d=z(),l=ot(),{Link:c}=te(),m=d==="legacy"?c:l,[P,x]=Wr(""),[C,v]=Wr(""),[g,U]=Wr(!1),S=B(),h=W(),{mutate:i}=bt({v3LegacyAuthProviderCompatible:!!(h!=null&&h.isLegacy)}),f=(T,y)=>le.createElement(m,{to:T},y),R=()=>e?e.map(T=>le.createElement("div",{key:T.name,style:{display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"1rem"}},le.createElement("button",{onClick:()=>i({providerName:T.name}),style:{display:"flex",alignItems:"center"}},T==null?void 0:T.icon,T.label??le.createElement("label",null,T.label)))):null,b=le.createElement("div",{...n},le.createElement("h1",{style:{textAlign:"center"}},S("pages.login.title","Sign in to your account")),R(),le.createElement("hr",null),le.createElement("form",{onSubmit:T=>{T.preventDefault(),i({email:P,password:C,remember:g})},...u},le.createElement("div",{style:{display:"flex",flexDirection:"column",padding:25}},le.createElement("label",{htmlFor:"email-input"},S("pages.login.fields.email","Email")),le.createElement("input",{id:"email-input",name:"email",type:"text",size:20,autoCorrect:"off",spellCheck:!1,autoCapitalize:"off",required:!0,value:P,onChange:T=>x(T.target.value)}),le.createElement("label",{htmlFor:"password-input"},S("pages.login.fields.password","Password")),le.createElement("input",{id:"password-input",type:"password",name:"password",required:!0,size:20,value:C,onChange:T=>v(T.target.value)}),o??le.createElement(le.Fragment,null,le.createElement("label",{htmlFor:"remember-me-input"},S("pages.login.buttons.rememberMe","Remember me"),le.createElement("input",{id:"remember-me-input",name:"remember",type:"checkbox",size:20,checked:g,value:g.toString(),onChange:()=>{U(!g)}}))),le.createElement("br",null),r??f("/forgot-password",S("pages.login.buttons.forgotPassword","Forgot password?")),le.createElement("input",{type:"submit",value:S("pages.login.signin","Sign in")}),t??le.createElement("span",null,S("pages.login.buttons.noAccount","Don\u2019t have an account?")," ",f("/register",S("pages.login.register","Sign up"))))));return le.createElement("div",{...a},s?s(b,p):b)};import ye,{useState as Cn}from"react";var hn=({providers:e,loginLink:t,wrapperProps:r,contentProps:o,renderContent:n,formProps:a,title:s=void 0})=>{let u=z(),p=ot(),{Link:d}=te(),l=u==="legacy"?d:p,[c,m]=Cn(""),[P,x]=Cn(""),C=B(),v=W(),{mutate:g,isLoading:U}=yr({v3LegacyAuthProviderCompatible:!!(v!=null&&v.isLegacy)}),S=(f,R)=>ye.createElement(l,{to:f},R),h=()=>e?e.map(f=>ye.createElement("div",{key:f.name,style:{display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"1rem"}},ye.createElement("button",{onClick:()=>g({providerName:f.name}),style:{display:"flex",alignItems:"center"}},f==null?void 0:f.icon,f.label??ye.createElement("label",null,f.label)))):null,i=ye.createElement("div",{...o},ye.createElement("h1",{style:{textAlign:"center"}},C("pages.register.title","Sign up for your account")),h(),ye.createElement("hr",null),ye.createElement("form",{onSubmit:f=>{f.preventDefault(),g({email:c,password:P})},...a},ye.createElement("div",{style:{display:"flex",flexDirection:"column",padding:25}},ye.createElement("label",{htmlFor:"email-input"},C("pages.register.fields.email","Email")),ye.createElement("input",{id:"email-input",name:"email",type:"email",size:20,autoCorrect:"off",spellCheck:!1,autoCapitalize:"off",required:!0,value:c,onChange:f=>m(f.target.value)}),ye.createElement("label",{htmlFor:"password-input"},C("pages.register.fields.password","Password")),ye.createElement("input",{id:"password-input",name:"password",type:"password",required:!0,size:20,value:P,onChange:f=>x(f.target.value)}),ye.createElement("input",{type:"submit",value:C("pages.register.buttons.submit","Sign up"),disabled:U}),t??ye.createElement(ye.Fragment,null,ye.createElement("span",null,C("pages.login.buttons.haveAccount","Have an account?")," ",S("/login",C("pages.login.signin","Sign in")))))));return ye.createElement("div",{...r},n?n(i,s):i)};import Qe,{useState as qa}from"react";var bn=({loginLink:e,wrapperProps:t,contentProps:r,renderContent:o,formProps:n,title:a=void 0})=>{let s=B(),u=z(),p=ot(),{Link:d}=te(),l=u==="legacy"?d:p,[c,m]=qa(""),{mutate:P,isLoading:x}=Tr(),C=(g,U)=>Qe.createElement(l,{to:g},U),v=Qe.createElement("div",{...r},Qe.createElement("h1",{style:{textAlign:"center"}},s("pages.forgotPassword.title","Forgot your password?")),Qe.createElement("hr",null),Qe.createElement("form",{onSubmit:g=>{g.preventDefault(),P({email:c})},...n},Qe.createElement("div",{style:{display:"flex",flexDirection:"column",padding:25}},Qe.createElement("label",{htmlFor:"email-input"},s("pages.forgotPassword.fields.email","Email")),Qe.createElement("input",{id:"email-input",name:"email",type:"mail",autoCorrect:"off",spellCheck:!1,autoCapitalize:"off",required:!0,value:c,onChange:g=>m(g.target.value)}),Qe.createElement("input",{type:"submit",disabled:x,value:s("pages.forgotPassword.buttons.submit","Send reset instructions")}),Qe.createElement("br",null),e??Qe.createElement("span",null,s("pages.register.buttons.haveAccount","Have an account? ")," ",C("/login",s("pages.login.signin","Sign in"))))));return Qe.createElement("div",{...t},o?o(v,a):v)};import Ve,{useState as vn}from"react";var Dn=({wrapperProps:e,contentProps:t,renderContent:r,formProps:o,title:n=void 0})=>{let a=B(),s=W(),{mutate:u,isLoading:p}=Pr({v3LegacyAuthProviderCompatible:!!(s!=null&&s.isLegacy)}),[d,l]=vn(""),[c,m]=vn(""),P=Ve.createElement("div",{...t},Ve.createElement("h1",{style:{textAlign:"center"}},a("pages.updatePassword.title","Update Password")),Ve.createElement("hr",null),Ve.createElement("form",{onSubmit:x=>{x.preventDefault(),u({password:d,confirmPassword:c})},...o},Ve.createElement("div",{style:{display:"flex",flexDirection:"column",padding:25}},Ve.createElement("label",{htmlFor:"password-input"},a("pages.updatePassword.fields.password","New Password")),Ve.createElement("input",{id:"password-input",name:"password",type:"password",required:!0,size:20,value:d,onChange:x=>l(x.target.value)}),Ve.createElement("label",{htmlFor:"confirm-password-input"},a("pages.updatePassword.fields.confirmPassword","Confirm New Password")),Ve.createElement("input",{id:"confirm-password-input",name:"confirmPassword",type:"password",required:!0,size:20,value:c,onChange:x=>m(x.target.value)}),Ve.createElement("input",{type:"submit",disabled:p,value:a("pages.updatePassword.buttons.submit","Update")}))));return Ve.createElement("div",{...e},r?r(P,n):P)};var ei=e=>{let{type:t}=e;return Rt.createElement(Rt.Fragment,null,(()=>{switch(t){case"register":return Rt.createElement(hn,{...e});case"forgotPassword":return Rt.createElement(bn,{...e});case"updatePassword":return Rt.createElement(Dn,{...e});default:return Rt.createElement(xn,{...e})}})())};import ve from"react";var Kr=()=>ve.createElement(ve.Fragment,null,ve.createElement("h1",null,"Welcome on board"),ve.createElement("p",null,"Your configuration is completed."),ve.createElement("p",null,"Now you can get started by adding your resources to the"," ",ve.createElement("code",null,"`resources`")," property of ",ve.createElement("code",null,"`<Refine>`")),ve.createElement("div",{style:{display:"flex",gap:8}},ve.createElement("a",{href:"https://refine.dev",target:"_blank",rel:"noreferrer"},ve.createElement("button",null,"Documentation")),ve.createElement("a",{href:"https://refine.dev/examples",target:"_blank",rel:"noreferrer"},ve.createElement("button",null,"Examples")),ve.createElement("a",{href:"https://discord.gg/refine",target:"_blank",rel:"noreferrer"},ve.createElement("button",null,"Community"))));import J,{useState as ti}from"react";var ri=[{title:"Documentation",description:"Learn about the technical details of using refine in your projects.",link:"https://refine.dev/",icon:J.createElement("svg",{width:"14",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J.createElement("path",{d:"M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V5a1 1 0 0 0-1-1H3a1 1 0 0 1 0-2h10a1 1 0 1 0 0-2H2Z",fill:"#fff"}))},{title:"Tutorial",description:"Learn how to use refine by building a fully-functioning CRUD app, from scratch to full launch.",link:"https://refine.dev/docs/tutorial/introduction/index/",icon:J.createElement("svg",{width:"16",height:"14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J.createElement("path",{d:"M0 4.573c0-.475.163-.948.53-1.25a4.57 4.57 0 0 1 .854-.553L5.956.485a4.571 4.571 0 0 1 4.088 0l4.572 2.285c.308.154.594.34.853.553.306.251.47.62.517 1.01.01.055.014.112.014.169v6.5a1 1 0 0 1-2 0V6.684l-3.956 1.978a4.571 4.571 0 0 1-4.088 0L1.384 6.376a4.57 4.57 0 0 1-.853-.553C.163 5.522 0 5.05 0 4.573Z",fill:"#fff"}),J.createElement("path",{d:"M5.061 13.305 3 12.274V9.42l2.061 1.031a6.571 6.571 0 0 0 5.878 0L13 9.421v2.853l-2.061 1.03a6.571 6.571 0 0 1-5.878 0Z",fill:"#fff"}))},{title:"Examples",description:"A collection of reference applications you can use as a starting point.",link:"https://refine.dev/examples",icon:J.createElement("svg",{width:"16",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 2a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4H0V2Zm3 2a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm4-1a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm2 1a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",fill:"#fff"}),J.createElement("path",{d:"M0 14V8h16v6a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2Z",fill:"#fff"}))},{title:"Community",description:"Join our Discord community and keep up with the latest news.",link:"https://discord.gg/refine",icon:J.createElement("svg",{width:"16",height:"12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J.createElement("path",{d:"M13.553 1.005A13.334 13.334 0 0 0 10.253 0c-.156.276-.298.56-.423.85a12.42 12.42 0 0 0-3.664 0A8.975 8.975 0 0 0 5.744 0 13.43 13.43 0 0 0 2.44 1.007C.351 4.066-.215 7.05.068 9.99A13.36 13.36 0 0 0 4.116 12c.328-.436.618-.9.867-1.384a8.647 8.647 0 0 1-1.365-.645c.115-.082.227-.167.335-.249a9.594 9.594 0 0 0 8.094 0c.11.089.222.173.335.25-.436.254-.894.47-1.368.646.249.484.539.946.867 1.382a13.3 13.3 0 0 0 4.051-2.01c.332-3.41-.568-6.365-2.379-8.985Zm-8.21 7.176c-.79 0-1.442-.709-1.442-1.58 0-.872.63-1.587 1.439-1.587s1.456.715 1.442 1.586c-.014.872-.636 1.58-1.44 1.58Zm5.315 0c-.79 0-1.44-.709-1.44-1.58 0-.872.63-1.587 1.44-1.587.81 0 1.452.715 1.438 1.586-.014.872-.634 1.58-1.438 1.58Z",fill:"#fff"}))}],oi=()=>{let e=tr("(max-width: 1010px)"),t=tr("(max-width: 650px)"),r=()=>t?"1, 280px":e?"2, 280px":"4, 208px",o=()=>t?"32px":e?"40px":"48px",n=()=>t?"16px":e?"20px":"24px";return J.createElement("div",{style:{backgroundImage:"url(https://refine.ams3.cdn.digitaloceanspaces.com/welcome-page/welcome-page.webp)",backgroundPosition:"center top",backgroundSize:"cover",backgroundRepeat:"no-repeat",minHeight:"100vh",backgroundColor:"#0D0D12",fontFamily:"Arial",color:"#FFFFFF"}},J.createElement("div",{style:{height:"89px"}}),J.createElement("div",{style:{display:"flex",justifyContent:"center"}},J.createElement("img",{src:"https://refine.ams3.cdn.digitaloceanspaces.com/welcome-page/welcome-logo.webp",width:"198",height:"54"})),J.createElement("div",{style:{height:e?"270px":"22vw",minHeight:e?"270px":"313px"}}),J.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"16px",textAlign:"center"}},J.createElement("h1",{style:{fontSize:o(),fontWeight:700,margin:"0px"}},"Welcome Aboard!"),J.createElement("h4",{style:{fontSize:n(),fontWeight:400,margin:"0px"}},"Your configuration is completed.")),J.createElement("div",{style:{height:"64px"}}),J.createElement("div",{style:{display:"grid",gridTemplateColumns:`repeat(${r()})`,justifyContent:"center",gap:"48px",paddingRight:"16px",paddingLeft:"16px",maxWidth:"976px",margin:"auto"}},ri.map(a=>J.createElement(ni,{key:`welcome-page-${a.title}`,card:a}))),J.createElement("div",{style:{height:"64px"}}))},ni=({card:e})=>{let{title:t,description:r,icon:o,link:n}=e,[a,s]=ti(!1);return J.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"16px"}},J.createElement("div",{style:{display:"flex",alignItems:"center"}},J.createElement("a",{onPointerEnter:()=>s(!0),onPointerLeave:()=>s(!1),style:{display:"flex",alignItems:"center",color:"#fff",textDecoration:"none"},href:n},o,J.createElement("span",{style:{fontSize:"16px",fontWeight:700,marginLeft:"13px",marginRight:"14px"}},t),J.createElement("svg",{style:{transition:"transform 0.5s ease-in-out, opacity 0.2s ease-in-out",...a&&{transform:"translateX(4px)",opacity:1}},width:"12",height:"8",fill:"none",opacity:"0.5",xmlns:"http://www.w3.org/2000/svg"},J.createElement("path",{d:"M7.293.293a1 1 0 0 1 1.414 0l3 3a1 1 0 0 1 0 1.414l-3 3a1 1 0 0 1-1.414-1.414L8.586 5H1a1 1 0 0 1 0-2h7.586L7.293 1.707a1 1 0 0 1 0-1.414Z",fill:"#fff"})))),J.createElement("span",{style:{fontSize:"12px",opacity:.5,lineHeight:"16px"}},r))};import{QueryClient as wn,QueryClientProvider as ui}from"@tanstack/react-query";import{ReactQueryDevtools as ci}from"@tanstack/react-query-devtools";import ne from"react";import{useEffect as ai}from"react";import{useContext as st}from"react";var si="4.26.3",Ln=()=>{let e=xr(),t=st(nt),r=st(We),o=st(Qt),n=st(St),{i18nProvider:a}=st(Fe),s=st(At),u=st(Xe),{resources:p}=k(),d=!!t.create||!!t.get||!!t.update,l=!!(r!=null&&r.publish)||!!(r!=null&&r.subscribe)||!!(r!=null&&r.unsubscribe),c=!!o.useHistory||!!o.Link||!!o.Prompt||!!o.useLocation||!!o.useParams,m=!!n,P=!!(a!=null&&a.changeLocale)||!!(a!=null&&a.getLocale)||!!(a!=null&&a.translate),x=!!s.close||!!s.open,C=!!u.can;return{providers:{auth:e,auditLog:d,live:l,router:c,data:m,i18n:P,notification:x,accessControl:C},version:si,resourceCount:p.length}};var ii=e=>{let t=JSON.stringify(e||{});return typeof btoa<"u"?btoa(t):Buffer.from(t).toString("base64")},En=()=>{let e=Ln();return ai(()=>{if(typeof window>"u"&&!Image)return;let t=new Image;t.src=`https://telemetry.refine.dev/telemetry?payload=${ii(e)}`},[]),null};import pi from"warn-once";var Un=e=>{let t=["go","parse","back","Link"],r=Object.keys(e).filter(n=>!t.includes(n));return r.length>0?(console.warn(`Unsupported properties are found in \`routerProvider\` prop. You provided \`${r.join(", ")}\`. Supported properties are \`${t.join(", ")}\`. You may wanted to use \`legacyRouterProvider\` prop instead.`),!0):!1};import Mn from"react";var In=e=>{let t=Mn.useRef(!1);Mn.useEffect(()=>{t.current===!1&&e&&Un(e)&&(t.current=!0)},[e])};var di=({legacyAuthProvider:e,authProvider:t,dataProvider:r,legacyRouterProvider:o,routerProvider:n,notificationProvider:a,accessControlProvider:s,auditLogProvider:u,resources:p,DashboardPage:d,ReadyPage:l,LoginPage:c,catchAll:m,children:P,liveProvider:x,i18nProvider:C,Title:v,Layout:g,Sider:U,Header:S,Footer:h,OffLayoutArea:i,onLiveEvent:f,options:R})=>{var E;let{optionsWithDefaults:b,disableTelemetryWithDefault:T,reactQueryWithDefaults:y}=Mr({options:R}),D=nr(()=>{var I;return y.clientConfig instanceof wn?y.clientConfig:new wn({...y.clientConfig,defaultOptions:{...y.clientConfig.defaultOptions,queries:{refetchOnWindowFocus:!1,keepPreviousData:!0,...(I=y.clientConfig.defaultOptions)==null?void 0:I.queries}}})},[y.clientConfig]),A=ne.useMemo(()=>typeof a=="function"?a:()=>a??{},[a])();if(In(n),o&&!n&&(p??[]).length===0)return l?ne.createElement(l,null):ne.createElement(Kr,null);let{RouterComponent:w=ne.Fragment}=n?{}:o??{};return typeof window<"u"&&((E=window==null?void 0:window.location)==null?void 0:E.hostname)==="localhost"&&pi(!0,`%c
|
|
10
|
+
See https://refine.dev/docs/api-reference/core/hooks/show/useShow/#resource`);let i=Qt({resource:P,id:E??"",queryOptions:{enabled:E!==void 0,...d},successNotification:r,errorNotification:o,meta:b,metaData:b,liveMode:n,onLiveEvent:u,dataProviderName:p}),{elapsedTime:f}=j({isLoading:i.isFetching,interval:l==null?void 0:l.interval,onInterval:l==null?void 0:l.onInterval});return{queryResult:i,showId:E,setShowId:A,overtime:{elapsedTime:f}}};import{useEffect as La,useState as _r}from"react";import{parse as Ea}from"papaparse";import Ua from"lodash-es/chunk";var bT=({resourceName:e,resource:t,mapData:r=l=>l,paparseOptions:o,batchSize:s=Number.MAX_SAFE_INTEGER,onFinish:a,meta:n,metaData:u,onProgress:p,dataProviderName:d}={})=>{let[l,c]=_r(0),[m,P]=_r(0),[x,C]=_r(!1),{resource:v,identifier:g}=V(t??e),E=K(),A=Gr(),b=kt(),i=E({resource:v,meta:M(n,u)}),f;s===1?f=b:f=A;let T=()=>{P(0),c(0),C(!1)},h=y=>{let D={succeeded:y.filter(L=>L.type==="success"),errored:y.filter(L=>L.type==="error")};a==null||a(D),C(!1)};La(()=>{p==null||p({totalAmount:m,processedAmount:l})},[m,l]);let R=({file:y})=>(T(),new Promise(D=>{C(!0),Ea(y,{complete:async({data:L})=>{let w=Yt(L,r);if(P(w.length),s===1){let I=w.map(S=>async()=>({response:await b.mutateAsync({resource:g??"",values:S,successNotification:!1,errorNotification:!1,dataProviderName:d,meta:i,metaData:i}),value:S})),U=await sr(I,({response:S,value:F})=>(c(k=>k+1),{response:[S.data],type:"success",request:[F]}),(S,F)=>({response:[S],type:"error",request:[w[F]]}));D(U)}else{let I=Ua(w,s),U=I.map(F=>async()=>({response:await A.mutateAsync({resource:g??"",values:F,successNotification:!1,errorNotification:!1,dataProviderName:d,meta:i,metaData:i}),value:F,currentBatchLength:F.length})),S=await sr(U,({response:F,currentBatchLength:k,value:G})=>(c(O=>O+k),{response:F.data,type:"success",request:G}),(F,k)=>({response:[F],type:"error",request:I[k]}));D(S)}},...o})}).then(D=>(h(D),D)));return{inputProps:{type:"file",accept:".csv",onChange:y=>{y.target.files&&y.target.files.length>0&&R({file:y.target.files[0]})}},mutationResult:f,isLoading:x,handleChange:R}};import{useCallback as os,useState as Ma}from"react";var DT=({defaultVisible:e=!1}={})=>{let[t,r]=Ma(e),o=os(()=>r(!0),[t]),s=os(()=>r(!1),[t]);return{visible:t,show:o,close:s}};import Ia from"react";var Nt=()=>{let e=_(),{resource:t,resources:r}=V(),o=le();return Ia.useCallback(({resource:a,action:n,meta:u})=>{var m;let p=a||t;if(!p)return;let l=(m=ye(p,r,e==="legacy").find(P=>P.action===n))==null?void 0:m.route;return l?Re(l,p==null?void 0:p.meta,o,u):void 0},[r,t,o])};var wa=({resource:e,action:t,meta:r,legacy:o})=>Nt()({resource:e,action:t,meta:r,legacy:o});import Sa,{useContext as Aa}from"react";var nt=()=>{let e=Aa(ze);return e!=null&&e.Link?e.Link:({to:r,...o})=>Sa.createElement("a",{href:r,...o})};import{useContext as Qa}from"react";import ss from"react";var _e={useHistory:()=>!1,useLocation:()=>!1,useParams:()=>({}),Prompt:()=>null,Link:()=>null},Fa=ss.createContext(_e),Ht=Fa,ns=({children:e,useHistory:t,useLocation:r,useParams:o,Prompt:s,Link:a,routes:n})=>ss.createElement(Ht.Provider,{value:{useHistory:t??_e.useHistory,useLocation:r??_e.useLocation,useParams:o??_e.useParams,Prompt:s??_e.Prompt,Link:a??_e.Link,routes:n??_e.routes}},e);var re=()=>{let e=Qa(Ht),{useHistory:t,useLocation:r,useParams:o,Prompt:s,Link:a,routes:n}=e??_e;return{useHistory:t,useLocation:r,useParams:o,Prompt:s,Link:a,routes:n}};import{useQuery as ka}from"@tanstack/react-query";import{useContext as Va}from"react";import as from"react";var Xe=as.createContext({options:{buttons:{enableAccessControl:!0,hideIfUnauthorized:!1}}});var is=({can:e,children:t,options:r})=>as.createElement(Xe.Provider,{value:{can:e,options:r?{...r,buttons:{enableAccessControl:!0,hideIfUnauthorized:!1,...r.buttons}}:{buttons:{enableAccessControl:!0,hideIfUnauthorized:!1}}}},t);var Rt=e=>{if(!e)return;let{icon:t,list:r,edit:o,create:s,show:a,clone:n,children:u,meta:p,options:d,...l}=e,{icon:c,...m}=p??{},{icon:P,...x}=d??{};return{...l,...p?{meta:m}:{},...d?{options:x}:{}}};var us=({action:e,resource:t,params:r,queryOptions:o})=>{let{can:s}=Va(Xe),{resource:a,...n}=r??{},u=Rt(a),p=ka(["useCan",{action:e,resource:t,params:{...n,resource:u},enabled:o==null?void 0:o.enabled}],()=>(s==null?void 0:s({action:e,resource:t,params:{...n,resource:u}}))??Promise.resolve({can:!0}),{enabled:typeof s<"u",...o,retry:!1});return typeof s>"u"?{data:{can:!0}}:p};import cs from"react";var yR=()=>{let{can:e}=cs.useContext(Xe);return{can:cs.useMemo(()=>e?async({params:o,...s})=>{let a=o!=null&&o.resource?Rt(o.resource):void 0;return e({...s,...o?{params:{...o,resource:a}}:{}})}:void 0,[e])}};import{useCallback as ps,useMemo as Ba,useState as jr}from"react";import Na from"lodash/uniqBy";import Ha from"lodash/debounce";import mr from"lodash/get";var IR=e=>{let[t,r]=jr([]),[o,s]=jr([]),[a,n]=jr([]),{resource:u,sort:p,sorters:d,filters:l=[],optionLabel:c="title",optionValue:m="id",debounce:P=300,successNotification:x,errorNotification:C,defaultValueQueryOptions:v,queryOptions:g,fetchSize:E,pagination:A,hasPagination:b=!1,liveMode:i,defaultValue:f=[],onLiveEvent:T,onSearch:h,liveParams:R,meta:y,metaData:D,dataProviderName:L,overtimeOptions:w}=e,{resource:I,identifier:U}=V(u),F=K()({resource:I,meta:M(y,D)}),k=Array.isArray(f)?f:[f],G=ps(Z=>{n(Z.data.map(q=>({label:mr(q,c),value:mr(q,m)})))},[c,m]),O=v??g,z=Nr({resource:U,ids:k,queryOptions:{...O,enabled:k.length>0&&((O==null?void 0:O.enabled)??!0),onSuccess:Z=>{var q;G(Z),(q=O==null?void 0:O.onSuccess)==null||q.call(O,Z)}},meta:F,metaData:F,liveMode:"off",dataProviderName:L}),X=ps(Z=>{s(Z.data.map(q=>({label:mr(q,c),value:mr(q,m)})))},[c,m]),Q=Ft({resource:U,sorters:M(d,p),filters:l.concat(t),pagination:{current:A==null?void 0:A.current,pageSize:(A==null?void 0:A.pageSize)??E,mode:A==null?void 0:A.mode},hasPagination:b,queryOptions:{...g,onSuccess:Z=>{var q;X(Z),(q=g==null?void 0:g.onSuccess)==null||q.call(g,Z)}},successNotification:x,errorNotification:C,meta:F,metaData:F,liveMode:i,liveParams:R,onLiveEvent:T,dataProviderName:L}),$=Z=>{if(h){r(h(Z));return}if(Z)r([{field:c,operator:"contains",value:Z}]);else{r([]);return}},{elapsedTime:N}=j({isLoading:Q.isFetching||z.isFetching,interval:w==null?void 0:w.interval,onInterval:w==null?void 0:w.onInterval});return{queryResult:Q,defaultValueQueryResult:z,options:Ba(()=>Na([...o,...a],"value"),[o,a]),onSearch:Ha($,P),overtime:{elapsedTime:N}}};import Oa,{useState as fr,useEffect as ds}from"react";import ls from"qs";import yr from"lodash/differenceWith";import gr from"lodash/isEqual";import $a from"warn-once";var ms=[],fs=[];function WR({initialCurrent:e,initialPageSize:t,hasPagination:r=!0,pagination:o,initialSorter:s,permanentSorter:a=fs,defaultSetFilterBehavior:n,initialFilter:u,permanentFilter:p=ms,filters:d,sorters:l,syncWithLocation:c,resource:m,successNotification:P,errorNotification:x,queryOptions:C,liveMode:v,onLiveEvent:g,liveParams:E,meta:A,metaData:b,dataProviderName:i,overtimeOptions:f}={}){var eo,to,ro,oo,so;let{syncWithLocation:T}=Br(),h=c??T,R=Xo(v),y=_(),{useLocation:D}=re(),{search:L,pathname:w}=D(),I=K(),U=le(),S=((d==null?void 0:d.mode)||"server")==="server",F=((l==null?void 0:l.mode)||"server")==="server",k=r===!1?"off":"server",G=((o==null?void 0:o.mode)??k)!=="off",O=M(o==null?void 0:o.current,e),z=M(o==null?void 0:o.pageSize,t),X=M(A,b),{parsedCurrent:Q,parsedPageSize:$,parsedSorter:N,parsedFilters:Z}=Jt(L??"?"),q=M(d==null?void 0:d.initial,u),he=M(d==null?void 0:d.permanent,p)??ms,je=M(l==null?void 0:l.initial,s),Oe=M(l==null?void 0:l.permanent,a)??fs,$t=M(d==null?void 0:d.defaultBehavior,n)??"merge",ut,ct,qe,pt;h?(ut=((eo=U==null?void 0:U.params)==null?void 0:eo.current)||Q||O||1,ct=((to=U==null?void 0:U.params)==null?void 0:to.pageSize)||$||z||10,qe=((ro=U==null?void 0:U.params)==null?void 0:ro.sorters)||(N.length?N:je),pt=((oo=U==null?void 0:U.params)==null?void 0:oo.filters)||(Z.length?Z:q)):(ut=O||1,ct=z||10,qe=je,pt=q);let{replace:ht}=ue(),et=ce(),{resource:Gt,identifier:tt}=V(m),Wt=I({resource:Gt,meta:X});Oa.useEffect(()=>{$a(typeof tt>"u","useTable: `resource` is not defined.")},[tt]);let[$e,Kt]=fr(tr(Oe,qe??[])),[dt,vt]=fr(er(he,pt??[])),[lt,Dt]=fr(ut),[Ge,de]=fr(ct),Ve=({pagination:{current:fe,pageSize:Me},sorter:zt,filters:_t})=>{if(y==="new")return et({type:"path",options:{keepHash:!0,keepQuery:!0},query:{...G?{current:fe,pageSize:Me}:{},sorters:zt,filters:_t,...ve()}})??"";{let Et=ls.parse(L==null?void 0:L.substring(1)),ks=Xt({pagination:{pageSize:Me,current:fe},sorters:$e??zt,filters:_t,...Et});return`${w??""}?${ks??""}`}};ds(()=>{L===""&&(Dt(ut),de(ct),Kt(tr(Oe,qe??[])),vt(er(he,pt??[])))},[L]);let ve=()=>{if(y==="new"){let{sorters:fe,filters:Me,pageSize:zt,current:_t,...Et}=(U==null?void 0:U.params)??{};return Et}else{let{sorter:fe,filters:Me,pageSize:zt,current:_t,...Et}=ls.parse(L,{ignoreQueryPrefix:!0});return Et}};ds(()=>{if(h){let fe=ve();if(y==="new")et({type:"replace",options:{keepQuery:!0},query:{...G?{pageSize:Ge,current:lt}:{},sorters:yr($e,Oe,gr),filters:yr(dt,he,gr)}});else{let Me=Xt({...G?{pagination:{pageSize:Ge,current:lt}}:{},sorters:yr($e,Oe,gr),filters:yr(dt,he,gr),...fe});return ht==null?void 0:ht(`${w}?${Me}`,void 0,{shallow:!0})}}},[h,lt,Ge,$e,dt]);let Be=Ft({resource:tt,hasPagination:r,pagination:{current:lt,pageSize:Ge,mode:o==null?void 0:o.mode},filters:S?yt(he,dt):void 0,sorters:F?qt(Oe,$e):void 0,queryOptions:C,successNotification:P,errorNotification:x,meta:Wt,metaData:Wt,liveMode:R,liveParams:E,onLiveEvent:g,dataProviderName:i}),xe=fe=>{vt(Me=>yt(he,fe,Me))},Ze=fe=>{vt(yt(he,fe))},rt=fe=>{vt(Me=>yt(he,fe(Me)))},ot=(fe,Me=$t)=>{typeof fe=="function"?rt(fe):Me==="replace"?Ze(fe):xe(fe)},Lt=fe=>{Kt(()=>qt(Oe,fe))},{elapsedTime:Qs}=j({isLoading:Be.isFetching,interval:f==null?void 0:f.interval,onInterval:f==null?void 0:f.onInterval});return{tableQueryResult:Be,sorters:$e,setSorters:Lt,sorter:$e,setSorter:Lt,filters:dt,setFilters:ot,current:lt,setCurrent:Dt,pageSize:Ge,setPageSize:de,pageCount:Ge?Math.ceil((((so=Be.data)==null?void 0:so.total)??0)/Ge):1,createLinkForSyncWithLocation:Ve,overtime:{elapsedTime:Qs}}}import{useContext as Ts}from"react";import{useMutation as Rs,useQueryClient as Ga}from"@tanstack/react-query";import ys from"react";var at=ys.createContext({}),gs=({create:e,get:t,update:r,children:o})=>ys.createElement(at.Provider,{value:{create:e,get:t,update:r}},o);var we=({logMutationOptions:e,renameMutationOptions:t}={})=>{let r=Ga(),o=Ts(at),s=W(),{resources:a}=Ts(Je),{data:n,refetch:u,isLoading:p}=Tr({v3LegacyAuthProviderCompatible:!!(s!=null&&s.isLegacy),queryOptions:{enabled:!!o}}),d=Rs(async c=>{var C,v,g,E,A;let m=pe(c.resource,a),P=M((C=m==null?void 0:m.meta)==null?void 0:C.audit,(v=m==null?void 0:m.options)==null?void 0:v.audit,(E=(g=m==null?void 0:m.options)==null?void 0:g.auditLog)==null?void 0:E.permissions);if(P&&!Ur(P,c.action))return;let x;return p&&(x=await u()),await((A=o.create)==null?void 0:A.call(o,{...c,author:n??(x==null?void 0:x.data)}))},e),l=Rs(async c=>{var m;return await((m=o.update)==null?void 0:m.call(o,c))},{onSuccess:c=>{if(c!=null&&c.resource){let m=ee(c==null?void 0:c.resource);r.invalidateQueries(m.logList())}},...t});return{log:d,rename:l}};import{useContext as Wa}from"react";import{useQuery as Ka}from"@tanstack/react-query";var dP=({resource:e,action:t,meta:r,author:o,metaData:s,queryOptions:a})=>{let{get:n}=Wa(at),u=ee(e,void 0,s);return Ka(u.logList(r),()=>(n==null?void 0:n({resource:e,action:t,author:o,meta:r,metaData:s}))??Promise.resolve([]),{enabled:typeof n<"u",...a,retry:!1})};import{useCallback as za}from"react";import{useQueryClient as _a}from"@tanstack/react-query";var Se=()=>{let{resources:e}=V(),t=_a();return za(({resource:o,dataProviderName:s,invalidates:a,id:n})=>{if(a===!1)return;let u=ee(o,H(o,s,e));a.forEach(p=>{switch(p){case"all":t.invalidateQueries(u.all);break;case"list":t.invalidateQueries(u.list());break;case"many":t.invalidateQueries(u.many());break;case"resourceAll":t.invalidateQueries(u.resourceAll);break;case"detail":t.invalidateQueries(u.detail(n||""));break;default:break}})},[])};import{useContext as ja}from"react";import Za from"warn-once";var SP=({meta:e={}}={})=>{let t=_(),{i18nProvider:r}=ja(Ae),o=le(),s=B(),{resources:a,resource:n,action:u}=V(),{options:{textTransformers:p}}=ae(),d=[];if(!(n!=null&&n.name))return{breadcrumbs:d};let l=c=>{var P,x,C,v,g,E;let m=typeof c=="string"?pe(c,a,t==="legacy")??{name:c}:c;if(m){let A=M((P=m==null?void 0:m.meta)==null?void 0:P.parent,m==null?void 0:m.parentName);A&&l(A);let b=ye(m,a,t==="legacy").find(T=>T.action==="list"),i=(x=b==null?void 0:b.resource)!=null&&x.list?b==null?void 0:b.route:void 0,f=i?t==="legacy"?i:Re(i,m==null?void 0:m.meta,o,e):void 0;d.push({label:M((C=m.meta)==null?void 0:C.label,(v=m.options)==null?void 0:v.label)??s(`${m.name}.${m.name}`,p.humanize(m.name)),href:f,icon:M((g=m.meta)==null?void 0:g.icon,(E=m.options)==null?void 0:E.icon,m.icon)})}};if(l(n),u&&u!=="list"){let c=`actions.${u}`,m=s(c);typeof r<"u"&&m===c?(Za(!0,`[useBreadcrumb]: Breadcrumb missing translate key for the "${u}" action. Please add "actions.${u}" key to your translation file.
|
|
11
|
+
For more information, see https://refine.dev/docs/api-reference/core/hooks/useBreadcrumb/#i18n-support`),d.push({label:s(`buttons.${u}`,p.humanize(u))})):d.push({label:s(c,p.humanize(u))})}return{breadcrumbs:d}};import Zr from"react";var Pt=(e,t,r=!1)=>{let o=[],s=Ee(e,t);for(;s;)o.push(s),s=Ee(s,t);return o.reverse(),`/${[...o,e].map(n=>Te((r?n.route:void 0)??n.identifier??n.name)).join("/").replace(/^\//,"")}`};var Ps=(e,t=!1)=>{let r={item:{name:"__root__"},children:{}};e.forEach(s=>{let a=[],n=Ee(s,e);for(;n;)a.push(n),n=Ee(n,e);a.reverse();let u=r;a.forEach(d=>{let l=(t?d.route:void 0)??d.identifier??d.name;u.children[l]||(u.children[l]={item:d,children:{}}),u=u.children[l]});let p=(t?s.route:void 0)??s.identifier??s.name;u.children[p]||(u.children[p]={item:s,children:{}})});let o=s=>{let a=[];return Object.keys(s.children).forEach(n=>{let u=Pt(s.children[n].item,e,t),p={...s.children[n].item,key:u,children:o(s.children[n])};a.push(p)}),a};return o(r)};var xs=e=>e.split("?")[0].split("#")[0].replace(/(.+)(\/$)/,"$1"),Ya=({meta:e,hideOnMissingParameter:t}={hideOnMissingParameter:!0})=>{let r=B(),o=Nt(),s=_(),{resource:a,resources:n}=V(),{pathname:u}=le(),{useLocation:p}=re(),{pathname:d}=p(),l=gt(),m=`/${((s==="legacy"?xs(d):u?xs(u):void 0)??"").replace(/^\//,"")}`,P=a?Pt(a,n,s==="legacy"):m??"",x=Zr.useMemo(()=>{if(!a)return[];let g=Ee(a,n),E=[Pt(a,n)];for(;g;)E.push(Pt(g,n)),g=Ee(g,n);return E},[]),C=Zr.useCallback(g=>{var A,b,i,f,T,h;if((((A=g==null?void 0:g.meta)==null?void 0:A.hide)??((b=g==null?void 0:g.options)==null?void 0:b.hide))||!(g!=null&&g.list)&&g.children.length===0)return;let E=g.list?o({resource:g,action:"list",legacy:s==="legacy",meta:e}):void 0;if(!(t&&E&&E.match(/(\/|^):(.+?)(\/|$){1}/)))return{...g,route:E,icon:M((i=g.meta)==null?void 0:i.icon,(f=g.options)==null?void 0:f.icon,g.icon),label:M((T=g==null?void 0:g.meta)==null?void 0:T.label,(h=g==null?void 0:g.options)==null?void 0:h.label)??r(`${g.name}.${g.name}`,l(g.name,"plural"))}},[s,e,r,t]),v=Zr.useMemo(()=>{let g=Ps(n,s==="legacy"),E=A=>A.flatMap(b=>{let i=E(b.children),f=C({...b,children:i});return f?[f]:[]});return E(g)},[n,s,C]);return{defaultOpenKeys:x,selectedKey:P,menuItems:v}};var K=()=>{let{params:e}=le();return({resource:r,meta:o}={})=>{let{meta:s}=Rt(r)??{meta:{}},{filters:a,sorters:n,current:u,pageSize:p,...d}=e??{};return{...s,...d,...o}}};var qa=()=>{let[e,t]=Xa(),r=B(),{push:o}=ue(),s=ce(),a=_(),{resource:n,action:u}=V();return Ja(()=>{n&&u&&t(r("pages.error.info",{action:u,resource:n.name},`You may have forgotten to add the "${u}" component to "${n.name}" resource.`))},[n,u]),Ot.createElement(Ot.Fragment,null,Ot.createElement("h1",null,r("pages.error.404",void 0,"Sorry, the page you visited does not exist.")),e&&Ot.createElement("p",null,e),Ot.createElement("button",{onClick:()=>{a==="legacy"?o("/"):s({to:"/"})}},r("pages.error.backHome",void 0,"Back Home")))};import Pe,{useState as Cs}from"react";var Fr=()=>{let[e,t]=Cs(""),[r,o]=Cs(""),s=B(),a=W(),{mutate:n}=Ut({v3LegacyAuthProviderCompatible:!!(a!=null&&a.isLegacy)});return Pe.createElement(Pe.Fragment,null,Pe.createElement("h1",null,s("pages.login.title","Sign in your account")),Pe.createElement("form",{onSubmit:u=>{u.preventDefault(),n({username:e,password:r})}},Pe.createElement("table",null,Pe.createElement("tbody",null,Pe.createElement("tr",null,Pe.createElement("td",null,s("pages.login.username",void 0,"username"),":"),Pe.createElement("td",null,Pe.createElement("input",{type:"text",size:20,autoCorrect:"off",spellCheck:!1,autoCapitalize:"off",autoFocus:!0,required:!0,value:e,onChange:u=>t(u.target.value)}))),Pe.createElement("tr",null,Pe.createElement("td",null,s("pages.login.password",void 0,"password"),":"),Pe.createElement("td",null,Pe.createElement("input",{type:"password",required:!0,size:20,value:r,onChange:u=>o(u.target.value)}))))),Pe.createElement("br",null),Pe.createElement("input",{type:"submit",value:"login"})))};import xt from"react";import me,{useState as Yr}from"react";var bs=({providers:e,registerLink:t,forgotPasswordLink:r,rememberMe:o,contentProps:s,wrapperProps:a,renderContent:n,formProps:u,title:p=void 0})=>{let d=_(),l=nt(),{Link:c}=re(),m=d==="legacy"?c:l,[P,x]=Yr(""),[C,v]=Yr(""),[g,E]=Yr(!1),A=B(),b=W(),{mutate:i}=Ut({v3LegacyAuthProviderCompatible:!!(b!=null&&b.isLegacy)}),f=(R,y)=>me.createElement(m,{to:R},y),T=()=>e?e.map(R=>me.createElement("div",{key:R.name,style:{display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"1rem"}},me.createElement("button",{onClick:()=>i({providerName:R.name}),style:{display:"flex",alignItems:"center"}},R==null?void 0:R.icon,R.label??me.createElement("label",null,R.label)))):null,h=me.createElement("div",{...s},me.createElement("h1",{style:{textAlign:"center"}},A("pages.login.title","Sign in to your account")),T(),me.createElement("hr",null),me.createElement("form",{onSubmit:R=>{R.preventDefault(),i({email:P,password:C,remember:g})},...u},me.createElement("div",{style:{display:"flex",flexDirection:"column",padding:25}},me.createElement("label",{htmlFor:"email-input"},A("pages.login.fields.email","Email")),me.createElement("input",{id:"email-input",name:"email",type:"text",size:20,autoCorrect:"off",spellCheck:!1,autoCapitalize:"off",required:!0,value:P,onChange:R=>x(R.target.value)}),me.createElement("label",{htmlFor:"password-input"},A("pages.login.fields.password","Password")),me.createElement("input",{id:"password-input",type:"password",name:"password",required:!0,size:20,value:C,onChange:R=>v(R.target.value)}),o??me.createElement(me.Fragment,null,me.createElement("label",{htmlFor:"remember-me-input"},A("pages.login.buttons.rememberMe","Remember me"),me.createElement("input",{id:"remember-me-input",name:"remember",type:"checkbox",size:20,checked:g,value:g.toString(),onChange:()=>{E(!g)}}))),me.createElement("br",null),r??f("/forgot-password",A("pages.login.buttons.forgotPassword","Forgot password?")),me.createElement("input",{type:"submit",value:A("pages.login.signin","Sign in")}),t??me.createElement("span",null,A("pages.login.buttons.noAccount","Don\u2019t have an account?")," ",f("/register",A("pages.login.register","Sign up"))))));return me.createElement("div",{...a},n?n(h,p):h)};import ge,{useState as hs}from"react";var vs=({providers:e,loginLink:t,wrapperProps:r,contentProps:o,renderContent:s,formProps:a,title:n=void 0})=>{let u=_(),p=nt(),{Link:d}=re(),l=u==="legacy"?d:p,[c,m]=hs(""),[P,x]=hs(""),C=B(),v=W(),{mutate:g,isLoading:E}=Cr({v3LegacyAuthProviderCompatible:!!(v!=null&&v.isLegacy)}),A=(f,T)=>ge.createElement(l,{to:f},T),b=()=>e?e.map(f=>ge.createElement("div",{key:f.name,style:{display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"1rem"}},ge.createElement("button",{onClick:()=>g({providerName:f.name}),style:{display:"flex",alignItems:"center"}},f==null?void 0:f.icon,f.label??ge.createElement("label",null,f.label)))):null,i=ge.createElement("div",{...o},ge.createElement("h1",{style:{textAlign:"center"}},C("pages.register.title","Sign up for your account")),b(),ge.createElement("hr",null),ge.createElement("form",{onSubmit:f=>{f.preventDefault(),g({email:c,password:P})},...a},ge.createElement("div",{style:{display:"flex",flexDirection:"column",padding:25}},ge.createElement("label",{htmlFor:"email-input"},C("pages.register.fields.email","Email")),ge.createElement("input",{id:"email-input",name:"email",type:"email",size:20,autoCorrect:"off",spellCheck:!1,autoCapitalize:"off",required:!0,value:c,onChange:f=>m(f.target.value)}),ge.createElement("label",{htmlFor:"password-input"},C("pages.register.fields.password","Password")),ge.createElement("input",{id:"password-input",name:"password",type:"password",required:!0,size:20,value:P,onChange:f=>x(f.target.value)}),ge.createElement("input",{type:"submit",value:C("pages.register.buttons.submit","Sign up"),disabled:E}),t??ge.createElement(ge.Fragment,null,ge.createElement("span",null,C("pages.login.buttons.haveAccount","Have an account?")," ",A("/login",C("pages.login.signin","Sign in")))))));return ge.createElement("div",{...r},s?s(i,n):i)};import Fe,{useState as ei}from"react";var Ds=({loginLink:e,wrapperProps:t,contentProps:r,renderContent:o,formProps:s,title:a=void 0})=>{let n=B(),u=_(),p=nt(),{Link:d}=re(),l=u==="legacy"?d:p,[c,m]=ei(""),{mutate:P,isLoading:x}=hr(),C=(g,E)=>Fe.createElement(l,{to:g},E),v=Fe.createElement("div",{...r},Fe.createElement("h1",{style:{textAlign:"center"}},n("pages.forgotPassword.title","Forgot your password?")),Fe.createElement("hr",null),Fe.createElement("form",{onSubmit:g=>{g.preventDefault(),P({email:c})},...s},Fe.createElement("div",{style:{display:"flex",flexDirection:"column",padding:25}},Fe.createElement("label",{htmlFor:"email-input"},n("pages.forgotPassword.fields.email","Email")),Fe.createElement("input",{id:"email-input",name:"email",type:"mail",autoCorrect:"off",spellCheck:!1,autoCapitalize:"off",required:!0,value:c,onChange:g=>m(g.target.value)}),Fe.createElement("input",{type:"submit",disabled:x,value:n("pages.forgotPassword.buttons.submit","Send reset instructions")}),Fe.createElement("br",null),e??Fe.createElement("span",null,n("pages.register.buttons.haveAccount","Have an account? ")," ",C("/login",n("pages.login.signin","Sign in"))))));return Fe.createElement("div",{...t},o?o(v,a):v)};import ke,{useState as Ls}from"react";var Es=({wrapperProps:e,contentProps:t,renderContent:r,formProps:o,title:s=void 0})=>{let a=B(),n=W(),{mutate:u,isLoading:p}=Dr({v3LegacyAuthProviderCompatible:!!(n!=null&&n.isLegacy)}),[d,l]=Ls(""),[c,m]=Ls(""),P=ke.createElement("div",{...t},ke.createElement("h1",{style:{textAlign:"center"}},a("pages.updatePassword.title","Update Password")),ke.createElement("hr",null),ke.createElement("form",{onSubmit:x=>{x.preventDefault(),u({password:d,confirmPassword:c})},...o},ke.createElement("div",{style:{display:"flex",flexDirection:"column",padding:25}},ke.createElement("label",{htmlFor:"password-input"},a("pages.updatePassword.fields.password","New Password")),ke.createElement("input",{id:"password-input",name:"password",type:"password",required:!0,size:20,value:d,onChange:x=>l(x.target.value)}),ke.createElement("label",{htmlFor:"confirm-password-input"},a("pages.updatePassword.fields.confirmPassword","Confirm New Password")),ke.createElement("input",{id:"confirm-password-input",name:"confirmPassword",type:"password",required:!0,size:20,value:c,onChange:x=>m(x.target.value)}),ke.createElement("input",{type:"submit",disabled:p,value:a("pages.updatePassword.buttons.submit","Update")}))));return ke.createElement("div",{...e},r?r(P,s):P)};var ti=e=>{let{type:t}=e;return xt.createElement(xt.Fragment,null,(()=>{switch(t){case"register":return xt.createElement(vs,{...e});case"forgotPassword":return xt.createElement(Ds,{...e});case"updatePassword":return xt.createElement(Es,{...e});default:return xt.createElement(bs,{...e})}})())};import Le from"react";var Jr=()=>Le.createElement(Le.Fragment,null,Le.createElement("h1",null,"Welcome on board"),Le.createElement("p",null,"Your configuration is completed."),Le.createElement("p",null,"Now you can get started by adding your resources to the"," ",Le.createElement("code",null,"`resources`")," property of ",Le.createElement("code",null,"`<Refine>`")),Le.createElement("div",{style:{display:"flex",gap:8}},Le.createElement("a",{href:"https://refine.dev",target:"_blank",rel:"noreferrer"},Le.createElement("button",null,"Documentation")),Le.createElement("a",{href:"https://refine.dev/examples",target:"_blank",rel:"noreferrer"},Le.createElement("button",null,"Examples")),Le.createElement("a",{href:"https://discord.gg/refine",target:"_blank",rel:"noreferrer"},Le.createElement("button",null,"Community"))));import J,{useState as ri}from"react";var oi=[{title:"Documentation",description:"Learn about the technical details of using refine in your projects.",link:"https://refine.dev/",icon:J.createElement("svg",{width:"14",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J.createElement("path",{d:"M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V5a1 1 0 0 0-1-1H3a1 1 0 0 1 0-2h10a1 1 0 1 0 0-2H2Z",fill:"#fff"}))},{title:"Tutorial",description:"Learn how to use refine by building a fully-functioning CRUD app, from scratch to full launch.",link:"https://refine.dev/docs/tutorial/introduction/index/",icon:J.createElement("svg",{width:"16",height:"14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J.createElement("path",{d:"M0 4.573c0-.475.163-.948.53-1.25a4.57 4.57 0 0 1 .854-.553L5.956.485a4.571 4.571 0 0 1 4.088 0l4.572 2.285c.308.154.594.34.853.553.306.251.47.62.517 1.01.01.055.014.112.014.169v6.5a1 1 0 0 1-2 0V6.684l-3.956 1.978a4.571 4.571 0 0 1-4.088 0L1.384 6.376a4.57 4.57 0 0 1-.853-.553C.163 5.522 0 5.05 0 4.573Z",fill:"#fff"}),J.createElement("path",{d:"M5.061 13.305 3 12.274V9.42l2.061 1.031a6.571 6.571 0 0 0 5.878 0L13 9.421v2.853l-2.061 1.03a6.571 6.571 0 0 1-5.878 0Z",fill:"#fff"}))},{title:"Examples",description:"A collection of reference applications you can use as a starting point.",link:"https://refine.dev/examples",icon:J.createElement("svg",{width:"16",height:"16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 2a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4H0V2Zm3 2a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm4-1a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm2 1a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",fill:"#fff"}),J.createElement("path",{d:"M0 14V8h16v6a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2Z",fill:"#fff"}))},{title:"Community",description:"Join our Discord community and keep up with the latest news.",link:"https://discord.gg/refine",icon:J.createElement("svg",{width:"16",height:"12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},J.createElement("path",{d:"M13.553 1.005A13.334 13.334 0 0 0 10.253 0c-.156.276-.298.56-.423.85a12.42 12.42 0 0 0-3.664 0A8.975 8.975 0 0 0 5.744 0 13.43 13.43 0 0 0 2.44 1.007C.351 4.066-.215 7.05.068 9.99A13.36 13.36 0 0 0 4.116 12c.328-.436.618-.9.867-1.384a8.647 8.647 0 0 1-1.365-.645c.115-.082.227-.167.335-.249a9.594 9.594 0 0 0 8.094 0c.11.089.222.173.335.25-.436.254-.894.47-1.368.646.249.484.539.946.867 1.382a13.3 13.3 0 0 0 4.051-2.01c.332-3.41-.568-6.365-2.379-8.985Zm-8.21 7.176c-.79 0-1.442-.709-1.442-1.58 0-.872.63-1.587 1.439-1.587s1.456.715 1.442 1.586c-.014.872-.636 1.58-1.44 1.58Zm5.315 0c-.79 0-1.44-.709-1.44-1.58 0-.872.63-1.587 1.44-1.587.81 0 1.452.715 1.438 1.586-.014.872-.634 1.58-1.438 1.58Z",fill:"#fff"}))}],si=()=>{let e=ur("(max-width: 1010px)"),t=ur("(max-width: 650px)"),r=()=>t?"1, 280px":e?"2, 280px":"4, 208px",o=()=>t?"32px":e?"40px":"48px",s=()=>t?"16px":e?"20px":"24px";return J.createElement("div",{style:{backgroundImage:"url(https://refine.ams3.cdn.digitaloceanspaces.com/welcome-page/welcome-page.webp)",backgroundPosition:"center top",backgroundSize:"cover",backgroundRepeat:"no-repeat",minHeight:"100vh",backgroundColor:"#0D0D12",fontFamily:"Arial",color:"#FFFFFF"}},J.createElement("div",{style:{height:"89px"}}),J.createElement("div",{style:{display:"flex",justifyContent:"center"}},J.createElement("img",{src:"https://refine.ams3.cdn.digitaloceanspaces.com/welcome-page/welcome-logo.webp",width:"198",height:"54"})),J.createElement("div",{style:{height:e?"270px":"22vw",minHeight:e?"270px":"313px"}}),J.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"16px",textAlign:"center"}},J.createElement("h1",{style:{fontSize:o(),fontWeight:700,margin:"0px"}},"Welcome Aboard!"),J.createElement("h4",{style:{fontSize:s(),fontWeight:400,margin:"0px"}},"Your configuration is completed.")),J.createElement("div",{style:{height:"64px"}}),J.createElement("div",{style:{display:"grid",gridTemplateColumns:`repeat(${r()})`,justifyContent:"center",gap:"48px",paddingRight:"16px",paddingLeft:"16px",maxWidth:"976px",margin:"auto"}},oi.map(a=>J.createElement(ni,{key:`welcome-page-${a.title}`,card:a}))),J.createElement("div",{style:{height:"64px"}}))},ni=({card:e})=>{let{title:t,description:r,icon:o,link:s}=e,[a,n]=ri(!1);return J.createElement("div",{style:{display:"flex",flexDirection:"column",gap:"16px"}},J.createElement("div",{style:{display:"flex",alignItems:"center"}},J.createElement("a",{onPointerEnter:()=>n(!0),onPointerLeave:()=>n(!1),style:{display:"flex",alignItems:"center",color:"#fff",textDecoration:"none"},href:s},o,J.createElement("span",{style:{fontSize:"16px",fontWeight:700,marginLeft:"13px",marginRight:"14px"}},t),J.createElement("svg",{style:{transition:"transform 0.5s ease-in-out, opacity 0.2s ease-in-out",...a&&{transform:"translateX(4px)",opacity:1}},width:"12",height:"8",fill:"none",opacity:"0.5",xmlns:"http://www.w3.org/2000/svg"},J.createElement("path",{d:"M7.293.293a1 1 0 0 1 1.414 0l3 3a1 1 0 0 1 0 1.414l-3 3a1 1 0 0 1-1.414-1.414L8.586 5H1a1 1 0 0 1 0-2h7.586L7.293 1.707a1 1 0 0 1 0-1.414Z",fill:"#fff"})))),J.createElement("span",{style:{fontSize:"12px",opacity:.5,lineHeight:"16px"}},r))};import{QueryClient as As,QueryClientProvider as ci}from"@tanstack/react-query";import{ReactQueryDevtools as pi}from"@tanstack/react-query-devtools";import ne from"react";import{useEffect as ii}from"react";import{useContext as it}from"react";var ai="4.27.0",Us=()=>{let e=Lr(),t=it(at),r=it(Ke),o=it(Ht),s=it(Vt),{i18nProvider:a}=it(Ae),n=it(Bt),u=it(Xe),{resources:p}=V(),d=!!t.create||!!t.get||!!t.update,l=!!(r!=null&&r.publish)||!!(r!=null&&r.subscribe)||!!(r!=null&&r.unsubscribe),c=!!o.useHistory||!!o.Link||!!o.Prompt||!!o.useLocation||!!o.useParams,m=!!s,P=!!(a!=null&&a.changeLocale)||!!(a!=null&&a.getLocale)||!!(a!=null&&a.translate),x=!!n.close||!!n.open,C=!!u.can;return{providers:{auth:e,auditLog:d,live:l,router:c,data:m,i18n:P,notification:x,accessControl:C},version:ai,resourceCount:p.length}};var ui=e=>{let t=JSON.stringify(e||{});return typeof btoa<"u"?btoa(t):Buffer.from(t).toString("base64")},Ms=()=>{let e=Us();return ii(()=>{if(typeof window>"u"&&!Image)return;let t=new Image;t.src=`https://telemetry.refine.dev/telemetry?payload=${ui(e)}`},[]),null};import di from"warn-once";var Is=e=>{let t=["go","parse","back","Link"],r=Object.keys(e).filter(s=>!t.includes(s));return r.length>0?(console.warn(`Unsupported properties are found in \`routerProvider\` prop. You provided \`${r.join(", ")}\`. Supported properties are \`${t.join(", ")}\`. You may wanted to use \`legacyRouterProvider\` prop instead.`),!0):!1};import ws from"react";var Ss=e=>{let t=ws.useRef(!1);ws.useEffect(()=>{t.current===!1&&e&&Is(e)&&(t.current=!0)},[e])};var li=({legacyAuthProvider:e,authProvider:t,dataProvider:r,legacyRouterProvider:o,routerProvider:s,notificationProvider:a,accessControlProvider:n,auditLogProvider:u,resources:p,DashboardPage:d,ReadyPage:l,LoginPage:c,catchAll:m,children:P,liveProvider:x,i18nProvider:C,Title:v,Layout:g,Sider:E,Header:A,Footer:b,OffLayoutArea:i,onLiveEvent:f,options:T})=>{var U;let{optionsWithDefaults:h,disableTelemetryWithDefault:R,reactQueryWithDefaults:y}=Qr({options:T}),D=lr(()=>{var S;return y.clientConfig instanceof As?y.clientConfig:new As({...y.clientConfig,defaultOptions:{...y.clientConfig.defaultOptions,queries:{refetchOnWindowFocus:!1,keepPreviousData:!0,...(S=y.clientConfig.defaultOptions)==null?void 0:S.queries}}})},[y.clientConfig]),w=ne.useMemo(()=>typeof a=="function"?a:()=>a??{},[a])();if(Ss(s),o&&!s&&(p??[]).length===0)return l?ne.createElement(l,null):ne.createElement(Jr,null);let{RouterComponent:I=ne.Fragment}=s?{}:o??{};return typeof window<"u"&&((U=window==null?void 0:window.location)==null?void 0:U.hostname)==="localhost"&&di(!0,`%c
|
|
12
12
|
\u2705 Zero-trust security model
|
|
13
13
|
\u2705 User/role management
|
|
14
14
|
\u2705 Granular access control
|
|
@@ -16,7 +16,7 @@ For more information, see https://refine.dev/docs/api-reference/core/hooks/useBr
|
|
|
16
16
|
\u2705 VPN-less secure deployments
|
|
17
17
|
\u2705 Direct connection to DBs
|
|
18
18
|
|
|
19
|
-
Interested in any of the new backend features of refine? Join now and get early access -> https://s.refine.dev/go-enterprise`,"color: green; background: yellow; font-size: 17px"),ne.createElement(
|
|
19
|
+
Interested in any of the new backend features of refine? Join now and get early access -> https://s.refine.dev/go-enterprise`,"color: green; background: yellow; font-size: 17px"),ne.createElement(ci,{client:D},ne.createElement(qo,{...w},ne.createElement(ao,{...e??{},isProvided:!!e},ne.createElement(uo,{...t??{},isProvided:!!t},ne.createElement(No,{...r},ne.createElement(Oo,{liveProvider:x},ne.createElement(_o,{value:o&&!s?"legacy":"new"},ne.createElement(Zo,{router:s},ne.createElement(ns,{...o},ne.createElement(Wo,{resources:p??[]},ne.createElement(ts,{i18nProvider:C},ne.createElement(is,{...n??{}},ne.createElement(gs,{...u??{}},ne.createElement($r,null,ne.createElement(Mo,{mutationMode:h.mutationMode,warnWhenUnsavedChanges:h.warnWhenUnsavedChanges,syncWithLocation:h.syncWithLocation,Title:v,undoableTimeout:h.undoableTimeout,catchAll:m,DashboardPage:d,LoginPage:c,Layout:g,Sider:E,Footer:b,Header:A,OffLayoutArea:i,hasDashboard:!!d,liveMode:h.liveMode,onLiveEvent:f,options:h},ne.createElement(Fo,null,ne.createElement(I,null,P,!R&&ne.createElement(Ms,null),ne.createElement(Xr,null))))))))))))))))),y.devtoolConfig===!1?null:ne.createElement(pi,{initialIsOpen:!1,position:"bottom-right",...y.devtoolConfig}))};import{useEffect as mi,useState as fi}from"react";var Vo=({notification:e})=>{let t=B(),{notificationDispatch:r}=He(),{open:o}=De(),[s,a]=fi(),n=()=>{if(e.isRunning===!0&&(e.seconds===0&&e.doMutation(),e.isSilent||o==null||o({key:`${e.id}-${e.resource}-notification`,type:"progress",message:t("notifications.undoable",{seconds:Mt(e.seconds)},`You have ${Mt(e.seconds)} seconds to undo`),cancelMutation:e.cancelMutation,undoableTimeout:Mt(e.seconds)}),e.seconds>0)){s&&clearTimeout(s);let u=setTimeout(()=>{r({type:"DECREASE_NOTIFICATION_SECOND",payload:{id:e.id,seconds:e.seconds,resource:e.resource}})},1e3);a(u)}};return mi(()=>{n()},[e]),null};import qr,{useEffect as yi}from"react";var gi=({children:e,Layout:t,Sider:r,Header:o,Title:s,Footer:a,OffLayoutArea:n})=>{let{Layout:u,Footer:p,Header:d,Sider:l,Title:c,OffLayoutArea:m}=ae();return qr.createElement(t??u,{Sider:r??l,Header:o??d,Footer:a??p,Title:s??c,OffLayoutArea:n??m},e,qr.createElement(Ti,null))},Ti=()=>{let{Prompt:e}=re(),t=B(),{warnWhen:r,setWarnWhen:o}=At(),s=a=>(a.preventDefault(),a.returnValue=t("warnWhenUnsavedChanges","Are you sure you want to leave? You have unsaved changes."),a.returnValue);return yi(()=>(r&&window.addEventListener("beforeunload",s),window.removeEventListener("beforeunload",s)),[r]),qr.createElement(e,{when:r,message:t("warnWhenUnsavedChanges","Are you sure you want to leave? You have unsaved changes."),setWarnWhen:o})};import Ue from"react";var Ri=()=>{let e=ce(),[t,r]=Ue.useState(void 0);return Ue.useEffect(()=>{t&&e(t)},[t]),Ue.useCallback(s=>{t||r(s)},[t])};function Pi({redirectOnFail:e=!0,appendCurrentPathToQuery:t=!0,children:r,fallback:o,loading:s}){var h;let a=W(),n=_(),u=!!(a!=null&&a.isProvided),p=!!(a!=null&&a.isLegacy),d=n==="legacy",l=le(),c=ce(),m=Ri(),{replace:P}=ue(),{useLocation:x}=re(),C=x(),{isLoading:v,isFetching:g,isSuccess:E,data:{authenticated:A,redirectTo:b}={},refetch:i}=Zt({v3LegacyAuthProviderCompatible:p});Ue.useEffect(()=>{i()},[r,o]);let f=Ue.useRef({status:v?"initial":"pending",content:s??null});g?f.current.status="pending":g||(f.current.status="settled");let T=u?p?E:A:!0;if(f.current.status==="settled")if(T)f.current.content=Ue.createElement(Ue.Fragment,null,r??null);else if(typeof o<"u")f.current.content=Ue.createElement(Ue.Fragment,null,o);else{let R=`${d?C==null?void 0:C.pathname:l.pathname}`.replace(/(\?.*|#.*)$/,""),y=p?typeof e=="string"?e:"/login":typeof e=="string"?e:b;if(y)if(d){let D=t?`?to=${encodeURIComponent(R)}`:"";P(`${y}${D}`)}else m({to:y,query:t?{to:(h=l.params)!=null&&h.to?l.params.to:c({to:R,options:{keepQuery:!0},type:"path"})}:void 0,type:"replace"})}return u?Ue.createElement(Ue.Fragment,null,f.current.content):Ue.createElement(Ue.Fragment,null,r??null)}import{useEffect as xi}from"react";var Xr=()=>{let{useLocation:e}=re(),{checkAuth:t}=te(),r=e();return xi(()=>{t==null||t().catch(()=>!1)},[r==null?void 0:r.pathname]),null};import Ct from"react";var Ci=({resource:e,action:t,params:r,fallback:o,children:s,...a})=>{let{resource:n,id:u,action:p}=V(e),{identifier:d}=V(),c=(()=>{let P=(r==null?void 0:r.id)??u;return e&&e!==d?r==null?void 0:r.id:P})(),{data:m}=us({resource:e??(n==null?void 0:n.name),action:t??p??"",params:r??{id:c,resource:n}});return m!=null&&m.can?Ct.isValidElement(s)?Ct.cloneElement(s,a):Ct.createElement(Ct.Fragment,null,s):(m==null?void 0:m.can)===!1?Ct.createElement(Ct.Fragment,null,o??null):null};import bt,{useEffect as bi}from"react";var Fs=[`
|
|
20
20
|
.banner {
|
|
21
21
|
display: flex;
|
|
22
22
|
@media (max-width: 1000px) {
|
|
@@ -74,5 +74,5 @@ Interested in any of the new backend features of refine? Join now and get early
|
|
|
74
74
|
text-decoration: none;
|
|
75
75
|
z-index: 9;
|
|
76
76
|
}
|
|
77
|
-
`];var hi=()=>(
|
|
77
|
+
`];var hi=()=>(bi(()=>{let e=document.createElement("style");document.head.appendChild(e),Fs.forEach(t=>{var r;return(r=e.sheet)==null?void 0:r.insertRule(t,e.sheet.cssRules.length)})},[]),bt.createElement("div",{className:"banner",style:{flexDirection:"row",justifyContent:"center",alignItems:"center",position:"relative",padding:"8px 16px",backgroundColor:"#0d0d0d",borderBottom:"1px solid rgba(255, 255, 255, 0.15)"}},bt.createElement("div",{style:{width:"200px"}}),bt.createElement("a",{className:"gh-link",href:"https://s.refine.dev/github-support",target:"_blank",rel:"noreferrer"},bt.createElement("div",{className:"content",style:{position:"relative",zIndex:2,color:"#fff",display:"flex",flexDirection:"row",gap:"8px"}},bt.createElement("span",{className:"wizard",style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",width:"32px",height:"32px",fontSize:"32px",lineHeight:"32px"}},"\u{1F9D9}\u200D\u2642\uFE0F"),bt.createElement("span",{className:"text",style:{padding:"4px 0",fontSize:"16px",lineHeight:"24px",textShadow:"0px 0px 4px rgba(255, 255, 255, 0.5)"}},"refine grants your wishes! Please give us a \u2B50\uFE0F on GitHub to keep the magic going.")))));export{Xe as AccessControlContext,ti as AuthPage,Pi as Authenticated,Ci as CanAccess,qa as ErrorComponent,hi as GitHubBanner,gi as LayoutWrapper,Fr as LoginPage,Jr as ReadyPage,li as Refine,Je as ResourceContext,Xr as RouteChangeHandler,Ae as TranslationContext,Vo as UndoableQueue,si as WelcomePage,Lo as createTreeView,Js as file2Base64,So as generateDefaultDocumentTitle,Ys as getDefaultFilter,Zs as getDefaultSortOrder,nr as getNextPageParam,ar as getPreviousPageParam,vo as handleUseParams,Yt as importCSVMapper,ir as legacyResourceTransform,Sr as matchResourceFromRoute,Jt as parseTableParams,js as parseTableParamsFromQuery,M as pickNotDeprecated,or as routeGenerator,er as setInitialFilters,tr as setInitialSorters,Xt as stringifyTableParams,yt as unionFilters,qt as unionSorters,W as useActiveAuthProvider,Un as useApiUrl,Gs as useAuthenticated,zr as useBack,SP as useBreadcrumb,us as useCan,yR as useCanWithoutCache,He as useCancelNotification,Ws as useCheckError,kt as useCreate,Gr as useCreateMany,In as useCustom,Sn as useCustomMutation,Y as useDataProvider,xn as useDelete,En as useDeleteMany,bg as useExport,hr as useForgotPassword,kg as useForm,Tr as useGetIdentity,ma as useGetLocale,Nt as useGetToPath,ce as useGo,se as useHandleNotification,bT as useImport,Vn as useInfiniteList,Se as useInvalidate,Zt as useIsAuthenticated,Lr as useIsExistAuthentication,nt as useLink,Ft as useList,Xo as useLiveMode,j as useLoadingOvertime,we as useLog,dP as useLogList,Ut as useLogin,jt as useLogout,Nr as useMany,Ya as useMenu,K as useMeta,DT as useModal,Qe as useMutationMode,ue as useNavigation,De as useNotification,oe as useOnError,Qt as useOne,Wr as useParse,le as useParsed,Vs as usePermissions,Ie as usePublish,rs as useRedirectionAfterSubmission,ae as useRefineContext,Cr as useRegister,V as useResource,Ye as useResourceSubscription,Yo as useResourceWithRoute,re as useRouterContext,_ as useRouterType,IR as useSelect,ua as useSetLocale,lT as useShow,wy as useSubscription,Br as useSyncWithLocation,WR as useTable,nn as useTitle,wa as useToPath,B as useTranslate,dr as useUpdate,vn as useUpdateMany,Dr as useUpdatePassword,gt as useUserFriendlyName,At as useWarnAboutChange,rr as userFriendlyResourceName};
|
|
78
78
|
//# sourceMappingURL=index.js.map
|