import{f as e,h as t,i as n,r,s as i,t as a}from"./useToast-CS8pZhce.js";import{t as o}from"./clock-BelL0bvZ.js";import{t as s}from"./phone-DpnQw4if.js";import{t as c}from"./star-B6hvSjuv.js";import{C as l,L as u,r as d,s as f,t as p,y as m}from"./index-CyHCRa3Z.js";import{a as h}from"./mockData-DAqQG5te.js";var g=t(e(),1),_=i(),v=[`Пн`,`Вт`,`Ср`,`Чт`,`Пт`,`Сб`,`Вс`],y=[{employeeId:`emp-1`,day:`Пн`,shiftText:`10:00 - 22:00`,hours:12},{employeeId:`emp-1`,day:`Вт`,shiftText:`10:00 - 22:00`,hours:12},{employeeId:`emp-1`,day:`Ср`,shiftText:`10:00 - 22:00`,hours:12},{employeeId:`emp-1`,day:`Чт`,shiftText:`10:00 - 22:00`,hours:12},{employeeId:`emp-1`,day:`Пт`,shiftText:`09:00 - 23:00`,hours:14,hasConflict:!0,conflictReason:`Смена превышает 12 ч (ТК РФ)`},{employeeId:`emp-2`,day:`Вт`,shiftText:`11:00 - 23:00`,hours:12},{employeeId:`emp-2`,day:`Ср`,shiftText:`11:00 - 23:00`,hours:12},{employeeId:`emp-2`,day:`Чт`,shiftText:`11:00 - 23:00`,hours:12},{employeeId:`emp-2`,day:`Сб`,shiftText:`11:00 - 23:00`,hours:12},{employeeId:`emp-2`,day:`Вс`,shiftText:`11:00 - 23:00`,hours:12},{employeeId:`emp-3`,day:`Пн`,shiftText:`10:00 - 22:00`,hours:12},{employeeId:`emp-3`,day:`Чт`,shiftText:`10:00 - 22:00`,hours:12},{employeeId:`emp-3`,day:`Пт`,shiftText:`10:00 - 22:00`,hours:12},{employeeId:`emp-3`,day:`Сб`,shiftText:`10:00 - 22:00`,hours:12},{employeeId:`emp-4`,day:`Пн`,shiftText:`12:00 - 00:00`,hours:12},{employeeId:`emp-4`,day:`Вт`,shiftText:`12:00 - 00:00`,hours:12},{employeeId:`emp-4`,day:`Пт`,shiftText:`12:00 - 00:00`,hours:12},{employeeId:`emp-4`,day:`Сб`,shiftText:`12:00 - 00:00`,hours:12}],b=()=>{let{showToast:e}=a(),[t,i]=(0,g.useState)(`employees`),[b,x]=(0,g.useState)(h),[S,C]=(0,g.useState)(y),[w,T]=(0,g.useState)(``),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(``),[A,j]=(0,g.useState)(`Официант`),[M,N]=(0,g.useState)(`+7 (913) `),[P,F]=(0,g.useState)(250),[I,L]=(0,g.useState)(null),R=b.filter(e=>e.name.toLowerCase().includes(w.toLowerCase())||e.role.toLowerCase().includes(w.toLowerCase())),z=t=>{if(t.preventDefault(),!O.trim())return;let n=O.split(` `).map(e=>e[0]).join(``).slice(0,2).toUpperCase()||`НС`,r={id:`emp-${Date.now()}`,name:O.trim(),role:A,status:`off_shift`,shiftHours:`09:00 - 21:00`,salesToday:0,rating:5,phone:M,avatarInitials:n};x(e=>[r,...e]),D(!1),k(``),e({title:`Сотрудник добавлен`,message:`Карточка «${r.name}» (${r.role}) успешно создана`,type:`success`})},B=()=>{if(!I)return;let t=I.hours>12,n=t?`Смена превышает 12 ч (ТК РФ)`:void 0;C(e=>{let r=e.filter(e=>e.employeeId!==I.empId||e.day!==I.day);return I.shiftText===`Выходной`||I.hours===0?r:[...r,{employeeId:I.empId,day:I.day,shiftText:I.shiftText,hours:I.hours,hasConflict:t,conflictReason:n}]}),L(null),e({title:`Смена обновлена`,message:`График на ${I.day} сохранен`,type:`success`})},V=S.filter(e=>e.hasConflict).length;return(0,_.jsxs)(`div`,{className:`space-y-4 animate-fade-in`,children:[(0,_.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3 bg-krona-surface p-3.5 rounded-xl border border-krona-border shadow-krona-soft`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`h2`,{className:`text-sm font-bold text-krona-primary`,children:`Сотрудники, графики и табель учета смен`}),(0,_.jsx)(p,{level:`target`,size:`sm`})]}),(0,_.jsx)(`p`,{className:`text-xs text-krona-secondary mt-0.5`,children:`Управление персоналом, планировщик смен, контроль переработок и предупреждения о конфликтах расписания`})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center bg-krona-workspace p-1 rounded-lg border border-krona-border text-xs`,children:[(0,_.jsxs)(`button`,{onClick:()=>i(`employees`),className:`px-3 py-1 rounded font-medium transition-colors ${t===`employees`?`bg-[#2F684C] text-white shadow-sm`:`text-krona-secondary`}`,children:[`Сотрудники (`,b.length,`)`]}),(0,_.jsxs)(`button`,{onClick:()=>i(`schedule`),className:`px-3 py-1 rounded font-medium transition-colors flex items-center gap-1.5 ${t===`schedule`?`bg-[#2F684C] text-white shadow-sm`:`text-krona-secondary`}`,children:[`График смен`,V>0&&(0,_.jsx)(`span`,{className:`w-4 h-4 rounded-full bg-rose-500 text-white text-[10px] flex items-center justify-center font-bold`,children:V})]})]}),(0,_.jsxs)(n,{variant:`primary`,size:`sm`,onClick:()=>D(!0),children:[(0,_.jsx)(l,{className:`w-3.5 h-3.5 mr-1`}),`Добавить сотрудника`]})]})]}),t===`employees`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,_.jsxs)(`div`,{className:`relative w-72`,children:[(0,_.jsx)(m,{className:`w-3.5 h-3.5 absolute left-2.5 top-2.5 text-krona-secondary`}),(0,_.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:`Поиск по имени или должности...`,className:`w-full pl-8 pr-3 py-1.5 text-xs bg-krona-surface border border-krona-border rounded-lg text-krona-primary placeholder:text-krona-secondary focus:outline-none focus:border-krona-green`})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-krona-secondary`,children:[(0,_.jsxs)(r,{variant:`green`,size:`md`,children:[`На смене: `,b.filter(e=>e.status===`on_shift`).length]}),(0,_.jsxs)(r,{variant:`neutral`,size:`md`,children:[`Выходной: `,b.filter(e=>e.status!==`on_shift`).length]})]})]}),(0,_.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3.5`,children:R.map(e=>(0,_.jsxs)(`div`,{className:`p-4 rounded-xl border border-krona-border bg-krona-surface shadow-krona-soft space-y-3 hover:border-krona-border-strong transition-all`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,_.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-krona-workspace border border-krona-border flex items-center justify-center font-bold text-sm text-krona-primary`,children:e.avatarInitials}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h4`,{className:`text-xs font-bold text-krona-primary`,children:e.name}),(0,_.jsx)(`span`,{className:`text-[11px] text-krona-secondary`,children:e.role})]})]}),(0,_.jsx)(r,{variant:e.status===`on_shift`?`green`:`neutral`,size:`sm`,children:e.status===`on_shift`?`На смене`:`Выходной`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs py-1 border-y border-krona-border/50`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`span`,{className:`text-krona-secondary block text-[10px]`,children:`График сегодня:`}),(0,_.jsxs)(`span`,{className:`font-semibold text-krona-primary flex items-center gap-1`,children:[(0,_.jsx)(o,{className:`w-3 h-3 text-krona-gold`}),e.shiftHours]})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`span`,{className:`text-krona-secondary block text-[10px]`,children:`Рейтинг качества:`}),(0,_.jsxs)(`span`,{className:`font-semibold text-krona-primary flex items-center gap-1`,children:[(0,_.jsx)(c,{className:`w-3 h-3 text-krona-gold fill-krona-gold`}),e.rating,` / 5.0`]})]})]}),(0,_.jsxs)(`div`,{className:`flex items-center justify-between text-xs pt-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1 text-krona-secondary`,children:[(0,_.jsx)(s,{className:`w-3.5 h-3.5`}),(0,_.jsx)(`span`,{className:`font-mono font-medium text-krona-primary`,children:e.phone})]}),(0,_.jsx)(`button`,{onClick:()=>{x(b.map(t=>t.id===e.id?{...t,status:t.status===`on_shift`?`off_shift`:`on_shift`}:t))},className:`text-xs text-krona-green font-medium hover:underline`,children:e.status===`on_shift`?`Завершить смену`:`Вывести на смену`})]})]},e.id))})]}),t===`schedule`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3 bg-krona-surface p-3 rounded-xl border border-krona-border`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(u,{className:`w-4 h-4 text-krona-gold`}),(0,_.jsx)(`span`,{className:`font-bold text-xs text-krona-primary`,children:`Недельный график смен (07.09.2026 — 13.09.2026)`}),V>0?(0,_.jsxs)(r,{variant:`danger`,size:`sm`,children:[V,` конфликт расписания!`]}):(0,_.jsx)(r,{variant:`green`,size:`sm`,children:`Конфликтов нет`})]}),(0,_.jsx)(`p`,{className:`text-[11px] text-krona-secondary`,children:`Кликните по ячейке для назначения или изменения времени смены сотрудника`})]}),(0,_.jsx)(`div`,{className:`bg-krona-surface border border-krona-border rounded-xl shadow-krona-soft overflow-hidden`,children:(0,_.jsx)(`div`,{className:`overflow-x-auto`,children:(0,_.jsxs)(`table`,{className:`w-full text-left text-xs border-collapse min-w-[700px]`,children:[(0,_.jsx)(`thead`,{className:`bg-krona-workspace/80 text-krona-secondary border-b border-krona-border`,children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{className:`p-3 font-semibold w-48`,children:`Сотрудник / Должность`}),v.map(e=>(0,_.jsx)(`th`,{className:`p-3 font-semibold text-center border-l border-krona-border/40`,children:e},e)),(0,_.jsx)(`th`,{className:`p-3 font-semibold text-center border-l border-krona-border/40 w-24`,children:`Часы / нед.`})]})}),(0,_.jsx)(`tbody`,{className:`divide-y divide-krona-border/50`,children:b.map(e=>{let t=S.filter(t=>t.employeeId===e.id),n=t.reduce((e,t)=>e+t.hours,0);return(0,_.jsxs)(`tr`,{className:`hover:bg-krona-workspace/40 transition-colors`,children:[(0,_.jsxs)(`td`,{className:`p-3 font-medium text-krona-primary`,children:[(0,_.jsx)(`div`,{className:`font-semibold`,children:e.name}),(0,_.jsx)(`div`,{className:`text-[11px] text-krona-secondary`,children:e.role})]}),v.map(n=>{let r=t.find(e=>e.day===n);return(0,_.jsx)(`td`,{onClick:()=>{L({empId:e.id,day:n,shiftText:r?r.shiftText:`10:00 - 22:00`,hours:r?r.hours:12})},className:`p-2 border-l border-krona-border/40 text-center cursor-pointer hover:bg-krona-workspace transition-colors`,children:r?(0,_.jsxs)(`div`,{className:`p-1.5 rounded-lg border text-[11px] font-mono leading-tight ${r.hasConflict?`bg-rose-500/15 border-rose-500/50 text-rose-700 dark:text-rose-300 font-bold`:`bg-emerald-500/10 border-emerald-500/30 text-emerald-800 dark:text-emerald-300 font-medium`}`,title:r.conflictReason||`Смена подтверждена`,children:[(0,_.jsx)(`div`,{children:r.shiftText}),(0,_.jsxs)(`div`,{className:`text-[9px] opacity-75`,children:[r.hours,` ч`]}),r.hasConflict&&(0,_.jsxs)(`div`,{className:`flex items-center justify-center gap-0.5 mt-0.5 text-rose-600 font-bold text-[9px]`,children:[(0,_.jsx)(f,{className:`w-2.5 h-2.5`}),` Превышение!`]})]}):(0,_.jsx)(`span`,{className:`text-[11px] text-krona-secondary/60 hover:text-krona-primary`,children:`—`})},n)}),(0,_.jsx)(`td`,{className:`p-3 border-l border-krona-border/40 text-center font-mono font-bold`,children:(0,_.jsxs)(`span`,{className:n>40?`text-amber-600`:`text-krona-primary`,children:[n,` ч`]})})]},e.id)})})]})})})]}),E&&(0,_.jsx)(d,{isOpen:E,onClose:()=>D(!1),title:`Новый сотрудник`,subtitle:`Создание профиля и назначение должности`,maxWidth:`sm`,footer:(0,_.jsxs)(`div`,{className:`flex gap-2 w-full justify-end`,children:[(0,_.jsx)(n,{variant:`secondary`,onClick:()=>D(!1),children:`Отмена`}),(0,_.jsx)(n,{variant:`primary`,onClick:z,children:`Сохранить`})]}),children:(0,_.jsxs)(`div`,{className:`space-y-3 text-xs`,children:[(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-semibold text-krona-primary`,children:`ФИО сотрудника:`}),(0,_.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`Иванова Екатерина Сергеевна`,className:`w-full p-2 bg-krona-workspace border border-krona-border rounded-lg text-krona-primary focus:outline-none focus:border-krona-green`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-semibold text-krona-primary`,children:`Должность:`}),(0,_.jsxs)(`select`,{value:A,onChange:e=>j(e.target.value),className:`w-full p-2 bg-krona-workspace border border-krona-border rounded-lg text-krona-primary focus:outline-none focus:border-krona-green`,children:[(0,_.jsx)(`option`,{value:`Официант`,children:`Официант`}),(0,_.jsx)(`option`,{value:`Су-шеф`,children:`Су-шеф`}),(0,_.jsx)(`option`,{value:`Повар-сушист`,children:`Повар-сушист`}),(0,_.jsx)(`option`,{value:`Курьер`,children:`Курьер`}),(0,_.jsx)(`option`,{value:`Администратор`,children:`Администратор`}),(0,_.jsx)(`option`,{value:`Бармен`,children:`Бармен`})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-semibold text-krona-primary`,children:`Ставка в час (₽):`}),(0,_.jsx)(`input`,{type:`number`,value:P,onChange:e=>F(Number(e.target.value)),className:`w-full p-2 bg-krona-workspace border border-krona-border rounded-lg text-krona-primary focus:outline-none focus:border-krona-green`})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-semibold text-krona-primary`,children:`Контактный телефон:`}),(0,_.jsx)(`input`,{type:`text`,value:M,onChange:e=>N(e.target.value),className:`w-full p-2 bg-krona-workspace border border-krona-border rounded-lg text-krona-primary focus:outline-none focus:border-krona-green`})]})]})}),I&&(0,_.jsx)(d,{isOpen:!!I,onClose:()=>L(null),title:`Назначение смены: ${I.day}`,subtitle:`Сотрудник: ${b.find(e=>e.id===I.empId)?.name}`,maxWidth:`sm`,footer:(0,_.jsxs)(`div`,{className:`flex gap-2 w-full justify-between`,children:[(0,_.jsx)(n,{variant:`danger`,size:`sm`,onClick:()=>{L({...I,shiftText:`Выходной`,hours:0}),setTimeout(B,50)},children:`Сделать выходным`}),(0,_.jsxs)(`div`,{className:`flex gap-2`,children:[(0,_.jsx)(n,{variant:`secondary`,onClick:()=>L(null),children:`Отмена`}),(0,_.jsx)(n,{variant:`primary`,onClick:B,children:`Сохранить смену`})]})]}),children:(0,_.jsxs)(`div`,{className:`space-y-3 text-xs`,children:[(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`font-semibold text-krona-primary`,children:`Время смены:`}),(0,_.jsxs)(`select`,{value:I.shiftText,onChange:e=>{let t=e.target.value,n=12;t.includes(`09:00 - 23:00`)?n=14:t.includes(`10:00 - 18:00`)?n=8:t===`Выходной`&&(n=0),L({...I,shiftText:t,hours:n})},className:`w-full p-2 bg-krona-workspace border border-krona-border rounded-lg text-krona-primary focus:outline-none focus:border-krona-green`,children:[(0,_.jsx)(`option`,{value:`10:00 - 22:00`,children:`10:00 - 22:00 (12 часов, норма)`}),(0,_.jsx)(`option`,{value:`11:00 - 23:00`,children:`11:00 - 23:00 (12 часов, норма)`}),(0,_.jsx)(`option`,{value:`12:00 - 00:00`,children:`12:00 - 00:00 (12 часов, норма)`}),(0,_.jsx)(`option`,{value:`10:00 - 18:00`,children:`10:00 - 18:00 (8 часов, сокращенная)`}),(0,_.jsx)(`option`,{value:`09:00 - 23:00`,children:`09:00 - 23:00 (14 часов, переработка!)`}),(0,_.jsx)(`option`,{value:`Выходной`,children:`Выходной (0 часов)`})]})]}),I.hours>12&&(0,_.jsxs)(`div`,{className:`p-2.5 bg-rose-500/10 border border-rose-500/30 rounded-lg flex items-center gap-2 text-rose-700 dark:text-rose-300`,children:[(0,_.jsx)(f,{className:`w-4 h-4 shrink-0 text-rose-600`}),(0,_.jsxs)(`span`,{children:[`Внимание: смена длится `,I.hours,` часов. Согласно Трудовому кодексу, стандартная смена не должна превышать 12 часов.`]})]})]})})]})};export{b as EmployeesModule};