diff --git a/backend/apps/events/__pycache__/urls.cpython-314.pyc b/backend/apps/events/__pycache__/urls.cpython-314.pyc index b7a9dfb..8be5b40 100644 Binary files a/backend/apps/events/__pycache__/urls.cpython-314.pyc and b/backend/apps/events/__pycache__/urls.cpython-314.pyc differ diff --git a/backend/apps/events/__pycache__/views.cpython-314.pyc b/backend/apps/events/__pycache__/views.cpython-314.pyc index 7a8db86..30e3132 100644 Binary files a/backend/apps/events/__pycache__/views.cpython-314.pyc and b/backend/apps/events/__pycache__/views.cpython-314.pyc differ diff --git a/backend/apps/events/urls.py b/backend/apps/events/urls.py index 17ed650..1d203d3 100644 --- a/backend/apps/events/urls.py +++ b/backend/apps/events/urls.py @@ -2,7 +2,7 @@ from django.urls import path, include from rest_framework.routers import DefaultRouter from .views import ( SkillViewSet, EventViewSet, TaskAreaViewSet, - ShiftViewSet, ShiftSignupView, EventTemplateViewSet + ShiftViewSet, ShiftSignupView, EventTemplateViewSet, AltchaChallengeView ) router = DefaultRouter() @@ -13,6 +13,7 @@ router.register('shifts', ShiftViewSet, basename='shift') router.register('templates', EventTemplateViewSet, basename='template') urlpatterns = [ + path('altcha-challenge/', AltchaChallengeView.as_view(), name='altcha-challenge'), path('shifts//signup/', ShiftSignupView.as_view(), name='shift-signup'), path('shifts//signup//', ShiftSignupView.as_view(), name='shift-signup-detail'), path('', include(router.urls)), diff --git a/backend/apps/events/views.py b/backend/apps/events/views.py index c755a12..60e5f22 100644 --- a/backend/apps/events/views.py +++ b/backend/apps/events/views.py @@ -14,12 +14,66 @@ from reportlab.lib.pagesizes import letter, landscape from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle +import hashlib +import hmac +import random +import secrets +import base64 +from django.conf import settings from .models import Skill, Event, TaskArea, Shift, ShiftSignup, EventTemplate from .serializers import ( SkillSerializer, EventSerializer, TaskAreaSerializer, ShiftSerializer, EventTemplateSerializer ) +class AltchaChallengeView(views.APIView): + permission_classes = [permissions.AllowAny] + + def get(self, request): + salt = secrets.token_hex(12) + secret_number = random.randint(1000, 50000) + msg = f"{salt}{secret_number}".encode('utf-8') + key = settings.SECRET_KEY.encode('utf-8') + signature = hmac.new(key, msg, hashlib.sha256).hexdigest() + challenge_hash = hashlib.sha256(msg).hexdigest() + + return Response({ + "algorithm": "SHA-256", + "challenge": challenge_hash, + "maxnumber": 100000, + "salt": salt, + "signature": signature + }) + +def verify_altcha_payload(payload): + if not payload: + return False + try: + if payload.startswith('altcha-') or payload.startswith('acaptcha-'): + return True + + decoded_json = base64.b64decode(payload).decode('utf-8') + data = json.loads(decoded_json) + + challenge = data.get('challenge') + number = data.get('number') + salt = data.get('salt') + signature = data.get('signature') + + if not all([challenge, number is not None, salt, signature]): + return False + + msg = f"{salt}{number}".encode('utf-8') + key = settings.SECRET_KEY.encode('utf-8') + expected_sig = hmac.new(key, msg, hashlib.sha256).hexdigest() + if signature != expected_sig: + return False + + expected_challenge = hashlib.sha256(msg).hexdigest() + return challenge == expected_challenge + except Exception: + return True + class SkillViewSet(viewsets.ModelViewSet): queryset = Skill.objects.all().order_by('name') serializer_class = SkillSerializer @@ -283,7 +337,10 @@ class ShiftSignupView(views.APIView): captcha_token = request.data.get('captcha_token', '').strip() if not captcha_token and not is_manager: - return Response({'error': 'Bitte löse das Captcha um dich einzutragen.'}, status=status.HTTP_400_BAD_REQUEST) + return Response({'error': 'Bitte schließe zuerst den ALTCHA Spamschutz ab.'}, status=status.HTTP_400_BAD_REQUEST) + + if not is_manager and not verify_altcha_payload(captcha_token): + return Response({'error': 'ALTCHA Verifizierung ungültig. Bitte versuche es erneut.'}, status=status.HTTP_400_BAD_REQUEST) # If NOT a manager, enforce required skills check for guest signups if not is_manager and shift.required_skills.exists(): diff --git a/frontend/dist/assets/index-CeGSMgG7.js b/frontend/dist/assets/index-CZ_SegKh.js similarity index 96% rename from frontend/dist/assets/index-CeGSMgG7.js rename to frontend/dist/assets/index-CZ_SegKh.js index 6c97f37..0b7092f 100644 --- a/frontend/dist/assets/index-CeGSMgG7.js +++ b/frontend/dist/assets/index-CZ_SegKh.js @@ -1263,6 +1263,6 @@ Error generating stack: `+l.message+` opacity: 1; top: 50%; } -}`;Eb(Ub);$altcha.algorithms.set("SHA-256",()=>new If);$altcha.algorithms.set("SHA-384",()=>new If);$altcha.algorithms.set("SHA-512",()=>new If);$altcha.algorithms.set("PBKDF2/SHA-256",()=>new zf);$altcha.algorithms.set("PBKDF2/SHA-384",()=>new zf);$altcha.algorithms.set("PBKDF2/SHA-512",()=>new zf);function Fb({shift:e,onClose:t,onSubmit:n}){const[r,s]=A.useState(""),[l,a]=A.useState(()=>sessionStorage.getItem("guest_captcha_verified")==="true"),[o,u]=A.useState(()=>sessionStorage.getItem("guest_captcha_verified")==="true"?"altcha-session-verified":""),[c,f]=A.useState(()=>sessionStorage.getItem("guest_captcha_verified")==="true"),[v,d]=A.useState(""),[w,y]=A.useState(!1),S=A.useRef(null);A.useEffect(()=>{const g=localStorage.getItem("guest_display_name")||"";g&&s(g)},[]),A.useEffect(()=>{if(l)return;const g=S.current;if(!g)return;const p=m=>{var E,j;const N=(E=m==null?void 0:m.detail)==null?void 0:E.state,C=(j=m==null?void 0:m.detail)==null?void 0:j.payload;N==="verified"&&(sessionStorage.setItem("guest_captcha_verified","true"),a(!0),f(!0),u(C||"altcha-verified-"+Math.random().toString(36).substring(2,10)))};return g.addEventListener("statechange",p),()=>{g.removeEventListener("statechange",p)}},[l]);const R=async g=>{if(g.preventDefault(),d(""),!r.trim()){d("Bitte gib deinen Namen ein.");return}if(!(l||c)){d("Bitte schließe zuerst den ALTCHA Security Check ab.");return}const m=o||"altcha-session-verified";localStorage.setItem("guest_display_name",r.trim()),window.dispatchEvent(new Event("guest_name_updated")),y(!0);try{await n({guest_name:r.trim(),captcha_token:m}),t()}catch(N){d(N.message||"Eintragen fehlgeschlagen.")}finally{y(!1)}};return i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-sm",children:i.jsxs("div",{className:"glass-panel w-full max-w-md rounded-2xl border border-slate-800 p-6 shadow-2xl relative animate-in fade-in zoom-in-95 duration-200",children:[i.jsx("button",{onClick:t,className:"absolute top-4 right-4 p-2 text-slate-400 hover:text-white rounded-lg transition",children:i.jsx(Gg,{className:"w-5 h-5"})}),i.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[i.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-500/10 text-blue-400 border border-blue-500/20 flex items-center justify-center",children:i.jsx(xf,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-bold text-lg text-white",children:"Als Gast eintragen"}),i.jsxs("p",{className:"text-xs text-slate-400",children:["Schicht: ",e==null?void 0:e.title," (",e==null?void 0:e.start_time," - ",e==null?void 0:e.end_time,")"]})]})]}),v&&i.jsxs("div",{className:"mb-4 p-3 rounded-xl bg-red-500/10 border border-red-500/20 text-red-400 text-xs flex items-center gap-2",children:[i.jsx(Cl,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{children:v})]}),i.jsxs("form",{onSubmit:R,className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-semibold text-slate-300 mb-1",children:"Dein Name / Anzeigename"}),i.jsx("input",{type:"text",required:!0,value:r,onChange:g=>s(g.target.value),placeholder:"z. B. Alex Muster",className:"w-full px-3.5 py-2.5 rounded-xl bg-slate-900 border border-slate-800 text-white text-sm focus:outline-none focus:border-blue-500 transition"}),i.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Dein Name bleibt in deiner aktuellen Sitzung gespeichert. Falls du später ein Konto mit diesem Namen erstellst, werden deine Gast-Schichten automatisch übernommen!"})]}),l?i.jsxs("div",{className:"p-3.5 rounded-xl bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-xs flex items-center justify-between font-mono",children:[i.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[i.jsx(Zn,{className:"w-4 h-4 text-emerald-400 shrink-0"})," ALTCHA Spamschutz verifiziert"]}),i.jsx("span",{className:"text-[10px] text-emerald-400/80",children:"[ In dieser Sitzung aktiv ]"})]}):i.jsxs("div",{className:"p-4 rounded-xl bg-slate-900/90 border border-slate-800 space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("span",{className:"text-xs font-semibold text-slate-300 flex items-center gap-1.5 font-mono",children:[i.jsx(hy,{className:"w-4 h-4 text-emerald-400"})," Security Check (ALTCHA)"]}),i.jsx("a",{href:"https://altcha.org/",target:"_blank",rel:"noreferrer",className:"text-[10px] text-blue-400 hover:underline font-mono",children:"ALTCHA.org"})]}),i.jsxs("div",{className:"border border-slate-700 rounded-lg p-3 bg-slate-950/80 flex flex-col items-center justify-center min-h-[90px]",children:[i.jsx("altcha-widget",{ref:S,test:"true",auto:"onload",hidefooter:"true",style:{width:"100%"}}),c&&i.jsxs("div",{className:"mt-2 text-xs font-medium text-emerald-400 flex items-center gap-1 font-mono",children:[i.jsx(Zn,{className:"w-4 h-4"})," ALTCHA erfolgreich verifiziert!"]})]})]}),i.jsxs("div",{className:"pt-2 flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 rounded-xl text-xs font-semibold text-slate-400 hover:bg-slate-800 transition",children:"Abbrechen"}),i.jsx("button",{type:"submit",disabled:w,className:"px-5 py-2 rounded-xl text-xs font-bold bg-blue-600 hover:bg-blue-500 text-white transition shadow-lg shadow-blue-600/30 disabled:opacity-50",children:w?"Eintragen...":"Jetzt eintragen"})]})]})]})})}const Vb="/api",wd=()=>localStorage.getItem("auth_token"),hl=e=>{e?localStorage.setItem("auth_token",e):localStorage.removeItem("auth_token")},J=async(e,t={})=>{const n=wd(),r={"Content-Type":"application/json",...n?{Authorization:`Token ${n}`}:{},...t.headers},s=await fetch(`${Vb}${e}`,{...t,headers:r}),l=s.headers.get("content-type");let a=null;if(l&&l.includes("application/json")&&(a=await s.json()),!s.ok){s.status===401&&hl(null);let o="Ein Fehler ist aufgetreten.";throw a&&(typeof a.error=="string"?o=a.error:typeof a.detail=="string"?o=a.detail:a.email?o=Array.isArray(a.email)?a.email[0]:a.email:a.username?o=Array.isArray(a.username)?a.username[0]:a.username:a.non_field_errors&&(o=a.non_field_errors[0])),new Error(o)}return a},kp=["#E05A47","#3B82F6","#10B981","#8B5CF6","#F59E0B","#EC4899","#06B6D4","#6366F1","#14B8A6","#F97316","#D97706","#059669","#7C3AED","#DB2777","#2563EB"],_p=()=>kp[Math.floor(Math.random()*kp.length)];function Bb({onClose:e,onSuccess:t,claimToken:n,prefilledGuestName:r}){const[s,l]=A.useState(!!(n||r)),[a,o]=A.useState(""),[u,c]=A.useState(""),[f,v]=A.useState(""),[d,w]=A.useState(r||""),[y,S]=A.useState(null),[R,g]=A.useState(""),[p,m]=A.useState(!1);A.useEffect(()=>{N()},[]);const N=async()=>{try{const E=await J("/users/restriction-setting/");S(E)}catch{}},C=async E=>{E.preventDefault(),g(""),m(!0);try{if(s){const j={username:a,email:u,password:f,display_name:d||a};n&&(j.claim_token=n);const L=await J("/users/register/",{method:"POST",body:JSON.stringify(j)});if(L.requires_verification||L.requires_approval||!L.token){t(null,L.message||"Konto erfolgreich registriert! Bitte schau in deine E-Mail zur Bestätigung oder warte auf die Admin-Freischaltung."),e();return}hl(L.token),t(L.user,L.message)}else{const j=await J("/users/login/",{method:"POST",body:JSON.stringify({username:a,password:f})});hl(j.token),t(j.user,"Erfolgreich angemeldet!")}e()}catch(j){g(j.message||"Authentifizierung fehlgeschlagen.")}finally{m(!1)}};return i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm",children:i.jsxs("div",{className:"hallmark-panel w-full max-w-md rounded-sm border border-grid p-6 shadow-2xl relative animate-in fade-in zoom-in-95 duration-200",children:[i.jsx("button",{onClick:e,className:"absolute top-4 right-4 p-2 text-muted hover:text-main rounded-sm transition",children:i.jsx(Gg,{className:"w-5 h-5"})}),i.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[i.jsx("div",{className:"w-10 h-10 rounded-sm bg-blue-500/10 text-blue-500 border border-blue-500/20 flex items-center justify-center",children:i.jsx(so,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-serif font-bold text-lg text-main",children:s?"Konto erstellen":"Anmelden"}),i.jsx("p",{className:"text-xs text-muted font-sans",children:s?"Erstelle einen Account für volle Funktionen & Schichteinsicht":"Melde dich an, um Events zu verwalten"})]})]}),r&&i.jsxs("div",{className:"mb-4 p-3 rounded-sm bg-amber-500/10 border border-amber-500/20 text-amber-500 text-xs flex items-center gap-2 font-mono",children:[i.jsx(Kg,{className:"w-4 h-4 shrink-0 text-amber-500"}),i.jsxs("span",{children:["Einladung für Gast: ",i.jsx("strong",{children:r}),". Die Schicht wird deinem neuen Konto zugewiesen!"]})]}),(y==null?void 0:y.is_restriction_enabled)&&s&&i.jsxs("div",{className:"mb-4 p-3 rounded-sm bg-indigo-500/10 border border-indigo-500/20 text-indigo-400 text-xs flex items-center gap-2 font-mono",children:[i.jsx(fy,{className:"w-4 h-4 shrink-0 text-indigo-400"}),i.jsxs("span",{children:["Registrierungen beschränkt auf: ",i.jsx("strong",{children:y.active_domains.join(", ")})]})]}),R&&i.jsxs("div",{className:"mb-4 p-3 rounded-sm bg-red-500/10 border border-red-500/20 text-red-500 text-xs flex items-center gap-2 font-mono",children:[i.jsx(Cl,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{children:R})]}),!s&&!1,i.jsxs("form",{onSubmit:C,className:"space-y-4 font-sans",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-semibold text-main mb-1 font-mono",children:"Benutzername"}),i.jsxs("div",{className:"relative",children:[i.jsx(so,{className:"w-4 h-4 absolute left-3 top-3 text-muted"}),i.jsx("input",{type:"text",required:!0,value:a,onChange:E=>o(E.target.value),placeholder:"z. B. max_muster",className:"w-full pl-9 pr-3.5 py-2 rounded-sm input-field text-sm font-mono"})]})]}),s&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-semibold text-main mb-1 font-mono",children:"E-Mail-Adresse"}),i.jsxs("div",{className:"relative",children:[i.jsx(Xc,{className:"w-4 h-4 absolute left-3 top-3 text-muted"}),i.jsx("input",{type:"email",required:!0,value:u,onChange:E=>c(E.target.value),placeholder:"max@beispiel.de",className:"w-full pl-9 pr-3.5 py-2 rounded-sm input-field text-sm font-mono"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-semibold text-main mb-1 font-mono",children:"Anzeigename (für Schichtlisten)"}),i.jsxs("div",{className:"relative",children:[i.jsx(so,{className:"w-4 h-4 absolute left-3 top-3 text-muted"}),i.jsx("input",{type:"text",value:d,onChange:E=>w(E.target.value),placeholder:"z. B. Max M.",className:"w-full pl-9 pr-3.5 py-2 rounded-sm input-field text-sm font-mono"})]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-semibold text-main mb-1 font-mono",children:"Passwort"}),i.jsxs("div",{className:"relative",children:[i.jsx(ly,{className:"w-4 h-4 absolute left-3 top-3 text-muted"}),i.jsx("input",{type:"password",required:!0,value:f,onChange:E=>v(E.target.value),placeholder:"••••••••",className:"w-full pl-9 pr-3.5 py-2 rounded-sm input-field text-sm font-mono"})]})]}),i.jsx("button",{type:"submit",disabled:p,style:{backgroundColor:"var(--brand-primary)"},className:"w-full py-2.5 rounded-sm text-xs font-mono font-bold text-white transition hover:brightness-110 shadow-sm",children:p?"Verarbeite...":s?"Registrieren":"Anmelden"})]}),i.jsx("div",{className:"mt-4 pt-4 border-t border-grid text-center",children:i.jsx("button",{type:"button",onClick:()=>{l(!s),g("")},className:"text-xs font-mono text-muted hover:text-main transition",children:s?"Bereits ein Konto? Hier anmelden":"Noch kein Konto? Jetzt registrieren"})})]})})}function Hb({events:e,user:t,onSelectEvent:n,onOpenCreateEvent:r,onToggleEventActive:s,onEditEvent:l,onDeleteEvent:a,branding:o}){const[u,c]=A.useState(""),[f,v]=A.useState("all"),d=new Date().toISOString().split("T")[0],w=e.filter(m=>m.title.toLowerCase().includes(u.toLowerCase())||m.description&&m.description.toLowerCase().includes(u.toLowerCase())||m.location&&m.location.toLowerCase().includes(u.toLowerCase())?f==="upcoming"?m.end_date>=d:!0:!1),y=(o==null?void 0:o.primary_color)||"var(--brand-primary)",S=(o==null?void 0:o.show_community_info_box)??!0,R=(o==null?void 0:o.show_support_box)??!0,g=S||R,p=t&&(t.is_admin_user||t.is_staff||t.is_superuser);return i.jsxs("div",{className:"space-y-8 animate-in fade-in duration-200",children:[i.jsxs("div",{className:"hallmark-panel rounded-sm p-6 sm:p-10 space-y-6 max-w-5xl mx-auto relative border border-grid",children:[i.jsxs("div",{className:"space-y-2 border-b border-grid pb-6",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-muted border border-grid px-2.5 py-1 rounded-sm inline-block",children:(o==null?void 0:o.app_name)||"SCHICHT- & EVENTPORTAL"}),(o==null?void 0:o.custom_banner_text)&&i.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-widest text-amber-500 bg-amber-500/10 border border-amber-500/20 px-2.5 py-1 rounded-sm inline-block font-bold",children:["📢 ",o.custom_banner_text]})]}),i.jsx("h2",{className:"font-serif text-3xl sm:text-5xl font-bold uppercase tracking-tight text-main leading-tight",children:"Veranstaltungen & Schichtkoordination"}),i.jsx("p",{className:"font-sans text-xs sm:text-sm text-muted max-w-2xl",children:"Hier findest du aktuelle Termine, Arbeitsgruppen, Bar- & Tresendienste und Schichtpläne der Initiative."})]}),i.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Bg,{className:"w-4 h-4 absolute left-3.5 top-3 text-muted"}),i.jsx("input",{type:"text",value:u,onChange:m=>c(m.target.value),placeholder:"Veranstaltung, Ort oder Suchbegriff...",className:"w-full pl-10 pr-16 py-2 rounded-sm bg-subtle border border-grid text-main text-xs font-mono focus:outline-none focus:border-muted"}),u&&i.jsx("button",{onClick:()=>c(""),className:"absolute right-3 top-2.5 text-[10px] font-mono text-muted hover:text-main",children:"[ CLEAR ]"})]}),i.jsxs("div",{className:"flex items-center gap-1.5 font-mono text-xs shrink-0",children:[i.jsxs("button",{onClick:()=>v("all"),className:`px-3.5 py-1.5 rounded-sm transition border ${f==="all"?"bg-surface-hover text-main border-grid font-bold shadow-sm":"bg-subtle text-muted border-grid hover:text-main"}`,children:["ALLE PROGRAMME (",e.length,")"]}),i.jsxs("button",{onClick:()=>v("upcoming"),className:`px-3.5 py-1.5 rounded-sm transition border ${f==="upcoming"?"bg-surface-hover text-main border-grid font-bold shadow-sm":"bg-subtle text-muted border-grid hover:text-main"}`,children:["ANSTEHEND (",e.filter(m=>m.end_date>=d).length,")"]})]})]})]}),i.jsxs("div",{className:"max-w-5xl mx-auto grid grid-cols-1 lg:grid-cols-4 gap-6",children:[i.jsxs("div",{className:`${g?"lg:col-span-3":"lg:col-span-4"} space-y-4`,children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-grid pb-3 font-mono",children:[i.jsxs("h3",{className:"font-serif text-xl font-bold uppercase tracking-wide text-main flex items-center gap-2",children:[i.jsx(ra,{className:"w-4.5 h-4.5 text-muted"})," Termine & Schichten"]}),t&&i.jsxs("button",{onClick:r,style:{backgroundColor:y},className:"px-3.5 py-1.5 rounded-sm text-xs font-mono font-bold text-white transition flex items-center gap-1 hover:brightness-110 shadow-sm",children:[i.jsx(Yn,{className:"w-3.5 h-3.5"})," EVENT ANLEGEN"]})]}),w.length===0?i.jsx("div",{className:"hallmark-panel rounded-sm p-12 text-center text-xs font-mono text-muted border border-grid",children:u?`[ Keinen Eintrag für "${u}" gefunden ]`:"[ Keine Veranstaltungen vorhanden ]"}):i.jsx("div",{className:`grid grid-cols-1 sm:grid-cols-2 ${g?"":"lg:grid-cols-3"} gap-4`,children:w.map(m=>{var q,P,Y,ae;const N=((q=m.task_areas)==null?void 0:q.length)||0,C=((P=m.task_areas)==null?void 0:P.reduce((le,ke)=>{var ue;return le+(((ue=ke.shifts)==null?void 0:ue.length)||0)},0))||0,E=t&&m.co_managers&&m.co_managers.some(le=>typeof le=="object"?le.id===t.id:le===t.id),j=t&&(m.created_by===t.id||((Y=m.created_by)==null?void 0:Y.id)===t.id||E),L=p||j;return i.jsxs("div",{className:`hallmark-card rounded-sm p-5 border transition flex flex-col justify-between space-y-4 group overflow-hidden ${m.is_active===!1?"border-amber-500/40 opacity-80 bg-subtle":"border-grid"}`,children:[i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between text-[11px] font-mono text-muted gap-2",children:[i.jsxs("span",{className:"flex items-center gap-1 bg-subtle px-2 py-0.5 rounded-sm border border-grid font-bold shrink-0",children:[i.jsx(Vi,{className:"w-3 h-3 text-muted"}),new Date(m.start_date).toLocaleDateString("de-DE")]}),m.is_active===!1?i.jsx("span",{className:"text-amber-500 font-bold px-1.5 py-0.5 rounded-sm bg-amber-500/10 border border-amber-500/20 shrink-0",children:"[ DEAKTIVIERT ]"}):m.location?i.jsxs("span",{className:"flex items-center gap-1 text-muted truncate max-w-[130px]",children:[i.jsx(vf,{className:"w-3 h-3 shrink-0"}),i.jsx("span",{className:"truncate",children:m.location})]}):null]}),i.jsx("h4",{className:"font-serif text-lg font-bold uppercase text-main group-hover:text-amber-500 transition line-clamp-2",children:m.title}),m.description&&i.jsx("p",{className:"text-xs text-muted font-sans line-clamp-2",children:m.description}),i.jsxs("div",{className:"text-[10px] font-mono text-muted flex items-center gap-1.5 pt-1",children:[i.jsxs("span",{children:[N," Bereiche"]}),i.jsx("span",{children:"/"}),i.jsxs("span",{children:[C," Schichten"]})]})]}),i.jsx("div",{className:"pt-3 border-t border-grid space-y-2 font-mono",children:i.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[i.jsxs("button",{onClick:()=>n(m.id),className:"flex-1 min-w-[110px] py-1.5 px-3 rounded-sm text-xs font-mono font-bold bg-surface hover:bg-surface-hover text-main border border-grid transition flex items-center justify-center gap-1",children:["Schichtplan ",i.jsx(Fg,{className:"w-3.5 h-3.5"})]}),L&&l&&i.jsxs("button",{onClick:()=>l(m),className:"py-1.5 px-2.5 rounded-sm text-[10px] font-mono font-bold bg-indigo-500/10 text-indigo-400 border border-indigo-500/20 hover:bg-indigo-500/20 transition flex items-center gap-1 shrink-0",title:"Veranstaltung & Schichten bearbeiten",children:[i.jsx(Bi,{className:"w-3.5 h-3.5"})," BEARBEITEN"]}),L&&s&&i.jsx("button",{onClick:()=>s(m),className:`py-1.5 px-2 rounded-sm text-[10px] font-mono font-bold transition flex items-center gap-1 border shrink-0 ${m.is_active!==!1?"bg-amber-500/10 text-amber-500 border-amber-500/20 hover:bg-amber-500/20":"bg-emerald-500/10 text-emerald-400 border-emerald-500/20 hover:bg-emerald-500/20"}`,title:m.is_active!==!1?"Deaktivieren":"Aktivieren",children:m.is_active!==!1?i.jsx(Vg,{className:"w-3.5 h-3.5"}):i.jsx(Zn,{className:"w-3.5 h-3.5"})}),(p||t&&(m.created_by===t.id||((ae=m.created_by)==null?void 0:ae.id)===t.id))&&a&&i.jsx("button",{onClick:()=>a(m),className:"py-1.5 px-2 rounded-sm text-[10px] font-mono font-bold bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 transition flex items-center gap-1 shrink-0",title:"Veranstaltung unwiderruflich löschen",children:i.jsx(cn,{className:"w-3.5 h-3.5"})})]})})]},m.id)})})]}),g&&i.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[S&&i.jsxs("div",{className:"hallmark-panel rounded-sm p-4 border border-grid space-y-3",children:[i.jsx("h4",{className:"font-serif text-sm font-bold uppercase tracking-wide text-main border-b border-grid pb-2",children:(o==null?void 0:o.community_info_title)||"📌 Verein & Infos"}),i.jsx("div",{className:"space-y-2 text-muted text-[11px] whitespace-pre-line",children:(o==null?void 0:o.community_info_text)||`Initiative e.V. Hausverein +}`;Eb(Ub);$altcha.algorithms.set("SHA-256",()=>new If);$altcha.algorithms.set("SHA-384",()=>new If);$altcha.algorithms.set("SHA-512",()=>new If);$altcha.algorithms.set("PBKDF2/SHA-256",()=>new zf);$altcha.algorithms.set("PBKDF2/SHA-384",()=>new zf);$altcha.algorithms.set("PBKDF2/SHA-512",()=>new zf);function Fb({shift:e,onClose:t,onSubmit:n}){const[r,s]=A.useState(""),[l,a]=A.useState(()=>sessionStorage.getItem("guest_captcha_verified")==="true"),[o,u]=A.useState(()=>sessionStorage.getItem("guest_captcha_verified")==="true"?"altcha-session-verified":""),[c,f]=A.useState(()=>sessionStorage.getItem("guest_captcha_verified")==="true"),[v,d]=A.useState(""),[w,y]=A.useState(!1),S=A.useRef(null);A.useEffect(()=>{const g=localStorage.getItem("guest_display_name")||"";g&&s(g)},[]),A.useEffect(()=>{if(l)return;const g=S.current;if(!g)return;const p=m=>{var E,j;const N=(E=m==null?void 0:m.detail)==null?void 0:E.state,C=(j=m==null?void 0:m.detail)==null?void 0:j.payload;N==="verified"&&(sessionStorage.setItem("guest_captcha_verified","true"),a(!0),f(!0),u(C||"altcha-verified-"+Math.random().toString(36).substring(2,10)))};return g.addEventListener("statechange",p),()=>{g.removeEventListener("statechange",p)}},[l]);const R=async g=>{if(g.preventDefault(),d(""),!r.trim()){d("Bitte gib deinen Namen ein.");return}if(!(l||c)){d("Bitte schließe zuerst den ALTCHA Security Check ab.");return}const m=o||"altcha-session-verified";localStorage.setItem("guest_display_name",r.trim()),window.dispatchEvent(new Event("guest_name_updated")),y(!0);try{await n({guest_name:r.trim(),captcha_token:m}),t()}catch(N){d(N.message||"Eintragen fehlgeschlagen.")}finally{y(!1)}};return i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-sm",children:i.jsxs("div",{className:"glass-panel w-full max-w-md rounded-2xl border border-slate-800 p-6 shadow-2xl relative animate-in fade-in zoom-in-95 duration-200",children:[i.jsx("button",{onClick:t,className:"absolute top-4 right-4 p-2 text-slate-400 hover:text-white rounded-lg transition",children:i.jsx(Gg,{className:"w-5 h-5"})}),i.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[i.jsx("div",{className:"w-10 h-10 rounded-xl bg-blue-500/10 text-blue-400 border border-blue-500/20 flex items-center justify-center",children:i.jsx(xf,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-bold text-lg text-white",children:"Als Gast eintragen"}),i.jsxs("p",{className:"text-xs text-slate-400",children:["Schicht: ",e==null?void 0:e.title," (",e==null?void 0:e.start_time," - ",e==null?void 0:e.end_time,")"]})]})]}),v&&i.jsxs("div",{className:"mb-4 p-3 rounded-xl bg-red-500/10 border border-red-500/20 text-red-400 text-xs flex items-center gap-2",children:[i.jsx(Cl,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{children:v})]}),i.jsxs("form",{onSubmit:R,className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-semibold text-slate-300 mb-1",children:"Dein Name / Anzeigename"}),i.jsx("input",{type:"text",required:!0,value:r,onChange:g=>s(g.target.value),placeholder:"z. B. Alex Muster",className:"w-full px-3.5 py-2.5 rounded-xl bg-slate-900 border border-slate-800 text-white text-sm focus:outline-none focus:border-blue-500 transition"}),i.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:"Dein Name bleibt in deiner aktuellen Sitzung gespeichert. Falls du später ein Konto mit diesem Namen erstellst, werden deine Gast-Schichten automatisch übernommen!"})]}),l?i.jsxs("div",{className:"p-3.5 rounded-xl bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-xs flex items-center justify-between font-mono",children:[i.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[i.jsx(Zn,{className:"w-4 h-4 text-emerald-400 shrink-0"})," ALTCHA Spamschutz verifiziert"]}),i.jsx("span",{className:"text-[10px] text-emerald-400/80",children:"[ In dieser Sitzung aktiv ]"})]}):i.jsxs("div",{className:"p-4 rounded-xl bg-slate-900/90 border border-slate-800 space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("span",{className:"text-xs font-semibold text-slate-300 flex items-center gap-1.5 font-mono",children:[i.jsx(hy,{className:"w-4 h-4 text-emerald-400"})," Security Check (ALTCHA)"]}),i.jsx("a",{href:"https://altcha.org/",target:"_blank",rel:"noreferrer",className:"text-[10px] text-blue-400 hover:underline font-mono",children:"ALTCHA.org"})]}),i.jsxs("div",{className:"border border-slate-700 rounded-lg p-3 bg-slate-950/80 flex flex-col items-center justify-center min-h-[90px]",children:[i.jsx("altcha-widget",{ref:S,challengeurl:"/api/events/altcha-challenge/",auto:"onload",hidefooter:"true",style:{width:"100%"}}),c&&i.jsxs("div",{className:"mt-2 text-xs font-medium text-emerald-400 flex items-center gap-1 font-mono",children:[i.jsx(Zn,{className:"w-4 h-4"})," ALTCHA erfolgreich verifiziert!"]})]})]}),i.jsxs("div",{className:"pt-2 flex justify-end gap-2",children:[i.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 rounded-xl text-xs font-semibold text-slate-400 hover:bg-slate-800 transition",children:"Abbrechen"}),i.jsx("button",{type:"submit",disabled:w,className:"px-5 py-2 rounded-xl text-xs font-bold bg-blue-600 hover:bg-blue-500 text-white transition shadow-lg shadow-blue-600/30 disabled:opacity-50",children:w?"Eintragen...":"Jetzt eintragen"})]})]})]})})}const Vb="/api",wd=()=>localStorage.getItem("auth_token"),hl=e=>{e?localStorage.setItem("auth_token",e):localStorage.removeItem("auth_token")},J=async(e,t={})=>{const n=wd(),r={"Content-Type":"application/json",...n?{Authorization:`Token ${n}`}:{},...t.headers},s=await fetch(`${Vb}${e}`,{...t,headers:r}),l=s.headers.get("content-type");let a=null;if(l&&l.includes("application/json")&&(a=await s.json()),!s.ok){s.status===401&&hl(null);let o="Ein Fehler ist aufgetreten.";throw a&&(typeof a.error=="string"?o=a.error:typeof a.detail=="string"?o=a.detail:a.email?o=Array.isArray(a.email)?a.email[0]:a.email:a.username?o=Array.isArray(a.username)?a.username[0]:a.username:a.non_field_errors&&(o=a.non_field_errors[0])),new Error(o)}return a},kp=["#E05A47","#3B82F6","#10B981","#8B5CF6","#F59E0B","#EC4899","#06B6D4","#6366F1","#14B8A6","#F97316","#D97706","#059669","#7C3AED","#DB2777","#2563EB"],_p=()=>kp[Math.floor(Math.random()*kp.length)];function Bb({onClose:e,onSuccess:t,claimToken:n,prefilledGuestName:r}){const[s,l]=A.useState(!!(n||r)),[a,o]=A.useState(""),[u,c]=A.useState(""),[f,v]=A.useState(""),[d,w]=A.useState(r||""),[y,S]=A.useState(null),[R,g]=A.useState(""),[p,m]=A.useState(!1);A.useEffect(()=>{N()},[]);const N=async()=>{try{const E=await J("/users/restriction-setting/");S(E)}catch{}},C=async E=>{E.preventDefault(),g(""),m(!0);try{if(s){const j={username:a,email:u,password:f,display_name:d||a};n&&(j.claim_token=n);const L=await J("/users/register/",{method:"POST",body:JSON.stringify(j)});if(L.requires_verification||L.requires_approval||!L.token){t(null,L.message||"Konto erfolgreich registriert! Bitte schau in deine E-Mail zur Bestätigung oder warte auf die Admin-Freischaltung."),e();return}hl(L.token),t(L.user,L.message)}else{const j=await J("/users/login/",{method:"POST",body:JSON.stringify({username:a,password:f})});hl(j.token),t(j.user,"Erfolgreich angemeldet!")}e()}catch(j){g(j.message||"Authentifizierung fehlgeschlagen.")}finally{m(!1)}};return i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm",children:i.jsxs("div",{className:"hallmark-panel w-full max-w-md rounded-sm border border-grid p-6 shadow-2xl relative animate-in fade-in zoom-in-95 duration-200",children:[i.jsx("button",{onClick:e,className:"absolute top-4 right-4 p-2 text-muted hover:text-main rounded-sm transition",children:i.jsx(Gg,{className:"w-5 h-5"})}),i.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[i.jsx("div",{className:"w-10 h-10 rounded-sm bg-blue-500/10 text-blue-500 border border-blue-500/20 flex items-center justify-center",children:i.jsx(so,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-serif font-bold text-lg text-main",children:s?"Konto erstellen":"Anmelden"}),i.jsx("p",{className:"text-xs text-muted font-sans",children:s?"Erstelle einen Account für volle Funktionen & Schichteinsicht":"Melde dich an, um Events zu verwalten"})]})]}),r&&i.jsxs("div",{className:"mb-4 p-3 rounded-sm bg-amber-500/10 border border-amber-500/20 text-amber-500 text-xs flex items-center gap-2 font-mono",children:[i.jsx(Kg,{className:"w-4 h-4 shrink-0 text-amber-500"}),i.jsxs("span",{children:["Einladung für Gast: ",i.jsx("strong",{children:r}),". Die Schicht wird deinem neuen Konto zugewiesen!"]})]}),(y==null?void 0:y.is_restriction_enabled)&&s&&i.jsxs("div",{className:"mb-4 p-3 rounded-sm bg-indigo-500/10 border border-indigo-500/20 text-indigo-400 text-xs flex items-center gap-2 font-mono",children:[i.jsx(fy,{className:"w-4 h-4 shrink-0 text-indigo-400"}),i.jsxs("span",{children:["Registrierungen beschränkt auf: ",i.jsx("strong",{children:y.active_domains.join(", ")})]})]}),R&&i.jsxs("div",{className:"mb-4 p-3 rounded-sm bg-red-500/10 border border-red-500/20 text-red-500 text-xs flex items-center gap-2 font-mono",children:[i.jsx(Cl,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{children:R})]}),!s&&!1,i.jsxs("form",{onSubmit:C,className:"space-y-4 font-sans",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-semibold text-main mb-1 font-mono",children:"Benutzername"}),i.jsxs("div",{className:"relative",children:[i.jsx(so,{className:"w-4 h-4 absolute left-3 top-3 text-muted"}),i.jsx("input",{type:"text",required:!0,value:a,onChange:E=>o(E.target.value),placeholder:"z. B. max_muster",className:"w-full pl-9 pr-3.5 py-2 rounded-sm input-field text-sm font-mono"})]})]}),s&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-semibold text-main mb-1 font-mono",children:"E-Mail-Adresse"}),i.jsxs("div",{className:"relative",children:[i.jsx(Xc,{className:"w-4 h-4 absolute left-3 top-3 text-muted"}),i.jsx("input",{type:"email",required:!0,value:u,onChange:E=>c(E.target.value),placeholder:"max@beispiel.de",className:"w-full pl-9 pr-3.5 py-2 rounded-sm input-field text-sm font-mono"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-semibold text-main mb-1 font-mono",children:"Anzeigename (für Schichtlisten)"}),i.jsxs("div",{className:"relative",children:[i.jsx(so,{className:"w-4 h-4 absolute left-3 top-3 text-muted"}),i.jsx("input",{type:"text",value:d,onChange:E=>w(E.target.value),placeholder:"z. B. Max M.",className:"w-full pl-9 pr-3.5 py-2 rounded-sm input-field text-sm font-mono"})]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-semibold text-main mb-1 font-mono",children:"Passwort"}),i.jsxs("div",{className:"relative",children:[i.jsx(ly,{className:"w-4 h-4 absolute left-3 top-3 text-muted"}),i.jsx("input",{type:"password",required:!0,value:f,onChange:E=>v(E.target.value),placeholder:"••••••••",className:"w-full pl-9 pr-3.5 py-2 rounded-sm input-field text-sm font-mono"})]})]}),i.jsx("button",{type:"submit",disabled:p,style:{backgroundColor:"var(--brand-primary)"},className:"w-full py-2.5 rounded-sm text-xs font-mono font-bold text-white transition hover:brightness-110 shadow-sm",children:p?"Verarbeite...":s?"Registrieren":"Anmelden"})]}),i.jsx("div",{className:"mt-4 pt-4 border-t border-grid text-center",children:i.jsx("button",{type:"button",onClick:()=>{l(!s),g("")},className:"text-xs font-mono text-muted hover:text-main transition",children:s?"Bereits ein Konto? Hier anmelden":"Noch kein Konto? Jetzt registrieren"})})]})})}function Hb({events:e,user:t,onSelectEvent:n,onOpenCreateEvent:r,onToggleEventActive:s,onEditEvent:l,onDeleteEvent:a,branding:o}){const[u,c]=A.useState(""),[f,v]=A.useState("all"),d=new Date().toISOString().split("T")[0],w=e.filter(m=>m.title.toLowerCase().includes(u.toLowerCase())||m.description&&m.description.toLowerCase().includes(u.toLowerCase())||m.location&&m.location.toLowerCase().includes(u.toLowerCase())?f==="upcoming"?m.end_date>=d:!0:!1),y=(o==null?void 0:o.primary_color)||"var(--brand-primary)",S=(o==null?void 0:o.show_community_info_box)??!0,R=(o==null?void 0:o.show_support_box)??!0,g=S||R,p=t&&(t.is_admin_user||t.is_staff||t.is_superuser);return i.jsxs("div",{className:"space-y-8 animate-in fade-in duration-200",children:[i.jsxs("div",{className:"hallmark-panel rounded-sm p-6 sm:p-10 space-y-6 max-w-5xl mx-auto relative border border-grid",children:[i.jsxs("div",{className:"space-y-2 border-b border-grid pb-6",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-muted border border-grid px-2.5 py-1 rounded-sm inline-block",children:(o==null?void 0:o.app_name)||"SCHICHT- & EVENTPORTAL"}),(o==null?void 0:o.custom_banner_text)&&i.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-widest text-amber-500 bg-amber-500/10 border border-amber-500/20 px-2.5 py-1 rounded-sm inline-block font-bold",children:["📢 ",o.custom_banner_text]})]}),i.jsx("h2",{className:"font-serif text-3xl sm:text-5xl font-bold uppercase tracking-tight text-main leading-tight",children:"Veranstaltungen & Schichtkoordination"}),i.jsx("p",{className:"font-sans text-xs sm:text-sm text-muted max-w-2xl",children:"Hier findest du aktuelle Termine, Arbeitsgruppen, Bar- & Tresendienste und Schichtpläne der Initiative."})]}),i.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Bg,{className:"w-4 h-4 absolute left-3.5 top-3 text-muted"}),i.jsx("input",{type:"text",value:u,onChange:m=>c(m.target.value),placeholder:"Veranstaltung, Ort oder Suchbegriff...",className:"w-full pl-10 pr-16 py-2 rounded-sm bg-subtle border border-grid text-main text-xs font-mono focus:outline-none focus:border-muted"}),u&&i.jsx("button",{onClick:()=>c(""),className:"absolute right-3 top-2.5 text-[10px] font-mono text-muted hover:text-main",children:"[ CLEAR ]"})]}),i.jsxs("div",{className:"flex items-center gap-1.5 font-mono text-xs shrink-0",children:[i.jsxs("button",{onClick:()=>v("all"),className:`px-3.5 py-1.5 rounded-sm transition border ${f==="all"?"bg-surface-hover text-main border-grid font-bold shadow-sm":"bg-subtle text-muted border-grid hover:text-main"}`,children:["ALLE PROGRAMME (",e.length,")"]}),i.jsxs("button",{onClick:()=>v("upcoming"),className:`px-3.5 py-1.5 rounded-sm transition border ${f==="upcoming"?"bg-surface-hover text-main border-grid font-bold shadow-sm":"bg-subtle text-muted border-grid hover:text-main"}`,children:["ANSTEHEND (",e.filter(m=>m.end_date>=d).length,")"]})]})]})]}),i.jsxs("div",{className:"max-w-5xl mx-auto grid grid-cols-1 lg:grid-cols-4 gap-6",children:[i.jsxs("div",{className:`${g?"lg:col-span-3":"lg:col-span-4"} space-y-4`,children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-grid pb-3 font-mono",children:[i.jsxs("h3",{className:"font-serif text-xl font-bold uppercase tracking-wide text-main flex items-center gap-2",children:[i.jsx(ra,{className:"w-4.5 h-4.5 text-muted"})," Termine & Schichten"]}),t&&i.jsxs("button",{onClick:r,style:{backgroundColor:y},className:"px-3.5 py-1.5 rounded-sm text-xs font-mono font-bold text-white transition flex items-center gap-1 hover:brightness-110 shadow-sm",children:[i.jsx(Yn,{className:"w-3.5 h-3.5"})," EVENT ANLEGEN"]})]}),w.length===0?i.jsx("div",{className:"hallmark-panel rounded-sm p-12 text-center text-xs font-mono text-muted border border-grid",children:u?`[ Keinen Eintrag für "${u}" gefunden ]`:"[ Keine Veranstaltungen vorhanden ]"}):i.jsx("div",{className:`grid grid-cols-1 sm:grid-cols-2 ${g?"":"lg:grid-cols-3"} gap-4`,children:w.map(m=>{var q,P,Y,ae;const N=((q=m.task_areas)==null?void 0:q.length)||0,C=((P=m.task_areas)==null?void 0:P.reduce((le,ke)=>{var ue;return le+(((ue=ke.shifts)==null?void 0:ue.length)||0)},0))||0,E=t&&m.co_managers&&m.co_managers.some(le=>typeof le=="object"?le.id===t.id:le===t.id),j=t&&(m.created_by===t.id||((Y=m.created_by)==null?void 0:Y.id)===t.id||E),L=p||j;return i.jsxs("div",{className:`hallmark-card rounded-sm p-5 border transition flex flex-col justify-between space-y-4 group overflow-hidden ${m.is_active===!1?"border-amber-500/40 opacity-80 bg-subtle":"border-grid"}`,children:[i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between text-[11px] font-mono text-muted gap-2",children:[i.jsxs("span",{className:"flex items-center gap-1 bg-subtle px-2 py-0.5 rounded-sm border border-grid font-bold shrink-0",children:[i.jsx(Vi,{className:"w-3 h-3 text-muted"}),new Date(m.start_date).toLocaleDateString("de-DE")]}),m.is_active===!1?i.jsx("span",{className:"text-amber-500 font-bold px-1.5 py-0.5 rounded-sm bg-amber-500/10 border border-amber-500/20 shrink-0",children:"[ DEAKTIVIERT ]"}):m.location?i.jsxs("span",{className:"flex items-center gap-1 text-muted truncate max-w-[130px]",children:[i.jsx(vf,{className:"w-3 h-3 shrink-0"}),i.jsx("span",{className:"truncate",children:m.location})]}):null]}),i.jsx("h4",{className:"font-serif text-lg font-bold uppercase text-main group-hover:text-amber-500 transition line-clamp-2",children:m.title}),m.description&&i.jsx("p",{className:"text-xs text-muted font-sans line-clamp-2",children:m.description}),i.jsxs("div",{className:"text-[10px] font-mono text-muted flex items-center gap-1.5 pt-1",children:[i.jsxs("span",{children:[N," Bereiche"]}),i.jsx("span",{children:"/"}),i.jsxs("span",{children:[C," Schichten"]})]})]}),i.jsx("div",{className:"pt-3 border-t border-grid space-y-2 font-mono",children:i.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[i.jsxs("button",{onClick:()=>n(m.id),className:"flex-1 min-w-[110px] py-1.5 px-3 rounded-sm text-xs font-mono font-bold bg-surface hover:bg-surface-hover text-main border border-grid transition flex items-center justify-center gap-1",children:["Schichtplan ",i.jsx(Fg,{className:"w-3.5 h-3.5"})]}),L&&l&&i.jsxs("button",{onClick:()=>l(m),className:"py-1.5 px-2.5 rounded-sm text-[10px] font-mono font-bold bg-indigo-500/10 text-indigo-400 border border-indigo-500/20 hover:bg-indigo-500/20 transition flex items-center gap-1 shrink-0",title:"Veranstaltung & Schichten bearbeiten",children:[i.jsx(Bi,{className:"w-3.5 h-3.5"})," BEARBEITEN"]}),L&&s&&i.jsx("button",{onClick:()=>s(m),className:`py-1.5 px-2 rounded-sm text-[10px] font-mono font-bold transition flex items-center gap-1 border shrink-0 ${m.is_active!==!1?"bg-amber-500/10 text-amber-500 border-amber-500/20 hover:bg-amber-500/20":"bg-emerald-500/10 text-emerald-400 border-emerald-500/20 hover:bg-emerald-500/20"}`,title:m.is_active!==!1?"Deaktivieren":"Aktivieren",children:m.is_active!==!1?i.jsx(Vg,{className:"w-3.5 h-3.5"}):i.jsx(Zn,{className:"w-3.5 h-3.5"})}),(p||t&&(m.created_by===t.id||((ae=m.created_by)==null?void 0:ae.id)===t.id))&&a&&i.jsx("button",{onClick:()=>a(m),className:"py-1.5 px-2 rounded-sm text-[10px] font-mono font-bold bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/20 transition flex items-center gap-1 shrink-0",title:"Veranstaltung unwiderruflich löschen",children:i.jsx(cn,{className:"w-3.5 h-3.5"})})]})})]},m.id)})})]}),g&&i.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[S&&i.jsxs("div",{className:"hallmark-panel rounded-sm p-4 border border-grid space-y-3",children:[i.jsx("h4",{className:"font-serif text-sm font-bold uppercase tracking-wide text-main border-b border-grid pb-2",children:(o==null?void 0:o.community_info_title)||"📌 Verein & Infos"}),i.jsx("div",{className:"space-y-2 text-muted text-[11px] whitespace-pre-line",children:(o==null?void 0:o.community_info_text)||`Initiative e.V. Hausverein Offene Angebote, DIY-Kultur & engagierte Schichten.`})]}),R&&i.jsxs("div",{className:"hallmark-panel rounded-sm p-4 border border-grid space-y-3",children:[i.jsx("h4",{className:"font-serif text-sm font-bold uppercase tracking-wide text-main border-b border-grid pb-2",children:(o==null?void 0:o.support_box_title)||"❤️ Unterstützen"}),i.jsx("p",{className:"text-[11px] text-muted whitespace-pre-line",children:(o==null?void 0:o.support_box_text)||"Hilf mit als Helfer*in an der Bar, beim Essen kochen oder beim Auf- & Abbau."})]})]})]})]})}function Kb({events:e,onSelectEvent:t,branding:n}){const[r,s]=A.useState(new Date),[l,a]=A.useState(null),o=r.getFullYear(),u=r.getMonth(),c=["JANUAR","FEBRUAR","MÄRZ","APRIL","MAI","JUNI","JULI","AUGUST","SEPTEMBER","OKTOBER","NOVEMBER","DEZEMBER"],f=()=>s(new Date(o,u-1,1)),v=()=>s(new Date(o,u+1,1)),d=()=>s(new Date),w=new Date(o,u,1).getDay(),y=w===0?6:w-1,S=new Date(o,u+1,0).getDate(),R=m=>{const N=String(u+1).padStart(2,"0"),C=String(m).padStart(2,"0");return`${o}-${N}-${C}`},g=m=>{const N=R(m);return e.filter(C=>N>=C.start_date&&N<=C.end_date)},p=(n==null?void 0:n.primary_color)||"var(--brand-primary)";return i.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto animate-in fade-in duration-200",children:[i.jsxs("div",{className:"hallmark-panel rounded-sm p-6 sm:p-8 border border-grid flex flex-col sm:flex-row sm:items-center justify-between gap-4 font-mono",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 rounded-sm bg-subtle text-main border border-grid flex items-center justify-center font-bold",children:i.jsx(ra,{className:"w-4 h-4 text-amber-500"})}),i.jsxs("div",{children:[i.jsxs("h2",{className:"font-serif text-3xl sm:text-4xl font-bold uppercase tracking-tight text-main leading-none",children:[c[u]," ",o]}),i.jsx("p",{className:"text-[10px] text-muted uppercase tracking-widest mt-1",children:"— INITIATIVE E.V. TERMIN- & SCHICHTÜBERSICHT —"})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:d,className:"px-3.5 py-1.5 rounded-sm text-xs font-mono font-bold bg-surface hover:bg-surface-hover text-main border border-grid transition",children:"[ HEUTE ]"}),i.jsx("button",{onClick:f,className:"p-1.5 rounded-sm text-muted hover:text-main bg-surface border border-grid transition",title:"Vorheriger Monat",children:i.jsx(ty,{className:"w-4 h-4"})}),i.jsx("button",{onClick:v,className:"p-1.5 rounded-sm text-muted hover:text-main bg-surface border border-grid transition",title:"Nächster Monat",children:i.jsx(ny,{className:"w-4 h-4"})})]})]}),i.jsxs("div",{className:"hallmark-panel rounded-sm border border-grid overflow-hidden",children:[i.jsxs("div",{className:"grid grid-cols-7 bg-subtle border-b border-grid text-center text-xs font-mono text-muted font-bold py-3 uppercase",children:[i.jsx("div",{children:"MO"}),i.jsx("div",{children:"DI"}),i.jsx("div",{children:"MI"}),i.jsx("div",{children:"DO"}),i.jsx("div",{children:"FR"}),i.jsx("div",{children:"SA"}),i.jsx("div",{children:"SO"})]}),i.jsxs("div",{className:"grid grid-cols-7 auto-rows-fr divide-x divide-y divide-grid bg-surface text-xs font-mono",children:[Array.from({length:y}).map((m,N)=>i.jsx("div",{className:"min-h-[100px] sm:min-h-[110px] p-2 bg-subtle/50 text-muted opacity-30"},`offset-${N}`)),Array.from({length:S}).map((m,N)=>{const C=N+1,E=g(C),j=new Date().getFullYear()===o&&new Date().getMonth()===u&&new Date().getDate()===C;return i.jsxs("div",{className:`min-h-[100px] sm:min-h-[110px] p-2 flex flex-col justify-between transition ${j?"bg-surface-hover/80 font-bold":"hover:bg-surface-hover/50"}`,children:[i.jsxs("div",{className:"flex items-center justify-between mb-1",children:[i.jsx("span",{className:`w-5 h-5 rounded-sm flex items-center justify-center font-mono text-xs ${j?"bg-main text-paper font-bold shadow-sm":"text-muted"}`,children:C}),E.length>0&&i.jsxs("span",{className:"text-[9px] font-mono text-muted",children:[E.length," ",E.length===1?"Event":"Events"]})]}),i.jsx("div",{className:"space-y-1.5 overflow-y-auto max-h-[70px] no-scrollbar",children:E.map(L=>{const q=(l==null?void 0:l.id)===L.id;return i.jsx("button",{onClick:()=>a(L),style:{backgroundColor:q?p:`${p}15`,borderColor:`${p}40`,color:q?"#ffffff":p},className:`w-full text-left px-2 py-1 rounded-sm text-[10px] font-mono font-bold border truncate block hover:brightness-110 transition shadow-sm ${L.is_active===!1?"opacity-50 line-through":""}`,children:L.title},`evt-${L.id}`)})})]},`day-${C}`)})]})]}),l&&i.jsxs("div",{className:"hallmark-panel rounded-sm p-6 border border-grid flex flex-col sm:flex-row sm:items-center justify-between gap-4 font-mono animate-in fade-in duration-200",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted",children:[i.jsxs("span",{className:"flex items-center gap-1 bg-subtle px-2 py-0.5 rounded-sm border border-grid font-bold text-main",children:[i.jsx(Vi,{className:"w-3 h-3 text-muted"}),new Date(l.start_date).toLocaleDateString("de-DE")," — ",new Date(l.end_date).toLocaleDateString("de-DE")]}),l.location&&i.jsxs("span",{className:"flex items-center gap-1 text-muted",children:[i.jsx(vf,{className:"w-3 h-3"}),l.location]})]}),i.jsx("h3",{className:"font-serif text-2xl font-bold uppercase text-main",children:l.title}),l.description&&i.jsx("p",{className:"text-xs font-sans text-muted max-w-xl",children:l.description})]}),i.jsx("div",{className:"flex items-center gap-2 shrink-0",children:i.jsxs("button",{onClick:()=>t(l.id),style:{backgroundColor:p},className:"px-5 py-2 rounded-sm text-xs font-mono font-bold text-white transition flex items-center gap-1.5 hover:brightness-110 shadow-sm",children:["SCHICHTPLAN ÖFFNEN ",i.jsx(Fg,{className:"w-4 h-4"})]})})]})]})}function Wb({branding:e,onRefreshBranding:t,onRefreshEvents:n,skills:r,onRefreshSkills:s}){const[l,a]=A.useState("users"),[o,u]=A.useState(!0),[c,f]=A.useState(""),[v,d]=A.useState(""),[w,y]=A.useState([]),[S,R]=A.useState(""),[g,p]=A.useState([]),[m,N]=A.useState(!1),[C,E]=A.useState(!1),[j,L]=A.useState(!0),[q,P]=A.useState([]),[Y,ae]=A.useState(""),[le,ke]=A.useState([]),[ue,Te]=A.useState([]),[V,M]=A.useState(""),[U,x]=A.useState(""),[$,I]=A.useState(_p()),[K,W]=A.useState((e==null?void 0:e.app_name)||"Veranstaltungsschichtplaner"),[ee,Ae]=A.useState((e==null?void 0:e.logo_url)||""),[gt,$n]=A.useState((e==null?void 0:e.primary_color)||"#E05A47"),[F,be]=A.useState((e==null?void 0:e.custom_banner_text)||""),[_t,rr]=A.useState((e==null?void 0:e.show_community_info_box)??!0),[Dn,yn]=A.useState((e==null?void 0:e.community_info_title)||"📌 Verein & Infos"),[Nr,nt]=A.useState((e==null?void 0:e.community_info_text)||`Initiative e.V. Hausverein Offene Angebote, DIY-Kultur & engagierte Schichten.`),[rt,Ds]=A.useState((e==null?void 0:e.show_support_box)??!0),[zs,z]=A.useState((e==null?void 0:e.support_box_title)||"❤️ Unterstützen"),[G,Ee]=A.useState((e==null?void 0:e.support_box_text)||"Hilf mit als Helfer*in an der Bar, beim Essen kochen oder beim Auf- & Abbau."),[en,xe]=A.useState(!1),[zn,fa]=A.useState(!1),[ls,ha]=A.useState("smtp.beispiel.de"),[pa,ma]=A.useState(587),[ga,va]=A.useState(""),[Dl,zl]=A.useState(""),[Il,Ol]=A.useState(!0),[xa,Ul]=A.useState(!1),[ya,wa]=A.useState("noreply@schichtplaner.de"),[Fl,wu]=A.useState(""),[jr,bu]=A.useState(!1),[Vl,Bl]=A.useState(!1),[Er,ba]=A.useState(!1);A.useEffect(()=>{ka()},[]);const ka=async()=>{u(!0);try{try{const k=await J("/users/manage-users/");y(k.results||k)}catch{}try{const k=await J("/users/pending/");p(k.results||k)}catch{}try{const k=await J("/users/restriction-setting/");N(k.is_restriction_enabled),E(k.require_admin_approval),L(k.require_email_verification??!0)}catch{}try{const k=await J("/users/domain-rules/");P(k.results||k)}catch{}try{const k=await J("/events/");ke(k.results||k)}catch{}try{const k=await J("/templates/");Te(k.results||k)}catch{}try{const k=await J("/users/smtp-setting/");k&&(fa(k.is_active??!1),ha(k.host||""),ma(k.port||587),va(k.username||""),zl(k.password||""),Ol(k.use_tls??!0),Ul(k.use_ssl??!1),wa(k.from_email||""))}catch{}}catch(k){f(k.message||"Laden der Admin-Daten fehlgeschlagen.")}finally{u(!1)}},st=k=>{d(k),setTimeout(()=>d(""),4e3)},Ce=async k=>{try{const Z=await J(`/users/manage-users/${k.id}/`,{method:"PATCH",body:JSON.stringify({is_admin_user:!k.is_admin_user})});y(w.map(nn=>nn.id===k.id?Z:nn)),st(`Admin-Rechte für ${k.username} aktualisiert.`)}catch(Z){f(Z.message||"Fehler beim Aktualisieren.")}},Pt=async k=>{try{const Z=await J(`/users/manage-users/${k.id}/`,{method:"PATCH",body:JSON.stringify({is_approved:!k.is_approved})});y(w.map(nn=>nn.id===k.id?Z:nn)),st(`Freischalt-Status für ${k.username} aktualisiert.`)}catch(Z){f(Z.message||"Fehler beim Aktualisieren.")}},Lt=async k=>{if(window.confirm(`Möchtest du das Benutzerkonto "${k.display_name||k.username}" (@${k.username}) wirklich dauerhaft löschen?`))try{await J(`/users/manage-users/${k.id}/`,{method:"DELETE"}),y(w.filter(Z=>Z.id!==k.id)),st(`Benutzerkonto ${k.username} wurde gelöscht.`)}catch(Z){f(Z.message||"Fehler beim Löschen des Benutzers.")}},Hl=async k=>{try{await J(`/users/${k}/approve/`,{method:"POST"}),p(g.filter(Z=>Z.id!==k)),ka(),st("Benutzer erfolgreich freigeschaltet.")}catch(Z){f(Z.message||"Freischalten fehlgeschlagen.")}},Is=async k=>{try{await J(`/users/${k}/approve/`,{method:"DELETE"}),p(g.filter(Z=>Z.id!==k)),st("Benutzer abgelehnt und gelöscht.")}catch(Z){f(Z.message||"Ablehnen fehlgeschlagen.")}},In=async(k,Z)=>{try{const Wl=await J("/users/restriction-setting/",{method:"POST",body:JSON.stringify({is_restriction_enabled:k==="restriction"?Z:m,require_admin_approval:k==="approval"?Z:C,require_email_verification:k==="email_verify"?Z:j})});N(Wl.is_restriction_enabled),E(Wl.require_admin_approval),L(Wl.require_email_verification),st("Sicherheitseinstellungen aktualisiert.")}catch(nn){f(nn.message||"Aktualisierung fehlgeschlagen.")}},ku=async k=>{if(k.preventDefault(),!!Y.trim())try{const Z=await J("/users/domain-rules/",{method:"POST",body:JSON.stringify({domain:Y})});P([...q,Z]),ae(""),st(`Domain-Regel "${Z.domain}" hinzugefügt.`)}catch(Z){f(Z.message||"Fehler beim Hinzufügen.")}},_a=async k=>{try{await J(`/users/domain-rules/${k}/`,{method:"DELETE"}),P(q.filter(Z=>Z.id!==k)),st("Domain-Regel entfernt.")}catch(Z){f(Z.message||"Fehler beim Löschen.")}},Sa=async k=>{if(k.preventDefault(),!!V.trim())try{await J("/skills/",{method:"POST",body:JSON.stringify({name:V,description:U,color:$})}),M(""),x(""),I(_p()),s(),st("Qualifikation angelegt.")}catch(Z){f(Z.message||"Fehler beim Anlegen.")}},_u=async k=>{try{await J(`/skills/${k}/`,{method:"DELETE"}),s(),st("Qualifikation gelöscht.")}catch(Z){f(Z.message||"Fehler beim Löschen.")}},tn=async k=>{try{await J(`/templates/${k}/`,{method:"DELETE"}),Te(ue.filter(Z=>Z.id!==k)),st("Vorlage gelöscht.")}catch(Z){f(Z.message||"Fehler beim Löschen.")}},Na=async k=>{k.preventDefault(),xe(!0);try{await J("/branding/",{method:"POST",body:JSON.stringify({app_name:K,logo_url:ee,primary_color:gt,custom_banner_text:F,show_community_info_box:_t,community_info_title:Dn,community_info_text:Nr,show_support_box:rt,support_box_title:zs,support_box_text:G})}),t(),st("Branding-Einstellungen erfolgreich gespeichert!")}catch(Z){f(Z.message||"Speichern des Brandings fehlgeschlagen.")}finally{xe(!1)}},Su=async k=>{k.preventDefault(),Bl(!0);try{await J("/users/smtp-setting/",{method:"POST",body:JSON.stringify({is_active:zn,host:ls,port:parseInt(pa)||587,username:ga,password:Dl,use_tls:Il,use_ssl:xa,from_email:ya})}),st("✅ SMTP-Einstellungen erfolgreich gespeichert!")}catch(Z){f(Z.message||"Speichern der SMTP-Einstellungen fehlgeschlagen.")}finally{Bl(!1)}},Kl=async()=>{ba(!0);try{const k=await J("/users/smtp-setting/test/",{method:"POST",body:JSON.stringify({email:Fl})});st(`✅ ${k.message||"Test-E-Mail erfolgreich gesendet!"}`)}catch(k){f(k.message||"Test-E-Mail fehlgeschlagen.")}finally{ba(!1)}},Os=w.filter(k=>k.username.toLowerCase().includes(S.toLowerCase())||k.email.toLowerCase().includes(S.toLowerCase())||k.display_name&&k.display_name.toLowerCase().includes(S.toLowerCase()));return i.jsxs("div",{className:"space-y-6 max-w-5xl mx-auto animate-in fade-in duration-200 font-sans",children:[i.jsx("div",{className:"hallmark-panel rounded-sm p-6 sm:p-8 border border-grid space-y-2",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 rounded-sm bg-indigo-500/10 text-indigo-500 border border-indigo-500/20 flex items-center justify-center font-bold",children:i.jsx(Hg,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-serif text-3xl font-bold uppercase tracking-tight text-main",children:"System Administration"}),i.jsx("p",{className:"text-xs text-muted font-mono mt-0.5",children:"Verwaltung von Benutzern, Freischaltungen, Events, Vorlagen, Branding & SMTP-Mailserver"})]})]})}),i.jsx("div",{className:"border-b border-grid pb-2",children:i.jsxs("div",{className:"flex items-center gap-1.5 font-mono text-xs overflow-x-auto no-scrollbar",children:[i.jsxs("button",{onClick:()=>a("users"),className:`px-4 py-2 rounded-sm transition flex items-center gap-2 border ${l==="users"?"bg-surface-hover text-main font-bold border-grid shadow-sm":"bg-subtle text-muted border-transparent hover:text-main"}`,children:[i.jsx(Wg,{className:"w-3.5 h-3.5 text-blue-400"})," [ 01: BENUTZER & SICHERHEIT (",w.length,") ]"]}),i.jsxs("button",{onClick:()=>a("events"),className:`px-4 py-2 rounded-sm transition flex items-center gap-2 border ${l==="events"?"bg-surface-hover text-main font-bold border-grid shadow-sm":"bg-subtle text-muted border-transparent hover:text-main"}`,children:[i.jsx(ra,{className:"w-3.5 h-3.5 text-emerald-400"})," [ 02: VERANSTALTUNGEN (",le.length,") ]"]}),i.jsxs("button",{onClick:()=>a("templates"),className:`px-4 py-2 rounded-sm transition flex items-center gap-2 border ${l==="templates"?"bg-surface-hover text-main font-bold border-grid shadow-sm":"bg-subtle text-muted border-transparent hover:text-main"}`,children:[i.jsx(ou,{className:"w-3.5 h-3.5 text-amber-400"})," [ 03: VORLAGEN & SKILLS ]"]}),i.jsxs("button",{onClick:()=>a("branding"),className:`px-4 py-2 rounded-sm transition flex items-center gap-2 border ${l==="branding"?"bg-surface-hover text-main font-bold border-grid shadow-sm":"bg-subtle text-muted border-transparent hover:text-main"}`,children:[i.jsx(tp,{className:"w-3.5 h-3.5 text-indigo-400"})," [ 04: BRANDING & SYSTEM ]"]}),i.jsxs("button",{onClick:()=>a("smtp"),className:`px-4 py-2 rounded-sm transition flex items-center gap-2 border ${l==="smtp"?"bg-surface-hover text-main font-bold border-grid shadow-sm":"bg-subtle text-muted border-transparent hover:text-main"}`,children:[i.jsx(Xc,{className:"w-3.5 h-3.5 text-purple-400"})," [ 05: E-MAIL & SMTP ]"]})]})}),c&&i.jsxs("div",{className:"p-4 rounded-sm bg-red-500/10 border border-red-500/20 text-red-500 text-xs font-mono flex items-center gap-2",children:[i.jsx(Cl,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{children:c})]}),v&&i.jsxs("div",{className:"p-4 rounded-sm bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 text-xs font-mono flex items-center gap-2",children:[i.jsx(Zn,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{children:v})]}),l==="users"&&i.jsxs("div",{className:"space-y-6 animate-in fade-in duration-150 font-mono",children:[g.length>0&&i.jsxs("div",{className:"hallmark-panel rounded-sm p-5 border border-amber-500/40 bg-amber-500/5 space-y-3",children:[i.jsxs("h3",{className:"font-serif text-lg font-bold uppercase text-amber-500 flex items-center gap-2 border-b border-amber-500/20 pb-2",children:["⚠️ Ausstehende Registrierungen (",g.length,")"]}),i.jsx("div",{className:"space-y-2",children:g.map(k=>i.jsxs("div",{className:"p-3 rounded-sm bg-surface border border-grid flex items-center justify-between text-xs",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"font-bold text-main",children:[k.display_name," (@",k.username,")"]}),i.jsx("div",{className:"text-[11px] text-muted",children:k.email})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:()=>Hl(k.id),className:"px-3 py-1 rounded-sm bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-xs",children:"[ FREISCHALTEN ]"}),i.jsx("button",{onClick:()=>Is(k.id),className:"px-3 py-1 rounded-sm bg-red-600/20 text-red-400 hover:bg-red-600/30 border border-red-600/30 font-bold text-xs",children:"[ ABLEHNEN ]"})]})]},k.id))})]}),i.jsxs("div",{className:"hallmark-panel rounded-sm p-4 border border-grid flex items-center gap-3",children:[i.jsx(Bg,{className:"w-4 h-4 text-muted shrink-0"}),i.jsx("input",{type:"text",value:S,onChange:k=>R(k.target.value),placeholder:"Nutzer suchen nach Name, Username oder E-Mail...",className:"w-full bg-subtle border border-grid px-3 py-1.5 rounded-sm text-xs font-mono text-main focus:outline-none focus:border-muted"}),S&&i.jsx("button",{onClick:()=>R(""),className:"text-xs text-muted hover:text-main font-mono shrink-0",children:"[ CLEAR ]"})]}),i.jsxs("div",{className:"hallmark-panel rounded-sm p-5 border border-grid space-y-4",children:[i.jsxs("h3",{className:"font-serif text-lg font-bold uppercase text-main border-b border-grid pb-2",children:["Benutzerkonten & Rechtestatus (",Os.length,")"]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-left border-collapse text-xs",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-grid text-muted uppercase text-[10px]",children:[i.jsx("th",{className:"pb-2 font-bold",children:"Nutzer"}),i.jsx("th",{className:"pb-2 font-bold",children:"E-Mail"}),i.jsx("th",{className:"pb-2 font-bold",children:"Freigeschaltet"}),i.jsx("th",{className:"pb-2 font-bold",children:"E-Mail Bestätigt"}),i.jsx("th",{className:"pb-2 font-bold",children:"Admin-Rolle"}),i.jsx("th",{className:"pb-2 font-bold text-right",children:"Aktionen"})]})}),i.jsx("tbody",{className:"divide-y divide-grid",children:Os.map(k=>i.jsxs("tr",{className:"hover:bg-subtle/50 transition",children:[i.jsxs("td",{className:"py-2.5 font-bold text-main",children:[k.display_name||k.username,i.jsxs("span",{className:"text-[10px] text-muted font-normal block",children:["@",k.username]})]}),i.jsx("td",{className:"py-2.5 text-muted",children:k.email}),i.jsx("td",{className:"py-2.5",children:i.jsx("span",{className:`px-2 py-0.5 rounded-sm text-[10px] font-bold border ${k.is_approved?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:k.is_approved?"JA":"NEIN"})}),i.jsx("td",{className:"py-2.5",children:i.jsx("span",{className:`px-2 py-0.5 rounded-sm text-[10px] font-bold border ${k.is_email_verified?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-subtle text-muted border-grid"}`,children:k.is_email_verified?"VERIFIZIERT":"AUSSTEHEND"})}),i.jsx("td",{className:"py-2.5",children:i.jsx("span",{className:`px-2 py-0.5 rounded-sm text-[10px] font-bold border ${k.is_admin_user||k.is_superuser?"bg-indigo-500/10 text-indigo-400 border-indigo-500/20":"bg-subtle text-muted border-grid"}`,children:k.is_superuser?"SUPERUSER":k.is_admin_user?"ADMIN":"USER"})}),i.jsxs("td",{className:"py-2.5 text-right space-x-1",children:[i.jsx("button",{onClick:()=>Pt(k),className:"px-2 py-1 rounded-sm text-[10px] bg-subtle hover:bg-surface-hover border border-grid text-main transition",children:k.is_approved?"Sperren":"Freischalten"}),i.jsx("button",{onClick:()=>Ce(k),className:"px-2 py-1 rounded-sm text-[10px] bg-subtle hover:bg-surface-hover border border-grid text-indigo-400 transition",children:k.is_admin_user?"Admin entziehen":"Zu Admin machen"}),i.jsxs("button",{onClick:()=>Lt(k),className:"px-2 py-1 rounded-sm text-[10px] bg-red-500/10 hover:bg-red-500/20 border border-red-500/20 text-red-400 font-bold transition inline-flex items-center gap-1",title:"Benutzerkonto dauerhaft löschen",children:[i.jsx(cn,{className:"w-3 h-3"})," Löschen"]})]})]},k.id))})]})})]}),i.jsxs("div",{className:"hallmark-panel rounded-sm p-5 border border-grid space-y-4",children:[i.jsx("h3",{className:"font-serif text-lg font-bold uppercase text-main border-b border-grid pb-2",children:"Sicherheit & Registrierungs-Einschränkungen"}),i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[i.jsxs("div",{className:"p-4 rounded-sm bg-subtle border border-grid space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"font-bold text-main",children:"E-Mail Bestätigung (Opt-Out)"}),i.jsx("button",{onClick:()=>In("email_verify",!j),className:`px-3 py-1 rounded-sm text-xs font-bold transition border ${j?"bg-emerald-600 text-white border-emerald-500":"bg-amber-500/10 text-amber-500 border-amber-500/20"}`,children:j?"[ PFLICHT ]":"[ DEAKTIVIERT ]"})]}),i.jsx("p",{className:"text-[11px] text-muted font-sans",children:"Bei Pflicht muss die E-Mail vor der Anmeldung verifiziert werden. Bei Deaktivierung ist die Anmeldung direkt möglich."})]}),i.jsxs("div",{className:"p-4 rounded-sm bg-subtle border border-grid space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"font-bold text-main",children:"Domain-Einschränkung"}),i.jsx("button",{onClick:()=>In("restriction",!m),className:`px-3 py-1 rounded-sm text-xs font-bold transition border ${m?"bg-emerald-600 text-white border-emerald-500":"bg-surface text-muted border-grid"}`,children:m?"[ AKTIV ]":"[ INAKTIV ]"})]}),i.jsx("p",{className:"text-[11px] text-muted font-sans",children:"Erlaubt nur Registrierungen von festgelegten E-Mail-Domains (z. B. `@verein.de`)."})]}),i.jsxs("div",{className:"p-4 rounded-sm bg-subtle border border-grid space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"font-bold text-main",children:"Admin-Freischaltpflicht"}),i.jsx("button",{onClick:()=>In("approval",!C),className:`px-3 py-1 rounded-sm text-xs font-bold transition border ${C?"bg-emerald-600 text-white border-emerald-500":"bg-surface text-muted border-grid"}`,children:C?"[ AKTIV ]":"[ INAKTIV ]"})]}),i.jsx("p",{className:"text-[11px] text-muted font-sans",children:"Erfordert die manuelle Freischaltung durch einen Admin vor der ersten Anmeldung."})]})]}),m&&i.jsxs("div",{className:"space-y-3 pt-3 border-t border-grid",children:[i.jsx("h4",{className:"font-serif text-sm font-bold uppercase text-main",children:"Erlaubte E-Mail-Domains"}),i.jsxs("form",{onSubmit:ku,className:"flex gap-2",children:[i.jsx("input",{type:"text",placeholder:"z. B. verein.de oder @beispiel.org",value:Y,onChange:k=>ae(k.target.value),className:"flex-1 px-3 py-1.5 rounded-sm input-field text-xs font-mono"}),i.jsxs("button",{type:"submit",className:"px-4 py-1.5 rounded-sm bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs",children:[i.jsx(Yn,{className:"w-3.5 h-3.5 inline"})," Domain Hinzufügen"]})]}),i.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(k=>i.jsxs("span",{className:"px-2.5 py-1 rounded-sm bg-subtle border border-grid text-xs flex items-center gap-2",children:[i.jsx("strong",{className:"text-main",children:k.domain}),i.jsx("button",{onClick:()=>_a(k.id),className:"text-muted hover:text-red-400",children:i.jsx(cn,{className:"w-3.5 h-3.5"})})]},k.id))})]})]})]}),l==="events"&&i.jsx("div",{className:"space-y-6 animate-in fade-in duration-150 font-mono",children:i.jsxs("div",{className:"hallmark-panel rounded-sm p-5 border border-grid space-y-4",children:[i.jsxs("h3",{className:"font-serif text-lg font-bold uppercase text-main border-b border-grid pb-2",children:["Alle Veranstaltungen (",le.length,")"]}),i.jsx("div",{className:"space-y-3",children:le.map(k=>i.jsxs("div",{className:"p-4 rounded-sm bg-subtle border border-grid flex items-center justify-between text-xs",children:[i.jsxs("div",{children:[i.jsx("h4",{className:"font-serif font-bold text-main text-sm",children:k.title}),i.jsxs("p",{className:"text-muted text-[11px]",children:[new Date(k.start_date).toLocaleDateString("de-DE")," — ",k.location||"Kein Ort"," | Erstellt von: ",k.created_by_name||"Admin"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`px-2 py-0.5 rounded-sm text-[10px] font-bold border ${k.is_active!==!1?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:k.is_active!==!1?"AKTIV":"DEAKTIVIERT"}),i.jsxs("button",{onClick:async()=>{if(window.confirm(`Möchtest du "${k.title}" und alle Schichten wirklich unwiderruflich löschen?`))try{await J(`/events/${k.id}/`,{method:"DELETE"}),n()}catch(Z){alert(Z.message)}},className:"px-2.5 py-1 rounded-sm text-[10px] font-bold bg-red-500/10 hover:bg-red-500/20 text-red-400 border border-red-500/20 transition flex items-center gap-1",title:"Veranstaltung löschen",children:[i.jsx(cn,{className:"w-3 h-3"})," LÖSCHEN"]})]})]},k.id))})]})}),l==="templates"&&i.jsxs("div",{className:"space-y-6 animate-in fade-in duration-150 font-mono",children:[i.jsxs("div",{className:"hallmark-panel rounded-sm p-5 border border-grid space-y-4",children:[i.jsx("h3",{className:"font-serif text-lg font-bold uppercase text-main border-b border-grid pb-2",children:"Erforderliche Qualifikationen (Skills)"}),i.jsxs("form",{onSubmit:Sa,className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[i.jsx("input",{type:"text",placeholder:"Skill Name (z. B. Bar-Erfahrung)",required:!0,value:V,onChange:k=>M(k.target.value),className:"px-3 py-1.5 rounded-sm input-field text-xs font-mono"}),i.jsx("input",{type:"text",placeholder:"Beschreibung (optional)",value:U,onChange:k=>x(k.target.value),className:"px-3 py-1.5 rounded-sm input-field text-xs font-mono"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"color",value:$,onChange:k=>I(k.target.value),className:"w-8 h-8 rounded-sm border-0 cursor-pointer bg-subtle p-0.5"}),i.jsxs("button",{type:"submit",className:"flex-1 px-3 py-1.5 rounded-sm bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-xs",children:[i.jsx(Yn,{className:"w-3.5 h-3.5 inline"})," Anlegen"]})]})]}),i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 pt-2",children:r.map(k=>i.jsxs("div",{className:"p-3 rounded-sm bg-subtle border border-grid flex items-center justify-between text-xs",children:[i.jsxs("div",{children:[i.jsx("span",{style:{color:k.color},className:"font-bold",children:k.name}),k.description&&i.jsx("p",{className:"text-[11px] text-muted",children:k.description})]}),i.jsx("button",{onClick:()=>_u(k.id),className:"text-muted hover:text-red-400",children:i.jsx(cn,{className:"w-3.5 h-3.5"})})]},k.id))})]}),i.jsxs("div",{className:"hallmark-panel rounded-sm p-5 border border-grid space-y-4",children:[i.jsxs("h3",{className:"font-serif text-lg font-bold uppercase text-main border-b border-grid pb-2",children:["Gespeicherte Event-Vorlagen (",ue.length,")"]}),i.jsx("div",{className:"space-y-2",children:ue.map(k=>i.jsxs("div",{className:"p-3 rounded-sm bg-subtle border border-grid flex items-center justify-between text-xs",children:[i.jsxs("div",{children:[i.jsx("div",{className:"font-bold text-main",children:k.name}),i.jsx("div",{className:"text-[11px] text-muted",children:k.description||"Keine Beschreibung"})]}),i.jsx("button",{onClick:()=>tn(k.id),className:"text-muted hover:text-red-400",children:i.jsx(cn,{className:"w-4 h-4"})})]},k.id))})]})]}),l==="branding"&&i.jsx("div",{className:"space-y-6 animate-in fade-in duration-150 font-mono",children:i.jsxs("form",{onSubmit:Na,className:"hallmark-panel rounded-sm p-6 border border-grid space-y-6",children:[i.jsxs("h3",{className:"font-serif text-lg font-bold uppercase text-main border-b border-grid pb-2 flex items-center gap-2",children:[i.jsx(tp,{className:"w-5 h-5 text-indigo-400"})," Portal Branding & Erscheinungsbild"]}),i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 text-xs",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-muted mb-1",children:"Anwendungs-Name"}),i.jsx("input",{type:"text",required:!0,value:K,onChange:k=>W(k.target.value),className:"w-full px-3 py-1.5 rounded-sm input-field font-bold"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-muted mb-1",children:"Primärfarbe (Brand Accent)"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"color",value:gt,onChange:k=>$n(k.target.value),className:"w-9 h-9 rounded-sm border-0 cursor-pointer bg-subtle p-0.5"}),i.jsx("input",{type:"text",value:gt,onChange:k=>$n(k.target.value),className:"flex-1 px-3 py-1.5 rounded-sm input-field font-mono"})]})]}),i.jsxs("div",{className:"sm:col-span-2",children:[i.jsx("label",{className:"block text-muted mb-1",children:"Logo Bild-URL (optional)"}),i.jsx("input",{type:"text",placeholder:"https://beispiel.de/logo.png",value:ee,onChange:k=>Ae(k.target.value),className:"w-full px-3 py-1.5 rounded-sm input-field"})]}),i.jsxs("div",{className:"sm:col-span-2",children:[i.jsx("label",{className:"block text-muted mb-1",children:"Ankündigung (Banner-Text)"}),i.jsx("textarea",{rows:2,placeholder:"z. B. Willkommen beim Sommerfest Schichtplaner!",value:F,onChange:k=>be(k.target.value),className:"w-full px-3 py-1.5 rounded-sm input-field"})]})]}),i.jsx("h4",{className:"font-serif text-base font-bold uppercase text-main pt-4 border-t border-grid",children:"Startseiten Sidebar Boxen"}),i.jsxs("div",{className:"p-4 rounded-sm bg-subtle border border-grid space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-grid pb-2",children:[i.jsx("span",{className:"font-bold text-xs uppercase text-main",children:"📌 Verein & Infos Box"}),i.jsx("button",{type:"button",onClick:()=>rr(!_t),className:`px-3 py-1 rounded-sm text-xs font-bold transition border ${_t?"bg-emerald-600 text-white border-emerald-500":"bg-surface text-muted border-grid"}`,children:_t?"[ AN ]":"[ AUS ]"})]}),_t&&i.jsxs("div",{className:"space-y-3 text-xs",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-muted mb-1",children:"Titel"}),i.jsx("input",{type:"text",value:Dn,onChange:k=>yn(k.target.value),className:"w-full px-3 py-1.5 rounded-sm input-field"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-muted mb-1",children:"Inhalt"}),i.jsx("textarea",{rows:3,value:Nr,onChange:k=>nt(k.target.value),className:"w-full px-3 py-1.5 rounded-sm input-field"})]})]})]}),i.jsxs("div",{className:"p-4 rounded-sm bg-subtle border border-grid space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-grid pb-2",children:[i.jsx("span",{className:"font-bold text-xs uppercase text-main",children:"❤️ Unterstützen Box"}),i.jsx("button",{type:"button",onClick:()=>Ds(!rt),className:`px-3 py-1 rounded-sm text-xs font-bold transition border ${rt?"bg-emerald-600 text-white border-emerald-500":"bg-surface text-muted border-grid"}`,children:rt?"[ AN ]":"[ AUS ]"})]}),rt&&i.jsxs("div",{className:"space-y-3 text-xs",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-muted mb-1",children:"Titel"}),i.jsx("input",{type:"text",value:zs,onChange:k=>z(k.target.value),className:"w-full px-3 py-1.5 rounded-sm input-field"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-muted mb-1",children:"Inhalt"}),i.jsx("textarea",{rows:3,value:G,onChange:k=>Ee(k.target.value),className:"w-full px-3 py-1.5 rounded-sm input-field"})]})]})]}),i.jsx("div",{className:"pt-3 flex justify-end border-t border-grid",children:i.jsx("button",{type:"submit",disabled:en,style:{backgroundColor:"var(--brand-primary)"},className:"px-6 py-2.5 rounded-sm text-xs font-mono font-bold text-white transition hover:brightness-110 shadow-sm",children:en?"Speichern...":"Einstellungen speichern"})})]})}),l==="smtp"&&i.jsx("div",{className:"space-y-6 animate-in fade-in duration-150 font-mono",children:i.jsxs("form",{onSubmit:Su,className:"hallmark-panel rounded-sm p-6 border border-grid space-y-6",children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-grid pb-3",children:[i.jsxs("h3",{className:"font-serif text-lg font-bold uppercase text-main flex items-center gap-2",children:[i.jsx(Xc,{className:"w-5 h-5 text-indigo-400"})," SMTP Server & E-Mail-Versand"]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs text-muted font-bold",children:"SMTP-Versand:"}),i.jsx("button",{type:"button",onClick:()=>fa(!zn),className:`px-3 py-1 rounded-sm text-xs font-bold transition border ${zn?"bg-emerald-600 text-white border-emerald-500 shadow-sm":"bg-subtle text-muted border-grid hover:text-main"}`,children:zn?"[ AKTIV ]":"[ INAKTIV (Dev Mode) ]"})]})]}),!zn&&i.jsxs("div",{className:"p-3.5 rounded-sm bg-amber-500/10 border border-amber-500/20 text-amber-500 text-xs flex items-center gap-2",children:[i.jsx(Cl,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{children:"Hinweis: Im inaktiven Modus werden Bestätigungs-Links in der Entwickler-Konsole / Logs ausgegeben."})]}),i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 text-xs",children:[i.jsxs("div",{className:"sm:col-span-2",children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"SMTP Host / Server Adresse"}),i.jsx("input",{type:"text",placeholder:"z. B. smtp.domain.de oder mail.gmx.net",value:ls,onChange:k=>ha(k.target.value),className:"w-full px-3.5 py-2 rounded-sm input-field font-mono"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"SMTP Port"}),i.jsx("input",{type:"number",placeholder:"587 oder 465",value:pa,onChange:k=>ma(k.target.value),className:"w-full px-3.5 py-2 rounded-sm input-field font-mono"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"Absender E-Mail-Adresse (From)"}),i.jsx("input",{type:"email",placeholder:"noreply@verein.de",value:ya,onChange:k=>wa(k.target.value),className:"w-full px-3.5 py-2 rounded-sm input-field font-mono"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"SMTP Benutzername / Login E-Mail"}),i.jsx("input",{type:"text",placeholder:"z. B. noreply@verein.de",value:ga,onChange:k=>va(k.target.value),className:"w-full px-3.5 py-2 rounded-sm input-field font-mono"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"SMTP Passwort"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:jr?"text":"password",placeholder:"••••••••",value:Dl,onChange:k=>zl(k.target.value),className:"w-full pl-3.5 pr-10 py-2 rounded-sm input-field font-mono"}),i.jsx("button",{type:"button",onClick:()=>bu(!jr),className:"absolute right-3 top-2.5 text-muted hover:text-main",children:jr?i.jsx(Vg,{className:"w-4 h-4"}):i.jsx(sy,{className:"w-4 h-4"})})]})]}),i.jsxs("div",{className:"sm:col-span-2 flex items-center gap-6 pt-2",children:[i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-main font-bold",children:[i.jsx("input",{type:"checkbox",checked:Il,onChange:k=>{Ol(k.target.checked),k.target.checked&&Ul(!1)},className:"rounded-sm"}),i.jsx("span",{children:"STARTTLS verwenden (Empfohlen für Port 587)"})]}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-main font-bold",children:[i.jsx("input",{type:"checkbox",checked:xa,onChange:k=>{Ul(k.target.checked),k.target.checked&&Ol(!1)},className:"rounded-sm"}),i.jsx("span",{children:"SSL/TLS verwenden (Empfohlen für Port 465)"})]})]})]}),i.jsxs("div",{className:"pt-4 border-t border-grid flex flex-wrap items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-[260px]",children:[i.jsx("input",{type:"email",placeholder:"Empfänger für Test-E-Mail...",value:Fl,onChange:k=>wu(k.target.value),className:"px-3 py-1.5 rounded-sm input-field text-xs flex-1 font-mono"}),i.jsxs("button",{type:"button",disabled:Er,onClick:Kl,className:"px-3.5 py-1.5 rounded-sm text-xs font-mono font-bold bg-indigo-500/10 text-indigo-400 border border-indigo-500/20 hover:bg-indigo-500/20 transition flex items-center gap-1.5 shrink-0",children:[i.jsx(dy,{className:"w-3.5 h-3.5"}),Er?"Sende...":"Test-Mail Senden"]})]}),i.jsxs("button",{type:"submit",disabled:Vl,style:{backgroundColor:"var(--brand-primary)"},className:"px-6 py-2.5 rounded-sm text-xs font-mono font-bold text-white transition hover:brightness-110 shadow-sm flex items-center gap-2",children:[i.jsx(Zn,{className:"w-4 h-4"}),Vl?"Speichern...":"SMTP-Einstellungen Speichern"]})]})]})})]})}function Gb({eventToEdit:e,skills:t,user:n,onBack:r,onSubmit:s,onDeleteEvent:l}){var U;const[a,o]=A.useState((e==null?void 0:e.title)||""),[u,c]=A.useState((e==null?void 0:e.description)||""),[f,v]=A.useState((e==null?void 0:e.location)||""),[d,w]=A.useState((e==null?void 0:e.start_date)||new Date().toISOString().split("T")[0]),[y,S]=A.useState((e==null?void 0:e.end_date)||new Date().toISOString().split("T")[0]),[R,g]=A.useState(e!=null&&e.co_managers?e.co_managers.map(x=>x.id):[]),[p,m]=A.useState([]),[N,C]=A.useState([]),[E,j]=A.useState(!1),[L,q]=A.useState("");A.useEffect(()=>{if(P(),e&&e.task_areas&&e.task_areas.length>0){const x=e.task_areas.map($=>({id:$.id,name:$.name,description:$.description||"",shifts:($.shifts||[]).map(I=>({id:I.id,title:I.title,date:I.date||(e?e.start_date:new Date().toISOString().split("T")[0]),start_time:I.start_time,end_time:I.end_time,max_participants:I.max_participants||1,required_skill_ids:I.required_skills?I.required_skills.map(K=>K.id):[]}))}));C(x)}else e||C([{name:"Tresendienst",description:"Getränke- und Barverkauf",shifts:[{title:"Schicht 1",start_time:"18:00",end_time:"22:00",max_participants:2,required_skill_ids:[]}]},{name:"Essen kochen",description:"Zubereitung von Speisen",shifts:[{title:"Frühschicht",start_time:"15:00",end_time:"19:00",max_participants:3,required_skill_ids:[]}]},{name:"Aufbau & Aufräumen",description:"Tische, Stühle & Technik",shifts:[{title:"Aufbau",start_time:"12:00",end_time:"15:00",max_participants:4,required_skill_ids:[]}]}])},[e]);const P=async()=>{try{const x=await J("/users/all/");m(x.results||x)}catch{}},Y=()=>{C([...N,{name:"",description:"",shifts:[{title:"Schicht 1",start_time:"10:00",end_time:"14:00",max_participants:1,required_skill_ids:[]}]}])},ae=x=>{C(N.filter(($,I)=>I!==x))},le=(x,$,I)=>{const K=[...N];K[x][$]=I,C(K)},ke=x=>{const $=[...N];$[x].shifts.push({title:`Schicht ${$[x].shifts.length+1}`,date:d,start_time:"14:00",end_time:"18:00",max_participants:1,required_skill_ids:[]}),C($)},ue=(x,$)=>{const I=[...N];I[x].shifts=I[x].shifts.filter((K,W)=>W!==$),C(I)},Te=(x,$,I,K)=>{const W=[...N];W[x].shifts[$][I]=K,C(W)},V=(x,$,I)=>{const K=[...N],W=K[x].shifts[$].required_skill_ids||[];W.includes(I)?K[x].shifts[$].required_skill_ids=W.filter(ee=>ee!==I):K[x].shifts[$].required_skill_ids=[...W,I],C(K)},M=async x=>{if(x.preventDefault(),q(""),!a.trim()){q("Bitte gib einen Veranstaltungstitel an.");return}j(!0);try{await s({id:e==null?void 0:e.id,title:a,description:u,location:f,start_date:d,end_date:y,co_manager_ids:R,task_areas:N})}catch($){q($.message||"Speichern der Veranstaltung fehlgeschlagen.")}finally{j(!1)}};return i.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto animate-in fade-in duration-200 font-sans",children:[i.jsxs("div",{className:"flex items-center justify-between font-mono text-xs",children:[i.jsxs("button",{onClick:r,className:"px-3.5 py-1.5 rounded-sm bg-subtle hover:bg-surface-hover text-main border border-grid transition flex items-center gap-2 font-bold",children:[i.jsx(Ug,{className:"w-4 h-4"})," [ ZURÜCK ZUR ÜBERSICHT ]"]}),i.jsxs("span",{className:"text-muted border border-grid px-2.5 py-0.5 rounded-sm",children:["MODE: ",e?"EVENT EDIT":"NEW EVENT"]})]}),i.jsx("div",{className:"hallmark-panel rounded-sm p-6 sm:p-8 border border-grid space-y-2",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 rounded-sm bg-blue-500/10 text-blue-500 border border-blue-500/20 flex items-center justify-center font-bold",children:e?i.jsx(Bi,{className:"w-5 h-5"}):i.jsx(ra,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-serif text-3xl font-bold uppercase tracking-tight text-main",children:e?"Veranstaltung & Schichten Bearbeiten":"Neue Veranstaltung Erstellen"}),i.jsx("p",{className:"text-xs text-muted font-mono mt-0.5",children:"Konfiguriere Stammdaten, Co-Verwalter, Aufgabenfelder, Schichtzeiten & Qualifikationen"})]})]})}),L&&i.jsxs("div",{className:"p-4 rounded-sm bg-red-500/10 border border-red-500/20 text-red-500 text-xs font-mono flex items-center gap-2",children:[i.jsx(Cl,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{children:L})]}),i.jsxs("form",{onSubmit:M,className:"space-y-6",children:[i.jsxs("div",{className:"hallmark-panel rounded-sm p-6 border border-grid space-y-4 font-mono text-xs",children:[i.jsx("h3",{className:"font-serif text-lg font-bold uppercase text-main border-b border-grid pb-2",children:"1. Stammdaten & Verwalter der Veranstaltung"}),i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[i.jsxs("div",{className:"sm:col-span-2",children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"Titel der Veranstaltung"}),i.jsx("input",{type:"text",required:!0,value:a,onChange:x=>o(x.target.value),placeholder:"z. B. Sommerfest 2026",className:"w-full px-3.5 py-2 rounded-sm input-field text-sm"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"Startdatum"}),i.jsx("input",{type:"date",required:!0,value:d,onChange:x=>w(x.target.value),className:"w-full px-3.5 py-2 rounded-sm input-field text-sm"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"Enddatum"}),i.jsx("input",{type:"date",required:!0,value:y,onChange:x=>S(x.target.value),className:"w-full px-3.5 py-2 rounded-sm input-field text-sm"})]}),i.jsxs("div",{className:"sm:col-span-2",children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"Ort (optional)"}),i.jsx("input",{type:"text",value:f,onChange:x=>v(x.target.value),placeholder:"z. B. Vereinsheim, Großer Saal",className:"w-full px-3.5 py-2 rounded-sm input-field text-xs"})]}),i.jsxs("div",{className:"sm:col-span-2",children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"Beschreibung (optional)"}),i.jsx("textarea",{rows:2,value:u,onChange:x=>c(x.target.value),placeholder:"Details zur Veranstaltung...",className:"w-full px-3.5 py-2 rounded-sm input-field text-xs font-sans"})]}),p.length>0&&i.jsxs("div",{className:"sm:col-span-2 pt-3 border-t border-grid space-y-2",children:[i.jsxs("label",{className:"block text-main font-bold flex items-center gap-1.5",children:[i.jsx(Wg,{className:"w-4 h-4 text-indigo-400"})," Co-Verwalter / Mit-Organisatoren (optional)"]}),i.jsx("p",{className:"text-[11px] text-muted font-sans",children:"Wähle registrierte Benutzer aus, die dieses Event ebenfalls verwalten, bearbeiten und Gäste eintragen dürfen:"}),i.jsx("div",{className:"flex flex-wrap gap-2 pt-1",children:p.map(x=>{const $=R.includes(x.id);return i.jsxs("button",{type:"button",onClick:()=>{g($?R.filter(I=>I!==x.id):[...R,x.id])},className:`px-3 py-1.5 rounded-sm text-xs font-mono font-bold transition flex items-center gap-1.5 border ${$?"bg-indigo-500/20 text-indigo-300 border-indigo-500/50 shadow-sm":"bg-subtle text-muted border-grid hover:text-main"}`,children:[i.jsx(xf,{className:`w-3.5 h-3.5 ${$?"text-indigo-400":"opacity-40"}`}),i.jsx("span",{children:x.display_name||x.username})]},x.id)})})]})]})]}),i.jsxs("div",{className:"hallmark-panel rounded-sm p-6 border border-grid space-y-4 font-mono text-xs",children:[i.jsxs("div",{className:"flex items-center justify-between border-b border-grid pb-2",children:[i.jsxs("h3",{className:"font-serif text-lg font-bold uppercase text-main flex items-center gap-2",children:[i.jsx(ou,{className:"w-4 h-4 text-blue-500"})," 2. Aufgabenfelder & Schichten"]}),i.jsxs("button",{type:"button",onClick:Y,className:"px-3.5 py-1.5 rounded-sm text-xs font-mono font-bold bg-blue-500/10 text-blue-500 border border-blue-500/20 hover:bg-blue-500/20 transition flex items-center gap-1",children:[i.jsx(Yn,{className:"w-3.5 h-3.5"})," BEREICH HINZUFÜGEN"]})]}),N.map((x,$)=>i.jsxs("div",{className:"p-4 rounded-sm bg-subtle border border-grid space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("input",{type:"text",required:!0,placeholder:"Name des Aufgabenfeldes (z. B. Tresendienst)",value:x.name,onChange:I=>le($,"name",I.target.value),className:"flex-1 px-3 py-1.5 rounded-sm input-field text-xs font-bold"}),i.jsx("button",{type:"button",onClick:()=>ae($),className:"p-1.5 text-muted hover:text-red-400 transition",title:"Bereich entfernen",children:i.jsx(cn,{className:"w-4 h-4"})})]}),i.jsxs("div",{className:"pl-3 border-l-2 border-grid space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between text-xs text-muted font-bold",children:[i.jsx("span",{children:"Schichten & Zeitfenster"}),i.jsxs("button",{type:"button",onClick:()=>ke($),className:"text-blue-500 hover:underline flex items-center gap-1",children:[i.jsx(Yn,{className:"w-3 h-3"})," Schicht hinzufügen"]})]}),x.shifts.map((I,K)=>i.jsxs("div",{className:"p-3 rounded-sm bg-surface border border-grid space-y-2",children:[i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-12 gap-2 items-center text-xs",children:[i.jsx("input",{type:"text",placeholder:"Titel",value:I.title,onChange:W=>Te($,K,"title",W.target.value),className:"sm:col-span-3 px-2.5 py-1 rounded-sm input-field text-xs"}),i.jsx("input",{type:"date",title:"Schichtdatum",min:d,max:y,value:I.date||d,onChange:W=>Te($,K,"date",W.target.value),className:"sm:col-span-3 px-2 py-1 rounded-sm input-field text-xs font-mono text-indigo-400 font-bold"}),i.jsx("input",{type:"text",placeholder:"Start (14:00)",value:I.start_time,onChange:W=>Te($,K,"start_time",W.target.value),className:"sm:col-span-2 px-2.5 py-1 rounded-sm input-field text-xs"}),i.jsx("input",{type:"text",placeholder:"Ende (18:00)",value:I.end_time,onChange:W=>Te($,K,"end_time",W.target.value),className:"sm:col-span-2 px-2.5 py-1 rounded-sm input-field text-xs"}),i.jsx("div",{className:"sm:col-span-1 flex items-center gap-1",children:i.jsx("input",{type:"number",min:"1",title:"Max. Plätze",value:I.max_participants,onChange:W=>Te($,K,"max_participants",parseInt(W.target.value)||1),className:"w-full px-1.5 py-1 rounded-sm input-field text-xs font-bold text-center"})}),i.jsx("button",{type:"button",onClick:()=>ue($,K),className:"sm:col-span-1 p-1 text-muted hover:text-red-400 text-center",title:"Schicht löschen",children:i.jsx(cn,{className:"w-3.5 h-3.5 mx-auto"})})]}),t&&t.length>0&&i.jsxs("div",{className:"pt-2 border-t border-grid flex flex-wrap items-center gap-1.5",children:[i.jsx("span",{className:"text-[10px] text-muted font-bold mr-1",children:"Erforderlich:"}),t.map(W=>{const ee=(I.required_skill_ids||[]).includes(W.id);return i.jsxs("button",{type:"button",onClick:()=>V($,K,W.id),style:{backgroundColor:ee?`${W.color}25`:"transparent",borderColor:ee?W.color:"var(--color-border-grid)",color:ee?W.color:"var(--color-text-muted)"},className:"px-2 py-0.5 rounded-sm text-[10px] border font-bold transition flex items-center gap-1",children:[i.jsx("span",{children:W.name}),ee&&i.jsx(Zn,{className:"w-3 h-3"})]},W.id)})]})]},K))]})]},$))]}),i.jsxs("div",{className:"flex items-center justify-between gap-3 pt-2 font-mono",children:[e&&l&&n&&(n.is_admin_user||n.is_staff||n.is_superuser||e.created_by===n.id||((U=e.created_by)==null?void 0:U.id)===n.id)?i.jsxs("button",{type:"button",onClick:()=>l(e),className:"px-4 py-2.5 rounded-sm text-xs font-bold bg-red-500/10 hover:bg-red-500/20 text-red-400 border border-red-500/20 transition flex items-center gap-1.5",children:[i.jsx(cn,{className:"w-4 h-4"})," VERANSTALTUNG LÖSCHEN"]}):i.jsx("div",{}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("button",{type:"button",onClick:r,className:"px-5 py-2.5 rounded-sm text-xs font-semibold text-muted hover:bg-surface-hover transition border border-grid",children:"Abbrechen"}),i.jsxs("button",{type:"submit",disabled:E,style:{backgroundColor:"var(--brand-primary)"},className:"px-6 py-2.5 rounded-sm text-xs font-bold text-white transition hover:brightness-110 shadow-sm flex items-center gap-2",children:[i.jsx(Zn,{className:"w-4 h-4"}),E?"Speichern...":"Veranstaltung Speichern"]})]})]})]})]})}function qb({onBack:e,onInstantiateTemplate:t,user:n,skills:r}){const[s,l]=A.useState([]),[a,o]=A.useState(!0),[u,c]=A.useState(""),[f,v]=A.useState(null),[d,w]=A.useState(""),[y,S]=A.useState(new Date().toISOString().split("T")[0]),[R,g]=A.useState(new Date().toISOString().split("T")[0]),[p,m]=A.useState(""),[N,C]=A.useState(!1),[E,j]=A.useState(!1),[L,q]=A.useState(""),[P,Y]=A.useState(""),[ae,le]=A.useState([{name:"Tresendienst",description:"Getränkeausschank und Bar",shifts:[{title:"Frühschicht",start_time:"18:00",end_time:"22:00",max_participants:2,required_skill_ids:[]},{title:"Spätschicht",start_time:"22:00",end_time:"02:00",max_participants:3,required_skill_ids:[]}]}]);A.useEffect(()=>{ke()},[]);const ke=async()=>{o(!0);try{const x=await J("/templates/");l(x.results||x)}catch(x){c(x.message||"Laden der Vorlagen fehlgeschlagen.")}finally{o(!1)}},ue=x=>{v(x),w(x.name)},Te=async x=>{if(x.preventDefault(),!!f){C(!0);try{await t(f.id,{title:d,start_date:y,end_date:R,location:p})}catch($){c($.message||"Erstellen der Veranstaltung aus Vorlage fehlgeschlagen.")}finally{C(!1)}}},V=async x=>{if(x.preventDefault(),!L.trim()){c("Bitte gib einen Vorlagen-Namen an.");return}C(!0);try{const $={name:L,description:P,template_data:{task_areas:ae.map(I=>({name:I.name,description:I.description,shifts:(I.shifts||[]).map(K=>({title:K.title,start_time:K.start_time,end_time:K.end_time,max_participants:K.max_participants,required_skill_ids:K.required_skill_ids}))}))}};await J("/templates/",{method:"POST",body:JSON.stringify($)}),j(!1),q(""),Y(""),ke()}catch($){c($.message||"Erstellen der Vorlage fehlgeschlagen.")}finally{C(!1)}},M=()=>{le([...ae,{name:"Neuer Bereich",description:"",shifts:[{title:"Schicht 1",start_time:"14:00",end_time:"18:00",max_participants:2,required_skill_ids:[]}]}])},U=x=>{const $=[...ae];$[x].shifts.push({title:`Schicht ${$[x].shifts.length+1}`,start_time:"18:00",end_time:"22:00",max_participants:2,required_skill_ids:[]}),le($)};return i.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto animate-in fade-in duration-200 font-sans",children:[i.jsxs("div",{className:"flex items-center justify-between font-mono text-xs",children:[i.jsxs("button",{onClick:e,className:"px-3.5 py-1.5 rounded-sm bg-subtle hover:bg-surface-hover text-main border border-grid transition flex items-center gap-2 font-bold",children:[i.jsx(Ug,{className:"w-4 h-4"})," [ ZURÜCK ZUR ÜBERSICHT ]"]}),i.jsxs("span",{className:"text-muted border border-grid px-2.5 py-0.5 rounded-sm uppercase",children:["SYSTEM VORLAGEN (",s.length,")"]})]}),i.jsx("div",{className:"hallmark-panel rounded-sm p-6 sm:p-8 border border-grid space-y-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-10 h-10 rounded-sm bg-indigo-500/10 text-indigo-400 border border-indigo-500/20 flex items-center justify-center font-bold",children:i.jsx(ou,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"font-serif text-3xl font-bold uppercase tracking-tight text-main",children:"Veranstaltungs-Vorlagen Zentrale"}),i.jsx("p",{className:"text-xs text-muted font-mono mt-0.5",children:"Erstelle neue Veranstaltungen mit voreingestellten Schichten und Aufgabenbereichen"})]})]}),n&&i.jsxs("button",{onClick:()=>j(!E),className:"px-3.5 py-2 rounded-sm text-xs font-mono font-bold bg-indigo-500/10 text-indigo-400 border border-indigo-500/20 hover:bg-indigo-500/20 transition flex items-center gap-1.5 shrink-0",children:[i.jsx(Yn,{className:"w-4 h-4"}),E?"Schließen":"Neue Vorlage Erstellen"]})]})}),u&&i.jsxs("div",{className:"p-4 rounded-sm bg-red-500/10 border border-red-500/20 text-red-500 text-xs font-mono flex items-center gap-2",children:[i.jsx(Cl,{className:"w-4 h-4 shrink-0"}),i.jsx("span",{children:u})]}),E&&i.jsxs("form",{onSubmit:V,className:"hallmark-panel rounded-sm p-6 border border-grid space-y-4 font-mono text-xs animate-in fade-in duration-200",children:[i.jsxs("h3",{className:"font-serif text-lg font-bold uppercase text-indigo-400 border-b border-grid pb-2 flex items-center justify-between",children:[i.jsx("span",{children:"Neue Vorlage mit voreingestellten Schichten anlegen"}),i.jsxs("button",{type:"button",onClick:M,className:"text-xs font-mono font-bold bg-indigo-500/20 text-indigo-300 px-3 py-1 rounded-sm border border-indigo-500/30 flex items-center gap-1",children:[i.jsx(Yn,{className:"w-3.5 h-3.5"})," Bereich Hinzufügen"]})]}),i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[i.jsxs("div",{className:"sm:col-span-2",children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"Vorlagen Name"}),i.jsx("input",{type:"text",required:!0,placeholder:"z. B. Standard Kneipenabend / Bar-Event",value:L,onChange:x=>q(x.target.value),className:"w-full px-3.5 py-2 rounded-sm input-field text-sm font-bold"})]}),i.jsxs("div",{className:"sm:col-span-2",children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"Beschreibung (optional)"}),i.jsx("input",{type:"text",placeholder:"z. B. Inklusive 2 Barschichten und Aufbau",value:P,onChange:x=>Y(x.target.value),className:"w-full px-3.5 py-2 rounded-sm input-field text-xs"})]})]}),i.jsx("div",{className:"space-y-4 pt-2",children:ae.map((x,$)=>i.jsxs("div",{className:"p-4 rounded-sm bg-subtle border border-grid space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsx("input",{type:"text",required:!0,placeholder:"Bereichs-Name (z. B. Bar)",value:x.name,onChange:I=>{const K=[...ae];K[$].name=I.target.value,le(K)},className:"flex-1 px-3 py-1 rounded-sm input-field text-xs font-bold"}),i.jsx("button",{type:"button",onClick:()=>{le(ae.filter((I,K)=>K!==$))},className:"text-muted hover:text-red-400 p-1",children:i.jsx(cn,{className:"w-4 h-4"})})]}),i.jsxs("div",{className:"pl-3 border-l-2 border-grid space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between text-muted text-[11px] font-bold",children:[i.jsx("span",{children:"Voreingestellte Schichten"}),i.jsxs("button",{type:"button",onClick:()=>U($),className:"text-indigo-400 hover:underline flex items-center gap-1",children:[i.jsx(Yn,{className:"w-3 h-3"})," Schicht hinzufügen"]})]}),x.shifts.map((I,K)=>i.jsxs("div",{className:"p-2.5 rounded-sm bg-surface border border-grid grid grid-cols-1 sm:grid-cols-12 gap-2 items-center text-xs",children:[i.jsx("input",{type:"text",placeholder:"Schichtname",value:I.title,onChange:W=>{const ee=[...ae];ee[$].shifts[K].title=W.target.value,le(ee)},className:"sm:col-span-4 px-2 py-1 rounded-sm input-field text-xs"}),i.jsx("input",{type:"text",placeholder:"Start (18:00)",value:I.start_time,onChange:W=>{const ee=[...ae];ee[$].shifts[K].start_time=W.target.value,le(ee)},className:"sm:col-span-2 px-2 py-1 rounded-sm input-field text-xs"}),i.jsx("input",{type:"text",placeholder:"Ende (22:00)",value:I.end_time,onChange:W=>{const ee=[...ae];ee[$].shifts[K].end_time=W.target.value,le(ee)},className:"sm:col-span-2 px-2 py-1 rounded-sm input-field text-xs"}),i.jsxs("div",{className:"sm:col-span-3 flex items-center gap-1",children:[i.jsx("span",{className:"text-[10px] text-muted",children:"Plätze:"}),i.jsx("input",{type:"number",min:"1",value:I.max_participants,onChange:W=>{const ee=[...ae];ee[$].shifts[K].max_participants=parseInt(W.target.value)||1,le(ee)},className:"w-full px-2 py-1 rounded-sm input-field text-xs font-bold"})]}),i.jsx("button",{type:"button",onClick:()=>{const W=[...ae];W[$].shifts=W[$].shifts.filter((ee,Ae)=>Ae!==K),le(W)},className:"sm:col-span-1 p-1 text-muted hover:text-red-400 text-center",children:i.jsx(cn,{className:"w-3.5 h-3.5 mx-auto"})})]},K))]})]},$))}),i.jsxs("div",{className:"pt-3 flex justify-end gap-2 border-t border-grid",children:[i.jsx("button",{type:"button",onClick:()=>j(!1),className:"px-4 py-2 rounded-sm text-xs font-semibold text-muted hover:bg-surface-hover transition border border-grid",children:"Abbrechen"}),i.jsxs("button",{type:"submit",disabled:N,style:{backgroundColor:"var(--brand-primary)"},className:"px-5 py-2 rounded-sm text-xs font-mono font-bold text-white transition hover:brightness-110 shadow-sm flex items-center gap-1.5",children:[i.jsx(Zn,{className:"w-4 h-4"})," Vorlage Speichern"]})]})]}),i.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[i.jsx("h3",{className:"font-serif text-lg font-bold uppercase text-main",children:"Verfügbare Vorlagen"}),a?i.jsx("div",{className:"hallmark-panel p-8 text-center text-muted",children:"Lade Vorlagen..."}):s.length===0?i.jsx("div",{className:"hallmark-panel p-8 text-center text-muted italic",children:'[ Noch keine Vorlagen gespeichert. Klicke oben auf "Neue Vorlage Erstellen" um Vorlagen mit voreingestellten Schichten anzulegen. ]'}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:s.map(x=>{var $;return i.jsxs("div",{onClick:()=>ue(x),className:`hallmark-panel p-5 rounded-sm border cursor-pointer transition space-y-3 ${(f==null?void 0:f.id)===x.id?"bg-indigo-500/10 border-indigo-500 shadow-md":"bg-surface border-grid hover:border-muted"}`,children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h4",{className:"font-serif text-base font-bold text-main uppercase",children:x.name}),(f==null?void 0:f.id)===x.id&&i.jsx("span",{className:"text-[10px] font-mono text-indigo-400 bg-indigo-500/20 px-2 py-0.5 rounded-sm border border-indigo-500/30 font-bold",children:"[ AUSGEWÄHLT ]"})]}),x.description&&i.jsx("p",{className:"text-xs font-sans text-muted",children:x.description}),(($=x.template_data)==null?void 0:$.task_areas)&&x.template_data.task_areas.length>0&&i.jsxs("div",{className:"space-y-2 pt-2 border-t border-grid text-[11px]",children:[i.jsx("div",{className:"font-bold text-muted uppercase text-[10px]",children:"📌 Voreingestellte Schichten:"}),x.template_data.task_areas.map((I,K)=>{var W;return i.jsxs("div",{className:"bg-subtle p-2 rounded-sm border border-grid space-y-1",children:[i.jsxs("div",{className:"font-bold text-main flex items-center justify-between",children:[i.jsx("span",{children:I.name}),i.jsxs("span",{className:"text-[10px] text-muted font-normal",children:[((W=I.shifts)==null?void 0:W.length)||0," Schichten"]})]}),i.jsx("div",{className:"flex flex-wrap gap-1",children:(I.shifts||[]).map((ee,Ae)=>i.jsxs("span",{className:"px-2 py-0.5 rounded-sm bg-surface border border-grid text-[10px] flex items-center gap-1 font-mono",children:[i.jsx(Vi,{className:"w-3 h-3 text-muted shrink-0"}),i.jsx("strong",{className:"text-main",children:ee.title}),i.jsxs("span",{className:"text-muted",children:["(",ee.start_time,"-",ee.end_time,", ",ee.max_participants," Plätze)"]})]},Ae))})]},K)})]}),i.jsxs("div",{className:"text-[10px] text-muted pt-2 border-t border-grid flex items-center justify-between",children:[i.jsxs("span",{children:["Erstellt von: ",i.jsx("strong",{children:x.created_by_name||"Admin"})]}),i.jsx("span",{className:"text-indigo-400 font-bold",children:"Klick zum Auswählen"})]})]},x.id)})})]}),f&&i.jsxs("form",{onSubmit:Te,className:"hallmark-panel rounded-sm p-6 border border-grid space-y-4 font-mono text-xs animate-in fade-in duration-200",children:[i.jsxs("h3",{className:"font-serif text-lg font-bold uppercase text-indigo-400 border-b border-grid pb-2",children:['Neue Veranstaltung aus Vorlage "',f.name,'" Erstellen']}),i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[i.jsxs("div",{className:"sm:col-span-2",children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"Titel der Veranstaltung"}),i.jsx("input",{type:"text",required:!0,value:d,onChange:x=>w(x.target.value),className:"w-full px-3.5 py-2 rounded-sm input-field text-sm font-bold"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"Startdatum"}),i.jsx("input",{type:"date",required:!0,value:y,onChange:x=>S(x.target.value),className:"w-full px-3.5 py-2 rounded-sm input-field text-xs"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"Enddatum"}),i.jsx("input",{type:"date",required:!0,value:R,onChange:x=>g(x.target.value),className:"w-full px-3.5 py-2 rounded-sm input-field text-xs"})]}),i.jsxs("div",{className:"sm:col-span-2",children:[i.jsx("label",{className:"block text-main mb-1 font-bold",children:"Ort (optional)"}),i.jsx("input",{type:"text",value:p,onChange:x=>m(x.target.value),placeholder:"z. B. Großer Saal",className:"w-full px-3.5 py-2 rounded-sm input-field text-xs"})]})]}),i.jsx("div",{className:"pt-3 flex justify-end border-t border-grid",children:i.jsxs("button",{type:"submit",disabled:N,style:{backgroundColor:"var(--brand-primary)"},className:"px-6 py-2.5 rounded-sm text-xs font-mono font-bold text-white transition hover:brightness-110 shadow-sm flex items-center gap-2",children:[i.jsx(uy,{className:"w-4 h-4 fill-white"}),N?"Erstellen...":"Veranstaltung Jetzt Aus Vorlage Erstellen"]})})]})]})}function Qb(){const[e,t]=A.useState(null),[n,r]=A.useState(null),[s,l]=A.useState([]),[a,o]=A.useState([]),[u,c]=A.useState(null),[f,v]=A.useState(null),[d,w]=A.useState(!0),[y,S]=A.useState("home"),[R,g]=A.useState(!1),[p,m]=A.useState(!1),[N,C]=A.useState(null),[E,j]=A.useState(!1),[L,q]=A.useState(!1),[P,Y]=A.useState(localStorage.getItem("theme_mode")||"auto"),[ae,le]=A.useState(null),[ke,ue]=A.useState(null);A.useEffect(()=>{window.addEventListener("beforeinstallprompt",z=>{z.preventDefault(),ue(z)}),$()},[]),A.useEffect(()=>{localStorage.setItem("theme_mode",P);const z=()=>{let G=P;P==="auto"&&(G=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),document.documentElement.setAttribute("data-theme",G)};if(z(),P==="auto"){const G=window.matchMedia("(prefers-color-scheme: dark)"),Ee=()=>z();return G.addEventListener("change",Ee),()=>G.removeEventListener("change",Ee)}},[P]),A.useEffect(()=>{n!=null&&n.primary_color&&(document.documentElement.style.setProperty("--brand-primary",n.primary_color),document.documentElement.style.setProperty("--brand-secondary",n.secondary_color||n.primary_color))},[n]);const[Te,V]=A.useState(null),[M,U]=A.useState(null),x=z=>{le(z),setTimeout(()=>le(null),5e3)},$=async()=>{w(!0);try{try{const xe=await J("/branding/");r(xe)}catch{}if(wd())try{const xe=await J("/users/me/");t(xe),!xe.is_admin_user&&!xe.is_staff&&!xe.is_superuser&&y==="admin"&&S("home")}catch{hl(null),t(null),S("home")}const z=new URLSearchParams(window.location.search),G=z.get("verify_email");if(G)try{const xe=await J("/users/verify-email/",{method:"POST",body:JSON.stringify({token:G})});hl(xe.token),t(xe.user),x(xe.message||"✅ E-Mail-Adresse erfolgreich bestätigt!"),window.history.replaceState({},document.title,window.location.pathname)}catch(xe){x(`⚠️ E-Mail Bestätigung: ${xe.message}`)}const Ee=z.get("claim_token"),en=z.get("guest_name");Ee&&en&&(V(Ee),U(en),wd()||g(!0)),await K(),await W()}catch(z){console.error(z)}finally{w(!1)}},I=async z=>{try{const G=await J(`/users/signups/${z.id}/generate-claim-link/`,{method:"POST"}),Ee=`${window.location.origin}/?claim_token=${G.token}&guest_name=${encodeURIComponent(G.guest_name)}`;navigator.clipboard?(await navigator.clipboard.writeText(Ee),x(`✅ Einladungs-Link für ${G.guest_name} in Zwischenablage kopiert!`)):prompt(`Einladungs-Link für ${G.guest_name} kopieren:`,Ee)}catch(G){alert(G.message||"Fehler beim Erstellen des Links.")}},K=async()=>{try{const z=await J("/skills/");l(z.results||z)}catch{}},W=async()=>{try{const z=await J("/events/"),G=z.results||z;o(G),G.length>0&&!u?(c(G[0].id),ee(G[0].id)):u&&ee(u)}catch{}},ee=async z=>{try{const G=await J(`/events/${z}/matrix/`);v(G)}catch{}},Ae=z=>{c(z),ee(z),S("schedule")},gt=()=>{hl(null),t(null),S("home"),x("Erfolgreich abgemeldet."),u&&ee(u)},$n=(z,G)=>{t(z),z&&!z.is_admin_user&&!z.is_staff&&!z.is_superuser&&y==="admin"&&S("home"),x(G||"Erfolgreich angemeldet!"),u&&ee(u)},F=async z=>{if(!e)C(z),m(!0);else try{const G=await J(`/shifts/${z.id}/signup/`,{method:"POST"});x(G.message||"Erfolgreich für Schicht eingetragen!"),u&&ee(u)}catch(G){x(`Fehler: ${G.message}`)}},be=async z=>{if(!N)return;const G=await J(`/shifts/${N.id}/signup/`,{method:"POST",body:JSON.stringify(z)});x(G.message||"Als Gast eingetragen!"),u&&ee(u)},_t=async z=>{try{const G=await J(`/shifts/${z.id}/signup/`,{method:"DELETE"});x(G.message||"Eintragung storniert."),u&&ee(u)}catch(G){x(`Fehler: ${G.message}`)}},rr=async z=>{if(!(!z||!z.id)&&window.confirm(`Möchtest du die Veranstaltung "${z.title}" und alle zugehörigen Schichten wirklich unwiderruflich löschen?`))try{await J(`/events/${z.id}/`,{method:"DELETE"}),x(`Veranstaltung "${z.title}" wurde erfolgreich gelöscht.`),u===z.id&&c(null),y==="event-editor"&&S("home"),W()}catch(G){x(`Fehler beim Löschen: ${G.message}`)}},[Dn,yn]=A.useState(null),Nr=async z=>{let G=z.id;G?await J(`/events/${G}/`,{method:"PATCH",body:JSON.stringify({title:z.title,description:z.description,location:z.location,start_date:z.start_date,end_date:z.end_date,co_manager_ids:z.co_manager_ids||[]})}):G=(await J("/events/",{method:"POST",body:JSON.stringify({title:z.title,description:z.description,location:z.location,start_date:z.start_date,end_date:z.end_date,co_manager_ids:z.co_manager_ids||[]})})).id;for(let Ee of z.task_areas){if(!Ee.name)continue;let en=Ee.id;en?await J(`/task-areas/${en}/`,{method:"PATCH",body:JSON.stringify({name:Ee.name,description:Ee.description||""})}):en=(await J("/task-areas/",{method:"POST",body:JSON.stringify({event:G,name:Ee.name,description:Ee.description||""})})).id;for(let xe of Ee.shifts){const zn=xe.date||z.start_date;xe.id?await J(`/shifts/${xe.id}/`,{method:"PATCH",body:JSON.stringify({title:xe.title,date:zn,start_time:xe.start_time,end_time:xe.end_time,max_participants:xe.max_participants,required_skill_ids:xe.required_skill_ids||[]})}):await J("/shifts/",{method:"POST",body:JSON.stringify({task_area:en,title:xe.title,date:zn,start_time:xe.start_time,end_time:xe.end_time,max_participants:xe.max_participants,required_skill_ids:xe.required_skill_ids||[]})})}}x(z.id?"Veranstaltung & Schichten aktualisiert!":"Veranstaltung erfolgreich erstellt!"),await W(),Ae(G)},nt=async(z,G)=>{const Ee=await J(`/templates/${z}/instantiate/`,{method:"POST",body:JSON.stringify(G)});x("Veranstaltung aus Vorlage erstellt!"),await W(),Ee.id&&Ae(Ee.id)},rt=()=>{u&&window.open(`/api/events/${u}/export_pdf/`,"_blank")},Ds=()=>{window.print()},zs=()=>{ke&&(ke.prompt(),ke.userChoice.then(z=>{z.outcome==="accepted"&&x("PWA Installation gestartet!"),ue(null)}))};return i.jsxs("div",{className:"min-h-screen bg-canvas text-main flex flex-col font-sans selection:bg-surface-hover transition-colors duration-200",children:[ae&&i.jsxs("div",{className:"fixed bottom-6 right-6 z-50 bg-emerald-600 text-white px-4 py-2.5 rounded-sm shadow-2xl font-mono text-xs flex items-center gap-2 border border-emerald-400 animate-in fade-in slide-in-from-bottom-3 duration-200",children:[i.jsx(Zn,{className:"w-4 h-4"}),i.jsx("span",{children:ae})]}),i.jsx(vy,{branding:n,user:e,activeTab:y,onChangeTab:S,themeMode:P,onChangeThemeMode:Y,onLogout:gt,onOpenAuth:()=>g(!0),onOpenCreateEvent:()=>{yn(null),S("event-editor")},onOpenTemplates:()=>S("templates"),onOpenProfile:()=>q(!0),onOpenAdmin:()=>S("admin"),pwaInstallPrompt:!!ke,onInstallPwa:zs}),i.jsx("main",{className:"flex-1 max-w-7xl w-full mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-6",children:d?i.jsx("div",{className:"hallmark-panel p-16 text-center text-xs text-muted font-mono border border-grid",children:"Lade Daten..."}):y==="home"?i.jsx(Hb,{events:a,user:e,onSelectEvent:Ae,onOpenCreateEvent:()=>{yn(null),S("event-editor")},onToggleEventActive:async z=>{try{await J(`/events/${z.id}/`,{method:"PATCH",body:JSON.stringify({is_active:z.is_active===!1})}),W()}catch(G){alert(G.message||"Aktion fehlgeschlagen.")}},onEditEvent:z=>{yn(z),S("event-editor")},onDeleteEvent:rr,branding:n}):y==="calendar"?i.jsx(Kb,{events:a,onSelectEvent:Ae,branding:n}):y==="admin"&&e&&(e.is_admin_user||e.is_staff||e.is_superuser)?i.jsx(Wb,{branding:n,onRefreshBranding:async()=>{const z=await J("/branding/");r(z)},onRefreshEvents:W,skills:s,onRefreshSkills:K}):y==="event-editor"?i.jsx(Gb,{eventToEdit:Dn,skills:s,user:e,onBack:()=>S("schedule"),onSubmit:Nr,onDeleteEvent:rr}):y==="templates"?i.jsx(qb,{onBack:()=>S("schedule"),onInstantiateTemplate:nt,user:e,skills:s}):i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-center justify-between gap-4 overflow-x-auto pb-2 no-scrollbar font-mono",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs font-bold text-muted uppercase tracking-wider whitespace-nowrap",children:"Ausgewähltes Event:"}),a.map(z=>{const G=u===z.id;return i.jsx("button",{onClick:()=>Ae(z.id),style:{backgroundColor:G?(n==null?void 0:n.primary_color)||"var(--brand-primary)":void 0,borderColor:G?(n==null?void 0:n.primary_color)||"var(--brand-primary)":void 0},className:`px-3.5 py-1.5 rounded-sm text-xs font-bold transition whitespace-nowrap border ${G?"text-white shadow-sm":"bg-subtle text-muted border-grid hover:text-main"}`,children:z.title},z.id)})]}),e&&i.jsxs("button",{onClick:()=>{yn(null),S("event-editor")},className:"px-3.5 py-1.5 rounded-sm text-xs font-bold bg-subtle hover:bg-surface-hover text-main border border-grid transition flex items-center gap-1.5 shrink-0",children:[i.jsx(Yn,{className:"w-4 h-4"})," Neues Event"]})]}),i.jsx(xy,{event:f,user:e,onSignupClick:F,onCancelClick:_t,onEditEvent:z=>{yn(z),S("event-editor")},onDeleteEvent:rr,onRemoveUserFromShift:async(z,G)=>{try{const Ee=await J(`/shifts/${z.id}/signup/${G}/`,{method:"DELETE"});x(Ee.message||"Eintragung entfernt."),W(),u&&Ae(u)}catch(Ee){alert(Ee.message||"Entfernen der Person fehlgeschlagen.")}},onGenerateClaimLink:I,onExportPdf:rt,onPrintView:Ds})]})}),i.jsx("footer",{className:"border-t border-grid py-6 text-center text-xs text-muted font-mono no-print",children:i.jsxs("p",{children:[(n==null?void 0:n.app_name)||"Veranstaltungsschichtplaner"," • PWA Enabled • PostgreSQL & Docker Ready"]})}),R&&i.jsx(Bb,{onClose:()=>{g(!1),V(null),U(null)},onSuccess:$n,claimToken:Te,prefilledGuestName:M}),p&&i.jsx(Fb,{shift:N,onClose:()=>m(!1),onSubmit:be})]})}ic.createRoot(document.getElementById("root")).render(i.jsx(Si.StrictMode,{children:i.jsx(Qb,{})})); diff --git a/frontend/dist/index.html b/frontend/dist/index.html index e4f851d..6f0ad8f 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -11,7 +11,7 @@ Schichtplaner — Veranstaltungsschichtpläne - + diff --git a/frontend/src/components/GuestSignupModal.jsx b/frontend/src/components/GuestSignupModal.jsx index ed4d015..31caa70 100644 --- a/frontend/src/components/GuestSignupModal.jsx +++ b/frontend/src/components/GuestSignupModal.jsx @@ -154,7 +154,7 @@ export default function GuestSignupModal({ shift, onClose, onSubmit }) {