@espresso-lab/mantine-data-table 2.1.5 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +4 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +15 -15
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`react/jsx-runtime`),require(`@mantine/core`),require(`@mantine/form`),require(`@mantine/dates`),require(`@tabler/icons-react`),require(`@mantine/hooks`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`react/jsx-runtime`,`@mantine/core`,`@mantine/form`,`@mantine/dates`,`@tabler/icons-react`,`@mantine/hooks`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MantineDataTable={},e.React,e.react_jsx_runtime,e.MantineCore,e.MantineForm,e._mantine_dates,e.TablerIconsReact,e.MantineHooks))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=Object.create,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=d(t),a=0,o=i.length,s;a<o;a++)s=i[a],!p.call(e,s)&&s!==n&&l(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=u(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:c(f(e)),m(t||!e||!e.__esModule?l(n,`default`,{value:e,enumerable:!0}):n,e)))(t);var h=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},g=new class extends h{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},_={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},v=new class{#e=_;#t=!1;setTimeoutProvider(e){process.env.NODE_ENV!==`production`&&this.#t&&e!==this.#e&&console.error(`[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,{previous:this.#e,provider:e}),this.#e=e,process.env.NODE_ENV!==`production`&&(this.#t=!1)}setTimeout(e,t){return process.env.NODE_ENV!==`production`&&(this.#t=!0),this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!==`production`&&(this.#t=!0),this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function y(e){setTimeout(e,0)}var b=typeof window>`u`||`Deno`in globalThis;function x(){}function S(e){return typeof e==`number`&&e>=0&&e!==1/0}function C(e,t){return Math.max(e+(t||0)-Date.now(),0)}function w(e,t){return typeof e==`function`?e(t):e}function T(e,t){return typeof e==`function`?e(t):e}function E(e){return JSON.stringify(e,(e,t)=>j(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}var D=Object.prototype.hasOwnProperty;function O(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=A(e)&&A(t);if(!r&&!(j(e)&&j(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:D.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=O(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function k(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function A(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function j(e){if(!M(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!M(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function M(e){return Object.prototype.toString.call(e)===`[object Object]`}function ee(e,t,n){if(typeof n.structuralSharing==`function`)return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!==`production`)try{return O(e,t)}catch(e){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${e}`),e}return O(e,t)}return t}function N(e,t){return typeof e==`function`?e(...t):!!e}var P=(()=>{let e=()=>b;return{isServer(){return e()},setIsServer(t){e=t}}})();function F(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var te=y;function ne(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=te,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var re=ne(),ie=new class extends h{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function I(e){return(e??`online`)===`online`?ie.isOnline():!0}function ae(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:I(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}var oe=class extends h{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=F(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),ce(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return le(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return le(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof T(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!k(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&ue(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||T(this.options.enabled,this.#t)!==T(t.enabled,this.#t)||w(this.options.staleTime,this.#t)!==w(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||T(this.options.enabled,this.#t)!==T(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return de(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(x)),t}#g(){this.#b();let e=w(this.options.staleTime,this.#t);if(P.isServer()||this.#r.isStale||!S(e))return;let t=C(this.#r.dataUpdatedAt,e)+1;this.#d=v.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(P.isServer()||T(this.options.enabled,this.#t)===!1||!S(this.#p)||this.#p===0)&&(this.#f=v.setInterval(()=>{(this.options.refetchIntervalInBackground||g.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(v.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(v.clearInterval(this.#f),void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&ce(e,t),o=i&&ue(e,n,t,r);(a||o)&&(l={...l,...ae(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=ee(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=ee(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:L(e,t),refetch:this.refetch,promise:this.#o,isEnabled:T(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=F())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!k(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){re.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function se(e,t){return T(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function ce(e,t){return se(e,t)||e.state.data!==void 0&&le(e,t,t.refetchOnMount)}function le(e,t,n){if(T(t.enabled,e)!==!1&&w(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&L(e,t)}return!1}function ue(e,t,n,r){return(e!==t||T(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&L(e,n)}function L(e,t){return T(t.enabled,e)!==!1&&e.isStaleByTime(w(t.staleTime,e))}function de(e,t){return!k(e.getCurrentResult(),t)}function fe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var R=class extends h{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),k(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&E(t.mutationKey)!==E(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??fe();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){re.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},z=t.createContext(void 0),pe=e=>{let n=t.useContext(z);if(e)return e;if(!n)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return n},me=({client:e,children:r})=>(t.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,n.jsx)(z.Provider,{value:e,children:r})),he=t.createContext(!1),ge=()=>t.useContext(he);he.Provider;function B(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var V=t.createContext(B()),_e=()=>t.useContext(V),ve=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?N(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ye=e=>{t.useEffect(()=>{e.clearReset()},[e])},be=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||N(n,[e.error,r])),xe=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Se=(e,t)=>e.isLoading&&e.isFetching&&!t,Ce=(e,t)=>e?.suspense&&t.isPending,we=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function H(e,n,r){if(process.env.NODE_ENV!==`production`&&(typeof e!=`object`||Array.isArray(e)))throw Error(`Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object`);let i=ge(),a=_e(),o=pe(r),s=o.defaultQueryOptions(e);o.getDefaultOptions().queries?._experimental_beforeQuery?.(s);let c=o.getQueryCache().get(s.queryHash);process.env.NODE_ENV!==`production`&&(s.queryFn||console.error(`[${s.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),s._optimisticResults=i?`isRestoring`:`optimistic`,xe(s),ve(s,a,c),ye(a);let l=!o.getQueryCache().get(s.queryHash),[u]=t.useState(()=>new n(o,s)),d=u.getOptimisticResult(s),f=!i&&e.subscribed!==!1;if(t.useSyncExternalStore(t.useCallback(e=>{let t=f?u.subscribe(re.batchCalls(e)):x;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),t.useEffect(()=>{u.setOptions(s)},[s,u]),Ce(s,d))throw we(s,u,a);if(be({result:d,errorResetBoundary:a,throwOnError:s.throwOnError,query:c,suspense:s.suspense}))throw d.error;return o.getDefaultOptions().queries?._experimental_afterQuery?.(s,d),s.experimental_prefetchInRender&&!P.isServer()&&Se(d,i)&&(l?we(s,u,a):c?.promise)?.catch(x).finally(()=>{u.updateResult()}),s.notifyOnChangeProps?d:u.trackResult(d)}function Te(e,t){return H(e,oe,t)}function Ee(e,n){let r=pe(n),[i]=t.useState(()=>new R(r,e));t.useEffect(()=>{i.setOptions(e)},[i,e]);let a=t.useSyncExternalStore(t.useCallback(e=>i.subscribe(re.batchCalls(e)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),o=t.useCallback((e,t)=>{i.mutate(e,t).catch(x)},[i]);if(a.error&&N(i.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}var De=(0,t.createContext)(void 0),Oe=async()=>({"Content-Type":`application/json`});function ke({children:e,baseUrl:t,queryClient:r,getHeaders:i=Oe}){return(0,n.jsx)(De.Provider,{value:{baseUrl:t,queryClient:r,getHeaders:i},children:(0,n.jsx)(me,{client:r,children:e})})}function U(){let e=(0,t.useContext)(De);if(!e)throw Error(`useDataTable must be used within a DataTableProvider`);return e}function Ae(e){if(typeof e==`string`)try{let t=JSON.parse(e);return{message:t.message||e,code:t.code,details:t.details}}catch{return{message:e}}return e instanceof Error?{message:e.message}:{message:`Unbekannter Fehler`}}async function W(e,t){let n=await fetch(e,t);if(n.status>=400){let e=await n.text();if(!e)throw Error(`HTTP ${n.status}: ${n.statusText}`);let t=null;try{t=JSON.parse(e)}catch{throw Error(e)}throw Error(t?.message??t?.error??e)}return n}async function je(e,t){return(await W(e,{method:`GET`,headers:await t()})).json()}async function Me(e,t,n){return(await W(`${e}/${t}`,{method:`GET`,headers:await n()})).json()}async function Ne(e,t,n){await W(`${e}/${t}`,{method:`DELETE`,headers:await n()})}async function Pe(e,t,n){let r=await W(e,{method:`POST`,headers:await n(),body:JSON.stringify(t)});return r.status===204?t:r.json()}async function Fe(e,t,n,r){let i=await W(t,{method:e,headers:await n(),body:r?JSON.stringify(r):void 0});if(i.status!==204)return i.json()}async function Ie(e,t,n){let r=await W(`${e}/${t.id}`,{method:`PUT`,headers:await n(),body:JSON.stringify(t)});return r.status===204?t:r.json()}function Le(e,t,n){let{baseUrl:r,getHeaders:i}=U();return Te({queryKey:[...t.map(e=>e.toString()),String(n?.toString())],queryFn:()=>Me(`${r}${e}`,n,i),enabled:!!n})}function Re(e,t,n=!0){let{baseUrl:r,getHeaders:i}=U();return Te({queryKey:[...t.map(e=>e.toString())],queryFn:()=>je(`${r}${e}`,i),enabled:n})}function ze(e,t){let{baseUrl:n,queryClient:r,getHeaders:i}=U();return Ee({mutationKey:[...t.map(e=>e.toString())],mutationFn:t=>Pe(`${n}${e}`,t,i),onSettled(){return r.invalidateQueries({queryKey:[...t.map(e=>e.toString())]})}})}function Be(e,t){let{baseUrl:n,queryClient:r,getHeaders:i}=U();return Ee({mutationKey:[...t.map(e=>e.toString())],mutationFn:t=>Ie(`${n}${e}`,t,i),onSettled(){return r.invalidateQueries({queryKey:[...t.map(e=>e.toString())]})}})}function Ve(e,t){let{baseUrl:n,queryClient:r,getHeaders:i}=U();return Ee({mutationKey:[...t.map(e=>e.toString())],mutationFn:t=>Ne(`${n}${e}`,t,i),onSettled(){return r.invalidateQueries({queryKey:[...t.map(e=>e.toString())]})}})}function He({fields:e,onClose:o,queryKey:s,apiPath:c,steps:l,onCreated:u}){let[d,f]=(0,t.useState)(0),[p,m]=(0,t.useState)(!1),[h,g]=(0,t.useState)(),{mutateAsync:_,isError:v,error:y,isPending:b}=ze(c,s),{mutateAsync:x,isPending:S}=Be(c,s),C=b||S,w=[...new Set(e.filter(e=>typeof e.step==`number`).map(e=>e.step))];function T(e,t){return typeof e.required==`function`?e.required(t??{}):!!e.required}let E=(0,i.useForm)({mode:`uncontrolled`,initialValues:e.reduce((e,t)=>(e[t.id]=t.type===`boolean`?!1:t.defaultValue??``,e),{}),validate:e.filter(e=>e.required).reduce((e,t)=>(e[t.id]=(e,n)=>t.conditional&&!t.conditional(n)||!T(t,n)||e?null:`Pflichtfeld`,e),{})});function D(e){let i=E.getValues();if(e.conditional&&!e.conditional(i))return null;let o=T(e,i);return(0,n.jsxs)(t.Fragment,{children:[(e.type===void 0||e.type==`text`)&&(0,n.jsx)(r.TextInput,{label:e.column.title,placeholder:e.placeholder??``,...E.getInputProps(e.id),type:e.id.includes(`email`)?`email`:void 0,required:o},E.key(e.id)),e.type===`number`&&(0,n.jsx)(r.NumberInput,{decimalSeparator:`,`,label:e.column.title,placeholder:e.placeholder??``,...E.getInputProps(e.id),required:o},E.key(e.id)),e.type===`date`&&(0,n.jsx)(a.DateInput,{label:e.column.title,placeholder:e.placeholder??``,valueFormat:`DD.MM.YYYY`,clearable:!0,...E.getInputProps(e.id),required:o},E.key(e.id)),e.type===`boolean`&&(0,n.jsx)(r.Checkbox,{mt:`md`,label:e.column.title,...E.getInputProps(e.id,{type:`checkbox`}),required:o},E.key(e.id)),e.type===`textarea`&&(0,n.jsx)(r.Textarea,{label:e.column.title,placeholder:e.placeholder??``,...E.getInputProps(e.id),minRows:3,autosize:!0,required:o},E.key(e.id)),e.type===`custom`&&e.render&&e.render({...E.getValues(),...h&&{id:h}},E.setValues,m,{error:E.getInputProps(e.id).error,required:o})]},e.id)}return(0,n.jsxs)(n.Fragment,{children:[v&&(0,n.jsx)(r.Alert,{variant:`outline`,color:`red`,title:y?.name??`Fehler aufgetreten`,mb:`lg`,children:y?.message??`Fehler aufgetreten`}),(0,n.jsxs)(`form`,{onSubmit:E.onSubmit(async e=>{let t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t===``?void 0:t]));if(h)await x({...t,id:h});else{let e=await _(t);g(e.id),u?.(e.id)}w.length&&d<w.length-1?v||f(d+1):v||(E.setInitialValues(t),E.reset(),o())}),children:[w.length?(0,n.jsx)(r.Stepper,{active:d,size:`sm`,children:w.map(t=>(0,n.jsx)(r.Stepper.Step,{...l&&l[t-1]?{label:l[t-1].label}:{},children:e.filter(e=>e.step===t).map(e=>D(e))},t))}):e.map(e=>D(e)),!p&&(0,n.jsxs)(r.Group,{mt:`md`,justify:`end`,children:[(0,n.jsx)(r.Button,{onClick:()=>w.length?d===0?o():f(d-1):o(),variant:`outline`,children:w.length?d===0?`Abbrechen`:`Zurück`:`Abbrechen`}),(0,n.jsx)(r.Button,{type:`submit`,loading:C,children:w.length?d===w.length-1?`Speichern`:`Weiter`:`Speichern`})]})]})]})}function Ue(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Ue(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function G(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ue(e))&&(r&&(r+=` `),r+=t);return r}var[We,Ge]=(0,r.createSafeContext)(`useDataTableColumnsContext must be used within DataTableColumnProvider`),Ke=e=>{let{children:r,columnsOrder:i,setColumnsOrder:a,columnsToggle:o,setColumnsToggle:s,resetColumnsOrder:c,resetColumnsToggle:l,setColumnWidth:u,setMultipleColumnWidths:d,resetColumnsWidth:f}=e,[p,m]=(0,t.useState)(``),[h,g]=(0,t.useState)(``);return(0,n.jsx)(We,{value:{sourceColumn:p,setSourceColumn:m,targetColumn:h,setTargetColumn:g,columnsToggle:o,setColumnsToggle:s,swapColumns:()=>{if(!i||!a||!p||!h)return;let e=i.indexOf(p),t=i.indexOf(h);if(e!==-1&&t!==-1){let n=i.splice(e,1)[0];i.splice(t,0,n),a([...i])}},resetColumnsOrder:c,resetColumnsToggle:l,setColumnWidth:u,setMultipleColumnWidths:d,resetColumnsWidth:f},children:r})};function qe(){return(0,n.jsx)(`tr`,{className:`mantine-datatable-empty-row`,children:(0,n.jsx)(`td`,{})})}function Je(){return(0,n.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M12.983 8.978c3.955 -.182 7.017 -1.446 7.017 -2.978c0 -1.657 -3.582 -3 -8 -3c-1.661 0 -3.204 .19 -4.483 .515m-2.783 1.228c-.471 .382 -.734 .808 -.734 1.257c0 1.22 1.944 2.271 4.734 2.74`}),(0,n.jsx)(`path`,{d:`M4 6v6c0 1.657 3.582 3 8 3c.986 0 1.93 -.067 2.802 -.19m3.187 -.82c1.251 -.53 2.011 -1.228 2.011 -1.99v-6`}),(0,n.jsx)(`path`,{d:`M4 12v6c0 1.657 3.582 3 8 3c3.217 0 5.991 -.712 7.261 -1.74m.739 -3.26v-4`}),(0,n.jsx)(`path`,{d:`M3 3l18 18`})]})}function Ye({icon:e,text:t,active:i,children:a}){return(0,n.jsx)(r.Center,{className:`mantine-datatable-empty-state`,"data-active":i||void 0,children:a||(0,n.jsxs)(n.Fragment,{children:[e||(0,n.jsx)(`div`,{className:`mantine-datatable-empty-state-icon`,children:(0,n.jsx)(Je,{})}),(0,n.jsx)(r.Text,{component:`div`,size:`sm`,c:`dimmed`,children:t})]})})}function Xe({key:e,columns:t=[],getInitialValueInEffect:n=!0}){function r(e,t){let n=[];return e.forEach(e=>{t.find(t=>t.accessor===e)&&n.push(e)}),t.forEach(e=>{n.includes(e.accessor)||n.push(e.accessor)}),n}let i=t&&t.map(e=>e.accessor)||[],[a,o]=(0,s.useLocalStorage)({key:e?`${e}-columns-order`:``,defaultValue:e?i:void 0,getInitialValueInEffect:n});function c(t){e&&o(t)}let l=()=>{c(i)};if(!e)return{columnsOrder:a,setColumnsOrder:c,resetColumnsOrder:l};let u=r(a,t),d=JSON.stringify(a);return JSON.stringify(u)!==d&&c(u),{columnsOrder:u,setColumnsOrder:c,resetColumnsOrder:l}}function Ze({key:e,columns:n=[],getInitialValueInEffect:r=!0,headerRef:i,onFixedLayoutChange:a}){let o=(0,t.useRef)(!1),c=(0,t.useRef)({}),[l,u]=(0,t.useState)(!0),d=(0,t.useMemo)(()=>n.some(e=>e.resizable&&!e.hidden&&e.accessor!==`__selection__`),[n]),f=(0,t.useMemo)(()=>n.filter(e=>e.resizable&&!e.hidden&&e.accessor!==`__selection__`),[n]),p=(0,t.useMemo)(()=>f.some(e=>e.width===void 0||e.width===``||e.width===`initial`),[f]),m=(0,t.useCallback)(()=>n.filter(e=>e.accessor!==`__selection__`).map(e=>({[e.accessor]:e.width??`auto`})),[n]),[h,g]=(0,s.useLocalStorage)({key:e?`${e}-columns-width`:``,defaultValue:e?m():void 0,getInitialValueInEffect:!1}),[_,v]=(0,t.useState)(()=>m());(0,t.useEffect)(()=>{u(!1)},[]);let y=(0,t.useCallback)(()=>{if(!i?.current||l)return{};let e=i.current,t=Array.from(e.querySelectorAll(`th[data-accessor]`)),n={};return t.forEach(e=>{let t=e.getAttribute(`data-accessor`);if(!t||t===`__selection__`)return;let r=f.find(e=>e.accessor===t);if(r&&(r.width===void 0||r.width===``||r.width===`initial`)){let r=e.getBoundingClientRect();n[t]=Math.round(r.width)}}),n},[i,f,l]),b=(0,t.useCallback)(t=>{let n=t.filter(e=>e.accessor!==`__selection__`),r=_.map(e=>{let t=Object.keys(e)[0],r=n.find(e=>e.accessor===t);return r?{[t]:r.width}:e});v(r),e&&g(r)},[_,e,g]),x=(0,t.useCallback)(e=>{b(e)},[b]),S=(0,t.useCallback)(()=>{!i?.current||!a||l||(p?(a(!1),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let e=y();c.current={...c.current,...e},v(n.filter(e=>e.accessor!==`__selection__`).map(t=>{let n=t.accessor,r=h?.find(e=>Object.keys(e)[0]===n);if(r&&r[n]!==`auto`)return{[n]:r[n]};let i=e[n];return i?{[n]:`${i}px`}:{[n]:t.width??`auto`}})),setTimeout(()=>{a(!0),o.current=!0},10)})})):(v(n.filter(e=>e.accessor!==`__selection__`).map(e=>({[e.accessor]:e.width??`auto`}))),a(!0),o.current=!0))},[i,a,l,p,y,n,h]),C=S;(0,t.useEffect)(()=>{if(!d||!a||l){a?.(!1);return}o.current=!1;let e=setTimeout(()=>{S()},50);return()=>clearTimeout(e)},[d,a,l,S]),(0,t.useEffect)(()=>{l||!e||!r||h&&h.length>0&&v(h)},[l,e,r,h]);let w=(0,t.useCallback)(()=>{e&&g(m()),c.current={},o.current=!1,a&&(a(!1),setTimeout(()=>{S()},10))},[e,g,m,a,S]);return{columnsWidth:_,setColumnsWidth:b,setColumnWidth:(0,t.useCallback)((e,t)=>{b([{accessor:e,width:t}])},[b]),setMultipleColumnWidths:x,resetColumnsWidth:w,hasResizableColumns:d,allResizableWidthsInitial:(0,t.useMemo)(()=>d?_.filter(e=>{let t=Object.keys(e)[0];return f.some(e=>e.accessor===t)}).every(e=>{let t=Object.values(e)[0];return t===`auto`||t===`initial`}):!1,[d,_,f]),measureAndSetColumnWidths:C}}function Qe({key:e,columns:t=[],getInitialValueInEffect:n=!0}){function r(e,t){let n=[];return e.forEach(e=>{t.find(t=>t.accessor===e.accessor)&&n.push(e)}),t.forEach(e=>{n.find(t=>t.accessor===e.accessor)||n.push({accessor:e.accessor,defaultToggle:e.defaultToggle||!0,toggleable:e.toggleable,toggled:e.defaultToggle===void 0?!0:e.defaultToggle})}),n}let i=t&&t.map(e=>({accessor:e.accessor,defaultToggle:e.defaultToggle||!0,toggleable:e.toggleable,toggled:e.defaultToggle===void 0?!0:e.defaultToggle})),[a,o]=(0,s.useLocalStorage)({key:e?`${e}-columns-toggle`:``,defaultValue:e?i:void 0,getInitialValueInEffect:n});function c(t){e&&o(t)}let l=()=>{c(i)};if(!e)return{columnsToggle:a,setColumnsToggle:c,resetColumnsToggle:l};let u=r(a,t),d=JSON.stringify(a);return JSON.stringify(u)!==d&&c(u),{columnsToggle:u,setColumnsToggle:c,resetColumnsToggle:l}}var $e=({key:e,columns:n=[],getInitialValueInEffect:r=!0,headerRef:i,scrollViewportRef:a,onFixedLayoutChange:o})=>{let{columnsOrder:s,setColumnsOrder:c,resetColumnsOrder:l}=Xe({key:e,columns:n,getInitialValueInEffect:r}),{columnsToggle:u,setColumnsToggle:d,resetColumnsToggle:f}=Qe({key:e,columns:n,getInitialValueInEffect:r}),{columnsWidth:p,setColumnsWidth:m,setColumnWidth:h,setMultipleColumnWidths:g,resetColumnsWidth:_,hasResizableColumns:v,allResizableWidthsInitial:y,measureAndSetColumnWidths:b}=Ze({key:e,columns:n,getInitialValueInEffect:r,headerRef:i,scrollViewportRef:a,onFixedLayoutChange:o});return{effectiveColumns:(0,t.useMemo)(()=>s?s.map(e=>n.find(t=>t.accessor===e)).map(e=>({...e,hidden:e?.hidden||!u.find(t=>t.accessor===e?.accessor)?.toggled})).map(e=>e?.accessor===`__selection__`?e:{...e,width:p.find(t=>t[e?.accessor])?.[e?.accessor]}):n,[n,s,u,p]),setColumnsOrder:c,columnsOrder:s,resetColumnsOrder:l,columnsToggle:u,setColumnsToggle:d,resetColumnsToggle:f,columnsWidth:p,setColumnsWidth:m,setColumnWidth:h,setMultipleColumnWidths:g,resetColumnsWidth:_,hasResizableColumns:v,allResizableWidthsInitial:y,measureAndSetColumnWidths:b}},et=typeof window<`u`?t.useLayoutEffect:t.useEffect;function tt(e){let n=(0,t.useRef)(e);return n.current=e,n}var nt=`--mantine-datatable-header-height`,rt=`--mantine-datatable-footer-height`,K=`--mantine-datatable-selection-column-width`,it=`--mantine-datatable-last-row-border-bottom`;function q(e,t,n){e?.style.setProperty(t,n)}function at(e){let t=e.borderBoxSize?.[0]||e.contentBoxSize?.[0];return t?{width:t.inlineSize,height:t.blockSize}:{width:e.contentRect.width,height:e.contentRect.height}}function ot(e,t,n){if(e){let r=new ResizeObserver(e=>{let n=e[0];n&&t(at(n))});return r.observe(e),()=>{r.disconnect(),n()}}}function st({scrollCallbacks:e,withRowBorders:n}){let i={root:(0,t.useRef)(null),table:(0,t.useRef)(null),scrollViewport:(0,t.useRef)(null),header:(0,t.useRef)(null),footer:(0,t.useRef)(null),selectionColumnHeader:(0,t.useRef)(null)},{root:a,table:o,scrollViewport:s,header:c,footer:l,selectionColumnHeader:u}=i,d=tt({withRowBorders:n}),f=tt(e),p=(0,t.useRef)(()=>{}),m=(0,t.useRef)(()=>{}),h=(0,t.useCallback)(e=>{f.current.onScroll?.(e),p.current()},[]);return(0,t.useEffect)(()=>ot(c.current,e=>{q(a.current,nt,`${e.height}px`)},()=>q(a.current,nt,`0`)),[c.current]),(0,t.useEffect)(()=>ot(l.current,e=>{q(a.current,rt,`${e.height}px`)},()=>q(a.current,rt,`0`)),[l.current]),(0,t.useEffect)(()=>ot(u.current,e=>{q(a.current,K,`${e.width}px`)},()=>q(a.current,K,`0`)),[u.current]),et(()=>{let e={top:!0,bottom:!0,left:!0,right:!0},t={width:0,height:0},n={width:0,height:0};function i(t,n){let r=e[t];return e[t]=n,q(a.current,`--mantine-datatable-${t}-shadow-opacity`,n?`0`:`1`),r}function c(){let e=t.height-n.height,r=e<0;q(a.current,`--mantine-datatable-footer-position`,r?`relative`:`sticky`),q(a.current,`--mantine-datatable-footer-bottom`,r?`${e}px`:`0`)}function l(){d.current.withRowBorders&&t.height<n.height?q(a.current,it,`${(0,r.rem)(`1px`)} solid var(--mantine-datatable-border-color)`):q(a.current,it,`unset`)}m.current=l;function u(){let e=f.current,r=s.current,a=r?.scrollTop??0,o=r?.scrollLeft??0,c=a===0,l=t.height-a-n.height<1,u=i(`top`,c),d=i(`bottom`,l);c&&c!==u&&e.onScrollToTop?.(),l&&l!==d&&e.onScrollToBottom?.();let p=r?getComputedStyle(r).direction===`rtl`:!1,m=(r?.scrollWidth??0)-n.width,h,g;if(p){let e=Math.abs(o);g=e<1,h=m-e<1}else h=o<1,g=t.width-o-n.width<1;let _=i(`left`,h),v=i(`right`,g);h&&h!==_&&e.onScrollToLeft?.(),g&&g!==v&&e.onScrollToRight?.()}p.current=u;let h=new ResizeObserver(e=>{for(let r of e)switch(r.target.tagName){case`TABLE`:t=at(r);break;case`DIV`:n=at(r);break}u(),c(),l()});return h.observe(o.current),h.observe(s.current),()=>{h.disconnect()}},[]),et(()=>{m.current()},[n]),{refs:i,onScroll:h}}function ct(e){let[n,r]=(0,t.useState)(null);return(0,t.useEffect)(()=>{r(null)},[e?.join(`:`)||``]),{lastSelectionChangeIndex:n,setLastSelectionChangeIndex:r}}function lt(e,t){let n=()=>{t(e.map(e=>e.matches))},r=e.map(e=>{try{return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)}catch{return e.addListener(n),()=>e.removeListener(n)}});return()=>{r.forEach(e=>e())}}function ut(e,t){return t||(typeof window<`u`&&`matchMedia`in window?e.map(e=>window.matchMedia(e).matches):e.map(()=>!1))}function dt(e,n,{getInitialValueInEffect:r}={getInitialValueInEffect:!0}){let[i,a]=(0,t.useState)(r?n:ut(e,n)),o=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(`matchMedia`in window)return o.current=e.map(e=>window.matchMedia(e)),a(o.current.map(e=>e.matches)),lt(o.current,e=>{a(e)})},[e]),i}function ft(e){let n=(0,r.useMantineTheme)();return dt((0,t.useMemo)(()=>e.map(e=>(typeof e==`function`?e(n):e)??``),[e,n]),(0,t.useMemo)(()=>e.map(()=>!0),[e]))}function J(e){let t=(0,r.useMantineTheme)();return(0,s.useMediaQuery)((typeof e==`function`?e(t):e)||``,!0)}function pt(e){let t=e.replace(/([a-z\d])([A-Z]+)/g,`$1 $2`).replace(/\W|_/g,` `).trim().toLowerCase();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function mt(e,t,n){return e.filter(e=>!t.map(n).includes(n(e)))}function ht(e,t){return e.filter((e,n,r)=>n===r.findIndex(n=>t(e)===t(n)))}function gt(e,t){return t?t.match(/([^[.\]])+/g).reduce((e,t)=>e&&e[t],e):void 0}function Y(e,t){return typeof t==`string`?gt(e,t):t(e)}function _t(e){return!e||e.length===0?0:Math.max(...e.map(e=>e.groups&&e.groups.length>0?1+_t(e.groups):1))}function vt(e){let t=[];for(let n of e)n.columns&&n.columns.length>0?t.push(...n.columns.filter(e=>e!=null)):n.groups&&n.groups.length>0&&t.push(...vt(n.groups));return t.filter(e=>e!=null)}function yt(e,t){return e.columns&&e.columns.length>0?e.columns.filter((e,n)=>e.hidden?!1:t?t[n]!==!1:!0).length:e.groups&&e.groups.length>0?e.groups.reduce((e,n)=>e+yt(n,t),0):0}function bt(e,t,n=0){if(n===t)return[...e];let r=[];for(let i of e)i.groups&&i.groups.length>0&&r.push(...bt(i.groups,t,n+1));return r}function xt(e,t,n){return n?!e||t:!1}function St({rowExpansion:e,records:n,idAccessor:r}){let i=[];if(e&&n){let{trigger:t,allowMultiple:a,initiallyExpanded:o}=e;n&&t===`always`?i=n.map(e=>Y(e,r)):o&&(i=n.filter((e,t)=>o({record:e,index:t})).map(e=>Y(e,r)),a||(i=[i[0]]))}let a,o,s=(0,t.useState)(i);if(e){let{expandable:t,trigger:n,allowMultiple:i,collapseProps:c,content:l}=e;e.expanded?{recordIds:a,onRecordIdsChange:o}=e.expanded:[a,o]=s;let u=e=>o?.(a.filter(t=>t!==Y(e,r)));return{expandOnClick:n!==`always`&&n!==`never`,isRowExpanded:e=>n===`always`?!0:a.includes(Y(e,r)),isExpandable:({record:e,index:n})=>t?t({record:e,index:n}):!0,expandRow:e=>{let t=Y(e,r);o?.(i?[...a,t]:[t])},collapseRow:u,collapseProps:c,content:({record:e,index:t})=>()=>l({record:e,index:t,collapse:()=>u(e)})}}}function Ct(e,n){let[r,i]=(0,t.useState)(e),[a,o]=(0,t.useState)(e),c=(0,s.useTimeout)(()=>i(!0),0),l=(0,s.useTimeout)(()=>o(!1),n||200);return(0,t.useEffect)(()=>{e?(l.clear(),o(!0),c.start()):(c.clear(),i(!1),l.start())},[c,l,e]),{expanded:r,visible:a}}var wt=`mantine-datatable-nowrap`,Tt=`mantine-datatable-ellipsis`,X=`mantine-datatable-pointer-cursor`,Et=`mantine-datatable-context-menu-cursor`,Dt=`mantine-datatable-text-selection-disabled`,Z=`mantine-datatable-text-align-left`,Q=`mantine-datatable-text-align-center`,Ot=`mantine-datatable-text-align-right`;function kt({className:e,style:t,visibleMediaQuery:i,title:a,noWrap:o,ellipsis:s,textAlign:c,width:l}){return J(i)?(0,n.jsx)(r.TableTh,{className:G({[wt]:o||s,[Tt]:s,[Z]:c===`left`,[Q]:c===`center`,[Ot]:c===`right`},e),style:[{width:l,minWidth:l,maxWidth:l},t],children:a}):null}function At({shadowVisible:e}){return(0,n.jsx)(r.TableTh,{className:`mantine-datatable-footer-selector-placeholder-cell`,"data-shadow-visible":e||void 0})}function jt({className:e,style:t,columns:i,defaultColumnProps:a,selectionVisible:o,selectorCellShadowVisible:s,ref:c}){return(0,n.jsx)(r.TableTfoot,{ref:c,className:G(`mantine-datatable-footer`,e),style:t,children:(0,n.jsxs)(r.TableTr,{children:[o&&(0,n.jsx)(At,{shadowVisible:s}),i.map(({hidden:e,...t})=>{if(e)return null;let{accessor:r,visibleMediaQuery:i,textAlign:o,width:s,footer:c,footerClassName:l,footerStyle:u,noWrap:d,ellipsis:f}={...a,...t};return(0,n.jsx)(kt,{className:l,style:u,visibleMediaQuery:i,textAlign:o,width:s,title:c,noWrap:d,ellipsis:f},r)})]})})}function Mt({group:{id:e,columns:i,groups:a,title:o,textAlign:s,className:c,style:l},maxDepth:u,currentDepth:d,previousGroups:f,isLastGroup:p,withColumnBorders:m=!1,totalTableColumns:h}){let g=(0,t.useMemo)(()=>i&&i.length>0?i:a&&a.length>0?vt([{id:e,columns:i,groups:a}]):[],[i,a,e]),_=ft((0,t.useMemo)(()=>g.map(({visibleMediaQuery:e})=>e),[g])),v=(0,t.useMemo)(()=>yt({id:e,columns:i,groups:a},_),[e,i,a,_]),y=(0,t.useMemo)(()=>f.reduce((e,t)=>e+yt(t,_),0),[f,_]),b=a&&a.length>0?1:u-d,x=xt(p,y+v<h,m);return v>0?(0,n.jsx)(r.TableTh,{colSpan:v,rowSpan:b>1?b:void 0,className:G(`mantine-datatable-column-group-header-cell`,{[Z]:s===`left`,[Q]:s===`center`,[Ot]:s===`right`,"mantine-datatable-column-group-header-cell--needs-border":x},c),style:l,children:o??pt(e)}):null}function Nt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227z`})]})}function Pt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M20 3h-16a1 1 0 0 0 -1 1v2.227l.008 .223a3 3 0 0 0 .772 1.795l4.22 4.641v8.114a1 1 0 0 0 1.316 .949l6 -2l.108 -.043a1 1 0 0 0 .576 -.906v-6.586l4.121 -4.12a3 3 0 0 0 .879 -2.123v-2.171a1 1 0 0 0 -1 -1z`,strokeWidth:`0`,fill:`currentColor`})]})}function Ft({children:e,isActive:t,filterPopoverProps:i,filterPopoverDisableClickOutside:a}){let[o,{close:c,toggle:l}]=(0,s.useDisclosure)(!1),u=t?Pt:Nt,d=(0,s.useClickOutside)(c);return a&&(d=void 0),(0,n.jsxs)(r.Popover,{withArrow:!0,shadow:`md`,opened:o,onClose:c,trapFocus:!0,...i,children:[(0,n.jsx)(r.PopoverTarget,{children:(0,n.jsx)(r.ActionIcon,{className:`mantine-datatable-header-cell-filter-action-icon`,"data-active":t||void 0,size:`sm`,variant:`default`,onClick:e=>{e.preventDefault(),l()},onKeyDown:e=>e.stopPropagation(),children:(0,n.jsx)(u,{})})}),(0,n.jsx)(r.PopoverDropdown,{ref:d,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:typeof e==`function`?e({close:c}):e})]})}var It=e=>{let{accessor:i,columnRef:a}=e,[o,s]=(0,t.useState)(!1),c=(0,t.useRef)(0),l=(0,t.useRef)({current:0,next:0}),{dir:u}=(0,r.useDirection)(),d=u===`rtl`,{setMultipleColumnWidths:f}=Ge(),p=(0,t.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!a.current)return;let t=a.current,n=t.nextElementSibling;for(;n;){let e=n.getAttribute(`data-accessor`);if(e&&e!==`__selection__`)break;n=n.nextElementSibling}if(!n)return;let r=n.getAttribute(`data-accessor`);if(!r)return;let o=r===`__selection__`;s(!0),c.current=e.clientX,l.current={current:t.offsetWidth,next:n.offsetWidth};let u=e=>{if(!a.current)return;let t=a.current,n=t.nextElementSibling;if(!n)return;let r=e.clientX-c.current;d&&(r=-r);let i=l.current.current-50,o=l.current.next-50,s=Math.max(-i,Math.min(r,o)),u=l.current.current+s,f=l.current.next-s;t.style.width=`${u}px`,n.style.width=`${f}px`,t.style.minWidth=`${u}px`,t.style.maxWidth=`${u}px`,n.style.minWidth=`${f}px`,n.style.maxWidth=`${f}px`},p=()=>{if(!a.current)return;let e=a.current,t=e.nextElementSibling;s(!1),document.body.style.cursor=`initial`,document.body.style.userSelect=`initial`;let n=parseInt(e.style.width)||e.offsetWidth,r=t?parseInt(t.style.width)||t.offsetWidth:0,c=[{accessor:i,width:`${n}px`}];if(t&&!o){let e=t.getAttribute(`data-accessor`);e&&c.push({accessor:e,width:`${r}px`})}setTimeout(()=>{f(c)},0),document.removeEventListener(`mousemove`,u),document.removeEventListener(`mouseup`,p)};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,document.addEventListener(`mousemove`,u),document.addEventListener(`mouseup`,p)},[i,a,d,f]),m=(0,t.useCallback)(()=>{if(!a.current)return;let e=a.current,t=e.nextElementSibling;e.style.width=``,e.style.minWidth=``,e.style.maxWidth=``;let n=[{accessor:i,width:`auto`}];if(t){t.style.width=``,t.style.minWidth=``,t.style.maxWidth=``;let e=t.getAttribute(`data-accessor`);e&&e!==`__selection__`&&n.push({accessor:e,width:`auto`})}setTimeout(()=>{f(n)},0)},[i,a,f]);return(0,n.jsx)(`div`,{className:`mantine-datatable-header-resizable-handle`,style:{cursor:o?`col-resize`:void 0},onMouseDown:p,onDoubleClick:m,onClick:e=>e.stopPropagation(),title:`Drag to resize column, double-click to reset`})};function Lt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M12 5l0 14`}),(0,n.jsx)(`path`,{d:`M16 9l-4 -4`}),(0,n.jsx)(`path`,{d:`M8 9l4 -4`})]})}function Rt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M8 7l4 -4l4 4`}),(0,n.jsx)(`path`,{d:`M8 17l4 4l4 -4`}),(0,n.jsx)(`path`,{d:`M12 3l0 18`})]})}function zt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M9 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,n.jsx)(`path`,{d:`M9 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,n.jsx)(`path`,{d:`M9 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,n.jsx)(`path`,{d:`M15 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,n.jsx)(`path`,{d:`M15 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,n.jsx)(`path`,{d:`M15 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`})]})}function Bt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M18 6l-12 12`}),(0,n.jsx)(`path`,{d:`M6 6l12 12`})]})}function Vt({className:e,style:i,accessor:a,visibleMediaQuery:o,title:s,sortable:c,draggable:l,toggleable:u,resizable:d,sortIcons:f,textAlign:p,width:m,sortStatus:h,onSortStatusChange:g,filter:_,filterPopoverProps:v,filterPopoverDisableClickOutside:y,filtering:b,sortKey:x}){let{setSourceColumn:S,setTargetColumn:C,swapColumns:w,setColumnsToggle:T}=Ge(),[E,D]=(0,t.useState)(!1),O=(0,t.useRef)(null);if(!J(o))return null;let k=s??pt(a),A=typeof k==`string`?k:void 0,j=c&&g?e=>{e?.defaultPrevented||g({sortKey:x,columnAccessor:a,direction:h?.columnAccessor===a?h.direction===`asc`?`desc`:`asc`:h?.direction??`asc`})}:void 0,M=e=>{e.stopPropagation(),S(a),D(!1)},ee=e=>{e.preventDefault(),C(a),D(!0)},N=()=>{C(a),D(!1),w()},P=()=>{D(!0)},F=()=>{D(!1)},te=e=>{e.stopPropagation(),T(e=>e.map(e=>e.accessor===a?{...e,toggled:!1}:e))};return(0,n.jsxs)(r.TableTh,{"data-accessor":a,className:G({"mantine-datatable-header-cell-sortable":c,"mantine-datatable-header-cell-toggleable":u,"mantine-datatable-header-cell-resizable":d},e),style:[{width:m,...d?{}:{minWidth:m,maxWidth:m}},i],role:c?`button`:void 0,tabIndex:c?0:void 0,onClick:j,onKeyDown:e=>e.key===`Enter`&&j?.(),ref:O,children:[(0,n.jsxs)(r.Group,{className:`mantine-datatable-header-cell-sortable-group`,justify:`space-between`,wrap:`nowrap`,children:[(0,n.jsxs)(r.Flex,{align:`center`,w:`100%`,className:G({"mantine-datatable-header-cell-draggable":l,"mantine-datatable-header-cell-drag-over":E}),draggable:l,onDragStart:l?M:void 0,onDragEnter:l?P:void 0,onDragOver:l?ee:void 0,onDrop:l?N:void 0,onDragLeave:l?F:void 0,children:[l?(0,n.jsx)(r.Center,{role:`img`,"aria-label":`Drag column`,children:(0,n.jsx)(r.ActionIcon,{className:`mantine-datatable-header-cell-draggable-action-icon`,variant:`subtle`,size:`xs`,onClick:e=>{e.stopPropagation()},children:(0,n.jsx)(zt,{})})}):null,(0,n.jsx)(r.Box,{className:G(`mantine-datatable-header-cell-sortable-text`,{[Z]:p===`left`,[Q]:p===`center`,[Ot]:p===`right`},wt,Tt),title:A,children:k})]}),u?(0,n.jsx)(r.Center,{className:`mantine-datatable-header-cell-toggleable-icon`,role:`img`,"aria-label":`Toggle column`,children:(0,n.jsx)(r.ActionIcon,{size:`xs`,variant:`light`,onClick:te,children:(0,n.jsx)(Bt,{})})}):null,c||h?.columnAccessor===a?(0,n.jsx)(n.Fragment,{children:h?.columnAccessor===a?(0,n.jsx)(r.Center,{className:G(`mantine-datatable-header-cell-sortable-icon`,{"mantine-datatable-header-cell-sortable-icon-reversed":h.direction===`desc`}),role:`img`,"aria-label":`Sorted ${h.direction===`desc`?`descending`:`ascending`}`,children:f?.sorted||(0,n.jsx)(Lt,{})}):(0,n.jsx)(r.Center,{className:`mantine-datatable-header-cell-sortable-unsorted-icon`,role:`img`,"aria-label":`Not sorted`,children:f?.unsorted||(0,n.jsx)(Rt,{})})}):null,_?(0,n.jsx)(Ft,{filterPopoverProps:v,isActive:!!b,filterPopoverDisableClickOutside:y,children:_}):null]}),d&&a!==`__selection__`?(0,n.jsx)(It,{accessor:a,columnRef:O}):null]})}function Ht({className:e,style:t,trigger:i,shadowVisible:a,checked:o,indeterminate:s,checkboxProps:c,onChange:l,rowSpan:u,ref:d}){let f=!c.disabled;return(0,n.jsx)(r.TableTh,{ref:d,className:G(`mantine-datatable-header-selector-cell`,{[X]:i===`cell`&&f},e),style:t,rowSpan:u,"data-shadow-visible":a||void 0,"data-accessor":`__selection__`,onClick:i===`cell`&&f?l:void 0,children:(0,n.jsx)(r.Checkbox,{classNames:f?{input:X}:void 0,checked:o,indeterminate:s,onChange:l,...c,disabled:!(l||c.onChange)||c.disabled})})}function Ut({selectionColumnHeaderRef:e,className:i,style:a,sortStatus:o,sortIcons:s,onSortStatusChange:c,columns:l,defaultColumnProps:u,groups:d,selectionTrigger:f,selectionVisible:p,selectionChecked:m,selectionIndeterminate:h,onSelectionChange:g,selectionCheckboxProps:_,selectorCellShadowVisible:v,selectionColumnClassName:y,selectionColumnStyle:b,withColumnBorders:x=!1,ref:S}){let C=d?_t(d):0,w=C>0?C+1:1,T=p?(0,n.jsx)(Ht,{ref:e,className:y,style:b,trigger:f,shadowVisible:v,checked:m,indeterminate:h,checkboxProps:_,onChange:g,rowSpan:d?w:void 0}):null,{columnsToggle:E,setColumnsToggle:D}=Ge(),[O,k]=(0,t.useState)(!1),A=l.some(e=>e.toggleable),j=A?Object.fromEntries(l.map(({accessor:e,title:t})=>[e,t??pt(String(e))])):void 0,M=(0,n.jsxs)(r.TableThead,{className:G(`mantine-datatable-header`,i),style:a,ref:S,onContextMenu:A?e=>{e.preventDefault(),k(e=>!e)}:void 0,children:[d&&Array.from({length:C},(e,t)=>{let i=bt(d,t);return(0,n.jsxs)(r.TableTr,{children:[t===0&&T,i.map((e,r)=>(0,n.jsx)(Mt,{group:e,maxDepth:C,currentDepth:t,previousGroups:i.slice(0,r),isLastGroup:r===i.length-1,withColumnBorders:x,totalTableColumns:l.length},e.id))]},`group-depth-${t}`)}),(0,n.jsxs)(r.TableTr,{children:[!d&&T,l.map(({hidden:e,...t},r)=>{if(e)return null;let{accessor:i,visibleMediaQuery:a,textAlign:d,width:f,title:p,sortable:m,draggable:h,toggleable:g,resizable:_,titleClassName:v,titleStyle:y,filter:b,filterPopoverProps:x,filterPopoverDisableClickOutside:S,filtering:C,sortKey:w}={...u,...t};return(0,n.jsx)(Vt,{accessor:i,className:v,style:y,visibleMediaQuery:a,textAlign:d,width:f,title:p,sortable:m,draggable:h,toggleable:g,resizable:_&&r<l.length-1,sortStatus:o,sortIcons:s,sortKey:w,onSortStatusChange:c,filter:b,filterPopoverProps:x,filterPopoverDisableClickOutside:S,filtering:C},i)})]})]});return A?(0,n.jsxs)(r.Popover,{position:`bottom`,withArrow:!0,shadow:`md`,opened:O,onChange:k,children:[(0,n.jsx)(r.PopoverTarget,{children:M}),(0,n.jsx)(r.PopoverDropdown,{children:(0,n.jsx)(r.Stack,{children:E.filter(e=>e.toggleable).map(e=>(0,n.jsx)(r.Group,{children:(0,n.jsx)(r.Checkbox,{classNames:{label:`mantine-datatable-header-column-toggle-checkbox-label`},size:`xs`,label:j[e.accessor],checked:e.toggled,onChange:t=>{D(E.map(n=>n.accessor===e.accessor?{...n,toggled:t.currentTarget.checked}:n))}})},e.accessor))})})]}):M}function Wt({fetching:e,customContent:t,backgroundBlur:i,size:a,type:o,color:s}){return(0,n.jsx)(r.Center,{className:G(`mantine-datatable-loader`,{"mantine-datatable-loader-fetching":e}),style:[{backdropFilter:i?`blur(${i}px)`:void 0}],children:e&&(t||(0,n.jsx)(r.Loader,{size:a,type:o,color:s}))})}function $(e,t,n){return e?(0,r.parseThemeColor)({color:typeof e==`object`?e[n]:e,theme:t}).value:void 0}function Gt({theme:e,c:t,backgroundColor:n,borderColor:r,rowBorderColor:i,stripedColor:a,highlightOnHoverColor:o}){return{"--mantine-datatable-color-light":$(t,e,`light`),"--mantine-datatable-color-dark":$(t,e,`dark`),"--mantine-datatable-background-color-light":$(n,e,`light`),"--mantine-datatable-background-color-dark":$(n,e,`dark`),"--mantine-datatable-border-color-light":$(r,e,`light`),"--mantine-datatable-border-color-dark":$(r,e,`dark`),"--mantine-datatable-row-border-color-light":$(i,e,`light`),"--mantine-datatable-row-border-color-dark":$(i,e,`dark`),"--mantine-datatable-striped-color-light":$(a,e,`light`),"--mantine-datatable-striped-color-dark":$(a,e,`dark`),"--mantine-datatable-highlight-on-hover-color-light":$(o,e,`light`),"--mantine-datatable-highlight-on-hover-color-dark":$(o,e,`dark`)}}function Kt({theme:e,paginationActiveTextColor:t,paginationActiveBackgroundColor:n}){return{"--mantine-datatable-pagination-active-text-color-light":$(t,e,`light`),"--mantine-datatable-pagination-active-text-color-dark":$(t,e,`dark`),"--mantine-datatable-pagination-active-background-color-light":$(n,e,`light`),"--mantine-datatable-pagination-active-background-color-dark":$(n,e,`dark`)}}function qt({theme:e,color:t,backgroundColor:n}){return{"--mantine-datatable-row-color-light":$(t,e,`light`),"--mantine-datatable-row-color-dark":$(t,e,`dark`),"--mantine-datatable-row-background-color-light":$(n,e,`light`),"--mantine-datatable-row-background-color-dark":$(n,e,`dark`)}}function Jt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M8 9l4 -4l4 4`}),(0,n.jsx)(`path`,{d:`M16 15l-4 4l-4 -4`})]})}var Yt={xs:(0,r.rem)(22),sm:(0,r.rem)(26),md:(0,r.rem)(32),lg:(0,r.rem)(38),xl:(0,r.rem)(44)};function Xt({size:e,label:t,values:i,value:a,activeTextColor:o,activeBackgroundColor:s,onChange:c}){return(0,n.jsxs)(r.Group,{gap:`xs`,children:[(0,n.jsx)(r.Text,{component:`div`,size:e,children:t}),(0,n.jsxs)(r.Menu,{withinPortal:!0,withArrow:!0,offset:2,classNames:{arrow:`mantine-datatable-page-size-selector-menu-arrow`},children:[(0,n.jsx)(r.MenuTarget,{children:(0,n.jsx)(r.Button,{size:e,variant:`default`,classNames:{section:`mantine-datatable-page-size-selector-button-icon`},rightSection:(0,n.jsx)(Jt,{}),style:[{fontWeight:`normal`},t=>({height:Yt[e],paddingLeft:t.spacing[e],paddingRight:t.spacing[e]})],children:a})}),(0,n.jsx)(r.MenuDropdown,{children:i.map(t=>{let i=t===a;return(0,n.jsx)(r.MenuItem,{className:G({"mantine-datatable-page-size-selector-active":i}),style:[{height:Yt[e]},i&&(o||s)?e=>Kt({theme:e,paginationActiveTextColor:o,paginationActiveBackgroundColor:s}):void 0],disabled:i,onClick:()=>c(t),children:(0,n.jsx)(r.Text,{component:`div`,size:e,children:t})},t)})})]})]})}function Zt({className:e,style:t,fetching:i,page:a,onPageChange:o,paginationWithEdges:s,paginationWithControls:c,paginationActiveTextColor:l,paginationActiveBackgroundColor:u,paginationSize:d,loadingText:f,noRecordsText:p,paginationText:m,totalRecords:h,recordsPerPage:g,onRecordsPerPageChange:_,recordsPerPageLabel:v,recordsPerPageOptions:y,recordsLength:b,horizontalSpacing:x,paginationWrapBreakpoint:S,getPaginationControlProps:C,getPaginationItemProps:w,renderPagination:T}){let E;if(h){let e=(a-1)*g+1;E=m({from:e,to:e+(b||0)-1,totalRecords:h})}else E=i?f:p;let D=h&&g?Math.max(1,Math.ceil(h/g)):1,O=h?(a-1)*(g??0)+1:void 0,k=h?(O??1)+(b??0)-1:void 0,A=!J(({breakpoints:e})=>`(min-width: ${typeof S==`number`?`${(0,r.rem)(S)}rem`:e[S]||S})`),j={Text:e=>(0,n.jsx)(r.Text,{component:`div`,className:`mantine-datatable-pagination-text`,size:d,...e,children:E}),PageSizeSelector:e=>y?(0,n.jsx)(Xt,{activeTextColor:l,activeBackgroundColor:u,size:d,label:v,values:y,value:g,onChange:_,...e}):(0,n.jsx)(n.Fragment,{}),Pagination:e=>(0,n.jsx)(r.Pagination,{classNames:{root:G(`mantine-datatable-pagination-pages`,{"mantine-datatable-pagination-pages-fetching":i||!b}),control:`mantine-datatable-pagination-pages-control`},style:l||u?e=>Kt({theme:e,paginationActiveTextColor:l,paginationActiveBackgroundColor:u}):void 0,withEdges:s,withControls:c,value:a,onChange:o,size:d,total:D,getControlProps:C,getItemProps:w,...e})},M={state:{paginationSize:d,page:a,totalPages:D,totalRecords:h,recordsPerPage:g,recordsLength:b,fetching:i,from:O,to:k,isWrapped:A},actions:{setPage:e=>o?.(e),setRecordsPerPage:_?e=>_(e):void 0},Controls:j};return(0,n.jsx)(r.Box,{px:x??`xs`,py:`xs`,className:G(`mantine-datatable-pagination`,e),style:[{flexDirection:A?`column`:`row`},t],children:typeof T==`function`?T(M):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(j.Text,{}),(0,n.jsx)(j.PageSizeSelector,{}),(0,n.jsx)(j.Pagination,{})]})})}function Qt({className:e,style:t,visibleMediaQuery:i,record:a,index:o,onClick:s,onDoubleClick:c,onContextMenu:l,noWrap:u,ellipsis:d,textAlign:f,width:p,accessor:m,render:h,defaultRender:g,customCellAttributes:_}){return J(i)?(0,n.jsx)(r.TableTd,{className:G({[wt]:u||d,[Tt]:d,[X]:s||c,[Et]:l,[Z]:f===`left`,[Q]:f===`center`,[Ot]:f===`right`},e),style:[{width:p,minWidth:p,maxWidth:p},t],onClick:s,onDoubleClick:c,onContextMenu:l,..._?.(a,o),children:h?h(a,o):g?g(a,o,m):gt(a,m)}):null}function $t({open:e,colSpan:t,content:i,collapseProps:a}){let{expanded:o,visible:s}=Ct(e,a?.transitionDuration);return s?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.TableTr,{}),(0,n.jsx)(r.TableTr,{children:(0,n.jsx)(r.TableTd,{className:`mantine-datatable-row-expansion-cell`,colSpan:t,children:(0,n.jsx)(r.Collapse,{in:o,...a,children:(0,n.jsx)(`div`,{className:`mantine-datatable-row-expansion-cell-content`,children:i()})})})})]}):null}function en({className:e,style:t,record:i,index:a,trigger:o,onChange:s,withRightShadow:c,checkboxProps:l,getCheckboxProps:u,...d}){let f={...l,...u(i,a)},p=!d.disabled&&!f.disabled,m=e=>{e.stopPropagation(),o===`cell`&&p&&s?.(e)};return(0,n.jsx)(r.TableTd,{className:G(`mantine-datatable-row-selector-cell`,{[X]:o===`cell`&&p},e),style:t,"data-shadow-visible":c||void 0,onClick:m,children:(0,n.jsx)(r.Checkbox,{classNames:p?{input:X}:void 0,onChange:s,...d,...f})})}function tn({record:e,index:t,columns:i,defaultColumnProps:a,defaultColumnRender:o,selectionTrigger:s,selectionVisible:c,selectionChecked:l,onSelectionChange:u,isRecordSelectable:d,selectionCheckboxProps:f,getSelectionCheckboxProps:p,onClick:m,onDoubleClick:h,onContextMenu:g,onCellClick:_,onCellDoubleClick:v,onCellContextMenu:y,expansion:b,customAttributes:x,color:S,backgroundColor:C,className:w,style:T,selectorCellShadowVisible:E,selectionColumnClassName:D,selectionColumnStyle:O,rowFactory:k}){let A=(0,n.jsxs)(n.Fragment,{children:[c&&(0,n.jsx)(en,{className:D,style:O,record:e,index:t,trigger:s,withRightShadow:E,checked:l,disabled:!u||(d?!d(e,t):!1),onChange:u,checkboxProps:f,getCheckboxProps:p}),i.map(({hidden:r,hiddenContent:i,...s},c)=>{if(r||i)return null;let{accessor:l,visibleMediaQuery:u,textAlign:d,noWrap:f,ellipsis:p,width:m,render:h,cellsClassName:g,cellsStyle:b,customCellAttributes:x}={...a,...s};return(0,n.jsx)(Qt,{className:typeof g==`function`?g(e,t):g,style:b?.(e,t),visibleMediaQuery:u,record:e,index:t,onClick:_?n=>_({event:n,record:e,index:t,column:s,columnIndex:c}):void 0,onDoubleClick:v?n=>v({event:n,record:e,index:t,column:s,columnIndex:c}):void 0,onContextMenu:y?n=>y({event:n,record:e,index:t,column:s,columnIndex:c}):void 0,accessor:l,textAlign:d,noWrap:f,ellipsis:p,width:m,render:h,defaultRender:o,customCellAttributes:x},l)})]}),j=b&&(0,n.jsx)($t,{colSpan:i.filter(({hidden:e})=>!e).length+ +!!c,open:b.isRowExpanded(e),content:b.content({record:e,index:t}),collapseProps:b.collapseProps}),M=nn({record:e,index:t,selectionChecked:l,onClick:m,onDoubleClick:h,onContextMenu:g,expansion:b,customAttributes:x,color:S,backgroundColor:C,className:w,style:T});return k?k({record:e,index:t,rowProps:M,children:A,expandedElement:j}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.TableTr,{...M,children:A}),j]})}function nn({record:e,index:t,selectionChecked:n,onClick:r,onDoubleClick:i,onContextMenu:a,expansion:o,customAttributes:s,color:c,backgroundColor:l,className:u,style:d}){return{className:G(`mantine-datatable-row`,{[X]:r||i||o?.isExpandable({record:e,index:t})&&o?.expandOnClick},{[Et]:a},typeof u==`function`?u(e,t):u),"data-selected":n||void 0,onClick:n=>{if(o){let{isExpandable:n,isRowExpanded:r,expandOnClick:i,expandRow:a,collapseRow:s}=o;n({record:e,index:t})&&i&&(r(e)?s(e):a(e))}r?.({event:n,record:e,index:t})},onDoubleClick:i?n=>i({event:n,record:e,index:t}):void 0,onContextMenu:a?n=>a({event:n,record:e,index:t}):void 0,style:[c||l?n=>{let r=c?.(e,t),i=l?.(e,t);return qt({theme:n,color:r,backgroundColor:i})}:void 0,d?.(e,t)],...s?.(e,t)??{}}}function rn({leftShadowBehind:e,rightShadowBehind:t,onScrollPositionChange:i,children:a,viewportRef:o,scrollAreaProps:s}){return(0,n.jsxs)(r.ScrollArea,{...s,viewportRef:o,classNames:{root:`mantine-datatable-scroll-area`,scrollbar:`mantine-datatable-scroll-area-scrollbar`,thumb:`mantine-datatable-scroll-area-thumb`,corner:`mantine-datatable-scroll-area-corner`},onScrollPositionChange:i,children:[a,(0,n.jsx)(r.Box,{className:G(`mantine-datatable-scroll-area-shadow`,`mantine-datatable-scroll-area-top-shadow`)}),(0,n.jsx)(`div`,{className:G(`mantine-datatable-scroll-area-shadow`,`mantine-datatable-scroll-area-left-shadow`,{"mantine-datatable-scroll-area-shadow-behind":e})}),(0,n.jsx)(`div`,{className:G(`mantine-datatable-scroll-area-shadow`,`mantine-datatable-scroll-area-right-shadow`,{"mantine-datatable-scroll-area-shadow-behind":t})}),(0,n.jsx)(r.Box,{className:G(`mantine-datatable-scroll-area-shadow`,`mantine-datatable-scroll-area-bottom-shadow`)})]})}function an({withTableBorder:e,borderRadius:i,textSelectionDisabled:a,height:o=`100%`,minHeight:c,maxHeight:l,shadow:u,verticalAlign:d=`center`,fetching:f,columns:p,storeColumnsKey:m,groups:h,pinFirstColumn:g,pinLastColumn:_,defaultColumnProps:v,defaultColumnRender:y,idAccessor:b=`id`,records:x,selectionTrigger:S=`checkbox`,selectedRecords:C,onSelectedRecordsChange:w,selectionColumnClassName:T,selectionColumnStyle:E,isRecordSelectable:D,selectionCheckboxProps:O,allRecordsSelectionCheckboxProps:k={"aria-label":`Select all records`},getRecordSelectionCheckboxProps:A=(e,t)=>({"aria-label":`Select record ${t+1}`}),sortStatus:j,sortIcons:M,onSortStatusChange:ee,horizontalSpacing:N,page:P,onPageChange:F,totalRecords:te,recordsPerPage:ne,onRecordsPerPageChange:re,recordsPerPageOptions:ie,recordsPerPageLabel:I=`Records per page`,paginationWithEdges:ae,paginationWithControls:oe,paginationActiveTextColor:se,paginationActiveBackgroundColor:ce,paginationSize:le=`sm`,paginationText:ue=({from:e,to:t,totalRecords:n})=>`${e} - ${t} / ${n}`,paginationWrapBreakpoint:L=`sm`,getPaginationControlProps:de=e=>e===`previous`?{"aria-label":`Previous page`}:e===`next`?{"aria-label":`Next page`}:{},getPaginationItemProps:fe,renderPagination:R,loaderBackgroundBlur:z,customLoader:pe,loaderSize:me,loaderType:he,loaderColor:ge,loadingText:B=`...`,emptyState:V,noRecordsText:_e=`No records`,noRecordsIcon:ve,highlightOnHover:ye,striped:be,noHeader:xe,onRowClick:Se,onRowDoubleClick:Ce,onRowContextMenu:we,onCellClick:H,onCellDoubleClick:Te,onCellContextMenu:Ee,onScroll:De,onScrollToTop:Oe,onScrollToBottom:ke,onScrollToLeft:U,onScrollToRight:Ae,c:W,backgroundColor:je,borderColor:Me,rowBorderColor:Ne,stripedColor:Pe,highlightOnHoverColor:Fe,rowColor:Ie,rowBackgroundColor:Le,rowExpansion:Re,rowClassName:ze,rowStyle:Be,customRowAttributes:Ve,scrollViewportRef:He,scrollAreaProps:Ue,tableRef:We,bodyRef:Ge,m:Je,my:Xe,mx:Ze,mt:Qe,mb:et,ml:tt,mr:nt,className:rt,classNames:K,style:it,styles:q,rowFactory:at,tableWrapper:ot,...lt}){let ut=(0,t.useMemo)(()=>h?vt(h):p,[p,h]),[dt,ft]=(0,t.useState)(!1),{refs:J,onScroll:pt}=st({scrollCallbacks:{onScroll:De,onScrollToTop:Oe,onScrollToBottom:ke,onScrollToLeft:U,onScrollToRight:Ae},withRowBorders:lt.withRowBorders}),gt=$e({key:m,columns:ut,headerRef:J.header,scrollViewportRef:J.scrollViewport,onFixedLayoutChange:ft}),_t=(0,s.useMergedRef)(J.table,We),yt=(0,s.useMergedRef)(J.scrollViewport,He),bt=St({rowExpansion:Re,records:x,idAccessor:b}),xt=(0,t.useRef)(!1),Ct=(0,t.useRef)(P),wt=(0,t.useRef)(x),Tt=(0,t.useCallback)(e=>{xt.current=!0,wt.current=x,F(e)},[F,x]);(0,t.useEffect)(()=>{Ct.current!==P&&(xt.current=!0,wt.current=x,Ct.current=P)},[P,x]);let X=x?.length;(0,t.useLayoutEffect)(()=>{if(!xt.current||f||x===wt.current)return;let e=J.scrollViewport.current;if(!e)return;let t=requestAnimationFrame(()=>{e.scrollTo({top:0,left:0}),xt.current=!1});return()=>cancelAnimationFrame(t)},[f,x,J.scrollViewport]);let Et=x?.map(e=>Y(e,b)),Z=!!C,Q=C?.map(e=>Y(e,b)),Ot=Et!==void 0&&Q!==void 0&&Q.length>0,kt=D?x?.filter(D):x,At=kt?.map(e=>Y(e,b)),Mt=Ot&&At.every(e=>Q.includes(e)),Nt=Ot&&At.some(e=>Q.includes(e)),Pt=(0,t.useCallback)(()=>{C&&w&&w(Mt?C.filter(e=>!At.includes(Y(e,b))):ht([...C,...kt],e=>Y(e,b)))},[Mt,b,w,At,kt,C]),{lastSelectionChangeIndex:Ft,setLastSelectionChangeIndex:It}=ct(Et),Lt=Z&&!g,Rt={m:Je,my:Xe,mx:Ze,mt:Qe,mb:et,ml:tt,mr:nt},zt=(0,t.useCallback)(({children:e})=>ot?ot({children:e}):e,[ot]);return(0,n.jsx)(Ke,{...gt,children:(0,n.jsxs)(r.Box,{ref:J.root,...Rt,className:G(`mantine-datatable`,{"mantine-datatable-with-border":e},rt,K?.root),style:[e=>({...Gt({theme:e,c:W,backgroundColor:je,borderColor:Me,rowBorderColor:Ne,stripedColor:Pe,highlightOnHoverColor:Fe}),borderRadius:e.radius[i]||i,boxShadow:e.shadows[u]||u,height:o,minHeight:c,maxHeight:l}),it,q?.root,{position:`relative`}],children:[(0,n.jsx)(rn,{viewportRef:yt,leftShadowBehind:Z||!!g,rightShadowBehind:_,onScrollPositionChange:pt,scrollAreaProps:Ue,children:(0,n.jsx)(zt,{children:(0,n.jsxs)(r.Table,{ref:_t,horizontalSpacing:N,className:G(`mantine-datatable-table`,{[Dt]:a,"mantine-datatable-vertical-align-top":d===`top`,"mantine-datatable-vertical-align-bottom":d===`bottom`,"mantine-datatable-pin-last-column":_,"mantine-datatable-selection-column-visible":Z,"mantine-datatable-pin-first-column":g,"mantine-datatable-resizable-columns":gt.hasResizableColumns&&dt},K?.table),style:{...q?.table},"data-striped":X&&be||void 0,"data-highlight-on-hover":ye||void 0,...lt,children:[xe?null:(0,n.jsx)(Ke,{...gt,children:(0,n.jsx)(Ut,{ref:J.header,selectionColumnHeaderRef:J.selectionColumnHeader,className:K?.header,style:q?.header,columns:ut,defaultColumnProps:v,groups:h,sortStatus:j,sortIcons:M,onSortStatusChange:ee,selectionTrigger:S,selectionVisible:Z,selectionChecked:Mt,selectionIndeterminate:Nt&&!Mt,onSelectionChange:Pt,selectionCheckboxProps:{...O,...k},selectorCellShadowVisible:Lt,selectionColumnClassName:T,selectionColumnStyle:E,withColumnBorders:lt.withColumnBorders})}),(0,n.jsx)(`tbody`,{ref:Ge,children:X?x.map((e,t)=>{let r=Y(e,b),i=Q?.includes(r)||!1,a;return w&&C&&(a=n=>{if(n.nativeEvent.shiftKey&&Ft!==null){let e=x.filter(t>Ft?(e,n)=>n>=Ft&&n<=t&&(D?D(e,n):!0):(e,n)=>n>=t&&n<=Ft&&(D?D(e,n):!0));w(i?mt(C,e,e=>Y(e,b)):ht([...C,...e],e=>Y(e,b)))}else w(i?C.filter(e=>Y(e,b)!==r):ht([...C,e],e=>Y(e,b)));It(t)}),(0,n.jsx)(tn,{record:e,index:t,columns:ut,defaultColumnProps:v,defaultColumnRender:y,selectionTrigger:S,selectionVisible:Z,selectionChecked:i,onSelectionChange:a,isRecordSelectable:D,selectionCheckboxProps:O,getSelectionCheckboxProps:A,onClick:Se,onDoubleClick:Ce,onCellClick:H,onCellDoubleClick:Te,onContextMenu:we,onCellContextMenu:Ee,expansion:bt,color:Ie,backgroundColor:Le,className:ze,style:Be,customAttributes:Ve,selectorCellShadowVisible:Lt,selectionColumnClassName:T,selectionColumnStyle:E,idAccessor:b,rowFactory:at},r)}):(0,n.jsx)(qe,{})}),ut.some(({footer:e})=>e)&&(0,n.jsx)(jt,{ref:J.footer,className:K?.footer,style:q?.footer,columns:ut,defaultColumnProps:v,selectionVisible:Z,selectorCellShadowVisible:Lt})]})})}),!!(P&&X)&&(0,n.jsx)(Zt,{className:K?.pagination,style:q?.pagination,horizontalSpacing:N,fetching:f,page:P,onPageChange:Tt,totalRecords:te,recordsPerPage:ne,onRecordsPerPageChange:re,recordsPerPageOptions:ie,recordsPerPageLabel:I,paginationWithEdges:ae,paginationWithControls:oe,paginationActiveTextColor:se,paginationActiveBackgroundColor:ce,paginationSize:le,paginationText:ue,paginationWrapBreakpoint:L,getPaginationControlProps:de,getPaginationItemProps:fe,noRecordsText:_e,loadingText:B,recordsLength:X,renderPagination:R}),(0,n.jsx)(Wt,{fetching:f,backgroundBlur:z,customContent:pe,size:me,type:he,color:ge}),(0,n.jsx)(Ye,{icon:ve,text:_e,active:!f&&!X,children:V})]})})}function on({fields:e,onClose:o,queryKey:s,apiPath:c,id:l,steps:u}){let[d,f]=(0,t.useState)(0),[p,m]=(0,t.useState)(!1),{data:h,isLoading:g}=Le(c,s,l),{mutateAsync:_,isError:v,error:y,isPending:b}=Be(c,s),x=[...new Set(e.filter(e=>typeof e.step==`number`).map(e=>e.step))],S=(0,i.useForm)({mode:`uncontrolled`,initialValues:e.reduce((e,t)=>(e[t.id]=t.type===`boolean`?t.defaultValue??!1:t.defaultValue??``,e),{}),validate:e.filter(e=>e.required).reduce((e,t)=>(e[t.id]=(e,n)=>t.conditional&&!t.conditional(n)||!(typeof t.required==`function`?t.required(n):t.required)||e?null:`Pflichtfeld`,e),{})});(0,t.useEffect)(()=>{if(h){let t={...h};e.forEach(e=>{let n=e.id;e.type===`boolean`&&t[n]===null?t[n]=!1:e.type===`date`&&t[n]?t[n]=new Date(t[n]):t[n]===null&&(t[n]=``)}),S.initialize(t),S.setValues(t)}},[h]);function C(e,t){return typeof e.required==`function`?e.required(t??{}):!!e.required}function w(e){let i=S.getValues();if(e.conditional&&!e.conditional(i))return null;let o=C(e,i);return(0,n.jsxs)(t.Fragment,{children:[(e.type===void 0||e.type==`text`)&&(0,n.jsx)(r.TextInput,{label:e.column.title,placeholder:e.placeholder??``,...S.getInputProps(e.id),type:e.id.includes(`email`)?`email`:void 0,required:o},S.key(e.id)),e.type===`number`&&(0,n.jsx)(r.NumberInput,{decimalSeparator:`,`,label:e.column.title,placeholder:e.placeholder??``,...S.getInputProps(e.id),required:o},S.key(e.id)),e.type===`date`&&(0,n.jsx)(a.DateInput,{label:e.column.title,placeholder:e.placeholder??``,valueFormat:`DD.MM.YYYY`,clearable:!0,...S.getInputProps(e.id),required:o},S.key(e.id)),e.type===`boolean`&&(0,n.jsx)(r.Checkbox,{mt:`md`,label:e.column.title,...S.getInputProps(e.id,{type:`checkbox`}),required:o},S.key(e.id)),e.type===`textarea`&&(0,n.jsx)(r.Textarea,{label:e.column.title,placeholder:e.placeholder??``,...S.getInputProps(e.id),minRows:3,autosize:!0,required:o},S.key(e.id)),e.type===`custom`&&e.render&&e.render({...S.getValues(),id:l},S.setValues,m,{error:S.getInputProps(e.id).error,required:o})]},e.id)}return(0,n.jsxs)(n.Fragment,{children:[v&&(0,n.jsx)(r.Alert,{variant:`outline`,color:`red`,title:y?.name??`Fehler aufgetreten`,mb:`lg`,children:y?.message??`Fehler aufgetreten`}),g?(0,n.jsxs)(r.Stack,{gap:`md`,children:[(0,n.jsx)(r.Skeleton,{height:40}),Array(e.length).fill(0).map((e,t)=>(0,n.jsx)(r.Skeleton,{height:35},`skeleton-field-${t}`)),(0,n.jsxs)(r.Group,{mt:`md`,justify:`end`,children:[(0,n.jsx)(r.Skeleton,{width:100,height:36}),(0,n.jsx)(r.Skeleton,{width:100,height:36})]})]}):(0,n.jsxs)(`form`,{onSubmit:S.onSubmit(async e=>{let t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t===``?void 0:t]));await _({...t,id:l}),x.length&&d<x.length-1?v||f(d+1):v||(S.setInitialValues(t),S.reset(),o())}),children:[x.length?(0,n.jsx)(r.Stepper,{active:d,size:`sm`,children:x.map(t=>(0,n.jsx)(r.Stepper.Step,{...u&&u[t-1]?{label:u[t-1].label}:{},children:e.filter(e=>e.step===t).map(e=>w(e))},t))}):e.map(e=>w(e)),!p&&(0,n.jsxs)(r.Group,{mt:`md`,justify:`end`,children:[(0,n.jsx)(r.Button,{onClick:()=>x.length?d===0?o():f(d-1):o(),variant:`outline`,children:x.length?d===0?`Abbrechen`:`Zurück`:`Abbrechen`}),(0,n.jsx)(r.Button,{type:`submit`,loading:b,children:x.length?d===x.length-1?`Speichern`:`Weiter`:`Speichern`})]})]})]})}function sn({queryKey:e,apiPath:i,onClose:a,selectedRecords:o}){let{mutateAsync:s,isError:c,error:l,isPending:u}=Ve(i,e),[d,f]=(0,t.useState)(o),[p,m]=(0,t.useState)(!1),h=p||u;return(0,t.useEffect)(()=>{d.length||a()},[a,d]),d.length?(0,n.jsxs)(n.Fragment,{children:[c&&l.message&&(0,n.jsx)(r.Alert,{variant:`outline`,color:`red`,title:l.name,children:l.message}),(0,n.jsx)(r.Text,{children:d.length===1?`Soll ${d.length} Eintrag wirklich gelöscht werden?`:`Sollen ${d.length} Einträge wirklich gelöscht werden?`}),(0,n.jsxs)(r.Group,{mt:`md`,justify:`end`,children:[(0,n.jsx)(r.Button,{onClick:a,variant:`outline`,disabled:h,children:`Abbrechen`}),(0,n.jsx)(r.Button,{color:`red`,loading:h,onClick:async()=>{m(!0);try{await Promise.all(d.map(e=>s(e.id))),f([])}finally{m(!1)}},children:`Löschen`})]})]}):(0,n.jsx)(n.Fragment,{})}function cn(e,n){let[r,i]=(0,t.useState)(()=>{let t=localStorage.getItem(`use_persistent_storage_${n}`);return t?JSON.parse(t):e});return[r,e=>{i(e),localStorage.setItem(`use_persistent_storage_${n}`,JSON.stringify(e))}]}var ln=[/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,/^\d{4}-\d{2}-\d{2}$/,/^\d{1,2}\/\d{1,2}\/\d{4}$/,/^\d{1,2}\.\d{1,2}\.\d{4}$/],un=(e,t)=>{let n=e.map(e=>e[t]).filter(e=>e!=null&&e!==``);if(n.length===0)return`string`;let r=n.slice(0,100),i={string:0,number:0,date:0};r.forEach(e=>{if(typeof e==`number`)i.number++;else if(typeof e==`string`){let t=e.trim();if(t!==``&&!isNaN(Number(t))&&!isNaN(parseFloat(t))){i.number++;return}if(ln.some(e=>e.test(t))){let e=new Date(t);if(!isNaN(e.getTime())){i.date++;return}}i.string++}else e instanceof Date?i.date++:i.string++});let a=i.string+i.number+i.date;return i.date/a>=.6?`date`:i.number/a>=.6?`number`:i.string/a>=.6?`string`:`mixed`};function dn(e,t){switch(t){case`date`:if(typeof e==`string`){let t=new Date(e.trim());return isNaN(t.getTime())?null:t.getTime()}return e instanceof Date?e.getTime():null;case`number`:if(typeof e==`number`)return e;let t=parseFloat(String(e).trim());return isNaN(t)?null:t;case`string`:return(typeof e==`string`?e:String(e)).toLowerCase().trim();default:return String(e).toLowerCase().trim()}}var fn=(e,t,n=`asc`)=>{if(!e||e.length===0)return[];let r=un(e,t);return[...e].sort((e,i)=>{let a=e[t],o=i[t],s=a==null||a===``,c=o==null||o===``;if(s&&c)return 0;if(s)return n===`asc`?-1:1;if(c)return n===`asc`?1:-1;let l=dn(a,r),u=dn(o,r);return l===null&&u===null?0:l===null?n===`asc`?1:-1:u===null||l<u?n===`asc`?-1:1:l>u?n===`asc`?1:-1:0})};function pn(e,t){return t.split(`.`).reduce((e,t)=>{if(e&&typeof e==`object`&&t in e)return e[t]},e)}function mn(e,t){let i=t.column;if(i.render)return i.render(e,0);let a=pn(e,i.accessor??t.id);return a==null?(0,n.jsx)(r.Text,{c:`dimmed`,children:`–`}):typeof a==`boolean`?(0,n.jsx)(r.Text,{fz:`sm`,children:a?`Ja`:`Nein`}):(0,n.jsx)(r.Text,{fz:`sm`,children:String(a)})}function hn({field:e,record:t}){return(0,n.jsxs)(r.Group,{wrap:`nowrap`,justify:`space-between`,align:`center`,py:`xs`,px:`sm`,children:[(0,n.jsx)(r.Text,{fw:700,fz:`sm`,children:e.column.title??e.id}),(0,n.jsx)(r.Box,{ta:`right`,fz:`sm`,children:mn(t,e)})]})}function gn({records:e,fields:i,selection:a,selectedRecords:s=[],onSelectedRecordsChange:c,onRowClick:l,actions:u,canUpdate:d,canDelete:f,pagination:p,sort:m,rowExpansion:h}){let[g,_]=(0,t.useState)(new Set),v=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},y=i.filter(e=>e.list&&e.column),b=y.filter(e=>e.column.sortable!==!1).reduce((e,t)=>{let n=t.column.accessor??t.id;return e.some(e=>e.value===n)||e.push({value:n,label:t.column.title??t.id}),e},[]),x=e=>s.some(t=>t.id===e.id),S=e=>{c&&(x(e)?c(s.filter(t=>t.id!==e.id)):c([...s,e]))},C=(e,t,n)=>{l?l({record:e,index:t,event:n}):a&&S(e)};return e.length===0?(0,n.jsx)(r.Text,{c:`dimmed`,ta:`center`,py:`xl`,children:`Keine Einträge gefunden`}):(0,n.jsxs)(r.Stack,{gap:`sm`,my:`md`,children:[m&&b.length>0&&(0,n.jsxs)(r.Group,{gap:`xs`,wrap:`nowrap`,children:[(0,n.jsx)(r.Select,{data:b,value:m.field,onChange:e=>e&&m.onSortChange(e,m.direction),allowDeselect:!1,style:{flex:1}}),(0,n.jsx)(r.ActionIcon,{variant:`filled`,size:`input-sm`,onClick:()=>m.onSortChange(m.field,m.direction===`asc`?`desc`:`asc`),children:m.direction===`asc`?(0,n.jsx)(o.IconSortAscending,{size:18}):(0,n.jsx)(o.IconSortDescending,{size:18})})]}),e.map((e,i)=>{let s=x(e),c=!!l||!!a,p=e.id??i,m=g.has(p);return(0,n.jsx)(t.default.Fragment,{children:(0,n.jsxs)(r.Box,{bg:s?`var(--mantine-primary-color-light)`:`var(--mantine-color-body)`,bd:s?void 0:`1px solid var(--mantine-color-default-border)`,style:{borderRadius:`var(--mantine-radius-md)`,overflow:`hidden`},children:[(0,n.jsxs)(r.Box,{w:`100%`,style:{cursor:c||h?`pointer`:`default`},onClick:t=>{h&&!l?v(p):C(e,i,t)},children:[(a||h||u&&u.length>0)&&(0,n.jsxs)(r.Group,{px:`sm`,pt:`sm`,justify:`space-between`,children:[(0,n.jsxs)(r.Group,{gap:`xs`,children:[h&&(0,n.jsx)(r.Box,{c:`var(--mantine-primary-color-filled)`,style:{cursor:`pointer`,display:`flex`,alignItems:`center`},onClick:e=>{e.stopPropagation(),v(p)},children:(0,n.jsx)(o.IconChevronDown,{size:16,style:{transform:m?`rotate(0deg)`:`rotate(-90deg)`,transition:`transform 200ms`}})}),a&&(0,n.jsx)(r.Checkbox,{checked:s,onChange:()=>S(e),onClick:e=>e.stopPropagation()})]}),u&&u.length>0&&(()=>{let t=u.filter(t=>!(t.label===`Bearbeiten`&&d&&!d(e)||t.label===`Löschen`&&f&&!f(e)));return t.length===0?null:(0,n.jsxs)(r.Menu,{shadow:`md`,position:`bottom-end`,children:[(0,n.jsx)(r.Menu.Target,{children:(0,n.jsx)(r.ActionIcon,{variant:`subtle`,color:`gray`,size:`sm`,onClick:e=>e.stopPropagation(),children:(0,n.jsx)(o.IconDotsVertical,{size:16})})}),(0,n.jsx)(r.Menu.Dropdown,{children:t.map((t,i)=>(0,n.jsx)(r.Menu.Item,{leftSection:t.icon,onClick:n=>{n.stopPropagation(),t.onClick([e])},children:t.label},`card_action_${i}`))})]})})()]}),y.map((i,a)=>(0,n.jsxs)(t.default.Fragment,{children:[a>0&&(0,n.jsx)(r.Divider,{}),(0,n.jsx)(hn,{field:i,record:e})]},i.id))]}),h&&(0,n.jsxs)(r.Collapse,{expanded:m,children:[(0,n.jsx)(r.Divider,{}),(0,n.jsx)(r.Box,{px:`sm`,py:`sm`,children:h.content(e)})]})]})},p)}),p&&p.totalRecords>p.recordsPerPage&&(0,n.jsxs)(r.Stack,{gap:`xs`,mt:`sm`,children:[(0,n.jsx)(r.Group,{justify:`center`,children:(0,n.jsx)(r.Pagination,{total:Math.ceil(p.totalRecords/p.recordsPerPage),value:p.page,onChange:p.onPageChange,size:`sm`})}),p.recordsPerPageOptions&&p.onRecordsPerPageChange&&(0,n.jsxs)(r.Group,{justify:`center`,gap:`xs`,children:[(0,n.jsx)(r.Text,{fz:`xs`,c:`dimmed`,children:`Einträge pro Seite:`}),(0,n.jsx)(r.Select,{data:p.recordsPerPageOptions.map(e=>({value:String(e),label:String(e)})),value:String(p.recordsPerPage),onChange:e=>e&&p.onRecordsPerPageChange(Number(e)),allowDeselect:!1,size:`xs`,w:70})]})]})]})}var _n=[10,15,50,100,500];function vn({title:e,queryKey:i,connectedQueryKeys:a,apiPath:s,mutationApiPath:c,buttons:l,fields:u,selection:d,pagination:f,filters:p,actions:m,steps:h,defaultSort:g,onSortChange:_,createButtonText:v,queryParams:y,tabs:b,defaultTab:x,activeTab:S,onActiveTabChange:C,canUpdate:w,canDelete:T,showRefresh:E=!0,rowExpansion:D,onRowClick:O,mobileCards:k=!1}){let[A,j]=(0,t.useState)(x||(b&&b.length>0?b[0].value:null)),M=S===void 0?A:S,ee=e=>{S===void 0&&j(e),C&&C(e)},N=b?.find(e=>e.value===M),P=N?.queryParams||{},F=N?.apiPath??s,te=N?.mutationApiPath??c??F,ne={...y,...P},re=ne?`?`+Object.entries(ne).filter(([,e])=>e!=null).map(([e,t])=>`${e}=${encodeURIComponent(t??``)}`).join(`&`):``,ie=M?[...i,M]:i,{data:I,isLoading:ae,isError:oe,isRefetching:se,refetch:ce}=Re(F+re,ie),{queryClient:le}=U();(0,t.useEffect)(()=>{!I||!Array.isArray(I)||a?.forEach(e=>le.invalidateQueries({queryKey:e}))},[I,a,le]);let ue=!I||!Array.isArray(I)?[]:!p||p.length===0?I:I.filter(e=>p.every(t=>{if(t.value===void 0)return!0;let n=t.id;if(t.type===`query`){let r=e[n];return Array.isArray(t.value)?Array.isArray(r)?r.some(e=>{if(typeof e==`string`||typeof e==`number`)return t.value.includes(String(e));if(e&&typeof e==`object`){let n=e;if(`id`in n&&t.value.includes(n.id))return!0;for(let e in n){let r=n[e];if(typeof r==`string`&&t.value.includes(r)||r&&typeof r==`object`&&`id`in r&&t.value.includes(r.id))return!0}}return!1}):r&&typeof r==`object`&&`id`in r?t.value.includes(r.id):!1:typeof r==`string`&&r.includes(t.value)}else if(t.type===`date`){let r=t.value;if(!r)return!0;let[i,a]=r;if(!i&&!a)return!0;let o=e[n];if(typeof o==`string`){let e=o.split(` `)[0];if(i&&a)return e>=i&&e<=a;if(i&&!a)return e>=i;if(!i&&a)return e<=a}return!0}else if(t.type===`boolean`)return e[n]===t.value;return!0})),[L,de]=(0,t.useState)({columnAccessor:g?.field??u[0].id,direction:g?.direction??`desc`}),fe=e=>{de(e),_&&_(String(e.columnAccessor),e.direction)},R=fn(ue,L.columnAccessor,L.direction),[z,pe]=cn(_n[1],`mantine-table-page-size`),[me,he]=(0,t.useState)(1),ge=f?R.slice((me-1)*z,me*z):R,[B,V]=(0,t.useState)([]);(0,t.useEffect)(()=>{V([])},[M]);let[_e,ve]=(0,t.useState)(!1),[ye,be]=(0,t.useState)(!1),[xe,Se]=(0,t.useState)(!1),Ce=u.some(e=>e.update),we=u.some(e=>e.delete),H=[];return Ce&&H.push({icon:(0,n.jsx)(o.IconPencil,{size:14}),label:`Bearbeiten`,onClick:e=>{V(e),be(!0)}}),m&&H.push(...m),we&&H.push({icon:(0,n.jsx)(o.IconTrash,{size:14}),label:`Löschen`,onClick:e=>{V(e),Se(!0)}}),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(r.Group,{gap:`xs`,justify:e?`space-between`:`end`,align:`center`,wrap:`wrap`,children:[e&&(typeof e==`string`?(0,n.jsx)(r.Title,{order:4,children:e}):e),(0,n.jsxs)(r.Group,{align:`center`,gap:`xs`,wrap:`wrap`,justify:`end`,style:{marginLeft:`auto`},children:[E&&(0,n.jsx)(r.ActionIcon,{variant:`subtle`,onClick:()=>ce(),"aria-label":`Neuladen`,children:(0,n.jsx)(o.IconRefresh,{})}),(u.some(e=>e.update)||d)&&(()=>{let e=u.find(e=>e.update)&&(!w||B.length>0&&w(B[0])),i=u.find(e=>e.delete)&&(!T||B.length>0&&T(B[0])),a=(m??[]).length>0,s=e||i||a;return(0,n.jsx)(r.Box,{...k?{visibleFrom:`sm`}:{},children:(0,n.jsxs)(r.Menu,{shadow:`md`,children:[(0,n.jsx)(r.Menu.Target,{children:(0,n.jsx)(r.Button,{variant:`outline`,rightSection:(0,n.jsx)(o.IconCaretDownFilled,{size:14}),disabled:!B.length||!s,children:`Aktionen`})}),(0,n.jsxs)(r.Menu.Dropdown,{children:[e&&(0,n.jsx)(r.Menu.Item,{leftSection:(0,n.jsx)(o.IconPencil,{size:14}),onClick:()=>be(!0),disabled:B.length!==1,children:`Bearbeiten`}),(m??[]).map((e,n)=>(0,t.createElement)(r.Menu.Item,{...e.icon&&{leftSection:e.icon},key:`custom_action_${n}`,onClick:()=>e.onClick(B),disabled:e.disabled?.(B)??!1},e.label)),i&&(0,n.jsx)(r.Menu.Item,{leftSection:(0,n.jsx)(o.IconTrash,{size:14}),onClick:()=>Se(!0),color:`red`,children:`Löschen`})]})]})})})(),u.find(e=>e.create)&&(0,n.jsx)(r.Button,{onClick:()=>ve(!0),disabled:ae,children:v??`Erstellen`}),l]})]}),b&&b.length>0&&(0,n.jsx)(r.Tabs,{value:M,onChange:ee,mt:`md`,children:(0,n.jsx)(r.Tabs.List,{children:b.map(e=>(0,n.jsx)(r.Tabs.Tab,{value:e.value,leftSection:e.icon,children:e.label},e.value))})}),oe&&(0,n.jsx)(r.Alert,{mt:`md`,variant:`light`,color:`red`,title:`Es ist ein Fehler aufgetreten.`,icon:(0,n.jsx)(o.IconInfoCircle,{}),children:`Bitte versuche es später erneut oder sende eine Nachricht an unseren Support.`}),(ae||se)&&(0,n.jsxs)(r.Stack,{my:`md`,children:[(0,n.jsx)(r.Skeleton,{height:40}),[,,,,,].fill(0).map((e,t)=>(0,n.jsx)(r.Skeleton,{height:35},`skeleton-${t}`))]}),!ae&&!se&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.Box,{...k?{visibleFrom:`sm`}:{},children:(0,n.jsx)(an,{my:`md`,striped:!0,highlightOnHover:!0,minHeight:150,fetching:oe,records:ge,sortStatus:L,onSortStatusChange:fe,...d&&{selectedRecords:B,onSelectedRecordsChange:V},...f&&ge.length&&{totalRecords:R.length,recordsPerPage:z,onPageChange:he,page:me,recordsPerPageOptions:_n,onRecordsPerPageChange:pe,recordsPerPageLabel:`Einträge pro Seite`},...D&&{rowExpansion:{allowMultiple:D.allowMultiple??!1,content:({record:e})=>D.content(e),...D.expanded&&{expanded:D.expanded}}},columns:u.map(e=>e.column),noRecordsText:`Keine Einträge gefunden`,onRowClick:O,...O&&{style:{cursor:`pointer`}}})}),k&&(0,n.jsx)(r.Box,{hiddenFrom:`sm`,children:(0,n.jsx)(gn,{records:ge,fields:u,selection:d,selectedRecords:B,onSelectedRecordsChange:V,onRowClick:O,sort:{field:String(L.columnAccessor),direction:L.direction,onSortChange:(e,t)=>{fe({columnAccessor:e,direction:t})}},...f&&ge.length&&{pagination:{totalRecords:R.length,recordsPerPage:z,page:me,onPageChange:he,recordsPerPageOptions:_n,onRecordsPerPageChange:e=>{pe(e),he(1)}}},...D&&{rowExpansion:{content:D.content}},...H.length>0&&{actions:H,canUpdate:w,canDelete:T}})})]}),(0,n.jsx)(r.Modal,{opened:ye,onClose:()=>{be(!1),V([])},title:e??`Bearbeiten`,children:B.length>0&&(0,n.jsx)(on,{fields:u.filter(e=>e.update),queryKey:i,apiPath:te,id:B[0].id,onClose:()=>{be(!1),V([])},steps:h})}),B.length>0&&(0,n.jsx)(r.Modal,{opened:xe,onClose:()=>{Se(!1),V([])},title:e??`Löschen`,children:(0,n.jsx)(sn,{onClose:()=>{Se(!1),V([])},queryKey:i,apiPath:te,selectedRecords:B})}),(0,n.jsx)(r.Modal,{opened:_e,onClose:()=>{ve(!1)},title:e??`Anlegen`,children:(0,n.jsx)(He,{queryKey:i,apiPath:te,onClose:()=>{ve(!1)},fields:u.filter(e=>e.create),steps:h})})]})}function yn(e){return(0,n.jsx)(vn,{...e})}e.CreateModal=He,e.DataTable=yn,e.DataTableProvider=ke,e.DeleteModal=sn,e.MobileCardList=gn,e.UpdateModal=on,e.api=Fe,e.createOne=Pe,e.deleteOne=Ne,e.getAll=je,e.getOne=Me,e.parseApiError=Ae,e.sortData=fn,e.updateOne=Ie,e.useAddOne=ze,e.useDataTable=U,e.useDeleteOne=Ve,e.useGetAll=Re,e.useGetOne=Le,e.usePersistentState=cn,e.useUpdateOne=Be});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`react`),require(`react/jsx-runtime`),require(`@mantine/core`),require(`@mantine/form`),require(`@mantine/dates`),require(`@tabler/icons-react`),require(`@mantine/hooks`)):typeof define==`function`&&define.amd?define([`exports`,`react`,`react/jsx-runtime`,`@mantine/core`,`@mantine/form`,`@mantine/dates`,`@tabler/icons-react`,`@mantine/hooks`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MantineDataTable={},e.React,e.react_jsx_runtime,e.MantineCore,e.MantineForm,e._mantine_dates,e.TablerIconsReact,e.MantineHooks))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=Object.create,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=d(t),a=0,o=i.length,s;a<o;a++)s=i[a],!p.call(e,s)&&s!==n&&l(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=u(t,s))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:c(f(e)),m(t||!e||!e.__esModule?l(n,`default`,{value:e,enumerable:!0}):n,e)))(t,1);var h=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},g=new class extends h{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},_={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},v=new class{#e=_;#t=!1;setTimeoutProvider(e){process.env.NODE_ENV!==`production`&&this.#t&&e!==this.#e&&console.error(`[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,{previous:this.#e,provider:e}),this.#e=e,process.env.NODE_ENV!==`production`&&(this.#t=!1)}setTimeout(e,t){return process.env.NODE_ENV!==`production`&&(this.#t=!0),this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!==`production`&&(this.#t=!0),this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function y(e){setTimeout(e,0)}var b=typeof window>`u`||`Deno`in globalThis;function x(){}function S(e){return typeof e==`number`&&e>=0&&e!==1/0}function C(e,t){return Math.max(e+(t||0)-Date.now(),0)}function w(e,t){return typeof e==`function`?e(t):e}function T(e,t){return typeof e==`function`?e(t):e}function E(e){return JSON.stringify(e,(e,t)=>j(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}var D=Object.prototype.hasOwnProperty;function O(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=A(e)&&A(t);if(!r&&!(j(e)&&j(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:D.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=O(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function k(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function A(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function j(e){if(!M(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!M(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function M(e){return Object.prototype.toString.call(e)===`[object Object]`}function ee(e,t,n){if(typeof n.structuralSharing==`function`)return n.structuralSharing(e,t);if(n.structuralSharing!==!1){if(process.env.NODE_ENV!==`production`)try{return O(e,t)}catch(e){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${e}`),e}return O(e,t)}return t}function N(e,t){return typeof e==`function`?e(...t):!!e}var P=(()=>{let e=()=>b;return{isServer(){return e()},setIsServer(t){e=t}}})();function F(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var te=y;function ne(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=te,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var re=ne(),ie=new class extends h{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function I(e){return(e??`online`)===`online`?ie.isOnline():!0}function ae(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:I(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}var oe=class extends h{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=F(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),ce(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return le(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return le(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof T(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!k(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&ue(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||T(this.options.enabled,this.#t)!==T(t.enabled,this.#t)||w(this.options.staleTime,this.#t)!==w(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||T(this.options.enabled,this.#t)!==T(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return de(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(x)),t}#g(){this.#b();let e=w(this.options.staleTime,this.#t);if(P.isServer()||this.#r.isStale||!S(e))return;let t=C(this.#r.dataUpdatedAt,e)+1;this.#d=v.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(P.isServer()||T(this.options.enabled,this.#t)===!1||!S(this.#p)||this.#p===0)&&(this.#f=v.setInterval(()=>{(this.options.refetchIntervalInBackground||g.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(v.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(v.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&ce(e,t),o=i&&ue(e,n,t,r);(a||o)&&(l={...l,...ae(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=ee(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=ee(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:L(e,t),refetch:this.refetch,promise:this.#o,isEnabled:T(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=F())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!k(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){re.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function se(e,t){return T(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&T(t.retryOnMount,e)===!1)}function ce(e,t){return se(e,t)||e.state.data!==void 0&&le(e,t,t.refetchOnMount)}function le(e,t,n){if(T(t.enabled,e)!==!1&&w(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&L(e,t)}return!1}function ue(e,t,n,r){return(e!==t||T(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&L(e,n)}function L(e,t){return T(t.enabled,e)!==!1&&e.isStaleByTime(w(t.staleTime,e))}function de(e,t){return!k(e.getCurrentResult(),t)}function fe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var R=class extends h{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),k(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&E(t.mutationKey)!==E(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??fe();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){re.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},z=t.createContext(void 0),pe=e=>{let n=t.useContext(z);if(e)return e;if(!n)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return n},me=({client:e,children:r})=>(t.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,n.jsx)(z.Provider,{value:e,children:r})),he=t.createContext(!1),ge=()=>t.useContext(he);he.Provider;function B(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var V=t.createContext(B()),_e=()=>t.useContext(V),ve=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?N(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ye=e=>{t.useEffect(()=>{e.clearReset()},[e])},be=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||N(n,[e.error,r])),xe=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Se=(e,t)=>e.isLoading&&e.isFetching&&!t,Ce=(e,t)=>e?.suspense&&t.isPending,we=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function H(e,n,r){if(process.env.NODE_ENV!==`production`&&(typeof e!=`object`||Array.isArray(e)))throw Error(`Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object`);let i=ge(),a=_e(),o=pe(r),s=o.defaultQueryOptions(e);o.getDefaultOptions().queries?._experimental_beforeQuery?.(s);let c=o.getQueryCache().get(s.queryHash);process.env.NODE_ENV!==`production`&&(s.queryFn||console.error(`[${s.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),s._optimisticResults=i?`isRestoring`:`optimistic`,xe(s),ve(s,a,c),ye(a);let l=!o.getQueryCache().get(s.queryHash),[u]=t.useState(()=>new n(o,s)),d=u.getOptimisticResult(s),f=!i&&e.subscribed!==!1;if(t.useSyncExternalStore(t.useCallback(e=>{let t=f?u.subscribe(re.batchCalls(e)):x;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),t.useEffect(()=>{u.setOptions(s)},[s,u]),Ce(s,d))throw we(s,u,a);if(be({result:d,errorResetBoundary:a,throwOnError:s.throwOnError,query:c,suspense:s.suspense}))throw d.error;return o.getDefaultOptions().queries?._experimental_afterQuery?.(s,d),s.experimental_prefetchInRender&&!P.isServer()&&Se(d,i)&&(l?we(s,u,a):c?.promise)?.catch(x).finally(()=>{u.updateResult()}),s.notifyOnChangeProps?d:u.trackResult(d)}function Te(e,t){return H(e,oe,t)}function Ee(e,n){let r=pe(n),[i]=t.useState(()=>new R(r,e));t.useEffect(()=>{i.setOptions(e)},[i,e]);let a=t.useSyncExternalStore(t.useCallback(e=>i.subscribe(re.batchCalls(e)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),o=t.useCallback((e,t)=>{i.mutate(e,t).catch(x)},[i]);if(a.error&&N(i.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}var De=(0,t.createContext)(void 0),Oe=async()=>({"Content-Type":`application/json`});function ke({children:e,baseUrl:t,queryClient:r,getHeaders:i=Oe}){return(0,n.jsx)(De.Provider,{value:{baseUrl:t,queryClient:r,getHeaders:i},children:(0,n.jsx)(me,{client:r,children:e})})}function U(){let e=(0,t.useContext)(De);if(!e)throw Error(`useDataTable must be used within a DataTableProvider`);return e}function Ae(e){if(typeof e==`string`)try{let t=JSON.parse(e);return{message:t.message||e,code:t.code,details:t.details}}catch{return{message:e}}return e instanceof Error?{message:e.message}:{message:`Unbekannter Fehler`}}async function W(e,t){let n=await fetch(e,t);if(n.status>=400){let e=await n.text();if(!e)throw Error(`HTTP ${n.status}: ${n.statusText}`);let t=null;try{t=JSON.parse(e)}catch{throw Error(e)}throw Error(t?.message??t?.error??e)}return n}async function je(e,t){return(await W(e,{method:`GET`,headers:await t()})).json()}async function Me(e,t,n){return(await W(`${e}/${t}`,{method:`GET`,headers:await n()})).json()}async function Ne(e,t,n){await W(`${e}/${t}`,{method:`DELETE`,headers:await n()})}async function Pe(e,t,n){let r=await W(e,{method:`POST`,headers:await n(),body:JSON.stringify(t)});return r.status===204?t:r.json()}async function Fe(e,t,n,r){let i=await W(t,{method:e,headers:await n(),body:r?JSON.stringify(r):void 0});if(i.status!==204)return i.json()}async function Ie(e,t,n){let r=await W(`${e}/${t.id}`,{method:`PUT`,headers:await n(),body:JSON.stringify(t)});return r.status===204?t:r.json()}function Le(e,t,n){let{baseUrl:r,getHeaders:i}=U();return Te({queryKey:[...t.map(e=>e.toString()),String(n?.toString())],queryFn:()=>Me(`${r}${e}`,n,i),enabled:!!n})}function Re(e,t,n=!0){let{baseUrl:r,getHeaders:i}=U();return Te({queryKey:[...t.map(e=>e.toString())],queryFn:()=>je(`${r}${e}`,i),enabled:n})}function ze(e,t){let{baseUrl:n,queryClient:r,getHeaders:i}=U();return Ee({mutationKey:[...t.map(e=>e.toString())],mutationFn:t=>Pe(`${n}${e}`,t,i),onSettled(){return r.invalidateQueries({queryKey:[...t.map(e=>e.toString())]})}})}function Be(e,t){let{baseUrl:n,queryClient:r,getHeaders:i}=U();return Ee({mutationKey:[...t.map(e=>e.toString())],mutationFn:t=>Ie(`${n}${e}`,t,i),onSettled(){return r.invalidateQueries({queryKey:[...t.map(e=>e.toString())]})}})}function Ve(e,t){let{baseUrl:n,queryClient:r,getHeaders:i}=U();return Ee({mutationKey:[...t.map(e=>e.toString())],mutationFn:t=>Ne(`${n}${e}`,t,i),onSettled(){return r.invalidateQueries({queryKey:[...t.map(e=>e.toString())]})}})}function He({fields:e,onClose:o,queryKey:s,apiPath:c,steps:l,onCreated:u}){let[d,f]=(0,t.useState)(0),[p,m]=(0,t.useState)(!1),[h,g]=(0,t.useState)(),{mutateAsync:_,isError:v,error:y,isPending:b}=ze(c,s),{mutateAsync:x,isPending:S}=Be(c,s),C=b||S,w=[...new Set(e.filter(e=>typeof e.step==`number`).map(e=>e.step))];function T(e,t){return typeof e.required==`function`?e.required(t??{}):!!e.required}let E=(0,i.useForm)({mode:`uncontrolled`,initialValues:e.reduce((e,t)=>(e[t.id]=t.type===`boolean`?!1:t.defaultValue??``,e),{}),validate:e.filter(e=>e.required).reduce((e,t)=>(e[t.id]=(e,n)=>t.conditional&&!t.conditional(n)||!T(t,n)||e?null:`Pflichtfeld`,e),{})});function D(e){let i=E.getValues();if(e.conditional&&!e.conditional(i))return null;let o=T(e,i);return(0,n.jsxs)(t.Fragment,{children:[(e.type===void 0||e.type==`text`)&&(0,n.jsx)(r.TextInput,{label:e.column.title,placeholder:e.placeholder??``,...E.getInputProps(e.id),type:e.id.includes(`email`)?`email`:void 0,required:o},E.key(e.id)),e.type===`number`&&(0,n.jsx)(r.NumberInput,{decimalSeparator:`,`,label:e.column.title,placeholder:e.placeholder??``,...E.getInputProps(e.id),required:o},E.key(e.id)),e.type===`date`&&(0,n.jsx)(a.DateInput,{label:e.column.title,placeholder:e.placeholder??``,valueFormat:`DD.MM.YYYY`,clearable:!0,...E.getInputProps(e.id),required:o},E.key(e.id)),e.type===`boolean`&&(0,n.jsx)(r.Checkbox,{mt:`md`,label:e.column.title,...E.getInputProps(e.id,{type:`checkbox`}),required:o},E.key(e.id)),e.type===`textarea`&&(0,n.jsx)(r.Textarea,{label:e.column.title,placeholder:e.placeholder??``,...E.getInputProps(e.id),minRows:3,autosize:!0,required:o},E.key(e.id)),e.type===`custom`&&e.render&&e.render({...E.getValues(),...h&&{id:h}},E.setValues,m,{error:E.getInputProps(e.id).error,required:o})]},e.id)}return(0,n.jsxs)(n.Fragment,{children:[v&&(0,n.jsx)(r.Alert,{variant:`outline`,color:`red`,title:y?.name??`Fehler aufgetreten`,mb:`lg`,children:y?.message??`Fehler aufgetreten`}),(0,n.jsxs)(`form`,{onSubmit:E.onSubmit(async e=>{let t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t===``?void 0:t]));if(h)await x({...t,id:h});else{let e=await _(t);g(e.id),u?.(e.id)}w.length&&d<w.length-1?v||f(d+1):v||(E.setInitialValues(t),E.reset(),o())}),children:[w.length?(0,n.jsx)(r.Stepper,{active:d,size:`sm`,children:w.map(t=>(0,n.jsx)(r.Stepper.Step,{...l&&l[t-1]?{label:l[t-1].label}:{},children:e.filter(e=>e.step===t).map(e=>D(e))},t))}):e.map(e=>D(e)),!p&&(0,n.jsxs)(r.Group,{mt:`md`,justify:`end`,children:[(0,n.jsx)(r.Button,{onClick:()=>w.length?d===0?o():f(d-1):o(),variant:`outline`,children:w.length?d===0?`Abbrechen`:`Zurück`:`Abbrechen`}),(0,n.jsx)(r.Button,{type:`submit`,loading:C,children:w.length?d===w.length-1?`Speichern`:`Weiter`:`Speichern`})]})]})]})}function Ue(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Ue(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function G(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Ue(e))&&(r&&(r+=` `),r+=t);return r}var[We,Ge]=(0,r.createSafeContext)(`useDataTableColumnsContext must be used within DataTableColumnProvider`),Ke=e=>{let{children:r,columnsOrder:i,setColumnsOrder:a,columnsToggle:o,setColumnsToggle:s,resetColumnsOrder:c,resetColumnsToggle:l,setColumnWidth:u,setMultipleColumnWidths:d,resetColumnsWidth:f}=e,[p,m]=(0,t.useState)(``),[h,g]=(0,t.useState)(``);return(0,n.jsx)(We,{value:{sourceColumn:p,setSourceColumn:m,targetColumn:h,setTargetColumn:g,columnsToggle:o,setColumnsToggle:s,swapColumns:()=>{if(!i||!a||!p||!h)return;let e=i.indexOf(p),t=i.indexOf(h);if(e!==-1&&t!==-1){let n=i.splice(e,1)[0];i.splice(t,0,n),a([...i])}},resetColumnsOrder:c,resetColumnsToggle:l,setColumnWidth:u,setMultipleColumnWidths:d,resetColumnsWidth:f},children:r})};function qe(){return(0,n.jsx)(`tr`,{className:`mantine-datatable-empty-row`,children:(0,n.jsx)(`td`,{})})}function Je(){return(0,n.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M12.983 8.978c3.955 -.182 7.017 -1.446 7.017 -2.978c0 -1.657 -3.582 -3 -8 -3c-1.661 0 -3.204 .19 -4.483 .515m-2.783 1.228c-.471 .382 -.734 .808 -.734 1.257c0 1.22 1.944 2.271 4.734 2.74`}),(0,n.jsx)(`path`,{d:`M4 6v6c0 1.657 3.582 3 8 3c.986 0 1.93 -.067 2.802 -.19m3.187 -.82c1.251 -.53 2.011 -1.228 2.011 -1.99v-6`}),(0,n.jsx)(`path`,{d:`M4 12v6c0 1.657 3.582 3 8 3c3.217 0 5.991 -.712 7.261 -1.74m.739 -3.26v-4`}),(0,n.jsx)(`path`,{d:`M3 3l18 18`})]})}function Ye({icon:e,text:t,active:i,children:a}){return(0,n.jsx)(r.Center,{className:`mantine-datatable-empty-state`,"data-active":i||void 0,children:a||(0,n.jsxs)(n.Fragment,{children:[e||(0,n.jsx)(`div`,{className:`mantine-datatable-empty-state-icon`,children:(0,n.jsx)(Je,{})}),(0,n.jsx)(r.Text,{component:`div`,size:`sm`,c:`dimmed`,children:t})]})})}function Xe({key:e,columns:t=[],getInitialValueInEffect:n=!0}){function r(e,t){let n=[];return e.forEach(e=>{t.find(t=>t.accessor===e)&&n.push(e)}),t.forEach(e=>{n.includes(e.accessor)||n.push(e.accessor)}),n}let i=t&&t.map(e=>e.accessor)||[],[a,o]=(0,s.useLocalStorage)({key:e?`${e}-columns-order`:``,defaultValue:e?i:void 0,getInitialValueInEffect:n});function c(t){e&&o(t)}let l=()=>{c(i)};if(!e)return{columnsOrder:a,setColumnsOrder:c,resetColumnsOrder:l};let u=r(a,t),d=JSON.stringify(a);return JSON.stringify(u)!==d&&c(u),{columnsOrder:u,setColumnsOrder:c,resetColumnsOrder:l}}function Ze({key:e,columns:n=[],getInitialValueInEffect:r=!0,headerRef:i,onFixedLayoutChange:a}){let o=(0,t.useRef)(!1),c=(0,t.useRef)({}),[l,u]=(0,t.useState)(!0),d=(0,t.useMemo)(()=>n.some(e=>e.resizable&&!e.hidden&&e.accessor!==`__selection__`),[n]),f=(0,t.useMemo)(()=>n.filter(e=>e.resizable&&!e.hidden&&e.accessor!==`__selection__`),[n]),p=(0,t.useMemo)(()=>f.some(e=>e.width===void 0||e.width===``||e.width===`initial`),[f]),m=(0,t.useCallback)(()=>n.filter(e=>e.accessor!==`__selection__`).map(e=>({[e.accessor]:e.width??`auto`})),[n]),[h,g]=(0,s.useLocalStorage)({key:e?`${e}-columns-width`:``,defaultValue:e?m():void 0,getInitialValueInEffect:!1}),[_,v]=(0,t.useState)(()=>m());(0,t.useEffect)(()=>{u(!1)},[]);let y=(0,t.useCallback)(()=>{if(!i?.current||l)return{};let e=i.current,t=Array.from(e.querySelectorAll(`th[data-accessor]`)),n={};return t.forEach(e=>{let t=e.getAttribute(`data-accessor`);if(!t||t===`__selection__`)return;let r=f.find(e=>e.accessor===t);if(r&&(r.width===void 0||r.width===``||r.width===`initial`)){let r=e.getBoundingClientRect();n[t]=Math.round(r.width)}}),n},[i,f,l]),b=(0,t.useCallback)(t=>{let n=t.filter(e=>e.accessor!==`__selection__`),r=_.map(e=>{let t=Object.keys(e)[0],r=n.find(e=>e.accessor===t);return r?{[t]:r.width}:e});v(r),e&&g(r)},[_,e,g]),x=(0,t.useCallback)(e=>{b(e)},[b]),S=(0,t.useCallback)(()=>{!i?.current||!a||l||(p?(a(!1),requestAnimationFrame(()=>{requestAnimationFrame(()=>{let e=y();c.current={...c.current,...e},v(n.filter(e=>e.accessor!==`__selection__`).map(t=>{let n=t.accessor,r=h?.find(e=>Object.keys(e)[0]===n);if(r&&r[n]!==`auto`)return{[n]:r[n]};let i=e[n];return i?{[n]:`${i}px`}:{[n]:t.width??`auto`}})),setTimeout(()=>{a(!0),o.current=!0},10)})})):(v(n.filter(e=>e.accessor!==`__selection__`).map(e=>({[e.accessor]:e.width??`auto`}))),a(!0),o.current=!0))},[i,a,l,p,y,n,h]),C=S;(0,t.useEffect)(()=>{if(!d||!a||l){a?.(!1);return}o.current=!1;let e=setTimeout(()=>{S()},50);return()=>clearTimeout(e)},[d,a,l,S]),(0,t.useEffect)(()=>{l||!e||!r||h&&h.length>0&&v(h)},[l,e,r,h]);let w=(0,t.useCallback)(()=>{e&&g(m()),c.current={},o.current=!1,a&&(a(!1),setTimeout(()=>{S()},10))},[e,g,m,a,S]);return{columnsWidth:_,setColumnsWidth:b,setColumnWidth:(0,t.useCallback)((e,t)=>{b([{accessor:e,width:t}])},[b]),setMultipleColumnWidths:x,resetColumnsWidth:w,hasResizableColumns:d,allResizableWidthsInitial:(0,t.useMemo)(()=>d?_.filter(e=>{let t=Object.keys(e)[0];return f.some(e=>e.accessor===t)}).every(e=>{let t=Object.values(e)[0];return t===`auto`||t===`initial`}):!1,[d,_,f]),measureAndSetColumnWidths:C}}function Qe({key:e,columns:t=[],getInitialValueInEffect:n=!0}){function r(e,t){let n=[];return e.forEach(e=>{t.find(t=>t.accessor===e.accessor)&&n.push(e)}),t.forEach(e=>{n.find(t=>t.accessor===e.accessor)||n.push({accessor:e.accessor,defaultToggle:e.defaultToggle||!0,toggleable:e.toggleable,toggled:e.defaultToggle===void 0?!0:e.defaultToggle})}),n}let i=t&&t.map(e=>({accessor:e.accessor,defaultToggle:e.defaultToggle||!0,toggleable:e.toggleable,toggled:e.defaultToggle===void 0?!0:e.defaultToggle})),[a,o]=(0,s.useLocalStorage)({key:e?`${e}-columns-toggle`:``,defaultValue:e?i:void 0,getInitialValueInEffect:n});function c(t){e&&o(t)}let l=()=>{c(i)};if(!e)return{columnsToggle:a,setColumnsToggle:c,resetColumnsToggle:l};let u=r(a,t),d=JSON.stringify(a);return JSON.stringify(u)!==d&&c(u),{columnsToggle:u,setColumnsToggle:c,resetColumnsToggle:l}}var $e=({key:e,columns:n=[],getInitialValueInEffect:r=!0,headerRef:i,scrollViewportRef:a,onFixedLayoutChange:o})=>{let{columnsOrder:s,setColumnsOrder:c,resetColumnsOrder:l}=Xe({key:e,columns:n,getInitialValueInEffect:r}),{columnsToggle:u,setColumnsToggle:d,resetColumnsToggle:f}=Qe({key:e,columns:n,getInitialValueInEffect:r}),{columnsWidth:p,setColumnsWidth:m,setColumnWidth:h,setMultipleColumnWidths:g,resetColumnsWidth:_,hasResizableColumns:v,allResizableWidthsInitial:y,measureAndSetColumnWidths:b}=Ze({key:e,columns:n,getInitialValueInEffect:r,headerRef:i,scrollViewportRef:a,onFixedLayoutChange:o});return{effectiveColumns:(0,t.useMemo)(()=>s?s.map(e=>n.find(t=>t.accessor===e)).map(e=>({...e,hidden:e?.hidden||!u.find(t=>t.accessor===e?.accessor)?.toggled})).map(e=>e?.accessor===`__selection__`?e:{...e,width:p.find(t=>t[e?.accessor])?.[e?.accessor]}):n,[n,s,u,p]),setColumnsOrder:c,columnsOrder:s,resetColumnsOrder:l,columnsToggle:u,setColumnsToggle:d,resetColumnsToggle:f,columnsWidth:p,setColumnsWidth:m,setColumnWidth:h,setMultipleColumnWidths:g,resetColumnsWidth:_,hasResizableColumns:v,allResizableWidthsInitial:y,measureAndSetColumnWidths:b}},et=typeof window<`u`?t.useLayoutEffect:t.useEffect;function tt(e){let n=(0,t.useRef)(e);return n.current=e,n}var nt=`--mantine-datatable-header-height`,rt=`--mantine-datatable-footer-height`,K=`--mantine-datatable-selection-column-width`,it=`--mantine-datatable-last-row-border-bottom`;function q(e,t,n){e?.style.setProperty(t,n)}function at(e){let t=e.borderBoxSize?.[0]||e.contentBoxSize?.[0];return t?{width:t.inlineSize,height:t.blockSize}:{width:e.contentRect.width,height:e.contentRect.height}}function ot(e,t,n){if(e){let r=new ResizeObserver(e=>{let n=e[0];n&&t(at(n))});return r.observe(e),()=>{r.disconnect(),n()}}}function st({scrollCallbacks:e,withRowBorders:n}){let i={root:(0,t.useRef)(null),table:(0,t.useRef)(null),scrollViewport:(0,t.useRef)(null),header:(0,t.useRef)(null),footer:(0,t.useRef)(null),selectionColumnHeader:(0,t.useRef)(null)},{root:a,table:o,scrollViewport:s,header:c,footer:l,selectionColumnHeader:u}=i,d=tt({withRowBorders:n}),f=tt(e),p=(0,t.useRef)(()=>{}),m=(0,t.useRef)(()=>{}),h=(0,t.useCallback)(e=>{f.current.onScroll?.(e),p.current()},[]);return(0,t.useEffect)(()=>ot(c.current,e=>{q(a.current,nt,`${e.height}px`)},()=>q(a.current,nt,`0`)),[c.current]),(0,t.useEffect)(()=>ot(l.current,e=>{q(a.current,rt,`${e.height}px`)},()=>q(a.current,rt,`0`)),[l.current]),(0,t.useEffect)(()=>ot(u.current,e=>{q(a.current,K,`${e.width}px`)},()=>q(a.current,K,`0`)),[u.current]),et(()=>{let e={top:!0,bottom:!0,left:!0,right:!0},t={width:0,height:0},n={width:0,height:0};function i(t,n){let r=e[t];return e[t]=n,q(a.current,`--mantine-datatable-${t}-shadow-opacity`,n?`0`:`1`),r}function c(){let e=t.height-n.height,r=e<0;q(a.current,`--mantine-datatable-footer-position`,r?`relative`:`sticky`),q(a.current,`--mantine-datatable-footer-bottom`,r?`${e}px`:`0`)}function l(){d.current.withRowBorders&&t.height<n.height?q(a.current,it,`${(0,r.rem)(`1px`)} solid var(--mantine-datatable-border-color)`):q(a.current,it,`unset`)}m.current=l;function u(){let e=f.current,r=s.current,a=r?.scrollTop??0,o=r?.scrollLeft??0,c=a===0,l=t.height-a-n.height<1,u=i(`top`,c),d=i(`bottom`,l);c&&c!==u&&e.onScrollToTop?.(),l&&l!==d&&e.onScrollToBottom?.();let p=r?getComputedStyle(r).direction===`rtl`:!1,m=(r?.scrollWidth??0)-n.width,h,g;if(p){let e=Math.abs(o);g=e<1,h=m-e<1}else h=o<1,g=t.width-o-n.width<1;let _=i(`left`,h),v=i(`right`,g);h&&h!==_&&e.onScrollToLeft?.(),g&&g!==v&&e.onScrollToRight?.()}p.current=u;let h=new ResizeObserver(e=>{for(let r of e)switch(r.target.tagName){case`TABLE`:t=at(r);break;case`DIV`:n=at(r);break}u(),c(),l()});return h.observe(o.current),h.observe(s.current),()=>{h.disconnect()}},[]),et(()=>{m.current()},[n]),{refs:i,onScroll:h}}function ct(e){let[n,r]=(0,t.useState)(null);return(0,t.useEffect)(()=>{r(null)},[e?.join(`:`)||``]),{lastSelectionChangeIndex:n,setLastSelectionChangeIndex:r}}function lt(e,t){let n=()=>{t(e.map(e=>e.matches))},r=e.map(e=>{try{return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)}catch{return e.addListener(n),()=>e.removeListener(n)}});return()=>{r.forEach(e=>e())}}function ut(e,t){return t||(typeof window<`u`&&`matchMedia`in window?e.map(e=>window.matchMedia(e).matches):e.map(()=>!1))}function dt(e,n,{getInitialValueInEffect:r}={getInitialValueInEffect:!0}){let[i,a]=(0,t.useState)(r?n:ut(e,n)),o=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(`matchMedia`in window)return o.current=e.map(e=>window.matchMedia(e)),a(o.current.map(e=>e.matches)),lt(o.current,e=>{a(e)})},[e]),i}function ft(e){let n=(0,r.useMantineTheme)();return dt((0,t.useMemo)(()=>e.map(e=>(typeof e==`function`?e(n):e)??``),[e,n]),(0,t.useMemo)(()=>e.map(()=>!0),[e]))}function J(e){let t=(0,r.useMantineTheme)();return(0,s.useMediaQuery)((typeof e==`function`?e(t):e)||``,!0)}function pt(e){let t=e.replace(/([a-z\d])([A-Z]+)/g,`$1 $2`).replace(/\W|_/g,` `).trim().toLowerCase();return`${t.charAt(0).toUpperCase()}${t.slice(1)}`}function mt(e,t,n){return e.filter(e=>!t.map(n).includes(n(e)))}function ht(e,t){return e.filter((e,n,r)=>n===r.findIndex(n=>t(e)===t(n)))}function gt(e,t){return t?t.match(/([^[.\]])+/g).reduce((e,t)=>e&&e[t],e):void 0}function Y(e,t){return typeof t==`string`?gt(e,t):t(e)}function _t(e){return!e||e.length===0?0:Math.max(...e.map(e=>e.groups&&e.groups.length>0?1+_t(e.groups):1))}function vt(e){let t=[];for(let n of e)n.columns&&n.columns.length>0?t.push(...n.columns.filter(e=>e!=null)):n.groups&&n.groups.length>0&&t.push(...vt(n.groups));return t.filter(e=>e!=null)}function yt(e,t){return e.columns&&e.columns.length>0?e.columns.filter((e,n)=>e.hidden?!1:t?t[n]!==!1:!0).length:e.groups&&e.groups.length>0?e.groups.reduce((e,n)=>e+yt(n,t),0):0}function bt(e,t,n=0){if(n===t)return[...e];let r=[];for(let i of e)i.groups&&i.groups.length>0&&r.push(...bt(i.groups,t,n+1));return r}function xt(e,t,n){return n?!e||t:!1}function St({rowExpansion:e,records:n,idAccessor:r}){let i=[];if(e&&n){let{trigger:t,allowMultiple:a,initiallyExpanded:o}=e;n&&t===`always`?i=n.map(e=>Y(e,r)):o&&(i=n.filter((e,t)=>o({record:e,index:t})).map(e=>Y(e,r)),a||(i=[i[0]]))}let a,o,s=(0,t.useState)(i);if(e){let{expandable:t,trigger:n,allowMultiple:i,collapseProps:c,content:l}=e;e.expanded?{recordIds:a,onRecordIdsChange:o}=e.expanded:[a,o]=s;let u=e=>o?.(a.filter(t=>t!==Y(e,r)));return{expandOnClick:n!==`always`&&n!==`never`,isRowExpanded:e=>n===`always`?!0:a.includes(Y(e,r)),isExpandable:({record:e,index:n})=>t?t({record:e,index:n}):!0,expandRow:e=>{let t=Y(e,r);o?.(i?[...a,t]:[t])},collapseRow:u,collapseProps:c,content:({record:e,index:t})=>()=>l({record:e,index:t,collapse:()=>u(e)})}}}function Ct(e,n){let[r,i]=(0,t.useState)(e),[a,o]=(0,t.useState)(e),c=(0,s.useTimeout)(()=>i(!0),0),l=(0,s.useTimeout)(()=>o(!1),n||200);return(0,t.useEffect)(()=>{e?(l.clear(),o(!0),c.start()):(c.clear(),i(!1),l.start())},[c,l,e]),{expanded:r,visible:a}}var wt=`mantine-datatable-nowrap`,Tt=`mantine-datatable-ellipsis`,X=`mantine-datatable-pointer-cursor`,Et=`mantine-datatable-context-menu-cursor`,Dt=`mantine-datatable-text-selection-disabled`,Z=`mantine-datatable-text-align-left`,Q=`mantine-datatable-text-align-center`,Ot=`mantine-datatable-text-align-right`;function kt({className:e,style:t,visibleMediaQuery:i,title:a,noWrap:o,ellipsis:s,textAlign:c,width:l}){return J(i)?(0,n.jsx)(r.TableTh,{className:G({[wt]:o||s,[Tt]:s,[Z]:c===`left`,[Q]:c===`center`,[Ot]:c===`right`},e),style:[{width:l,minWidth:l,maxWidth:l},t],children:a}):null}function At({shadowVisible:e}){return(0,n.jsx)(r.TableTh,{className:`mantine-datatable-footer-selector-placeholder-cell`,"data-shadow-visible":e||void 0})}function jt({className:e,style:t,columns:i,defaultColumnProps:a,selectionVisible:o,selectorCellShadowVisible:s,ref:c}){return(0,n.jsx)(r.TableTfoot,{ref:c,className:G(`mantine-datatable-footer`,e),style:t,children:(0,n.jsxs)(r.TableTr,{children:[o&&(0,n.jsx)(At,{shadowVisible:s}),i.map(({hidden:e,...t})=>{if(e)return null;let{accessor:r,visibleMediaQuery:i,textAlign:o,width:s,footer:c,footerClassName:l,footerStyle:u,noWrap:d,ellipsis:f}={...a,...t};return(0,n.jsx)(kt,{className:l,style:u,visibleMediaQuery:i,textAlign:o,width:s,title:c,noWrap:d,ellipsis:f},r)})]})})}function Mt({group:{id:e,columns:i,groups:a,title:o,textAlign:s,className:c,style:l},maxDepth:u,currentDepth:d,previousGroups:f,isLastGroup:p,withColumnBorders:m=!1,totalTableColumns:h}){let g=(0,t.useMemo)(()=>i&&i.length>0?i:a&&a.length>0?vt([{id:e,columns:i,groups:a}]):[],[i,a,e]),_=ft((0,t.useMemo)(()=>g.map(({visibleMediaQuery:e})=>e),[g])),v=(0,t.useMemo)(()=>yt({id:e,columns:i,groups:a},_),[e,i,a,_]),y=(0,t.useMemo)(()=>f.reduce((e,t)=>e+yt(t,_),0),[f,_]),b=a&&a.length>0?1:u-d,x=xt(p,y+v<h,m);return v>0?(0,n.jsx)(r.TableTh,{colSpan:v,rowSpan:b>1?b:void 0,className:G(`mantine-datatable-column-group-header-cell`,{[Z]:s===`left`,[Q]:s===`center`,[Ot]:s===`right`,"mantine-datatable-column-group-header-cell--needs-border":x},c),style:l,children:o??pt(e)}):null}function Nt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227z`})]})}function Pt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M20 3h-16a1 1 0 0 0 -1 1v2.227l.008 .223a3 3 0 0 0 .772 1.795l4.22 4.641v8.114a1 1 0 0 0 1.316 .949l6 -2l.108 -.043a1 1 0 0 0 .576 -.906v-6.586l4.121 -4.12a3 3 0 0 0 .879 -2.123v-2.171a1 1 0 0 0 -1 -1z`,strokeWidth:`0`,fill:`currentColor`})]})}function Ft({children:e,isActive:t,filterPopoverProps:i,filterPopoverDisableClickOutside:a}){let[o,{close:c,toggle:l}]=(0,s.useDisclosure)(!1),u=t?Pt:Nt,d=(0,s.useClickOutside)(c);return a&&(d=void 0),(0,n.jsxs)(r.Popover,{withArrow:!0,shadow:`md`,opened:o,onClose:c,trapFocus:!0,...i,children:[(0,n.jsx)(r.PopoverTarget,{children:(0,n.jsx)(r.ActionIcon,{className:`mantine-datatable-header-cell-filter-action-icon`,"data-active":t||void 0,size:`sm`,variant:`default`,onClick:e=>{e.preventDefault(),l()},onKeyDown:e=>e.stopPropagation(),children:(0,n.jsx)(u,{})})}),(0,n.jsx)(r.PopoverDropdown,{ref:d,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:typeof e==`function`?e({close:c}):e})]})}var It=e=>{let{accessor:i,columnRef:a}=e,[o,s]=(0,t.useState)(!1),c=(0,t.useRef)(0),l=(0,t.useRef)({current:0,next:0}),{dir:u}=(0,r.useDirection)(),d=u===`rtl`,{setMultipleColumnWidths:f}=Ge(),p=(0,t.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),!a.current)return;let t=a.current,n=t.nextElementSibling;for(;n;){let e=n.getAttribute(`data-accessor`);if(e&&e!==`__selection__`)break;n=n.nextElementSibling}if(!n)return;let r=n.getAttribute(`data-accessor`);if(!r)return;let o=r===`__selection__`;s(!0),c.current=e.clientX,l.current={current:t.offsetWidth,next:n.offsetWidth};let u=e=>{if(!a.current)return;let t=a.current,n=t.nextElementSibling;if(!n)return;let r=e.clientX-c.current;d&&(r=-r);let i=l.current.current-50,o=l.current.next-50,s=Math.max(-i,Math.min(r,o)),u=l.current.current+s,f=l.current.next-s;t.style.width=`${u}px`,n.style.width=`${f}px`,t.style.minWidth=`${u}px`,t.style.maxWidth=`${u}px`,n.style.minWidth=`${f}px`,n.style.maxWidth=`${f}px`},p=()=>{if(!a.current)return;let e=a.current,t=e.nextElementSibling;s(!1),document.body.style.cursor=`initial`,document.body.style.userSelect=`initial`;let n=parseInt(e.style.width)||e.offsetWidth,r=t?parseInt(t.style.width)||t.offsetWidth:0,c=[{accessor:i,width:`${n}px`}];if(t&&!o){let e=t.getAttribute(`data-accessor`);e&&c.push({accessor:e,width:`${r}px`})}setTimeout(()=>{f(c)},0),document.removeEventListener(`mousemove`,u),document.removeEventListener(`mouseup`,p)};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,document.addEventListener(`mousemove`,u),document.addEventListener(`mouseup`,p)},[i,a,d,f]),m=(0,t.useCallback)(()=>{if(!a.current)return;let e=a.current,t=e.nextElementSibling;e.style.width=``,e.style.minWidth=``,e.style.maxWidth=``;let n=[{accessor:i,width:`auto`}];if(t){t.style.width=``,t.style.minWidth=``,t.style.maxWidth=``;let e=t.getAttribute(`data-accessor`);e&&e!==`__selection__`&&n.push({accessor:e,width:`auto`})}setTimeout(()=>{f(n)},0)},[i,a,f]);return(0,n.jsx)(`div`,{className:`mantine-datatable-header-resizable-handle`,style:{cursor:o?`col-resize`:void 0},onMouseDown:p,onDoubleClick:m,onClick:e=>e.stopPropagation(),title:`Drag to resize column, double-click to reset`})};function Lt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M12 5l0 14`}),(0,n.jsx)(`path`,{d:`M16 9l-4 -4`}),(0,n.jsx)(`path`,{d:`M8 9l4 -4`})]})}function Rt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M8 7l4 -4l4 4`}),(0,n.jsx)(`path`,{d:`M8 17l4 4l4 -4`}),(0,n.jsx)(`path`,{d:`M12 3l0 18`})]})}function zt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M9 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,n.jsx)(`path`,{d:`M9 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,n.jsx)(`path`,{d:`M9 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,n.jsx)(`path`,{d:`M15 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,n.jsx)(`path`,{d:`M15 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,n.jsx)(`path`,{d:`M15 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`})]})}function Bt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M18 6l-12 12`}),(0,n.jsx)(`path`,{d:`M6 6l12 12`})]})}function Vt({className:e,style:i,accessor:a,visibleMediaQuery:o,title:s,sortable:c,draggable:l,toggleable:u,resizable:d,sortIcons:f,textAlign:p,width:m,sortStatus:h,onSortStatusChange:g,filter:_,filterPopoverProps:v,filterPopoverDisableClickOutside:y,filtering:b,sortKey:x}){let{setSourceColumn:S,setTargetColumn:C,swapColumns:w,setColumnsToggle:T}=Ge(),[E,D]=(0,t.useState)(!1),O=(0,t.useRef)(null);if(!J(o))return null;let k=s??pt(a),A=typeof k==`string`?k:void 0,j=c&&g?e=>{e?.defaultPrevented||g({sortKey:x,columnAccessor:a,direction:h?.columnAccessor===a?h.direction===`asc`?`desc`:`asc`:h?.direction??`asc`})}:void 0,M=e=>{e.stopPropagation(),S(a),D(!1)},ee=e=>{e.preventDefault(),C(a),D(!0)},N=()=>{C(a),D(!1),w()},P=()=>{D(!0)},F=()=>{D(!1)},te=e=>{e.stopPropagation(),T(e=>e.map(e=>e.accessor===a?{...e,toggled:!1}:e))};return(0,n.jsxs)(r.TableTh,{"data-accessor":a,className:G({"mantine-datatable-header-cell-sortable":c,"mantine-datatable-header-cell-toggleable":u,"mantine-datatable-header-cell-resizable":d},e),style:[{width:m,...d?{}:{minWidth:m,maxWidth:m}},i],role:c?`button`:void 0,tabIndex:c?0:void 0,onClick:j,onKeyDown:e=>e.key===`Enter`&&j?.(),ref:O,children:[(0,n.jsxs)(r.Group,{className:`mantine-datatable-header-cell-sortable-group`,justify:`space-between`,wrap:`nowrap`,children:[(0,n.jsxs)(r.Flex,{align:`center`,w:`100%`,className:G({"mantine-datatable-header-cell-draggable":l,"mantine-datatable-header-cell-drag-over":E}),draggable:l,onDragStart:l?M:void 0,onDragEnter:l?P:void 0,onDragOver:l?ee:void 0,onDrop:l?N:void 0,onDragLeave:l?F:void 0,children:[l?(0,n.jsx)(r.Center,{role:`img`,"aria-label":`Drag column`,children:(0,n.jsx)(r.ActionIcon,{className:`mantine-datatable-header-cell-draggable-action-icon`,variant:`subtle`,size:`xs`,onClick:e=>{e.stopPropagation()},children:(0,n.jsx)(zt,{})})}):null,(0,n.jsx)(r.Box,{className:G(`mantine-datatable-header-cell-sortable-text`,{[Z]:p===`left`,[Q]:p===`center`,[Ot]:p===`right`},wt,Tt),title:A,children:k})]}),u?(0,n.jsx)(r.Center,{className:`mantine-datatable-header-cell-toggleable-icon`,role:`img`,"aria-label":`Toggle column`,children:(0,n.jsx)(r.ActionIcon,{size:`xs`,variant:`light`,onClick:te,children:(0,n.jsx)(Bt,{})})}):null,c||h?.columnAccessor===a?(0,n.jsx)(n.Fragment,{children:h?.columnAccessor===a?(0,n.jsx)(r.Center,{className:G(`mantine-datatable-header-cell-sortable-icon`,{"mantine-datatable-header-cell-sortable-icon-reversed":h.direction===`desc`}),role:`img`,"aria-label":`Sorted ${h.direction===`desc`?`descending`:`ascending`}`,children:f?.sorted||(0,n.jsx)(Lt,{})}):(0,n.jsx)(r.Center,{className:`mantine-datatable-header-cell-sortable-unsorted-icon`,role:`img`,"aria-label":`Not sorted`,children:f?.unsorted||(0,n.jsx)(Rt,{})})}):null,_?(0,n.jsx)(Ft,{filterPopoverProps:v,isActive:!!b,filterPopoverDisableClickOutside:y,children:_}):null]}),d&&a!==`__selection__`?(0,n.jsx)(It,{accessor:a,columnRef:O}):null]})}function Ht({className:e,style:t,trigger:i,shadowVisible:a,checked:o,indeterminate:s,checkboxProps:c,onChange:l,rowSpan:u,ref:d}){let f=!c.disabled;return(0,n.jsx)(r.TableTh,{ref:d,className:G(`mantine-datatable-header-selector-cell`,{[X]:i===`cell`&&f},e),style:t,rowSpan:u,"data-shadow-visible":a||void 0,"data-accessor":`__selection__`,onClick:i===`cell`&&f?l:void 0,children:(0,n.jsx)(r.Checkbox,{classNames:f?{input:X}:void 0,checked:o,indeterminate:s,onChange:l,...c,disabled:!(l||c.onChange)||c.disabled})})}function Ut({selectionColumnHeaderRef:e,className:i,style:a,sortStatus:o,sortIcons:s,onSortStatusChange:c,columns:l,defaultColumnProps:u,groups:d,selectionTrigger:f,selectionVisible:p,selectionChecked:m,selectionIndeterminate:h,onSelectionChange:g,selectionCheckboxProps:_,selectorCellShadowVisible:v,selectionColumnClassName:y,selectionColumnStyle:b,withColumnBorders:x=!1,ref:S}){let C=d?_t(d):0,w=C>0?C+1:1,T=p?(0,n.jsx)(Ht,{ref:e,className:y,style:b,trigger:f,shadowVisible:v,checked:m,indeterminate:h,checkboxProps:_,onChange:g,rowSpan:d?w:void 0}):null,{columnsToggle:E,setColumnsToggle:D}=Ge(),[O,k]=(0,t.useState)(!1),A=l.some(e=>e.toggleable),j=A?Object.fromEntries(l.map(({accessor:e,title:t})=>[e,t??pt(String(e))])):void 0,M=(0,n.jsxs)(r.TableThead,{className:G(`mantine-datatable-header`,i),style:a,ref:S,onContextMenu:A?e=>{e.preventDefault(),k(e=>!e)}:void 0,children:[d&&Array.from({length:C},(e,t)=>{let i=bt(d,t);return(0,n.jsxs)(r.TableTr,{children:[t===0&&T,i.map((e,r)=>(0,n.jsx)(Mt,{group:e,maxDepth:C,currentDepth:t,previousGroups:i.slice(0,r),isLastGroup:r===i.length-1,withColumnBorders:x,totalTableColumns:l.length},e.id))]},`group-depth-${t}`)}),(0,n.jsxs)(r.TableTr,{children:[!d&&T,l.map(({hidden:e,...t},r)=>{if(e)return null;let{accessor:i,visibleMediaQuery:a,textAlign:d,width:f,title:p,sortable:m,draggable:h,toggleable:g,resizable:_,titleClassName:v,titleStyle:y,filter:b,filterPopoverProps:x,filterPopoverDisableClickOutside:S,filtering:C,sortKey:w}={...u,...t};return(0,n.jsx)(Vt,{accessor:i,className:v,style:y,visibleMediaQuery:a,textAlign:d,width:f,title:p,sortable:m,draggable:h,toggleable:g,resizable:_&&r<l.length-1,sortStatus:o,sortIcons:s,sortKey:w,onSortStatusChange:c,filter:b,filterPopoverProps:x,filterPopoverDisableClickOutside:S,filtering:C},i)})]})]});return A?(0,n.jsxs)(r.Popover,{position:`bottom`,withArrow:!0,shadow:`md`,opened:O,onChange:k,children:[(0,n.jsx)(r.PopoverTarget,{children:M}),(0,n.jsx)(r.PopoverDropdown,{children:(0,n.jsx)(r.Stack,{children:E.filter(e=>e.toggleable).map(e=>(0,n.jsx)(r.Group,{children:(0,n.jsx)(r.Checkbox,{classNames:{label:`mantine-datatable-header-column-toggle-checkbox-label`},size:`xs`,label:j[e.accessor],checked:e.toggled,onChange:t=>{D(E.map(n=>n.accessor===e.accessor?{...n,toggled:t.currentTarget.checked}:n))}})},e.accessor))})})]}):M}function Wt({fetching:e,customContent:t,backgroundBlur:i,size:a,type:o,color:s}){return(0,n.jsx)(r.Center,{className:G(`mantine-datatable-loader`,{"mantine-datatable-loader-fetching":e}),style:[{backdropFilter:i?`blur(${i}px)`:void 0}],children:e&&(t||(0,n.jsx)(r.Loader,{size:a,type:o,color:s}))})}function $(e,t,n){return e?(0,r.parseThemeColor)({color:typeof e==`object`?e[n]:e,theme:t}).value:void 0}function Gt({theme:e,c:t,backgroundColor:n,borderColor:r,rowBorderColor:i,stripedColor:a,highlightOnHoverColor:o}){return{"--mantine-datatable-color-light":$(t,e,`light`),"--mantine-datatable-color-dark":$(t,e,`dark`),"--mantine-datatable-background-color-light":$(n,e,`light`),"--mantine-datatable-background-color-dark":$(n,e,`dark`),"--mantine-datatable-border-color-light":$(r,e,`light`),"--mantine-datatable-border-color-dark":$(r,e,`dark`),"--mantine-datatable-row-border-color-light":$(i,e,`light`),"--mantine-datatable-row-border-color-dark":$(i,e,`dark`),"--mantine-datatable-striped-color-light":$(a,e,`light`),"--mantine-datatable-striped-color-dark":$(a,e,`dark`),"--mantine-datatable-highlight-on-hover-color-light":$(o,e,`light`),"--mantine-datatable-highlight-on-hover-color-dark":$(o,e,`dark`)}}function Kt({theme:e,paginationActiveTextColor:t,paginationActiveBackgroundColor:n}){return{"--mantine-datatable-pagination-active-text-color-light":$(t,e,`light`),"--mantine-datatable-pagination-active-text-color-dark":$(t,e,`dark`),"--mantine-datatable-pagination-active-background-color-light":$(n,e,`light`),"--mantine-datatable-pagination-active-background-color-dark":$(n,e,`dark`)}}function qt({theme:e,color:t,backgroundColor:n}){return{"--mantine-datatable-row-color-light":$(t,e,`light`),"--mantine-datatable-row-color-dark":$(t,e,`dark`),"--mantine-datatable-row-background-color-light":$(n,e,`light`),"--mantine-datatable-row-background-color-dark":$(n,e,`dark`)}}function Jt(){return(0,n.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,n.jsx)(`path`,{stroke:`none`,d:`M0 0h24v24H0z`,fill:`none`}),(0,n.jsx)(`path`,{d:`M8 9l4 -4l4 4`}),(0,n.jsx)(`path`,{d:`M16 15l-4 4l-4 -4`})]})}var Yt={xs:(0,r.rem)(22),sm:(0,r.rem)(26),md:(0,r.rem)(32),lg:(0,r.rem)(38),xl:(0,r.rem)(44)};function Xt({size:e,label:t,values:i,value:a,activeTextColor:o,activeBackgroundColor:s,onChange:c}){return(0,n.jsxs)(r.Group,{gap:`xs`,children:[(0,n.jsx)(r.Text,{component:`div`,size:e,children:t}),(0,n.jsxs)(r.Menu,{withinPortal:!0,withArrow:!0,offset:2,classNames:{arrow:`mantine-datatable-page-size-selector-menu-arrow`},children:[(0,n.jsx)(r.MenuTarget,{children:(0,n.jsx)(r.Button,{size:e,variant:`default`,classNames:{section:`mantine-datatable-page-size-selector-button-icon`},rightSection:(0,n.jsx)(Jt,{}),style:[{fontWeight:`normal`},t=>({height:Yt[e],paddingLeft:t.spacing[e],paddingRight:t.spacing[e]})],children:a})}),(0,n.jsx)(r.MenuDropdown,{children:i.map(t=>{let i=t===a;return(0,n.jsx)(r.MenuItem,{className:G({"mantine-datatable-page-size-selector-active":i}),style:[{height:Yt[e]},i&&(o||s)?e=>Kt({theme:e,paginationActiveTextColor:o,paginationActiveBackgroundColor:s}):void 0],disabled:i,onClick:()=>c(t),children:(0,n.jsx)(r.Text,{component:`div`,size:e,children:t})},t)})})]})]})}function Zt({className:e,style:t,fetching:i,page:a,onPageChange:o,paginationWithEdges:s,paginationWithControls:c,paginationActiveTextColor:l,paginationActiveBackgroundColor:u,paginationSize:d,loadingText:f,noRecordsText:p,paginationText:m,totalRecords:h,recordsPerPage:g,onRecordsPerPageChange:_,recordsPerPageLabel:v,recordsPerPageOptions:y,recordsLength:b,horizontalSpacing:x,paginationWrapBreakpoint:S,getPaginationControlProps:C,getPaginationItemProps:w,renderPagination:T}){let E;if(h){let e=(a-1)*g+1;E=m({from:e,to:e+(b||0)-1,totalRecords:h})}else E=i?f:p;let D=h&&g?Math.max(1,Math.ceil(h/g)):1,O=h?(a-1)*(g??0)+1:void 0,k=h?(O??1)+(b??0)-1:void 0,A=!J(({breakpoints:e})=>`(min-width: ${typeof S==`number`?`${(0,r.rem)(S)}rem`:e[S]||S})`),j={Text:e=>(0,n.jsx)(r.Text,{component:`div`,className:`mantine-datatable-pagination-text`,size:d,...e,children:E}),PageSizeSelector:e=>y?(0,n.jsx)(Xt,{activeTextColor:l,activeBackgroundColor:u,size:d,label:v,values:y,value:g,onChange:_,...e}):(0,n.jsx)(n.Fragment,{}),Pagination:e=>(0,n.jsx)(r.Pagination,{classNames:{root:G(`mantine-datatable-pagination-pages`,{"mantine-datatable-pagination-pages-fetching":i||!b}),control:`mantine-datatable-pagination-pages-control`},style:l||u?e=>Kt({theme:e,paginationActiveTextColor:l,paginationActiveBackgroundColor:u}):void 0,withEdges:s,withControls:c,value:a,onChange:o,size:d,total:D,getControlProps:C,getItemProps:w,...e})},M={state:{paginationSize:d,page:a,totalPages:D,totalRecords:h,recordsPerPage:g,recordsLength:b,fetching:i,from:O,to:k,isWrapped:A},actions:{setPage:e=>o?.(e),setRecordsPerPage:_?e=>_(e):void 0},Controls:j};return(0,n.jsx)(r.Box,{px:x??`xs`,py:`xs`,className:G(`mantine-datatable-pagination`,e),style:[{flexDirection:A?`column`:`row`},t],children:typeof T==`function`?T(M):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(j.Text,{}),(0,n.jsx)(j.PageSizeSelector,{}),(0,n.jsx)(j.Pagination,{})]})})}function Qt({className:e,style:t,visibleMediaQuery:i,record:a,index:o,onClick:s,onDoubleClick:c,onContextMenu:l,noWrap:u,ellipsis:d,textAlign:f,width:p,accessor:m,render:h,defaultRender:g,customCellAttributes:_}){return J(i)?(0,n.jsx)(r.TableTd,{className:G({[wt]:u||d,[Tt]:d,[X]:s||c,[Et]:l,[Z]:f===`left`,[Q]:f===`center`,[Ot]:f===`right`},e),style:[{width:p,minWidth:p,maxWidth:p},t],onClick:s,onDoubleClick:c,onContextMenu:l,..._?.(a,o),children:h?h(a,o):g?g(a,o,m):gt(a,m)}):null}function $t({open:e,colSpan:t,content:i,collapseProps:a}){let{expanded:o,visible:s}=Ct(e,a?.transitionDuration);return s?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.TableTr,{}),(0,n.jsx)(r.TableTr,{children:(0,n.jsx)(r.TableTd,{className:`mantine-datatable-row-expansion-cell`,colSpan:t,children:(0,n.jsx)(r.Collapse,{expanded:o,...a,children:(0,n.jsx)(`div`,{className:`mantine-datatable-row-expansion-cell-content`,children:i()})})})})]}):null}function en({className:e,style:t,record:i,index:a,trigger:o,onChange:s,withRightShadow:c,checkboxProps:l,getCheckboxProps:u,...d}){let f={...l,...u(i,a)},p=!d.disabled&&!f.disabled,m=e=>{e.stopPropagation(),o===`cell`&&p&&s?.(e)};return(0,n.jsx)(r.TableTd,{className:G(`mantine-datatable-row-selector-cell`,{[X]:o===`cell`&&p},e),style:t,"data-shadow-visible":c||void 0,onClick:m,children:(0,n.jsx)(r.Checkbox,{classNames:p?{input:X}:void 0,onChange:s,...d,...f})})}function tn({record:e,index:t,columns:i,defaultColumnProps:a,defaultColumnRender:o,selectionTrigger:s,selectionVisible:c,selectionChecked:l,onSelectionChange:u,isRecordSelectable:d,selectionCheckboxProps:f,getSelectionCheckboxProps:p,onClick:m,onDoubleClick:h,onContextMenu:g,onCellClick:_,onCellDoubleClick:v,onCellContextMenu:y,expansion:b,customAttributes:x,color:S,backgroundColor:C,className:w,style:T,selectorCellShadowVisible:E,selectionColumnClassName:D,selectionColumnStyle:O,rowFactory:k}){let A=(0,n.jsxs)(n.Fragment,{children:[c&&(0,n.jsx)(en,{className:D,style:O,record:e,index:t,trigger:s,withRightShadow:E,checked:l,disabled:!u||(d?!d(e,t):!1),onChange:u,checkboxProps:f,getCheckboxProps:p}),i.map(({hidden:r,hiddenContent:i,...s},c)=>{if(r||i)return null;let{accessor:l,visibleMediaQuery:u,textAlign:d,noWrap:f,ellipsis:p,width:m,render:h,cellsClassName:g,cellsStyle:b,customCellAttributes:x}={...a,...s};return(0,n.jsx)(Qt,{className:typeof g==`function`?g(e,t):g,style:b?.(e,t),visibleMediaQuery:u,record:e,index:t,onClick:_?n=>_({event:n,record:e,index:t,column:s,columnIndex:c}):void 0,onDoubleClick:v?n=>v({event:n,record:e,index:t,column:s,columnIndex:c}):void 0,onContextMenu:y?n=>y({event:n,record:e,index:t,column:s,columnIndex:c}):void 0,accessor:l,textAlign:d,noWrap:f,ellipsis:p,width:m,render:h,defaultRender:o,customCellAttributes:x},l)})]}),j=b&&(0,n.jsx)($t,{colSpan:i.filter(({hidden:e})=>!e).length+ +!!c,open:b.isRowExpanded(e),content:b.content({record:e,index:t}),collapseProps:b.collapseProps}),M=nn({record:e,index:t,selectionChecked:l,onClick:m,onDoubleClick:h,onContextMenu:g,expansion:b,customAttributes:x,color:S,backgroundColor:C,className:w,style:T});return k?k({record:e,index:t,rowProps:M,children:A,expandedElement:j}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.TableTr,{...M,children:A}),j]})}function nn({record:e,index:t,selectionChecked:n,onClick:r,onDoubleClick:i,onContextMenu:a,expansion:o,customAttributes:s,color:c,backgroundColor:l,className:u,style:d}){return{className:G(`mantine-datatable-row`,{[X]:r||i||o?.isExpandable({record:e,index:t})&&o?.expandOnClick},{[Et]:a},typeof u==`function`?u(e,t):u),"data-selected":n||void 0,onClick:n=>{if(o){let{isExpandable:n,isRowExpanded:r,expandOnClick:i,expandRow:a,collapseRow:s}=o;n({record:e,index:t})&&i&&(r(e)?s(e):a(e))}r?.({event:n,record:e,index:t})},onDoubleClick:i?n=>i({event:n,record:e,index:t}):void 0,onContextMenu:a?n=>a({event:n,record:e,index:t}):void 0,style:[c||l?n=>{let r=c?.(e,t),i=l?.(e,t);return qt({theme:n,color:r,backgroundColor:i})}:void 0,d?.(e,t)],...s?.(e,t)??{}}}function rn({leftShadowBehind:e,rightShadowBehind:t,onScrollPositionChange:i,children:a,viewportRef:o,scrollAreaProps:s}){return(0,n.jsxs)(r.ScrollArea,{...s,viewportRef:o,classNames:{root:`mantine-datatable-scroll-area`,scrollbar:`mantine-datatable-scroll-area-scrollbar`,thumb:`mantine-datatable-scroll-area-thumb`,corner:`mantine-datatable-scroll-area-corner`},onScrollPositionChange:i,children:[a,(0,n.jsx)(r.Box,{className:G(`mantine-datatable-scroll-area-shadow`,`mantine-datatable-scroll-area-top-shadow`)}),(0,n.jsx)(`div`,{className:G(`mantine-datatable-scroll-area-shadow`,`mantine-datatable-scroll-area-left-shadow`,{"mantine-datatable-scroll-area-shadow-behind":e})}),(0,n.jsx)(`div`,{className:G(`mantine-datatable-scroll-area-shadow`,`mantine-datatable-scroll-area-right-shadow`,{"mantine-datatable-scroll-area-shadow-behind":t})}),(0,n.jsx)(r.Box,{className:G(`mantine-datatable-scroll-area-shadow`,`mantine-datatable-scroll-area-bottom-shadow`)})]})}function an({withTableBorder:e,borderRadius:i,textSelectionDisabled:a,height:o=`100%`,minHeight:c,maxHeight:l,shadow:u,verticalAlign:d=`center`,fetching:f,columns:p,storeColumnsKey:m,groups:h,pinFirstColumn:g,pinLastColumn:_,defaultColumnProps:v,defaultColumnRender:y,idAccessor:b=`id`,records:x,selectionTrigger:S=`checkbox`,selectedRecords:C,onSelectedRecordsChange:w,selectionColumnClassName:T,selectionColumnStyle:E,isRecordSelectable:D,selectionCheckboxProps:O,allRecordsSelectionCheckboxProps:k={"aria-label":`Select all records`},getRecordSelectionCheckboxProps:A=(e,t)=>({"aria-label":`Select record ${t+1}`}),sortStatus:j,sortIcons:M,onSortStatusChange:ee,horizontalSpacing:N,page:P,onPageChange:F,totalRecords:te,recordsPerPage:ne,onRecordsPerPageChange:re,recordsPerPageOptions:ie,recordsPerPageLabel:I=`Records per page`,paginationWithEdges:ae,paginationWithControls:oe,paginationActiveTextColor:se,paginationActiveBackgroundColor:ce,paginationSize:le=`sm`,paginationText:ue=({from:e,to:t,totalRecords:n})=>`${e} - ${t} / ${n}`,paginationWrapBreakpoint:L=`sm`,getPaginationControlProps:de=e=>e===`previous`?{"aria-label":`Previous page`}:e===`next`?{"aria-label":`Next page`}:{},getPaginationItemProps:fe,renderPagination:R,loaderBackgroundBlur:z,customLoader:pe,loaderSize:me,loaderType:he,loaderColor:ge,loadingText:B=`...`,emptyState:V,noRecordsText:_e=`No records`,noRecordsIcon:ve,highlightOnHover:ye,striped:be,noHeader:xe,onRowClick:Se,onRowDoubleClick:Ce,onRowContextMenu:we,onCellClick:H,onCellDoubleClick:Te,onCellContextMenu:Ee,onScroll:De,onScrollToTop:Oe,onScrollToBottom:ke,onScrollToLeft:U,onScrollToRight:Ae,c:W,backgroundColor:je,borderColor:Me,rowBorderColor:Ne,stripedColor:Pe,highlightOnHoverColor:Fe,rowColor:Ie,rowBackgroundColor:Le,rowExpansion:Re,rowClassName:ze,rowStyle:Be,customRowAttributes:Ve,scrollViewportRef:He,scrollAreaProps:Ue,tableRef:We,bodyRef:Ge,m:Je,my:Xe,mx:Ze,mt:Qe,mb:et,ml:tt,mr:nt,className:rt,classNames:K,style:it,styles:q,rowFactory:at,tableWrapper:ot,...lt}){let ut=(0,t.useMemo)(()=>h?vt(h):p,[p,h]),[dt,ft]=(0,t.useState)(!1),{refs:J,onScroll:pt}=st({scrollCallbacks:{onScroll:De,onScrollToTop:Oe,onScrollToBottom:ke,onScrollToLeft:U,onScrollToRight:Ae},withRowBorders:lt.withRowBorders}),gt=$e({key:m,columns:ut,headerRef:J.header,scrollViewportRef:J.scrollViewport,onFixedLayoutChange:ft}),_t=(0,s.useMergedRef)(J.table,We),yt=(0,s.useMergedRef)(J.scrollViewport,He),bt=St({rowExpansion:Re,records:x,idAccessor:b}),xt=(0,t.useRef)(!1),Ct=(0,t.useRef)(P),wt=(0,t.useRef)(x),Tt=(0,t.useCallback)(e=>{xt.current=!0,wt.current=x,F(e)},[F,x]);(0,t.useEffect)(()=>{Ct.current!==P&&(xt.current=!0,wt.current=x,Ct.current=P)},[P,x]);let X=x?.length;(0,t.useLayoutEffect)(()=>{if(!xt.current||f||x===wt.current)return;let e=J.scrollViewport.current;if(!e)return;let t=requestAnimationFrame(()=>{e.scrollTo({top:0,left:0}),xt.current=!1});return()=>cancelAnimationFrame(t)},[f,x,J.scrollViewport]);let Et=x?.map(e=>Y(e,b)),Z=!!C,Q=C?.map(e=>Y(e,b)),Ot=Et!==void 0&&Q!==void 0&&Q.length>0,kt=D?x?.filter(D):x,At=kt?.map(e=>Y(e,b)),Mt=Ot&&At.every(e=>Q.includes(e)),Nt=Ot&&At.some(e=>Q.includes(e)),Pt=(0,t.useCallback)(()=>{C&&w&&w(Mt?C.filter(e=>!At.includes(Y(e,b))):ht([...C,...kt],e=>Y(e,b)))},[Mt,b,w,At,kt,C]),{lastSelectionChangeIndex:Ft,setLastSelectionChangeIndex:It}=ct(Et),Lt=Z&&!g,Rt={m:Je,my:Xe,mx:Ze,mt:Qe,mb:et,ml:tt,mr:nt},zt=(0,t.useCallback)(({children:e})=>ot?ot({children:e}):e,[ot]);return(0,n.jsx)(Ke,{...gt,children:(0,n.jsxs)(r.Box,{ref:J.root,...Rt,className:G(`mantine-datatable`,{"mantine-datatable-with-border":e},rt,K?.root),style:[e=>({...Gt({theme:e,c:W,backgroundColor:je,borderColor:Me,rowBorderColor:Ne,stripedColor:Pe,highlightOnHoverColor:Fe}),borderRadius:e.radius[i]||i,boxShadow:e.shadows[u]||u,height:o,minHeight:c,maxHeight:l}),it,q?.root,{position:`relative`}],children:[(0,n.jsx)(rn,{viewportRef:yt,leftShadowBehind:Z||!!g,rightShadowBehind:_,onScrollPositionChange:pt,scrollAreaProps:Ue,children:(0,n.jsx)(zt,{children:(0,n.jsxs)(r.Table,{ref:_t,horizontalSpacing:N,className:G(`mantine-datatable-table`,{[Dt]:a,"mantine-datatable-vertical-align-top":d===`top`,"mantine-datatable-vertical-align-bottom":d===`bottom`,"mantine-datatable-pin-last-column":_,"mantine-datatable-selection-column-visible":Z,"mantine-datatable-pin-first-column":g,"mantine-datatable-resizable-columns":gt.hasResizableColumns&&dt},K?.table),style:{...q?.table},"data-striped":X&&be||void 0,"data-highlight-on-hover":ye||void 0,...lt,children:[xe?null:(0,n.jsx)(Ke,{...gt,children:(0,n.jsx)(Ut,{ref:J.header,selectionColumnHeaderRef:J.selectionColumnHeader,className:K?.header,style:q?.header,columns:ut,defaultColumnProps:v,groups:h,sortStatus:j,sortIcons:M,onSortStatusChange:ee,selectionTrigger:S,selectionVisible:Z,selectionChecked:Mt,selectionIndeterminate:Nt&&!Mt,onSelectionChange:Pt,selectionCheckboxProps:{...O,...k},selectorCellShadowVisible:Lt,selectionColumnClassName:T,selectionColumnStyle:E,withColumnBorders:lt.withColumnBorders})}),(0,n.jsx)(`tbody`,{ref:Ge,children:X?x.map((e,t)=>{let r=Y(e,b),i=Q?.includes(r)||!1,a;return w&&C&&(a=n=>{if(n.nativeEvent.shiftKey&&Ft!==null){let e=x.filter(t>Ft?(e,n)=>n>=Ft&&n<=t&&(D?D(e,n):!0):(e,n)=>n>=t&&n<=Ft&&(D?D(e,n):!0));w(i?mt(C,e,e=>Y(e,b)):ht([...C,...e],e=>Y(e,b)))}else w(i?C.filter(e=>Y(e,b)!==r):ht([...C,e],e=>Y(e,b)));It(t)}),(0,n.jsx)(tn,{record:e,index:t,columns:ut,defaultColumnProps:v,defaultColumnRender:y,selectionTrigger:S,selectionVisible:Z,selectionChecked:i,onSelectionChange:a,isRecordSelectable:D,selectionCheckboxProps:O,getSelectionCheckboxProps:A,onClick:Se,onDoubleClick:Ce,onCellClick:H,onCellDoubleClick:Te,onContextMenu:we,onCellContextMenu:Ee,expansion:bt,color:Ie,backgroundColor:Le,className:ze,style:Be,customAttributes:Ve,selectorCellShadowVisible:Lt,selectionColumnClassName:T,selectionColumnStyle:E,idAccessor:b,rowFactory:at},r)}):(0,n.jsx)(qe,{})}),ut.some(({footer:e})=>e)&&(0,n.jsx)(jt,{ref:J.footer,className:K?.footer,style:q?.footer,columns:ut,defaultColumnProps:v,selectionVisible:Z,selectorCellShadowVisible:Lt})]})})}),!!(P&&X)&&(0,n.jsx)(Zt,{className:K?.pagination,style:q?.pagination,horizontalSpacing:N,fetching:f,page:P,onPageChange:Tt,totalRecords:te,recordsPerPage:ne,onRecordsPerPageChange:re,recordsPerPageOptions:ie,recordsPerPageLabel:I,paginationWithEdges:ae,paginationWithControls:oe,paginationActiveTextColor:se,paginationActiveBackgroundColor:ce,paginationSize:le,paginationText:ue,paginationWrapBreakpoint:L,getPaginationControlProps:de,getPaginationItemProps:fe,noRecordsText:_e,loadingText:B,recordsLength:X,renderPagination:R}),(0,n.jsx)(Wt,{fetching:f,backgroundBlur:z,customContent:pe,size:me,type:he,color:ge}),(0,n.jsx)(Ye,{icon:ve,text:_e,active:!f&&!X,children:V})]})})}function on({fields:e,onClose:o,queryKey:s,apiPath:c,id:l,steps:u}){let[d,f]=(0,t.useState)(0),[p,m]=(0,t.useState)(!1),{data:h,isLoading:g}=Le(c,s,l),{mutateAsync:_,isError:v,error:y,isPending:b}=Be(c,s),x=[...new Set(e.filter(e=>typeof e.step==`number`).map(e=>e.step))],S=(0,i.useForm)({mode:`uncontrolled`,initialValues:e.reduce((e,t)=>(e[t.id]=t.type===`boolean`?t.defaultValue??!1:t.defaultValue??``,e),{}),validate:e.filter(e=>e.required).reduce((e,t)=>(e[t.id]=(e,n)=>t.conditional&&!t.conditional(n)||!(typeof t.required==`function`?t.required(n):t.required)||e?null:`Pflichtfeld`,e),{})});(0,t.useEffect)(()=>{if(h){let t={...h};e.forEach(e=>{let n=e.id;e.type===`boolean`&&t[n]===null?t[n]=!1:e.type===`date`&&t[n]?t[n]=new Date(t[n]):t[n]===null&&(t[n]=``)}),S.initialize(t),S.setValues(t)}},[h]);function C(e,t){return typeof e.required==`function`?e.required(t??{}):!!e.required}function w(e){let i=S.getValues();if(e.conditional&&!e.conditional(i))return null;let o=C(e,i);return(0,n.jsxs)(t.Fragment,{children:[(e.type===void 0||e.type==`text`)&&(0,n.jsx)(r.TextInput,{label:e.column.title,placeholder:e.placeholder??``,...S.getInputProps(e.id),type:e.id.includes(`email`)?`email`:void 0,required:o},S.key(e.id)),e.type===`number`&&(0,n.jsx)(r.NumberInput,{decimalSeparator:`,`,label:e.column.title,placeholder:e.placeholder??``,...S.getInputProps(e.id),required:o},S.key(e.id)),e.type===`date`&&(0,n.jsx)(a.DateInput,{label:e.column.title,placeholder:e.placeholder??``,valueFormat:`DD.MM.YYYY`,clearable:!0,...S.getInputProps(e.id),required:o},S.key(e.id)),e.type===`boolean`&&(0,n.jsx)(r.Checkbox,{mt:`md`,label:e.column.title,...S.getInputProps(e.id,{type:`checkbox`}),required:o},S.key(e.id)),e.type===`textarea`&&(0,n.jsx)(r.Textarea,{label:e.column.title,placeholder:e.placeholder??``,...S.getInputProps(e.id),minRows:3,autosize:!0,required:o},S.key(e.id)),e.type===`custom`&&e.render&&e.render({...S.getValues(),id:l},S.setValues,m,{error:S.getInputProps(e.id).error,required:o})]},e.id)}return(0,n.jsxs)(n.Fragment,{children:[v&&(0,n.jsx)(r.Alert,{variant:`outline`,color:`red`,title:y?.name??`Fehler aufgetreten`,mb:`lg`,children:y?.message??`Fehler aufgetreten`}),g?(0,n.jsxs)(r.Stack,{gap:`md`,children:[(0,n.jsx)(r.Skeleton,{height:40}),Array(e.length).fill(0).map((e,t)=>(0,n.jsx)(r.Skeleton,{height:35},`skeleton-field-${t}`)),(0,n.jsxs)(r.Group,{mt:`md`,justify:`end`,children:[(0,n.jsx)(r.Skeleton,{width:100,height:36}),(0,n.jsx)(r.Skeleton,{width:100,height:36})]})]}):(0,n.jsxs)(`form`,{onSubmit:S.onSubmit(async e=>{let t=Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t===``?void 0:t]));await _({...t,id:l}),x.length&&d<x.length-1?v||f(d+1):v||(S.setInitialValues(t),S.reset(),o())}),children:[x.length?(0,n.jsx)(r.Stepper,{active:d,size:`sm`,children:x.map(t=>(0,n.jsx)(r.Stepper.Step,{...u&&u[t-1]?{label:u[t-1].label}:{},children:e.filter(e=>e.step===t).map(e=>w(e))},t))}):e.map(e=>w(e)),!p&&(0,n.jsxs)(r.Group,{mt:`md`,justify:`end`,children:[(0,n.jsx)(r.Button,{onClick:()=>x.length?d===0?o():f(d-1):o(),variant:`outline`,children:x.length?d===0?`Abbrechen`:`Zurück`:`Abbrechen`}),(0,n.jsx)(r.Button,{type:`submit`,loading:b,children:x.length?d===x.length-1?`Speichern`:`Weiter`:`Speichern`})]})]})]})}function sn({queryKey:e,apiPath:i,onClose:a,selectedRecords:o}){let{mutateAsync:s,isError:c,error:l,isPending:u}=Ve(i,e),[d,f]=(0,t.useState)(o),[p,m]=(0,t.useState)(!1),h=p||u;return(0,t.useEffect)(()=>{d.length||a()},[a,d]),d.length?(0,n.jsxs)(n.Fragment,{children:[c&&l.message&&(0,n.jsx)(r.Alert,{variant:`outline`,color:`red`,title:l.name,children:l.message}),(0,n.jsx)(r.Text,{children:d.length===1?`Soll ${d.length} Eintrag wirklich gelöscht werden?`:`Sollen ${d.length} Einträge wirklich gelöscht werden?`}),(0,n.jsxs)(r.Group,{mt:`md`,justify:`end`,children:[(0,n.jsx)(r.Button,{onClick:a,variant:`outline`,disabled:h,children:`Abbrechen`}),(0,n.jsx)(r.Button,{color:`red`,loading:h,onClick:async()=>{m(!0);try{await Promise.all(d.map(e=>s(e.id))),f([])}finally{m(!1)}},children:`Löschen`})]})]}):(0,n.jsx)(n.Fragment,{})}function cn(e,n){let[r,i]=(0,t.useState)(()=>{let t=localStorage.getItem(`use_persistent_storage_${n}`);return t?JSON.parse(t):e});return[r,e=>{i(e),localStorage.setItem(`use_persistent_storage_${n}`,JSON.stringify(e))}]}var ln=[/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,/^\d{4}-\d{2}-\d{2}$/,/^\d{1,2}\/\d{1,2}\/\d{4}$/,/^\d{1,2}\.\d{1,2}\.\d{4}$/],un=(e,t)=>{let n=e.map(e=>e[t]).filter(e=>e!=null&&e!==``);if(n.length===0)return`string`;let r=n.slice(0,100),i={string:0,number:0,date:0};r.forEach(e=>{if(typeof e==`number`)i.number++;else if(typeof e==`string`){let t=e.trim();if(t!==``&&!isNaN(Number(t))&&!isNaN(parseFloat(t))){i.number++;return}if(ln.some(e=>e.test(t))){let e=new Date(t);if(!isNaN(e.getTime())){i.date++;return}}i.string++}else e instanceof Date?i.date++:i.string++});let a=i.string+i.number+i.date;return i.date/a>=.6?`date`:i.number/a>=.6?`number`:i.string/a>=.6?`string`:`mixed`};function dn(e,t){switch(t){case`date`:if(typeof e==`string`){let t=new Date(e.trim());return isNaN(t.getTime())?null:t.getTime()}return e instanceof Date?e.getTime():null;case`number`:if(typeof e==`number`)return e;let t=parseFloat(String(e).trim());return isNaN(t)?null:t;case`string`:return(typeof e==`string`?e:String(e)).toLowerCase().trim();default:return String(e).toLowerCase().trim()}}var fn=(e,t,n=`asc`)=>{if(!e||e.length===0)return[];let r=un(e,t);return[...e].sort((e,i)=>{let a=e[t],o=i[t],s=a==null||a===``,c=o==null||o===``;if(s&&c)return 0;if(s)return n===`asc`?-1:1;if(c)return n===`asc`?1:-1;let l=dn(a,r),u=dn(o,r);return l===null&&u===null?0:l===null?n===`asc`?1:-1:u===null||l<u?n===`asc`?-1:1:l>u?n===`asc`?1:-1:0})};function pn(e,t){return t.split(`.`).reduce((e,t)=>{if(e&&typeof e==`object`&&t in e)return e[t]},e)}function mn(e,t){let i=t.column;if(i.render)return i.render(e,0);let a=pn(e,i.accessor??t.id);return a==null?(0,n.jsx)(r.Text,{c:`dimmed`,children:`–`}):typeof a==`boolean`?(0,n.jsx)(r.Text,{fz:`sm`,children:a?`Ja`:`Nein`}):(0,n.jsx)(r.Text,{fz:`sm`,children:String(a)})}function hn({field:e,record:t}){return(0,n.jsxs)(r.Group,{wrap:`nowrap`,justify:`space-between`,align:`center`,py:`xs`,px:`sm`,children:[(0,n.jsx)(r.Text,{fw:700,fz:`sm`,children:e.column.title??e.id}),(0,n.jsx)(r.Box,{ta:`right`,fz:`sm`,children:mn(t,e)})]})}function gn({records:e,fields:i,selection:a,selectedRecords:s=[],onSelectedRecordsChange:c,onRowClick:l,actions:u,canUpdate:d,canDelete:f,pagination:p,sort:m,rowExpansion:h}){let[g,_]=(0,t.useState)(new Set),v=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},y=i.filter(e=>e.list&&e.column),b=y.filter(e=>e.column.sortable!==!1).reduce((e,t)=>{let n=t.column.accessor??t.id;return e.some(e=>e.value===n)||e.push({value:n,label:t.column.title??t.id}),e},[]),x=e=>s.some(t=>t.id===e.id),S=e=>{c&&(x(e)?c(s.filter(t=>t.id!==e.id)):c([...s,e]))},C=(e,t,n)=>{l?l({record:e,index:t,event:n}):a&&S(e)};return e.length===0?(0,n.jsx)(r.Text,{c:`dimmed`,ta:`center`,py:`xl`,children:`Keine Einträge gefunden`}):(0,n.jsxs)(r.Stack,{gap:`sm`,my:`md`,children:[m&&b.length>0&&(0,n.jsxs)(r.Group,{gap:`xs`,wrap:`nowrap`,children:[(0,n.jsx)(r.Select,{data:b,value:m.field,onChange:e=>e&&m.onSortChange(e,m.direction),allowDeselect:!1,style:{flex:1}}),(0,n.jsx)(r.ActionIcon,{variant:`filled`,size:`input-sm`,onClick:()=>m.onSortChange(m.field,m.direction===`asc`?`desc`:`asc`),children:m.direction===`asc`?(0,n.jsx)(o.IconSortAscending,{size:18}):(0,n.jsx)(o.IconSortDescending,{size:18})})]}),e.map((e,i)=>{let s=x(e),c=!!l||!!a,p=e.id??i,m=g.has(p);return(0,n.jsx)(t.default.Fragment,{children:(0,n.jsxs)(r.Box,{bg:s?`var(--mantine-primary-color-light)`:`var(--mantine-color-body)`,bd:s?void 0:`1px solid var(--mantine-color-default-border)`,style:{borderRadius:`var(--mantine-radius-md)`,overflow:`hidden`},children:[(0,n.jsxs)(r.Box,{w:`100%`,style:{cursor:c||h?`pointer`:`default`},onClick:t=>{h&&!l?v(p):C(e,i,t)},children:[(a||h||u&&u.length>0)&&(0,n.jsxs)(r.Group,{px:`sm`,pt:`sm`,justify:`space-between`,children:[(0,n.jsxs)(r.Group,{gap:`xs`,children:[h&&(0,n.jsx)(r.Box,{c:`var(--mantine-primary-color-filled)`,style:{cursor:`pointer`,display:`flex`,alignItems:`center`},onClick:e=>{e.stopPropagation(),v(p)},children:(0,n.jsx)(o.IconChevronDown,{size:16,style:{transform:m?`rotate(0deg)`:`rotate(-90deg)`,transition:`transform 200ms`}})}),a&&(0,n.jsx)(r.Checkbox,{checked:s,onChange:()=>S(e),onClick:e=>e.stopPropagation()})]}),u&&u.length>0&&(()=>{let t=u.filter(t=>!(t.label===`Bearbeiten`&&d&&!d(e)||t.label===`Löschen`&&f&&!f(e)));return t.length===0?null:(0,n.jsxs)(r.Menu,{shadow:`md`,position:`bottom-end`,children:[(0,n.jsx)(r.Menu.Target,{children:(0,n.jsx)(r.ActionIcon,{variant:`subtle`,color:`gray`,size:`sm`,onClick:e=>e.stopPropagation(),children:(0,n.jsx)(o.IconDotsVertical,{size:16})})}),(0,n.jsx)(r.Menu.Dropdown,{children:t.map((t,i)=>(0,n.jsx)(r.Menu.Item,{leftSection:t.icon,onClick:n=>{n.stopPropagation(),t.onClick([e])},children:t.label},`card_action_${i}`))})]})})()]}),y.map((i,a)=>(0,n.jsxs)(t.default.Fragment,{children:[a>0&&(0,n.jsx)(r.Divider,{}),(0,n.jsx)(hn,{field:i,record:e})]},i.id))]}),h&&(0,n.jsxs)(r.Collapse,{expanded:m,children:[(0,n.jsx)(r.Divider,{}),(0,n.jsx)(r.Box,{px:`sm`,py:`sm`,children:h.content(e)})]})]})},p)}),p&&p.totalRecords>p.recordsPerPage&&(0,n.jsxs)(r.Stack,{gap:`xs`,mt:`sm`,children:[(0,n.jsx)(r.Group,{justify:`center`,children:(0,n.jsx)(r.Pagination,{total:Math.ceil(p.totalRecords/p.recordsPerPage),value:p.page,onChange:p.onPageChange,size:`sm`})}),p.recordsPerPageOptions&&p.onRecordsPerPageChange&&(0,n.jsxs)(r.Group,{justify:`center`,gap:`xs`,children:[(0,n.jsx)(r.Text,{fz:`xs`,c:`dimmed`,children:`Einträge pro Seite:`}),(0,n.jsx)(r.Select,{data:p.recordsPerPageOptions.map(e=>({value:String(e),label:String(e)})),value:String(p.recordsPerPage),onChange:e=>e&&p.onRecordsPerPageChange(Number(e)),allowDeselect:!1,size:`xs`,w:70})]})]})]})}var _n=[10,15,50,100,500];function vn({title:e,queryKey:i,connectedQueryKeys:a,apiPath:s,mutationApiPath:c,buttons:l,fields:u,selection:d,pagination:f,filters:p,actions:m,steps:h,defaultSort:g,onSortChange:_,createButtonText:v,queryParams:y,tabs:b,defaultTab:x,activeTab:S,onActiveTabChange:C,canUpdate:w,canDelete:T,showRefresh:E=!0,rowExpansion:D,onRowClick:O,mobileCards:k=!1}){let[A,j]=(0,t.useState)(x||(b&&b.length>0?b[0].value:null)),M=S===void 0?A:S,ee=e=>{S===void 0&&j(e),C&&C(e)},N=b?.find(e=>e.value===M),P=N?.queryParams||{},F=N?.apiPath??s,te=N?.mutationApiPath??c??F,ne={...y,...P},re=ne?`?`+Object.entries(ne).filter(([,e])=>e!=null).map(([e,t])=>`${e}=${encodeURIComponent(t??``)}`).join(`&`):``,ie=M?[...i,M]:i,{data:I,isLoading:ae,isError:oe,isRefetching:se,refetch:ce}=Re(F+re,ie),{queryClient:le}=U();(0,t.useEffect)(()=>{!I||!Array.isArray(I)||a?.forEach(e=>le.invalidateQueries({queryKey:e}))},[I,a,le]);let ue=!I||!Array.isArray(I)?[]:!p||p.length===0?I:I.filter(e=>p.every(t=>{if(t.value===void 0)return!0;let n=t.id;if(t.type===`query`){let r=e[n];return Array.isArray(t.value)?Array.isArray(r)?r.some(e=>{if(typeof e==`string`||typeof e==`number`)return t.value.includes(String(e));if(e&&typeof e==`object`){let n=e;if(`id`in n&&t.value.includes(n.id))return!0;for(let e in n){let r=n[e];if(typeof r==`string`&&t.value.includes(r)||r&&typeof r==`object`&&`id`in r&&t.value.includes(r.id))return!0}}return!1}):r&&typeof r==`object`&&`id`in r?t.value.includes(r.id):!1:typeof r==`string`&&r.includes(t.value)}else if(t.type===`date`){let r=t.value;if(!r)return!0;let[i,a]=r;if(!i&&!a)return!0;let o=e[n];if(typeof o==`string`){let e=o.split(` `)[0];if(i&&a)return e>=i&&e<=a;if(i&&!a)return e>=i;if(!i&&a)return e<=a}return!0}else if(t.type===`boolean`)return e[n]===t.value;return!0})),[L,de]=(0,t.useState)({columnAccessor:g?.field??u[0].id,direction:g?.direction??`desc`}),fe=e=>{de(e),_&&_(String(e.columnAccessor),e.direction)},R=fn(ue,L.columnAccessor,L.direction),[z,pe]=cn(_n[1],`mantine-table-page-size`),[me,he]=(0,t.useState)(1),ge=f?R.slice((me-1)*z,me*z):R,[B,V]=(0,t.useState)([]);(0,t.useEffect)(()=>{V([])},[M]);let[_e,ve]=(0,t.useState)(!1),[ye,be]=(0,t.useState)(!1),[xe,Se]=(0,t.useState)(!1),Ce=u.some(e=>e.update),we=u.some(e=>e.delete),H=[];return Ce&&H.push({icon:(0,n.jsx)(o.IconPencil,{size:14}),label:`Bearbeiten`,onClick:e=>{V(e),be(!0)}}),m&&H.push(...m),we&&H.push({icon:(0,n.jsx)(o.IconTrash,{size:14}),label:`Löschen`,onClick:e=>{V(e),Se(!0)}}),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(r.Group,{gap:`xs`,justify:e?`space-between`:`end`,align:`center`,wrap:`wrap`,children:[e&&(typeof e==`string`?(0,n.jsx)(r.Title,{order:4,children:e}):e),(0,n.jsxs)(r.Group,{align:`center`,gap:`xs`,wrap:`wrap`,justify:`end`,style:{marginLeft:`auto`},children:[E&&(0,n.jsx)(r.ActionIcon,{variant:`subtle`,onClick:()=>ce(),"aria-label":`Neuladen`,children:(0,n.jsx)(o.IconRefresh,{})}),(u.some(e=>e.update)||d)&&(()=>{let e=u.find(e=>e.update)&&(!w||B.length>0&&w(B[0])),i=u.find(e=>e.delete)&&(!T||B.length>0&&T(B[0])),a=(m??[]).length>0,s=e||i||a;return(0,n.jsx)(r.Box,{...k?{visibleFrom:`sm`}:{},children:(0,n.jsxs)(r.Menu,{shadow:`md`,children:[(0,n.jsx)(r.Menu.Target,{children:(0,n.jsx)(r.Button,{variant:`outline`,rightSection:(0,n.jsx)(o.IconCaretDownFilled,{size:14}),disabled:!B.length||!s,children:`Aktionen`})}),(0,n.jsxs)(r.Menu.Dropdown,{children:[e&&(0,n.jsx)(r.Menu.Item,{leftSection:(0,n.jsx)(o.IconPencil,{size:14}),onClick:()=>be(!0),disabled:B.length!==1,children:`Bearbeiten`}),(m??[]).map((e,n)=>(0,t.createElement)(r.Menu.Item,{...e.icon&&{leftSection:e.icon},key:`custom_action_${n}`,onClick:()=>e.onClick(B),disabled:e.disabled?.(B)??!1},e.label)),i&&(0,n.jsx)(r.Menu.Item,{leftSection:(0,n.jsx)(o.IconTrash,{size:14}),onClick:()=>Se(!0),color:`red`,children:`Löschen`})]})]})})})(),u.find(e=>e.create)&&(0,n.jsx)(r.Button,{onClick:()=>ve(!0),disabled:ae,children:v??`Erstellen`}),l]})]}),b&&b.length>0&&(0,n.jsx)(r.Tabs,{value:M,onChange:ee,mt:`md`,children:(0,n.jsx)(r.Tabs.List,{children:b.map(e=>(0,n.jsx)(r.Tabs.Tab,{value:e.value,leftSection:e.icon,children:e.label},e.value))})}),oe&&(0,n.jsx)(r.Alert,{mt:`md`,variant:`light`,color:`red`,title:`Es ist ein Fehler aufgetreten.`,icon:(0,n.jsx)(o.IconInfoCircle,{}),children:`Bitte versuche es später erneut oder sende eine Nachricht an unseren Support.`}),(ae||se)&&(0,n.jsxs)(r.Stack,{my:`md`,children:[(0,n.jsx)(r.Skeleton,{height:40}),[,,,,,].fill(0).map((e,t)=>(0,n.jsx)(r.Skeleton,{height:35},`skeleton-${t}`))]}),!ae&&!se&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.Box,{...k?{visibleFrom:`sm`}:{},children:(0,n.jsx)(an,{my:`md`,striped:!0,highlightOnHover:!0,minHeight:150,fetching:oe,records:ge,sortStatus:L,onSortStatusChange:fe,...d&&{selectedRecords:B,onSelectedRecordsChange:V},...f&&ge.length&&{totalRecords:R.length,recordsPerPage:z,onPageChange:he,page:me,recordsPerPageOptions:_n,onRecordsPerPageChange:pe,recordsPerPageLabel:`Einträge pro Seite`},...D&&{rowExpansion:{allowMultiple:D.allowMultiple??!1,content:({record:e})=>D.content(e),...D.expanded&&{expanded:D.expanded}}},columns:u.map(e=>e.column),noRecordsText:`Keine Einträge gefunden`,onRowClick:O,...O&&{style:{cursor:`pointer`}}})}),k&&(0,n.jsx)(r.Box,{hiddenFrom:`sm`,children:(0,n.jsx)(gn,{records:ge,fields:u,selection:d,selectedRecords:B,onSelectedRecordsChange:V,onRowClick:O,sort:{field:String(L.columnAccessor),direction:L.direction,onSortChange:(e,t)=>{fe({columnAccessor:e,direction:t})}},...f&&ge.length&&{pagination:{totalRecords:R.length,recordsPerPage:z,page:me,onPageChange:he,recordsPerPageOptions:_n,onRecordsPerPageChange:e=>{pe(e),he(1)}}},...D&&{rowExpansion:{content:D.content}},...H.length>0&&{actions:H,canUpdate:w,canDelete:T}})})]}),(0,n.jsx)(r.Modal,{opened:ye,onClose:()=>{be(!1),V([])},title:e??`Bearbeiten`,children:B.length>0&&(0,n.jsx)(on,{fields:u.filter(e=>e.update),queryKey:i,apiPath:te,id:B[0].id,onClose:()=>{be(!1),V([])},steps:h})}),B.length>0&&(0,n.jsx)(r.Modal,{opened:xe,onClose:()=>{Se(!1),V([])},title:e??`Löschen`,children:(0,n.jsx)(sn,{onClose:()=>{Se(!1),V([])},queryKey:i,apiPath:te,selectedRecords:B})}),(0,n.jsx)(r.Modal,{opened:_e,onClose:()=>{ve(!1)},title:e??`Anlegen`,children:(0,n.jsx)(He,{queryKey:i,apiPath:te,onClose:()=>{ve(!1)},fields:u.filter(e=>e.create),steps:h})})]})}function yn(e){return(0,n.jsx)(vn,{...e})}e.CreateModal=He,e.DataTable=yn,e.DataTableProvider=ke,e.DeleteModal=sn,e.MobileCardList=gn,e.UpdateModal=on,e.api=Fe,e.createOne=Pe,e.deleteOne=Ne,e.getAll=je,e.getOne=Me,e.parseApiError=Ae,e.sortData=fn,e.updateOne=Ie,e.useAddOne=ze,e.useDataTable=U,e.useDeleteOne=Ve,e.useGetAll=Re,e.useGetOne=Le,e.usePersistentState=cn,e.useUpdateOne=Be});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|