1import{b as We,c as je,d as Fe,e as we,f as Ft}from"./chunk-YYLGWJZF.js";import{b as zt,c as Be,f as Re,g as At}from"./chunk-5EPGO6EJ.js";import{a as Et,b as Rt,c as Dt,d as Ot}from"./chunk-KSH4ZOK3.js";import{e as at,g as st}from"./chunk-JCGU4DJ5.js";import{a as Nt,b as Tt,c as It,d as Bt}from"./chunk-GJF57JXS.js";import{a as ae}from"./chunk-QRQ73WOJ.js";import{c as St,d as Ee,e as Ie,f as wt,g as Mt,h as Pt,i as kt}from"./chunk-SQYUGGX4.js";import{a as ut,b as ht,d as gt,g as yt,i as _t,j as ft,n as xt,o as Ct,q as vt,w as bt}from"./chunk-4NYICKVE.js";import{h as ct,j as dt}from"./chunk-KFRX2MAL.js";import{b as L,c as N,d as pt,e as U,f as ee,g as ie,h as $e,j as mt,k as te,l as G,m as J,o as Pe}from"./chunk-5JXCLUFZ.js";import{F as lt,H as Ke,J as ke}from"./chunk-AYQHWHSC.js";import{$a as z,Ab as he,Da as et,Fb as tt,Ha as v,Ma as Ue,Ob as nt,Pb as it,Q as b,R as S,S as pe,Sa as u,T as fe,Ta as s,Ua as a,Va as re,Xb as ot,Ya as xe,Z as Je,Za as Ce,Zb as rt,bb as P,cb as p,hb as me,ib as ue,jb as W,kb as c,lb as E,mb as w,na as Xe,nb as Se,qb as j,rb as H,sa as l,sb as Z,wb as T,yb as I,za as Me}from"./chunk-SFGAONKY.js";import{a as Q,b as de}from"./chunk-C6Q5SG76.js";function B(r){return String(r??"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}function De(r,e){let t=B(r),n=B(e);return!!(t&&n&&t===n)}function Oe(r){let e=B(r);return["anul","cancel","nieobecn","no show","usun"].some(t=>e.includes(t))}function ge(r,e=""){let t=`${B(r)} ${B(e)}`.trim();return["zablokowany czas","blokada czasu","rezerwacja czasu","przerwa","blocked time","time reservation"].some(n=>t.includes(n))}function He(r){let e=B(r);return e.includes("voucher")||e.includes("bon")?"voucher":e.includes("kart")||e.includes("card")||e.includes("terminal")?"card":"cash"}function Ze(r){let e=String(r??"").replace(/\s/g,"").replace(",",".").replace(/[^0-9.-]/g,"");if(!e)return null;let t=Number(e);return Number.isFinite(t)&&t>=0?t:null}function Vt(r,e){return!r&&!e}function Ht(r,e){if(r&1&&(s(0,"option",47),c(1),a()),r&2){let t=e.$implicit;u("value",t.key),l(),w(" ",t.label," ")}}function Zt(r,e){if(r&1&&(s(0,"option",47),c(1),a()),r&2){let t=e.$implicit,n=p(3);u("value",t.uid),l(),w(" ",n.reporterOptionLabel(t)," ")}}function Gt(r,e){if(r&1){let t=z();s(0,"label")(1,"span"),c(2,"Pracownik"),a(),s(3,"select",48),Z("ngModelChange",function(i){b(t);let o=p(2);return H(o.selectedReporterUid,i)||(o.selectedReporterUid=i),S(i)}),P("ngModelChange",function(i){b(t);let o=p(2);return S(o.onReporterChange(i))}),s(4,"option",49),c(5,"Wszyscy (zsumowany)"),a(),v(6,Zt,2,2,"option",31),a()()}if(r&2){let t=p(2);l(3),j("ngModel",t.selectedReporterUid),l(3),u("ngForOf",t.reporterOptions)}}function Qt(r,e){if(r&1){let t=z();s(0,"button",50),P("click",function(){b(t);let i=p(2);return S(i.exportMonthlyPdf())}),c(1),a()}if(r&2){let t=p(2);u("disabled",t.isPdfGenerating||t.isMonthlyLoading),l(),w(" ",t.isPdfGenerating?"Generowanie PDF...":"PDF dla ksiegowej"," ")}}function qt(r,e){r&1&&(s(0,"span",51),c(1,"Gotowka (brak ewidencji)"),a())}function Yt(r,e){if(r&1&&(s(0,"div",52)(1,"article",53)(2,"span"),c(3,"Raporty w miesiacu"),a(),s(4,"strong"),c(5),a()(),s(6,"article",53)(7,"span"),c(8,"Brutto"),a(),s(9,"strong"),c(10),T(11,"number"),a()(),s(12,"article",53)(13,"span"),c(14,"Ewidencjonowana"),a(),s(15,"strong"),c(16),T(17,"number"),a()(),s(18,"article",53)(19,"span"),c(20,"Nieewidencjonowana"),a(),s(21,"strong"),c(22),T(23,"number"),a()(),s(24,"article",53)(25,"span"),c(26,"Stale koszty (admin)"),a(),s(27,"strong"),c(28),T(29,"number"),a()(),s(30,"article",53)(31,"span"),c(32,"Koszty pracownikow"),a(),s(33,"strong"),c(34),T(35,"number"),a()(),s(36,"article",53)(37,"span"),c(38,"Brutto po stalych kosztach"),a(),s(39,"strong"),c(40),T(41,"number"),a()(),s(42,"article",53)(43,"span"),c(44,"Brutto po wszystkich kosztach"),a(),s(45,"strong"),c(46),T(47,"number"),a()()()),r&2){let t=p(2);l(5),E(t.monthlySummary.reportCount),l(5),w("",I(11,8,t.monthlySummary.gross,"1.2-2")," zl"),l(6),w("",I(17,11,t.monthlySummary.recorded,"1.2-2")," zl"),l(6),w("",I(23,14,t.monthlySummary.unrecorded,"1.2-2")," zl"),l(6),w("",I(29,17,t.monthlySummary.fixedCosts,"1.2-2")," zl"),l(6),w("",I(35,20,t.monthlySummary.employeeCosts,"1.2-2")," zl"),l(6),w("",I(41,23,t.monthlySummary.afterFixedCosts,"1.2-2")," zl"),l(6),w("",I(47,26,t.monthlySummary.afterAllCosts,"1.2-2")," zl")}}
1function Jt(r,e){r&1&&(s(0,"div",54),c(1,"Ladowanie tygodnia..."),a())}function Xt(r,e){if(r&1&&(s(0,"span"),c(1),T(2,"number"),a()),r&2){let t=e.$implicit;l(),w("",I(2,1,t,"1.0-0")," zl")}}function en(r,e){if(r&1&&re(0,"div",70),r&2){let t=e.$implicit,n=p(4);ue("height",n.daySegmentHeightPercent(t.amount),"%"),W("cash",t.kind==="cash")("unrecorded",t.kind==="unrecorded")("card",t.kind==="card")("voucher",t.kind==="voucher"),u("title",n.segmentTitle(t))}}function tn(r,e){r&1&&(s(0,"div",71),c(1,"Brak"),a())}function nn(r,e){if(r&1&&(s(0,"span",72),c(1),a()),r&2){let t=p().$implicit;l(),w(" ",t.pendingSettlementCount," do akceptacji ")}}function on(r,e){if(r&1){let t=z();s(0,"button",61),P("click",function(){let i=b(t).$implicit,o=p(3);return S(o.openMonthDay(i.dateKey))}),s(1,"div",62)(2,"span",63),c(3),a(),s(4,"strong"),c(5),a()(),s(6,"div",64)(7,"div",65),v(8,en,1,11,"div",66)(9,tn,2,0,"div",67),a()(),s(10,"div",68)(11,"span"),c(12),a(),s(13,"span"),c(14),T(15,"number"),a(),v(16,nn,2,1,"span",69),a()()}if(r&2){let t=e.$implicit,n=p(3);Ue("title",n.isAdmin?n.dayTooltip(t):null),l(3),E(t.dayLabel),l(2),E(t.dayNumber),l(2),W("is-empty",!t.segments.length),l(),u("ngForOf",t.segments),l(),u("ngIf",!t.segments.length),l(3),w("",t.reportCount," raport"),l(2),w("",I(15,10,t.gross,"1.0-0")," zl"),l(2),u("ngIf",n.isAdmin&&t.pendingSettlementCount)}
1}function rn(r,e){if(r&1&&(s(0,"div",55)(1,"div",56),v(2,Xt,3,4,"span",57),a(),s(3,"div",58)(4,"div",59),v(5,on,17,13,"button",60),a()()()),r&2){let t=p(2);l(2),u("ngForOf",t.chartScaleTicks),l(3),u("ngForOf",t.visibleChartDays)("ngForTrackBy",t.trackByDay)}}function an(r,e){if(r&1&&(s(0,"article",76)(1,"div",77)(2,"strong"),c(3),a(),s(4,"span"),c(5),a(),s(6,"span"),c(7),T(8,"number"),a(),s(9,"span"),c(10),T(11,"number"),a(),s(12,"span"),c(13),T(14,"number"),a(),s(15,"span"),c(16),T(17,"number"),a(),s(18,"span"),c(19),a(),s(20,"span"),c(21),T(22,"number"),a()()()),r&2){let t=e.$implicit,n=p(3);l(3),E(t.email),l(2),w("Raporty: ",t.reportCount),l(2),w("Brutto: ",I(8,8,t.gross,"1.2-2")," zl"),l(3),w("Godziny: ",I(11,11,t.hours,"1.2-2")),l(3),w("Ewidencjonowana: ",I(14,14,t.recorded,"1.2-2")," zl"),l(3),w("Nieewidencjonowana: ",I(17,17,t.unrecorded,"1.2-2")," zl"),l(3),w("Forma: ",n.employmentTypeLabel(t.employmentCostType)),l(2),w("Koszt pracownika: ",I(22,20,n.employeeCostTotal(t),"1.2-2")," zl")}}function sn(r,e){if(r&1&&(s(0,"section",73)(1,"h3"),c(2,"Podsumowanie pracownikow"),a(),s(3,"div",74),v(4,an,23,23,"article",75),a(),s(5,"div",54),c(6,"Koszty pracownikow ustawisz w panelu Uzytkownicy."),a()()),r&2){let t=p(2);l(4),u("ngForOf",t.employeeMonthSummaries)("ngForTrackBy",t.trackByEmployee)}}function ln(r,e){if(r&1&&(s(0,"div",54),c(1),a()),r&2){let t=p(3);l(),w(" Pominieto ",t.hourlySettlementMissingDurationCount," pozycji bez czasu uslugi w cenniku. ")}}function cn(r,e){if(r&1&&(s(0,"tr")(1,"td"),c(2),a(),s(3,"td"),c(4),a(),s(5,"td"),c(6),a(),s(7,"td"),c(8),a()()),r&2){let t=e.$implicit,n=p(4);W("summary-row",t.isSummary),l(2),E(t.dateLabel),l(2),E(t.serviceLabel),l(2),E(n.formatSettlementHours(t.durationHours)),l(2),E(n.formatSettlementHourlyRate(t.hourlyRate))}}function dn(r,e){if(r&1&&(s(0,"div",84)(1,"table",85)(2,"thead")(3,"tr")(4,"th"),c(5,"Dzien"),a(),s(6,"th"),c(7,"Rodzaj uslugi"),a(),s(8,"th"),c(9,"Czas uslugi"),a(),s(10,"th"),c(11,"Cena za godzine"),a()()(),s(12,"tbody"),v(13,cn,9,6,"tr",86),a()()()),r&2){let t=p(3);l(13),u("ngForOf",t.hourlySettlementRows)("ngForTrackBy",t.trackByHourlySettlementRow)}}function pn(r,e){r&1&&(s(0,"div",54),c(1,"Brak pozycji do rozliczenia dla wybranego miesiaca."),a())}function mn(r,e){if(r&1){let t=z();s(0,"section",78)(1,"div",28)(2,"div")(3,"h2"),c(4,"Godziny do rozliczenia"),a(),s(5,"p"),
1c(6),a(),s(7,"div",54),c(8),a()(),s(9,"button",79),P("click",function(){b(t);let i=p(2);return S(i.printHourlySettlementSheet())}),c(10),a()(),s(11,"div",80)(12,"label",81)(13,"span"),c(14,"Podpis pracownika na wydruku"),a(),s(15,"input",82),Z("ngModelChange",function(i){b(t);let o=p(2);return H(o.hourlySettlementSignature,i)||(o.hourlySettlementSignature=i),S(i)}),a()(),v(16,ln,2,1,"div",43),a(),v(17,dn,14,2,"div",83)(18,pn,2,0,"ng-template",null,0,he),a()}if(r&2){let t=me(19),n=p(2);l(6),w("Automatyczne rozliczenie godzinowe za miesiac: ",n.selectedMonthLabel,"."),l(2),w("Pracownik: ",n.selectedSettlementReporterLabel),l(),u("disabled",n.isHourlySettlementPrinting||!n.hourlySettlementRows.length),l(),w(" ",n.isHourlySettlementPrinting?"Przygotowywanie...":"Drukuj A4"," "),l(5),j("ngModel",n.hourlySettlementSignature),l(),u("ngIf",n.hourlySettlementMissingDurationCount),l(),u("ngIf",n.hourlySettlementRows.length)("ngIfElse",t)}}function un(r,e){if(r&1){let t=z();s(0,"div",10)(1,"section",11)(2,"div")(3,"h1"),c(4,"Raport dzienny"),a(),s(5,"p"),
1c(6,"Tygodniowy widok raport\xF3w oraz osobne formularze raportu dziennego i wydatk\xF3w."),a()()(),s(7,"section",12)(8,"button",13),P("click",function(){b(t);let i=p();return S(i.setTopAction("report"))}),s(9,"span",14),pe(),s(10,"svg",15),re(11,"path",16)(12,"path",17)(13,"path",18)(14,"path",19),a()(),fe(),s(15,"span",20),c(16,"Sporzadz raport"),a()(),s(17,"button",21),P("click",function(){b(t);let i=p();return S(i.setTopAction("expense"))}),s(18,"span",14),pe(),s(19,"svg",15),re(20,"path",22)(21,"path",23)(22,"path",24)(23,"path",25)(24,"path",26),a()(),fe(),s(25,"span",20),c(26,"Dodaj wydatek"),a()()(),s(27,"section",27)(28,"div",28)(29,"h2"),c(30,"Poprzednie raporty"),a(),s(31,"div",29)(32,"label")(33,"span"),c(34,"Miesiac"),a(),s(35,"select",30),Z("ngModelChange",function(i){b(t);let o=p();return H(o.selectedMonthKey,i)||(o.selectedMonthKey=i),S(i)}),P("ngModelChange",function(i){b(t);let o=p();return S(o.onMonthChange(i))}),v(36,Ht,2,2,"option",31),a()(),v(37,Gt,7,2,"label",32)(38,Qt,2,2,"button",33),a()(),s(39,"div",34)(40,"button",35),P("click",function(){b(t);let i=p();return S(i.previousWeek())}),c(41," Poprzedni tydzien "),a(),s(42,"strong"),c(43),a(),s(44,"button",35),P("click",function(){b(t);let i=p();return S(i.nextWeek())}),c(45,"Nastepny tydzien"),a()(),s(46,"div",36)(47,"span",37),c(48,"Gotowka"),a(),v(49,qt,2,0,"span",38),s(50,"span",39),c(51,"Karta"),a(),s(52,"span",40),c(53,"Voucher"),a(),s(54,"span",41),c(55,"Kliknij dzien na wykresie, aby otworzyc szczegoly."),a()(),v(56,Yt,48,29,"div",42)(57,Jt,2,0,"div",43)(58,rn,6,3,"div",44)(59,sn,7,2,"section",45),a(),v(60,mn,20,8,"section",46),a()}if(r&2){let t=p();l(8),W("active",t.isReportModalOpen),l(9),W("active",t.isExpenseModalOpen),u("disabled",!t.canUseExpenseAction),l(18),j("ngModel",t.selectedMonthKey),l(),u("ngForOf",t.monthOptions),l(),u("ngIf",t.isAdmin),l(),u("ngIf",t.isAdmin),l(5),E(t.selectedWeekLabel),l(6),u("ngIf",t.canUseNoRecord),l(7),u("ngIf",t.isAdmin),l(),u("ngIf",t.isMonthlyLoading),l(),u("ngIf",!t.isMonthlyLoading),l(),u("ngIf",t.isAdmin&&t.employeeMonthSummaries.length),l(),u("ngIf",t.canShowHourlySettlementSheet)}}function hn(r,e){r&1&&(s(0,"div",54),c(1,"Ladowanie szczegolow..."),a())}function gn(r,e){r&1&&(s(0,"div",54),c(1," Brak raportu dla wybranego dnia. "),a())}function yn(r,e){if(r&1&&(s(0,"small"),c(1),a()),r&2){let t=p().$implicit;l(),E(t.status)}}function _n(r,e){if(r&1){let t=z();s(0,"article",96),P("dragstart",function(i){let o=b(t).$implicit,d=p(4);return S(d.startTerminalPaymentDrag(i,o))}),s(1,"span",97),c(2,"\u{1F4B3}"),a(),s(3,"strong"),c(4),T(5,"number"),a(),s(6,"small"),c(7),a(),v(8,yn,2,1,"small",32),a()}if(r&2){let t=e.$implicit,n=p(4);l(4),Se("",I(5,5,t.amount,"1.2-2")," ",t.currency||"PLN"),l(3),Se("",n.terminalPaymentTime(t)," \xB7 ",t.maskedCardNumber||t.brand||"karta"),l(),u("ngIf",t.status)}}function fn(r,e){if(r&1&&(s(0,"div",94),v(1,_n,9,8,"article",95),a()),r&2){let t=p(3);l(),u("ngForOf",t.unmatchedTerminalPayments())("ngForTrackBy",t.trackByTerminalPayment)}}function xn(r,e){if(r&1&&(s(0,"span",98),c(1),a()),r&2){let t=p(3);l(),w(" ",t.selectedDayTerminalPayments.length?"Wszystkie transakcje z tego dnia s\u0105 dopasowane.":"Brak transakcji terminalowych dla tego dnia."," ")}}function Cn(r,e){if(r&1&&(s(0,"section",92)(1,"div")(2,"strong"),c(3,"Niedopasowane p\u0142atno\u015Bci kart\u0105"),a(),s(4,"span"),c(5,"Przeci\u0105gnij transakcj\u0119 na \u015Brodkowe pole przy w\u0142a\u015Bciwej wizycie."),a()(),v(6,fn,2,2,"div",93)(7,xn,2,1,"ng-template",null,1,he),a()),r&2){let t=me(8),n=p(2);l(6),u("ngIf",n.unmatchedTerminalPayments().length)("ngIfElse",t)}}function vn(r,e){if(r&1&&(xe(0),c(1),Ce()),r&2){let t=p(3).$implicit;l(),w(" \xB7 ",t.settlementApprovedByLabel)}}function bn(r,e){if(r&1&&(s(0,"span"),c(1),v(2,vn,2,1,"ng-container",32),a()),r&2){let t=p(2).$implicit;l(),w(" ",t.settlementApprovedAtLabel),l(),u("ngIf",t.settlementApprovedByLabel)}}function Sn(r,e){if(r&1&&(s(0,"div",110)(1,"strong"),c(2),a(),s(3,"span"),c(4),a(),v(5,bn,3,2,"span",32),a()),r&2){let t=p().$implicit,n=p(2);W("is-pending",t.settlementApprovalStatus==="pending")("is-approved",t.settlementApprovalStatus==="approved"),l(2),E(n.settlementApprovalLabel(t)),l(2),w("",t.booksyProposalCount," propozycje Booksy"),l(
1),u("ngIf",t.settlementApprovalStatus==="approved"&&t.settlementApprovedAtLabel)}}function wn(r,e){if(r&1){let t=z();s(0,"button",79),P("click",function(){b(t);let i=p().$implicit,o=p(2);return S(o.approveSettlementProposal(i))}),c(1),a()}if(r&2){let t=p().$implicit,n=p(2);u("disabled",n.settlementApprovalBusyById[t.id]),l(),w(" ",n.settlementApprovalBusyById[t.id]?"Akceptowanie...":"Akceptuj rozliczenie"," ")}}function Mn(r,e){if(r&1){let t=z();s(0,"button",35),P("click",function(){b(t);let i=p().$implicit,o=p(2);return S(o.openDetailedReportForEdit(i))}),c(1," Edytuj raport "),a()}}function Pn(r,e){if(r&1&&(s(0,"article",53)(1,"span"),c(2,"Nieewidencjonowana"),a(),s(3,"strong"),c(4),T(5,"number"),a()()),r&2){let t=p().$implicit;l(4),w("",I(5,1,t.unrecordedAmount,"1.2-2")," zl")}}function kn(r,e){if(r&1&&(s(0,"div",119)(1,"span"),c(2),a(),re(3,"i"),a()),r&2){let t=e.$implicit;ue("top",t.topPx,"px"),l(2),E(t.label)}}function En(r,e){if(r&1&&(s(0,"span",125),c(1),a()),r&2){let t=p().ngIf,n=p(6);l(),E(n.paymentMethodIcon(t.paymentMethod))}}function Rn(r,e){if(r&1&&(s(0,"span"),c(1),T(2,"number"),a()),r&2){let t=p().ngIf;l(),w("",I(2,1,t.hours,"1.2-2")," godz.")}}function Dn(r,e){if(r&1&&(s(0,"article",121)(1,"div",122)(2,"strong"),c(3),a(),v(4,En,2,1,"span",123),a(),s(5,"div",124)(6,"span"),c(7),a(),s(8,"span"),c(9),a(),s(10,"strong"),c(11),a(),v(12,Rn,3,4,"span",32),a()()),r&2){let t=e.ngIf,n=p().$implicit,i=p(5);ue("top",n.topPx,"px")("height",n.heightPx,"px"),l(3),E(i.formatBooksyTime(t.startAt)),l(),u("ngIf",!t.isTimeReservation),l(3),E(t.clientName||"Brak klienta"),l(2),E(t.serviceName||"Brak uslugi"),l(2),E(t.isTimeReservation?"bez przychodu":i.displayAmount(t.amount)),l(),u("ngIf",t.hours!==null)}}function On(r,e){if(r&1&&(s(0,"article",126)(1,"strong"),c(2,"Brak w Booksy"),a(),s(3,"span"),c(4,"Pozycja dodana recznie."),a()()),r&2){let t=p().$implicit;ue("top",t.topPx,"px")("height",t.heightPx,"px")}}function zn(r,e){if(r&1&&(xe(0),v(1,Dn,13,10,"article",120)(2,On,5,4,"ng-template",null,3,he),Ce()),r&2){let t=e.$implicit,n=me(3);l(),u("ngIf",t.proposal)("ngIfElse",n)}}function An(r,e){if(r&1){let t=z();s(0,"button",130),P("click",function(){let i=b(t).$implicit,o=p(7);return S(o.unmatchTerminalPayment(i))}),s(1,"strong"),c(2),T(3,"number"),a(),s(4,"span"),c(5),a(),s(6,"small"),c(7,"roz\u0142\u0105cz"),a()()}if(r&2){let t=e.$implicit,n=p(7);u("disabled",n.terminalPaymentMatchBusyById[t.id]),l(2),Se("",I(3,4,t.amount,"1.2-2")," ",t.currency||"PLN"),l(3),E(n.terminalPaymentTime(t))}}function Nn(r,e){r&1&&(s(0,"span",131),c(1,"\xB7\xB7\xB7\xB7 upu\u015B\u0107 tutaj \xB7\xB7\xB7\xB7"),a())}function Tn(r,e){if(r&1&&(xe(0),v(1,An,8,7,"button",128)(2,Nn,2,0,"span",129),Ce()),r&2){let t=e.ngIf,n=p(6);l(),u("ngForOf",t)("ngForTrackBy",n.trackByTerminalPayment),l(),u("ngIf",!t.length)}}function In(r,e){if(r&1){let t=z();s(0,"div",127),P("dragover",function(i){b(t);let o=p(5);return S(o.allowTerminalPaymentDrop(i))})("drop",function(i){let o=b(t).$implicit,d=p(3).$implicit,m=p(2);return S(m.matchTerminalPayment(i,d,o))}),v(1,Tn,3,3,"ng-container",32),a()}if(r&2){let t=e.$implicit,n=p(3).$implicit,i=p(2);ue("top",t.topPx,"px")("height",t.heightPx,"px"),l(),u("ngIf",i.matchedTerminalPayments(n,t))}}function Bn(r,e){if(r&1&&(s(0,"span",125),c(1),a()),r&2){let t=p().ngIf,n=p().$implicit,i=p(5);W("is-different",i.isCalendarValueDifferent(t,n.proposal,"paymentMethod")),l(),E(i.paymentMethodIcon(t.paymentMethod))}}function Fn(r,e){if(r&1&&(xe(0),s(1,"div",122)(2,"strong"),c(3),a(),v(4,Bn,2,3,"span",134),a(),s(5,"div",124)(6,"span"),c(7),a(),s(8,"span"),c(9),a(),s(10,"strong"),c(11),a(),s(12,"span"),c(13),T(14,"number"),a()(),Ce()),r&2){let t=e.ngIf,n=p().$implicit,i=p(5);l(3),E(n.proposal?i.formatBooksyTime(n.proposal.startAt):"Dodana recznie"),l(),u("ngIf",!t.isTimeReservation),l(2),W("is-different",i.isCalendarValueDifferent(t,n.proposal,"clientName")),l(),E(t.clientName||"Brak klienta"),l(),W("is-different",i.isCalendarValueDifferent(t,n.proposal,"serviceName")),l(),E(t.serviceName||"Brak uslugi"),l(),W("is-different",i.isCalendarValueDifferent(t,n.proposal,"amount")),l(),E(t.isTimeReservation?"bez przychodu":i.displayAmount(t.amount)),l(),W("is-different",i.isCalendarValueDifferent(t,n.proposal,"hours")),l(),E(t.reportedHours!==null?I(14,14,t.reportedHours,"1.2-2")+" godz.":"Brak czasu")}}
1function Vn(r,e){r&1&&(s(0,"strong",135),c(1,"Usunieta przez pracownika"),a(),s(2,"span"),c(3,"Tej wizyty nie ma w zapisanym raporcie."),a())}function Ln(r,e){if(r&1&&(s(0,"article",132),v(1,Fn,15,17,"ng-container",133)(2,Vn,4,0,"ng-template",null,4,he),a()),r&2){let t=e.$implicit,n=me(3);ue("top",t.topPx,"px")("height",t.heightPx,"px"),W("is-added",t.kind==="added")("is-removed",t.kind==="removed"),l(),u("ngIf",t.client)("ngIfElse",n)}}function Un(r,e){if(r&1&&(xe(0),s(1,"div",112)(2,"strong"),c(3,"Kalendarz Booksy"),a(),s(4,"strong"),c(5,"Compare \xB7 p\u0142atno\u015B\u0107 kart\u0105"),a(),s(6,"strong"),c(7,"Kalendarz po zmianach pracownika"),a()(),s(8,"div",113),v(9,kn,4,3,"div",114),s(10,"div",115),v(11,zn,4,2,"ng-container",116),a(),s(12,"div",115),v(13,In,2,5,"div",117),a(),s(14,"div",115),v(15,Ln,4,10,"article",118),a()(),Ce()),r&2){let t=e.ngIf,n=p(4);l(8),ue("height",t.heightPx,"px"),l(),u("ngForOf",t.hours),l(2),u("ngForOf",t.rows)("ngForTrackBy",n.trackByCalendarComparisonRow),l(2),u("ngForOf",t.rows)("ngForTrackBy",n.trackByCalendarComparisonRow),l(2),u("ngForOf",t.rows)("ngForTrackBy",n.trackByCalendarComparisonRow)}}function Kn(r,e){if(r&1&&(s(0,"section",111)(1,"div",28)(2,"div")(3,"h3"),c(4,"Porownanie kalendarza"),a(),s(5,"div",54),c(6," Po lewej dane z Booksy, po prawej raport zapisany przez pracownika. "),a()()(),v(7,Un,16,9,"ng-container",32),a()),r&2){let t=p().$implicit,n=p(2);l(7),u("ngIf",n.calendarTimeline(t))}}function $n(r,e){if(r&1&&(s(0,"span"),c(1),a()),r&2){let t=p().$implicit;l(),w("Kod vouchera: ",t.voucherCode||"brak")}}function Wn(r,e){if(r&1&&(s(0,"article",138)(1,"div",139)(2,"strong"),c(3),a(),s(4,"span"),c(5),a()(),s(6,"div",140)(7,"span"),c(8),a(),s(9,"span"),c(10),a(),s(11,"span"),c(12),a(),s(13,"span"),c(14),a(),s(15,"span"),c(16),T(17,"number"),a(),s(18,"span"),c(19),a(),s(20,"span"),c(21),a(),s(22,"span"),c(23),a(),v(24,$n,2,1,"span",32),a()()),r&2){let t=e.$implicit,n=e.index,i=p(4);l(3),E(t.clientName||"Klient "+(n+1)),l(2),E(i.paymentMethodLabel(t.paymentMethod)),l(3),w("Imie i nazwisko: ",t.clientName||"brak"),l(2),w("Telefon: ",t.clientPhone?i.displayPhone(t.clientPhone):"brak"),l(2),w("Rodzaj uslugi: ",t.serviceName||"brak"),l(2),w("Kwota: ",i.displayAmount(t.amount)),l(2),w("Godziny: ",t.reportedHours!==null?I(17,11,t.reportedHours,"1.2-2"):"brak"),l(3),w("Brak ewidencji: ",t.noRecord?"Tak":"Nie"),l(2),w("Znizka: ",t.hasDiscount?i.displayAmount(t.discountAmount):"Nie"),l(2),w("Voucher: ",t.usedVoucher?i.displayAmount(t.voucherAmount):"Nie"),l(),u("ngIf",t.usedVoucher)}}function jn(r,e){if(r&1&&(s(0,"div",136),v(1,Wn,25,14,"article",137),a()),r&2){let t=p().$implicit,n=p(2);l(),u("ngForOf",t.clients)("ngForTrackBy",n.trackByReportClient)}}function Hn(r,e){r&1&&(s(0,"div",54),c(1,"Brak klientow w tym raporcie."),a())}function Zn(r,e){if(r&1&&(s(0,"div",143)(1,"strong"),c(2,"Zamowienie"),a(),s(3,"span"),c(4),T(5,"number"),a(),s(6,"span"),c(7),a()()),r&2){let t=p(2).$implicit,n=p(2);l(4),w("Kwota: ",I(5,2,t.ordersCost,"1.2-2")," zl"),l(3),w("Platnosc: ",n.paymentMethodLabel(t.ordersPaymentMethod))}}function Gn(r,e){if(r&1&&(s(0,"article",146)(1,"span"),c(2),a(),s(3,"span"),c(4),a(),s(5,"span"),c(6),a()()),r&2){let t=e.$implicit,n=e.index,i=p(5);l(2),E(t.label||"Wydatek "+(n+1)),l(2),E(i.displayAmount(t.cost)),l(2),E(i.paymentMethodLabel(t.paymentMethod))}}function Qn(r,e){if(r&1&&(s(0,"div",144),v(1,Gn,7,3,"article",145),a()),r&2){let t=p(2).$implicit;l(),u("ngForOf",t.expenses)}}function qn(r,e){if(r&1&&(s(0,"section",107)(1,"div",28)(2,"h3"),c(3,"Wydatki"),a()(),v(4,Zn,8,5,"div",141)(5,Qn,2,1,"div",142),a()),r&2){let t=p().$implicit,n=p(2);l(4),u("ngIf",t.hadOrders),l(),u("ngIf",n.hasReportExpenses(t))}}function Yn(r,e){if(r&1&&(s(0,"section",99)(1,"div",28)(2,"div")(3,"h3"),c(4),a(),s(5,"div",54),c(6),a()(),s(7,"div",100),v(8,Sn,6,7,"div",101)(9,wn,2,2,"button",102)(10,Mn,2,0,"button",103),a()(),s(11,"div",104)(12,"article",53)(13,"span"),c(14,"Kwota klientow"),a(),s(15,"strong"),c(16),T(17,"number"),a()(),s(18,"article",53)(19,"span"),c(20,"Gotowka"),a(),s(21,"strong"),c(22),T(23,"number"),a()(),s(24,"article",53)(25,"span"),c(26,"Karta"),a(),s(27,"strong"),c(28),T(29,"number"),a()(),v(30,Pn,6,4,"article",105),s(31,"article",53)(32,"span"),c(33,"Znizki"),a(),s(34,"strong"),c(35),T(36,"number"),a()(),s(37,"article",53)(38,"span"),c(39,"Vouchery"),a(),s(40,"strong"),c(41),T(42,"number"),a()()(),v(43,Kn,8,1,"section",106),s(44,"section",107)(45,"div",28)(46,"h3"),c(47,"Klienci"),a()(),v(48,jn,2,2,"div",108)(49,Hn,2,0,"ng-template",null,2,he),a(),v(51,qn,6,2,"section",109),a()),r&2){let t=e.$implicit,n=me
1(50),i=p(2);l(4),E(t.reporterDisplayName||t.reporterEmail),l(2),Se(" Utworzono: ",t.createdAtLabel," | Aktualizacja: ",t.updatedAtLabel," "),l(2),u("ngIf",i.isAdmin&&t.booksyProposalCount),l(),u("ngIf",i.isAdmin&&t.settlementApprovalStatus==="pending"),l(),u("ngIf",i.canEditDetailedReport(t)),l(6),w("",I(17,16,t.totals.clientAmount,"1.2-2")," zl"),l(6),w("",I(23,19,t.cashAmount,"1.2-2")," zl"),l(6),w("",I(29,22,t.cardAmount,"1.2-2")," zl"),l(2),u("ngIf",i.canUseNoRecord||i.isAdmin),l(5),w("",I(36,25,t.totals.discountAmount,"1.2-2")," zl"),l(6),w("",I(42,28,t.totals.voucherAmount,"1.2-2")," zl"),l(2),u("ngIf",i.isAdmin&&t.booksyProposalCount),l(5),u("ngIf",i.hasReportClients(t))("ngIfElse",n),l(3),u("ngIf",t.hadOrders||i.hasReportExpenses(t))}}function Jn(r,e){if(r&1){let t=z();s(0,"div",87)(1,"section",88)(2,"div",28)(3,"div")(4,"h2"),c(5,"Szczegoly raportu"),a(),s(6,"div",54),c(7),a()(),s(8,"button",89),P("click",function(){b(t);let i=p();return S(i.closeDayDetailsModal())}),c(9," Wr\xF3\u0107 do raport\xF3w "),a()(),v(10,hn,2,0,"div",43)(11,gn,2,0,"div",43)(12,Cn,9,2,"section",90)(13,Yn,52,31,"section",91),a()()}if(r&2){let t=p();l(7),E(t.selectedDayDetailsDateKey),l(),u("disabled",t.isDayDetailsLoading),l(2),u("ngIf",t.isDayDetailsLoading),l(),u("ngIf",!t.isDayDetailsLoading&&!t.selectedDayDetails.length),l(),u("ngIf",t.isAdmin&&!t.isDayDetailsLoading),l(),u("ngForOf",t.selectedDayDetails)("ngForTrackBy",t.trackByDetailedReport)}}function Xn(r,e){r&1&&(s(0,"div",54),c(1," Nowe pozycje zostana dolaczone do istniejacego raportu. "),a())}function ei(r,e){if(r&1&&(s(0,"option",47),c(1),a()),r&2){let t=e.$implicit,n=p(3);u("value",t.uid),l(),w(" ",n.reporterOptionLabel(t)," ")}}function ti(r,e){if(r&1){let t=z();s(0,"label",150)(1,"span"),c(2,"Pracownik"),a(),s(3,"select",160),Z("ngModelChange",function(i){b(t);let o=p(2);return H(o.selectedReporterUid,i)||(o.selectedReporterUid=i),S(i)}),P("ngModelChange",function(i){b(t);let o=p(2);return S(o.onReporterChange(i))}),s(4,"option",49),c(5,"Wybierz pracownika"),a(),v(6,ei,2,2,"option",31),a()()}if(r&2){let t=p(2);l(3),j("ngModel",t.selectedReporterUid),l(3),u("ngForOf",t.reporterOptions)}}function ni(r,e){if(r&1&&(s(0,"div",54),c(1," Raport dla: "),s(2,"strong"),c(3),a()()),r&2){let t=p(2);l(3),E(t.activeReporterLabel)}}function ii(r,e){if(r&1&&(s(0,"section",161)(1,"div",53)(2,"span"),c(3,"Kwota klientow"),a(),s(4,"strong"),c(5),a()(),s(6,"div",53)(7,"span"),c(8,"Suma znizek"),a(),s(9,"strong"),c(10),a()(),s(11,"div",53)(12,"span"),c(13,"Suma voucherow"),a(),s(14,"strong"),c(15),a()(),s(16,"div",53)(17,"span"),c(18,"Kwota ewidencjonowana"),a(),s(19,"strong"),c(20),a()(),s(21,"div",53)(22,"span"),c(23,"Kwota nieewidencjonowana"),a(),s(24,"strong"),c(25),a()()()),r&2){let t=p(2);l(5),w("",t.totalClientAmount," zl"),l(5),w("",t.totalDiscountAmount," zl"),l(5),w("",t.totalVoucherAmount," zl"),l(5),w("",t.recordedTotalAmount," zl"),l(5),w("",t.unrecordedTotalAmount," zl")}}function oi(r,e){if(r&1&&(s(0,"div",54),c(1),a()),r&2){let t=p(2);l(),E(t.booksyPrefillInfo)}}function ri(r,e){r&1&&(s(0,"span",178),c(1,"czas pracy, bez przychodu"),a())}function ai(r,e){if(r&1){let t=z();s(0,"button",179),P("click",function(){b(t);let i=p().index,o=p(2);return S(o.removeClient(i))}),c(1," Usun "),a()}}function si(r,e){if(r&1){let t=z();s(0,"label",180)(1,"input",181),Z("ngModelChange",function(i){b(t);let o=p().$implicit;return H(o.anonymous,i)||(o.anonymous=i),S(i)}),P("ngModelChange",function(){b(t);let i=p().$implicit,o=p(2);return S(o.onAnonymousChange(i))}),a(),s(2,"span"),c(3,"Brak danych klienta"),a()()}
1if(r&2){let t=p(),n=t.$implicit,i=t.index;l(),j("ngModel",n.anonymous),u("name","anonymous"+i)}}function li(r,e){if(r&1){let t=z();s(0,"button",188),P("click",function(){b(t);let i=p(2).$implicit,o=p(2);return S(o.clearSelectedCustomer(i))}),c(1," Zmien "),a()}}function ci(r,e){if(r&1){let t=z();s(0,"button",193),P("mousedown",function(i){let o=b(t).$implicit,d=p(3).$implicit,m=p(2);return S(m.selectCustomerSuggestion(d,o,i))}),s(1,"span",194),c(2),a(),s(3,"span",195),c(4),a()()}if(r&2){let t=e.$implicit,n=p(5);l(2),E(t.fullName),l(2),E(n.displayPhone(t.phone))}}function di(r,e){r&1&&(s(0,"div",196),c(1," Brak dopasowanego klienta w bazie. "),a())}function pi(r,e){if(r&1){let t=z();s(0,"button",197),P("mousedown",function(i){b(t);let o=p(5);return i.preventDefault(),S(o.openCustomerBase())}),c(1," Otworz baze klientow i dodaj nowy rekord "),a()}}function mi(r,e){if(r&1&&(s(0,"div",189),v(1,ci,5,2,"button",190)(2,di,2,0,"div",191)(3,pi,2,0,"button",192),a()),r&2){let t=p(2).$implicit,n=p(2);l(),u("ngForOf",t.customerSuggestions),l(),u("ngIf",!t.customerSuggestions.length),l(),u("ngIf",n.shouldOfferCustomerCreate(t))}}function ui(r,e){if(r&1){let t=z();xe(0),s(1,"label",182)(2,"span"),c(3,"Klient"),a(),s(4,"div",183)(5,"div",184)(6,"input",185),Z("ngModelChange",function(i){b(t);let o=p().$implicit;return H(o.customerQuery,i)||(o.customerQuery=i),S(i)}),P("focus",function(){b(t);let i=p().$implicit,o=p(2);return S(o.onCustomerQueryFocus(i))})("click",function(){b(t);let i=p().$implicit,o=p(2);return S(o.onCustomerQueryFocus(i))})("input",function(){b(t);let i=p().$implicit,o=p(2);return S(o.onCustomerQueryInput(i))})("blur",function(){b(t);let i=p().$implicit,o=p(2);return S(o.onCustomerQueryBlur(i))}),a(),v(7,li,2,0,"button",186),a(),v(8,mi,4,3,"div",187),a()(),Ce()}
1if(r&2){let t=p(),n=t.$implicit,i=t.index,o=p(2);l(6),j("ngModel",n.customerQuery),u("name","customerQuery"+i),l(),u("ngIf",n.customerId),l(),u("ngIf",o.shouldShowCustomerSuggestions(n))}}function hi(r,e){r&1&&(s(0,"small"),c(1,"Ostatnio wybierane"),a())}function gi(r,e){if(r&1&&(s(0,"span"),c(1),a()),r&2){let t=p().$implicit;l(),w("\u2022 ",t.price," zl")}}function yi(r,e){if(r&1){let t=z();s(0,"button",201),P("mousedown",function(i){let o=b(t).$implicit,d=p(2).$implicit,m=p(2);return S(m.selectServiceSuggestion(d,o,i))}),s(1,"span",202),c(2),v(3,hi,2,0,"small",32),a(),s(4,"span",203),c(5),v(6,gi,2,1,"span",32),a()()}if(r&2){let t=e.$implicit;l(2),w(" ",t.name," "),l(),u("ngIf",t.isRecent),l(2),w(" ",t.category||"Bez kategorii"," "),l(),u("ngIf",t.price)}}function _i(r,e){r&1&&(s(0,"span"),c(1," Brak ostatnio wybieranych uslug. Wpisz minimum 2 znaki, aby szukac w katalogu. "),a())}function fi(r,e){r&1&&(s(0,"span"),c(1," Brak wynikow dla wpisanej frazy. "),a())}function xi(r,e){if(r&1&&(s(0,"div",204),v(1,_i,2,0,"span",32)(2,fi,2,0,"span",32),a()),r&2){let t=p(2).$implicit;l(),u("ngIf",t.serviceName.trim().length<2),l(),u("ngIf",t.serviceName.trim().length>=2)}}function Ci(r,e){if(r&1&&(s(0,"div",198),v(1,yi,7,4,"button",199)(2,xi,3,2,"div",200),a()),r&2){let t=p().$implicit;l(),u("ngForOf",t.serviceSuggestions),l(),u("ngIf",!t.serviceSuggestions.length)}}function vi(r,e){r&1&&(s(0,"small",205),c(1," Wybierz poprawna usluge z cennika. "),a())}function bi(r,e){if(r&1&&(s(0,"div",206)(1,"strong"),c(2,"Wybrany klient"),a(),s(3,"span"),c(4),a()()),r&2){let t=p().$implicit,n=p(2);l(4),Se("",t.clientName," | ",n.displayPhone(t.clientPhone))}}function Si(r,e){if(r&1){let t=z();s(0,"label")(1,"span"),c(2,"Liczba godzin"),a(),s(3,"input",207),Z("ngModelChange",function(i){b(t);let o=p().$implicit;return H(o.hours,i)||(o.hours=i),S(i)}),a()()}
1if(r&2){let t=p(),n=t.$implicit,i=t.index;l(3),j("ngModel",n.hours),u("name","hours"+i)}}function wi(r,e){if(r&1){let t=z();s(0,"label",224)(1,"input",211),P("change",function(){b(t);let i=p(2).$implicit,o=p(2);return S(o.setPaymentOption(i,"cash-no-record"))}),a(),s(2,"span",212),pe(),s(3,"svg",15),re(4,"rect",213)(5,"path",225)(6,"path",226),a()(),fe(),s(7,"span",217)(8,"span",218),c(9,"Gotowka"),a(),s(10,"span",227),c(11,"Brak ewid."),a()()()}if(r&2){let t=p(2),n=t.$implicit,i=t.index,o=p(2);W("is-active",o.paymentOptionValue(n)==="cash-no-record"),l(),u("name","payment"+i)("checked",o.paymentOptionValue(n)==="cash-no-record")}}function Mi(r,e){if(r&1){let t=z();s(0,"div",208)(1,"span"),c(2,"Forma platnosci"),a(),s(3,"div",209)(4,"label",210)(5,"input",211),P("change",function(){b(t);let i=p().$implicit,o=p(2);return S(o.setPaymentOption(i,"cash"))}),a(),s(6,"span",212),pe(),s(7,"svg",15),re(8,"rect",213)(9,"circle",214)(10,"path",215)(11,"path",216),a()(),fe(),s(12,"span",217)(13,"span",218),c(14,"Gotowka"),a()()(),v(15,wi,12,4,"label",219),s(16,"label",210)(17,"input",211),P("change",function(){b(t);let i=p().$implicit,o=p(2);return S(o.setPaymentOption(i,"card"))}),a(),s(18,"span",212),pe(),s(19,"svg",15),re(20,"rect",220)(21,"path",221),a()(),fe(),s(22,"span",217)(23,"span",218),c(24,"Karta"),a()()(),s(25,"label",210)(26,"input",211),P("change",function(){b(t);let i=p().$implicit,o=p(2);return S(o.setPaymentOption(i,"voucher"))}),a(),s(27,"span",212),pe(),s(28,"svg",15),re(29,"path",222)(30,"path",223),a()(),fe(),s(31,"span",217)(32,"span",218),c(33,"Voucher"),a()()()()()}
1if(r&2){let t=p(),n=t.$implicit,i=t.index,o=p(2);l(3),W("has-no-record",o.canUseNoRecord),l(),W("is-active",o.paymentOptionValue(n)==="cash"),l(),u("name","payment"+i)("checked",o.paymentOptionValue(n)==="cash"),l(10),u("ngIf",o.canUseNoRecord),l(),W("is-active",o.paymentOptionValue(n)==="card"),l(),u("name","payment"+i)("checked",o.paymentOptionValue(n)==="card"),l(8),W("is-active",o.paymentOptionValue(n)==="voucher"),l(),u("name","payment"+i)("checked",o.paymentOptionValue(n)==="voucher")}}function Pi(r,e){if(r&1&&(s(0,"small",230),c(1),a()),r&2){let t=p(2).$implicit,n=p(2);W("is-found",t.voucherLookupState==="found")("is-missing",t.voucherLookupState==="missing"),l(),w(" ",n.voucherLookupStatusLabel(t)," ")}}function ki(r,e){if(r&1){let t=z();s(0,"label")(1,"span"),c(2,"Numer vouchera (opcjonalnie)"),a(),s(3,"input",228),Z("ngModelChange",function(i){b(t);let o=p().$implicit;return H(o.voucherCode,i)||(o.voucherCode=i),S(i)}),P("input",function(){b(t);let i=p().$implicit,o=p(2);return S(o.onVoucherCodeInput(i))})("blur",function(){b(t);let i=p().$implicit,o=p(2);return S(o.onVoucherCodeBlur(i))}),a(),v(4,Pi,2,5,"small",229),a()}
1if(r&2){let t=p(),n=t.$implicit,i=t.index,o=p(2);l(3),j("ngModel",n.voucherCode),u("name","voucherCode"+i),l(),u("ngIf",o.voucherLookupStatusLabel(n))}}function Ei(r,e){if(r&1){let t=z();s(0,"label")(1,"span"),c(2,"Odejmij srodki z vouchera (zl)"),a(),s(3,"input",175),Z("ngModelChange",function(i){b(t);let o=p().$implicit;return H(o.voucherAmount,i)||(o.voucherAmount=i),S(i)}),a()()}if(r&2){let t=p(),n=t.$implicit,i=t.index;l(3),j("ngModel",n.voucherAmount),u("name","voucherAmount"+i)}}function Ri(r,e){if(r&1){let t=z();s(0,"article",162)(1,"div",163)(2,"h3"),c(3),v(4,ri,2,0,"span",164),a(),v(5,ai,2,0,"button",165),a(),s(6,"div",166),v(7,si,4,2,"label",167)(8,ui,9,4,"ng-container",32),s(9,"label",168)(10,"span"),c(11,"Rodzaj uslugi"),a(),s(12,"div",169)(13,"input",170),Z("ngModelChange",function(i){let o=b(t).$implicit;return H(o.serviceName,i)||(o.serviceName=i),S(i)}),P("focus",function(){let i=b(t).$implicit,o=p(2);return S(o.onServiceFieldFocus(i))})("click",function(){let i=b(t).$implicit,o=p(2);return S(o.onServiceFieldFocus(i))})("input",function(){let i=b(t).$implicit,o=p(2);return S(o.onServiceFieldInput(i))})("blur",function(){let i=b(t).$implicit,o=p(2);return S(o.onServiceFieldBlur(i))}),a(),v(14,Ci,3,2,"div",171)(15,vi,2,0,"small",172),a()(),v(16,bi,5,2,"div",173),s(17,"div",174)(18,"label")(19,"span"),c(20,"Kwota uslugi (zl)"),a(),s(21,"input",175),Z("ngModelChange",function(i){let o=b(t).$implicit;return H(o.amount,i)||(o.amount=i),S(i)}),a()(),v(22,Si,4,2,"label",32),a(),v(23,Mi,34,15,"div",176),a(),s(24,"div",177),v(25,ki,5,3,"label",32)(26,Ei,4,2,"label",32),a()()}if(r&2){let t=e.$implicit,n=e.index,i=p(2);l(3),w(" ",t.isTimeReservation?"Rezerwacja czasu Booksy":"Klient "+(n+1)," "),l(),u("ngIf",t.isTimeReservation),l(),u("ngIf",i.clients.length>1),l(2),u("ngIf",!t.isTimeReservation),l(),u("ngIf",!t.anonymous&&!t.isTimeReservation),l(5),j("ngModel",t.serviceName),u("name","serviceName"+n),l(),u("ngIf",t.isServiceSuggestionsOpen),l(),u("ngIf",!i.isAdmin&&t.serviceName.trim()&&!t.serviceSelectedFromCatalog),l(),u("ngIf",t.customerId),l(5),j("ngModel",t.amount),u("name","amount"+n),l(),u("ngIf",i.usesHourlySettlement),l(),u("ngIf",!t.isTimeReservation),l(2),u("ngIf",i.shouldShowVoucherFields(t)),l(),u("ngIf",i.shouldShowVoucherAmountField(t))}}function Di(r,e){if(r&1&&(s(0,"div",231),c(1),a()),r&2){let t=p(2);l(),E(t.error)}}function Oi(r,e){if(r&1&&(s(0,"div",232),c(1),a()),r&2){let t=p(2);l(),E(t.info)}}function zi(r,e){if(r&1){let t=z();s(0,"div",147),P("click",function(){b(t);let i=p();return S(i.closeReportModal())}),s(1,"section",148),P("click",function(i){return b(t),S(i.stopPropagation())}),s(2,"div",28)(3,"div")(4,"h2"),c(5,"Sporzadz raport dzienny"),a(),v(6,Xn,2,0,"div",43),a(),s(7,"button",89),P("click",function(){b(t);let i=p();return S(i.closeReportModal())}),c(8," Zamknij "),a()(),s(9,"section",149)(10,"label",150)(11,"span"),c(12,"Data raportu"),a(),s(13,"input",151),Z("ngModelChange",function(i){b(t);let o=p();return H(o.reportDate,i)||(o.reportDate=i),S(i)}),P("change",function(){b(t);let i=p();return S(i.onReportModalDateChange())}),a()(),v(14,ti,7,2,"label",152)(15,ni,4,1,"div",43),s(16,"div",54),c(17," Domyslnie otwierany jest raport na dzis. Mozesz zmienic date, aby uzupelnic zalegly wpis. "),a()(),v(18,ii,26,5,"section",153),s(19,"section",154)(20,"div",28)(21,"h2"),c(22,"Klienci"),a(),s(23,"button",35),P("click",function(){b(t);let i=p();return S(i.addClient())}),c(24,"Dodaj klienta"),a()(),v(25,oi,2,1,"div",43),s(26,"div",155),v(27,Ri,27,16,"article",156),a()(),s(28,"div",157)(29,"button",79),P("click",function(){b(t);let i=p();return S(i.saveDailyReport())}),c(30),a(),s(31,"button",89),P("click",function(){b(t);let i=p();return S(i.clearReportFormData())}),c(32," Wyczysc dane "),a(),s(33,"button",89),P("click",function(){b(t);let i=p();return S(i.closeReportModal())}),c(34," Anuluj "),a()(),v(35,Di,2,1,"div",158)(36,Oi,2,1,"div",159),a()()}if(r&2){let t=p();l(6),u("ngIf",t.isEditingExistingReport&&t.saveButtonLabel==="Dodaj do raportu dziennego"),l(),u("disabled",t.isSaving),l(6),j("ngModel",t.reportDate),l(),u("ngIf",t.isAdmin),l(),u("ngIf",t.isAdmin),l(3),u("ngIf",t.isAdmin),l(7),u("ngIf",t.booksyPrefillInfo),l(2),u("ngForOf",t.clients),l(2),u("disabled",t.isSaving||t.isLoading),l(
1),w(" ",t.saveButtonLabel," "),l(),u("disabled",t.isSaving),l(2),u("disabled",t.isSaving),l(2),u("ngIf",t.error),l(),u("ngIf",t.info)}}function Ai(r,e){if(r&1&&(s(0,"option",47),c(1),a()),r&2){let t=e.$implicit,n=p(3);u("value",t.uid),l(),w(" ",n.reporterOptionLabel(t)," ")}}function Ni(r,e){if(r&1){let t=z();s(0,"label",150)(1,"span"),c(2,"Pracownik"),a(),s(3,"select",237),Z("ngModelChange",function(i){b(t);let o=p(2);return H(o.selectedReporterUid,i)||(o.selectedReporterUid=i),S(i)}),P("ngModelChange",function(i){b(t);let o=p(2);return S(o.onReporterChange(i))}),s(4,"option",49),c(5,"Wybierz pracownika"),a(),v(6,Ai,2,2,"option",31),a()()}if(r&2){let t=p(2);l(3),j("ngModel",t.selectedReporterUid),l(3),u("ngForOf",t.reporterOptions)}}function Ti(r,e){if(r&1&&(s(0,"div",54),c(1," Wydatek dla: "),s(2,"strong"),c(3),a()()),r&2){let t=p(2);l(3),E(t.activeReporterLabel)}}function Ii(r,e){r&1&&(s(0,"span"),c(1,"..."),a())}function Bi(r,e){r&1&&(pe(),s(0,"svg",259),re(1,"path",260)(2,"path",261)(3,"path",262)(4,"path",263)(5,"path",264),a())}function Fi(r,e){if(r&1){let t=z();s(0,"div",253)(1,"div",254)(2,"a",255),c(3),a(),s(4,"span",256),c(5),a()(),s(6,"button",257),P("click",function(){let i=b(t).$implicit,o=p(5);return S(o.deleteExpenseAttachment(i))}),v(7,Ii,2,0,"span",32)(8,Bi,6,0,"svg",258),a()()}if(r&2){let t=e.$implicit,n=p(5);l(2),u("href",t.url,Xe),l(),w(" ",t.name||t.fileName," "),l(2),E(t.createdAtLabel),l(),u("title","Usun zalacznik "+(t.name||t.fileName))("disabled",n.expenseAttachmentDeleteBusyById[t.id]||n.isSaving),Ue("aria-label","Usun zalacznik "+(t.name||t.fileName)),l(),u("ngIf",n.expenseAttachmentDeleteBusyById[t.id]),l(),u("ngIf",!n.expenseAttachmentDeleteBusyById[t.id])}}function Vi(r,e){if(r&1&&(s(0,"div",251),v(1,Fi,9,8,"div",252),a()),r&2){let t=p().$implicit,n=p(3);l(),u("ngForOf",n.expenseAttachments(t.id))("ngForTrackBy",n.trackByExpenseAttachment)}}function Li(r,e){r&1&&(s(0,"div",265),c(1,"Brak zalacznikow."),a())}function Ui(r,e){if(r&1&&(s(0,"div",54),c(1),a()),r&2){let t=p(2).$implicit,n=p(3);l(),w(" Wybrano: ",n.selectedExpenseAttachmentName(t.id),". Plik zostanie wyslany po zapisaniu wydatkow. ")}}function Ki(r,e){r&1&&(s(0,"div",54),c(1," Firebase Storage jest niedostepny, wiec nie da sie teraz dodac zalacznika. "),a())}function $i(r,e){if(r&1){let t=z();s(0,"div",266)(1,"input",267),P("change",function(i){b(t);let o=p().$implicit,d=p(3);return S(d.onExpenseAttachmentSelected(i,o.id))}),a(),v(2,Ui,2,1,"div",43)(3,Ki,2,0,"div",43),a()}if(r&2){let t=p().$implicit,n=p(3);l(),u("disabled",n.isSaving||!n.storageReady),l(),u("ngIf",n.selectedExpenseAttachmentName(t.id)),l(),u("ngIf",!n.storageReady)}}function Wi(r,e){if(r&1){let t=z();s(0,"div",240)(1,"label")(2,"span"),c(3,"Nazwa wydatku"),a(),s(4,"input",241),Z("ngModelChange",function(i){let o=b(t).$implicit;return H(o.label,i)||(o.label=i),S(i)}),a()(),s(5,"label")(6,"span"),c(7,"Kwota (zl)"),a(),s(8,"input",175),Z("ngModelChange",function(i){let o=b(t).$implicit;return H(o.cost,i)||(o.cost=i),S(i)}),a()(),s(9,"div",242)(10,"span"),c(11,"Platnosc"),a(),s(12,"div",243)(13,"label",244)(14,"input",245),Z("ngModelChange",function(i){let o=b(t).$implicit;return H(o.paymentMethod,i)||(o.paymentMethod=i),S(i)}),a(),s(15,"span"),c(16,"Gotowka"),a()(),s(17,"label",244)(18,"input",246),Z("ngModelChange",function(i){let o=b(t).$implicit;return H(o.paymentMethod,i)||(o.paymentMethod=i),S(i)}),a(),s(19,"span"),c(20,"Karta"),a()()()(),s(21,"button",247),P("click",function(){let i=b(t).index,o=p(3);return S(o.removeExpense(i))}),c(22,"Usun"),a(),s(23,"div",248),v(24,Vi,2,2,"div",249)(25,Li,2,0,"ng-template",null,6,he)(27,$i,4,3,"div",250),a()()}if(r&2){let t=e.$implicit,n=e.index,i=me(26),o=p(3);l(4),j("ngModel",t.label),u("name","expenseLabel"+n),l(4),j("ngModel",t.cost),u("name","expenseCost"+n),l(6),u("name","expensePaymentMethod"+n),j("ngModel",t.paymentMethod),l(4),u("name","expensePaymentMethod"+n),j("ngModel",t.paymentMethod),l(6),u("ngIf",o.expenseAttachments(t.id).length)("ngIfElse",i),l(3),u("ngIf",!o.expenseAttachments(t.id).length)}}function ji(r,e){if(r&1&&(s(0,"div",238),v(1,Wi,28,11,"div",239),a()),r&2){let t=p(2);l(),u("ngForOf",t.expenses)("ngForTrackBy",t.trackByExpense)}}
1function Hi(r,e){r&1&&(s(0,"div",54),c(1,"Brak dodatkowych wydatkow."),a())}function Zi(r,e){if(r&1&&(s(0,"div",231),c(1),a()),r&2){let t=p(2);l(),E(t.error)}}function Gi(r,e){if(r&1&&(s(0,"div",232),c(1),a()),r&2){let t=p(2);l(),E(t.info)}}function Qi(r,e){if(r&1){let t=z();s(0,"div",147),P("click",function(){b(t);let i=p();return S(i.closeExpenseModal())}),s(1,"section",233),P("click",function(i){return b(t),S(i.stopPropagation())}),s(2,"div",28)(3,"div")(4,"h2"),c(5,"Dodaj wydatek"),a()(),s(6,"button",89),P("click",function(){b(t);let i=p();return S(i.closeExpenseModal())}),c(7," Zamknij "),a()(),s(8,"section",149)(9,"label",150)(10,"span"),c(11,"Data wydatku"),a(),s(12,"input",234),Z("ngModelChange",function(i){b(t);let o=p();return H(o.reportDate,i)||(o.reportDate=i),S(i)}),P("change",function(){b(t);let i=p();return S(i.onExpenseModalDateChange())}),a()(),v(13,Ni,7,2,"label",152)(14,Ti,4,1,"div",43),s(15,"div",54),c(16," Domyslnie otwierany jest dzisiejszy dzien. Mozesz wybrac np. zeszly piatek i dopisac zalegly wydatek. "),a()(),s(17,"section",154)(18,"h2"),c(19,"Wydatki dzienne"),a(),s(20,"div",235)(21,"h3"),c(22,"Dodatkowe wydatki dzienne"),a(),s(23,"button",35),P("click",function(){b(t);let i=p();return S(i.addExpense())}),c(24,"Dodaj wydatek"),a()(),v(25,ji,2,2,"div",236)(26,Hi,2,0,"ng-template",null,5,he),a(),s(28,"div",157)(29,"button",79),P("click",function(){b(t);let i=p();return S(i.saveExpenseEntries())}),c(30),a(),s(31,"button",89),P("click",function(){b(t);let i=p();return S(i.closeExpenseModal())}),c(32," Anuluj "),a()(),v(33,Zi,2,1,"div",158)(34,Gi,2,1,"div",159),a()()}if(r&2){let t=me(27),n=p();l(6),u("disabled",n.isSaving),l(6),j("ngModel",n.reportDate),l(),u("ngIf",n.isAdmin),l(),u("ngIf",n.isAdmin),l(11),u("ngIf",n.expenses.length)("ngIfElse",t),l(4),u("disabled",n.isSaving||n.isLoading),l(),w(" ",n.isSaving?"Zapisywanie...":"Zapisz wydatki"," "),l(),u("disabled",n.isSaving),l(2),u("ngIf",n.error),l(),u("ngIf",n.info)}}var Lt="users",oe="dailyReports",Ut="calendarEvents",Kt="customers",Ge="voucherPrints",Ve="clinicFixedCosts",$t="employeeCosts",ze="expenseAttachments",Qe="monthlyWorkReportFiles",Ae="affiliateAmbassadors",qi="affiliatePublicCards",Wt="pointEntries",Yi=50,Ji=3,qe="daily_report_form_drafts_v1",jt=class r{c
1onstructor(e,t,n,i){this.route=e;this.router=t;this.zone=n;this.cdr=i}isLoading=!0;isSaving=!1;isCustomerSaving=!1;isActualAdmin=!1;isAdmin=!1;canUseNoRecord=!1;isEditingExistingReport=!1;isReportModalOpen=!1;isExpenseModalOpen=!1;isDayDetailsModalOpen=!1;isDayDetailsPage=!1;isMonthlyLoading=!1;isDayDetailsLoading=!1;isFixedCostsLoading=!1;isFixedCostsSaving=!1;isPdfGenerating=!1;isMonthlyWorkReportUploading=!1;storageReady=!0;error="";info="";booksyPrefillInfo="";activeTopAction="report";reportDate=this.formatDateKeyLocal(new Date);calendarViewMode="week";selectedWeekStartKey=this.startOfWeekKey(this.formatDateKeyLocal(new Date));selectedDayDetailsDateKey="";clients=[this.createEmptyClient()];booksyProposals=[];expenses=[];hadOrders=!1;ordersCost=null;ordersPaymentMethod="cash";monthOptions=this.buildMonthOptions(Ji);selectedMonthKey=this.currentMonthKey();selectedReporterUid="";reporterOptions=[];monthViewDays=[];weekViewDays=[];employeeMonthSummaries=[];monthlySummary=this.emptyMonthlySummary();selectedDayDetails=[];selectedDayTerminalPayments=[];terminalPaymentMatchBusyById={};monthlyWorkReportFiles=[];selectedMonthlyWorkReportFile=null;monthlyWorkReportDeleteBusyById={};hourlySettlementRows=[];hourlySettlementMissingDurationCount=0;hourlySettlementSignature="";isHourlySettlementPrinting=!1;expenseAttachmentsByExpenseId={};selectedExpenseAttachmentFiles={};expenseAttachmentDeleteBusyById={};settlementApprovalBusyById={};fixedCosts=[];fixedCostLabel="";fixedCostAmount=null;fixedCostBusyById={};employeeCostConfigs={};serviceCatalogSuggestions=[];recentServiceSuggestions=[];customers=[];currentUserEmail="";currentUserDisplayName="";currentUserUid="";currentEmploymentCostType="brak";reportModalMode="append";app=null;auth=null;db=null;storage=null;authUnsub;routeUnsub;reportDraftsByKey={};reportFormContextKey="";lastPersistedDraftSnapshot="";voucherLookupCache={};get totalClientAmount(){return this.clients.reduce((e,t)=>e+(t.amount??0),0)}get totalDiscountAmount(){return this.clients.reduce((e,t)=>t.hasDiscount?e+(t.discountAmount??0):e,0)}get totalVoucherAmount(){return this.clients.reduce((e,t)=>t.usedVoucher?e+(t.voucherAmount??0):e,0)}get recordedTotalAmount(){return this.clients.reduce((e,t)=>t.noRecord?e:e+Math.max(0,t.amount??0),0)}get unrecordedTotalAmount(){return this.clients.reduce((e,t)=>t.noRecord?e+Math.max(0,t.amount??0):e,0)}get totalHours(){return this.clients.reduce((e,t)=>e+Math.max(0,t.hours??0),0)}get activeReporterUid(){return this.isAdmin?this.selectedReporterUid||"":this.currentUserUid}get activeReporterOption(){return!this.isAdmin||!this.selectedReporterUid?null:this.reporterOptions.find(e=>e.uid===this.selectedReporterUid)??null}get activeReporterEmail(){return this.isAdmin?this.activeReporterOption?.email??"":this.currentUserEmail}get activeReporterDisplayName(){return this.isAdmin?this.activeReporterOption?.displayName??"":this.currentUserDisplayName}get activeReporterLabel(){return this.isAdmin?this.activeReporterOption?this.reporterOptionLabel(this.activeReporterOption):"Nie wybrano pracownika":ae(this.currentUserDisplayName,this.currentUserEmail,this.currentUserUid)}get activeEmploymentCostType(){if(!this.isAdmin)return this.currentEmploymentCostType;let e=this.activeReporterUid;return e?this.employeeCostConfigs[e]?.employmentCostType??"brak":"brak"}get usesHourlySettlement(){return Pt(this.activeEmploymentCostType)}get saveButtonLabel(){return this.isSaving?"Zapisywanie...":this.reportModalMode==="edit"?"Zapisz korekte raportu":this.isEditingExistingReport?"Dodaj do raportu dziennego":"Zapisz raport dzienny"}get canUseExpenseAction(){return!!this.currentUserUid}get canSendMonthlyWorkReport(){return!this.isAdmin&&this.currentEmploymentCostType==="zlecenie"}get canShowHourlySettlementSheet(){return this.activeEmploymentCostType==="zlecenie"||this.activeEmploymentCostType==="zlecenie45"||this.activeEmploymentCostType==="zlecenie50"||this.activeEmploymentCostType==="zlecenie50plus55"}get selectedMonthLabel(){return this.monthOptions.find(e=>e.key===this.selectedMonthKey)?.label??this.selectedMonthKey}get selectedSettlementReporterLabel(){if(!this.isAdmin)return ae(this.currentUserDisplayName,this.currentUserEmail,this.currentUserUid);let e=this.reporterOptions.find(t=>t.uid===this.selectedReporterUid);return e?this.reporterOptionLabel(e):"Nie wybrano pracownika"}reporterOptionLabel(e){return ae(e.displayName,e.email,e.uid)}get selectedWeekLabel(){let e=this.selectedWeekStartKey,t=this.addDaysToDateKey(e,6);return`${this.formatDisplayDate(e)} - ${this.formatDisplayDate(t)}`}get visibleChartDays(){return this.weekViewDays}get chartScaleMax(){let e=this.visibleChartDays.reduce((t,n)=>
1{let i=n.cash+n.unrecorded+n.card+n.voucher;return Math.max(t,i)},0);return this.roundChartScaleMax(e)}get chartScaleTicks(){let e=this.chartScaleMax;return[e,e*.75,e*.5,e*.25,0].map(t=>Math.round(t))}ngOnInit(){this.loadReportDraftsFromStorage();let e=this.normalizeDateParam(this.route.snapshot.paramMap.get("dateKey"));e&&(this.isDayDetailsPage=!0,this.isDayDetailsModalOpen=!0,this.selectedDayDetailsDateKey=e,this.reportDate=e,this.selectedWeekStartKey=this.startOfWeekKey(e),this.selectedMonthKey=e.slice(0,7));let t=this.normalizeDateParam(this.route.snapshot.queryParamMap.get("date"));if(t){this.reportDate=t,this.selectedWeekStartKey=this.startOfWeekKey(t);let i=t.slice(0,7);this.monthOptions.some(o=>o.key===i)&&(this.selectedMonthKey=i)}this.initFirebase(),this.watchAuth();let n=this.route.queryParamMap.subscribe(i=>{let o=this.normalizeDateParam(i.get("date"));o&&o!==this.reportDate&&(this.reportDate=o,this.selectedWeekStartKey=this.startOfWeekKey(o)),this.currentUserUid&&(this.loadReportForDate(),this.loadMonthView(),this.handleRouteAction(i.get("action")))});this.routeUnsub=()=>n.unsubscribe()}ngOnDestroy(){this.authUnsub?.(),this.routeUnsub?.(),this.clearVoucherLookupTimers(this.clients)}ngDoCheck(){if(!this.isReportModalOpen||!this.reportFormContextKey){this.lastPersistedDraftSnapshot="";return}let e=this.currentReportDraftSnapshot();e!==this.lastPersistedDraftSnapshot&&(this.lastPersistedDraftSnapshot=e,this.persistCurrentReportDraft())}setTopAction(e){if(e==="report"){this.openReportModalForNewEntries();return}e==="expense"&&!this.canUseExpenseAction||this.openExpenseModal()}setCalendarViewMode(e){this.calendarViewMode=e}onMonthChange(e){e&&(this.selectedMonthKey=e,this.isDateInMonth(this.selectedWeekStartKey,e)||(this.selectedWeekStartKey=this.startOfWeekKey(`${e}-01`))),this.loadMonthView(),this.loadMonthlyWorkReportFiles()}onReporterChange(e){this.isReportModalOpen&&this.persistCurrentReportDraft(),typeof e=="string"&&(this.selectedReporterUid=e),this.loadRecentServiceSuggestions(),this.loadMonthView(),this.isReportModalOpen&&this.loadReportForDate(),this.isExpenseModalOpen&&this.loadExpenseFormForDate()}async openMonthDay(e){await this.router.navigate(["/portal/raport-dzienny/szczegoly",e])}previousWeek(){this.selectedWeekStartKey=this.addDaysToDateKey(this.selectedWeekStartKey,-7);let e=this.selectedWeekStartKey.slice(0,7);this.monthOptions.some(t=>t.key===e)&&(this.selectedMonthKey=e),this.loadMonthView()}nextWeek(){this.selectedWeekStartKey=this.addDaysToDateKey(this.selectedWeekStartKey,7);let e=this.selectedWeekStartKey.slice(0,7);this.monthOptions.some(t=>t.key===e)&&(this.selectedMonthKey=e),this.loadMonthView()}canEditDetailedReport(e){return this.isAdmin||e.reporterUid===this.currentUserUid}async approveSettlementProposal(e){if(!(!this.db||!this.isAdmin||e.settlementApprovalStatus!=="pending")&&window.confirm(`Zaakceptowac rozliczenie ${e.reporterDisplayName||e.reporterEmail} z dnia ${e.dateKey}?`)){this.error="",this.info="",this.settlementApprovalBusyById[e.id]=!0;try{await J(N(this.db,oe,e.id),{settlementApprovalStatus:"approved",settlementApprovedAt:U(),settlementApprovedByUid:this.currentUserUid,settlementApprovedByEmail:this.currentUserEmail,updatedAt:U()},{merge:!0}),this.info="Rozliczenie zostalo zaakceptowane.",await Promise.all([this.loadDayDetails(e.dateKey),this.loadMonthView()])}catch(t){console.warn("Nie udalo sie zaakceptowac rozliczenia:",t),this.error="Nie udalo sie zaakceptowac rozliczenia."}finally{this.settlementApprovalBusyById[e.id]=!1}}}async openDetailedReportForEdit(e){this.canEditDetailedReport(e)&&(this.isAdmin&&(this.selectedReporterUid=e.reporterUid),this.reportDate=e.dateKey,await this.openReportModalForEdit())}closeDayDetailsModal(){this.isSaving||this.isDayDetailsLoading||(this.isDayDetailsModalOpen=!1,this.selectedDayDetailsDateKey="",this.selectedDayDetails=[],this.selectedDayTerminalPayments=[],this.isDayDetailsPage&&this.router.navigate(["/portal/raport-dzienny"],{queryParams:{date:this.selectedDayDetailsDateKey||this.reportDate}}))}async openDayDetails(e){this.error="",this.info="",this.selectedDayDetail
1sDateKey=e,this.isDayDetailsModalOpen=!0,this.isDayDetailsLoading=!0,this.cdr.detectChanges();try{await this.loadDayDetails(e)}finally{this.isDayDetailsLoading=!1,this.zone.run(()=>this.cdr.detectChanges())}}async openReportModalForNewEntries(){this.error="",this.info="",this.isExpenseModalOpen=!1,this.isDayDetailsModalOpen=!1,this.activeTopAction="report",this.reportDate=this.formatDateKeyLocal(new Date),this.selectedWeekStartKey=this.startOfWeekKey(this.reportDate),this.selectedMonthKey=this.reportDate.slice(0,7),this.reportModalMode="append",this.resetReportForm(),this.isReportModalOpen=!0,await this.refreshExistingReportFlag(),this.reportFormContextKey=this.buildReportFormKey(this.reportDate,this.activeReporterUid),!this.restoreReportDraftForKey(this.reportFormContextKey)&&!this.isEditingExistingReport&&await this.prefillReportFromBooksy(),this.lastPersistedDraftSnapshot=this.currentReportDraftSnapshot()}async openReportModalForEdit(){this.error="",this.info="",this.isExpenseModalOpen=!1,this.isDayDetailsModalOpen=!1,this.activeTopAction="report",this.reportModalMode="edit",await this.loadReportForDate(),this.isReportModalOpen=!0}closeReportModal(){this.isSaving||(this.isReportModalOpen=!1,this.activeTopAction="report",this.reportModalMode="append",this.resetReportForm(),this.error="")}async clearReportFormData(){this.isSaving||(this.resetReportForm(),this.reportModalMode="append",this.isEditingExistingReport=!1,this.error="",this.info="",this.clearReportDraftForKey(this.reportFormContextKey),this.lastPersistedDraftSnapshot=this.currentReportDraftSnapshot(),await this.refreshExistingReportFlag())}async openExpenseModal(){this.error="",this.info="",this.isReportModalOpen&&this.persistCurrentReportDraft(),this.isReportModalOpen=!1,this.isDayDetailsModalOpen=!1,this.reportDate=this.formatDateKeyLocal(new Date),this.selectedWeekStartKey=this.startOfWeekKey(this.reportDate),this.selectedMonthKey=this.reportDate.slice(0,7),this.activeTopAction="expense",this.isExpenseModalOpen=!0,await this.loadExpenseFormForDate()}closeExpenseModal(){this.isSaving||(this.isExpenseModalOpen=!1,this.activeTopAction="report",this.resetExpenseForm(),this.error="")}trackByDay(e,t){return t.dateKey}daySegmentHeightPercent(e){let t=this.chartScaleMax;return e<=0||t<=0?0:Math.max(2,e/t*100)}trackByEmployee(e,t){return t.uid}trackByFixedCost(e,t){return t.id}trackByMonthlyWorkReportFile(e,t){return t.id}trackByHourlySettlementRow(e,t){return t.id}trackByExpense(e,t){return t.id}trackByExpenseAttachment(e,t){return t.id}expenseAttachments(e){return this.expenseAttachmentsByExpenseId[e]??[]}selectedExpenseAttachmentName(e){return this.selectedExpenseAttachmentFiles[e]?.name??""}employeeCostTotal(e){return this.calculateEmployeeCostTotal(e)}employmentTypeLabel(e){return Mt(e)}formatSettlementHours(e){return`${e.toLocaleString("pl-PL",{minimumFractionDigits:2,maximumFractionDigits:2})} h`}formatSettlementHourlyRate(e){return`${e.toLocaleString("pl-PL",{minimumFractionDigits:2,maximumFractionDigits:2})} zl`}async printHourlySettlementSheet(){if(!(!this.hourlySettlementRows.length||this.isHourlySettlementPrinting)){this.error="",this.info="",this.isHourlySettlementPrinting=!0;try{let[{jsPDF:e},t]=await Promise.all([import("./chunk-J2SBNJJE.js"),import("./chunk-ZVHM7VT7.js")]),n=t.default,i=new e({unit:"pt",format:"a4"}),o=i.internal.pageSize.getWidth(),d=i.internal.pageSize.getHeight(),m=this.hourlySettlementRows.length,_=m>26?6.2:m>18?7.2:8.2,g=m>26?1.6:m>18?2:2.6,h=this.hourlySettlementRows.map(f=>[f.isSummary?"Podsumowanie":f.dateLabel,f.serviceLabel,this.formatSettlementHours(f.durationHours),this.formatSettlementHourlyRate(f.hourlyRate)]);i.setFontSize(15),i.text("Godziny do rozliczenia",28,30),i.setFontSize(10),i.text(`Miesiac: ${this.selectedMonthLabel}`,28,48),i.text(`Pracownik: ${this.selectedSettlementReporterLabel}`,28,62),i.text(`Wygenerowano: ${this.formatDateTime(new Date)}`,28,76),n(i,{startY:92,theme:"grid",pageBreak:"avoid",margin:{top:24,right:28,bottom:76,left:28},head:[["Dzien","Rodzaj uslugi","Czas uslugi","Cena za godzine"]],body:h,styles:{fontSize:_,cellPadding:g,lineColor:[226,232,240],lineWidth:.6,overflow:"linebreak",valign:"middle"},headStyles:{fillColor:[15,23,42],textColor:[255,255,255],fontStyle:"bold"},bodyStyles:{textColor:[15,23,42]},columnStyles:{0:{cellWidth:72},1:{cellWidth:278},2:{cellWidth:90,halign:"right"},3:{cellWidth:90,halign:"right"}},didParseCell:f=>{let A=this.hourlySettlementRows[f.row.index];f.section==="body"&&A?.isSummary&&(f.cell.styles.fontStyle="bold",f.cell.styles.fillColor=[241,245,249])}});let x=d-42,M=o-210;i.setFontSize(9),i.text("Podpis pracownika",M,x-8),i.line(M,x,o-28,x);let D=this.hourlySettlementSignature.trim();D&&(i.setFontSize(10),i.text(D,M+4,x-12)),i.autoPrint();let C=i.output("bloburl");window.open(C,"_blank","noopener,noreferrer")||i.save(`godziny-do-rozliczenia-${this.selectedMonthKey}.pdf`),this.info="Otworzono wydruk tabeli do rozliczenia."}catch(e){console.warn("Nie udalo sie przygotowac wydruku tabeli godzin:",e),this.error="Nie udalo sie przygotowac wydruku tabeli godzin."}finally{this.isHourlySettlementPrinting=!1}}}async exportMonthlyPdf(){if(!(!this.isAdmin||this.isPdfGenerating)){this.error="",this.info="",this.isPdfGenerating=!0;try{let[{jsPDF:e},t]=await Promise.all([import("./chunk-J2SBNJJE.js"),import("./chunk-ZVHM7VT7.js")]),n=t.default,i=new e({unit:"pt",format:"a4"}),o=this.monthOptions.find(g=>g.key===this.selectedMonthKey)?.label??this.selectedMonthKey,d=this.selectedReporterUid?this.reporterOptions.find(g=>g.uid===this.selectedReporterUid)?.email??this.selectedReporterUid:"Wszyscy pracownicy";i.setFontSize(18),i.text("Asami - raport miesieczny dla ksiegowe
1j",40,42),i.setFontSize(11),i.text(`Miesiac: ${o}`,40,64),i.text(`Zakres: ${d}`,40,80),i.text(`Wygenerowano: ${this.formatDateTime(new Date)}`,40,96),n(i,{startY:118,theme:"grid",head:[["Metryka","Wartosc"]],body:[["Raporty w miesiacu",String(this.monthlySummary.reportCount)],["Brutto",this.formatMoney(this.monthlySummary.gross)],["Godziny",this.formatNumber(this.monthlySummary.hours)],["Ewidencjonowana",this.formatMoney(this.monthlySummary.recorded)],["Nieewidencjonowana",this.formatMoney(this.monthlySummary.unrecorded)],["Znizki",this.formatMoney(this.monthlySummary.discount)],["Vouchery",this.formatMoney(this.monthlySummary.voucher)],["Stale koszty",this.formatMoney(this.monthlySummary.fixedCosts)],["Koszty pracownikow",this.formatMoney(this.monthlySummary.employeeCosts)],["Po wszystkich kosztach",this.formatMoney(this.monthlySummary.afterAllCosts)]]});let m=this.employeeMonthSummaries.map(g=>[g.email,String(g.reportCount),this.formatMoney(g.gross),this.formatNumber(g.hours),this.formatMoney(g.recorded),this.formatMoney(g.unrecorded),this.employmentTypeLabel(g.employmentCostType),this.formatMoney(g.employeeCostTotal)]);m.length&&n(i,{startY:i.lastAutoTable?.finalY?(i.lastAutoTable?.finalY??0)+20:260,theme:"grid",head:[["Pracownik","Raporty","Brutto","Godziny","Ewid.","Nieewid.","Forma","Koszt"]],body:m});let _=this.monthViewDays.filter(g=>g.reportCount>0||g.gross>0||g.hours>0).map(g=>[g.dateKey,String(g.reportCount),this.formatMoney(g.gross),this.formatNumber(g.hours),this.formatMoney(g.recorded),this.formatMoney(g.unrecorded),this.formatMoney(g.discount),this.formatMoney(g.voucher)]);_.length&&n(i,{startY:i.lastAutoTable?.finalY?(i.lastAutoTable?.finalY??0)+20:420,theme:"grid",head:[["Data","Raporty","Brutto","Godziny","Ewid.","Nieewid.","Znizki","Vouchery"]],body:_}),i.save(`raport-miesieczny-${this.selectedMonthKey}.pdf`),this.info="Wygenerowano raport miesieczny PDF dla ksiegowej."}catch(e){console.warn("Nie udalo sie wygenerowac raportu PDF:",e),this.error="Nie udalo sie wygenerowac raportu PDF."}finally{this.isPdfGenerating=!1}}}segmentTitle(e){return`${this.segmentLabel(e.kind)}: ${e.amount.toFixed(2)} zl`}dayTooltip(e){if(!this.isAdmin)return"";let t=e.phoneCount?`Numery telefonow (${e.phoneCount}): ${e.phones.join(", ")}`:"Numery telefonow: brak",n=e.missingPhoneCount?`Brak numeru przy ${e.missingPhoneCount} kliencie/klientach`:"Wszystkie telefony podane",i=e.reporterEmails.length?`Pracownicy: ${e.reporterEmails.join(", ")}`:"Pracownicy: brak";return[`Data: ${e.dateKey}`,`Raporty: ${e.reportCount}`,`Brutto: ${e.gross.toFixed(2)} zl`,`Gotowka: ${e.cash.toFixed(2)} zl`,`Karta: ${e.card.toFixed(2)} zl`,`Voucher: ${e.voucher.toFixed(2)} zl`,`Do akceptacji: ${e.pendingSettlementCount}`,i,t,n].join(` 2`)}paymentMethodLabel(e){return e==="card"?"Karta":e==="voucher"?"Voucher":e==="cash"?"Gotowka":e}displayPhone(e){return this.formatPhone(e)}displayAmount(e){return`${this.numberOrZero(e).toFixed(2)} zl`}hasBooksyProposal(e){return!!e.booksyProposal}isBooksyProposalChanged(e){let t=e.booksyProposal;return t?B(e.clientName)!==B(t.clientName)||this.normalizePhone(e.clientPhone)!==this.normalizePhone(t.clientPhone)||B(e.serviceName)!==B(t.serviceName)||!this.sameNullableNumber(e.amount,t.amount)||!this.sameNullableNumber(e.reportedHours,t.hours)||e.paymentMethod!==t.paymentMethod:!1}settlementApprovalLabel(e){return e.settlementApprovalStatus==="approved"?"Zaakceptowane":e.settlementApprovalStatus==="pending"?"Do akceptacji":e.booksyProposalCount?"Por\xF3wnanie historyczne":"Brak propozycji Booksy"}calendarComparisonRows(e){let t=new Set(e.clients.map((i,o)=>o)),n=[...e.booksyProposals].sort((i,o)=>i.startAt.localeCompare(o.startAt)).map(i=>{let o=e.clients.findIndex((m,_)=>t.has(_)&&m.booksyProposal?.appointmentId===i.appointmentId),d=o>=0?o:this.findHistoricalClientMatch(e.clients,t,i);return d<0?{id:`removed-${i.appointmentId}`,proposal:i,client:null,kind:"removed"}:(t.delete(d),{id:`matched-${i.appointmentId}`,proposal:i,client:e.clients[d],kind:"matched"})});return e.clients.forEach((i,o)=>{t.has(o)&&n.push({id:`added-${o}`,proposal:null,client:i,kind:"added"})}),n}calendarTimeline(e){let n=this.calendarComparisonRows(e),i=n.map(y=>({row:y,startMinute:this.booksyStartMinute(y.proposal?.startAt??"")})).filter(y=>y.startMinute!==null),o=i.length?Math.min(...i.map(y=>y.startMinute)):480,d=i.length?Math.max(...i.map(y=>y.startMinute+this.comparisonDurationMinutes(y.row))):o,m=Math.max(0,Math.floor(o/60)*60),_=Math.min(1440,Math.ceil(d/60)*60),g=_,h=n.map(y=>{let f=this.booksyStartMinute(y.proposal?.startAt??""),A=f??g,O=this.comparisonDurationMinutes(y);return f===null&&(g+=O),de(Q({},y),{topPx:Math.max(0,(A-m)*1.5),heightPx:Math.max(54,O*1.5)})}).sort((y,f)=>y.topPx-f.topPx),x=Math.max(0,...h.map(y=>y.topPx+y.heightPx)),M=Math.max(_,m+60,m+Math.ceil(x/1.5)),D=Math.max(120,(M-m)*1.5),C=[];for(let y=m;y<=M;y+=60)C.push({label:`${String(Math.floor(y/60)%24).padStart(2,"0")}:00`,topPx:(y-m)*1.5});return{rows:h,hours:C,heightPx:D}}booksyStartMinute(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.getHours()*60+t.getMinutes()}comparisonDurationMinutes(e){let t=e.proposal?.hours??e.client?.reportedHours??e.client?.hours??null;return Math.max(15,Math.round((t&&t>0?t:1)*60))}
2findHistoricalClientMatch(e,t,n){let i=-1,o=0;return e.forEach((d,m)=>{if(!t.has(m))return;let _=0,g=this.normalizePhone(d.clientPhone),h=this.normalizePhone(n.clientPhone),x=B(d.clientName),M=B(n.clientName),D=B(d.serviceName),C=B(n.serviceName),y=this.booksyStartMinute(d.booksyProposal?.startAt??""),f=this.booksyStartMinute(n.startAt);y!==null&&f!==null&&y===f&&(_+=8),g&&h&&g===h&&(_+=7),x&&M&&x===M&&(_+=6),D&&C&&D===C&&(_+=4),this.sameNullableNumber(d.amount,n.amount)&&(_+=1),_>o&&(o=_,i=m)}),o>=4?i:-1}isComparisonFieldChanged(e,t,n){return n==="clientName"?B(e.clientName)!==B(t.clientName):n==="clientPhone"?this.normalizePhone(e.clientPhone)!==this.normalizePhone(t.clientPhone):n==="serviceName"?B(e.serviceName)!==B(t.serviceName):n==="amount"?!this.sameNullableNumber(e.amount,t.amount):n==="hours"?!this.sameNullableNumber(e.reportedHours,t.hours):e.paymentMethod!==t.paymentMethod}isCalendarValueDifferent(e,t,n){return!t||this.isComparisonFieldChanged(e,t,n)}paymentMethodIcon(e){return e==="card"?"\u{1F4B3}":e==="voucher"?"\u{1F39F}\uFE0F":"\u{1F4B5}"}formatBooksyTime(e){let t=new Date(e);return Number.isNaN(t.getTime())?"Godzina nieznana":t.toLocaleTimeString("pl-PL",{hour:"2-digit",minute:"2-digit"})}trackByCalendarComparisonRow(e,t){return t.id}trackByTerminalPayment(e,t){return t.id}unmatchedTerminalPayments(){return this.selectedDayTerminalPayments.filter(e=>!e.matchedReportId)}matchedTerminalPayments(e,t){return this.selectedDayTerminalPayments.filter(n=>n.matchedReportId===e.id&&n.matchedComparisonRowId===t.id)}terminalPaymentTime(e){let n=(e.authDateSortKey||e.authDate).match(/(?:T|\s)(\d{1,2}):(\d{2})(?::(\d{2}))?/);return n?`${n[1].padStart(2,"0")}:${n[2]}`:"czas nieznany"}startTerminalPaymentDrag(e,t){!e.dataTransfer||t.matchedReportId||(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",t.id),e.dataTransfer.setData("application/x-asami-terminal-payment",t.id))}allowTerminalPaymentDrop(e){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="move")}async matchTerminalPayment(e,t,n){if(e.preventDefault(),!this.db||!this.isAdmin)return;if(n.proposal?.isTimeReservation||n.client?.isTimeReservation){this.info="Rezerwacja czasu nie ma platnosci do dopasowania.";return}let i=e.dataTransfer?.getData("application/x-asami-terminal-payment")||e.dataTransfer?.getData("text/plain")||"",o=this.selectedDayTerminalPayments.find(d=>d.id===i);if(!(!o||o.matchedReportId||this.terminalPaymentMatchBusyById[o.id])){this.terminalPaymentMatchBusyById[o.id]=!0,this.error="";try{await J(N(this.db,"terminalPayments",o.id),{matchedReportId:t.id,matchedComparisonRowId:n.id,matchedAppointmentId:n.proposal?.appointmentId??"",matchedReporterUid:t.reporterUid,matchedDateKey:t.dateKey,matchedByUid:this.currentUserUid,matchedByEmail:this.currentUserEmail,matchedAt:U()},{merge:!0}),o.matchedReportId=t.id,o.matchedComparisonRowId=n.id,this.info=`Dopasowano p\u0142atno\u015B\u0107 ${o.amount.toFixed(2)} ${o.currency||"PLN"}.`,this.cdr.detectChanges()}catch(d){console.warn("Nie udalo sie dopasowac platnosci terminalowej:",d),this.error="Nie uda\u0142o si\u0119 zapisa\u0107 dopasowania p\u0142atno\u015Bci terminalowej."}finally{this.terminalPaymentMatchBusyById[o.id]=!1}}}async unmatchTerminalPayment(e){if(!(!this.db||!this.isAdmin||this.terminalPaymentMatchBusyById[e.id])){this.terminalPaymentMatchBusyById[e.id]=!0,this.error="";try{await J(N(this.db,"terminalPayments",e.id),{matchedReportId:"",matchedComparisonRowId:"",matchedAppointmentId:"",matchedReporterUid:"",matchedDateKey:"",matchedByUid:this.currentUserUid,matchedByEmail:this.currentUserEmail,matchedAt:U()},{merge:!0}),e.matchedReportId="",e.matchedComparisonRowId="",this.info="Usuni\u0119to dopasowanie p\u0142atno\u015Bci terminalowej.",this.cdr.detectChanges()}catch(t){console.warn("Nie udalo sie usunac dopasowania platnosci:",t),this.error="Nie uda\u0142o si\u0119 usun\u0105\u0107 dopasowania p\u0142atno\u015Bci."}finally{this.terminalPaymentMatchBusyById[e.id]=!1}}}hasReportExpenses(e){return e.expenses.some(t=>t.label||(t.cost??0)>0)}hasReportClients(e){return e.clients.length>0}trackByDetailedReport(e,t){return t.id}trackByReportClient(e){return e}customerOptionLabel(e){return`${e.fullName} | ${this.displayPhone(e.phone)}`}
2async openCustomerBase(){this.isReportModalOpen&&this.persistCurrentReportDraft(),await this.router.navigate(["/baza-klientow"])}addClient(){this.clients.push(this.createEmptyClient())}onCustomerQueryFocus(e){this.closeCustomerSuggestionMenus(e),!e.customerId&&(e.isCustomerSuggestionsOpen=!0,this.refreshCustomerSuggestions(e))}onCustomerQueryInput(e){if(e.customerId){let t=this.findCustomerById(e.customerId);(!t||e.customerQuery.trim()!==this.customerOptionLabel(t))&&this.resetClientCustomerSelection(e,e.customerQuery)}e.isCustomerCreateOpen=!1,e.pendingCustomerName="",e.pendingCustomerPhone="",e.isCustomerSuggestionsOpen=!0,this.refreshCustomerSuggestions(e)}onCustomerQueryBlur(e){window.setTimeout(()=>{e.isCustomerSuggestionsOpen=!1},120)}selectCustomerSuggestion(e,t,n){n?.preventDefault(),this.applyCustomerToClient(e,t)}clearSelectedCustomer(e){this.resetClientCustomerSelection(e),e.isCustomerSuggestionsOpen=!0,this.refreshCustomerSuggestions(e)}shouldShowCustomerSuggestions(e){return!e.customerId&&e.isCustomerSuggestionsOpen&&(e.customerSuggestions.length>0||this.shouldOfferCustomerCreate(e))}hasExactCustomerMatch(e){return this.findExactCustomerMatch(e)!==null}shouldOfferCustomerCreate(e){return!e.customerId&&this.customerQueryMode(e.customerQuery)!=="empty"&&!this.hasExactCustomerMatch(e)}isPhoneCustomerQuery(e){return this.customerQueryMode(e.customerQuery)==="phone"}canSavePendingCustomer(e){return!!(e.pendingCustomerName.trim()&&this.normalizePhone(e.pendingCustomerPhone)&&!this.hasExactCustomerMatch(e))}openCustomerCreateForm(e){if(e.isCustomerCreateOpen=!0,e.isCustomerSuggestionsOpen=!1,this.customerQueryMode(e.customerQuery)==="phone"){e.pendingCustomerPhone=this.formatPhone(this.normalizePhone(e.customerQuery)),e.pendingCustomerName.trim()||(e.pendingCustomerName="");return}e.pendingCustomerName=e.customerQuery.trim(),e.pendingCustomerPhone.trim()||(e.pendingCustomerPhone="")}cancelCustomerCreateForm(e){e.isCustomerCreateOpen=!1,e.pendingCustomerName="",e.pendingCustomerPhone=""}async addCustomerFromClient(e){if(!this.db||!this.currentUserUid||this.isCustomerSaving)return;let t=e.pendingCustomerName.trim(),n=this.normalizePhone(e.pendingCustomerPhone);if(!t||!n){this.error="Aby dodac klienta do bazy, podaj imie i nazwisko oraz poprawny numer telefonu.";return}let i=this.findExactCustomerMatch(e);if(i){this.applyCustomerToClient(e,i),this.info="Ten klient jest juz w bazie. Wybrano istniejacy rekord.",this.error="";return}this.error="",this.info="",this.isCustomerSaving=!0;try{let o=N(L(this.db,Kt)),d={fullName:t,phone:n,normalizedFullName:this.normalizeCustomerName(t),phoneDigits:Be(n),nationalPhoneDigits:Re(n)?.nationalNumber??"",countryCode:Re(n)?.countryCode??"48",createdAt:U(),updatedAt:U(),createdByUid:this.currentUserUid,createdByEmail:this.currentUserEmail,updatedByUid:this.currentUserUid,updatedByEmail:this.currentUserEmail};await J(o,d);let m={id:o.id,fullName:t,phone:n,normalizedFullName:d.normalizedFullName,phoneDigits:d.phoneDigits,nationalPhoneDigits:d.nationalPhoneDigits,countryCode:d.countryCode};this.customers=this.sortCustomers([...this.customers,m]),this.applyCustomerToClient(e,m),this.info="Dodano nowego klienta do bazy."}catch(o){console.warn("Nie udalo sie dodac klienta do bazy:",o),this.error="Nie udalo sie dodac klienta do bazy."}finally{this.isCustomerSaving=!1}}onServiceFieldFocus(e){this.closeServiceSuggestionMenus(e),e.isServiceSuggestionsOpen=!0,e.serviceSuggestions=this.buildServiceSuggestions(e.serviceName)}onServiceFieldInput(e){e.isServiceSuggestionsOpen=!0,e.serviceSuggestions=this.buildServiceSuggestions(e.serviceName),e.serviceSelectedFromCatalog=!1,this.applyCatalogPriceIfExactMatch(e,!1)}onServiceFieldBlur(e){window.setTimeout(()=>{e.isServiceSuggestionsOpen=!1},120)}selectServiceSuggestion(e,t,n){n?.preventDefault(),e.serviceName=t.name,e.serviceSelectedFromCatalog=!0,this.applyCatalogPrice(e,t,!0),e.serviceSuggestions=this.buildServiceSuggestions(t.name),e.isServiceSuggestionsOpen=!1}onAnonymousChange(e){e.anonymous&&(e.customerId="",e.customerQuery="",e.clientName="",e.clientPhone="",e.isCustomerSuggestionsOpen=!1,e.customerSuggestions=[])}paymentOptionValue(e){return e.paymentMethod==="voucher"?"voucher":e.paymentMethod==="card"?"card":e.noRecord?"cash-no-record":"cash"}shouldShowVoucherFields(e){return e.paymentMethod==="voucher"}shouldShowVoucherAmountField(e){return e.paymentMethod==="voucher"&&e.voucherLookupState==="found"}voucherLookupStatusLabel(e){return e.voucherLookupState==="checking"?"Sprawdzanie numeru vouchera...":e.voucherLookupState==="found"?"Voucher znaleziony. Mozesz odjac srodki.":e.voucherLookupState==="missing"?"Nie znaleziono vouchera o takim numerze."
2:""}setPaymentOption(e,t){e.paymentMethod=t==="card"?"card":t==="voucher"?"voucher":"cash",e.noRecord=t==="cash-no-record",e.usedVoucher=t==="voucher",t!=="voucher"&&(this.clearVoucherLookupTimer(e),e.voucherAmount=null,e.voucherCode="",e.voucherLookupState="idle")}onVoucherCodeInput(e){e.voucherCode=this.normalizeVoucherCode(e.voucherCode),this.scheduleVoucherLookup(e)}onVoucherCodeBlur(e){if(e.paymentMethod==="voucher"){if(e.voucherCode=this.normalizeVoucherCode(e.voucherCode),!e.voucherCode){this.clearVoucherLookupTimer(e),e.voucherLookupState="idle",e.voucherAmount=null;return}this.clearVoucherLookupTimer(e),this.lookupVoucherCode(e,e.voucherCode,e.voucherLookupRequestId+1)}}removeClient(e){this.clients.length<=1||this.clients.splice(e,1)}addExpense(){this.expenses.push(this.createEmptyExpense())}removeExpense(e){let t=this.expenses.splice(e,1)[0];t&&delete this.selectedExpenseAttachmentFiles[t.id]}onExpenseAttachmentSelected(e,t){let n=e.target,i=n?.files?.[0]??null;if(i&&!this.isAllowedExpenseAttachmentFile(i)){this.error="Dozwolone sa tylko pliki PDF, JPG, JPEG, PNG i WEBP.",this.info="",n&&(n.value=""),this.selectedExpenseAttachmentFiles[t]=null;return}this.error="",this.selectedExpenseAttachmentFiles[t]=i}async deleteExpenseAttachment(e){if(!(!this.db||!this.storage||!this.currentUserUid)&&!(!this.isAdmin&&e.reporterUid!==this.currentUserUid)&&window.confirm(`Usunac zalacznik "${e.name||e.fileName}"?`)){this.error="",this.info="",this.expenseAttachmentDeleteBusyById[e.id]=!0;try{e.storagePath&&await Fe(we(this.storage,e.storagePath)),await Pe(N(this.db,ze,e.id)),this.info="Usunieto zalacznik do wydatku.",await this.loadExpenseAttachments(),await this.loadMonthView()}catch(t){console.warn("Nie udalo sie usunac zalacznika do wydatku:",t),this.error="Nie udalo sie usunac zalacznika do wydatku."}finally{this.expenseAttachmentDeleteBusyById[e.id]=!1}}}closeServiceSuggestionMenus(e){this.clients.forEach(t=>{t!==e&&(t.isServiceSuggestionsOpen=!1)})}refreshCustomerSuggestions(e){if(e.customerId){e.customerSuggestions=[];return}e.customerSuggestions=this.buildCustomerSuggestions(e.customerQuery)}buildCustomerSuggestions(e){let t=this.customerQueryMode(e),n=t==="name"?this.normalizeCustomerName(e):"",i=t==="phone"?Be(e):"";return t==="empty"?[]:this.customers.filter(o=>{let d=t==="phone"&&i.length>=3&&(o.phoneDigits.includes(i)||o.nationalPhoneDigits.includes(i)||o.phone.includes(i)),m=t==="name"&&n.length>=2&&o.normalizedFullName.includes(n);return d||m}).sort((o,d)=>this.compareCustomerSuggestions(o,d,n,i)).slice(0,8)}compareCustomerSuggestions(e,t,n,i){let o=this.customerSuggestionScore(e,n,i),d=this.customerSuggestionScore(t,n,i);return o!==d?d-o:e.fullName.localeCompare(t.fullName,"pl",{sensitivity:"base"})}customerSuggestionScore(e,t,n){let i=0;return n.length>=3&&(e.phone===this.normalizePhone(n)?i+=100:e.phoneDigits===n||e.nationalPhoneDigits===n?i+=90:e.phoneDigits.startsWith(n)||e.nationalPhoneDigits.startsWith(n)||e.phone.endsWith(n)?i+=60:(e.phoneDigits.includes(n)||e.nationalPhoneDigits.includes(n))&&(i+=30)),t.length>=2&&(e.normalizedFullName===t?i+=100:e.normalizedFullName.startsWith(t)?i+=50:e.normalizedFullName.includes(t)&&(i+=20)),i}findCustomerById(e){return this.customers.find(t=>t.id===e)??null}findExactCustomerMatch(e){let t=this.customerQueryMode(e.customerQuery),n=t==="name"?this.normalizeCustomerName(e.customerQuery):this.normalizeCustomerName(e.pendingCustomerName),i=t==="phone"?this.normalizePhone(e.customerQuery):this.normalizePhone(e.pendingCustomerPhone);return this.customers.find(o=>!!i&&o.phone===i||n.length>=2&&o.normalizedFullName===n)??null}resolveStoredClientCustomer(e,t,n){if(e){let d=this.findCustomerById(e);if(d)return d}let i=this.normalizeCustomerName(t),o=this.normalizePhone(n);return this.customers.find(d=>!!o&&d.phone===o||i.length>=3&&d.normalizedFullName===i)??null}applyCustomerToClient(e,t){e.customerId=t.id,e.clientName=t.fullName,e.clientPhone=this.formatPhone(t.phone),e.customerQuery=this.customerOptionLabel(t),e.pendingCustomerName="",e.pendingCustomerPhone="",e.isCustomerCreateOpen=!1,e.customerSuggestions=[],e.isCustomerSuggestionsOpen=!1}resetClientCustomerSelection(e,t=""){e.customerId="",e.clientName="",e.clientPhone="",e.customerQuery=t,e.customerSuggestions=[],e.isCustomerCreateOpen=!1,e.pendingCustomerName="",e.pen
2dingCustomerPhone=""}customerQueryMode(e){let t=e.trim();if(!t)return"empty";let n=Be(t);return n.length>=3&&n.length>=Math.ceil(t.length/2)?"phone":"name"}closeCustomerSuggestionMenus(e){this.clients.forEach(t=>{t!==e&&(t.isCustomerSuggestionsOpen=!1)})}normalizeEditableClientName(e,t){let n=e.trim();return n?n===`Klient ${t+1}`?"":n:""}normalizeCustomerName(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}sortCustomers(e){return[...e].sort((t,n)=>t.fullName.localeCompare(n.fullName,"pl",{sensitivity:"base"}))}buildServiceSuggestions(e){let t=this.normalizeServiceSearch(e),n=new Map(this.recentServiceSuggestions.map((o,d)=>[o.normalizedName,d]));if(t.length<2)return this.recentServiceSuggestions.slice(0,8);let i=new Map;return this.serviceCatalogSuggestions.forEach(o=>{o.normalizedName.includes(t)&&i.set(o.normalizedName,de(Q({},o),{isRecent:n.has(o.normalizedName)}))}),this.recentServiceSuggestions.forEach(o=>{o.normalizedName.includes(t)&&!i.has(o.normalizedName)&&i.set(o.normalizedName,o)}),Array.from(i.values()).sort((o,d)=>{let m=n.has(o.normalizedName)?n.get(o.normalizedName):Number.MAX_SAFE_INTEGER,_=n.has(d.normalizedName)?n.get(d.normalizedName):Number.MAX_SAFE_INTEGER;if(m!==_)return m-_;let g=o.normalizedName.startsWith(t)?0:1,h=d.normalizedName.startsWith(t)?0:1;if(g!==h)return g-h;let x=o.normalizedName.indexOf(t),M=d.normalizedName.indexOf(t);return x!==M?x-M:o.name.localeCompare(d.name,"pl",{sensitivity:"base"})}).slice(0,8)}findServiceSuggestionByName(e){let t=this.normalizeServiceSearch(e);return t?this.serviceCatalogSuggestions.find(n=>n.normalizedName===t)??this.recentServiceSuggestions.find(n=>n.normalizedName===t)??null:null}findServiceSuggestionForBooksy(e){let t=this.normalizeServiceSearch(e);return t?this.serviceCatalogSuggestions.find(n=>n.normalizedName===t||n.normalizedBooksyName===t)??null:null}findUniqueCustomerForBooksy(e,t){let n=this.normalizePhone(t);if(n){let d=this.customers.filter(m=>m.phone===n);if(d.length===1)return d[0]}let i=this.normalizeCustomerName(e);if(i.length<3)return null;let o=this.customers.filter(d=>d.normalizedFullName===i);return o.length===1?o[0]:null}booksyDurationHours(e,t){let n=new Date(e.startAt),i=new Date(e.endAt);if(!Number.isNaN(n.getTime())&&!Number.isNaN(i.getTime())&&i>n)return(i.getTime()-n.getTime())/36e5;let o=this.parseServiceDurationMinutes(e.booksyDuration)??t?.durationMinutes??null;return o&&o>0?o/60:null}booksyDetailValue(e,t){let n=B(t),i=e.split(/\r?\n/).find(d=>B(d).startsWith(n));if(!i)return"";let o=i.indexOf(":");return o>=0?i.slice(o+1).trim():""}async prefillReportFromBooksy(){if(!this.db||!this.activeReporterUid||!Vt(this.isEditingExistingReport,this.hasMeaningfulReportDraft()))return;let e=this.activeReporterDisplayName.trim();if(!e){this.booksyPrefillInfo="Nie mo\u017Cna dopasowa\u0107 wizyt Booksy bez ustawionej nazwy pracownika.";return}try{let n=(await G(ee(L(this.db,Ut),ie("dateKey","==",this.reportDate)))).docs.map(h=>{let x=h.data();return String(x.source??"")!=="booksy"?null:{id:String(x.booksyAppointmentId??h.id),details:String(x.details??""),startAt:String(x.startAt??""),endAt:String(x.endAt??""),booksyEmployee:String(x.booksyEmployee??""),booksyClientName:String(x.booksyClientName??""),booksyClientPhone:String(x.booksyClientPhone??"")||this.booksyDetailValue(String(x.details??""),"Telefon:"),booksyService:String(x.booksyService??""),booksyStatus:String(x.booksyStatus??""),booksyPrice:String(x.booksyPrice??"")||this.booksyDetailValue(String(x.details??""),"Warto\u015B\u0107 us\u0142ug:"),booksyDuration:String(x.booksyDuration??"")||this.booksyDetailValue(String(x.details??""),"Czas trwania:"),booksyPaymentMethod:String(x.booksyPaymentMethod??"")||this.booksyDetailValue(String(x.details??""),"Metoda p\u0142atno\u015Bci:")}}).filter(h=>!!(h&&h.booksyService.trim()&&(h.booksyClientName.trim()||ge(h.booksyService,h.booksyClientName))&&De(h.booksyEmployee,e)&&!Oe(h.booksyStatus))).sort((h,x)=>h.startAt.localeCompare(x.startAt));if(!n.length){this.booksyPrefillInfo="Brak wizyt Booksy przypisanych do tego pracownika w wybranym dniu.";return}let i=0,o=0,d=0,m=0;this.clients=n.map(h=>{let x=this.createEmptyClient(),M=ge(h.booksyService,h.booksyClientName);x.isTimeReservation=M,M&&(x.anonymous=!0,x.clientName="Rezerwacja czasu Booksy",x.customerQuery="Rezerwacja czasu Booksy",m+=1);let D=this.findUniqueCustomerForBooksy(h.booksyClientName,h.booksyClientPhone);!M&&D?this.applyCustomerToClient(x,D):M||(x.customerQuery=h.booksyClientName.trim(),x.clientName=h.booksyClientName.trim(),x.clientPhone=this.formatPhone(h.booksyClientPhone),i+=1);let C=this.findServiceSuggestionForBooksy(h.booksyService);return!M&&C?(x.serviceName=C.name,x.serviceSelectedFromCatalog=!0):(x.serviceName=h.booksyService.trim(),x.serviceSelectedFromCatalog=M,M||(o+=1)),x.amount=M?0:Ze(h.booksyPrice)??(C?this.parseCatalogPrice(C.price):null),x.hours=this.booksyDurationHours(h,C),x.paymentMethod=He(h.booksyPaymentMethod),x.usedVoucher=x.paymentMethod==="voucher",x.booksyProposal={appointmentId:h.id,startAt:h.startAt,clientName:h.booksyClientName.trim(),clientPhone:this.normalizePhone(h.booksyClientPhone),serviceName:h.booksyService.trim(),amount:x.amount,hours:x.hours,paymentMethod:x.paymentMethod,isTimeReservation:M},!M&&!h.booksyPaymentMethod.trim()&&(d+=1),x}),this.booksyProposals=this.clients.map(h=>h.booksyProposal).filter(h=>!!h).map(h=>Q({},h));let _=[i?`${i} klient(\xF3w) do dopasowania`:"",o?`${o} us\u0142ug do dopasowania`:"",d?`${d}
2 form p\u0142atno\u015Bci do sprawdzenia`:""].filter(Boolean),g=n.length-m;this.booksyPrefillInfo=`Wczytano z Booksy: ${g} wizyt${m?` i ${m} rezerwacji czasu`:""}.${_.length?` Wymaga sprawdzenia: ${_.join(", ")}.`:" Sprawd\u017A dane i zapisz raport."}`}catch(t){console.warn("Nie uda\u0142o si\u0119 wst\u0119pnie wype\u0142ni\u0107 raportu z kalendarza Booksy:",t),this.booksyPrefillInfo="Nie uda\u0142o si\u0119 wczyta\u0107 propozycji z Booksy. Raport mo\u017Cesz uzupe\u0142ni\u0107 r\u0119cznie."}}parseServiceDurationMinutes(e){let t=String(e??"").trim().toLowerCase();if(!t)return null;let n=t.match(/(\d+(?:[.,]\d+)?)\s*h(?:(?:\s*:\s*|\s+)(\d{1,2}))?/);if(n){let m=Number(n[1].replace(",",".")),_=n[2]?Number(n[2]):0;if(Number.isFinite(m)&&Number.isFinite(_))return Math.max(0,Math.round(m*60+_))}let i=t.match(/(\d+(?:[.,]\d+)?)\s*min/);if(i){let m=Number(i[1].replace(",","."));if(Number.isFinite(m))return Math.max(0,Math.round(m))}let o=t.match(/^(\d{1,2}):(\d{2})$/);if(o){let m=Number(o[1]),_=Number(o[2]);if(Number.isFinite(m)&&Number.isFinite(_))return Math.max(0,Math.round(m*60+_))}let d=Number(t.replace(",","."));return Number.isFinite(d)&&d>0?Math.round(d):null}formatDurationMinutes(e){if(!Number.isFinite(e)||e<=0)return"";if(e<60)return`${e} min`;let t=Math.floor(e/60),n=e%60;return n?`${t} h ${n} min`:`${t} h`}rememberRecentServices(e){let t=[...this.recentServiceSuggestions];e.forEach(n=>{let i=n.serviceName.trim();if(!i)return;let o=this.normalizeServiceSearch(i),d=this.serviceCatalogSuggestions.find(g=>g.normalizedName===o),m={name:i,category:d?.category??"",price:d?.price??"",duration:d?.duration??"",durationMinutes:d?.durationMinutes??null,
2normalizedName:o,normalizedBooksyName:d?.normalizedBooksyName??"",isRecent:!0},_=t.findIndex(g=>g.normalizedName===o);_>=0&&t.splice(_,1),t.unshift(m)}),this.recentServiceSuggestions=t.slice(0,8)}applyCatalogPriceIfExactMatch(e,t){let n=this.normalizeServiceSearch(e.serviceName);if(!n)return;let i=this.serviceCatalogSuggestions.find(o=>o.normalizedName===n);i&&(e.serviceSelectedFromCatalog=!0,this.applyCatalogPrice(e,i,t))}applyCatalogPrice(e,t,n){let i=this.parseCatalogPrice(t.price);i!==null&&(!n&&e.amount!==null||(e.amount=i,t.durationMinutes!==null&&t.durationMinutes!==void 0&&(n||e.hours===null)&&(e.hours=t.durationMinutes/60)))}onMonthlyWorkReportFileSelected(e){let t=e.target;this.selectedMonthlyWorkReportFile=t?.files?.[0]??null}async onReportModalDateChange(){this.error="",this.info="",this.persistCurrentReportDraft(),this.selectedWeekStartKey=this.startOfWeekKey(this.reportDate),this.selectedMonthKey=this.reportDate.slice(0,7),this.resetReportForm(),this.reportModalMode="append",this.loadMonthView(),await this.refreshExistingReportFlag(),this.reportFormContextKey=this.buildReportFormKey(this.reportDate,this.activeReporterUid),!this.restoreReportDraftForKey(this.reportFormContextKey)&&!this.isEditingExistingReport&&await this.prefillReportFromBooksy()}async onExpenseModalDateChange(){this.error="",this.info="",this.selectedWeekStartKey=this.startOfWeekKey(this.reportDate),this.selectedMonthKey=this.reportDate.slice(0,7),this.resetExpenseForm(),this.loadMonthView(),await this.loadExpenseFormForDate()}async handleRouteAction(e){let t=e==="expense"?"expense":e==="report"?"report":null;!t||!this.currentUserUid||(t==="expense"&&!this.isExpenseModalOpen&&await this.openExpenseModal(),t==="report"&&!this.isReportModalOpen&&await this.openReportModalForNewEntries(),await this.router.navigate([],{relativeTo:this.route,queryParams:{action:null},queryParamsHandling:"merge",replaceUrl:!0}))}async saveDailyReport(){if(!this.db||!this.currentUserUid){this.error="Brak dostepu do zapisu raportu.";return}if(!this.activeReporterUid){this.error="Wybierz pracownika, dla ktorego zapisujesz raport.";return}for(let i of this.clients.filter(o=>this.hasMeaningfulClientEntry(o))){if(!i.anonymous){if(!i.customerId){if(this.hasExactCustomerMatch(i)){this.error="Wybierz klienta z listy podpowiedzi.";return}this.error="Wybierz klienta z bazy. Jesli go brakuje, dodaj go w module Baza klientow.";return}let o=i.clientName.trim(),d=this.normalizePhone(i.clientPhone);if(!o||!d){this.error="Przy kazdym kliencie podaj imie i nazwisko oraz poprawny numer telefonu.";return}}if(!this.isAdmin&&!i.isTimeReservation&&i.serviceName.trim()&&!i.serviceSelectedFromCatalog){this.error="Wybierz poprawna usluge z cennika.";return}}let e=this.normalizeClients();if(!e.length){this.error="Dodaj co najmniej jednego klienta z kwota.";return}for(let i of this.clients){if(i.paymentMethod==="voucher"&&i.voucherLookupState==="checking"){this.error="Poczekaj na sprawdzenie numeru vouchera przed zapisaniem raportu.";return}if(i.paymentMethod==="voucher"&&i.voucherLookupState==="found"&&(i.voucherAmount??0)<=0){this.error="Przy voucherze podaj kwote vouchera.";return}if(this.usesHourlySettlement&&(i.hours??0)<=0){this.error="Przy rozliczeniu godzinowym podaj liczbe godzin przy kazdym kliencie.";return}}let t=this.normalizeExpenses(),n=N(this.db,oe,this.reportDocId());this.error="",this.info="",this.isSaving=!0;try{let i=await te(n),o=i.exists()?i.data():null,d=o?.createdAt??null,m=this.extractReferralRewards(o?.referralRewards??[]),_=o?this.extractStoredClients(o.clients):[],g=o?this.extractBooksyProposals(o.booksyProposals,_):[],h=this.reportModalMode==="append"&&o?[..._,...e]:e,x=this.mergeBooksyProposals(this.reportModalMode==="append"?g:[],this.booksyProposals),M=this.reportModalMode==="append"&&o?[...this.extractStoredExpenses(o.expenses),...t]:t,D=this.extractStoredOrdersCashCost(o),C=this.extractStoredOrdersCardCost(o),y=this.hadOrders?this.numberOrZero(this.ordersCost):0,f=this.hadOrders&&this.ordersPaymentMethod==="cash"?y:0,A=this.hadOrders&&this.ordersPaymentMethod==="card"?y:0,O=this.reportModalMode==="append"&&o?D+f:f,F=this.reportModalMode==="append"&&o?C+A:A,q=O+F,K=q>0,se=O>0&&F>0?"mixed":O>0?"cash":"card",X=this.calculateReportTotals(h),ye=x.length>0;await J(n,{dateKey:this.reportDate,reporterUid:this.activeReporterUid,reporterEmail:this.activeReporterEmail,reporterDis
2playName:ae(this.activeReporterDisplayName,this.activeReporterEmail,this.activeReporterUid),clients:h,booksyProposals:x,expenses:M,hadOrders:K,ordersCost:K?q:null,ordersCashCost:K?O:0,ordersCardCost:K?F:0,ordersPaymentMethod:K?se:"",recordedAmount:X.recordedAmount,unrecordedAmount:X.unrecordedAmount,generalNotes:"",totals:{clientAmount:X.clientAmount,discountAmount:X.discountAmount,voucherAmount:X.voucherAmount},settlementApprovalStatus:ye?"pending":"not_required",settlementApprovedAt:null,settlementApprovedByUid:"",settlementApprovedByEmail:"",createdAt:d??U(),updatedAt:U()},{merge:!0});let R=await this.syncVoucherNotes(h),V=await this.syncReferralPoints(h,m);await J(n,{referralRewards:V.rewards,referralPointsTotal:V.totalPoints,updatedAt:U()},{merge:!0});let ne=[this.buildSaveInfoMessage(!!o)];R.length&&ne.push(`Nie znaleziono voucherow: ${R.join(", ")}.`),V.assignedCount>0&&ne.push(`Naliczono punkty afiliacyjne: ${V.totalPoints} za ${V.assignedCount} klientow.`),V.unmatchedPhones.length&&ne.push(`Nie znaleziono ambasadora dla numerow: ${V.unmatchedPhones.map(le=>this.formatPhone(le)).join(", ")}.`),this.info=ne.join(" "),this.rememberRecentServices(h),this.isEditingExistingReport=!0,this.clearReportDraftForKey(this.buildReportFormKey(this.reportDate,this.activeReporterUid)),this.isReportModalOpen=!1,this.reportModalMode="append",this.resetReportForm(),this.reportFormContextKey="",await this.loadMonthView()}catch(i){console.warn("Nie udalo sie zapisac raportu:",i),this.error="Nie udalo sie zapisac raportu."}finally{this.isSaving=!1}}async saveExpenseEntries(){if(!this.db||!this.currentUserUid){this.error="Brak dostepu do zapisu wydatkow.";return}if(!this.activeReporterUid){this.error="Wybierz pracownika, dla ktorego zapisujesz wydatek.";return}let e=this.reportDocId(),t=this.normalizeExpenses(),n=this.numberOrZero(this.ordersCost),i=n>0||t.length>0,o=N(this.db,oe,e);this.error="",this.info="",this.isSaving=!0;try{let d=await te(o),m=d.exists()?d.data():null;if(!m&&!i){this.error="Dodaj zamowienie lub co najmniej jeden wydatek.";return}let _=m?.createdAt??null,g=this.extractStoredClients(m?.clients),x=this.extractStoredExpenses(m?.expenses,e).map(K=>K.id).filter(K=>!t.some(se=>se.id===K)),M=this.calculateReportTotals(g),D=n,C=D>0&&this.ordersPaymentMethod==="cash"?D:0,y=D>0&&this.ordersPaymentMethod==="card"?D:0,f=C+y>0,A=C>0&&y<=0?"cash":"card";await J(o,{dateKey:this.reportDate,reporterUid:this.activeReporterUid,reporterEmail:this.activeReporterEmail,reporterDisplayName:ae(this.activeReporterDisplayName,this.activeReporterEmail,this.activeReporterUid),clients:g,expenses:t,hadOrders:f,ordersCost:f?D:null,ordersCashCost:f?C:0,ordersCardCost:f?y:0,ordersPaymentMethod:f?A:"",recordedAmount:m?this.numberOrZero(m.recordedAmount):M.recordedAmount,unrecordedAmount:m?this.numberOrZero(m.unrecordedAmount):M.unrecordedAmount,generalNotes:m?String(m.generalNotes??""):"",totals:{clientAmount:m?this.numberOrZero(m.totals?.clientAmount):M.clientAmount,discountAmount:m?this.numberOrZero(m.totals?.discountAmount):M.discountAmount,voucherAmount:m?this.numberOrZero(m.totals?.voucherAmount):M.voucherAmount},createdAt:_??U(),updatedAt:U()},{merge:!0});let O=await this.removeStoredExpenseAttachments(x),F=await this.uploadSelectedExpenseAttachments(t),q=[m?"Zamowienia i wydatki zostaly zaktualizowane.":"Zamowienia i wydatki zostaly zapisane."];if(F.uploadedCount>0&&q.push(F.uploadedCount===1?"Dodano 1 zalacznik.":`Dodano ${F.uploadedCount} zalaczniki.`),this.info=q.join(" "),await this.loadExpenseAttachments(),await this.loadMonthView(),!O||F.failedLabels.length){let K=[];O||K.push("nie udalo sie usunac wszystkich starych zalacznikow usunietych wydatkow"),F.failedLabels.length&&K.push(`nie udalo sie wyslac zalacznikow dla: ${F.failedLabels.join(", ")}`),this.error=`Wydatki zostaly zapisane, ale ${K.join(" i ")}.`;return}this.isExpenseModalOpen=!1,this.activeTopAction="report",this.resetExpenseForm()}catch(d){console.warn("Nie udalo sie zapisac wydatkow:",d),this.error="Nie udalo sie zapisac zamowien i wydatkow."}finally{this.isSaving=!1}}async uploadMonthlyWorkReport(){if(!this.db||!this.storage||!this.currentUserUid||!this.canSendMonthlyWorkReport){this.error="Brak dostepu do wyslania miesiecznego raportu pracy.",this.info="";return}let e=this.selectedMonthlyWorkReportFile;if(!e){this.error="Wybierz plik JPEG albo PDF z godzinami.",this.info="";return}if(!this.isAllowedMonthlyWorkReportFile(e)){this.error="Dozwolone sa tylko pliki PDF, JPG i JPEG.",this.info="";return}this.error="",this.info="",this.isMonthlyWorkReportUploading=!0;try{let t=e.name.replace(/[^a-zA-Z0-9._-]/g,"_"),n=`monthly-work-reports/${this.currentUserUid}/${this.selectedMonthKey}/${Date.now()}_${t}`,i=we(this.storage,n);await We(i,e);let o=await je(i),d=N(L(this.db,Qe));await J(d,{monthKey:this.selectedMonthKey,reporterUid:this.currentUserUid,reporterEmail:this.currentUserEmail,reporterDis
2playName:ae(this.currentUserDisplayName,this.currentUserEmail,this.currentUserUid),employmentCostType:this.currentEmploymentCostType,name:e.name,fileName:e.name,mime:e.type,size:e.size,url:o,storagePath:n,createdAt:U(),updatedAt:U()}),this.selectedMonthlyWorkReportFile=null,this.info=`Wyslano miesieczny raport pracy za ${this.selectedMonthLabel}.`,await this.loadMonthlyWorkReportFiles()}catch(t){console.warn("Nie udalo sie wyslac miesiecznego raportu pracy:",t),this.error="Nie udalo sie wyslac miesiecznego raportu pracy."}finally{this.isMonthlyWorkReportUploading=!1}}async deleteMonthlyWorkReportFile(e){if(!(!this.db||!this.storage||e.reporterUid!==this.currentUserUid)&&window.confirm(`Usunac plik "${e.fileName||e.name}"?`)){this.error="",this.info="",this.monthlyWorkReportDeleteBusyById[e.id]=!0;try{e.storagePath&&await Fe(we(this.storage,e.storagePath)),await Pe(N(this.db,Qe,e.id)),this.info="Usunieto plik miesiecznego raportu pracy.",await this.loadMonthlyWorkReportFiles()}catch(t){console.warn("Nie udalo sie usunac pliku miesiecznego raportu pracy:",t),this.error="Nie udalo sie usunac pliku miesiecznego raportu pracy."}finally{this.monthlyWorkReportDeleteBusyById[e.id]=!1}}}async addFixedCost(){if(!this.db||!this.isAdmin||!this.currentUserUid){this.error="Brak uprawnien do dodania kosztu stalego.",this.info="";return}let e=this.fixedCostLabel.trim(),t=this.numberOrNull(this.fixedCostAmount);if(!e||t===null||t<=0){this.error="Podaj nazwe i kwote kosztu stalego (wieksza od 0).",this.info="";return}this.error="",this.info="",this.isFixedCostsSaving=!0;try{let n=N(L(this.db,Ve));await J(n,{label:e,amount:t,active:!0,createdAt:U(),updatedAt:U(),createdByUid:this.currentUserUid,createdByEmail:this.currentUserEmail},{merge:!0}),this.fixedCostLabel="",this.fixedCostAmount=null,this.info="Koszt staly zostal dodany.",await this.loadFixedCosts(),await this.loadMonthView()}catch(n){console.warn("Nie udalo sie dodac kosztu stalego:",n),this.error="Nie udalo sie dodac kosztu stalego."}finally{this.isFixedCostsSaving=!1}}async toggleFixedCost(e){if(!(!this.db||!this.isAdmin)){this.fixedCostBusyById[e.id]=!0,this.error="",this.info="";try{await J(N(this.db,Ve,e.id),{active:!e.active,updatedAt:U(),updatedByUid:this.currentUserUid,updatedByEmail:this.currentUserEmail},{merge:!0}),this.info=`Koszt "${e.label}" ${e.active?"wylaczony":"wlaczony"}.`,await this.loadFixedCosts(),await this.loadMonthView()}catch(t){console.warn("Nie udalo sie zmienic kosztu stalego:",t),this.error="Nie udalo sie zmienic statusu kosztu stalego."}finally{this.fixedCostBusyById[e.id]=!1}}}async deleteFixedCost(e){if(!(!this.db||!this.isAdmin)&&window.confirm(`Usunac koszt staly "${e.label}"?`)){this.fixedCostBusyById[e.id]=!0,this.error="",this.info="";try{await Pe(N(this.db,Ve,e.id)),this.info=`Koszt "${e.label}" zostal usuniety.`,await this.loadFixedCosts(),await this.loadMonthView()}catch(t){console.warn("Nie udalo sie usunac kosztu stalego:",t),this.error="Nie udalo sie usunac kosztu stalego."}finally{this.fixedCostBusyById[e.id]=!1}}}initFirebase(){if(!ke.projectId||!ke.apiKey){this.error="Brak konfiguracji Firebase.",this.isLoading=!1;return}this.app=Ke().length?Ke()[0]:lt(ke),this.auth=dt(this.app),this.db=pt(this.app),ke.storageBucket?this.storage=Ft(this.app):this.storageReady=!1}watchAuth(){if(!this.auth||!this.db){this.isLoading=!1,this.cdr.detectChanges();return}let e=async n=>{if(this.isLoading=!0,!n){this.currentUserUid="",this.currentUserEmail="",this.isLoading=!1,this.error="Brak dostepu.",this.cdr.detectChanges();return}this.currentUserUid=n.uid,this.currentUserEmail=n.email??"",this.currentUserDisplayName=n.displayName??"";try{await n.getIdToken(),await this.loadRole(n),await this.loadReporterOptions(),await this.loadCustomers(),await this.loadServiceCatalogSuggestions(),await this.loadRecentServiceSuggestions(),await this.loadFixedCosts(),await this.loadEmployeeCosts(),await this.loadCurrentEmploymentCost(),await this.loadReportForDate(),await this.loadMonthView(),await this.loadMonthlyWorkReportFiles(),this.isDayDetailsPage&&this.selectedDayDetail
2sDateKey&&await this.openDayDetails(this.selectedDayDetailsDateKey),await this.handleRouteAction(this.route.snapshot.queryParamMap.get("action"))}finally{this.isLoading=!1,this.cdr.detectChanges()}},t=this.auth.currentUser;t&&this.zone.run(()=>{e(t)}),this.authUnsub=ct(this.auth,n=>{this.zone.run(()=>{e(n)})})}async loadRole(e){if(this.db){this.isActualAdmin=!1,this.isAdmin=!1,this.canUseNoRecord=!1;try{let t=await te(N(this.db,Lt,e.uid));if(!t.exists())return;let n=t.data();this.isActualAdmin=!!n.approved&&n.role==="admin",this.isAdmin=St(this.isActualAdmin),this.canUseNoRecord=this.isAdmin||this.isActualAdmin||!!n.canUseNoRecord,this.currentUserDisplayName=String(n.displayName??e.displayName??"").trim()}catch(t){console.warn("Nie udalo sie pobrac roli:",t)}}}async loadReporterOptions(){if(!this.db||!this.isAdmin){this.reporterOptions=[],this.selectedReporterUid="";return}try{let e=await G(ee(L(this.db,Lt),$e("email","asc")));this.reporterOptions=e.docs.map(t=>{let n=t.data();return{uid:t.id,email:String(n.email??"").trim(),displayName:String(n.displayName??"").trim(),approved:!!n.approved}}).filter(t=>t.email&&t.approved).map(t=>({uid:t.uid,email:t.email,displayName:t.displayName})),this.selectedReporterUid&&!this.reporterOptions.some(t=>t.uid===this.selectedReporterUid)&&(this.selectedReporterUid=""),!this.selectedReporterUid&&this.reporterOptions.some(t=>t.uid===this.currentUserUid)&&(this.selectedReporterUid=this.currentUserUid)}catch(e){console.warn("Nie udalo sie pobrac listy pracownikow:",e),this.reporterOptions=[],this.selectedReporterUid=""}}async loadCustomers(){if(!this.db||!this.currentUserUid){this.customers=[];return}try{let e=await G(L(this.db,Kt));this.customers=this.sortCustomers(e.docs.map(t=>{let n=t.data(),i=String(n.fullName??"").trim(),o=zt(String(n.countryCode??"48")).code,d=Re(String(n.phone??""),o);return!i||!d?null:{id:t.id,fullName:i,phone:d.canonicalDigits,normalizedFullName:this.normalizeCustomerName(i),phoneDigits:d.canonicalDigits,nationalPhoneDigits:d.nationalNumber,countryCode:d.countryCode}}).filter(t=>t!==null))}catch(e){console.warn("Nie udalo sie pobrac bazy klientow:",e),this.customers=[]}}async loadServiceCatalogSuggestions(){if(!this.db||!this.currentUserUid){this.serviceCatalogSuggestions=[];return}try{let e=await te(N(this.db,Tt,It)),t=Bt(e.data()?.activeCollection),n=await G(L(this.db,t||Nt)),i=new Map;n.docs.forEach(o=>{let d=o.data(),m=String(d.websiteName??d.name??d.cashRegisterName??d.booksyName??"").trim()||String(d.cashRegisterName??d.booksyName??"").trim();if(!m)return;let _=this.normalizeServiceSearch(m);!_||i.has(_)||i.set(_,{name:m,category:String(d.category??d.booksyCategory??d.cashRegisterType??"").trim(),price:String(d.websitePrice??d.cashRegisterPrice??d.booksyPrice??"").trim(),duration:String(d.duration??d.booksyDuration??"").trim(),durationMinutes:this.parseServiceDurationMinutes(d.duration??d.booksyDuration),normalizedName:_,normalizedBooksyName:this.normalizeServiceSearch(String(d.booksyName??"")),isRecent:!1})}),this.serviceCatalogSuggestions=Array.from(i.values()).sort((o,d)=>o.name.localeCompare(d.name,"pl",{sensitivity:"base"}))}catch(e){console.warn("Nie udalo sie pobrac katalogu uslug:",e),this.serviceCatalogSuggestions=[]}}async loadRecentServiceSuggestions(){if(!this.db||!this.currentUserUid||!this.activeReporterUid){this.recentServiceSuggestions=[];return}try{let e=await G(ee(L(this.db,oe),ie("reporterUid","==",this.activeReporterUid))),t=new Map;e.docs.forEach(n=>{let i=n.data(),o=String(i.dateKey??"");(Array.isArray(i.clients)?i.clients:[]).forEach(m=>{let _=String(m.serviceName??"").trim();if(!_)return;let g=this.normalizeServiceSearch(_);if(!g)return;let h=t.get(g);if(h&&h.dateKey>=o)return;let x=this.serviceCatalogSuggestions.find(M=>M.normalizedName===g);t.set(g,{suggestion:{name:_,category:x?.category??"",price:x?.price??"",duration:x?.duration??String(m.serviceDuration??"").trim(),durationMinutes:x?.durationMinutes??this.numberOrNull(m.serviceDurationMinutes)??this.parseServiceDurationMinutes(m.serviceDuration),normalizedName:g,normalizedBooksyName:x?.normalizedBooksyName??"",isRecent:!0},dateKey:o})})}),this.recentServiceSuggestions=Array.from(t.values()).sort((n,i)=>i.dateKey.localeCompare(n.dateKey)).map(n=>n.suggestion).slice(0,8)}catch(e){console.warn("Nie udalo sie pobrac ostatnio wybieranych uslug:",e),this.recentServiceSuggestions=[]}}async loadFixedCosts(){if(!this.db||!this.isAdmin){this.fixedCosts=[];return}this.isFixedCostsLoading=!0;try{let e=await G(ee(L(this.db,Ve),$e("createdAt","desc")));this.fixedCosts=e.docs.map(t=>{let n=t.data();return{id:t.id,label:String(n.label??"").trim(),amount:this.numberOrZero(n.amount),active:!!n.active,paymentPlanType:Et(n.paymentPlanType),remainingPayments:Rt(n.remainingPayments),paymentDueDay:Dt(n.paymentDueDay),createdAtLabel:this.formatDateTime(n.createdAt)}})}catch(e){console.warn("Nie udalo sie pobrac kosztow stalych:",e),this.fixedCosts=[]}finally{this.isFixedCostsLoading=!1}}async loadEmployeeCosts(){if(!this.db||!this.isAdmin){this.employeeCostConfigs={};return}try{let e=await G(L(this.db,$t)),t={};e.docs.forEach(n=>{let i=n.data(),o=String(i.uid??n.id).trim()||n.id;o&&(t[o]={uid:o,employmentCostType:Ie(i.employmentCostType),previousEmploymentCostType:Ie(i.previousEmploymentCostType),employmentCostTypeEffectiveFrom:String(i.employmentCostTypeEffectiveFrom??"").trim(),monthlyEmploymentCost:this.numberOrNull(i.monthlyEmploymentCost),hourlyRate:this.numberOrNull(i.hourlyRate),monthlyHours:this.numberOrNull(i.monthlyHours)})}),this.employeeCostConfigs=t}catch(e){console.warn("Nie udalo sie pobrac kosztow pracownikow:",e),this.employeeCostConfigs={}}}async loadCurrentEmploymentCost(){if(!this.db||!this.currentUserUid){this.currentEmploymentCostType=Ee(this.isActualAdmin,"brak");return}try{let e=await te(N(this.db,$t,this.currentUserUid));if(!e.exists()){this.currentEmploymentCostType=Ee(this.isActualAdmin,"brak");return}let t=e.data(),n=Ie(t.employmentCostType);this.currentEmploymentCostType=Ee(this.isActualAdmin,n)}catch(e){console.warn("Nie udalo sie pobrac typu rozliczenia pracownika:",e),this.currentEmploymentCostType=Ee(this.isActualAdmin,"brak")}}async loadMonthlyWorkReportFiles(){if(!this.db||!this.currentUserUid||!this.canSendMonthlyWorkReport){this.monthlyWorkReportFiles=[];return}try{let e=await G(ee(L(this.db,Qe),ie("reporterUid","==",this.currentUserUid),ie("monthKey","==",this.selectedMonthKey)));this.monthlyWorkReportFiles=e.docs.map(t=>{let n=t.data();return{id:t.id,monthKey:String(n.monthKey??"").trim(),reporterUid:String(n.reporterUid??"").trim(),reporterEmail:String(n.reporterEmail??"").trim(),name:String(n.name??"").trim(),fileName:String(n.fileName??"").trim(),mime:String(n.mime??"").trim(),size:this.numberOrZero(n.size),url:String(n.url??"").trim(),storagePath:String(n.storagePath??"").trim(),createdAtLabel:this.formatDateTime(n.createdAt)}}).sort((t,n)=>n.createdAtLabel.localeCompare(t.createdAtLabel,"pl"))}catch(e){console.warn("Nie udalo sie pobrac miesiecznych raportow pracy:",e),this.monthlyWorkReportFiles=[],this.error="Nie udalo sie pobrac miesiecznych raportow pracy."}}
2async refreshExistingReportFlag(){if(!this.db||!this.currentUserUid||!this.activeReporterUid){this.isEditingExistingReport=!1;return}try{let e=await te(N(this.db,oe,this.reportDocId()));this.isEditingExistingReport=e.exists()}catch{this.isEditingExistingReport=!1}}async loadReportForDate(){if(!this.db||!this.currentUserUid)return;let e=this.buildReportFormKey(this.reportDate,this.activeReporterUid);if(!this.activeReporterUid){this.resetReportForm(),this.isEditingExistingReport=!1,this.reportModalMode="append",this.reportFormContextKey=e,this.lastPersistedDraftSnapshot=this.currentReportDraftSnapshot();return}this.error="",this.info="";try{let t=await te(N(this.db,oe,this.reportDocId()));if(this.restoreReportDraftForKey(e)){this.reportFormContextKey=e,this.lastPersistedDraftSnapshot=this.currentReportDraftSnapshot();return}if(!t.exists()){this.resetReportForm(),this.isEditingExistingReport=!1,this.reportModalMode="append",this.reportFormContextKey=e,this.isReportModalOpen&&await this.prefillReportFromBooksy(),this.lastPersistedDraftSnapshot=this.currentReportDraftSnapshot();return}let n=t.data(),i=Array.isArray(n.clients)?n.clients:[];this.clients=i.length?i.map((o,d)=>{let m=String(o.clientName??"").trim(),_=String(o.customerId??"").trim(),g=this.resolveStoredClientCustomer(_,m,String(o.clientPhone??""));return{customerId:g?.id??_,customerQuery:g?this.customerOptionLabel(g):this.normalizeEditableClientName(m,d)||this.formatPhone(String(o.clientPhone??"")),clientName:g?.fullName??this.normalizeEditableClientName(m,d),amount:this.numberOrNull(o.amount),clientPhone:this.formatPhone(g?.phone??String(o.clientPhone??"")),serviceName:String(o.serviceName??"").trim(),hours:this.numberOrNull(o.reportedHours??o.hours),paymentMethod:this.canUseNoRecord&&o.noRecord?"cash":this.normalizePaymentMethod(o.paymentMethod),noRecord:this.canUseNoRecord&&this.normalizePaymentMethod(o.paymentMethod)==="cash"&&!!o.noRecord,hasDiscount:!1,discountAmount:null,usedVoucher:this.normalizePaymentMethod(o.paymentMethod)==="voucher"||!!o.usedVoucher,voucherAmount:this.numberOrNull(o.voucherAmount),voucherCode:this.normalizeVoucherCode(o.voucherCode),voucherLookupState:"idle",voucherLookupRequestId:0,voucherLookupTimerId:null,pendingCustomerName:"",pendingCustomerPhone:"",isCustomerCreateOpen:!1,customerSuggestions:[],isCustomerSuggestionsOpen:!1,serviceSuggestions:[],isServiceSuggestionsOpen:!1,anonymous:!!o.anonymous,serviceSelectedFromCatalog:!!String(o.serviceName??"").trim(),booksyProposal:this.extractBooksyProposal(o.booksyProposal),isTimeReservation:!!o.isTimeReservation||ge(o.serviceName,o.clientName)}}):[this.createEmptyClient()],this.booksyProposals=this.extractBooksyProposals(n.booksyProposals,this.extractStoredClients(n.clients)),this.expenses=this.extractStoredExpenses(n.expenses,this.reportDocId()),this.hadOrders=!!n.hadOrders,this.ordersCost=this.numberOrNull(n.ordersCost),this.ordersPaymentMethod=this.normalizeOrdersPaymentMethod(n),this.isEditingExistingReport=!0,this.reportModalMode="edit",this.clearReportDraftForKey(e),this.reportFormContextKey=e,this.lastPersistedDraftSnapshot=this.currentReportDraftSnapshot(),this.refreshVoucherLookups()}catch(t){console.warn("Nie udalo sie pobrac raportu:",t),this.error="Nie udalo sie pobrac raportu dla wybranej daty."}}async loadExpenseFormForDate(){if(!(!this.db||!this.currentUserUid)){if(!this.activeReporterUid){this.resetExpenseForm();return}try{let e=await te(N(this.db,oe,this.reportDocId()));if(!e.exists()){this.resetExpenseForm();return}let t=e.data();this.expenses=this.extractStoredExpenses(t.expenses,this.reportDocId()),this.expenses.length||(this.expenses=[this.createEmptyExpense()]),this.hadOrders=this.numberOrZero(t.ordersCost)>0||!!t.hadOrders,this.ordersCost=this.numberOrNull(t.ordersCost),this.ordersPaymentMethod=this.normalizeOrdersPaymentMethod(t),this.pruneSelectedExpenseAttachmentFiles(this.expenses),await this.loadExpenseAttachments()}catch(e){console.warn("Nie udalo sie pobrac wydatkow:",e),this.error="Nie udalo sie pobrac zamowien i wydatkow dla wybranej daty.",this.expenseAttachmentsByExpenseId={}}}}
2async loadDayDetails(e){if(!this.db||!this.currentUserUid){this.selectedDayDetails=[];return}try{let t=this.isAdmin?G(L(this.db,oe)):G(ee(L(this.db,oe),ie("reporterUid","==",this.currentUserUid))),n=this.isAdmin?G(ee(L(this.db,Ut),ie("dateKey","==",e))):Promise.resolve(null),i=this.isAdmin?G(ee(L(this.db,"terminalPayments"),ie("authDateKey","==",e))):Promise.resolve(null),[o,d,m]=await Promise.all([t,n,i]),_=d?d.docs.map(g=>Q({__docId:g.id},g.data())):[];this.selectedDayTerminalPayments=m?m.docs.map(g=>{let h=g.data();return{id:g.id,authDate:String(h.authDate??""),authDateKey:String(h.authDateKey??""),authDateSortKey:String(h.authDateSortKey??""),amount:this.numberOrZero(h.amount),currency:String(h.currency??"PLN"),status:String(h.status??""),maskedCardNumber:String(h.maskedCardNumber??""),brand:String(h.brand??""),authCode:String(h.authCode??""),merchantTransactionId:String(h.merchantTransactionId??""),matchedReportId:String(h.matchedReportId??""),matchedComparisonRowId:String(h.matchedComparisonRowId??"")}}).sort((g,h)=>(g.authDateSortKey||g.authDate).localeCompare(h.authDateSortKey||h.authDate,"pl")):[],this.selectedDayDetails=o.docs.map(g=>{let h=g.data(),x=String(h.reporterUid??"").trim(),M=String(h.dateKey??"").trim();if(M!==e||this.isAdmin&&this.selectedReporterUid&&x!==this.selectedReporterUid)return null;let D=Array.isArray(h.clients)?h.clients:[],C=this.extractStoredClients(h.clients),y=String(h.reporterDisplayName??"").trim(),f=y||this.reporterOptions.find(R=>R.uid===x)?.displayName||"",A=this.extractBooksyProposals(h.booksyProposals,C),O=new Map(_.filter(R=>String(R.source??"")==="booksy").map(R=>[String(R.booksyAppointmentId??R.__docId??"").trim(),R]).filter(([R])=>!!R)),F=_.filter(R=>String(R.source??"")==="booksy").sort((R,V)=>{let ne=!Number.isNaN(new Date(String(R.startAt??"")).getTime()),le=!Number.isNaN(new Date(String(V.startAt??"")).getTime());return Number(le)-Number(ne)}),q=new Set,K=A.filter(R=>{let V=O.get(R.appointmentId);return!V||!Oe(V.booksyStatus)}).map(R=>{let V=O.get(R.appointmentId),ne=B(R.clientName),le=B(R.serviceName),ve=this.normalizePhone(R.clientPhone),ce=F.filter(Y=>{let Te=String(Y.booksyAppointmentId??Y.__docId??"").trim(),k=this.normalizePhone(String(Y.booksyClientPhone??""));return!q.has(Te)&&(B(Y.booksyClientName)===ne||!!(ve&&k&&ve===k))&&!Oe(Y.booksyStatus)}),_e=(V&&!Number.isNaN(new Date(String(V.startAt??"")).getTime())?V:void 0)||ce.find(Y=>De(String(Y.booksyEmployee??""),f)&&B(Y.booksyService)===le)||ce.find(Y=>De(String(Y.booksyEmployee??""),f))||ce.find(Y=>B(Y.booksyService)===le)||ce[0]||V,be=String(_e?.booksyAppointmentId??_e?.__docId??"").trim();if(be&&q.add(be),!Number.isNaN(new Date(R.startAt).getTime()))return R;let Ne=String(_e?.startAt??"").trim();return Number.isNaN(new Date(Ne).getTime())?R:de(Q({},R),{startAt:Ne})}),se=K.length?[]:this.booksyProposalsForReporter(_,f),X=K.length?K:se,ye=X.length;return{id:g.id,dateKey:M,reporterUid:x,reporterEmail:String(h.reporterEmail??x).trim()||"Nieznany pracownik",reporterDisplayName:y,clients:C,booksyProposals:X,expenses:this.extractStoredExpenses(h.expenses,g.id),hadOrders:!!h.hadOrders,ordersCost:this.numberOrZero(h.ordersCost),ordersPaymentMethod:String(h.ordersPaymentMethod??"").trim(),cashAmount:D.reduce((R,V)=>this.normalizePaymentMethod(V.paymentMethod)==="cash"?R+Math.max(0,this.numberOrZero(V.amount)):R,0),cardAmount:D.reduce((R,V)=>this.normalizePaymentMethod(V.paymentMethod)==="card"?R+Math.max(0,this.numberOrZero(V.amount)):R,0),unrecordedAmount:this.numberOrZero(h.unrecordedAmount),totals:{clientAmount:this.numberOrZero(h.totals?.clientAmount),discountAmount:this.numberOrZero(h.totals?.discountAmount),voucherAmount:this.numberOrZero(h.totals?.voucherAmount)},createdAtLabel:this.formatDateTime(h.createdAt),updatedAtLabel:this.formatDateTime(h.updatedAt),settlementApprovalStatus:this.normalizeSettlementApprovalStatus(h.settlementApprovalStatus,A.length),settlementApprovedAtLabel:this.formatDateTime(h.settlementApprovedAt),settlementApprovedByLabel:String(h.settlementApprovedByEmail??h.settlementApprovedByUid??"").trim(),booksyProposalCount:ye}}).filter(g=>!!g).sort((g,h)=>
2ae(g.reporterDisplayName,g.reporterEmail,g.reporterUid).localeCompare(ae(h.reporterDisplayName,h.reporterEmail,h.reporterUid),"pl"))}catch(t){console.warn("Nie udalo sie pobrac szczegolow raportu dnia:",t),this.selectedDayDetails=[],this.selectedDayTerminalPayments=[],this.error="Nie udalo sie pobrac szczegolow raportu."}finally{this.zone.run(()=>this.cdr.detectChanges())}}async loadMonthView(){if(!(!this.db||!this.currentUserUid)){this.isMonthlyLoading=!0;try{let e=`${this.selectedMonthKey}-01`,t=this.daysInMonth(this.selectedMonthKey),n=`${this.selectedMonthKey}-${String(t).padStart(2,"0")}`,i=this.selectedWeekStartKey,o=this.addDaysToDateKey(i,6),d=this.isAdmin?await G(L(this.db,oe)):await G(ee(L(this.db,oe),ie("reporterUid","==",this.currentUserUid))),m={};for(let C=1;C<=t;C+=1){let y=`${this.selectedMonthKey}-${String(C).padStart(2,"0")}`;m[y]={dateKey:y,dayNumber:C,dayLabel:this.weekdayShort(y),reportCount:0,gross:0,cash:0,card:0,hours:0,recorded:0,unrecorded:0,discount:0,voucher:0,reporterEmails:[],phones:[],phoneCount:0,missingPhoneCount:0,pendingSettlementCount:0,segments:[]}}let _={};for(let C=0;C<7;C+=1){let y=this.addDaysToDateKey(i,C);_[y]={dateKey:y,dayNumber:Number(y.slice(-2)),dayLabel:this.weekdayShort(y),reportCount:0,gross:0,cash:0,card:0,hours:0,recorded:0,unrecorded:0,discount:0,voucher:0,reporterEmails:[],phones:[],phoneCount:0,missingPhoneCount:0,pendingSettlementCount:0,segments:[]}}let g=this.emptyMonthlySummary(),h={},x=new Map,M=0;d.docs.forEach(C=>{let y=C.data(),f=String(y.dateKey??"");if(!f||(f<e||f>n)&&(f<i||f>o))return;let A=String(y.reporterUid??""),O=ae(y.reporterDisplayName,y.reporterEmail??A,A);if(this.isAdmin&&this.selectedReporterUid&&A!==this.selectedReporterUid)return;let F=y.totals??{},q=Array.isArray(y.clients)?y.clients:[],K=q.filter(k=>!k.isTimeReservation),se=K.length>0,X=this.numberOrZero(F.clientAmount),ye=q.reduce((k,$)=>k+Math.max(0,this.numberOrZero($.hours)),0),R=q.reduce((k,$)=>this.normalizePaymentMethod($.paymentMethod)!=="cash"?k:k+Math.max(0,this.numberOrZero($.amount)),0),V=q.reduce((k,$)=>this.normalizePaymentMethod($.paymentMethod)!=="card"?k:k+Math.max(0,this.numberOrZero($.amount)),0),ne=K.map(k=>this.formatPhone(String(k.clientPhone??""))).filter(k=>k&&k.trim().length>0),le=K.length-ne.length,ve=this.numberOrZero(y.recordedAmount),ce=this.numberOrZero(y.unrecordedAmount),_e=this.numberOrZero(F.discountAmount),be=this.numberOrZero(F.voucherAmount),Ne=this.extractBooksyProposals(y.booksyProposals,this.extractStoredClients(y.clients)).length,Y=this.normalizeSettlementApprovalStatus(y.settlementApprovalStatus,Ne),Te=k=>{k&&(se&&(k.reportCount+=1),k.gross+=X,k.cash+=R,k.card+=V,k.hours+=ye,k.recorded+=ve,k.unrecorded+=ce,k.discount+=_e,k.voucher+=be,ne.forEach($=>{k.phones.includes($)||k.phones.push($)}),k.phoneCount=k.phones.length,k.missingPhoneCount+=Math.max(0,le),Y==="pending"&&(k.pendingSettlementCount+=1),O&&!k.reporterEmails.includes(O)&&k.reporterEmails.push(O))};if(Te(m[f]),Te(_[f]),f>=e&&f<=n&&(q.forEach(k=>{let $=this.extractHourlySettlementSource(f,k);if($==="missing-duration"){M+=1;return}if(!$)return;let Ye=`${$.dateKey}__${this.normalizeServiceSearch($.serviceLabel)}`,Le=x.get(Ye);if(Le){Le.durationMinutes+=$.durationMinutes,Le.amount+=$.amount;return}x.set(Ye,{dateKey:$.dateKey,serviceLabel:$.serviceLabel,durationMinutes:$.durationMinutes,amount:$.amount})}),se&&(g.reportCount+=1),g.gross+=X,g.hours+=ye,g.recorded+=ve,g.unrecorded+=ce,g.discount+=_e,g.voucher+=be,this.isAdmin)){h[A]||(h[A]={uid:A||"unknown",email:O||"Nieznany user",reportCount:0,gross:0,hours:0,recorded:0,unrecorded:0,discount:0,voucher:0,employmentCostType:"brak",monthlyEmploymentCost:null,hourlyRate:null,monthlyHours:null,employeeCostTotal:0});let k=h[A];se&&(k.reportCount+=1),k.gross+=X,k.hours+=ye,k.recorded+=ve,k.unrecorded+=ce,k.discount+=_e,k.voucher+=be}}),this.isAdmin&&this.reporterOptions.filter(y=>this.selectedReporterUid?y.uid===this.selectedReporterUid:!0).forEach(y=>{h[y.uid]||(h[y.uid]={uid:y.uid,email:y.email,reportCount:0,gross:0,hours:0,recorded:0,unrecorded:0,discount:0,voucher:0,employmentCostType:"brak",monthlyEmploymentCost:null,hourlyRate:null,monthlyHours:null,employeeCostTotal:0})});let D=this.isAdmin?this.fixedCosts.filter(C=>Ot(C)).reduce((C,y)=>C+y.amount,0):0;g.fixedCosts=D,g.afterFixedCosts=g.gross-D,this.monthViewDays=Object.values(m).sort((C,y)=>C.dateKey.localeCompare(y.dateKey,"pl")).map(C=>de(Q({},C),{reporterEmails:C.reporterEmails.sort((y,f)=>y.localeCompare(f,"pl")),segments:this.buildDaySegments(C)})),this.weekViewDays=Object.values(_).sort((C,y)=>C.dateKey.localeCompare(y.dateKey,"pl")).map(C=>de(Q({},C),{reporterEmails:C.reporterEmails.sort((y,f)=>y.localeCompare(f,"pl")),segments:this.buildDaySegments(C)})),this.employeeMonthSummaries=Object.values(h).map(C=>this.applyEmployeeCostConfig(C)).sort((C,y)=>C.email.localeCompare(y.email,"pl")),g.employeeCosts=this.isAdmin?this.employeeMonthSummaries.reduce((C,y)=>C+y.employeeCostTotal,0):0,g.afterAllCosts=g.gross-D-g.employeeCosts,this.monthlySummary=g,this.hourlySettlementRows=this.buildHourlySettlementRows(x),this.hourlySettlementMissingDurationCount=M}catch(e){console.warn("Nie udalo sie pobrac widoku miesiaca:",e),this.monthViewDays=[],this.weekViewDays=[],this.monthlySummary=this.emptyMonthlySummary(),this.employeeMonthSummaries=[],this.hourlySettlementRows=[],this.hourlySettlementMissingDurationCount=0}finally{this.isMonthlyLoading=!1,this.cdr.detectChanges()}}}buildDaySegments(e){let t=(n,i)=>i<=0?null:{kind:n,amount:i,heightPx:this.scaleAmountToPx(i)};return[t("cash",e.cash),t("unrecorded",e.unrecorded),t("card",e.card),t("voucher",e.voucher)].filter(n=>!!n)}roundChartScaleMax(e){return e<=0?100:e<=500?Math.ceil(e/100)*100:e<=2e3?Math.ceil(e/250)*250:e<=5e3?Math.ceil(e/500)*500:Math.ceil(e/1e3)*1e3}scaleAmountToPx(e){let t=e/100*Yi,n=Math.max(8,Math.round(t));return Math.min(520,n)}daysInMonth(e){let[t,n]=e.split("-").map(i=>Number(i));return!t||!n?30:new Date(t,n,0).getDate()}buildMonthOptions(e){let t=new Date,n=[];for(let i=0;i<=e;i+=1){let o=new Date(t.getFullYear(),t.getMonth()-i,1),d=`${o.getFullYear()}
2-${String(o.getMonth()+1).padStart(2,"0")}`;n.push({key:d,label:this.formatMonthLabel(o)})}return n}formatMonthLabel(e){let t=e.toLocaleDateString("pl-PL",{month:"long"}),n=e.getFullYear();return`${t} ${n}`}currentMonthKey(){let e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}emptyMonthlySummary(){return{reportCount:0,gross:0,hours:0,recorded:0,unrecorded:0,discount:0,voucher:0,fixedCosts:0,employeeCosts:0,afterFixedCosts:0,afterAllCosts:0}}applyEmployeeCostConfig(e){let t=this.employeeCostConfigs[e.uid],n=de(Q({},e),{employmentCostType:t?wt(t.employmentCostType,this.selectedMonthKey,t.previousEmploymentCostType,t.employmentCostTypeEffectiveFrom):"brak",monthlyEmploymentCost:t?.monthlyEmploymentCost??null,hourlyRate:t?.hourlyRate??null,monthlyHours:t?.monthlyHours??null,employeeCostTotal:0});return n.employeeCostTotal=this.calculateEmployeeCostTotal(n),n}calculateEmployeeCostTotal(e){return e.employmentCostType==="zlecenie"?this.numberOrZero(e.hourlyRate)*e.hours:e.employmentCostType==="zlecenie45"||e.employmentCostType==="zlecenie50"||e.employmentCostType==="zlecenie50plus55"?kt(e.gross,e.employmentCostType):e.employmentCostType==="brak"?0:this.numberOrZero(e.monthlyEmploymentCost)}segmentLabel(e){return e==="cash"?"Gotowka":e==="unrecorded"?"Gotowka (brak ewidencji)":e==="card"?"Karta":"Voucher"}buildSaveInfoMessage(e){return this.reportModalMode==="edit"?"Korekta raportu zapisana.":e?"Pozycje zostaly dodane do raportu dziennego.":"Raport dzienny zapisany."}calculateReportTotals(e){return e.reduce((t,n)=>{let i=Math.max(0,n.amount??0),o=n.hasDiscount?Math.max(0,n.discountAmount??0):0,d=n.usedVoucher?Math.max(0,n.voucherAmount??0):0;return t.clientAmount+=i,t.discountAmount+=o,t.voucherAmount+=d,n.noRecord?t.unrecordedAmount+=i:t.recordedAmount+=i,t},{clientAmount:0,discountAmount:0,voucherAmount:0,recordedAmount:0,unrecordedAmount:0})}extractStoredClients(e){return Array.isArray(e)?e.map((t,n)=>{let i=t,o=this.normalizePaymentMethod(i.paymentMethod);return{customerId:String(i.customerId??"").trim(),clientName:String(i.clientName??`Klient ${n+1}`),amount:this.numberOrNull(i.amount),clientPhone:this.normalizePhone(String(i.clientPhone??"")),serviceName:String(i.serviceName??"").trim(),serviceDuration:String(i.serviceDuration??"").trim(),serviceDurationMinutes:this.numberOrNull(i.serviceDurationMinutes),hours:this.numberOrNull(i.hours),reportedHours:this.numberOrNull(i.reportedHours??i.hours),paymentMethod:i.noRecord?"cash":o,noRecord:o==="cash"&&!!i.noRecord,hasDiscount:!!i.hasDiscount,discountAmount:this.numberOrNull(i.discountAmount),usedVoucher:o==="voucher"||!!i.usedVoucher,voucherAmount:this.numberOrNull(i.voucherAmount),voucherCode:this.normalizeVoucherCode(i.voucherCode),booksyProposal:this.extractBooksyProposal(i.booksyProposal),isTimeReservation:!!i.isTimeReservation||ge(i.serviceName,i.clientName),voucherLookupState:"idle",voucherLookupRequestId:0,voucherLookupTimerId:null}}):[]}extractBooksyProposal(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,n=String(t.appointmentId??"").trim();return n?{appointmentId:n,startAt:String(t.startAt??"").trim(),clientName:String(t.clientName??"").trim(),clientPhone:this.normalizePhone(String(t.clientPhone??"")),serviceName:String(t.serviceName??"").trim(),amount:this.numberOrNull(t.amount),hours:this.numberOrNull(t.hours),paymentMethod:this.normalizePaymentMethod(t.paymentMethod),isTimeReservation:!!t.isTimeReservation||ge(t.serviceName,t.clientName)}:null}extractBooksyProposals(e,t=[]){let n=Array.isArray(e)?e.map(o=>this.extractBooksyProposal(o)).filter(o=>!!o):[],i=t.map(o=>o.booksyProposal).filter(o=>!!o);return this.mergeBooksyProposals([],n.length?n:i)}booksyProposalsForReporter(e,t){if(!t.trim())return[];let n=e.map(i=>{if(String(i.source??"")!=="booksy")return null;let o=String(i.details??""),d=String(i.booksyEmployee??""),m=String(i.booksyStatus??"");if(!De(d,t)||Oe(m))return null;let _=String(i.booksyClientName??"").trim(),g=String(i.booksyService??"").trim(),h=ge(g,_);if(!_&&!h||!g)return null;let x=this.findServiceSuggestionForBooksy(g),M={id:String(i.booksyAppointmentId??i.__docId??"").trim(),details:o,startAt:String(i.startAt??""),endAt:String(i.endAt??""),booksyEmployee:d,booksyClientName:_,booksyClientPhone:String(i.booksyClientPhone??"")||this.booksyDetailValue(o,"Telefon:"),booksyService:g,booksyStatus:m,booksyPrice:String(i.booksyPrice??"")||this.booksyDetailValue(o,"Warto\u015B\u0107 us\u0142ug:"),booksyDuration:String(i.booksyDuration??"")||this.booksyDetailValue(o,"Czas trwania:"),booksyPaymentMethod:String(i.booksyPaymentMethod??"")||this.booksyDetailValue(o,"Metoda p\u0142atno\u015Bci:")};return M.id?{appointmentId:M.id,startAt:M.startAt,clientName:h?"Rezerwacja czasu Booksy":M.booksyClientName,clientPhone:this.normalizePhone(M.booksyClientPhone),serviceName:M.booksyService,amount:Ze(M.booksyPrice)??(x?this.parseCatalogPrice(
2x.price):null),hours:this.booksyDurationHours(M,x),paymentMethod:He(M.booksyPaymentMethod),isTimeReservation:h}:null}).filter(i=>!!i);return this.mergeBooksyProposals([],n)}mergeBooksyProposals(e,t){let n=new Map;return[...e,...t].forEach(i=>{i.appointmentId&&n.set(i.appointmentId,Q({},i))}),Array.from(n.values()).sort((i,o)=>i.startAt.localeCompare(o.startAt))}normalizeSettlementApprovalStatus(e,t){return t?e==="approved"?"approved":"pending":"not_required"}sameNullableNumber(e,t){return e===null||t===null?e===t:Math.abs(e-t)<.005}extractStoredExpenses(e,t=this.reportDocId()){return Array.isArray(e)?e.map((n,i)=>{let o=n;return{id:this.readExpenseId(o,t,i),label:String(o.label??"").trim(),cost:this.numberOrNull(o.cost),paymentMethod:o.paymentMethod==="card"?"card":"cash"}}):[]}extractStoredOrdersCashCost(e){if(!e)return 0;let t=this.numberOrZero(e.ordersCashCost);return t>0?t:e.hadOrders&&e.ordersPaymentMethod==="cash"?this.numberOrZero(e.ordersCost):0}extractStoredOrdersCardCost(e){if(!e)return 0;let t=this.numberOrZero(e.ordersCardCost);return t>0?t:e.hadOrders&&e.ordersPaymentMethod==="card"?this.numberOrZero(e.ordersCost):0}normalizeOrdersPaymentMethod(e){let t=String(e.ordersPaymentMethod??"").trim();if(t==="card")return"card";if(t==="cash")return"cash";let n=this.numberOrZero(e.ordersCashCost);return this.numberOrZero(e.ordersCardCost)>0&&n<=0?"card":"cash"}normalizePaymentMethod(e){return e==="card"?"card":e==="voucher"?"voucher":"cash"}normalizeServiceSearch(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g," ").trim()}parseCatalogPrice(e){let t=e.replace(/\s+/g,"").replace(/z[lł]/gi,"").replace(",",".").trim();if(!t)return null;let n=Number(t);return!Number.isFinite(n)||n<=0?null:Math.round(n*100)/100}async syncVoucherNotes(e){if(!this.db||!this.currentUserUid)return[];let t=[],n={};for(let i=0;i<e.length;i+=1){let o=e[i];if(!o.usedVoucher)continue;let d=o.voucherCode.trim().toUpperCase();if(!d)continue;if(!n[d]){let g=await te(N(this.db,Ge,d));n[d]=g.exists()}if(!n[d]){t.includes(d)||t.push(d);continue}let m=N(this.db,Ge,d,"notes",`report-${this.reportDocId()}-${i+1}`),_=[];_.push(`Raport dzienny ${this.reportDate}`),_.push(`Klient ${i+1}`),o.serviceName&&_.push(`Usluga: ${o.serviceName}`),_.push(`Platnosc: ${this.paymentMethodLabel(o.paymentMethod).toLowerCase()}`),o.hasDiscount&&(o.discountAmount??0)>0&&_.push(`Znizka: ${o.discountAmount} zl`),_.push(`Voucher: ${o.voucherAmount??0} zl`),await J(m,{text:_.join(". "),amount:o.voucherAmount??null,reportId:this.reportDocId(),reportDate:this.reportDate,source:"daily-report",createdAt:U(),createdByEmail:this.currentUserEmail,createdByUid:this.currentUserUid},{merge:!0})}return t}async syncReferralPoints(e,t){if(!this.db||!this.currentUserUid)return{rewards:[],totalPoints:0,assignedCount:0,unmatchedPhones:[]};let n=await G(L(this.db,Ae)),i=new Map;n.docs.forEach(C=>{let y=C.data();if(y.deleted===!0)return;let f=String(y.referralCode??"").trim(),A=String(y.displayName??"").trim();this.extractPhoneArray(y.referredPhones).forEach(F=>{i.has(F)||i.set(F,{id:C.id,displayName:A,referralCode:f})})});let o=[],d=[];e.forEach((C,y)=>{let f=this.normalizePhone(C.clientPhone),A=Math.max(0,C.amount??0);if(!f||A<=0)return;let O=i.get(f);if(!O){d.includes(f)||d.push(f);return}let F=Math.ceil(A*.1);F<=0||o.push({rewardKey:`client-${y+1}`,ambassadorId:O.id,ambassadorName:O.displayName,referralCode:O.referralCode,clientPhone:f,clientName:C.clientName||`Klient ${y+1}`,grossAmount:A,points:F})});let m=new Map(t.map(C=>[C.rewardKey,C])),_=new Map(o.map(C=>[C.rewardKey,C])),g=Array.from(new Set([...m.keys(),..._.keys()])),h=new Map,x=[],M=[],D=new Set;return g.forEach(C=>{let y=m.get(C),f=_.get(C);y&&(!f||y.ambassadorId!==f.ambassadorId||y.points!==f.points)&&(h.set(y.ambassadorId,(h.get(y.ambassadorId)??0)-y.points),x.push({ambassadorId:y.ambassadorId,rewardKey:C}),D.add(y.ambassadorId)),f&&((!y||y.ambassadorId!==f.ambassadorId||y.points!==f.points||y.grossAmount!==f.grossAmount||y.clientPhone!==f.clientPhone||y.clientName!==f.clientName)&&(M.push(f),D.add(f.ambassadorId)),(!y||y.ambassadorId!==f.ambassadorId||y.points!==f.points)&&h.set(f.ambassadorId,(h.get(f.ambassadorId)??0)+f.points))}),(h.size||x.length||M.length)&&(await mt(this.db,async C=>{let y=new Map;for(let f of D){let A=N(this.db,Ae,f),O=await C.get(A);if(!O.exists())throw new Error(`Nie znaleziono ambasadora: ${f}.`);y.set(f,{ref:A,data:O.data()})}
2h.forEach((f,A)=>{if(!f)return;let O=y.get(A);if(!O)return;let F=this.numberOrZero(O.data.pointsBalance);O.data.pointsBalance=F+f,C.update(O.ref,{pointsBalance:F+f,updatedAt:U(),updatedByUid:this.currentUserUid,updatedByEmail:this.currentUserEmail})}),x.forEach(f=>{C.delete(N(this.db,Ae,f.ambassadorId,Wt,this.referralPointEntryId(f.rewardKey)))}),M.forEach(f=>{C.set(N(this.db,Ae,f.ambassadorId,Wt,this.referralPointEntryId(f.rewardKey)),{delta:f.points,note:`Polecenie klienta ${f.clientName}. Telefon: ${this.formatPhone(f.clientPhone)}. Brutto: ${f.grossAmount.toFixed(2)} zl.`,source:"daily-report-referral",reportId:this.reportDocId(),reportDate:this.reportDate,rewardKey:f.rewardKey,clientPhone:f.clientPhone,clientName:f.clientName,grossAmount:f.grossAmount,createdAt:U(),createdByUid:this.currentUserUid,createdByEmail:this.currentUserEmail},{merge:!0})})}),await Promise.all(Array.from(D).map(C=>this.syncPublicCardPoints(C)))),{rewards:o,totalPoints:o.reduce((C,y)=>C+y.points,0),assignedCount:o.length,unmatchedPhones:d}}extractReferralRewards(e){return Array.isArray(e)?e.map(t=>{let n=t,i=String(n.rewardKey??"").trim(),o=String(n.ambassadorId??"").trim(),d=String(n.referralCode??"").trim(),m=this.normalizePhone(String(n.clientPhone??"")),_=this.numberOrZero(n.points),g=this.numberOrZero(n.grossAmount);return!i||!o||!m||_<=0?null:{rewardKey:i,ambassadorId:o,ambassadorName:String(n.ambassadorName??"").trim(),referralCode:d,clientPhone:m,clientName:String(n.clientName??"").trim()||i,grossAmount:g,points:_}}).filter(t=>t!==null):[]}async syncPublicCardPoints(e){if(!this.db)return;let t=await te(N(this.db,Ae,e));if(!t.exists())return;let n=t.data(),i=String(n.referralCode??"").trim();i&&await J(N(this.db,qi,i),{ambassadorId:e,referralCode:i,displayName:String(n.displayName??""),cardTitle:String(n.cardTitle??`Ambasador: ${String(n.displayName??"")}`),cardSubtitle:String(n.cardSubtitle??"Polecam Asami"),shareMessage:String(n.shareMessage??""),pointsBalance:this.numberOrZero(n.pointsBalance),updatedAt:U()},{merge:!0})}referralPointEntryId(e){return`auto-referral-${this.reportDocId()}-${e}`}extractPhoneArray(e){return Array.isArray(e)?e.map(t=>this.normalizePhone(String(t??""))).filter(t=>
2!!t).filter((t,n,i)=>i.indexOf(t)===n).sort((t,n)=>t.localeCompare(n,"pl")):[]}normalizePhone(e){return Re(e)?.canonicalDigits??""}addDaysToDateKey(e,t){let[n,i,o]=e.split("-").map(m=>Number(m)),d=new Date(n,(i||1)-1,o||1);return d.setDate(d.getDate()+t),this.formatDateKeyLocal(d)}startOfWeekKey(e){let[t,n,i]=e.split("-").map(_=>Number(_)),o=new Date(t,(n||1)-1,i||1),d=o.getDay(),m=d===0?-6:1-d;return o.setDate(o.getDate()+m),this.formatDateKeyLocal(o)}isDateInMonth(e,t){return e.startsWith(`${t}-`)}formatDisplayDate(e){let[t,n,i]=e.split("-").map(d=>Number(d));return new Date(t,(n||1)-1,i||1).toLocaleDateString("pl-PL",{day:"2-digit",month:"2-digit",year:"numeric"})}weekdayShort(e){let[t,n,i]=e.split("-").map(d=>Number(d));return new Date(t,(n||1)-1,i||1).toLocaleDateString("pl-PL",{weekday:"short"})}formatPhone(e){return At(e)}extractHourlySettlementSource(e,t){if(!this.canShowHourlySettlementSheet)return null;let n=Math.max(0,this.numberOrZero(t.amount));if(n<=0)return null;let i=String(t.serviceName??"").trim()||"Usluga",o=this.numberOrNull(t.serviceDurationMinutes),d=String(t.serviceDuration??"").trim(),m=this.findServiceSuggestionByName(i),_=o??this.parseServiceDurationMinutes(d)??m?.durationMinutes??this.parseServiceDurationMinutes(m?.duration)??null;return!_||_<=0?"missing-duration":{dateKey:e,serviceLabel:i,durationMinutes:_,amount:n}}buildHourlySettlementRows(e){let t=Array.from(e.values()).sort((d,m)=>{let _=d.dateKey.localeCompare(m.dateKey,"pl");return _!==0?_:d.serviceLabel.localeCompare(m.serviceLabel,"pl")}).map(d=>{let m=d.durationMinutes/60;return{id:`${d.dateKey}__${this.normalizeServiceSearch(d.serviceLabel)}`,dateKey:d.dateKey,dateLabel:this.formatDisplayDate(d.dateKey),serviceLabel:d.serviceLabel,durationMinutes:d.durationMinutes,durationHours:m,amount:d.amount,hourlyRate:m>0?d.amount/m:0,isSummary:!1}});if(!t.length)return[];let n=t.reduce((d,m)=>d+m.durationMinutes,0),i=t.reduce((d,m)=>d+m.amount,0),o=n/60;return t.push({id:"summary",dateKey:"summary",dateLabel:"Podsumowanie",serviceLabel:`${t.length} uslug, lacznie ${this.formatMoney(i)}`,durationMinutes:n,durationHours:o,amount:i,hourlyRate:o>0?i/o:0,isSummary:!0}),t}normalizeClients(){return this.clients.map(e=>{let t=this.normalizePaymentMethod(e.paymentMethod),n=this.canUseNoRecord&&t==="cash"&&e.noRecord,i=t==="voucher"||e.usedVoucher,o=this.normalizeVoucherCode(e.voucherCode),d=i&&e.voucherLookupState==="found",m=this.findServiceSuggestionByName(e.serviceName),_=m?.durationMinutes??this.parseServiceDurationMinutes(m?.duration)??(e.hours!==null&&e.hours>0?Math.round(e.hours*60):null),g=m?.duration||(_?this.formatDurationMinutes(_):"");return{customerId:e.customerId.trim(),amount:this.numberOrNull(e.amount),clientPhone:this.normalizePhone(e.clientPhone),serviceName:e.serviceName.trim(),serviceDuration:g,serviceDurationMinutes:_,hours:this.usesHourlySettlement?this.numberOrNull(e.hours):null,reportedHours:this.numberOrNull(e.hours),paymentMethod:n?"cash":t,noRecord:n,clientName:e.clientName.trim(),hasDiscount:!1,discountAmount:null,usedVoucher:i,voucherAmount:d?this.numberOrNull(e.voucherAmount):null,voucherCode:i?o:"",booksyProposal:e.booksyProposal?Q({},e.booksyProposal):null,isTimeReservation:e.isTimeReservation}}).map((e,t)=>de(Q({},e),{clientName:e.clientName||`Klient ${t+1}`})).filter(e=>e.amount!==null||e.usedVoucher)}normalizeExpenses(){return this.expenses.map(e=>({id:e.id?.trim()||this.createExpenseId(),label:e.label.trim(),cost:this.numberOrNull(e.cost),paymentMethod:e.paymentMethod==="card"?"card":"cash"})).filter(e=>e.label||e.cost!==null)}resetReportForm(){this.clearVoucherLookupTimers(this.clients),this.clients=[this.createEmptyClient()],this.booksyProposals=[],this.booksyPrefillInfo="",this.resetExpenseForm()}buildReportFormKey(e,t){let n=e.trim(),i=t.trim();return!n||!i?"":`${n}__${i}`}persistCurrentReportDraft(){let e=this.reportFormContextKey;if(e){if(!this.hasMeaningfulReportDraft()){this.clearReportDraftForKey(e);return}this.reportDraftsByKey[e]={clients:this.clients.map(t=>this.cloneClientEntry(t)),booksyProposals:this.booksyProposals.map(t=>Q({},t)),mode:this.reportModalMode,isEditingExistingReport:this.isEditingExistingReport},this.saveReportDraftsToStorage()}}restoreReportDraftForKey(e){if(!e)return!1;let t=this.reportDraftsByKey[e];return t?(this.clients=t.clients.length?t.clients.map(n=>this.cloneClientEntry(n)):[this.createEmptyClient()],this.booksyProposals=t.booksyProposals.map(n=>Q({},n)),this.isEditingExistingReport=t.isEditingExistingReport,this.reportModalMode=t.mode,this.lastPersistedDraftSnapshot=this.currentReportDraftSnapshot(),this.refreshVoucherLookups(),!0):!1}clearReportDraftForKey(e){e&&(delete this.reportDraftsByKey[e],this.saveReportDraftsToStorage(),e===this.reportFormContextKey&&(this.lastPersistedDraftSnapshot=""))}currentReportDraftSnapshot(){return JSON.stringify({clients:this.clients.map(e=>({customerId:e.customerId,customerQuery:e.customerQuery,clientName:e.clientName,amount:e.amount,clientPhone:e.clientPhone,serviceName:e.serviceName,hours:e.hours,paymentMethod:e.paymentMethod,noRecord:e.noRecord,hasDiscount:e.hasDiscount,discountAmount:e.discountAmount,usedVoucher:e.usedVoucher,voucherAmount:e.voucherAmount,voucherCode:e.voucherCode,booksyProposal:e.booksyProposal})),booksyProposals:this.booksyProposals,mode:this.reportModalMode,isEditingExistingReport:this.isEditingExistingReport})}saveReportDraftsToStorage(){if(!(typeof window>"u"))try{if(!Object.keys(this.reportDraftsByKey).length){window.localStorage.removeItem(qe);return}window.localStorage.setItem(qe,JSON.stringify(this.reportDraftsByKey))}catch(e){console.warn("Nie udalo sie zapisac szkicu raportu do localStorage:",e)}}loadReportDraftsFromStorage(){if(!(typeof window>"u"))try{let e=window.localStorage.getItem(qe);if(!e){this.reportDraftsByKey={};return}let t=JSON.parse(e),n={};Object.entries(t).forEach(([i,o])=>{let d=Array.isArray(o?.clients)?o.clients.map(m=>this.hydrateStoredClientDraft(m)).filter(m=>m!==null):[];n[i]={clients:d.length?d:[this.createEmptyClient()],booksyProposals:this.extractBooksyProposals(o?.booksyProposals,d),mode:o?.mode==="edit"?"edit":"append",
2isEditingExistingReport:!!o?.isEditingExistingReport}}),this.reportDraftsByKey=n}catch(e){console.warn("Nie udalo sie odczytac szkicow raportu z localStorage:",e),this.reportDraftsByKey={}}}hydrateStoredClientDraft(e){if(!e||typeof e!="object")return null;let t=String(e.serviceName??"").trim();return{customerId:String(e.customerId??"").trim(),customerQuery:String(e.customerQuery??"").trim(),clientName:String(e.clientName??"").trim(),amount:this.numberOrNull(e.amount),clientPhone:String(e.clientPhone??"").trim(),serviceName:t,hours:this.numberOrNull(e.hours),paymentMethod:this.normalizePaymentMethod(e.paymentMethod),noRecord:!!e.noRecord,hasDiscount:!1,discountAmount:null,usedVoucher:!!e.usedVoucher,voucherAmount:this.numberOrNull(e.voucherAmount),voucherCode:this.normalizeVoucherCode(e.voucherCode),voucherLookupState:"idle",voucherLookupRequestId:0,voucherLookupTimerId:null,pendingCustomerName:"",pendingCustomerPhone:"",isCustomerCreateOpen:!1,customerSuggestions:[],isCustomerSuggestionsOpen:!1,serviceSuggestions:[],isServiceSuggestionsOpen:!1,anonymous:!!e.anonymous,serviceSelectedFromCatalog:!!t,booksyProposal:this.extractBooksyProposal(e.booksyProposal),isTimeReservation:!!e.isTimeReservation||ge(e.serviceName,e.clientName)}}hasMeaningfulReportDraft(){return this.clients.some(e=>this.hasMeaningfulClientEntry(e))}hasMeaningfulClientEntry(e){return!!(e.customerQuery.trim()||e.clientName.trim()||e.clientPhone.trim()||e.serviceName.trim()||e.amount!==null||e.hours!==null||e.usedVoucher||e.voucherAmount!==null||e.voucherCode.trim())}cloneClientEntry(e){return{customerId:e.customerId,customerQuery:e.customerQuery,clientName:e.clientName,amount:e.amount,clientPhone:e.clientPhone,serviceName:e.serviceName,hours:e.hours,paymentMethod:e.paymentMethod,noRecord:e.noRecord,hasDiscount:!1,discountAmount:null,usedVoucher:e.usedVoucher,voucherAmount:e.voucherAmount,voucherCode:e.voucherCode,voucherLookupState:"idle",voucherLookupRequestId:0,voucherLookupTimerId:null,pendingCustomerName:e.pendingCustomerName,pendingCustomerPhone:e.pendingCustomerPhone,isCustomerCreateOpen:e.isCustomerCreateOpen,customerSuggestions:[],isCustomerSuggestionsOpen:e.isCustomerSuggestionsOpen,serviceSuggestions:[],isServiceSuggestionsOpen:!1,anonymous:e.anonymous,serviceSelectedFromCatalog:e.serviceSelectedFromCatalog,booksyProposal:e.booksyProposal?Q({},e.booksyProposal):null,isTimeReservation:e.isTimeReservation}}resetExpenseForm(){this.expenses=[this.createEmptyExpense()],this.hadOrders=!1,this.ordersCost=null,this.ordersPaymentMethod="cash",this.expenseAttachmentsByExpenseId={},this.selectedExpenseAttachmentFiles={},this.expenseAttachmentDeleteBusyById={}}reportDocId(){return`${this.reportDate}__${this.activeReporterUid}`}createEmptyClient(){return{customerId:"",customerQuery:"",clientName:"",amount:null,clientPhone:"",serviceName:"",hours:null,paymentMethod:"cash",noRecord:!1,hasDiscount:!1,discountAmount:null,usedVoucher:!1,voucherAmount:null,voucherCode:"",voucherLookupState:"idle",voucherLookupRequestId:0,voucherLookupTimerId:null,pendingCustomerName:"",pendingCustomerPhone:"",isCustomerCreateOpen:!1,customerSuggestions:[],isCustomerSuggestionsOpen:!1,serviceSuggestions:[],isServiceSuggestionsOpen:!1,anonymous:!1,serviceSelectedFromCatalog:!1,booksyProposal:null,isTimeReservation:!1}}createEmptyExpense(){return{id:this.createExpenseId(),label:"",cost:null,paymentMethod:"cash"}}refreshVoucherLookups(){this.clients.forEach(e=>{if(e.paymentMethod!=="voucher"){this.clearVoucherLookupTimer(e),e.voucherLookupState="idle",e.voucherAmount=null;return}if(e.voucherCode=this.normalizeVoucherCode(e.voucherCode),!e.voucherCode){e.voucherLookupState="idle",e.voucherAmount=null;return}this.scheduleVoucherLookup(e)})}scheduleVoucherLookup(e){if(e.paymentMethod!=="voucher")return;if(e.voucherCode=this.normalizeVoucherCode(e.voucherCode),this.clearVoucherLookupTimer(e),e.voucherLookupRequestId+=1,!e.voucherCode){e.voucherLookupState="idle",e.voucherAmount=null;return}e.voucherLookupState="checking";let t=e.voucherLookupRequestId;e.voucherLookupTimerId=window.setTimeout(()=>{e.voucherLookupTimerId=null,this.lookupVoucherCode(e,e.voucherCode,t)},300)}async lookupVoucherCode(e,t,n){if(e.voucherLookupRequestId=n,this.voucherLookupCache[t]!==void 0){this.commitVoucherLookupResult(e,t,n,this.voucherLookupCache[t]);return}if(!this.db){this.commitVoucherLookupResult(e,t,n,!1);return}e.voucherLookupState="checking";try{let o=(await te(N(this.db,Ge,t))).exists();this.voucherLookupCache[t]=o,this.commitVoucherLookupResult(e,t,n,o)}catch(i){console.warn("Nie udalo sie sprawdzic numeru vouchera:",i),this.commitVoucherLookupResult(e,t,n,!1)}}commitVoucherLookupResult(e,t,n,i){this.zone.run(()=>{this.applyVoucherLookupResult(e,t,n,i),this.cdr.detectChanges()})}applyVoucherLookupResult(e,t,n,i){e.voucherLookupRequestId===n&&this.normalizeVoucherCode(e.voucherCode)===t&&(e.voucherLookupState=i?"foun
2d":"missing",i||(e.voucherAmount=null))}clearVoucherLookupTimers(e){e.forEach(t=>this.clearVoucherLookupTimer(t))}clearVoucherLookupTimer(e){e.voucherLookupTimerId!==null&&(window.clearTimeout(e.voucherLookupTimerId),e.voucherLookupTimerId=null)}normalizeVoucherCode(e){return String(e??"").trim().toUpperCase().replace(/\s+/g,"")}async loadExpenseAttachments(){if(!this.db||!this.currentUserUid||!this.activeReporterUid){this.expenseAttachmentsByExpenseId={};return}try{let e=await G(ee(L(this.db,ze),ie("reportDocId","==",this.reportDocId()))),t={};e.docs.forEach(n=>{let i=n.data(),o=String(i.expenseId??"").trim();if(!o)return;let d={id:n.id,expenseId:o,reportDocId:String(i.reportDocId??"").trim(),reporterUid:String(i.reporterUid??"").trim(),name:String(i.name??"").trim(),url:String(i.url??"").trim(),fileName:String(i.fileName??"").trim(),size:this.numberOrZero(i.size),mime:String(i.mime??"").trim(),storagePath:String(i.storagePath??"").trim(),createdAtLabel:this.formatDateTime(i.createdAt)};t[o]||(t[o]=[]),t[o].push(d)}),Object.values(t).forEach(n=>{n.sort((i,o)=>o.createdAtLabel.localeCompare(i.createdAtLabel,"pl"))}),this.expenseAttachmentsByExpenseId=t}catch(e){console.warn("Nie udalo sie pobrac zalacznikow wydatkow:",e),this.expenseAttachmentsByExpenseId={}}}async removeStoredExpenseAttachments(e){if(!this.db||!this.storage||!e.length||!this.activeReporterUid)return!0;try{let t=await G(ee(L(this.db,ze),ie("reportDocId","==",this.reportDocId()))),n=new Set(e);for(let i of t.docs){let o=i.data(),d=String(o.expenseId??"").trim();if(!n.has(d))continue;let m=String(o.storagePath??"").trim();m&&await Fe(we(this.storage,m)),await Pe(N(this.db,ze,i.id))}return!0}catch(t){return console.warn("Nie udalo sie usunac zalacznikow usunietych wydatkow:",t),!1}}async uploadSelectedExpenseAttachments(e){if(!this.db||!this.storage||!this.currentUserUid||!this.activeReporterUid)return{uploadedCount:0,failedLabels:[]};let t={uploadedCount:0,failedLabels:[]},n=this.reportDocId(),i=this.activeReporterUid,o=this.activeReporterEmail,d=this.reportDate.slice(0,7);for(let m of e){let _=this.selectedExpenseAttachmentFiles[m.id];if(_){if(!this.isAllowedExpenseAttachmentFile(_)){t.failedLabels.push(m.label||"Wydatek");continue}try{let g=_.name.replace(/[^a-zA-Z0-9._-]/g,"_"),h=`expense-invoices/${i}/${n}/${m.id}/${Date.now()}_${g}`,x=we(this.storage,h);await We(x,_);let M=await je(x),D=N(L(this.db,ze));await J(D,{expenseId:m.id,reportDocId:n,reporterUid:i,reporterEmail:o,monthKey:d,dateKey:this.reportDate,expenseLabel:m.label,name:_.name,url:M,fileName:_.name,size:_.size,mime:_.type,storagePath:h,createdAt:U(),createdByUid:this.currentUserUid,createdByEmail:this.currentUserEmail}),this.selectedExpenseAttachmentFiles[m.id]=null,t.uploadedCount+=1}catch(g){console.warn("Nie udalo sie wyslac zalacznika wydatku:",g),t.failedLabels.push(m.label||"Wydatek")}}}return t}isAllowedExpenseAttachmentFile(e){let t=e.name.toLowerCase();return e.type==="application/pdf"||e.type.startsWith("image/")||t.endsWith(".pdf")||t.endsWith(".jpg")||t.endsWith(".jpeg")||t.endsWith(".png")||t.endsWith(".webp")}pruneSelectedExpenseAttachmentFiles(e){let t=new Set(e.map(i=>i.id)),n={};Object.entries(this.selectedExpenseAttachmentFiles).forEach(([i,o])=>{t.has(i)&&(n[i]=o)}),this.selectedExpenseAttachmentFiles=n}readExpenseId(e,t,n){let i=String(e.id??"").trim();return i||`${t}-expense-${n+1}`}createExpenseId(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`expense-${crypto.randomUUID()}`:`expense-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}numberOrNull(e){if(e==null||e==="")return null;let t=Number(e);return Number.isNaN(t)?null:t}numberOrZero(e){return this.numberOrNull(e)??0}formatDateTime(e){let t=this.toDate(e);if(!t)return"brak";let n=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),d=String(t.getHours()).padStart(2,"0"),m=String(t.getMinutes()).padStart(2,"0");return`${n}-${i}-${o} ${d}:${m}`}formatMoney(e){return`${e.toFixed(2)} zl`}formatNumber(e){return e.toFixed(2)}toDate(e){if(!e)return null;if(typeof e=="object"&&e!==null&&"toDate"in e){let n=e;if(typeof n.toDate=="function")return n.toDate()}let t=new Date(String(e));return Number.isNaN(t.getTime())?null:t}normalizeDateParam(e){return!e||!/^\d{4}-\d{2}-\d{2}$/.test(e)?null:e}formatDateKeyLocal(e){let t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${i}`}isAllowedMonthlyWorkReportFile(e){let t=e.type.toLowerCase(),n=e.name.toLowerCase();return t==="application/pdf"||t==="image/jpeg"||n.endsWith(".pdf")||n.endsWith(".jpg")||n.endsWith(".jpeg")}static \u0275fac=function(t){return new(t||r)(Me(at),Me(st),Me(Je),Me(tt))};static \u0275cmp=et({type:r,selectors:[["app-daily-report"]],decls:4,vars:4,consts:[["noHourlySettlementRows",""],["allPaymentsMatched",""],["noDetailedClients",""],["noTimelineBooksyVisit",""],["removedTimelineBooksyVisit",""],["noExpenses",""],["noExpenseAttachments",""],["class","report-shell",4,"ngIf"],["class","day-detail
2s-page",4,"ngIf"],["class","report-modal-backdrop",3,"click",4,"ngIf"],[1,"report-shell"],[1,"report-card","header"],[1,"quick-actions"],["type","button",1,"quick-btn",3,"click"],["aria-hidden","true",1,"quick-btn-icon"],["viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","2"],["d","M8 3h6l5 5v13H8a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"],["d","M14 3v5h5"],["d","M10 12h6"],["d","M10 16h6"],[1,"quick-btn-copy"],["type","button",1,"quick-btn",3,"click","disabled"],["d","M3 7h18"],["d","M6 7l1 13h10l1-13"],["d","M9 7V4h6v3"],["d","M12 11v5"],["d","M9.5 13.5h5"],[1,"report-card","month-card"],[1,"section-head"],[1,"month-filters"],["name","selectedMonthKey",3,"ngModelChange","ngModel"],[3,"value",4,"ngFor","ngForOf"],[4,"ngIf"],["type","button","class","btn secondary pdf-btn",3,"disabled","click",4,"ngIf"],[1,"week-toolbar"],["type","button",1,"btn","secondary",3,"click"],[1,"month-legend"],[1,"legend-item","cash"],["class","legend-item unrecorded",4,"ngIf"],[1,"legend-item","card"],[1,"legend-item","voucher"],[1,"legend-scale"],["class","month-summary",4,"ngIf"],["class","hint",4,"ngIf"],["class","report-chart-shell",4,"ngIf"],["class","employee-summary",4,"ngIf"],["class","report-card monthly-work-report-card",4,"ngIf"],[3,"value"],["name","selectedReporterUid",3,"ngModelChange","ngModel"],["value",""],["type","button",1,"btn","secondary","pdf-btn",3,"click","disabled"],[1,"legend-item","unrecorded"],[1,"month-summary"],[1,"tile"],[1,"hint"],[1,"report-chart-shell"],[1,"chart-axis"],[4,"ngFor","ngForOf"],[1,"report-chart-scroll"],[1,"report-chart"],["type","button","class","chart-day-card",3,"click",4,"ngFor","ngForOf","ngForTrackBy"],["type","button",1,"chart-day-card",3,"click"],[1,"chart-day-head"],[1,"weekday"],[1,"chart-bar-frame"],[1,"chart-bar"],["class","chart-segment",3,"cash","unrecorded","card","voucher","height","title",4,"ngFor","ngForOf"],["class","chart-bar-empty",4,"ngIf"],[1,"chart-day-meta"],["class","settlement-pending-chip",4,"ngIf"],[1,"chart-segment",3,"title"],[1,"chart-bar-empty"],[1,"settlement-pending-chip"],[1,"employee-summary"],[1,"employee-list"],["class","employee-item",4,"ngFor","ngForOf","ngForTrackBy"],[1,"employee-item"],[1,"employee-main"],[1,"report-card","monthly-work-report-card"],["type","button",1,"btn",3,"click","disabled"],[1,"hourly-settlement-actions"],[1,"field","signature-field"],["type","text","name","hourlySettlementSignature","placeholder","Imie i nazwisko",3,"ngModelChange","ngModel"],["class","hourly-settlement-table-wrap",4,"ngIf","ngIfElse"],[1,"hourly-settlement-table-wrap"],[1,"hourly-settlement-table"],[3,"summary-row",4,"ngFor","ngForOf","ngForTrackBy"],[1,"day-details-page"],["aria-label","Szczegoly raportu dnia",1,"day-details-surface"],["type","button",1,"btn","secondary",3,"click","disabled"],["class","terminal-payment-pool",4,"ngIf"],["class","report-card detail-report-card",4,"ngFor","ngForOf","ngForTrackBy"],[1,"terminal-payment-pool"],["class","terminal-payment-chips",4,"ngIf","ngIfElse"],[1,"terminal-payment-chips"],["class","terminal-payment-chip","draggable","true",3,"dragstart",4,"ngFor","ngForOf","ngForTrackBy"],["draggable","true",1,"terminal-payment-chip",3,"dragstart"],["aria-hidden","true"],[1,"terminal-payment-empty"],[1,"report-card","detail-report-card"],[1,"detail-report-actions"],["class","settlement-status",3,"is-pending","is-approved",4,"ngIf"],["type","button","class","btn",3,"disabled","click",4,"ngIf"],["type","button","class","btn secondary",3,"click",4,"ngIf"],[1,"detail-summary"],["class","tile",4,"ngIf"],["class","detail-section calendar-comparison-section",4,"ngIf"],[1,"detail-section"],["class","detail-client-list",4,"ngIf","ngIfElse"],["class","detail-section",4,"ngIf"],[1,"settlement-status"],[1,"detail-section","calendar-comparison-section"],["aria-hidden","true",1,"calendar-comparison-head"],[1,"calendar-timeline"],["class","timeline-hour",3,"top",4,"ngFor","ngForOf"],[1,"timeline-column"],[4,"ngFor","ngForOf","ngForTrackBy"],["class","card-match-slot timeline-match-slot",3,"top","height","dragover","drop",4,"ngFor","ngForOf","ngForTrackBy"],["class","calendar-visit-card employee-calendar-card timeline-visit-card",3,"top","height","is-added","is-removed",4,"ngFor","ngForOf","ngForTrackBy"],[1,"timeline-hour"],["class","calendar-visit-card booksy-calendar-card timeline-visit-card",3,"top","height",4,"ngIf","ngIfElse"],[1,"calendar-visit-card","booksy-calendar-card","timeline-visit-card"],[1,"calendar-visit-head"],["class","payment-icon",4,"ngIf"],[1,"calendar-visit-fields"],[1,"payment-icon"],[1,"calendar-visit-card","calendar-empty-card","timeline-visit-card"],[1,"card-match-slot","timeline-match-slot",3,"dragover","drop"],["type","button","class","matched-payment","title","Kliknij, aby usun\u0105\u0107 dopasowanie",3,"disabled","click",4,"ngFor","ngForOf","ngForTrackBy"],["class","card-match-placeholder",4,"ngIf"],["type","button","title","Kliknij, aby usun\u0105\u0107 dopasowanie",1,"matched-payment",3,"click","disabled"],[1,"card-match-placeholder"],[1,"calendar-visit-card","employee-calendar-card","timeline-visit-card"],[4,"ngIf","ngIfElse"],["class","payment-icon",3,"is-different",4,"ngIf"],[1,"removed-visit-label"],[1,"detail-client-list"],["class","client-item detail-client-item",4,"ngFor","ngForOf","ngForTrackBy"],[1,"client-item","detail-client-item"],[1,"detail-client-head"],[1,"detail-grid"],["class","detail-expense-box",4,"ngIf"],["class","expense-list detail-expense-list",4,"ngIf"],[1,"detail-expense-box"],[1,"expense-list","detail-expense-list"],["class","expense-item detail-expense-item",4,"ngFor","ngForOf"],[1,"expense-item","detail-expense-item"],[1,"report-modal-backdrop",3,"click"],["role","dialog","aria-modal","true","aria-label","Sporzadz raport dzienny",1,"report-modal",3,"click"],[1,"report-card","modal-date-card"],[1,"date-field","modal-date-field"],["type","date","name","modalReportDate",3,"ngModelChange","change","ngModel"],["class","date-field modal
2-date-field",4,"ngIf"],["class","report-card totals",4,"ngIf"],[1,"report-card"],[1,"client-list"],["class","client-item",4,"ngFor","ngForOf"],[1,"modal-actions"],["class","status error",4,"ngIf"],["class","status info",4,"ngIf"],["name","modalReportReporterUid",3,"ngModelChange","ngModel"],[1,"report-card","totals"],[1,"client-item"],[1,"item-head"],["class","booksy-time-badge",4,"ngIf"],["type","button","class","btn danger client-remove-btn",3,"click",4,"ngIf"],[1,"grid","client-grid"],["class","anonymous-checkbox-field",4,"ngIf"],[1,"service-field"],[1,"service-autocomplete"],["type","text","placeholder","Kliknij albo wpisz min. 2 znaki","autocomplete","off",3,"ngModelChange","focus","click","input","blur","ngModel","name"],["class","service-suggestions",4,"ngIf"],["class","service-validation-error",4,"ngIf"],["class","customer-selected",4,"ngIf"],[1,"client-compact-grid"],["type","number","step","0.01",3,"ngModelChange","ngModel","name"],["class","payment-field payment-field-compact",4,"ngIf"],[1,"grid","toggles","voucher-grid"],[1,"booksy-time-badge"],["type","button",1,"btn","danger","client-remove-btn",3,"click"],[1,"anonymous-checkbox-field"],["type","checkbox",3,"ngModelChange","ngModel","name"],[1,"customer-search-field"],[1,"customer-autocomplete"],[1,"customer-search-input-row"],["type","text","placeholder","Wpisz numer telefonu albo imie i nazwisko","autocomplete","off",3,"ngModelChange","focus","click","input","blur","ngModel","name"],["type","button","class","btn secondary customer-clear-btn",3,"click",4,"ngIf"],["class","customer-suggestions",4,"ngIf"],["type","button",1,"btn","secondary","customer-clear-btn",3,"click"],[1,"customer-suggestions"],["type","button","class","customer-suggestion",3,"mousedown",4,"ngFor","ngForOf"],["class","customer-suggestion-empty",4,"ngIf"],["type","button","class","customer-create-trigger",3,"mousedown",4,"ngIf"],["type","button",1,"customer-suggestion",3,"mousedown"],[1,"customer-suggestion-name"],[1,"customer-suggestion-phone"],[1,"customer-suggestion-empty"],["type","button",1,"customer-create-trigger",3,"mousedown"],[1,"service-suggestions"],["type","button","class","service-suggestion",3,"mousedown",4,"ngFor","ngForOf"],["class","service-suggestion-empty",4,"ngIf"],["type","button",1,"service-suggestion",3,"mousedown"],[1,"service-suggestion-main"],[1,"service-suggestion-meta"],[1,"service-suggestion-empty"],[1,"service-validation-error"],[1,"customer-selected"],["type","number","step","0.01","placeholder","Np. 1.50",3,"ngModelChange","ngModel","name"],[1,"payment-field","payment-field-compact"],[1,"payment-group","payment-group-grid"],[1,"radio-chip","payment-chip"],["type","radio",3,"change","name","checked"],["aria-hidden","true",1,"payment-chip-icon"],["x","3","y","6","width","18","height","12","rx","2"],["cx","12","cy","12","r","2.5"],["d","M7 10h.01"],["d","M17 14h.01"],[1,"payment-chip-copy"],[1,"payment-chip-title"],["class","radio-chip payment-chip payment-chip-warning",3,"is-active",4,"ngIf"],["x","2.5","y","5","width","19","height","14","rx","2"],["d","M2.5 10h19"],["d","M4 8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v3a2 2 0 0 0 0 4v3a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 0 0-4V8z"],["d","M12 6v12"],[1,"radio-chip","payment-chip","payment-chip-warning"],["d","M8 12h8"],["d","M12 9v6"],[1,"payment-chip-note"],["type","text",3,"ngModelChange","input","blur","ngModel","name"],["class","voucher-lookup-status",3,"is-found","is-missing",4,"ngIf"],[1,"voucher-lookup-status"],[1,"status","error"],[1,"status","info"],["role","dialog","aria-modal","true","aria-label","Dodaj wydatek",1,"report-modal","expense-modal",3,"click"],["type","date","name","modalExpenseDate",3,"ngModelChange","change","ngModel"],[1,"section-head","expenses-head"],["class","expense-list",4,"ngIf","ngIfElse"],["name","modalExpenseReporterUid",3,"ngModelChange","ngModel"],[1,"expense-list"],["class","expense-item",4,"ngFor","ngForOf","ngForTrackBy"],[1,"expense-item"],["type","text",3,"ngModelChange","ngModel","name"],[1,"payment-field"],[1,"payment-group","compact"],[1,"radio-chip"],["type","radio","value","cash",3,"ngModelChange","name","ngModel"],["type","radio","value","card",3,"ngModelChange","name","ngModel"],["type","button",1,"btn","danger",3,"click"],[1,"expense-attachments"],["class","expense-attachment-list",4,"ngIf","ngIfElse"],["class","expense-attachment-upload",4,"ngIf"],[1,"expense-attachment-list"],["class","expense-attachment-item",4,"ngFor","ngForOf","ngForTrackBy"],[1,"expense-attachment-item"],[1,"expense-attachment-copy"],["target","_blank","rel","noopener noreferrer",3,"href"],[1,"expense-attachment-meta"],["type","button",1,"expense-attachment-delete-icon",3,"click","title","disabled"],["viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","2","aria-hidden","true",4,"ngIf"],["viewBox","0 0 24 24","fill","none","stroke","currentColor","stroke-width","2","aria-hidden","true"],["d","M3 6h18"],["d","M8 6V4h8v2"],["d","M19 6l-1 14H6L5 6"],["d","M10 11v6"],["d","M14 11v6"],[1,"hint","expense-attachment-empty"],[1,"expense-attachment-upload"],["type","file","accept",".pdf,image/*",3,"change","disabled"]],template:function(t,n){t&1&&v(0,un,61,16,"div",7)(1,Jn,14,7,"div",8)(2,zi,37,14,"div",9)(3,Qi,35,11,"div",9),t&2&&(u("ngIf",!n.isDayDetail
2sPage),l(),u("ngIf",n.isDayDetailsPage&&n.isDayDetailsModalOpen),l(),u("ngIf",n.isReportModalOpen),l(),u("ngIf",n.isExpenseModalOpen))},dependencies:[rt,nt,it,bt,Ct,vt,ht,_t,ut,xt,ft,gt,yt,ot],styles:[".report-shell[_ngcontent-%COMP%]{max-width:1260px;margin:0 auto;padding:20px;display:grid;gap:14px;font-family:Poppins,Segoe UI,system-ui,-apple-system,sans-serif;color:#0f172a}.report-card[_ngcontent-%COMP%]{background:#fff;border:1px solid #e2e8f0;border-radius:16px;box-shadow:0 14px 30px #0f172a14;padding:16px;display:grid;gap:12px}.header[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:12px;align-items:end;flex-wrap:wrap}.header[_ngcontent-%COMP%] h1[_ngcontent-%COMP%]{margin:0 0 6px;font-size:28px}.header[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;color:#475569}.date-field[_ngcontent-%COMP%]{min-width:220px}.quick-actions[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.quick-btn[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;gap:10px;min-height:64px;border-radius:14px;border:1px solid #111827;background:#fff;color:#111827;font-size:19px;font-weight:700;cursor:pointer}.quick-btn-icon[_ngcontent-%COMP%]{width:22px;height:22px;flex:0 0 22px;display:inline-flex;align-items:center;justify-content:center}.quick-btn-icon[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:22px;height:22px}.quick-btn-copy[_ngcontent-%COMP%]{display:inline-block;line-height:1.1}.quick-btn.active[_ngcontent-%COMP%]{background:#111827;color:#fff}.quick-btn[disabled][_ngcontent-%COMP%]{opacity:.55;cursor:not-allowed}.section-head[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap}.section-head[_ngcontent-%COMP%] h2[_ngcontent-%COMP%], .section-head[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0}.month-filters[_ngcontent-%COMP%]{display:flex;gap:10px;flex-wrap:wrap}.view-mode-toggle[_ngcontent-%COMP%]{display:inline-flex;gap:8px}.view-mode-toggle[_ngcontent-%COMP%] .btn.active[_ngcontent-%COMP%]{background:#111827;color:#fff;border-color:#111827}.month-filters[_ngcontent-%COMP%] label[_ngcontent-%COMP%]{min-width:220px}.week-toolbar[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}.month-legend[_ngcontent-%COMP%]{display:flex;gap:8px;flex-wrap:wrap;align-items:center}.legend-item[_ngcontent-%COMP%]{font-size:12px;font-weight:700;border-radius:999px;padding:6px 10px;border:1px solid transparent}.legend-item.cash[_ngcontent-%COMP%]{color:#14532d;border-color:#86efac;background:#f0fdf4}.legend-item.unrecorded[_ngcontent-%COMP%]{color:#334155;border-color:#cbd5e1;background:#f8fafc}.legend-item.card[_ngcontent-%COMP%]{color:#9a3412;border-color:#fdba74;background:#fff7ed}.legend-item.voucher[_ngcontent-%COMP%]{color:#6b21a8;border-color:#d8b4fe;background:#faf5ff}.legend-scale[_ngcontent-%COMP%]{font-size:12px;color:#64748b}.month-summary[_ngcontent-%COMP%], .totals[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:10px}.tile[_ngcontent-%COMP%]{border:1px solid #dbeafe;background:#eff6ff;border-radius:12px;padding:10px;display:grid;gap:4px}.tile[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-size:12px;color:#334155}.tile[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{font-size:20px;color:#775a32}.report-chart-shell[_ngcontent-%COMP%]{display:grid;grid-template-columns:68px minmax(0,1fr);gap:12px;align-items:stretch}.chart-axis[_ngcontent-%COMP%]{height:320px;display:flex;flex-direction:column;justify-content:space-between;align-items:flex-end;padding:4px 0 28px;font-size:11px;color:#64748b}.report-chart-scroll[_ngcontent-%COMP%]{overflow-x:auto;overflow-y:hidden;padding-bottom:4px}.report-chart[_ngcontent-%COMP%]{min-height:320px;display:grid;grid-auto-flow:column;grid-auto-columns:minmax(72px,1fr);gap:10px;align-items:end}.report-chart.is-month[_ngcontent-%COMP%]{min-width:max-content}.chart-day-card[_ngcontent-%COMP%]{border:1px solid #e2e8f0;border-radius:14px;background:linear-gradient(180deg,#fff,#f8fafc);padding:10px 8px;display:grid;gap:10px;align-content:end;text-align:left;cursor:pointer;min-width:0}.chart-day-head[_ngcontent-%COMP%]{display:grid;gap:2px;font-size:11px;color:#475569}.weekday[_ngcontent-%COMP%]{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:#64748b}.chart-day-head[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{font-size:16px;color:#0f172a}.chart-bar-frame[_ngcontent-%COMP%]{height:220px;display:flex;align-items:end}.chart-bar[_ngcontent-%COMP%]{width:100%;height:100%;display:flex;flex-direction:column-reverse;justify-content:flex-start;gap:4px;padding:6px;border-radius:12px;border:1px solid #dbeafe;
2background:linear-gradient(to top,rgba(148,163,184,.12) 1px,transparent 1px) 0 0/100% 25%,linear-gradient(180deg,#f8fbff,#eef6ff);box-sizing:border-box}.chart-bar.is-empty[_ngcontent-%COMP%]{border-style:dashed;border-color:#d6deea;background:#f8fafc}.chart-segment[_ngcontent-%COMP%]{width:100%;border-radius:8px 8px 4px 4px;min-height:0}.chart-segment.cash[_ngcontent-%COMP%]{background:#16a34a}.chart-segment.unrecorded[_ngcontent-%COMP%]{background:#94a3b8}.chart-segment.card[_ngcontent-%COMP%]{background:#f97316}.chart-segment.voucher[_ngcontent-%COMP%]{background:#a855f7}.chart-bar-empty[_ngcontent-%COMP%]{margin:auto 0;text-align:center;font-size:12px;color:#94a3b8}.chart-day-meta[_ngcontent-%COMP%]{display:grid;gap:2px;font-size:11px;color:#334155}.settlement-pending-chip[_ngcontent-%COMP%]{color:#9a3412;font-weight:700}.employee-summary[_ngcontent-%COMP%]{margin-top:4px;display:grid;gap:10px}.monthly-work-report-card[_ngcontent-%COMP%] p[_ngcontent-%COMP%]{margin:0;color:#475569}.hourly-settlement-actions[_ngcontent-%COMP%]{display:grid;gap:10px}.signature-field[_ngcontent-%COMP%]{max-width:320px}.hourly-settlement-table-wrap[_ngcontent-%COMP%]{border:1px solid #e2e8f0;border-radius:12px;overflow-x:auto}.hourly-settlement-table[_ngcontent-%COMP%]{width:100%;min-width:620px;border-collapse:collapse}.hourly-settlement-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%], .hourly-settlement-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{padding:10px 12px;border-bottom:1px solid #e2e8f0;text-align:left;vertical-align:middle}.hourly-settlement-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]{background:#f8fafc;font-size:12px;color:#475569;white-space:nowrap}.hourly-settlement-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(3), .hourly-settlement-table[_ngcontent-%COMP%] td[_ngcontent-%COMP%]:nth-child(4), .hourly-settlement-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]:nth-child(3), .hourly-settlement-table[_ngcontent-%COMP%] th[_ngcontent-%COMP%]:nth-child(4){text-align:right}.hourly-settlement-table[_ngcontent-%COMP%] tbody[_ngcontent-%COMP%] tr[_ngcontent-%COMP%]:last-child td[_ngcontent-%COMP%]{border-bottom:0}.hourly-settlement-table[_ngcontent-%COMP%] .summary-row[_ngcontent-%COMP%] td[_ngcontent-%COMP%]{background:#f1f5f9;font-weight:700}.employee-summary[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0;font-size:16px}.employee-list[_ngcontent-%COMP%]{display:grid;gap:8px}.employee-item[_ngcontent-%COMP%]{border:1px solid #e2e8f0;border-radius:10px;padding:10px;display:grid;grid-template-columns:1fr;gap:10px;align-items:start;font-size:13px}.employee-main[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:10px;align-items:center}.client-list[_ngcontent-%COMP%], .expense-list[_ngcontent-%COMP%]{display:grid;gap:12px}.client-item[_ngcontent-%COMP%]{border:1px solid #e2e8f0;border-radius:12px;padding:12px;display:grid;gap:10px}.client-remove-btn[_ngcontent-%COMP%]{padding:8px 10px;line-height:1}.item-head[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;gap:10px}.item-head[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{margin:0;font-size:16px}.grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}.client-grid[_ngcontent-%COMP%]{grid-template-columns:repeat(2,minmax(0,1fr))}.toggles[_ngcontent-%COMP%]{grid-template-columns:repeat(3,minmax(0,1fr));align-items:end}.service-field[_ngcontent-%COMP%], .customer-search-field[_ngcontent-%COMP%], .customer-selected[_ngcontent-%COMP%], .customer-create[_ngcontent-%COMP%], .payment-field-compact[_ngcontent-%COMP%]{grid-column:1/-1}.client-compact-grid[_ngcontent-%COMP%]{grid-column:1/-1;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.voucher-grid[_ngcontent-%COMP%]{grid-column:1/-1;grid-template-columns:1fr;margin-top:4px}.voucher-lookup-status[_ngcontent-%COMP%]{font-size:12px;line-height:1.35;color:#64748b}.voucher-lookup-status.is-found[_ngcontent-%COMP%]{color:#0f766e}.voucher-lookup-status.is-missing[_ngcontent-%COMP%]{color:#b91c1c}.checkbox[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:10px;font-size:14px;font-weight:600;min-height:44px;padding:8px 10px;border:1px solid #dbe4f0;border-radius:10px;background:#f8fafc}.checkbox.no-record[_ngcontent-%COMP%]{border-color:#fbbf24;background:#fffbeb}label[_ngcontent-%COMP%]{display:grid;gap:6px}label[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-size:12px;color:#475569}.payment-field[_ngcontent-%COMP%]{display:grid;gap:8px}.payment-field-compact[_ngcontent-%COMP%]{grid-template-columns:1fr;align-items:start}.payment-field[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{font-size:12px;color:#475569}.payment-group[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:8px}.payment-group-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;align-items:stretch;justify-items:stretch}.payment-group-grid.has-no-record[_ngcontent-%COMP%]{grid-template-columns:repeat(4,minmax(0,1fr))}.radio-chip[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:10px;min-height:44px;padding:10px 12px;border:1px solid #d6deea;border-radius:10px;background:#fff;font-size:14px;font-weight:600;color:#0f172a;cursor:pointer}.payment-group-grid[_ngcontent-%COMP%] .radio-chip[_ngcontent-%COMP%]{width:100%;min-width:0;margin:0;justify-content:flex-start}.radio-chip[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-size:14px;color:inherit}.payment-chip[_ngcontent-%COMP%]{position:relative;min-height:52px;padding:8px 10px;gap:10px;width:100%;box-sizing:border-box;align-items:center;justify-content:flex-start;overflow:hidden}.payment-chip[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{position:absolute;opacity:0;pointer-events:none}.payment-chip.is-active[_ngcontent-%COMP%]{border-color:#0f766e;background:#ecfdf5;box-shadow:0 0 0 1px #0f766e1f}.payment-chip-warning.is-active[_ngcontent-%COMP%]{border-color:#d97706;background:#fff7ed;box-shadow:0 0 0 1px #d977061f}.payment-chip-icon[_ngcontent-%COMP%]{width:28px;height:28px;flex:0 0 28px;display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:#f1f5f9;color:#0f172a}.payment-chip.is-active[_ngcontent-%COMP%] .payment-chip-icon[_ngcontent-%COMP%]{background:#ccfbf1;color:#0f766e}.payment-chip-warning.is-active[_ngcontent-%COMP%] .payment-chip-icon[_ngcontent-%COMP%]{background:#ffedd5;color:#b45309}.payment-chip-icon[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:16px;height:16px}.payment-chip-copy[_ngcontent-%COMP%]{min-width:0;flex:1 1 auto;display:grid;gap:1px}.payment-chip-title[_ngcontent-%COMP%], .payment-chip-note[_ngcontent-%COMP%]{display:block;line-height:1.15;color:inherit}.payment-chip-title[_ngcontent-%COMP%]{font-size:13px;font-weight:700}.payment-chip-note[_ngcontent-%COMP%]{font-size:10px;font-weight:600;color:#64748b}.radio-chip.is-disabled[_ngcontent-%COMP%]{opacity:.55;cursor:not-allowed}.radio-chip[_ngcontent-%COMP%] input[type=radio][_ngcontent-%COMP%]{width:22px;height:22px;min-width:22px;margin:0;accent-color:#0f766e;cursor:pointer}.payment-group.compact[_ngcontent-%COMP%] .radio-chip[_ngcontent-%COMP%]{flex:1 1 120px}input[_ngcontent-%COMP%], select[_ngcontent-%COMP%], textarea[_ngcontent-%COMP%]{width:100%;box-sizing:border-box;border:1px solid #d6deea;border-radius:10px;padding:10px 12px;font-size:14px;font-family:inherit}.customer-search-field[_ngcontent-%COMP%], .customer-selected[_ngcontent-%COMP%], .customer-create[_ngcontent-%COMP%]{grid-column:1/-1}.customer-autocomplete[_ngcontent-%COMP%]{position:relative}.customer-search-input-row[_ngcontent-%COMP%]{display:flex;gap:8px;align-items:center}.customer-search-input-row[_ngcontent-%COMP%] input[_ngcontent-%COMP%]{min-width:0}.customer-clear-btn[_ngcontent-%COMP%]{flex:0 0 auto;padding-inline:10px}.customer-suggestions[_ngcontent-%COMP%]{position:absolute;top:calc(100% + 6px);left:0;right:0;z-index:24;display:grid;gap:6px;max-height:280px;overflow-y:auto;padding:8px;border:1px solid #d6deea;border-radius:12px;background:#fff;box-shadow:0 18px 36px #0f172a24}.customer-suggestion[_ngcontent-%COMP%], .customer-create-trigger[_ngcontent-%COMP%]{width:100%;border:1px solid #e2e8f0;border-radius:10px;background:#f8fafc;padding:10px 12px;text-align:left;cursor:pointer}.customer-suggestion[_ngcontent-%COMP%]{display:grid;gap:4px}
2.customer-suggestion-name[_ngcontent-%COMP%]{font-size:14px;font-weight:600;color:#0f172a}.customer-suggestion-phone[_ngcontent-%COMP%], .customer-suggestion-empty[_ngcontent-%COMP%]{font-size:12px;color:#64748b}.customer-create-trigger[_ngcontent-%COMP%]{color:#0f766e;font-weight:600}.customer-selected[_ngcontent-%COMP%], .customer-create[_ngcontent-%COMP%]{border:1px solid #dbe4f0;border-radius:10px;padding:10px 12px;background:#f8fafc}.customer-selected[_ngcontent-%COMP%]{display:grid;gap:4px}.customer-selected[_ngcontent-%COMP%] strong[_ngcontent-%COMP%], .customer-selected[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{line-height:1.3}.customer-selected[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{display:block;font-size:13px;color:#0f172a}.customer-selected[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{display:block;margin-top:4px;font-size:13px;color:#475569}.customer-create[_ngcontent-%COMP%]{display:grid;gap:12px}.customer-create-head[_ngcontent-%COMP%]{display:grid;gap:4px}.customer-create-head[_ngcontent-%COMP%] strong[_ngcontent-%COMP%]{font-size:13px;color:#0f172a}.customer-create-head[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{font-size:12px;color:#64748b}.customer-create-actions[_ngcontent-%COMP%]{display:flex;gap:8px;flex-wrap:wrap}.service-autocomplete[_ngcontent-%COMP%]{position:relative}.service-suggestions[_ngcontent-%COMP%]{position:absolute;top:calc(100% + 6px);left:0;right:0;z-index:20;display:grid;gap:6px;max-height:280px;overflow-y:auto;padding:8px;border:1px solid #d6deea;border-radius:12px;background:#fff;box-shadow:0 18px 36px #0f172a24}.service-suggestion[_ngcontent-%COMP%]{width:100%;border:1px solid #e2e8f0;border-radius:10px;background:#f8fafc;padding:10px 12px;display:grid;gap:4px;text-align:left;cursor:pointer}.service-suggestion-main[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:14px;font-weight:600;color:#0f172a}.service-suggestion-main[_ngcontent-%COMP%] small[_ngcontent-%COMP%], .service-suggestion-meta[_ngcontent-%COMP%], .service-suggestion-empty[_ngcontent-%COMP%]{font-size:12px;color:#64748b}.service-suggestion-empty[_ngcontent-%COMP%]{padding:10px 12px}.service-validation-error[_ngcontent-%COMP%]{display:block;margin-top:4px;font-size:12px;color:#dc2626}.anonymous-checkbox-field[_ngcontent-%COMP%]{grid-column:1/-1;display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:#475569;cursor:pointer}.anonymous-checkbox-field[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{width:18px;height:18px;min-width:18px;cursor:pointer;accent-color:#6366f1}.checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{width:28px;height:28px;min-width:28px;margin:0;padding:0;border:none;border-radius:6px;accent-color:#0f766e;cursor:pointer}.orders-box[_ngcontent-%COMP%]{border:1px dashed #cbd5e1;border-radius:12px;padding:12px;display:grid;gap:10px}.expense-item[_ngcontent-%COMP%]{border:1px solid #e2e8f0;border-radius:10px;padding:10px;display:grid;gap:10px;grid-template-columns:minmax(0,1fr) minmax(140px,220px) minmax(140px,180px) auto;align-items:end}.expense-attachments[_ngcontent-%COMP%]{grid-column:1/-1;display:grid;gap:8px;padding-top:4px;border-top:1px dashed #d6deea}.expense-attachment-list[_ngcontent-%COMP%], .expense-attachment-upload[_ngcontent-%COMP%]{display:grid;gap:8px}.expense-attachment-item[_ngcontent-%COMP%]{display:flex;gap:10px;align-items:center;padding:8px 10px;border:1px solid #e2e8f0;border-radius:10px;background:#f8fafc}.expense-attachment-copy[_ngcontent-%COMP%]{min-width:0;flex:1 1 auto;display:grid;gap:2px}.expense-attachment-item[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{font-weight:600;color:#0f172a;text-decoration:none;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.expense-attachment-item[_ngcontent-%COMP%] a[_ngcontent-%COMP%]:hover{text-decoration:none}.expense-attachment-meta[_ngcontent-%COMP%]{font-size:12px;color:#64748b}.expense-attachment-delete-icon[_ngcontent-%COMP%]{margin-left:auto;width:34px;height:34px;flex:0 0 34px;display:inline-flex;align-items:center;justify-content:center;border:1px solid #fda4af;border-radius:10px;background:#fff;color:#b91c1c;cursor:pointer}.expense-attachment-delete-icon[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:16px;height:16px}.expense-attachment-delete-icon[disabled][_ngcontent-%COMP%]{opacity:.6;cursor:not-allowed}.expense-attachment-empty[_ngcontent-%COMP%]{padding:2px 0 0}.expense-attachment-upload[_ngcontent-%COMP%] input[type=file][_ngcontent-%COMP%]{max-width:100%}.fixed-cost-form[_ngcontent-%COMP%]{display:grid;gap:10px;grid-template-columns:minmax(0,1fr) minmax(180px,240px) auto;align-items:end}.fixed-cost-list[_ngcontent-%COMP%]{display:grid;gap:8px}.fixed-cost-item[_ngcontent-%COMP%]{border:1px solid #e2e8f0;border-radius:10px;padding:10px;display:flex;align-items:center;justify-content:space-between;gap:10px}.fixed-cost-actions[_ngcontent-%COMP%]{display:flex;gap:8px;flex-wrap:wrap}.hint[_ngcontent-%COMP%]{font-size:13px;color:#64748b}.btn[_ngcontent-%COMP%]{border:1px solid #111827;background:#111827;color:#fff;border-radius:10px;padding:10px 12px;font-weight:600;cursor:pointer}.btn.secondary[_ngcontent-%COMP%]{background:#fff;color:#111827;border-color:#d6deea}.btn.danger[_ngcontent-%COMP%]{background:#fff;color:#b91c1c;border-color:#fda4af}.btn[disabled][_ngcontent-%COMP%]{opacity:.6;cursor:not-allowed}.actions-card[_ngcontent-%COMP%]{justify-items:start}.report-modal-backdrop[_ngcontent-%COMP%]{position:fixed;inset:0;z-index:140;background:#0f172a85;display:grid;place-items:center;padding:20px}.report-modal[_ngcontent-%COMP%]{width:min(1040px,100%);max-height:min(92vh,980px);overflow-y:auto;background:#fff;border:1px solid #e2e8f0;border-radius:18px;box-shadow:0 24px 70px #0f172a3d;padding:18px;display:grid;gap:14px}.expense-modal[_ngcontent-%COMP%]{width:min(880px,100%)}
2.day-details-modal[_ngcontent-%COMP%]{width:min(1080px,100%)}.day-details-page[_ngcontent-%COMP%]{min-height:100%;padding:22px;background:#f4f7fb}.day-details-surface[_ngcontent-%COMP%]{display:grid;grid-template-columns:minmax(0,1fr) minmax(280px,340px);gap:16px;width:min(1500px,100%);margin:0 auto}.day-details-surface[_ngcontent-%COMP%] > .section-head[_ngcontent-%COMP%]{grid-column:1/-1;padding:18px 20px;border:1px solid #e2e8f0;border-radius:16px;background:#fff}.day-details-surface[_ngcontent-%COMP%] > .hint[_ngcontent-%COMP%]{grid-column:1}.day-details-surface[_ngcontent-%COMP%] > .detail-report-card[_ngcontent-%COMP%]{grid-column:1}.day-details-surface[_ngcontent-%COMP%] > .terminal-payment-pool[_ngcontent-%COMP%]{position:sticky;top:18px;grid-column:2;grid-row:2/span 100;align-self:start;max-height:calc(100vh - 36px);overflow-y:auto}.detail-summary[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:10px}.detail-report-card[_ngcontent-%COMP%]{gap:14px}.detail-report-actions[_ngcontent-%COMP%]{display:flex;justify-content:flex-end;align-items:center;gap:10px;flex-wrap:wrap}.settlement-status[_ngcontent-%COMP%]{display:grid;gap:2px;padding:8px 10px;border:1px solid #cbd5e1;border-radius:10px;background:#f8fafc;font-size:12px;color:#475569}.settlement-status.is-pending[_ngcontent-%COMP%]{border-color:#fdba74;background:#fff7ed;color:#9a3412}.settlement-status.is-approved[_ngcontent-%COMP%]{border-color:#86efac;background:#f0fdf4;color:#166534}.detail-section[_ngcontent-%COMP%], .detail-client-list[_ngcontent-%COMP%], .detail-expense-list[_ngcontent-%COMP%]{display:grid;gap:10px}.detail-client-item[_ngcontent-%COMP%]{background:#fbfdff}.calendar-comparison-section[_ngcontent-%COMP%]{overflow-x:auto;padding:14px;border:1px solid #dbeafe;border-radius:14px;background:#f8fbff}.calendar-comparison-head[_ngcontent-%COMP%], .calendar-comparison-row[_ngcontent-%COMP%]{display:grid;grid-template-columns:minmax(260px,1fr) minmax(150px,.48fr) minmax(260px,1fr);gap:12px;min-width:760px}.calendar-comparison-head[_ngcontent-%COMP%]{padding:0 4px 8px 48px;color:#334155;font-size:13px}.calendar-comparison-list[_ngcontent-%COMP%]{display:grid;gap:12px}.calendar-timeline[_ngcontent-%COMP%]{position:relative;display:grid;grid-template-columns:minmax(260px,1fr) minmax(150px,.48fr) minmax(260px,1fr);gap:12px;min-width:760px;margin-left:48px}.timeline-hour[_ngcontent-%COMP%]{position:absolute;left:-48px;right:0;z-index:0;display:grid;grid-template-columns:42px 1fr;align-items:center;transform:translateY(-7px);pointer-events:none}.timeline-hour[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{color:#64748b;font-size:10px;font-weight:700}.timeline-hour[_ngcontent-%COMP%] i[_ngcontent-%COMP%]{height:1px;background:#dbeafe}.timeline-column[_ngcontent-%COMP%]{position:relative;z-index:1;min-height:100%}.timeline-visit-card[_ngcontent-%COMP%], .timeline-match-slot[_ngcontent-%COMP%]{position:absolute;left:0;right:0;min-height:0;overflow:auto}.timeline-visit-card[_ngcontent-%COMP%]{padding:9px 11px;gap:5px}.timeline-visit-card[_ngcontent-%COMP%] .calendar-visit-fields[_ngcontent-%COMP%]{gap:2px;font-size:11px}.timeline-visit-card[_ngcontent-%COMP%] .payment-icon[_ngcontent-%COMP%]{font-size:16px}.timeline-match-slot[_ngcontent-%COMP%]{min-height:0}.terminal-payment-pool[_ngcontent-%COMP%]{display:grid;gap:10px;padding:14px;border:1px solid #bfdbfe;border-radius:14px;background:#eff6ff}@media(max-width:980px){.day-details-page[_ngcontent-%COMP%]{padding:12px}.day-details-surface[_ngcontent-%COMP%]{grid-template-columns:minmax(0,1fr)}.day-details-surface[_ngcontent-%COMP%] > .terminal-payment-pool[_ngcontent-%COMP%]{position:static;grid-column:1;grid-row:auto;max-height:none}}.terminal-payment-pool[_ngcontent-%COMP%] > div[_ngcontent-%COMP%]:first-child{display:grid;gap:3px}.terminal-payment-pool[_ngcontent-%COMP%] > div[_ngcontent-%COMP%]:first-child span[_ngcontent-%COMP%], .terminal-payment-empty[_ngcontent-%COMP%]{color:#64748b;font-size:12px}.terminal-payment-chips[_ngcontent-%COMP%]{display:flex;gap:8px;overflow-x:auto;padding:2px 0 5px}.terminal-payment-chip[_ngcontent-%COMP%]{display:grid;grid-template-columns:auto 1fr;gap:2px 8px;min-width:190px;padding:10px 12px;border:1px solid #60a5fa;border-radius:11px;background:#fff;box-shadow:0 4px 12px #2563eb1a;cursor:grab;-webkit-user-select:none;user-select:none}.terminal-payment-chip[_ngcontent-%COMP%]:active{cursor:grabbing}.terminal-payment-chip[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{grid-row:1/span 3;font-size:20px}.terminal-payment-chip[_ngcontent-%COMP%] small[_ngcontent-%COMP%]{color:#64748b}.card-match-slot[_ngcontent-%COMP%]{display:grid;place-content:center;gap:8px;min-height:110px;padding:10px;border:2px dashed #93c5fd;border-radius:12px;background:#f8fbff;text-align:center}.card-match-placeholder[_ngcontent-%COMP%]{color:#64748b;font-size:11px;font-weight:700}.matched-payment[_ngcontent-%COMP%]{display:grid;gap:2px;padding:8px 10px;border:1px solid #34d399;border-radius:10px;background:#ecfdf5;color:#065f46;
2cursor:pointer}.matched-payment[_ngcontent-%COMP%] small[_ngcontent-%COMP%]{color:#047857;font-size:10px}.calendar-visit-card[_ngcontent-%COMP%]{display:grid;align-content:start;gap:10px;min-height:150px;padding:14px;border:1px solid #cbd5e1;border-radius:12px;background:#fff}.booksy-time-badge[_ngcontent-%COMP%]{display:inline-flex;margin-left:.55rem;padding:.2rem .5rem;border-radius:999px;background:#eef2ff;color:#775a32;font-size:.72rem;font-weight:700;vertical-align:middle}.booksy-calendar-card[_ngcontent-%COMP%]{border-left:4px solid #3b82f6}.employee-calendar-card[_ngcontent-%COMP%]{border-left:4px solid #0f766e}.employee-calendar-card.is-added[_ngcontent-%COMP%], .employee-calendar-card.is-removed[_ngcontent-%COMP%]{border-color:#ef4444;background:#fff7f7}.calendar-empty-card[_ngcontent-%COMP%]{justify-items:start;color:#64748b;border-style:dashed}.calendar-visit-head[_ngcontent-%COMP%]{display:flex;justify-content:space-between;align-items:center;gap:10px}.payment-icon[_ngcontent-%COMP%]{font-size:22px;line-height:1}.calendar-visit-fields[_ngcontent-%COMP%]{display:grid;gap:6px;color:#334155;font-size:13px}.calendar-visit-fields[_ngcontent-%COMP%] .is-different[_ngcontent-%COMP%], .payment-icon.is-different[_ngcontent-%COMP%]{color:#b91c1c;text-decoration:none;text-decoration-color:#dc2626;text-decoration-thickness:2px;text-underline-offset:3px;font-weight:700}.removed-visit-label[_ngcontent-%COMP%]{color:#b91c1c;text-decoration:none;text-decoration-thickness:2px;text-underline-offset:3px}.detail-client-head[_ngcontent-%COMP%]{display:flex;justify-content:space-between;gap:10px;align-items:center;flex-wrap:wrap}.detail-grid[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:8px;font-size:13px;color:#334155}.detail-expense-box[_ngcontent-%COMP%]{display:flex;gap:12px;flex-wrap:wrap;align-items:center;padding:12px;border:1px solid #e2e8f0;border-radius:12px;background:#f8fafc}.detail-expense-item[_ngcontent-%COMP%]{grid-template-columns:repeat(3,minmax(0,1fr));align-items:center}.modal-actions[_ngcontent-%COMP%]{display:flex;gap:10px;flex-wrap:wrap}.status[_ngcontent-%COMP%]{font-size:13px}.status.error[_ngcontent-%COMP%]{color:#b91c1c}.status.info[_ngcontent-%COMP%]{color:#0f766e}@media(max-width:1200px){.report-chart[_ngcontent-%COMP%]{grid-auto-columns:minmax(64px,1fr)}}@media(max-width:1100px){.grid[_ngcontent-%COMP%], .toggles[_ngcontent-%COMP%], .client-grid[_ngcontent-%COMP%], .client-compact-grid[_ngcontent-%COMP%], .voucher-grid[_ngcontent-%COMP%]{grid-template-columns:1fr 1fr}.fixed-cost-form[_ngcontent-%COMP%]{grid-template-columns:1fr}}@media(max-width:900px){.report-chart-shell[_ngcontent-%COMP%]{grid-template-columns:52px minmax(0,1fr)}}@media(max-width:800px){.grid[_ngcontent-%COMP%], .toggles[_ngcontent-%COMP%]{grid-template-columns:1fr}.report-modal[_ngcontent-%COMP%]{padding:14px;gap:12px}.client-item[_ngcontent-%COMP%]{padding:10px;gap:8px}.item-head[_ngcontent-%COMP%]{align-items:flex-start}.item-head[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-size:15px}.client-remove-btn[_ngcontent-%COMP%]{padding:7px 9px;font-size:13px}.client-grid[_ngcontent-%COMP%], .client-compact-grid[_ngcontent-%COMP%], .voucher-grid[_ngcontent-%COMP%]{grid-template-columns:1fr}.customer-search-input-row[_ngcontent-%COMP%], .customer-create-actions[_ngcontent-%COMP%]{flex-direction:column;align-items:stretch}.customer-clear-btn[_ngcontent-%COMP%]{width:100%}.customer-suggestions[_ngcontent-%COMP%], .service-suggestions[_ngcontent-%COMP%]{padding:6px;border-radius:10px}.customer-suggestion[_ngcontent-%COMP%], .customer-create-trigger[_ngcontent-%COMP%], .service-suggestion[_ngcontent-%COMP%], .customer-selected[_ngcontent-%COMP%]{padding:9px 10px}.payment-group-grid[_ngcontent-%COMP%] .radio-chip[_ngcontent-%COMP%]{min-height:0;padding:8px 4px 9px;gap:5px}.payment-group-grid.has-no-record[_ngcontent-%COMP%]{grid-template-columns:repeat(4,minmax(0,1fr))}.payment-group-grid[_ngcontent-%COMP%]:not(.has-no-record){grid-template-columns:repeat(3,minmax(0,1fr))}.payment-chip[_ngcontent-%COMP%]{flex-direction:column;justify-content:center;text-align:center;align-items:center}.payment-chip-icon[_ngcontent-%COMP%]{width:24px;height:24px;flex-basis:24px}.payment-chip-icon[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:14px;
2height:14px}.payment-chip-copy[_ngcontent-%COMP%]{width:auto;gap:2px;flex:0 1 auto;justify-items:center}.payment-chip-title[_ngcontent-%COMP%]{font-size:10px}.payment-chip-note[_ngcontent-%COMP%]{font-size:8px;line-height:1.05}.checkbox[_ngcontent-%COMP%] input[type=checkbox][_ngcontent-%COMP%]{width:32px;height:32px;min-width:32px}.expense-item[_ngcontent-%COMP%], .fixed-cost-item[_ngcontent-%COMP%]{grid-template-columns:1fr;flex-direction:column;align-items:stretch}.expense-attachment-item[_ngcontent-%COMP%] a[_ngcontent-%COMP%]{white-space:normal;overflow:visible;text-overflow:clip;word-break:break-word}.employee-item[_ngcontent-%COMP%]{grid-template-columns:1fr}.chart-axis[_ngcontent-%COMP%]{height:280px;padding-bottom:24px}.report-chart[_ngcontent-%COMP%]{min-height:280px;grid-auto-columns:minmax(58px,1fr)}.chart-bar-frame[_ngcontent-%COMP%]{height:190px}}@media(max-width:720px){.report-shell[_ngcontent-%COMP%], .report-modal-backdrop[_ngcontent-%COMP%]{padding:12px}.report-modal[_ngcontent-%COMP%]{padding:12px;border-radius:14px}.header[_ngcontent-%COMP%] h1[_ngcontent-%COMP%]{font-size:24px}.quick-actions[_ngcontent-%COMP%]{grid-template-columns:1fr}.quick-btn[_ngcontent-%COMP%]{font-size:18px}.quick-btn-icon[_ngcontent-%COMP%], .quick-btn-icon[_ngcontent-%COMP%] svg[_ngcontent-%COMP%]{width:20px;height:20px}.report-chart-shell[_ngcontent-%COMP%]{grid-template-columns:1fr;gap:8px}.chart-axis[_ngcontent-%COMP%]{height:auto;padding:0;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));align-items:center;text-align:center}.report-chart[_ngcontent-%COMP%]{min-height:260px;grid-auto-columns:minmax(54px,1fr)}.chart-bar-frame[_ngcontent-%COMP%]{height:170px}}"]})};export{jt as DailyReportComponent};
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.