(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,37727,e=>{"use strict";let t=(0,e.i(75254).default)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);e.s(["X",0,t],37727)},54858,e=>{"use strict";let t="/api/v1";async function s(e,t){let s=await e.text();if(!s)return t;try{let e=JSON.parse(s);return e.detail??e.message??s}catch{return s}}async function r(e,t){let s=await fetch("/api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:t}),credentials:"include"});if(!s.ok){let e=Error(await s.text()||`HTTP ${s.status}`);throw e.status=s.status,e}return s.json()}async function i(e,s){let r=await fetch(`${t}${e}`,{cache:"no-store",credentials:"include"});if(!r.ok)throw Error(`API request failed: ${r.status}`);return r.json()}async function a(e,r,i,a){let n=await fetch(`${t}${e}`,{method:i,headers:{"Content-Type":"application/json"},body:JSON.stringify(a),credentials:"include"});if(!n.ok)throw Error(await s(n,`API request failed: ${n.status}`));return n.json()}async function n(e,r){let i=await fetch(`${t}${e}`,{method:"DELETE",credentials:"include"});if(!i.ok)throw Error(await s(i,`API request failed: ${i.status}`))}async function l(e,r,i){let a=await fetch(`${t}${e}`,{...i,headers:{"Content-Type":"application/json",...i?.headers??{}},credentials:"include"});if(!a.ok)throw Error(await s(a,`API request failed: ${a.status}`));return a.json()}e.s(["API_BASE",0,t,"apiDelete",0,n,"apiFetch",0,l,"apiGet",0,i,"apiSend",0,a,"login",0,r,"normalizeValidationPayload",0,function(e){return{...e,...Object.fromEntries(["contact_id","examiner_id"].map(t=>[t,e[t]||null]))}}])},66027,e=>{"use strict";let t;var s=e.i(75555),r=e.i(73911),i=e.i(40143),a=e.i(86491),n=e.i(15823),l=e.i(93803),o=e.i(19273),c=e.i(80166),u=class extends n.Subscribable{constructor(e,t){super(),this.options=t,this.#e=e,this.#t=null,this.#s=(0,l.pendingThenable)(),this.bindMethods(),this.setOptions(t)}#e;#r=void 0;#i=void 0;#a=void 0;#n;#l;#s;#t;#o;#c;#u;#h;#d;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#r.addObserver(this),h(this.#r,this.options)?this.#f():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return d(this.#r,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return d(this.#r,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#x(),this.#r.removeObserver(this)}setOptions(e){let t=this.options,s=this.#r;if(this.options=this.#e.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof(0,o.resolveQueryBoolean)(this.options.enabled,this.#r))throw Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#g(),this.#r.setOptions(this.options),t._defaulted&&!(0,o.shallowEqualObjects)(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#r,observer:this});let r=this.hasListeners();r&&p(this.#r,s,this.options,t)&&this.#f(),this.updateResult(),r&&(this.#r!==s||(0,o.resolveQueryBoolean)(this.options.enabled,this.#r)!==(0,o.resolveQueryBoolean)(t.enabled,this.#r)||(0,o.resolveStaleTime)(this.options.staleTime,this.#r)!==(0,o.resolveStaleTime)(t.staleTime,this.#r))&&this.#v();let i=this.#j();r&&(this.#r!==s||(0,o.resolveQueryBoolean)(this.options.enabled,this.#r)!==(0,o.resolveQueryBoolean)(t.enabled,this.#r)||i!==this.#p)&&this.#w(i)}getOptimisticResult(e){var t,s;let r=this.#e.getQueryCache().build(this.#e,e),i=this.createResult(r,e);return t=this,s=i,(0,o.shallowEqualObjects)(t.getCurrentResult(),s)||(this.#a=i,this.#l=this.options,this.#n=this.#r.state),i}getCurrentResult(){return this.#a}trackResult(e,t){return new Proxy(e,{get:(e,s)=>(this.trackProp(s),t?.(s),"promise"===s&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#s.status||this.#s.reject(Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,s))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#r}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),s=this.#e.getQueryCache().build(this.#e,t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return this.#f({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#a))}#f(e){this.#g();let t=this.#r.fetch(this.options,e);return e?.throwOnError||(t=t.catch(o.noop)),t}#v(){this.#y();let e=(0,o.resolveStaleTime)(this.options.staleTime,this.#r);if(r.environmentManager.isServer()||this.#a.isStale||!(0,o.isValidTimeout)(e))return;let t=(0,o.timeUntilStale)(this.#a.dataUpdatedAt,e);this.#h=c.timeoutManager.setTimeout(()=>{this.#a.isStale||this.updateResult()},t+1)}#j(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#r):this.options.refetchInterval)??!1}#w(e){this.#x(),this.#p=e,!r.environmentManager.isServer()&&!1!==(0,o.resolveQueryBoolean)(this.options.enabled,this.#r)&&(0,o.isValidTimeout)(this.#p)&&0!==this.#p&&(this.#d=c.timeoutManager.setInterval(()=>{(this.options.refetchIntervalInBackground||s.focusManager.isFocused())&&this.#f()},this.#p))}#b(){this.#v(),this.#w(this.#j())}#y(){void 0!==this.#h&&(c.timeoutManager.clearTimeout(this.#h),this.#h=void 0)}#x(){void 0!==this.#d&&(c.timeoutManager.clearInterval(this.#d),this.#d=void 0)}createResult(e,t){let s,r=this.#r,i=this.options,n=this.#a,c=this.#n,u=this.#l,d=e!==r?e.state:this.#i,{state:f}=e,b={...f},y=!1;if(t._optimisticResults){let s=this.hasListeners(),n=!s&&h(e,t),l=s&&p(e,r,t,i);(n||l)&&(b={...b,...(0,a.fetchState)(f.data,e.options)}),"isRestoring"===t._optimisticResults&&(b.fetchStatus="idle")}let{error:x,errorUpdatedAt:g,status:v}=b;s=b.data;let j=!1;if(void 0!==t.placeholderData&&void 0===s&&"pending"===v){let e;n?.isPlaceholderData&&t.placeholderData===u?.placeholderData?(e=n.data,j=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,void 0!==e&&(v="success",s=(0,o.replaceData)(n?.data,e,t),y=!0)}if(t.select&&void 0!==s&&!j)if(n&&s===c?.data&&t.select===this.#o)s=this.#c;else try{this.#o=t.select,s=t.select(s),s=(0,o.replaceData)(n?.data,s,t),this.#c=s,this.#t=null}catch(e){this.#t=e}this.#t&&(x=this.#t,s=this.#c,g=Date.now(),v="error");let w="fetching"===b.fetchStatus,R="pending"===v,S="error"===v,N=R&&w,k=void 0!==s,Q={status:v,fetchStatus:b.fetchStatus,isPending:R,isSuccess:"success"===v,isError:S,isInitialLoading:N,isLoading:N,data:s,dataUpdatedAt:b.dataUpdatedAt,error:x,errorUpdatedAt:g,failureCount:b.fetchFailureCount,failureReason:b.fetchFailureReason,errorUpdateCount:b.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:b.dataUpdateCount>d.dataUpdateCount||b.errorUpdateCount>d.errorUpdateCount,isFetching:w,isRefetching:w&&!R,isLoadingError:S&&!k,isPaused:"paused"===b.fetchStatus,isPlaceholderData:y,isRefetchError:S&&k,isStale:m(e,t),refetch:this.refetch,promise:this.#s,isEnabled:!1!==(0,o.resolveQueryBoolean)(t.enabled,e)};if(this.options.experimental_prefetchInRender){let t=void 0!==Q.data,s="error"===Q.status&&!t,i=e=>{s?e.reject(Q.error):t&&e.resolve(Q.data)},a=()=>{i(this.#s=Q.promise=(0,l.pendingThenable)())},n=this.#s;switch(n.status){case"pending":e.queryHash===r.queryHash&&i(n);break;case"fulfilled":(s||Q.data!==n.value)&&a();break;case"rejected":s&&Q.error===n.reason||a()}}return Q}updateResult(){let e=this.#a,t=this.createResult(this.#r,this.options);if(this.#n=this.#r.state,this.#l=this.options,void 0!==this.#n.data&&(this.#u=this.#r),(0,o.shallowEqualObjects)(t,e))return;this.#a=t;let s=()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,s="function"==typeof t?t():t;if("all"===s||!s&&!this.#m.size)return!0;let r=new Set(s??this.#m);return this.options.throwOnError&&r.add("error"),Object.keys(this.#a).some(t=>this.#a[t]!==e[t]&&r.has(t))};this.#R({listeners:s()})}#g(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#r)return;let t=this.#r;this.#r=e,this.#i=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#R(e){i.notifyManager.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#a)}),this.#e.getQueryCache().notify({query:this.#r,type:"observerResultsUpdated"})})}};function h(e,t){return!1!==(0,o.resolveQueryBoolean)(t.enabled,e)&&void 0===e.state.data&&("error"!==e.state.status||!1!==(0,o.resolveQueryBoolean)(t.retryOnMount,e))||void 0!==e.state.data&&d(e,t,t.refetchOnMount)}function d(e,t,s){if(!1!==(0,o.resolveQueryBoolean)(t.enabled,e)&&"static"!==(0,o.resolveStaleTime)(t.staleTime,e)){let r="function"==typeof s?s(e):s;return"always"===r||!1!==r&&m(e,t)}return!1}function p(e,t,s,r){return(e!==t||!1===(0,o.resolveQueryBoolean)(r.enabled,e))&&(!s.suspense||"error"!==e.state.status)&&m(e,s)}function m(e,t){return!1!==(0,o.resolveQueryBoolean)(t.enabled,e)&&e.isStaleByTime((0,o.resolveStaleTime)(t.staleTime,e))}e.i(47167);var f=e.i(71645),b=e.i(12598);e.i(43476);var y=f.createContext((t=!1,{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t})),x=f.createContext(!1);x.Provider;var g=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});e.s(["useQuery",0,function(e,t){return function(e,t,s){let a,n=f.useContext(x),l=f.useContext(y),c=(0,b.useQueryClient)(s),u=c.defaultQueryOptions(e);c.getDefaultOptions().queries?._experimental_beforeQuery?.(u);let h=c.getQueryCache().get(u.queryHash),d=!1!==e.subscribed;if(u._optimisticResults=n?"isRestoring":d?"optimistic":void 0,u.suspense){let e=e=>"static"===e?e:Math.max(e??1e3,1e3),t=u.staleTime;u.staleTime="function"==typeof t?(...s)=>e(t(...s)):e(t),"number"==typeof u.gcTime&&(u.gcTime=Math.max(u.gcTime,1e3))}a=h?.state.error&&"function"==typeof u.throwOnError?(0,o.shouldThrowError)(u.throwOnError,[h.state.error,h]):u.throwOnError,(u.suspense||u.experimental_prefetchInRender||a)&&!l.isReset()&&(u.retryOnMount=!1),f.useEffect(()=>{l.clearReset()},[l]);let p=!c.getQueryCache().get(u.queryHash),[m]=f.useState(()=>new t(c,u)),v=m.getOptimisticResult(u),j=!n&&d;if(f.useSyncExternalStore(f.useCallback(e=>{let t=j?m.subscribe(i.notifyManager.batchCalls(e)):o.noop;return m.updateResult(),t},[m,j]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),f.useEffect(()=>{m.setOptions(u)},[u,m]),u?.suspense&&v.isPending)throw g(u,m,l);if((({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&void 0===e.data||(0,o.shouldThrowError)(s,[e.error,r])))({result:v,errorResetBoundary:l,throwOnError:u.throwOnError,query:h,suspense:u.suspense}))throw v.error;if(c.getDefaultOptions().queries?._experimental_afterQuery?.(u,v),u.experimental_prefetchInRender&&!r.environmentManager.isServer()&&v.isLoading&&v.isFetching&&!n){let e=p?g(u,m,l):h?.promise;e?.catch(o.noop).finally(()=>{m.updateResult()})}return u.notifyOnChangeProps?v:m.trackResult(v)}(e,u,t)}],66027)},54616,e=>{"use strict";var t=e.i(71645),s=e.i(14272),r=e.i(40143),i=e.i(15823),a=e.i(19273),n=class extends i.Subscribable{#e;#a=void 0;#S;#N;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#k()}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),(0,a.shallowEqualObjects)(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#S,observer:this}),t?.mutationKey&&this.options.mutationKey&&(0,a.hashKey)(t.mutationKey)!==(0,a.hashKey)(this.options.mutationKey)?this.reset():this.#S?.state.status==="pending"&&this.#S.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#S?.removeObserver(this)}onMutationUpdate(e){this.#k(),this.#R(e)}getCurrentResult(){return this.#a}reset(){this.#S?.removeObserver(this),this.#S=void 0,this.#k(),this.#R()}mutate(e,t){return this.#N=t,this.#S?.removeObserver(this),this.#S=this.#e.getMutationCache().build(this.#e,this.options),this.#S.addObserver(this),this.#S.execute(e)}#k(){let e=this.#S?.state??(0,s.getDefaultState)();this.#a={...e,isPending:"pending"===e.status,isSuccess:"success"===e.status,isError:"error"===e.status,isIdle:"idle"===e.status,mutate:this.mutate,reset:this.reset}}#R(e){r.notifyManager.batch(()=>{if(this.#N&&this.hasListeners()){let t=this.#a.variables,s=this.#a.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#N.onSuccess?.(e.data,t,s,r)}catch(e){Promise.reject(e)}try{this.#N.onSettled?.(e.data,null,t,s,r)}catch(e){Promise.reject(e)}}else if(e?.type==="error"){try{this.#N.onError?.(e.error,t,s,r)}catch(e){Promise.reject(e)}try{this.#N.onSettled?.(void 0,e.error,t,s,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#a)})})}},l=e.i(12598);e.s(["useMutation",0,function(e,s){let i=(0,l.useQueryClient)(s),[o]=t.useState(()=>new n(i,e));t.useEffect(()=>{o.setOptions(e)},[o,e]);let c=t.useSyncExternalStore(t.useCallback(e=>o.subscribe(r.notifyManager.batchCalls(e)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),u=t.useCallback((e,t)=>{o.mutate(e,t).catch(a.noop)},[o]);if(c.error&&(0,a.shouldThrowError)(o.options.throwOnError,[c.error]))throw c.error;return{...c,mutate:u,mutateAsync:c.mutate}}],54616)},55436,e=>{"use strict";let t=(0,e.i(75254).default)("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);e.s(["Search",0,t],55436)},27612,e=>{"use strict";let t=(0,e.i(75254).default)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);e.s(["Trash2",0,t],27612)},67240,e=>{"use strict";let t=(0,e.i(75254).default)("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);e.s(["RotateCcw",0,t],67240)},74886,e=>{"use strict";let t=(0,e.i(75254).default)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);e.s(["Copy",0,t],74886)},47086,e=>{"use strict";var t=e.i(43476),s=e.i(94814),r=e.i(54616),i=e.i(66027),a=e.i(12598),n=e.i(74886),l=e.i(67240),o=e.i(55436),c=e.i(27612);let u=(0,e.i(75254).default)("UserRoundPlus",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M22 19h-6",key:"vcuq98"}]]);var h=e.i(37727),d=e.i(71645),p=e.i(53145),m=e.i(50270),f=e.i(28779),b=e.i(54858);let y=m.z.object({first_name:m.z.string().min(1,"Vorname erforderlich"),last_name:m.z.string().min(1,"Nachname erforderlich"),email:m.z.string().email("Gueltige E-Mail erforderlich"),role:m.z.enum(["admin","pruefer","mitarbeiter","leser"]),is_active:m.z.boolean().default(!0),must_change_password:m.z.boolean().default(!0),temporary_password:m.z.string().min(12,"Mindestens 12 Zeichen")}),x={admin:"ADMIN",pruefer:"PRUEFER",mitarbeiter:"MITARBEITER",leser:"LESER"};e.s(["default",0,function(){let{token:e,user:m}=(0,f.useAuth)(),g=(0,a.useQueryClient)(),[v,j]=(0,d.useState)(""),[w,R]=(0,d.useState)(""),[S,N]=(0,d.useState)("all"),[k,Q]=(0,d.useState)(1),[_,O]=(0,d.useState)("created_at"),[C,T]=(0,d.useState)("desc"),[E,M]=(0,d.useState)(null),[I,P]=(0,d.useState)(""),[z,B]=(0,d.useState)(!1),[F,D]=(0,d.useState)(null),[A,q]=(0,d.useState)(""),[L,U]=(0,d.useState)(""),$=(0,p.useForm)({resolver:(0,s.zodResolver)(y),defaultValues:{first_name:"",last_name:"",email:"",role:"mitarbeiter",is_active:!0,must_change_password:!0,temporary_password:""}}),K=(0,i.useQuery)({queryKey:["users",k,20,v,w,S,_,C],queryFn:()=>(0,b.apiGet)(`/users?${(function({page:e,pageSize:t,search:s,role:r,active:i,sortBy:a,sortOrder:n}){let l=new URLSearchParams({page:String(e),page_size:String(t),sort_by:a,sort_order:n});return s&&s.trim()&&l.set("search",s.trim()),r&&l.set("role",r),(!0===i||!1===i)&&l.set("active",String(i)),l})({page:k,pageSize:20,search:v,role:w,active:"all"===S?void 0:"active"===S,sortBy:_,sortOrder:C}).toString()}`,e??""),enabled:!!e}),V=K.data?.pages??Math.max(1,Math.ceil((K.data?.total??0)/(K.data?.page_size??20))),W=(0,r.useMutation)({mutationFn:async t=>{let s={...t,email:t.email.trim().toLowerCase()};return E?(0,b.apiFetch)(`/users/${E.id}`,e??"",{method:"PUT",body:JSON.stringify(s)}):(0,b.apiFetch)("/users",e??"",{method:"POST",body:JSON.stringify(s)})},onSuccess:async e=>{let t=!E;E?P(""):P(e.temporary_password??""),q(E?"Benutzer gespeichert":"Benutzer angelegt"),U(""),M(null),B(t&&!!e.temporary_password),$.reset(),await g.invalidateQueries({queryKey:["users"]})},onError:e=>U(e.message)}),H=(0,r.useMutation)({mutationFn:t=>(0,b.apiDelete)(`/users/${t.id}`,e??""),onSuccess:async()=>{q("Benutzer geloescht"),U(""),D(null),await g.invalidateQueries({queryKey:["users"]})},onError:e=>U(e.message)}),J=(0,r.useMutation)({mutationFn:t=>(0,b.apiFetch)(`/users/${t.id}/reset-password`,e??"",{method:"POST"}),onSuccess:e=>{P(e.temporary_password),q("Temporäres Passwort erzeugt"),B(!0)}});return m?.role!=="admin"?(0,t.jsx)("div",{className:"rounded-lg border border-border bg-surface p-6 text-text-light",children:"Nur fuer Administratoren verfuegbar."}):(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("header",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-3xl font-semibold text-text",children:"Benutzer"}),(0,t.jsx)("p",{className:"mt-2 text-text-light",children:"Verwaltung von Rollen, Aktivstatus und Passworten."})]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-primary h-12",onClick:function(){M(null),$.reset({first_name:"",last_name:"",email:"",role:"mitarbeiter",is_active:!0,must_change_password:!0,temporary_password:""})},children:[(0,t.jsx)(u,{className:"h-4 w-4"})," Benutzer anlegen"]})]}),(0,t.jsx)("section",{className:"rounded-lg border border-border bg-surface p-4 shadow-soft",children:(0,t.jsxs)("div",{className:"grid gap-3 md:grid-cols-4",children:[(0,t.jsxs)("label",{className:"flex h-12 items-center gap-2 rounded-lg border border-border px-3 md:col-span-2",children:[(0,t.jsx)(o.Search,{className:"h-4 w-4 text-primary"}),(0,t.jsx)("input",{value:v,onChange:e=>j(e.target.value),className:"flex-1 outline-none",placeholder:"Suchen"})]}),(0,t.jsxs)("select",{value:w,onChange:e=>R(e.target.value),className:"h-12 rounded-lg border border-border px-3",children:[(0,t.jsx)("option",{value:"",children:"Alle Rollen"}),Object.entries(x).map(([e,s])=>(0,t.jsx)("option",{value:e,children:s},e))]}),(0,t.jsxs)("select",{value:S,onChange:e=>N(e.target.value),className:"h-12 rounded-lg border border-border px-3",children:[(0,t.jsx)("option",{value:"all",children:"Alle Status"}),(0,t.jsx)("option",{value:"active",children:"Aktiv"}),(0,t.jsx)("option",{value:"inactive",children:"Inaktiv"})]}),(0,t.jsxs)("select",{value:_,onChange:e=>O(e.target.value),className:"h-12 rounded-lg border border-border px-3",children:[(0,t.jsx)("option",{value:"created_at",children:"Erstellt am"}),(0,t.jsx)("option",{value:"name",children:"Name"}),(0,t.jsx)("option",{value:"email",children:"E-Mail"}),(0,t.jsx)("option",{value:"role",children:"Rolle"}),(0,t.jsx)("option",{value:"last_login_at",children:"Letzter Login"}),(0,t.jsx)("option",{value:"password_changed_at",children:"Passwort geaendert"})]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary h-12",onClick:()=>T(e=>"asc"===e?"desc":"asc"),children:["Sortierung: ",C.toUpperCase()]})]})}),(0,t.jsxs)("section",{className:"overflow-hidden rounded-lg border border-border bg-surface shadow-soft",children:[K.isLoading?(0,t.jsxs)("div",{className:"flex items-center gap-3 px-5 py-6 text-sm text-text-light",children:[(0,t.jsx)("span",{className:"spinner"}),"Benutzer werden geladen..."]}):K.isError?(0,t.jsx)("div",{className:"px-5 py-6 text-sm text-danger",children:"Benutzer konnten nicht geladen werden."}):null,(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"min-w-full text-left text-sm",children:[(0,t.jsx)("thead",{className:"bg-background text-xs uppercase text-text-light",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"px-5 py-4",children:"Name"}),(0,t.jsx)("th",{className:"px-5 py-4",children:"E-Mail"}),(0,t.jsx)("th",{className:"px-5 py-4",children:"Rolle"}),(0,t.jsx)("th",{className:"px-5 py-4",children:"Status"}),(0,t.jsx)("th",{className:"px-5 py-4",children:"Letzter Login"}),(0,t.jsx)("th",{className:"px-5 py-4",children:"Passwort zuletzt geaendert"}),(0,t.jsx)("th",{className:"px-5 py-4 text-right",children:"Aktionen"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-border",children:K.isLoading||K.isError||(K.data?.items.length??0)!==0?(K.data?.items??[]).map(e=>(0,t.jsxs)("tr",{children:[(0,t.jsxs)("td",{className:"px-5 py-4",children:[e.first_name," ",e.last_name]}),(0,t.jsx)("td",{className:"px-5 py-4",children:e.email}),(0,t.jsx)("td",{className:"px-5 py-4",children:x[e.role]}),(0,t.jsx)("td",{className:"px-5 py-4",children:e.is_active?"Aktiv":"Inaktiv"}),(0,t.jsx)("td",{className:"px-5 py-4",children:e.last_login_at??"nicht erfasst"}),(0,t.jsx)("td",{className:"px-5 py-4",children:e.password_changed_at??"nicht erfasst"}),(0,t.jsx)("td",{className:"px-5 py-4",children:(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary h-10 px-3",onClick:()=>{M(e),$.reset({first_name:e.first_name,last_name:e.last_name,email:e.email,role:e.role,is_active:e.is_active,must_change_password:e.must_change_password,temporary_password:""})},children:"Bearbeiten"}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary h-10 px-3",onClick:()=>J.mutate(e),children:[J.isPending?(0,t.jsx)("span",{className:"spinner"}):(0,t.jsx)(l.RotateCcw,{className:"h-4 w-4"})," Passwort zurücksetzen"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-danger h-10 px-3",onClick:()=>D(e),children:[(0,t.jsx)(c.Trash2,{className:"h-4 w-4"})," Löschen"]})]})})]},e.id)):(0,t.jsx)("tr",{children:(0,t.jsx)("td",{className:"px-5 py-6 text-sm text-text-light",colSpan:7,children:"Keine Benutzer vorhanden."})})})]})})]}),(0,t.jsxs)("footer",{className:"flex items-center justify-between text-sm text-text-light",children:[(0,t.jsxs)("span",{children:[K.data?.total??0," Datensätze"]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary",disabled:k<=1,onClick:()=>Q(e=>e-1),children:"Zurück"}),(0,t.jsxs)("span",{children:["Seite ",k," von ",V]}),(0,t.jsx)("button",{type:"button",className:"btn btn-secondary",disabled:(K.data?.items.length??0)<20||k>=V,onClick:()=>Q(e=>e+1),children:"Weiter"})]})]}),z&&I&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-end bg-black/20 p-3 sm:items-center sm:justify-center",children:(0,t.jsxs)("div",{className:"w-full max-w-md rounded-lg border border-border bg-surface p-5 shadow-soft",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:"Passwort zurückgesetzt"}),(0,t.jsx)("button",{type:"button","aria-label":"Schliessen",onClick:()=>B(!1),className:"icon-btn",children:(0,t.jsx)(h.X,{className:"h-4 w-4"})})]}),(0,t.jsx)("p",{className:"mt-3 text-sm text-text-light",children:"Dieses Passwort wird nur einmal angezeigt."}),(0,t.jsx)("div",{className:"mt-4 rounded-lg border border-border bg-background px-4 py-3 font-mono text-lg tracking-wide",children:I}),(0,t.jsxs)("div",{className:"mt-4 flex flex-wrap gap-3",children:[(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary h-11",onClick:async()=>navigator.clipboard.writeText(I),children:[(0,t.jsx)(n.Copy,{className:"h-4 w-4"})," Kopieren"]}),(0,t.jsx)("button",{type:"button",className:"btn btn-primary h-11",onClick:()=>B(!1),children:"Schliessen"})]})]})}),A&&(0,t.jsx)("div",{className:"fixed right-4 top-4 z-50 rounded-lg border border-success/30 bg-white p-4 text-sm text-success shadow-soft",children:A}),L&&(0,t.jsx)("div",{className:"fixed right-4 top-4 z-50 rounded-lg border border-danger/30 bg-white p-4 text-sm text-danger shadow-soft",children:L}),(0,t.jsxs)("form",{onSubmit:$.handleSubmit(function(e){W.isPending||W.mutate(e)}),className:"rounded-lg border border-border bg-surface p-5 shadow-soft",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:E?"Benutzer bearbeiten":"Benutzer anlegen"}),(0,t.jsxs)("div",{className:"mt-4 grid gap-4 md:grid-cols-2",children:[["first_name","last_name","email","temporary_password"].map(e=>(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:"first_name"===e?"Vorname":"last_name"===e?"Nachname":"email"===e?"E-Mail":"Temporäres Passwort"}),(0,t.jsx)("input",{type:"email"===e?"email":"text",...$.register(e),className:"mt-2 h-12 w-full rounded-lg border border-border px-4"})]},e)),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:"Rolle"}),(0,t.jsx)("select",{...$.register("role"),className:"mt-2 h-12 w-full rounded-lg border border-border px-4",children:Object.entries(x).map(([e,s])=>(0,t.jsx)("option",{value:e,children:s},e))})]}),(0,t.jsxs)("label",{className:"flex items-center gap-3 pt-7",children:[(0,t.jsx)("input",{type:"checkbox",...$.register("is_active")})," Aktiv"]}),(0,t.jsxs)("label",{className:"flex items-center gap-3 pt-7",children:[(0,t.jsx)("input",{type:"checkbox",...$.register("must_change_password")})," Passwortwechsel erzwingen"]})]}),(0,t.jsxs)("div",{className:"mt-5 flex justify-end gap-3",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary",onClick:()=>$.reset(),children:"Zurücksetzen"}),(0,t.jsxs)("button",{type:"submit",disabled:W.isPending,className:"btn btn-primary",children:[W.isPending?(0,t.jsx)("span",{className:"spinner"}):null,W.isPending?"Speichern...":"Speichern"]})]})]}),F&&(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-end bg-black/20 p-3 sm:items-center sm:justify-center",children:(0,t.jsxs)("div",{className:"w-full max-w-lg rounded-lg border border-border bg-surface p-5 shadow-soft",children:[(0,t.jsx)("h2",{className:"text-xl font-semibold",children:"Benutzer wirklich löschen?"}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-text-light",children:[F.first_name," ",F.last_name,(0,t.jsx)("br",{}),F.email]}),(0,t.jsxs)("div",{className:"mt-5 flex justify-end gap-3",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary",onClick:()=>D(null),children:"Abbrechen"}),(0,t.jsxs)("button",{type:"button",className:"btn btn-danger",disabled:H.isPending,onClick:()=>H.mutate(F),children:[H.isPending?(0,t.jsx)("span",{className:"spinner"}):null,H.isPending?"Löschen...":"Löschen"]})]})]})})]})}],47086)}]);