1import{j as e}from"./motion-4Pe-0l9l.js";import{r as p,a_ as B,J as M,_ as k,c as C,a$ as T,P as E}from"./icons-D33OLVah.js";import{u as A,a as D,b as L,c as O,d as I,e as P,f as $,g as K,h as W,i as F,j as G,k as U}from"./routines-hxoRPs4S.js";import{C as f}from"./Card-CRfFeeMV.js";import{B as x}from"./Button-DINrkm76.js";import{I as v}from"./Input-DCHAd5rh.js";import{M as w}from"./Modal-DGCgU3Zp.js";import{B as j}from"./Badge-DJlHaYuo.js";import{c as y}from"./index-DOjRTYqR.js";import"./react-query-B-PjvZ3S.js";import"./tanstack-9D8FVQmw.js";import"./client-BrDz2RtE.js";import"./gsap-DTZzdSNk.js";import"./GlassSurface-Ca_6sVz_.js";import"./radix-Bm8LYzHo.js";import"./router-C_86t40E.js";import"./recharts-CkBxNeT6.js";const _=["productivity","health","learning","creative","admin","sales","team","personal","other"],N=["Monday","Tuesday","Wednesday","Thursday","Friday"],b={productivity:"bg-accent-cyan/15 text-accent-cyan",health:"bg-accent-green/15 text-accent-green",learning:"bg-accent-purple/15 text-accent-purple",creative:"bg-accent-yellow/15 text-accent-yellow",admin:"bg-white/5 text-text-secondary",sales:"bg-accent-orange/15 text-accent-orange",team:"bg-accent-cyan/15 text-accent-cyan",personal:"bg-accent-purple/15 text-accent-purple",other:"bg-white/5 text-text-secondary"},V=Array.from({length:24},(i,r)=>{const n=Math.floor(r/2)+6,l=r%2===0?"00":"30";return`${n.toString().padStart(2,"0")}:${l}`});function ge(){const[i,r]=p.useState("overview"),[n,l]=p.useState(null),[t,s]=p.useState(null);return e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h1",{className:"text-2xl font-bold text-text-heading flex items-center gap-2",children:[e.jsx(B,{size:24,className:"text-accent-cyan"})," Routinen"]})}),e.jsx("div",{className:"flex gap-1 border-b border-border-secondary",children:[["overview","Ãbersicht"],["create","Erstellen"],["subscribe","Einschreiben"],["my-packages","Meine Pakete"]].map(([o,m])=>e.jsx("button",{onClick:()=>r(o),className:y("px-4 py-2.5 text-sm font-medium border-b-2 transition-colors",i===o?"text-accent-cyan border-accent-cyan":"text-text-muted border-transparent hover:text-text-primary"),children:m},o))}),i==="overview"&&e.jsx(Y,{onDetail:l}),i==="create"&&e.jsx(J,{}),i==="subscribe"&&e.jsx(Q,{onDetail:l}),i==="my-packages"&&e.jsx(Z,{onDetail:l,onCustomBlock:s}),e.jsx(q,{routineId:n,onClose:()=>l(null)}),e.jsx(H,{block:t,onClose:()=>s(null)})]})}function Y({onDetail:i}){const{data:r,isLoading:n}=A(),l=r?.routines??[];return n?e.jsx("div",{className:"text-text-muted text-center py-16",children:"Laden..."}):e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:[l.map(t=>e.jsxs(f,{className:"p-5 cursor-pointer",onClick:()=>i(t.id),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-text-heading font-semibold",children:t.title}),e.jsx(j,{variant:t.status==="active"?"green":t.status==="pending"?"yellow":"neutral",children:t.status})]}),e.jsx("p",{className:"text-text-secondary text-sm mb-3 line-clamp-2",children:t.description}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted",children:[e.jsx("span",{className:y("px-2 py-0.5 rounded",b[t.category]||b.other),children:t.category}),t.difficulty&&e.jsxs("span",{children:["Schwierigkeit: ",t.difficulty]}),t.duration_minutes&&e.jsxs("span",{children:[e.jsx(M,{size:12,className:"inline mr-1"}),t.duration_minutes," min"]})]})]},t.id)),l.length===0&&e.jsx("p",{className:"text-text-muted col-span-full text-center py-8",children:"Keine Routinen vorhanden."})]})}function J(){const i=D(),r=L(),[n,l]=p.useState("meta"),[t,s]=p.useState({title:"",description:"",category:"productivity",difficulty:"medium"}),[o,m]=p.useState(null),[c,d]=p.useState([]);function S(){i.mutateAsync(t).then(a=>{m(a.routine_id),l("schedule")})}function R(a,u){d([...c,{title:"Neuer Block",day_of_week:a,start_time:u,end_time:`${parseInt(u)+1}:00`,category:"focus"}])}function z(){o&&r.mutateAsync({id:o,tasks:c,replace:!0}).then(()=>{l("meta"),s({title:"",description:"",category:"productivity",difficulty:"medium"}),d([]),m(null)})}return n==="schedule"?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-lg font-semibold text-text-heading",children:["Wochenplan: ",t.title]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(x,{variant:"secondary",onClick:()=>l("meta"),children:"Zurück"}),e.jsx(x,{onClick:z,children:"Speichern"})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"grid grid-cols-6 gap-px bg-border-secondary/50 min-w-[700px]",children:[e.jsx("div",{className:"bg-bg-primary p-2"}),N.map(a=>e.jsx("div",{className:"bg-bg-primary p-2 text-center text-xs font-medium text-text-muted",children:a.slice(0,2)},a)),V.map(a=>e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-bg-primary px-2 py-1 text-xs text-text-muted text-right",children:a},`t-${a}`),N.map(u=>{const h=c.find(g=>g.day_of_week===u&&g.start_time===a);return e.jsx("div",{onClick:()=>!h&&R(u,a),className:y("bg-bg-primary p-1 min-h-8 cursor-pointer hover:bg-white/[0.02]",h&&"bg-accent-cyan/10"),children:h&&e.jsx("div",{className:"text-[10px] px-1 py-0.5 bg-accent-cyan/20 rounded text-accent-cyan truncate",children:h.title})},`${u}-${a}`)})]}))]})}),c.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h3",{className:"text-sm font-medium text-text-heading",children:["Geplante Blöcke (",c.length,")"]}),c.map((a,u)=>e.jsxs("div",{className:"glass-panel px-3 py-2 flex items-center gap-3 text-sm",children:[e.jsx(v,{value:a.title||"",onChange:h=>{const g=[...c];g[u]={...a,title:h.target.value},d(g)},className:"flex-1 !py-1 !text-xs"}),e.jsx(j,{variant:"neutral",children:a.day_of_week?.slice(0,2)}),e.jsxs("span",{className:"text-text-muted text-xs",children:[a.start_time," - ",a.end_time]}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>d(c.filter((h,g)=>g!==u)),children:e.jsx(k,{size:12})})]},u))]})]}):e.jsxs(f,{className:"p-6 max-w-xl",children:[e.jsx("h2",{className:"text-lg font-semibold text-text-heading mb-4",children:"Neue Routine erstellen"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{label:"Titel",value:t.title,onChange:a=>s({...t,title:a.target.value})}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-muted uppercase tracking-wider",children:"Beschreibung"}),e.jsx("textarea",{value:t.description,onChange:a=>s({...t,description:a.target.value}),rows:3,className:"bg-bg-input border border-border-secondary rounded-lg px-3 py-3 text-sm text-text-primary resize-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-muted uppercase tracking-wider",children:"Kategorie"}),e.jsx("select",{value:t.category,onChange:a=>s({...t,category:a.target.value}),className:"bg-bg-input border border-border-secondary rounded-lg px-3 py-3 text-sm text-text-primary",children:_.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-muted uppercase tracking-wider",children:"Schwierigkeit"}),e.jsxs("select",{value:t.difficulty,onChange:a=>s({...t,difficulty:a.target.value}),className:"bg-bg-input border border-border-secondary rounded-lg px-3 py-3 text-sm text-text-primary",children:[e.jsx("option",{value:"easy",children:"Einfach"}),e.jsx("option",{value:"medium",children:"Mittel"}),e.jsx("option",{value:"hard",children:"Schwer"})]})]})]}),e.jsx("div",{className:"flex gap-3 justify-end pt-2",children:e.jsx(x,{onClick:S,disabled:!t.t
1itle||i.isPending,children:"Weiter zum Wochenplan"})})]})]})}function Q({onDetail:i}){const{data:r,isLoading:n}=O("active"),l=I(),t=r?.routines??[];return n?e.jsx("div",{className:"text-text-muted text-center py-16",children:"Laden..."}):e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:[t.map(s=>e.jsxs(f,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-text-heading font-semibold",children:s.title}),s.is_subscribed?e.jsx(j,{variant:"green",children:"Abonniert"}):null]}),e.jsx("p",{className:"text-text-secondary text-sm mb-3 line-clamp-2",children:s.description}),e.jsx("div",{className:"flex items-center gap-2 text-xs mb-3",children:e.jsx("span",{className:y("px-2 py-0.5 rounded",b[s.category]||b.other),children:s.category})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(x,{variant:"ghost",size:"sm",onClick:()=>i(s.id),children:[e.jsx(C,{size:14})," Details"]}),!s.is_subscribed&&e.jsx(x,{size:"sm",onClick:()=>l.mutate(s.id),children:"Abonnieren"})]})]},s.id)),t.length===0&&e.jsx("p",{className:"text-text-muted col-span-full text-center py-8",children:"Keine aktiven Routinen verfügbar."})]})}function Z({onDetail:i,onCustomBlock:r}){const{data:n,isLoading:l}=P(),t=$(),s=K(),o=W(),m=n?.subscriptions??[],c=s.data?.blocks??[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-text-heading mb-3",children:"Meine Routinen"}),l?e.jsx("div",{className:"text-text-muted py-8 text-center",children:"Laden..."}):e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[m.map(d=>e.jsxs(f,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-text-heading font-semibold",children:d.title}),e.jsx(j,{variant:"green",children:"Abonniert"})]}),e.jsx("p",{className:"text-text-secondary text-sm mb-3",children:d.description}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(x,{variant:"ghost",size:"sm",onClick:()=>i(d.id),children:[e.jsx(C,{size:14})," Details"]}),e.jsx(x,{variant:"danger",size:"sm",onClick:()=>{confirm("Routine abbestellen?")&&t.mutate(d.id)},children:"Abbestellen"})]})]},d.id)),m.length===0&&e.jsx("p",{className:"text-text-muted col-span-full text-center py-4",children:"Keine abonnierten Routinen."})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h2",{className:"text-lg font-semibold text-text-heading flex items-center gap-2",children:[e.jsx(T,{size:18})," Custom Blocks"]}),e.jsxs(x,{size:"sm",onClick:()=>r({title:"",duration_minutes:30,category:"other"}),children:[e.jsx(E,{size:14})," Neuer Block"]})]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-3",children:c.map(d=>e.jsxs(f,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-text-primary font-medium text-sm",children:d.title}),e.jsxs("span",{className:"text-text-muted text-xs",children:[d.duration_minutes," min"]})]}),e.jsx("span",{className:y("text-xs px-2 py-0.5 rounded",b[d.category]||b.other),children:d.category}),e.jsxs("div",{className:"flex gap-1 mt-2",children:[e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>r(d),children:"Bearbeiten"}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>{confirm("Block löschen?")&&o.mutate(d.id)},children:e.jsx(k,{size:12})})]})]},d.id))})]})]})}function q({routineId:i,onClose:r}){const{data:n,isLoading:l}=F(i);return i?e.jsx(w,{open:!!i,onClose:r,title:n?.title||"Routine",size:"lg",children:l?e.jsx("div",{className:"text-text-muted py-8 text-center",children:"Laden..."}):n&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-text-secondary text-sm",children:n.description}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(j,{variant:"neutral",children:n.category}),n.difficulty&&e.jsx(j,{variant:"neutral",children:n.difficulty}),e.jsx(j,{variant:n.status==="active"?"green":"yellow",children:n.status})]}),n.tasks&&n.tasks.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-text-heading mb-2",children:"Wochenplan"}),e.jsx("div",{className:"space-y-1",children:N.map(t=>{const s=(n.tasks||[]).filter(o=>o.day_of_week===t);return s.length===0?null:e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-text-muted mb-1",children:t}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:s.map((o,m)=>e.jsxs("div",{className:"glass-panel px-3 py-1.5 text-xs",children:[e.jsx("span",{className:"text-text-primary",children:o.title}),e.jsxs("span",{className:"text-text-muted ml-2",children:[o.start_time,"-",o.end_time]})]},m))})]},t)})})]})]})}):null}function H({block:i,onClose:r}){const n=G(),l=U(),[t,s]=p.useState({}),o=i&&"id"in i&&i.id;if(!i)return null;if(Object.keys(t).length===0&&i)return setTimeout(()=>s(i),0),null;function m(){const c={title:t.title||"",duration_minutes:t.duration_minutes||30,category:t.category||"other",description:t.description};(o?l.mutateAsync({id:i.id,...c}):n.mutateAsync(c)).then(()=>{r(),s({})})}return e.jsx(w,{open:!!i,onClose:()=>{r(),s({})},title:o?"Block bearbeiten":"Neuer Custom Block",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{label:"Titel",value:t.title||"",onChange:c=>s({...t,title:c.target.value})}),e.jsx(v,{label:"Dauer (Minuten)",type:"number",value:t.duration_minutes??30,onChange:c=>s({...t,duration_minutes:+c.target.value})}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-muted uppercase tracking-wider",children:"Kategorie"}),e.jsx("select",{value:t.category||"other",onChange:c=>s({...t,category:c.target.value}),className:"bg-bg-input border border-border-secondary rounded-lg px-3 py-3 text-sm text-text-primary",children:_.map(c=>e.jsx("option",{value:c,children:c},c))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-text-muted uppercase tracking-wider",children:"Beschreibung"}),e.jsx("textarea",{value:t.description||"",onChange:c=>s({...t,description:c.target.value}),rows:2,className:"bg-bg-input border border-border-secondary rounded-lg px-3 py-3 text-sm text-text-primary resize-none"})]}),e.jsxs("div",{className:"flex gap-3 justify-end pt-2",children:[e.jsx(x,{variant:"secondary",onClick:()=>{r(),s({})},children:"Abbrechen"}
1),e.jsx(x,{onClick:m,disabled:!t.title,children:"Speichern"})]})]})})}export{ge as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.