app/public/assets/index-BdGwE2-x.js Repository MAG-AS Original path app/public/assets/index-BdGwE2-x.jsRole SOURCE Size 308841 bytes Lines 251 SHA-256 136bbab67e12c4a4052482aaac50b9f286805e612a2ae23512429800bac52a25Displayed range 251–251 Previous file/page · Project index · Next file/page
`+s)}}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=hn(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:s}=n;r!==void 0&&Wa.assertOptions(r,{silentJSONParsing:$e.transitional($e.boolean),forcedJSONParsing:$e.transitional($e.boolean),clarifyTimeoutError:$e.transitional($e.boolean),legacyInterceptorReqResOrdering:$e.transitional($e.boolean)},!1),a!=null&&(b.isFunction(a)?n.paramsSerializer={serialize:a}:Wa.assertOptions(a,{encode:$e.function,serialize:$e.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Wa.assertOptions(n,{baseUrl:$e.spelling("baseURL"),withXsrfToken:$e.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&b.merge(s.common,s[n.method]);s&&b.forEach(["delete","get","head","post","put","patch","common"],x=>{delete s[x]}),n.headers=Re.concat(i,s);const o=[];let u=!0;this.interceptors.request.forEach(function(N){if(typeof N.runWhen=="function"&&N.runWhen(n)===!1)return;u=u&&N.synchronous;const j=n.transitional||zo;j&&j.legacyInterceptorReqResOrdering?o.unshift(N.fulfilled,N.rejected):o.push(N.fulfilled,N.rejected)});const c=[];this.interceptors.response.forEach(function(N){c.push(N.fulfilled,N.rejected)});let d,f=0,y;if(!u){const x=[pc.bind(this),void 0];for(x.unshift(...o),x.push(...c),y=x.length,d=Promise.resolve(n);f<y;)d=d.then(x[f++],x[f++]);return d}y=o.length;let C=n;for(;f<y;){const x=o[f++],N=o[f++];try{C=x(C)}catch(j){N.call(this,j);break}}try{d=pc.call(this,C)}catch(x){return Promise.reject(x)}for(f=0,y=c.length;f<y;)d=d.then(c[f++],c[f++]);return d}getUri(t){t=hn(this.defaults,t);const n=xp(t.baseURL,t.url,t.allowAbsoluteUrls);return mp(n,t.params,t.paramsSerializer)}};b.forEach(["delete","get","head","options"],function(t){un.prototype[t]=function(n,r){return this.request(hn(r||{},{method:t,url:n,data:(r||{}).data}))}});b.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,o){return this.request(hn(o||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}un.prototype[t]=n(),un.prototype[t+"Form"]=n(!0)});let Lv=class jp{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(a=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](a);r._listeners=null}),this.promise.then=a=>{let s;const i=new Promise(o=>{r.subscribe(o),s=o}).then(a);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,o){r.reason||(r.reason=new ra(s,i,o),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new jp(function(a){t=a}),cancel:t}}};function Fv(e){return function(n){return e.apply(null,n)}}function Iv(e){return b.isObject(e)&&e.isAxiosError===!0}const Pl={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Pl).forEach(([e,t])=>{Pl[t]=e});function Cp(e){const t=new un(e),n=rp(un.prototype.request,t);return b.extend(n,un.prototype,t,{allOwnKeys:!0}),b.extend(n,t,null,{allOwnKeys:!0}),n.create=function(a){return Cp(hn(e,a))},n}const re=Cp(na);re.Axios=un;re.CanceledError=ra;re.CancelToken=Lv;re.isCancel=gp;re.VERSION=kp;re.toFormData=Ws;re.AxiosError=D;re.Cancel=re.CanceledError;re.all=function(t){return Promise.all(t)};re.spread=Fv;re.isAxiosError=Iv;re.mergeConfig=hn;re.AxiosHeaders=Re;re.formToJSON=e=>hp(b.isHTMLForm(e)?new FormData(e):e);re.getAdapter=Np.getAdapter;re.HttpStatusCode=Pl;re.default=re;const{Axios:g1,AxiosError:v1,CanceledError:x1,isCancel:w1,CancelToken:S1,VERSION:N1,all:k1,Cancel:j1,isAxiosError:C1,spread:E1,toFormData:P1,AxiosHeaders:b1,HttpStatusCode:z1,formToJSON:R1,getAdapter:O1,mergeConfig:T1}=re,U=re.create({baseURL:"/api"}),To=e=>U.get("/materials",{params:e}).then(t=>t.data),Av=e=>U.get(`/materials/${e}`).then(t=>t.data),$v=e=>U.post("/materials",e).then(t=>t.data),Uv=(e,t)=>U.put(`/materials/${e}`,t).then(n=>n.data),Bv=e=>U.patch(`/materials/${e}/toggle`).then(t=>t.data),Wv=e=>U.delete(`/materials/${e}`).then(t=>t.data),Vv=e=>U.post("/materials/delete-batch",{ids:e}).then(t=>t.data),_o=e=>U.get("/groups",{params:e}).then(t=>t.data),Hv=e=>U.get(`/groups/${e}`).then(t=>t.data),Qv=e=>U.post("/groups",e).then(t=>t.data),Yv=(e,t)=>U.put(`/groups/${e}`,t).then(n=>n.data),qv=e=>U.delete(`/groups/${e}`).then(t=>t.data),Ep=e=>U.get("/products",{params:e}).then(t=>t.data),Gv=e=>U.get(`/products/${e}`).then(t=>t.data),Kv=e=>U.post("/products",e).then(t=>t.data),Xv=(e,t)=>U.put(`/products/${e}`,t).then(n=>n.data),Jv=e=>U.post(`/products/${e}/duplicate`).then(t=>t.data),Zv=e=>U.patch(`/products/${e}/toggle`).then(t=>t.data),ex=e=>U.delete(`/products/${e}`).then(t=>t.data),tx=e=>U.post("/products/delete-batch",{ids:e}).then(t=>t.data),Pp=e=>U.get("/customers",{params:e}).then(t=>t.data),nx=e=>U.post("/customers",e).then(t=>t.data),rx=(e,t)=>U.put(`/customers/${e}`,t).then(n=>n.data),ax=e=>U.delete(`/customers/${e}`).then(t=>t.data),sx=e=>U.post("/customers/delete-batch",{ids:e}).then(t=>t.data),ix=e=>U.get("/orders",{params:e}).then(t=>t.data),lx=e=>U.post("/orders",e).then(t=>t.data),ox=e=>U.delete(`/orders/${e}`).then(t=>t.data),ux=e=>U.post("/orders/delete-batch",{ids:e}).then(t=>t.data),cx=e=>U.get("/dashboard",{params:e}).then(t=>t.data),dx=e=>`/api/export/dashboard.csv?${new URLSearchParams(e).toString()}`,fx=()=>"/api/export/materials.csv",px=()=>"/api/export/products.csv",mx=e=>U.post("/import/materials",{csv:e}).then(t=>t.data),hx=e=>U.post("/import/products",{csv:e}).then(t=>t.data);function ke(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function St(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function bp(e,t){const n=ke(e);if(isNaN(t))return St(e,NaN);if(!t)return n;const r=n.getDate(),a=St(e,n.getTime());a.setMonth(n.getMonth()+t+1,0);const s=a.getDate();return r>=s?a:(n.setFullYear(a.getFullYear(),a.getMonth(),r),n)}const zp=6048e5,yx=864e5;let gx={};function Hs(){return gx}function Yt(e,t){var o,u,c,d;const n=Hs(),r=(t==null?void 0:t.weekStartsOn)??((u=(o=t==null?void 0:t.locale)==null?void 0:o.options)==null?void 0:u.weekStartsOn)??n.weekStartsOn??((d=(c=n.locale)==null?void 0:c.options)==null?void 0:d.weekStartsOn)??0,a=ke(e),s=a.getDay(),i=(s<r?7:0)+s-r;return a.setDate(a.getDate()-i),a.setHours(0,0,0,0),a}function vs(e){return Yt(e,{weekStartsOn:1})}function Rp(e){const t=ke(e),n=t.getFullYear(),r=St(e,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);const a=vs(r),s=St(e,0);s.setFullYear(n,0,4),s.setHours(0,0,0,0);const i=vs(s);return t.getTime()>=a.getTime()?n+1:t.getTime()>=i.getTime()?n:n-1}function hc(e){const t=ke(e);return t.setHours(0,0,0,0),t}function yc(e){const t=ke(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function vx(e,t){const n=hc(e),r=hc(t),a=+n-yc(n),s=+r-yc(r);return Math.round((a-s)/yx)}function xx(e){const t=Rp(e),n=St(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),vs(n)}function wx(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Sx(e){if(!wx(e)&&typeof e!="number")return!1;const t=ke(e);return!isNaN(Number(t))}function Ea(e){const t=ke(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function Pa(e){const t=ke(e);return t.setDate(1),t.setHours(0,0,0,0),t}function Nx(e){const t=ke(e),n=St(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}function kx(e,t){const n=t==null?void 0:t.weekStartsOn,r=ke(e),a=r.getDay(),s=(a<n?-7:0)+6-(a-n);return r.setDate(r.getDate()+s),r.setHours(23,59,59,999),r}const jx={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Cx=(e,t,n)=>{let r;const a=jx[e];return typeof a=="string"?r=a:t===1?r=a.one:r=a.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function $n(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Ex={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Px={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},bx={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},zx={date:$n({formats:Ex,defaultWidth:"full"}),time:$n({formats:Px,defaultWidth:"full"}),dateTime:$n({formats:bx,defaultWidth:"full"})},Rx={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ox=(e,t,n,r)=>Rx[e];function st(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let a;if(r==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,o=n!=null&&n.width?String(n.width):i;a=e.formattingValues[o]||e.formattingValues[i]}else{const i=e.defaultWidth,o=n!=null&&n.width?String(n.width):e.defaultWidth;a=e.values[o]||e.values[i]}const s=e.argumentCallback?e.argumentCallback(t):t;return a[s]}}const Tx={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},_x={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Mx={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Dx={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Lx={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Fx={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Ix=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Ax={ordinalNumber:Ix,era:st({values:Tx,defaultWidth:"wide"}),quarter:st({values:_x,defaultWidth:"wide",argumentCallback:e=>e-1}),month:st({values:Mx,defaultWidth:"wide"}),day:st({values:Dx,defaultWidth:"wide"}),dayPeriod:st({values:Lx,defaultWidth:"wide",formattingValues:Fx,defaultFormattingWidth:"wide"})};function it(e){return(t,n={})=>{const r=n.width,a=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(a);if(!s)return null;const i=s[0],o=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],u=Array.isArray(o)?Ux(o,f=>f.test(i)):$x(o,f=>f.test(i));let c;c=e.valueCallback?e.valueCallback(u):u,c=n.valueCallback?n.valueCallback(c):c;const d=t.slice(i.length);return{value:c,rest:d}}}function $x(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Ux(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function Op(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const a=r[0],s=t.match(e.parsePattern);if(!s)return null;let i=e.valueCallback?e.valueCallback(s[0]):s[0];i=n.valueCallback?n.valueCallback(i):i;const o=t.slice(a.length);return{value:i,rest:o}}}const Bx=/^(\d+)(th|st|nd|rd)?/i,Wx=/\d+/i,Vx={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Hx={any:[/^b/i,/^(a|c)/i]},Qx={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Yx={any:[/1/i,/2/i,/3/i,/4/i]},qx={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Gx={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Kx={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Xx={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Jx={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Zx={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ew={ordinalNumber:Op({matchPattern:Bx,parsePattern:Wx,valueCallback:e=>parseInt(e,10)}),era:it({matchPatterns:Vx,defaultMatchWidth:"wide",parsePatterns:Hx,defaultParseWidth:"any"}),quarter:it({matchPatterns:Qx,defaultMatchWidth:"wide",parsePatterns:Yx,defaultParseWidth:"any",valueCallback:e=>e+1}),month:it({matchPatterns:qx,defaultMatchWidth:"wide",parsePatterns:Gx,defaultParseWidth:"any"}),day:it({matchPatterns:Kx,defaultMatchWidth:"wide",parsePatterns:Xx,defaultParseWidth:"any"}),dayPeriod:it({matchPatterns:Jx,defaultMatchWidth:"any",parsePatterns:Zx,defaultParseWidth:"any"})},tw={code:"en-US",formatDistance:Cx,formatLong:zx,formatRelative:Ox,localize:Ax,match:ew,options:{weekStartsOn:0,firstWeekContainsDate:1}};function nw(e){const t=ke(e);return vx(t,Nx(t))+1}function rw(e){const t=ke(e),n=+vs(t)-+xx(t);return Math.round(n/zp)+1}function Tp(e,t){var d,f,y,C;const n=ke(e),r=n.getFullYear(),a=Hs(),s=(t==null?void 0:t.firstWeekContainsDate)??((f=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??a.firstWeekContainsDate??((C=(y=a.locale)==null?void 0:y.options)==null?void 0:C.firstWeekContainsDate)??1,i=St(e,0);i.setFullYear(r+1,0,s),i.setHours(0,0,0,0);const o=Yt(i,t),u=St(e,0);u.setFullYear(r,0,s),u.setHours(0,0,0,0);const c=Yt(u,t);return n.getTime()>=o.getTime()?r+1:n.getTime()>=c.getTime()?r:r-1}function aw(e,t){var o,u,c,d;const n=Hs(),r=(t==null?void 0:t.firstWeekContainsDate)??((u=(o=t==null?void 0:t.locale)==null?void 0:o.options)==null?void 0:u.firstWeekContainsDate)??n.firstWeekContainsDate??((d=(c=n.locale)==null?void 0:c.options)==null?void 0:d.firstWeekContainsDate)??1,a=Tp(e,t),s=St(e,0);return s.setFullYear(a,0,r),s.setHours(0,0,0,0),Yt(s,t)}function sw(e,t){const n=ke(e),r=+Yt(n,t)-+aw(n,t);return Math.round(r/zp)+1}function W(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const Pt={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return W(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):W(n+1,2)},d(e,t){return W(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return W(e.getHours()%12||12,t.length)},H(e,t){return W(e.getHours(),t.length)},m(e,t){return W(e.getMinutes(),t.length)},s(e,t){return W(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return W(a,t.length)}},Sn={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},gc={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return Pt.y(e,t)},Y:function(e,t,n,r){const a=Tp(e,r),s=a>0?a:1-a;if(t==="YY"){const i=s%100;return W(i,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):W(s,t.length)},R:function(e,t){const n=Rp(e);return W(n,t.length)},u:function(e,t){const n=e.getFullYear();return W(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return W(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return W(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return Pt.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return W(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const a=sw(e,r);return t==="wo"?n.ordinalNumber(a,{unit:"week"}):W(a,t.length)},I:function(e,t,n){const r=rw(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):W(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Pt.d(e,t)},D:function(e,t,n){const r=nw(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):W(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const a=e.getDay(),s=(a-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return W(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});case"eeee":default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const a=e.getDay(),s=(a-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return W(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});case"cccc":default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),a=r===0?7:r;switch(t){case"i":return String(a);case"ii":return W(a,t.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let a;switch(r===12?a=Sn.noon:r===0?a=Sn.midnight:a=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let a;switch(r>=17?a=Sn.evening:r>=12?a=Sn.afternoon:r>=4?a=Sn.morning:a=Sn.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Pt.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Pt.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):W(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):W(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Pt.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Pt.s(e,t)},S:function(e,t){return Pt.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return xc(r);case"XXXX":case"XX":return tn(r);case"XXXXX":case"XXX":default:return tn(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return xc(r);case"xxxx":case"xx":return tn(r);case"xxxxx":case"xxx":default:return tn(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+vc(r,":");case"OOOO":default:return"GMT"+tn(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+vc(r,":");case"zzzz":default:return"GMT"+tn(r,":")}},t:function(e,t,n){const r=Math.trunc(e.getTime()/1e3);return W(r,t.length)},T:function(e,t,n){const r=e.getTime();return W(r,t.length)}};function vc(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=Math.trunc(r/60),s=r%60;return s===0?n+String(a):n+String(a)+t+W(s,2)}function xc(e,t){return e%60===0?(e>0?"-":"+")+W(Math.abs(e)/60,2):tn(e,t)}function tn(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),a=W(Math.trunc(r/60),2),s=W(r%60,2);return n+a+t+s}const wc=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},_p=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},iw=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return wc(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",wc(r,t)).replace("{{time}}",_p(a,t))},lw={p:_p,P:iw},ow=/^D+$/,uw=/^Y+$/,cw=["D","DD","YY","YYYY"];function dw(e){return ow.test(e)}function fw(e){return uw.test(e)}function pw(e,t,n){const r=mw(e,t,n);if(console.warn(r),cw.includes(e))throw new RangeError(r)}function mw(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const hw=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,yw=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,gw=/^'([^]*?)'?$/,vw=/''/g,xw=/[a-zA-Z]/;function Hr(e,t,n){var d,f,y,C,x,N,j,v;const r=Hs(),a=(n==null?void 0:n.locale)??r.locale??tw,s=(n==null?void 0:n.firstWeekContainsDate)??((f=(d=n==null?void 0:n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((C=(y=r.locale)==null?void 0:y.options)==null?void 0:C.firstWeekContainsDate)??1,i=(n==null?void 0:n.weekStartsOn)??((N=(x=n==null?void 0:n.locale)==null?void 0:x.options)==null?void 0:N.weekStartsOn)??r.weekStartsOn??((v=(j=r.locale)==null?void 0:j.options)==null?void 0:v.weekStartsOn)??0,o=ke(e);if(!Sx(o))throw new RangeError("Invalid time value");let u=t.match(yw).map(m=>{const g=m[0];if(g==="p"||g==="P"){const S=lw[g];return S(m,a.formatLong)}return m}).join("").match(hw).map(m=>{if(m==="''")return{isToken:!1,value:"'"};const g=m[0];if(g==="'")return{isToken:!1,value:ww(m)};if(gc[g])return{isToken:!0,value:m};if(g.match(xw))throw new RangeError("Format string contains an unescaped latin alphabet character `"+g+"`");return{isToken:!1,value:m}});a.localize.preprocessor&&(u=a.localize.preprocessor(o,u));const c={firstWeekContainsDate:s,weekStartsOn:i,locale:a};return u.map(m=>{if(!m.isToken)return m.value;const g=m.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&fw(g)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&dw(g))&&pw(g,t,String(e));const S=gc[g[0]];return S(o,g,a.localize,c)}).join("")}function ww(e){const t=e.match(gw);return t?t[1].replace(vw,"'"):e}function Sw(e,t,n){const r=Yt(e,n),a=Yt(t,n);return+r==+a}function Sc(e,t){return bp(e,-1)}const Nw={lessThanXSeconds:{one:{regular:"mniej niż sekunda",past:"mniej niż sekundę",future:"mniej niż sekundę"},twoFour:"mniej niż {{count}} sekundy",other:"mniej niż {{count}} sekund"},xSeconds:{one:{regular:"sekunda",past:"sekundę",future:"sekundę"},twoFour:"{{count}} sekundy",other:"{{count}} sekund"},halfAMinute:{one:"pół minuty",twoFour:"pół minuty",other:"pół minuty"},lessThanXMinutes:{one:{regular:"mniej niż minuta",past:"mniej niż minutę",future:"mniej niż minutę"},twoFour:"mniej niż {{count}} minuty",other:"mniej niż {{count}} minut"},xMinutes:{one:{regular:"minuta",past:"minutę",future:"minutę"},twoFour:"{{count}} minuty",other:"{{count}} minut"},aboutXHours:{one:{regular:"około godziny",past:"około godziny",future:"około godzinę"},twoFour:"około {{count}} godziny",other:"około {{count}} godzin"},xHours:{one:{regular:"godzina",past:"godzinę",future:"godzinę"},twoFour:"{{count}} godziny",other:"{{count}} godzin"},xDays:{one:{regular:"dzień",past:"dzień",future:"1 dzień"},twoFour:"{{count}} dni",other:"{{count}} dni"},aboutXWeeks:{one:"około tygodnia",twoFour:"około {{count}} tygodni",other:"około {{count}} tygodni"},xWeeks:{one:"tydzień",twoFour:"{{count}} tygodnie",other:"{{count}} tygodni"},aboutXMonths:{one:"około miesiąc",twoFour:"około {{count}} miesiące",other:"około {{count}} miesięcy"},xMonths:{one:"miesiąc",twoFour:"{{count}} miesiące",other:"{{count}} miesięcy"},aboutXYears:{one:"około rok",twoFour:"około {{count}} lata",other:"około {{count}} lat"},xYears:{one:"rok",twoFour:"{{count}} lata",other:"{{count}} lat"},overXYears:{one:"ponad rok",twoFour:"ponad {{count}} lata",other:"ponad {{count}} lat"},almostXYears:{one:"prawie rok",twoFour:"prawie {{count}} lata",other:"prawie {{count}} lat"}};function kw(e,t){if(t===1)return e.one;const n=t%100;if(n<=20&&n>10)return e.other;const r=n%10;return r>=2&&r<=4?e.twoFour:e.other}function ki(e,t,n){const r=kw(e,t);return(typeof r=="string"?r:r[n]).replace("{{count}}",String(t))}const jw=(e,t,n)=>{const r=Nw[e];return n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"za "+ki(r,t,"future"):ki(r,t,"past")+" temu":ki(r,t,"regular")},Cw={full:"EEEE, do MMMM y",long:"do MMMM y",medium:"do MMM y",short:"dd.MM.y"},Ew={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},Pw={full:"{{date}} {{time}}",long:"{{date}} {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},bw={date:$n({formats:Cw,defaultWidth:"full"}),time:$n({formats:Ew,defaultWidth:"full"}),dateTime:$n({formats:Pw,defaultWidth:"full"})},zw={masculine:"ostatni",feminine:"ostatnia"},Rw={masculine:"ten",feminine:"ta"},Ow={masculine:"następny",feminine:"następna"},Tw={0:"feminine",1:"masculine",2:"masculine",3:"feminine",4:"masculine",5:"masculine",6:"feminine"};function Nc(e,t,n,r){let a;if(Sw(t,n,r))a=Rw;else if(e==="lastWeek")a=zw;else if(e==="nextWeek")a=Ow;else throw new Error(`Cannot determine adjectives for token ${e}`);const s=t.getDay(),i=Tw[s];return`'${a[i]}' eeee 'o' p`}const _w={lastWeek:Nc,yesterday:"'wczoraj o' p",today:"'dzisiaj o' p",tomorrow:"'jutro o' p",nextWeek:Nc,other:"P"},Mw=(e,t,n,r)=>{const a=_w[e];return typeof a=="function"?a(e,t,n,r):a},Dw={narrow:["p.n.e.","n.e."],abbreviated:["p.n.e.","n.e."],wide:["przed naszą erą","naszej ery"]},Lw={narrow:["1","2","3","4"],abbreviated:["I kw.","II kw.","III kw.","IV kw."],wide:["I kwartał","II kwartał","III kwartał","IV kwartał"]},Fw={narrow:["S","L","M","K","M","C","L","S","W","P","L","G"],abbreviated:["sty","lut","mar","kwi","maj","cze","lip","sie","wrz","paź","lis","gru"],wide:["styczeń","luty","marzec","kwiecień","maj","czerwiec","lipiec","sierpień","wrzesień","październik","listopad","grudzień"]},Iw={narrow:["s","l","m","k","m","c","l","s","w","p","l","g"],abbreviated:["sty","lut","mar","kwi","maj","cze","lip","sie","wrz","paź","lis","gru"],wide:["stycznia","lutego","marca","kwietnia","maja","czerwca","lipca","sierpnia","września","października","listopada","grudnia"]},Aw={narrow:["N","P","W","Ś","C","P","S"],short:["nie","pon","wto","śro","czw","pią","sob"],abbreviated:["niedz.","pon.","wt.","śr.","czw.","pt.","sob."],wide:["niedziela","poniedziałek","wtorek","środa","czwartek","piątek","sobota"]},$w={narrow:["n","p","w","ś","c","p","s"],short:["nie","pon","wto","śro","czw","pią","sob"],abbreviated:["niedz.","pon.","wt.","śr.","czw.","pt.","sob."],wide:["niedziela","poniedziałek","wtorek","środa","czwartek","piątek","sobota"]},Uw={narrow:{am:"a",pm:"p",midnight:"półn.",noon:"poł",morning:"rano",afternoon:"popoł.",evening:"wiecz.",night:"noc"},abbreviated:{am:"AM",pm:"PM",midnight:"północ",noon:"południe",morning:"rano",afternoon:"popołudnie",evening:"wieczór",night:"noc"},wide:{am:"AM",pm:"PM",midnight:"północ",noon:"południe",morning:"rano",afternoon:"popołudnie",evening:"wieczór",night:"noc"}},Bw={narrow:{am:"a",pm:"p",midnight:"o półn.",noon:"w poł.",morning:"rano",afternoon:"po poł.",evening:"wiecz.",night:"w nocy"},abbreviated:{am:"AM",pm:"PM",midnight:"o północy",noon:"w południe",morning:"rano",afternoon:"po południu",evening:"wieczorem",night:"w nocy"},wide:{am:"AM",pm:"PM",midnight:"o północy",noon:"w południe",morning:"rano",afternoon:"po południu",evening:"wieczorem",night:"w nocy"}},Ww=(e,t)=>String(e),Vw={ordinalNumber:Ww,era:st({values:Dw,defaultWidth:"wide"}),quarter:st({values:Lw,defaultWidth:"wide",argumentCallback:e=>e-1}),month:st({values:Fw,defaultWidth:"wide",formattingValues:Iw,defaultFormattingWidth:"wide"}),day:st({values:Aw,defaultWidth:"wide",formattingValues:$w,defaultFormattingWidth:"wide"}),dayPeriod:st({values:Uw,defaultWidth:"wide",formattingValues:Bw,defaultFormattingWidth:"wide"})},Hw=/^(\d+)?/i,Qw=/\d+/i,Yw={narrow:/^(p\.?\s*n\.?\s*e\.?\s*|n\.?\s*e\.?\s*)/i,abbreviated:/^(p\.?\s*n\.?\s*e\.?\s*|n\.?\s*e\.?\s*)/i,wide:/^(przed\s*nasz(ą|a)\s*er(ą|a)|naszej\s*ery)/i},qw={any:[/^p/i,/^n/i]},Gw={narrow:/^[1234]/i,abbreviated:/^(I|II|III|IV)\s*kw\.?/i,wide:/^(I|II|III|IV)\s*kwarta(ł|l)/i},Kw={narrow:[/1/i,/2/i,/3/i,/4/i],any:[/^I kw/i,/^II kw/i,/^III kw/i,/^IV kw/i]},Xw={narrow:/^[slmkcwpg]/i,abbreviated:/^(sty|lut|mar|kwi|maj|cze|lip|sie|wrz|pa(ź|z)|lis|gru)/i,wide:/^(stycznia|stycze(ń|n)|lutego|luty|marca|marzec|kwietnia|kwiecie(ń|n)|maja|maj|czerwca|czerwiec|lipca|lipiec|sierpnia|sierpie(ń|n)|wrze(ś|s)nia|wrzesie(ń|n)|pa(ź|z)dziernika|pa(ź|z)dziernik|listopada|listopad|grudnia|grudzie(ń|n))/i},Jw={narrow:[/^s/i,/^l/i,/^m/i,/^k/i,/^m/i,/^c/i,/^l/i,/^s/i,/^w/i,/^p/i,/^l/i,/^g/i],any:[/^st/i,/^lu/i,/^mar/i,/^k/i,/^maj/i,/^c/i,/^lip/i,/^si/i,/^w/i,/^p/i,/^lis/i,/^g/i]},Zw={narrow:/^[npwścs]/i,short:/^(nie|pon|wto|(ś|s)ro|czw|pi(ą|a)|sob)/i,abbreviated:/^(niedz|pon|wt|(ś|s)r|czw|pt|sob)\.?/i,wide:/^(niedziela|poniedzia(ł|l)ek|wtorek|(ś|s)roda|czwartek|pi(ą|a)tek|sobota)/i},e1={narrow:[/^n/i,/^p/i,/^w/i,/^ś/i,/^c/i,/^p/i,/^s/i],abbreviated:[/^n/i,/^po/i,/^w/i,/^(ś|s)r/i,/^c/i,/^pt/i,/^so/i],any:[/^n/i,/^po/i,/^w/i,/^(ś|s)r/i,/^c/i,/^pi/i,/^so/i]},t1={narrow:/^(^a$|^p$|pó(ł|l)n\.?|o\s*pó(ł|l)n\.?|po(ł|l)\.?|w\s*po(ł|l)\.?|po\s*po(ł|l)\.?|rano|wiecz\.?|noc|w\s*nocy)/i,any:/^(am|pm|pó(ł|l)noc|o\s*pó(ł|l)nocy|po(ł|l)udnie|w\s*po(ł|l)udnie|popo(ł|l)udnie|po\s*po(ł|l)udniu|rano|wieczór|wieczorem|noc|w\s*nocy)/i},n1={narrow:{am:/^a$/i,pm:/^p$/i,midnight:/pó(ł|l)n/i,noon:/po(ł|l)/i,morning:/rano/i,afternoon:/po\s*po(ł|l)/i,evening:/wiecz/i,night:/noc/i},any:{am:/^am/i,pm:/^pm/i,midnight:/pó(ł|l)n/i,noon:/po(ł|l)/i,morning:/rano/i,afternoon:/po\s*po(ł|l)/i,evening:/wiecz/i,night:/noc/i}},r1={ordinalNumber:Op({matchPattern:Hw,parsePattern:Qw,valueCallback:e=>parseInt(e,10)}),era:it({matchPatterns:Yw,defaultMatchWidth:"wide",parsePatterns:qw,defaultParseWidth:"any"}),quarter:it({matchPatterns:Gw,defaultMatchWidth:"wide",parsePatterns:Kw,defaultParseWidth:"any",valueCallback:e=>e+1}),month:it({matchPatterns:Xw,defaultMatchWidth:"wide",parsePatterns:Jw,defaultParseWidth:"any"}),day:it({matchPatterns:Zw,defaultMatchWidth:"wide",parsePatterns:e1,defaultParseWidth:"any"}),dayPeriod:it({matchPatterns:t1,defaultMatchWidth:"any",parsePatterns:n1,defaultParseWidth:"any"})},a1={code:"pl",formatDistance:jw,formatLong:bw,formatRelative:Mw,localize:Vw,match:r1,options:{weekStartsOn:1,firstWeekContainsDate:4}};function Ue(e){return Hr(e,"yyyy-MM-dd")}function s1(){const e=new Date,[t,n]=k.useState(Ue(Pa(e))),[r,a]=k.useState(Ue(Ea(e))),[s,i]=k.useState(""),[o,u]=k.useState(null),[c,d]=k.useState([]),[f,y]=k.useState(!0),[C,x]=k.useState("month"),[N,j]=k.useState(e),v=k.useCallback(async()=>{y(!0);try{const p={};t&&(p.dateFrom=t),r&&(p.dateTo=r),s&&(p.groupId=s);const w=await cx(p);u(w)}catch{T.error("Błąd wczytywania dashboardu")}finally{y(!1)}},[t,r,s]);k.useEffect(()=>{_o().then(d).catch(()=>{})},[]),k.useEffect(()=>{v()},[v]);const m=p=>{x(p);const w=new Date;switch(p){case"today":n(Ue(w)),a(Ue(w));break;case"week":n(Ue(Yt(w,{weekStartsOn:1}))),a(Ue(kx(w,{weekStartsOn:1})));break;case"month":n(Ue(Pa(w))),a(Ue(Ea(w))),j(w);break;case"prevMonth":{const z=Sc(w);n(Ue(Pa(z))),a(Ue(Ea(z))),j(z);break}}},g=p=>{const w=p==="prev"?Sc(N):bp(N,1);j(w),n(Ue(Pa(w))),a(Ue(Ea(w))),x("custom")},S=()=>{const p={};t&&(p.dateFrom=t),r&&(p.dateTo=r),s&&(p.groupId=s),window.open(dx(p),"_blank")},h=[{key:"today",label:"Dziś"},{key:"week",label:"Ten tydzień"},{key:"month",label:"Ten miesiąc"},{key:"prevMonth",label:"Poprzedni miesiąc"},{key:"custom",label:"Własny zakres"}],E=Hr(N,"LLLL yyyy",{locale:a1});return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsx("h1",{className:"page-title",children:"Dashboard — zużycie materiałów"}),l.jsx("button",{onClick:S,className:"btn-success",children:"📥 Eksport CSV"})]}),l.jsxs("div",{className:"card mb-6 space-y-4",children:[l.jsx("div",{className:"flex flex-wrap gap-2",children:h.map(p=>l.jsx("button",{onClick:()=>m(p.key),className:`px-3 py-1.5 text-xs rounded-lg font-medium transition-colors ${C===p.key?"bg-indigo-600 text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200"}`,children:p.label},p.key))}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("button",{onClick:()=>g("prev"),className:"btn-secondary text-xs px-3 py-1",children:"← Wstecz"}),l.jsx("span",{className:"text-sm font-medium text-gray-700 capitalize",children:E}),l.jsx("button",{onClick:()=>g("next"),className:"btn-secondary text-xs px-3 py-1",children:"Naprzód →"})]}),l.jsxs("div",{className:"flex flex-wrap gap-4 items-end",children:[l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Data od"}),l.jsx("input",{type:"date",className:"input-field",value:t,onChange:p=>{n(p.target.value),x("custom")}})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Data do"}),l.jsx("input",{type:"date",className:"input-field",value:r,onChange:p=>{a(p.target.value),x("custom")}})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Grupa materiałowa"}),l.jsxs("select",{className:"input-field",value:s,onChange:p=>i(p.target.value),children:[l.jsx("option",{value:"",children:"Wszystkie grupy"}),c.map(p=>l.jsx("option",{value:p.id,children:p.name},p.id))]})]})]})]}),f?l.jsx("p",{className:"text-sm text-gray-500",children:"Ładowanie danych..."}):o?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-6",children:[l.jsxs("div",{className:"card text-center",children:[l.jsx("p",{className:"text-xs text-gray-500 uppercase font-medium",children:"Różnych materiałów"}),l.jsx("p",{className:"text-3xl font-bold text-indigo-600 mt-1",children:o.summary.totalMaterials})]}),l.jsxs("div",{className:"card text-center",children:[l.jsx("p",{className:"text-xs text-gray-500 uppercase font-medium",children:"Wartość netto"}),l.jsxs("p",{className:"text-3xl font-bold text-emerald-600 mt-1",children:[o.summary.totalNetValue.toFixed(2)," zł"]})]}),l.jsxs("div",{className:"card text-center",children:[l.jsx("p",{className:"text-xs text-gray-500 uppercase font-medium",children:"Wartość brutto"}),l.jsxs("p",{className:"text-3xl font-bold text-emerald-600 mt-1",children:[o.summary.totalGrossValue.toFixed(2)," zł"]})]})]}),!s&&o.allMaterials.length>0&&l.jsxs("div",{className:"card mb-6",children:[l.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Wszystkie materiały — widok ogólny"}),l.jsx(ji,{materials:o.allMaterials})]}),o.groups.map(p=>l.jsxs("div",{className:"card mb-6",children:[l.jsx("h2",{className:"text-lg font-semibold mb-4",children:l.jsxs("span",{className:"inline-flex items-center gap-2",children:["📁 ",p.groupName,l.jsxs("span",{className:"text-xs font-normal text-gray-400",children:["(",p.materials.length," materiałów)"]})]})}),l.jsx(ji,{materials:p.materials})]},p.groupId)),o.ungrouped.length>0&&l.jsxs("div",{className:"card mb-6",children:[l.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-500",children:"Bez grupy"}),l.jsx(ji,{materials:o.ungrouped})]}),o.allMaterials.length===0&&l.jsx("div",{className:"card",children:l.jsx("p",{className:"text-sm text-gray-500 text-center py-8",children:"Brak danych o zużyciu materiałów w wybranym okresie."})})]}):l.jsx("p",{className:"text-sm text-gray-500",children:"Brak danych"})]})}function ji({materials:e}){const t=[...e].sort((n,r)=>n.materialName.localeCompare(r.materialName,"pl"));return l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-gray-200 text-left text-gray-500 uppercase text-xs",children:[l.jsx("th",{className:"pb-2 pr-4",children:"Nazwa"}),l.jsx("th",{className:"pb-2 pr-4",children:"Kod"}),l.jsx("th",{className:"pb-2 pr-4 text-right",children:"Zużycie"}),l.jsx("th",{className:"pb-2 pr-4 text-right",children:"Cena netto"}),l.jsx("th",{className:"pb-2 pr-4 text-right",children:"Cena brutto"}),l.jsx("th",{className:"pb-2 pr-4 text-right",children:"Wartość netto"}),l.jsx("th",{className:"pb-2 text-right",children:"Wartość brutto"})]})}),l.jsx("tbody",{children:t.map(n=>l.jsxs("tr",{className:"border-b border-gray-100 hover:bg-gray-50",children:[l.jsx("td",{className:"py-2 pr-4 font-medium",children:n.materialName}),l.jsx("td",{className:"py-2 pr-4 text-gray-500 font-mono text-xs",children:n.materialCode}),l.jsx("td",{className:"py-2 pr-4 text-right font-semibold",children:n.totalQuantity}),l.jsxs("td",{className:"py-2 pr-4 text-right text-gray-600",children:[n.netPrice.toFixed(2)," zł"]}),l.jsxs("td",{className:"py-2 pr-4 text-right text-gray-600",children:[n.grossPrice.toFixed(2)," zł"]}),l.jsxs("td",{className:"py-2 pr-4 text-right font-medium text-emerald-700",children:[n.netValue.toFixed(2)," zł"]}),l.jsxs("td",{className:"py-2 text-right font-medium text-emerald-700",children:[n.grossValue.toFixed(2)," zł"]})]},n.materialId))}),l.jsx("tfoot",{children:l.jsxs("tr",{className:"border-t-2 border-gray-300 font-semibold",children:[l.jsx("td",{colSpan:5,className:"py-2 pr-4 text-right",children:"Suma:"}),l.jsxs("td",{className:"py-2 pr-4 text-right text-emerald-700",children:[t.reduce((n,r)=>n+r.netValue,0).toFixed(2)," zł"]}),l.jsxs("td",{className:"py-2 text-right text-emerald-700",children:[t.reduce((n,r)=>n+r.grossValue,0).toFixed(2)," zł"]})]})})]})})}function aa({open:e,title:t,message:n,onConfirm:r,onCancel:a}){return e?l.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center z-50",children:l.jsxs("div",{className:"bg-white rounded-xl shadow-xl p-6 max-w-md w-full mx-4",children:[l.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:t}),l.jsx("p",{className:"text-sm text-gray-600 mb-6",children:n}),l.jsxs("div",{className:"flex justify-end gap-3",children:[l.jsx("button",{onClick:a,className:"btn-secondary",children:"Anuluj"}),l.jsx("button",{onClick:r,className:"btn-danger",children:"Potwierdź"})]})]})}):null}function i1(){const[e,t]=k.useState([]),[n,r]=k.useState(""),[a,s]=k.useState("true"),[i,o]=k.useState(!0),[u,c]=k.useState(null),[d,f]=k.useState(new Set),y=async()=>{o(!0);try{const S={};n&&(S.search=n),a!=="all"&&(S.active=a);const h=await To(S);t(h)}catch{T.error("Błąd wczytywania materiałów")}finally{o(!1)}};k.useEffect(()=>{y()},[n,a]);const C=S=>{c({title:S.isActive?"Dezaktywacja materiału":"Aktywacja materiału",message:`Czy na pewno chcesz ${S.isActive?"dezaktywować":"aktywować"} materiał "${S.name}"?`,onConfirm:async()=>{try{await Bv(S.id),T.success(S.isActive?"Materiał dezaktywowany":"Materiał aktywowany"),y()}catch{T.error("Błąd zmiany statusu")}c(null)}})},x=S=>{c({title:"Usuwanie materiału",message:`Czy na pewno chcesz usunąć materiał "${S.name}"? Tej operacji nie można cofnąć.`,onConfirm:async()=>{var h,E;try{await Wv(S.id),T.success("Materiał usunięty"),f(p=>{const w=new Set(p);return w.delete(S.id),w}),y()}catch(p){T.error(((E=(h=p.response)==null?void 0:h.data)==null?void 0:E.error)||"Błąd usuwania")}c(null)}})},N=()=>{c({title:"Usuwanie wielu materiałów",message:`Czy na pewno chcesz usunąć ${d.size} zaznaczonych materiałów? Tej operacji nie można cofnąć.`,onConfirm:async()=>{var S,h;try{const E=await Vv([...d]);T.success(`Usunięto ${E.deleted} materiałów`),f(new Set),y()}catch(E){T.error(((h=(S=E.response)==null?void 0:S.data)==null?void 0:h.error)||"Błąd usuwania")}c(null)}})},j=S=>{f(h=>{const E=new Set(h);return E.has(S)?E.delete(S):E.add(S),E})},v=()=>{d.size===e.length?f(new Set):f(new Set(e.map(S=>S.id)))},m=k.useRef(null),g=async S=>{var p,w;const h=S.target.files[0];if(!h)return;const E=await h.text();try{const z=await mx(E);T.success(`Zaimportowano: ${z.created} nowych, ${z.skipped} pominięto`),z.errors.length>0&&T.error(`Błędy w wierszach: ${z.errors.map(P=>P.row).join(", ")}`),y()}catch(z){T.error(((w=(p=z.response)==null?void 0:p.data)==null?void 0:w.error)||"Błąd importu")}S.target.value=""};return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsx("h1",{className:"page-title",children:"Materiały"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("a",{href:fx(),download:!0,className:"btn-secondary text-xs",children:"Eksport CSV"}),l.jsx("button",{onClick:()=>{var S;return(S=m.current)==null?void 0:S.click()},className:"btn-secondary text-xs",children:"Import CSV"}),l.jsx("input",{ref:m,type:"file",accept:".csv",className:"hidden",onChange:g}),l.jsx(Gn,{to:"/materials/new",className:"btn-primary",children:"+ Dodaj materiał"})]})]}),l.jsx("div",{className:"card mb-6",children:l.jsxs("div",{className:"flex flex-wrap gap-4 items-end",children:[l.jsxs("div",{className:"flex-1 min-w-[200px]",children:[l.jsx("label",{className:"label-field",children:"Szukaj"}),l.jsx("input",{type:"text",className:"input-field",placeholder:"Nazwa lub kod...",value:n,onChange:S=>r(S.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Status"}),l.jsxs("select",{className:"input-field",value:a,onChange:S=>s(S.target.value),children:[l.jsx("option",{value:"true",children:"Aktywne"}),l.jsx("option",{value:"false",children:"Nieaktywne"}),l.jsx("option",{value:"all",children:"Wszystkie"})]})]})]})}),d.size>0&&l.jsxs("div",{className:"mb-4 flex items-center gap-3 bg-red-50 border border-red-200 rounded-lg px-4 py-2",children:[l.jsxs("span",{className:"text-sm text-red-700 font-medium",children:["Zaznaczono: ",d.size]}),l.jsx("button",{onClick:N,className:"text-xs font-medium text-red-600 hover:text-red-800 bg-white border border-red-300 rounded px-3 py-1",children:"Usuń zaznaczone"}),l.jsx("button",{onClick:()=>f(new Set),className:"text-xs text-gray-500 hover:text-gray-700",children:"Odznacz wszystkie"})]}),l.jsx("div",{className:"card overflow-x-auto",children:i?l.jsx("p",{className:"text-sm text-gray-500 py-4",children:"Ładowanie..."}):e.length===0?l.jsx("p",{className:"text-sm text-gray-500 py-4",children:"Brak materiałów do wyświetlenia"}):l.jsxs("table",{className:"w-full text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-gray-200 text-left text-gray-500 uppercase text-xs",children:[l.jsx("th",{className:"pb-3 pr-2 w-8",children:l.jsx("input",{type:"checkbox",checked:e.length>0&&d.size===e.length,onChange:v,className:"rounded"})}),l.jsx("th",{className:"pb-3 pr-4",children:"Nazwa"}),l.jsx("th",{className:"pb-3 pr-4",children:"Kod"}),l.jsx("th",{className:"pb-3 pr-4",children:"Typ/Rozmiar"}),l.jsx("th",{className:"pb-3 pr-4 text-right",children:"Cena netto"}),l.jsx("th",{className:"pb-3 pr-4 text-right",children:"Cena brutto"}),l.jsx("th",{className:"pb-3 pr-4 text-center",children:"Grupy"}),l.jsx("th",{className:"pb-3 pr-4 text-center",children:"Status"}),l.jsx("th",{className:"pb-3",children:"Akcje"})]})}),l.jsx("tbody",{children:e.map(S=>l.jsxs("tr",{className:`border-b border-gray-100 hover:bg-gray-50 ${d.has(S.id)?"bg-indigo-50":""}`,children:[l.jsx("td",{className:"py-3 pr-2",children:l.jsx("input",{type:"checkbox",checked:d.has(S.id),onChange:()=>j(S.id),className:"rounded"})}),l.jsx("td",{className:"py-3 pr-4 font-medium",children:S.name}),l.jsx("td",{className:"py-3 pr-4 text-gray-600 font-mono text-xs",children:S.code}),l.jsx("td",{className:"py-3 pr-4 text-gray-600",children:S.typeSize||"—"}),l.jsxs("td",{className:"py-3 pr-4 text-right",children:[S.netPrice.toFixed(2)," zł"]}),l.jsxs("td",{className:"py-3 pr-4 text-right",children:[S.grossPrice.toFixed(2)," zł"]}),l.jsx("td",{className:"py-3 pr-4 text-center",children:S.groupCount>0?l.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs bg-blue-100 text-blue-700",children:S.groupCount}):"—"}),l.jsx("td",{className:"py-3 pr-4 text-center",children:l.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${S.isActive?"bg-green-100 text-green-700":"bg-gray-100 text-gray-500"}`,children:S.isActive?"Aktywny":"Nieaktywny"})}),l.jsx("td",{className:"py-3",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Gn,{to:`/materials/${S.id}`,className:"text-indigo-600 hover:text-indigo-800 text-xs font-medium",children:"Edytuj"}),l.jsx("button",{onClick:()=>C(S),className:`text-xs font-medium ${S.isActive?"text-red-600 hover:text-red-800":"text-green-600 hover:text-green-800"}`,children:S.isActive?"Dezaktywuj":"Aktywuj"}),l.jsx("button",{onClick:()=>x(S),className:"text-red-600 hover:text-red-800 text-xs font-medium",children:"Usuń"})]})})]},S.id))})]})}),l.jsx(aa,{open:!!u,title:u==null?void 0:u.title,message:u==null?void 0:u.message,onConfirm:u==null?void 0:u.onConfirm,onCancel:()=>c(null)})]})}function kc(){const{id:e}=Hf(),t=Xr(),n=!!e,[r,a]=k.useState({name:"",code:"",typeSize:"",netPrice:"",vatRate:"23",grossPrice:"",description:""}),[s,i]=k.useState([]),[o,u]=k.useState([]),[c,d]=k.useState([]),[f,y]=k.useState(!1),[C,x]=k.useState(!1);k.useEffect(()=>{N(),n&&j()},[e]);const N=async()=>{try{const p=await _o();d(p)}catch{T.error("Błąd wczytywania grup")}},j=async()=>{y(!0);try{const p=await Av(e);a({name:p.name,code:p.code,typeSize:p.typeSize||"",netPrice:String(p.netPrice),vatRate:String(p.vatRate),grossPrice:String(p.grossPrice),description:p.description||""}),i(p.attributes.map(w=>({attributeName:w.attributeName,attributeValue:w.attributeValue}))),u(p.groups.map(w=>w.id))}catch{T.error("Błąd wczytywania materiału"),t("/materials")}finally{y(!1)}},v=(p,w)=>{const z={...r,[p]:w};if(p==="netPrice"||p==="vatRate"){const P=parseFloat(p==="netPrice"?w:z.netPrice)||0,M=parseFloat(p==="vatRate"?w:z.vatRate)||0;z.grossPrice=(P*(1+M/100)).toFixed(2)}a(z)},m=()=>{i([...s,{attributeName:"",attributeValue:""}])},g=p=>{i(s.filter((w,z)=>z!==p))},S=(p,w,z)=>{const P=[...s];P[p]={...P[p],[w]:z},i(P)},h=p=>{u(w=>w.includes(p)?w.filter(z=>z!==p):[...w,p])},E=async p=>{var P,M;if(p.preventDefault(),!r.name.trim()||!r.code.trim()){T.error("Nazwa i kod są wymagane");return}const w=s.filter(L=>L.attributeName.trim()&&L.attributeValue.trim()),z={name:r.name.trim(),code:r.code.trim(),typeSize:r.typeSize.trim()||null,netPrice:parseFloat(r.netPrice)||0,vatRate:parseFloat(r.vatRate)||23,grossPrice:parseFloat(r.grossPrice)||0,description:r.description.trim()||null,attributes:w,groupIds:o};x(!0);try{n?(await Uv(e,z),T.success("Materiał zaktualizowany")):(await $v(z),T.success("Materiał dodany")),t("/materials")}catch(L){T.error(((M=(P=L.response)==null?void 0:P.data)==null?void 0:M.error)||"Błąd zapisu")}finally{x(!1)}};return f?l.jsx("p",{className:"text-sm text-gray-500",children:"Ładowanie..."}):l.jsxs("div",{className:"max-w-3xl",children:[l.jsx("div",{className:"flex items-center justify-between mb-6",children:l.jsx("h1",{className:"page-title",children:n?"Edytuj materiał":"Nowy materiał"})}),l.jsxs("form",{onSubmit:E,children:[l.jsxs("div",{className:"card mb-6",children:[l.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Dane podstawowe"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Nazwa *"}),l.jsx("input",{type:"text",className:"input-field",value:r.name,onChange:p=>v("name",p.target.value),required:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Kod *"}),l.jsx("input",{type:"text",className:"input-field",value:r.code,onChange:p=>v("code",p.target.value),required:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Typ / Rozmiar"}),l.jsx("input",{type:"text",className:"input-field",value:r.typeSize,onChange:p=>v("typeSize",p.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Cena netto (zł)"}),l.jsx("input",{type:"number",step:"0.01",min:"0",className:"input-field",value:r.netPrice,onChange:p=>v("netPrice",p.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Stawka VAT (%)"}),l.jsx("input",{type:"number",step:"1",min:"0",max:"100",className:"input-field",value:r.vatRate,onChange:p=>v("vatRate",p.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Cena brutto (zł)"}),l.jsx("input",{type:"number",step:"0.01",min:"0",className:"input-field bg-gray-50",value:r.grossPrice,readOnly:!0})]}),l.jsxs("div",{className:"md:col-span-2",children:[l.jsx("label",{className:"label-field",children:"Opis"}),l.jsx("textarea",{className:"input-field",rows:3,value:r.description,onChange:p=>v("description",p.target.value)})]})]})]}),l.jsxs("div",{className:"card mb-6",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h2",{className:"text-lg font-semibold",children:"Atrybuty"}),l.jsx("button",{type:"button",onClick:m,className:"btn-secondary text-xs",children:"+ Dodaj atrybut"})]}),s.length===0?l.jsx("p",{className:"text-sm text-gray-400",children:'Brak atrybutów — kliknij „Dodaj atrybut"'}):l.jsx("div",{className:"space-y-3",children:s.map((p,w)=>l.jsxs("div",{className:"flex gap-3 items-start",children:[l.jsx("div",{className:"flex-1",children:l.jsx("input",{type:"text",className:"input-field",placeholder:"Nazwa atrybutu",value:p.attributeName,onChange:z=>S(w,"attributeName",z.target.value)})}),l.jsx("div",{className:"flex-1",children:l.jsx("input",{type:"text",className:"input-field",placeholder:"Wartość",value:p.attributeValue,onChange:z=>S(w,"attributeValue",z.target.value)})}),l.jsx("button",{type:"button",onClick:()=>g(w),className:"text-red-500 hover:text-red-700 p-2 text-lg leading-none",children:"×"})]},w))})]}),l.jsxs("div",{className:"card mb-6",children:[l.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Grupy"}),c.length===0?l.jsx("p",{className:"text-sm text-gray-400",children:"Brak grup — utwórz grupy w module Grupy"}):l.jsx("div",{className:"flex flex-wrap gap-3",children:c.map(p=>l.jsxs("label",{className:`flex items-center gap-2 px-3 py-2 rounded-lg border cursor-pointer transition-colors text-sm ${o.includes(p.id)?"border-indigo-500 bg-indigo-50 text-indigo-700":"border-gray-200 hover:border-gray-300"}`,children:[l.jsx("input",{type:"checkbox",checked:o.includes(p.id),onChange:()=>h(p.id),className:"sr-only"}),p.name]},p.id))})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx("button",{type:"submit",disabled:C,className:"btn-primary",children:C?"Zapisywanie...":"Zapisz"}),l.jsx("button",{type:"button",onClick:()=>t("/materials"),className:"btn-secondary",children:"Anuluj"})]})]})]})}function l1(){const[e,t]=k.useState([]),[n,r]=k.useState(!0),[a,s]=k.useState(""),[i,o]=k.useState(null),[u,c]=k.useState(""),[d,f]=k.useState(""),[y,C]=k.useState(!1),[x,N]=k.useState(null),[j,v]=k.useState(null),[m,g]=k.useState([]),S=async()=>{r(!0);try{const P={};a&&(P.search=a);const M=await _o(P);t(M)}catch{T.error("Błąd wczytywania grup")}finally{r(!1)}};k.useEffect(()=>{S()},[a]);const h=(P=null)=>{P?(o(P),c(P.name),f(P.description||"")):(o({}),c(""),f(""))},E=()=>{o(null),c(""),f("")},p=async()=>{var P,M;if(!u.trim()){T.error("Nazwa grupy jest wymagana");return}C(!0);try{const L={name:u.trim(),description:d.trim()||null};i.id?(await Yv(i.id,L),T.success("Grupa zaktualizowana")):(await Qv(L),T.success("Grupa dodana")),E(),S()}catch(L){T.error(((M=(P=L.response)==null?void 0:P.data)==null?void 0:M.error)||"Błąd zapisu")}finally{C(!1)}},w=P=>{N({title:"Usuwanie grupy",message:`Czy na pewno chcesz usunąć grupę "${P.name}"?${P.materialCount>0?` Grupa ma ${P.materialCount} powiązanych materiałów.`:""}`,onConfirm:async()=>{var M,L;try{await qv(P.id),T.success("Grupa usunięta"),S()}catch(te){T.error(((L=(M=te.response)==null?void 0:M.data)==null?void 0:L.error)||"Błąd usuwania")}N(null)}})},z=async P=>{if(j===P){v(null);return}try{const M=await Hv(P);g(M.materials),v(P)}catch{T.error("Błąd wczytywania materiałów grupy")}};return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsx("h1",{className:"page-title",children:"Grupy"}),l.jsx("button",{onClick:()=>h(),className:"btn-primary",children:"+ Dodaj grupę"})]}),l.jsx("div",{className:"card mb-6",children:l.jsxs("div",{className:"flex-1 min-w-[200px]",children:[l.jsx("label",{className:"label-field",children:"Szukaj"}),l.jsx("input",{type:"text",className:"input-field max-w-md",placeholder:"Nazwa grupy...",value:a,onChange:P=>s(P.target.value)})]})}),i&&l.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center z-50",children:l.jsxs("div",{className:"bg-white rounded-xl shadow-xl p-6 max-w-md w-full mx-4",children:[l.jsx("h3",{className:"text-lg font-semibold mb-4",children:i.id?"Edytuj grupę":"Nowa grupa"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Nazwa *"}),l.jsx("input",{type:"text",className:"input-field",value:u,onChange:P=>c(P.target.value),autoFocus:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Opis"}),l.jsx("textarea",{className:"input-field",rows:3,value:d,onChange:P=>f(P.target.value)})]})]}),l.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[l.jsx("button",{onClick:E,className:"btn-secondary",children:"Anuluj"}),l.jsx("button",{onClick:p,disabled:y,className:"btn-primary",children:y?"Zapisywanie...":"Zapisz"})]})]})}),l.jsx("div",{className:"card overflow-x-auto",children:n?l.jsx("p",{className:"text-sm text-gray-500 py-4",children:"Ładowanie..."}):e.length===0?l.jsx("p",{className:"text-sm text-gray-500 py-4",children:"Brak grup do wyświetlenia"}):l.jsxs("table",{className:"w-full text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-gray-200 text-left text-gray-500 uppercase text-xs",children:[l.jsx("th",{className:"pb-3 pr-4",children:"Nazwa"}),l.jsx("th",{className:"pb-3 pr-4",children:"Opis"}),l.jsx("th",{className:"pb-3 pr-4 text-center",children:"Materiały"}),l.jsx("th",{className:"pb-3",children:"Akcje"})]})}),l.jsx("tbody",{children:e.map(P=>l.jsxs(k.Fragment,{children:[l.jsxs("tr",{className:"border-b border-gray-100 hover:bg-gray-50",children:[l.jsx("td",{className:"py-3 pr-4 font-medium",children:P.name}),l.jsx("td",{className:"py-3 pr-4 text-gray-600",children:P.description||"—"}),l.jsx("td",{className:"py-3 pr-4 text-center",children:l.jsx("button",{onClick:()=>z(P.id),className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs bg-blue-100 text-blue-700 hover:bg-blue-200 transition-colors",children:P.materialCount})}),l.jsx("td",{className:"py-3",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>h(P),className:"text-indigo-600 hover:text-indigo-800 text-xs font-medium",children:"Edytuj"}),l.jsx("button",{onClick:()=>w(P),className:"text-red-600 hover:text-red-800 text-xs font-medium",children:"Usuń"})]})})]}),j===P.id&&l.jsx("tr",{children:l.jsx("td",{colSpan:4,className:"bg-gray-50 px-6 py-3",children:m.length===0?l.jsx("p",{className:"text-xs text-gray-400",children:"Brak materiałów w tej grupie"}):l.jsxs("div",{className:"text-xs space-y-1",children:[l.jsx("p",{className:"font-medium text-gray-500 mb-2",children:"Materiały w grupie:"}),m.map(M=>l.jsxs("div",{className:"flex gap-4",children:[l.jsx("span",{className:`font-medium ${M.isActive?"text-gray-700":"text-gray-400"}`,children:M.name}),l.jsx("span",{className:"text-gray-400 font-mono",children:M.code}),!M.isActive&&l.jsx("span",{className:"text-gray-400 italic",children:"(nieaktywny)"})]},M.id))]})})})]},P.id))})]})}),l.jsx(aa,{open:!!x,title:x==null?void 0:x.title,message:x==null?void 0:x.message,onConfirm:x==null?void 0:x.onConfirm,onCancel:()=>N(null)})]})}function o1(){const[e,t]=k.useState([]),[n,r]=k.useState(""),[a,s]=k.useState("true"),[i,o]=k.useState(!0),[u,c]=k.useState(null),[d,f]=k.useState(new Set),y=async()=>{o(!0);try{const h={};n&&(h.search=n),a!=="all"&&(h.active=a);const E=await Ep(h);t(E)}catch{T.error("Błąd wczytywania produktów")}finally{o(!1)}};k.useEffect(()=>{y()},[n,a]);const C=h=>{c({title:h.isActive?"Dezaktywacja produktu":"Aktywacja produktu",message:`Czy na pewno chcesz ${h.isActive?"dezaktywować":"aktywować"} produkt "${h.name}"?`,onConfirm:async()=>{try{await Zv(h.id),T.success(h.isActive?"Produkt dezaktywowany":"Produkt aktywowany"),y()}catch{T.error("Błąd zmiany statusu")}c(null)}})},x=async h=>{var E,p;try{const w=await Jv(h.id);T.success(`Skopiowano jako "${w.name}"`),y()}catch(w){T.error(((p=(E=w.response)==null?void 0:E.data)==null?void 0:p.error)||"Błąd duplikowania")}},N=h=>{c({title:"Usuwanie produktu",message:`Czy na pewno chcesz usunąć produkt "${h.name}"? Tej operacji nie można cofnąć.`,onConfirm:async()=>{var E,p;try{await ex(h.id),T.success("Produkt usunięty"),f(w=>{const z=new Set(w);return z.delete(h.id),z}),y()}catch(w){T.error(((p=(E=w.response)==null?void 0:E.data)==null?void 0:p.error)||"Błąd usuwania")}c(null)}})},j=()=>{c({title:"Usuwanie wielu produktów",message:`Czy na pewno chcesz usunąć ${d.size} zaznaczonych produktów? Tej operacji nie można cofnąć.`,onConfirm:async()=>{var h,E;try{const p=await tx([...d]);T.success(`Usunięto ${p.deleted} produktów`),f(new Set),y()}catch(p){T.error(((E=(h=p.response)==null?void 0:h.data)==null?void 0:E.error)||"Błąd usuwania")}c(null)}})},v=h=>{f(E=>{const p=new Set(E);return p.has(h)?p.delete(h):p.add(h),p})},m=()=>{d.size===e.length?f(new Set):f(new Set(e.map(h=>h.id)))},g=k.useRef(null),S=async h=>{var w,z;const E=h.target.files[0];if(!E)return;const p=await E.text();try{const P=await hx(p);T.success(`Zaimportowano: ${P.created} nowych, ${P.skipped} pominięto`),P.errors.length>0&&T.error(`Błędy w wierszach: ${P.errors.map(M=>M.row).join(", ")}`),y()}catch(P){T.error(((z=(w=P.response)==null?void 0:w.data)==null?void 0:z.error)||"Błąd importu")}h.target.value=""};return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsx("h1",{className:"page-title",children:"Produkty"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("a",{href:px(),download:!0,className:"btn-secondary text-xs",children:"Eksport CSV"}),l.jsx("button",{onClick:()=>{var h;return(h=g.current)==null?void 0:h.click()},className:"btn-secondary text-xs",children:"Import CSV"}),l.jsx("input",{ref:g,type:"file",accept:".csv",className:"hidden",onChange:S}),l.jsx(Gn,{to:"/products/new",className:"btn-primary",children:"+ Dodaj produkt"})]})]}),l.jsx("div",{className:"card mb-6",children:l.jsxs("div",{className:"flex flex-wrap gap-4 items-end",children:[l.jsxs("div",{className:"flex-1 min-w-[200px]",children:[l.jsx("label",{className:"label-field",children:"Szukaj"}),l.jsx("input",{type:"text",className:"input-field",placeholder:"Nazwa lub kod...",value:n,onChange:h=>r(h.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Status"}),l.jsxs("select",{className:"input-field",value:a,onChange:h=>s(h.target.value),children:[l.jsx("option",{value:"true",children:"Aktywne"}),l.jsx("option",{value:"false",children:"Nieaktywne"}),l.jsx("option",{value:"all",children:"Wszystkie"})]})]})]})}),d.size>0&&l.jsxs("div",{className:"mb-4 flex items-center gap-3 bg-red-50 border border-red-200 rounded-lg px-4 py-2",children:[l.jsxs("span",{className:"text-sm text-red-700 font-medium",children:["Zaznaczono: ",d.size]}),l.jsx("button",{onClick:j,className:"text-xs font-medium text-red-600 hover:text-red-800 bg-white border border-red-300 rounded px-3 py-1",children:"Usuń zaznaczone"}),l.jsx("button",{onClick:()=>f(new Set),className:"text-xs text-gray-500 hover:text-gray-700",children:"Odznacz wszystkie"})]}),l.jsx("div",{className:"card overflow-x-auto",children:i?l.jsx("p",{className:"text-sm text-gray-500 py-4",children:"Ładowanie..."}):e.length===0?l.jsx("p",{className:"text-sm text-gray-500 py-4",children:"Brak produktów do wyświetlenia"}):l.jsxs("table",{className:"w-full text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-gray-200 text-left text-gray-500 uppercase text-xs",children:[l.jsx("th",{className:"pb-3 pr-2 w-8",children:l.jsx("input",{type:"checkbox",checked:e.length>0&&d.size===e.length,onChange:m,className:"rounded"})}),l.jsx("th",{className:"pb-3 pr-4",children:"Nazwa"}),l.jsx("th",{className:"pb-3 pr-4",children:"Kod"}),l.jsx("th",{className:"pb-3 pr-4 text-right",children:"Cena netto"}),l.jsx("th",{className:"pb-3 pr-4 text-right",children:"Cena brutto"}),l.jsx("th",{className:"pb-3 pr-4 text-center",children:"Materiały w składzie"}),l.jsx("th",{className:"pb-3 pr-4 text-center",children:"Status"}),l.jsx("th",{className:"pb-3",children:"Akcje"})]})}),l.jsx("tbody",{children:e.map(h=>l.jsxs("tr",{className:`border-b border-gray-100 hover:bg-gray-50 ${d.has(h.id)?"bg-indigo-50":""}`,children:[l.jsx("td",{className:"py-3 pr-2",children:l.jsx("input",{type:"checkbox",checked:d.has(h.id),onChange:()=>v(h.id),className:"rounded"})}),l.jsx("td",{className:"py-3 pr-4 font-medium",children:h.name}),l.jsx("td",{className:"py-3 pr-4 text-gray-600 font-mono text-xs",children:h.code}),l.jsxs("td",{className:"py-3 pr-4 text-right",children:[(h.netPrice||0).toFixed(2)," zł"]}),l.jsxs("td",{className:"py-3 pr-4 text-right",children:[(h.grossPrice||0).toFixed(2)," zł"]}),l.jsx("td",{className:"py-3 pr-4 text-center",children:l.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs ${h.materialCount>0?"bg-blue-100 text-blue-700":"bg-yellow-100 text-yellow-700"}`,children:h.materialCount})}),l.jsx("td",{className:"py-3 pr-4 text-center",children:l.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${h.isActive?"bg-green-100 text-green-700":"bg-gray-100 text-gray-500"}`,children:h.isActive?"Aktywny":"Nieaktywny"})}),l.jsx("td",{className:"py-3",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Gn,{to:`/products/${h.id}`,className:"text-indigo-600 hover:text-indigo-800 text-xs font-medium",children:"Edytuj"}),l.jsx("button",{onClick:()=>x(h),className:"text-purple-600 hover:text-purple-800 text-xs font-medium",children:"Duplikuj"}),l.jsx("button",{onClick:()=>C(h),className:`text-xs font-medium ${h.isActive?"text-red-600 hover:text-red-800":"text-green-600 hover:text-green-800"}`,children:h.isActive?"Dezaktywuj":"Aktywuj"}),l.jsx("button",{onClick:()=>N(h),className:"text-red-600 hover:text-red-800 text-xs font-medium",children:"Usuń"})]})})]},h.id))})]})}),l.jsx(aa,{open:!!u,title:u==null?void 0:u.title,message:u==null?void 0:u.message,onConfirm:u==null?void 0:u.onConfirm,onCancel:()=>c(null)})]})}function jc(){const{id:e}=Hf(),t=Xr(),n=!!e,[r,a]=k.useState({name:"",code:"",description:"",netPrice:"",vatRate:"23",grossPrice:""}),[s,i]=k.useState([]),[o,u]=k.useState([]),[c,d]=k.useState(!1),[f,y]=k.useState(!1);k.useEffect(()=>{C(),n&&x()},[e]);const C=async()=>{try{const h=await To({active:"true"});u(h)}catch{T.error("Błąd wczytywania materiałów")}},x=async()=>{d(!0);try{const h=await Gv(e);a({name:h.name,code:h.code,description:h.description||"",netPrice:String(h.netPrice||""),vatRate:String(h.vatRate||"23"),grossPrice:String(h.grossPrice||"")}),i(h.materials.map(E=>({materialId:E.materialId,quantity:String(E.quantity)})))}catch{T.error("Błąd wczytywania produktu"),t("/products")}finally{d(!1)}},N=()=>{i([...s,{materialId:"",quantity:""}])},j=h=>{i(s.filter((E,p)=>p!==h))},v=(h,E,p)=>{const w=[...s];w[h]={...w[h],[E]:E==="materialId"?parseInt(p)||"":p},i(w)},m=async h=>{var w,z;if(h.preventDefault(),!r.name.trim()||!r.code.trim()){T.error("Nazwa i kod są wymagane");return}const E=s.filter(P=>P.materialId&&P.quantity);for(const P of E)if(parseFloat(P.quantity)<=0){T.error("Ilości materiałów muszą być dodatnie");return}const p={name:r.name.trim(),code:r.code.trim(),description:r.description.trim()||null,netPrice:parseFloat(r.netPrice)||0,vatRate:parseFloat(r.vatRate)||23,grossPrice:parseFloat(r.grossPrice)||null,materials:E.map(P=>({materialId:P.materialId,quantity:parseFloat(P.quantity)}))};y(!0);try{n?(await Xv(e,p),T.success("Produkt zaktualizowany")):(await Kv(p),T.success("Produkt dodany")),t("/products")}catch(P){T.error(((z=(w=P.response)==null?void 0:w.data)==null?void 0:z.error)||"Błąd zapisu")}finally{y(!1)}},g=h=>o.find(E=>E.id===h),S=h=>{const E=s.map(p=>p.materialId).filter(p=>p!==h);return o.filter(p=>!E.includes(p.id))};return c?l.jsx("p",{className:"text-sm text-gray-500",children:"Ładowanie..."}):l.jsxs("div",{className:"max-w-3xl",children:[l.jsx("div",{className:"flex items-center justify-between mb-6",children:l.jsx("h1",{className:"page-title",children:n?"Edytuj produkt":"Nowy produkt"})}),l.jsxs("form",{onSubmit:m,children:[l.jsxs("div",{className:"card mb-6",children:[l.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Dane produktu"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Nazwa *"}),l.jsx("input",{type:"text",className:"input-field",value:r.name,onChange:h=>a({...r,name:h.target.value}),required:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Kod *"}),l.jsx("input",{type:"text",className:"input-field",value:r.code,onChange:h=>a({...r,code:h.target.value}),required:!0})]}),l.jsxs("div",{className:"md:col-span-2",children:[l.jsx("label",{className:"label-field",children:"Opis"}),l.jsx("textarea",{className:"input-field",rows:3,value:r.description,onChange:h=>a({...r,description:h.target.value})})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Cena netto"}),l.jsx("input",{type:"number",step:"0.01",min:"0",className:"input-field",value:r.netPrice,onChange:h=>{const E=h.target.value,p=parseFloat(r.vatRate)||23,w=E?(parseFloat(E)*(1+p/100)).toFixed(2):"";a({...r,netPrice:E,grossPrice:w})}})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"VAT %"}),l.jsx("input",{type:"number",step:"1",min:"0",className:"input-field",value:r.vatRate,onChange:h=>{const E=h.target.value,p=parseFloat(r.netPrice)||0,w=p?(p*(1+(parseFloat(E)||23)/100)).toFixed(2):"";a({...r,vatRate:E,grossPrice:w})}})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Cena brutto"}),l.jsx("input",{type:"number",step:"0.01",min:"0",className:"input-field",value:r.grossPrice,onChange:h=>a({...r,grossPrice:h.target.value})})]})]})]}),l.jsxs("div",{className:"card mb-6",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h2",{className:"text-lg font-semibold",children:"Skład produktu (BOM)"}),l.jsx("button",{type:"button",onClick:N,className:"btn-secondary text-xs",children:"+ Dodaj materiał"})]}),s.length===0?l.jsx("p",{className:"text-sm text-gray-400",children:'Brak materiałów — kliknij „Dodaj materiał"'}):l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-[1fr_120px_40px] gap-3 text-xs text-gray-500 font-medium uppercase",children:[l.jsx("span",{children:"Materiał"}),l.jsx("span",{children:"Ilość"}),l.jsx("span",{})]}),s.map((h,E)=>{const p=h.materialId?g(h.materialId):null;return l.jsxs("div",{className:"grid grid-cols-[1fr_120px_40px] gap-3 items-start",children:[l.jsxs("div",{children:[l.jsxs("select",{className:"input-field",value:h.materialId,onChange:w=>v(E,"materialId",w.target.value),children:[l.jsx("option",{value:"",children:"— Wybierz materiał —"}),S(h.materialId).map(w=>l.jsxs("option",{value:w.id,children:[w.name," (",w.code,")"]},w.id))]}),p&&l.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[p.typeSize&&`${p.typeSize} · `,p.netPrice.toFixed(2)," zł netto"]})]}),l.jsx("input",{type:"number",step:"0.0001",min:"0.0001",className:"input-field",placeholder:"Ilość",value:h.quantity,onChange:w=>v(E,"quantity",w.target.value)}),l.jsx("button",{type:"button",onClick:()=>j(E),className:"text-red-500 hover:text-red-700 p-2 text-lg leading-none",children:"×"})]},E)})]})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx("button",{type:"submit",disabled:f,className:"btn-primary",children:f?"Zapisywanie...":"Zapisz"}),l.jsx("button",{type:"button",onClick:()=>t("/products"),className:"btn-secondary",children:"Anuluj"})]})]})]})}function u1(){const[e,t]=k.useState([]),[n,r]=k.useState(""),[a,s]=k.useState(!0),[i,o]=k.useState(null),[u,c]=k.useState({name:"",taxId:"",email:"",phone:"",note:""}),[d,f]=k.useState(!1),[y,C]=k.useState(null),[x,N]=k.useState(new Set),j=async()=>{s(!0);try{const w={};n&&(w.search=n);const z=await Pp(w);t(z)}catch{T.error("Błąd wczytywania klientów")}finally{s(!1)}};k.useEffect(()=>{j()},[n]);const v=(w=null)=>{w?(o(w),c({name:w.name,taxId:w.taxId||"",email:w.email||"",phone:w.phone||"",note:w.note||""})):(o({}),c({name:"",taxId:"",email:"",phone:"",note:""}))},m=()=>{o(null),c({name:"",taxId:"",email:"",phone:"",note:""})},g=async()=>{var z,P;if(!u.name.trim()){T.error("Nazwa klienta jest wymagana");return}const w={name:u.name.trim(),taxId:u.taxId.trim()||null,email:u.email.trim()||null,phone:u.phone.trim()||null,note:u.note.trim()||null};f(!0);try{i.id?(await rx(i.id,w),T.success("Klient zaktualizowany")):(await nx(w),T.success("Klient dodany")),m(),j()}catch(M){T.error(((P=(z=M.response)==null?void 0:z.data)==null?void 0:P.error)||"Błąd zapisu")}finally{f(!1)}},S=w=>{C({title:"Usuwanie klienta",message:`Czy na pewno chcesz usunąć klienta "${w.name}"? Tej operacji nie można cofnąć.`,onConfirm:async()=>{var z,P;try{await ax(w.id),T.success("Klient usunięty"),N(M=>{const L=new Set(M);return L.delete(w.id),L}),j()}catch(M){T.error(((P=(z=M.response)==null?void 0:z.data)==null?void 0:P.error)||"Błąd usuwania")}C(null)}})},h=()=>{C({title:"Usuwanie wielu klientów",message:`Czy na pewno chcesz usunąć ${x.size} zaznaczonych klientów? Tej operacji nie można cofnąć.`,onConfirm:async()=>{var w,z;try{const P=await sx([...x]);T.success(`Usunięto ${P.deleted} klientów`),N(new Set),j()}catch(P){T.error(((z=(w=P.response)==null?void 0:w.data)==null?void 0:z.error)||"Błąd usuwania")}C(null)}})},E=w=>{N(z=>{const P=new Set(z);return P.has(w)?P.delete(w):P.add(w),P})},p=()=>{x.size===e.length?N(new Set):N(new Set(e.map(w=>w.id)))};return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsx("h1",{className:"page-title",children:"Klienci"}),l.jsx("button",{onClick:()=>v(),className:"btn-primary",children:"+ Dodaj klienta"})]}),l.jsx("div",{className:"card mb-6",children:l.jsxs("div",{className:"flex-1 min-w-[200px]",children:[l.jsx("label",{className:"label-field",children:"Szukaj"}),l.jsx("input",{type:"text",className:"input-field max-w-md",placeholder:"Nazwa, NIP lub e-mail...",value:n,onChange:w=>r(w.target.value)})]})}),x.size>0&&l.jsxs("div",{className:"mb-4 flex items-center gap-3 bg-red-50 border border-red-200 rounded-lg px-4 py-2",children:[l.jsxs("span",{className:"text-sm text-red-700 font-medium",children:["Zaznaczono: ",x.size]}),l.jsx("button",{onClick:h,className:"text-xs font-medium text-red-600 hover:text-red-800 bg-white border border-red-300 rounded px-3 py-1",children:"Usuń zaznaczone"}),l.jsx("button",{onClick:()=>N(new Set),className:"text-xs text-gray-500 hover:text-gray-700",children:"Odznacz wszystkie"})]}),i&&l.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center z-50",children:l.jsxs("div",{className:"bg-white rounded-xl shadow-xl p-6 max-w-lg w-full mx-4",children:[l.jsx("h3",{className:"text-lg font-semibold mb-4",children:i.id?"Edytuj klienta":"Nowy klient"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Nazwa *"}),l.jsx("input",{type:"text",className:"input-field",value:u.name,onChange:w=>c({...u,name:w.target.value}),autoFocus:!0})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"NIP"}),l.jsx("input",{type:"text",className:"input-field",value:u.taxId,onChange:w=>c({...u,taxId:w.target.value})})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"E-mail"}),l.jsx("input",{type:"email",className:"input-field",value:u.email,onChange:w=>c({...u,email:w.target.value})})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Telefon"}),l.jsx("input",{type:"text",className:"input-field",value:u.phone,onChange:w=>c({...u,phone:w.target.value})})]})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Notatka"}),l.jsx("textarea",{className:"input-field",rows:2,value:u.note,onChange:w=>c({...u,note:w.target.value})})]})]}),l.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[l.jsx("button",{onClick:m,className:"btn-secondary",children:"Anuluj"}),l.jsx("button",{onClick:g,disabled:d,className:"btn-primary",children:d?"Zapisywanie...":"Zapisz"})]})]})}),l.jsx("div",{className:"card overflow-x-auto",children:a?l.jsx("p",{className:"text-sm text-gray-500 py-4",children:"Ładowanie..."}):e.length===0?l.jsx("p",{className:"text-sm text-gray-500 py-4",children:"Brak klientów do wyświetlenia"}):l.jsxs("table",{className:"w-full text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-gray-200 text-left text-gray-500 uppercase text-xs",children:[l.jsx("th",{className:"pb-3 pr-2 w-8",children:l.jsx("input",{type:"checkbox",checked:e.length>0&&x.size===e.length,onChange:p,className:"rounded"})}),l.jsx("th",{className:"pb-3 pr-4",children:"Nazwa"}),l.jsx("th",{className:"pb-3 pr-4",children:"NIP"}),l.jsx("th",{className:"pb-3 pr-4",children:"E-mail"}),l.jsx("th",{className:"pb-3 pr-4",children:"Telefon"}),l.jsx("th",{className:"pb-3",children:"Akcje"})]})}),l.jsx("tbody",{children:e.map(w=>l.jsxs("tr",{className:`border-b border-gray-100 hover:bg-gray-50 ${x.has(w.id)?"bg-indigo-50":""}`,children:[l.jsx("td",{className:"py-3 pr-2",children:l.jsx("input",{type:"checkbox",checked:x.has(w.id),onChange:()=>E(w.id),className:"rounded"})}),l.jsx("td",{className:"py-3 pr-4 font-medium",children:w.name}),l.jsx("td",{className:"py-3 pr-4 text-gray-600 font-mono text-xs",children:w.taxId||"—"}),l.jsx("td",{className:"py-3 pr-4 text-gray-600",children:w.email||"—"}),l.jsx("td",{className:"py-3 pr-4 text-gray-600",children:w.phone||"—"}),l.jsx("td",{className:"py-3",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>v(w),className:"text-indigo-600 hover:text-indigo-800 text-xs font-medium",children:"Edytuj"}),l.jsx("button",{onClick:()=>S(w),className:"text-red-600 hover:text-red-800 text-xs font-medium",children:"Usuń"})]})})]},w.id))})]})}),l.jsx(aa,{open:!!y,title:y==null?void 0:y.title,message:y==null?void 0:y.message,onConfirm:y==null?void 0:y.onConfirm,onCancel:()=>C(null)})]})}const c1={cash:"Gotówka",bank_transfer:"Przelew"};function d1(){const[e,t]=k.useState([]),[n,r]=k.useState(""),[a,s]=k.useState(""),[i,o]=k.useState(""),[u,c]=k.useState(!0),[d,f]=k.useState(null),[y,C]=k.useState(null),[x,N]=k.useState(new Set),j=async()=>{c(!0);try{const h={};n&&(h.search=n),a&&(h.dateFrom=a),i&&(h.dateTo=i);const E=await ix(h);t(E)}catch{T.error("Błąd wczytywania zamówień")}finally{c(!1)}};k.useEffect(()=>{j()},[n,a,i]);const v=h=>{C({title:"Usuwanie zamówienia",message:`Czy na pewno chcesz usunąć zamówienie${h.documentNumber?` "${h.documentNumber}"`:""} z ${Hr(new Date(h.orderDate),"dd.MM.yyyy")}? Tej operacji nie można cofnąć.`,onConfirm:async()=>{var E,p;try{await ox(h.id),T.success("Zamówienie usunięte"),N(w=>{const z=new Set(w);return z.delete(h.id),z}),d===h.id&&f(null),j()}catch(w){T.error(((p=(E=w.response)==null?void 0:E.data)==null?void 0:p.error)||"Błąd usuwania")}C(null)}})},m=()=>{C({title:"Usuwanie wielu zamówień",message:`Czy na pewno chcesz usunąć ${x.size} zaznaczonych zamówień? Tej operacji nie można cofnąć.`,onConfirm:async()=>{var h,E;try{const p=await ux([...x]);T.success(`Usunięto ${p.deleted} zamówień`),N(new Set),f(null),j()}catch(p){T.error(((E=(h=p.response)==null?void 0:h.data)==null?void 0:E.error)||"Błąd usuwania")}C(null)}})},g=h=>{N(E=>{const p=new Set(E);return p.has(h)?p.delete(h):p.add(h),p})},S=()=>{x.size===e.length?N(new Set):N(new Set(e.map(h=>h.id)))};return l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-6",children:[l.jsx("h1",{className:"page-title",children:"Zamówienia"}),l.jsx(Gn,{to:"/orders/new",className:"btn-primary",children:"+ Nowe zamówienie"})]}),l.jsx("div",{className:"card mb-6",children:l.jsxs("div",{className:"flex flex-wrap gap-4 items-end",children:[l.jsxs("div",{className:"flex-1 min-w-[200px]",children:[l.jsx("label",{className:"label-field",children:"Szukaj"}),l.jsx("input",{type:"text",className:"input-field",placeholder:"Nr dokumentu, faktury, klient...",value:n,onChange:h=>r(h.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Data od"}),l.jsx("input",{type:"date",className:"input-field",value:a,onChange:h=>s(h.target.value)})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Data do"}),l.jsx("input",{type:"date",className:"input-field",value:i,onChange:h=>o(h.target.value)})]})]})}),x.size>0&&l.jsxs("div",{className:"mb-4 flex items-center gap-3 bg-red-50 border border-red-200 rounded-lg px-4 py-2",children:[l.jsxs("span",{className:"text-sm text-red-700 font-medium",children:["Zaznaczono: ",x.size]}),l.jsx("button",{onClick:m,className:"text-xs font-medium text-red-600 hover:text-red-800 bg-white border border-red-300 rounded px-3 py-1",children:"Usuń zaznaczone"}),l.jsx("button",{onClick:()=>N(new Set),className:"text-xs text-gray-500 hover:text-gray-700",children:"Odznacz wszystkie"})]}),l.jsx("div",{className:"card overflow-x-auto",children:u?l.jsx("p",{className:"text-sm text-gray-500 py-4",children:"Ładowanie..."}):e.length===0?l.jsx("p",{className:"text-sm text-gray-500 py-4",children:"Brak zamówień do wyświetlenia"}):l.jsxs("table",{className:"w-full text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"border-b border-gray-200 text-left text-gray-500 uppercase text-xs",children:[l.jsx("th",{className:"pb-3 pr-2 w-8",children:l.jsx("input",{type:"checkbox",checked:e.length>0&&x.size===e.length,onChange:S,className:"rounded"})}),l.jsx("th",{className:"pb-3 pr-4",children:"Data"}),l.jsx("th",{className:"pb-3 pr-4",children:"Klient"}),l.jsx("th",{className:"pb-3 pr-4",children:"Nr dokumentu"}),l.jsx("th",{className:"pb-3 pr-4",children:"Nr faktury"}),l.jsx("th",{className:"pb-3 pr-4",children:"Płatność"}),l.jsx("th",{className:"pb-3 pr-4 text-center",children:"Pozycje"}),l.jsx("th",{className:"pb-3",children:"Szczegóły"})]})}),l.jsx("tbody",{children:e.map(h=>l.jsxs(k.Fragment,{children:[l.jsxs("tr",{className:`border-b border-gray-100 hover:bg-gray-50 ${x.has(h.id)?"bg-indigo-50":""}`,children:[l.jsx("td",{className:"py-3 pr-2",children:l.jsx("input",{type:"checkbox",checked:x.has(h.id),onChange:()=>g(h.id),className:"rounded"})}),l.jsx("td",{className:"py-3 pr-4 font-medium",children:Hr(new Date(h.orderDate),"dd.MM.yyyy")}),l.jsx("td",{className:"py-3 pr-4",children:h.customerNameSnapshot}),l.jsx("td",{className:"py-3 pr-4 text-gray-600 font-mono text-xs",children:h.documentNumber||"—"}),l.jsx("td",{className:"py-3 pr-4 text-gray-600 font-mono text-xs",children:h.invoiceNumber||"—"}),l.jsx("td",{className:"py-3 pr-4",children:l.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs ${h.paymentMethod==="cash"?"bg-green-100 text-green-700":"bg-blue-100 text-blue-700"}`,children:c1[h.paymentMethod]})}),l.jsx("td",{className:"py-3 pr-4 text-center",children:h.itemCount}),l.jsx("td",{className:"py-3",children:l.jsxs("div",{className:"flex gap-2",children:[l.jsx("button",{onClick:()=>f(d===h.id?null:h.id),className:"text-indigo-600 hover:text-indigo-800 text-xs font-medium",children:d===h.id?"Zwiń":"Rozwiń"}),l.jsx("button",{onClick:()=>v(h),className:"text-red-600 hover:text-red-800 text-xs font-medium",children:"Usuń"})]})})]}),d===h.id&&l.jsx("tr",{children:l.jsx("td",{colSpan:8,className:"bg-gray-50 px-6 py-4",children:l.jsxs("div",{className:"text-xs space-y-2",children:[h.note&&l.jsxs("p",{className:"text-gray-500 italic",children:["Notatka: ",h.note]}),l.jsx("p",{className:"font-medium text-gray-600",children:"Pozycje zamówienia:"}),l.jsxs("table",{className:"w-full",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"text-gray-400 text-left",children:[l.jsx("th",{className:"pr-4 pb-1",children:"Typ"}),l.jsx("th",{className:"pr-4 pb-1",children:"Nazwa"}),l.jsx("th",{className:"pr-4 pb-1",children:"Kod"}),l.jsx("th",{className:"pr-4 pb-1 text-right",children:"Ilość"}),l.jsx("th",{className:"pr-4 pb-1 text-right",children:"Cena jedn."})]})}),l.jsx("tbody",{children:h.items.map((E,p)=>l.jsxs("tr",{className:"border-t border-gray-200",children:[l.jsx("td",{className:"py-1 pr-4",children:l.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs ${E.type==="material"?"bg-yellow-100 text-yellow-700":"bg-blue-100 text-blue-700"}`,children:E.type==="material"?"Materiał":"Produkt"})}),l.jsx("td",{className:"py-1 pr-4",children:E.type==="material"?E.materialName:E.productName}),l.jsx("td",{className:"py-1 pr-4 font-mono text-gray-500",children:E.type==="material"?E.materialCode:E.productCode}),l.jsx("td",{className:"py-1 pr-4 text-right",children:E.quantity}),l.jsx("td",{className:"py-1 pr-4 text-right",children:E.unitPrice?`${E.unitPrice.toFixed(2)} zł`:"—"})]},p))})]})]})})})]},h.id))})]})}),l.jsx(aa,{open:!!y,title:y==null?void 0:y.title,message:y==null?void 0:y.message,onConfirm:y==null?void 0:y.onConfirm,onCancel:()=>C(null)})]})}function f1(){const e=Xr(),[t,n]=k.useState({orderDate:Hr(new Date,"yyyy-MM-dd"),customerId:"",customerNameSnapshot:"",documentNumber:"",invoiceNumber:"",paymentMethod:"cash",note:""}),[r,a]=k.useState([{type:"product",productId:"",materialId:"",quantity:"",unitPrice:""}]),[s,i]=k.useState([]),[o,u]=k.useState([]),[c,d]=k.useState([]),[f,y]=k.useState(!1),[C,x]=k.useState("select");k.useEffect(()=>{N(),v(),j()},[]);const N=async()=>{try{const p=await Ep({active:"true"});i(p)}catch{T.error("Błąd wczytywania produktów")}},j=async()=>{try{const p=await To({active:"true"});u(p)}catch{T.error("Błąd wczytywania materiałów")}},v=async()=>{try{const p=await Pp();d(p)}catch{T.error("Błąd wczytywania klientów")}},m=p=>{if(p){const w=c.find(z=>z.id===parseInt(p));n({...t,customerId:parseInt(p),customerNameSnapshot:w?w.name:""})}else n({...t,customerId:"",customerNameSnapshot:""})},g=()=>{a([...r,{type:"product",productId:"",materialId:"",quantity:"",unitPrice:""}])},S=p=>{r.length!==1&&a(r.filter((w,z)=>z!==p))},h=(p,w,z)=>{const P=[...r];P[p]={...P[p],[w]:z},a(P)},E=async p=>{var P,M;if(p.preventDefault(),!t.orderDate){T.error("Data zamówienia jest wymagana");return}if(!t.customerNameSnapshot.trim()){T.error("Nazwa klienta jest wymagana");return}const w=r.filter(L=>(L.type==="product"?L.productId:L.materialId)&&L.quantity);if(w.length===0){T.error("Dodaj co najmniej jedną pozycję zamówienia");return}for(const L of w){if(parseFloat(L.quantity)<=0){T.error("Ilości muszą być dodatnie");return}if(L.type==="product"){const te=s.find(Ie=>Ie.id===parseInt(L.productId));if(te&&te.materialCount===0){T.error(`Produkt "${te.name}" nie ma zdefiniowanego składu materiałowego`);return}}}const z={orderDate:t.orderDate,customerId:t.customerId||null,customerNameSnapshot:t.customerNameSnapshot.trim(),documentNumber:t.documentNumber.trim()||null,invoiceNumber:t.invoiceNumber.trim()||null,paymentMethod:t.paymentMethod,note:t.note.trim()||null,items:w.map(L=>{const te={quantity:parseFloat(L.quantity),unitPrice:L.unitPrice?parseFloat(L.unitPrice):null};return L.type==="product"?te.productId=parseInt(L.productId):te.materialId=parseInt(L.materialId),te})};y(!0);try{await lx(z),T.success("Zamówienie zapisane"),e("/orders")}catch(L){T.error(((M=(P=L.response)==null?void 0:P.data)==null?void 0:M.error)||"Błąd zapisu zamówienia")}finally{y(!1)}};return l.jsxs("div",{className:"max-w-4xl",children:[l.jsx("div",{className:"flex items-center justify-between mb-6",children:l.jsx("h1",{className:"page-title",children:"Nowe zamówienie"})}),l.jsxs("form",{onSubmit:E,children:[l.jsxs("div",{className:"card mb-6",children:[l.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Dane zamówienia"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Data zamówienia *"}),l.jsx("input",{type:"date",className:"input-field",value:t.orderDate,onChange:p=>n({...t,orderDate:p.target.value}),required:!0})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Forma płatności *"}),l.jsxs("select",{className:"input-field",value:t.paymentMethod,onChange:p=>n({...t,paymentMethod:p.target.value}),children:[l.jsx("option",{value:"cash",children:"Gotówka"}),l.jsx("option",{value:"bank_transfer",children:"Przelew"})]})]}),l.jsxs("div",{className:"md:col-span-2",children:[l.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[l.jsx("label",{className:"label-field mb-0",children:"Klient *"}),l.jsxs("div",{className:"flex gap-2 text-xs",children:[l.jsx("button",{type:"button",className:`px-2 py-1 rounded ${C==="select"?"bg-indigo-100 text-indigo-700":"text-gray-500 hover:text-gray-700"}`,onClick:()=>{x("select"),n({...t,customerId:"",customerNameSnapshot:""})},children:"Z listy"}),l.jsx("button",{type:"button",className:`px-2 py-1 rounded ${C==="manual"?"bg-indigo-100 text-indigo-700":"text-gray-500 hover:text-gray-700"}`,onClick:()=>{x("manual"),n({...t,customerId:""})},children:"Wpisz ręcznie"})]})]}),C==="select"?l.jsxs("select",{className:"input-field",value:t.customerId,onChange:p=>m(p.target.value),children:[l.jsx("option",{value:"",children:"— Wybierz klienta —"}),c.map(p=>l.jsxs("option",{value:p.id,children:[p.name,p.taxId?` (NIP: ${p.taxId})`:""]},p.id))]}):l.jsx("input",{type:"text",className:"input-field",placeholder:"Nazwa klienta...",value:t.customerNameSnapshot,onChange:p=>n({...t,customerNameSnapshot:p.target.value})})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Numer dokumentu"}),l.jsx("input",{type:"text",className:"input-field",value:t.documentNumber,onChange:p=>n({...t,documentNumber:p.target.value})})]}),l.jsxs("div",{children:[l.jsx("label",{className:"label-field",children:"Numer faktury"}),l.jsx("input",{type:"text",className:"input-field",value:t.invoiceNumber,onChange:p=>n({...t,invoiceNumber:p.target.value})})]}),l.jsxs("div",{className:"md:col-span-2",children:[l.jsx("label",{className:"label-field",children:"Notatka"}),l.jsx("textarea",{className:"input-field",rows:2,value:t.note,onChange:p=>n({...t,note:p.target.value})})]})]})]}),l.jsxs("div",{className:"card mb-6",children:[l.jsxs("div",{className:"flex items-center justify-between mb-4",children:[l.jsx("h2",{className:"text-lg font-semibold",children:"Pozycje zamówienia"}),l.jsx("button",{type:"button",onClick:g,className:"btn-secondary text-xs",children:"+ Dodaj pozycję"})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"grid grid-cols-[100px_1fr_100px_120px_40px] gap-3 text-xs text-gray-500 font-medium uppercase",children:[l.jsx("span",{children:"Typ"}),l.jsx("span",{children:"Pozycja"}),l.jsx("span",{children:"Ilość"}),l.jsx("span",{children:"Cena jedn."}),l.jsx("span",{})]}),r.map((p,w)=>{const z=p.type==="product"&&p.productId?s.find(P=>P.id===parseInt(p.productId)):null;return l.jsxs("div",{className:"grid grid-cols-[100px_1fr_100px_120px_40px] gap-3 items-start",children:[l.jsxs("select",{className:"input-field",value:p.type,onChange:P=>h(w,"type",P.target.value),children:[l.jsx("option",{value:"product",children:"Produkt"}),l.jsx("option",{value:"material",children:"Materiał"})]}),l.jsxs("div",{children:[p.type==="product"?l.jsxs("select",{className:"input-field",value:p.productId,onChange:P=>h(w,"productId",P.target.value),children:[l.jsx("option",{value:"",children:"— Wybierz produkt —"}),s.map(P=>l.jsxs("option",{value:P.id,children:[P.name," (",P.code,")"]},P.id))]}):l.jsxs("select",{className:"input-field",value:p.materialId,onChange:P=>h(w,"materialId",P.target.value),children:[l.jsx("option",{value:"",children:"— Wybierz materiał —"}),o.map(P=>l.jsxs("option",{value:P.id,children:[P.name," (",P.code,")"]},P.id))]}),z&&z.materialCount===0&&l.jsx("p",{className:"text-xs text-red-500 mt-1",children:"⚠ Brak składu materiałowego!"})]}),l.jsx("input",{type:"number",step:"0.01",min:"0.01",className:"input-field",placeholder:"Ilość",value:p.quantity,onChange:P=>h(w,"quantity",P.target.value)}),l.jsx("input",{type:"number",step:"0.01",min:"0",className:"input-field",placeholder:"Cena (opcj.)",value:p.unitPrice,onChange:P=>h(w,"unitPrice",P.target.value)}),l.jsx("button",{type:"button",onClick:()=>S(w),className:"text-red-500 hover:text-red-700 p-2 text-lg leading-none disabled:opacity-30",disabled:r.length===1,children:"×"})]},w)})]})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx("button",{type:"submit",disabled:f,className:"btn-primary",children:f?"Zapisywanie...":"Zapisz zamówienie"}),l.jsx("button",{type:"button",onClick:()=>e("/orders"),className:"btn-secondary",children:"Anuluj"})]})]})]})}function p1(){return l.jsx(a0,{children:l.jsxs(Zy,{children:[l.jsx(Oe,{path:"/",element:l.jsx(Xy,{to:"/dashboard",replace:!0})}),l.jsx(Oe,{path:"/dashboard",element:l.jsx(s1,{})}),l.jsx(Oe,{path:"/materials",element:l.jsx(i1,{})}),l.jsx(Oe,{path:"/materials/new",element:l.jsx(kc,{})}),l.jsx(Oe,{path:"/materials/:id",element:l.jsx(kc,{})}),l.jsx(Oe,{path:"/groups",element:l.jsx(l1,{})}),l.jsx(Oe,{path:"/products",element:l.jsx(o1,{})}),l.jsx(Oe,{path:"/products/new",element:l.jsx(jc,{})}),l.jsx(Oe,{path:"/products/:id",element:l.jsx(jc,{})}),l.jsx(Oe,{path:"/customers",element:l.jsx(u1,{})}),l.jsx(Oe,{path:"/orders",element:l.jsx(d1,{})}),l.jsx(Oe,{path:"/orders/new",element:l.jsx(f1,{})})]})})}Ci.createRoot(document.getElementById("root")).render(l.jsx(Dc.StrictMode,{children:l.jsxs(lg,{children:[l.jsx(p1,{}),l.jsx(t0,{position:"top-right",toastOptions:{duration:3e3,style:{fontSize:"14px"},success:{iconTheme:{primary:"#059669",secondary:"#fff"}},error:{duration:5e3}}})]})}));