PageSourceSearch

https://app.renttix.com/_next/static/chunks/70401.9174c62185c7d2b6.js

js renttix.com collected 2026-10-06 20:46:45 UTC 102,948 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[70401],{37942:function(e,t,a){"use strict";var l=a(57437);a(2265),t.Z=e=>{let{page:t,rows:a,totalRecords:s,onPageChange:n,rowsPerPageOptions:i=[10,25,50,100],className:r=""}=e,o=Number(a)>0?Number(a):i[0]||10,d=Number(s)>0?Number(s):0,c=Number(t)>0?Number(t):1,u=Math.ceil(d/o)||1,m=e=>{n({page:0,rows:e})},x=e=>{n({page:e-1,rows:o})};return(0,l.jsxs)("div",{className:"flex justify-content-between align-items-center mt-3 px-3 py-2 surface-200 mb-3 ".concat(r),style:{borderRadius:"6px"},children:[(0,l.jsx)("div",{className:"text-600",style:{fontSize:"14px"},children:d>0?(0,l.jsxs)(l.Fragment,{children:[(c-1)*o+1,"-",Math.min(c*o,d)," of ",d]}):"0 of 0"}),(0,l.jsxs)("div",{className:"flex align-items-center gap-3",children:[(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)("span",{className:"text-600",style:{fontSize:"14px"},children:"Rows per page:"}),(0,l.jsx)("select",{value:o,onChange:e=>m(parseInt(e.target.value)),className:"p-1 hover:border-transparent focus:border-transparent border-round surfcae-100 gray-100 border-transparent ",style:{fontSize:"14px",minWidth:"47px"},children:i.map(e=>(0,l.jsx)("option",{value:e,children:e},e))})]}),(0,l.jsxs)("div",{className:"flex align-items-center gap-1",children:[(0,l.jsx)("button",{onClick:()=>x(c-1),disabled:c<=1,className:"p-2 border-none bg-transparent cursor-pointer border-round hover:surface-100",style:{opacity:c<=1?.3:1,cursor:c<=1?"not-allowed":"pointer"},children:(0,l.jsx)("i",{className:"pi pi-chevron-left text-600 p-2 border-1 border-300 surface-card border-round-lg font-semibold",style:{fontSize:"10px"}})}),(0,l.jsxs)("span",{className:"text-600 mx-2",style:{fontSize:"14px"},children:[c,"/",u]}),(0,l.jsx)("button",{onClick:()=>x(c+1),disabled:c>=u,className:"p-2 border-none bg-transparent cursor-pointer border-round hover:surface-100",style:{opacity:c>=u?.3:1,cursor:c>=u?"not-allowed":"pointer"},children:(0,l.jsx)("i",{className:"pi pi-chevron-right text-900 p-2 border-1 border-300 surface-card border-round-lg font-semibold",style:{fontSize:"10px"}})})]})]})]})}},66095:function(e,t,a){"use strict";a.d(t,{Z:function(){return m}});var l=a(57437),s=a(2265),n=a(75119),i=a(86262),r=a(52226),o=a(63781);let d=[{label:"%",value:"percent"},{label:"\xa3",value:"amount"}],c=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GBP";try{return new Intl.NumberFormat("en-GB",{style:"currency",currency:t}).format(Number(e)||0)}catch(a){return"".concat(t," ").concat((Number(e)||0).toFixed(2))}},u=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"GBP";switch(e){case"USD":return"$";case"EUR":return"€";case"AUD":return"A$";default:return"\xa3"}};function m(e){var t;let{value:a,customerTierPercent:m=0,currency:x="GBP",onChange:h,readOnly:p=!1,defaultExpanded:v=!1}=e,[g,f]=(0,s.useState)(v),[b,y]=(0,s.useState)((null==a?void 0:a.type)||"percent"),[j,N]=(0,s.useState)(null!==(t=null==a?void 0:a.value)&&void 0!==t?t:0),[w,k]=(0,s.useState)((null==a?void 0:a.reason)||""),D=(0,s.useRef)(null);(0,s.useEffect)(()=>{var e;y((null==a?void 0:a.type)||"percent"),N(null!==(e=null==a?void 0:a.value)&&void 0!==e?e:0),k((null==a?void 0:a.reason)||"")},[a]);let S=!!(a&&Number(a.value)>0),C=!S&&Number(m)>0,I=e=>{"function"==typeof h&&h(e)};if(p){if(S){let e="percent"===a.type?"−".concat(Number(a.value).toFixed(a.value%1==0?0:2),"%"):"−".concat(c(a.value,x));return(0,l.jsxs)("span",{className:"text-xs text-700",children:[e,a.reason?(0,l.jsxs)("span",{className:"text-500 ml-1",children:["(",a.reason,")"]}):null]})}return C?(0,l.jsxs)("span",{className:"text-xs text-500",children:["Tier −",Number(m),"%"]}):(0,l.jsx)("span",{className:"text-xs text-400",children:"—"})}if(g)return(0,l.jsxs)("div",{ref:D,className:"surface-card border-1 surface-border border-round p-2 flex flex-column gap-2",style:{minWidth:230},children:[(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)(o.U,{value:b,options:d,onChange:e=>e.value&&y(e.value),allowEmpty:!1}),(0,l.jsx)(i.R,{value:j,onValueChange:e=>{var t;return N(null!==(t=e.value)&&void 0!==t?t:0)},min:0,max:"percent"===b?100:void 0,minFractionDigits:0,maxFractionDigits:2,suffix:"percent"===b?" %":void 0,prefix:"amount"===b?u(x):void 0,inputClassName:"w-7rem",className:"flex-1"})]}),(0,l.jsx)(r.o,{value:w,onChange:e=>k(e.target.value),placeholder:"Reason (optional)",className:"w-full"}),(0,l.jsxs)("div",{className:"flex justify-content-between gap-2",children:[(0,l.jsx)(n.z,{label:"Clear",text:!0,size:"small",severity:"secondary",onClick:()=>{N(0),k(""),I(null),f(!1)}}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(n.z,{label:"Cancel",text:!0,size:"small",onClick:()=>f(!1)}),(0,l.jsx)(n.z,{label:"Apply",size:"small",icon:"pi pi-check",onClick:()=>{let e=Number(j)||0;e<=0?I(null):I({type:b,value:"percent"===b?Math.min(100,Math.max(0,e)):Math.max(0,e),reason:w||""}),f(!1)}})]})]})]});if(S){let e="percent"===a.type?"−".concat(Number(a.value).toFixed(a.value%1==0?0:2),"% off"):"−".concat(c(a.value,x)," off");return(0,l.jsxs)("div",{className:"flex align-items-center gap-1",children:[(0,l.jsx)("span",{className:"border-round px-2 py-1 text-xs font-medium",style:{background:"#ECFDF5",color:"#059669"},children:e}),(0,l.jsx)(n.z,{icon:"pi pi-pencil",text:!0,rounded:!0,size:"small","aria-label":"Edit discount",onClick:()=>f(!0),style:{width:24,height:24}})]})}return C?(0,l.jsxs)("div",{className:"flex align-items-center gap-1",children:[(0,l.jsxs)("span",{className:"text-xs text-500",children:["Tier −",Number(m),"% applied"]}),(0,l.jsx)(n.z,{label:"Override",text:!0,size:"small",className:"p-0 text-xs",onClick:()=>f(!0)})]}):(0,l.jsx)(n.z,{label:"Add discount",icon:"pi pi-percentage",text:!0,size:"small",className:"p-0 text-xs",onClick:()=>f(!0)})}},97811:function(e,t,a){"use strict";a.d(t,{Z:function(){return m}});var l=a(57437),s=a(68575),n=a(2265),i=a(94890),r=a(94437),o=a(75119),d=a(45202),c=a(52521),u=a(14392);function m(e){let{tableName:t,columns:a}
1=e,[m,x]=(0,n.useState)(!1),[h,p]=(0,n.useState)({}),v=(0,s.I0)(),g=(0,s.v9)(e=>e.columnVisibility.tables[t])||{};(0,n.useEffect)(()=>{v((0,c.eq)({tableName:t,columns:Object.keys(a)}))},[v,t,a]),(0,n.useEffect)(()=>{m&&p(g)},[m,g]);let f=e=>{p(t=>({...t,[e]:!t[e]}))};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(o.z,{size:"small",onClick:()=>x(!0),severity:"secondary","aria-label":"Manage table columns",className:"font-normal",style:{height:"32px"},children:[(0,l.jsx)(d.F8i,{className:"p-button-icon text-2xl  p-button-icon-left"}),"Manage columns"]}),(0,l.jsxs)(i.V,{header:()=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("label",{htmlFor:"",className:"text-xl font-medium",children:"Manage Columns"}),(0,l.jsx)(u.i,{})]}),visible:m,onHide:()=>{p(g),x(!1)},style:{width:"598px"},breakpoints:{"960px":"75vw","641px":"90vw"},children:[(0,l.jsx)("div",{className:"grid row-gap-3 mb-4",children:Object.keys(a).map(e=>{var t;return(0,l.jsx)("div",{className:"col-12 md:col-4 lg:col-3",children:(0,l.jsxs)("div",{className:"flex align-items-center gap-2 ml-2",children:[(0,l.jsx)(r.X,{checked:null===(t=h[e])||void 0===t||t,onChange:()=>f(e),inputId:"col-".concat(e)}),(0,l.jsx)("label",{className:"text-xs font-medium text-900",htmlFor:"col-".concat(e),children:a[e]})]})},e)})}),(0,l.jsxs)("div",{className:"flex justify-content-between align-items-center mt-3",children:[(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(o.z,{style:{padding:"12px 15px"},label:"Show all",size:"small",onClick:()=>{p(Object.keys(a).reduce((e,t)=>(e[t]=!0,e),{}))},className:"surface-900 text-white border-1 border-900"}),(0,l.jsx)(o.z,{label:"Core default",style:{padding:"12px 10px"},size:"small",onClick:()=>{let e=Object.keys(a),t=e.slice(0,5).reduce((e,t)=>(e[t]=!0,e),{});e.slice(5).forEach(e=>{t[e]=!1}),p(t)},className:"border-400 surface-card text-900"})]}),(0,l.jsx)("div",{className:"flex gap-2",children:(0,l.jsx)(o.z,{label:"Apply",style:{padding:"12px 20px"},size:"small",onClick:()=>{v((0,c.f_)({tableName:t,columns:Object.keys(a)}));let e=Object.entries(h).filter(e=>
1{let[t,a]=e;return a}).map(e=>{let[t,a]=e;return{key:t,visible:!0}});e.length>0&&v((0,c.Re)({tableName:t,columns:e})),x(!1)},className:"p-button-primary"})})]})]})]})}},98971:function(e,t,a){"use strict";a.d(t,{Z:function(){return d}});var l=a(57437);a(2265);var s=a(68575),n=a(19505),i=a(29150),r=a(38039);a(97811);let o=e=>e&&"string"==typeof e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():e;function d(e){let{tableName:t,columns:a,data:d,renderColumnBody:c,loading:u,selection:m,onSelectionChange:x,isSelection:h,virtualScrollerOptions:p={},onRowClick:v,rowClassName:g,dataKey:f="_id",emptyMessage:b}=e,y=(0,s.v9)(e=>e.columnVisibility.tables[t])||{};return(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"flex align-items-center justify-content-start",role:"toolbar","aria-label":"Table column controls"}),u?(0,l.jsx)(n.w,{value:Array.from({length:7}),className:" surface-border surface-card shadow-1 overflow-scroll",role:"table","aria-label":"".concat(t," loading"),children:Object.entries(a).map(e=>{let[t,a]=e;return!1!==y[t]?(0,l.jsx)(i.s,{sortable:!0,field:t,body:(0,l.jsx)(r.O,{}),header:o(a)},t):null})}):(0,l.jsxs)(n.w,{scrollable:!0,resizableColumns:!0,columnResizeMode:"expand",className:"surface-border surface-card shadow-1",value:d||[],dataKey:f,...h&&{selectionMode:"multiple",selection:m,onSelectionChange:e=>x(e.value)},...v&&{onRowClick:v},...g&&{rowClassName:g},...null!=b&&{emptyMessage:b},children:[h&&(0,l.jsx)(i.s,{selectionMode:"multiple",exportable:!1}),Object.entries(a).map(e=>{let[t,a]=e;return!1!==y[t]?(0,l.jsx)(i.s,{field:t,header:o(a),sortable:"action"!==t,frozen:"action"===t,alignFrozen:"action"===t?"right":null,body:e=>c(t,e)},t):null})]})]})}},73650:function(e,t,a){"use strict";a.d(t,{Z:function(){return c}});var l=a(57437),s=a(2265),n=a(75119);a(34250);var i=a(42853),r=a(34307),o=a(38567),d=a(68575);function c(e){let{deliveryCoordinates:t,vendorId:a,currentRoute:c,onRouteChange:u,productId:m,productName:x,maintenanceDate:h,clearAddressSearch:p}=e,[v,g]=(0,s.useState)(!1),[f,b]=(0,s.useState)(!1),[y,j]=(0,s.useState)([]),[N,w]=(0,s.useState)(null),[k,D]=(0,s.useState)(""),[S,C]=(0,s.useState)(null),I=s.useRef(null),{token:T,user:P}=(0,d.v9)(e=>null==e?void 0:e.auth);(0,s.useEffect)(()=>{t&&!c&&A()},[t,P]);let A=async()=>{var e,a,l,s,n,i;if(!t){C("No delivery coordinates available");return}b(!0),C(null);try{let l=await r.Z.post("".concat(o.x,"/routes/match-maintenance"),{coordinates:t,maintenanceDate:h,vendorId:null==P?void 0:P._id},{headers:{authorization:"Bearer ".concat(T),"Content-Type":"application/json"}});if(l.data.success){let{matchedRoute:t,suggestions:s}=l.data.data;if(t)u({routeId:t.routeId,routeName:t.routeName,color:t.color||"#3B82F6",assignmentType:"automatic",assignedAt:new Date}),null===(e=I.current)||void 0===e||e.show({severity:"success",summary:"Route Assigned",detail:"Automatically assigned to ".concat(t.routeName),life:3e3});else if((null==s?void 0:s.length)>0){let e=[...s].sort((e,t)=>{let a=e.isInGeofence?0:e.distance||1/0,l=t.isInGeofence?0:t.distance||1/0;return a-l})[0];e&&(u({routeId:e.routeId,routeName:e.routeName,color:e.color||"#3B82F6",assignmentType:"automatic",assignedAt:new Date}),null===(a=I.current)||void 0===a||a.show({severity:"info",summary:"Nearest Route Assigned",detail:"Automatically assigned to ".concat(e.routeName),life:3e3}))}j(s||[])}else throw Error(l.data.message||"Failed to fetch routes")}catch(t){console.error("Error fetching route suggestions:",t);let e="Failed to fetch route suggestions";if((null===(l=t.response)||void 0===l?void 0:l.status)===401?e="Authentication required. Please log in.":(null===(s=t.response)||void 0===s?void 0:s.status)===404?e="Route matching service not available":(null===(i=t.response)||void 0===i?void 0:null===(n=i.data)||void 0===n?void 0:n.message)?e=t.response.data.message:t.message&&(e=t.message),C(e),!T){let e=[{routeId:"demo-1",routeName:"North Route",color:"#3B82F6",isInGeofence:!0,distance:0},{routeId:"demo-2",routeName:"South Route",color:"#10B981",isInGeofence:!1,distance:5.2},{routeId:"demo-3",routeName:"Central Route",color:"#8B5CF6",isInGeofence:!1,distance:7.8}];j(e),u({routeId:e[0].routeId,routeName:e[0].routeName,color:e[0].color,assignmentType:"automatic",assignedAt:new Date})}}finally{b(!1)}};return(n.z,n.z,f&&!c)?(0,l.jsxs)("div",{className:"route-loading",children:[(0,l.jsx)(i.G,{}),(0,l.jsx)("span",{className:"route-loading-text",children:"Finding best route..."})]}):(0,l.jsx)("div",{className:"route-selector"})}a(16712)},70401:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return ei}});var l=a(57437),s=a(2265),n=a(3163),i=a(78954),r=a(30398),o=a(79925),d=a(86262),c=a(75119),u=a(52226),m=a(81902),x=a(34250),h=a(22559),p=a(22406),v=a(10265),g=a(343
107),f=a(38567),b=a(68575),y=a(10231),j=a(1675),N=a(94437),w=a(9618),k=a(96218),D=a(42853);let S={async getTaskTypes(){try{return(await apiService.get("/task-types")).data||[]}catch(e){return console.error("Error fetching task types:",e),[]}},async getTaskTypesByCategory(e){try{return(await apiService.get("/task-types/category/".concat(e))).data||[]}catch(e){return console.error("Error fetching task types by category:",e),[]}},async createTaskType(e){try{return(await apiService.post("/task-types",e)).data}catch(e){throw console.error("Error creating task type:",e),e}},async updateTaskType(e,t){try{return(await apiService.put("/task-types/".concat(e),t)).data}catch(e){throw console.error("Error updating task type:",e),e}},async deleteTaskType(e){try{return(await apiService.delete("/task-types/".concat(e))).data}catch(e){throw console.error("Error deleting task type:",e),e}}};var C=a(73650);a(62186);let I=[{label:"15 minutes",value:15},{label:"30 minutes",value:30},{label:"45 minutes",value:45},{label:"1 hour",value:60},{label:"1.5 hours",value:90},{label:"2 hours",value:120},{label:"3 hours",value:180},{label:"4 hours",value:240}],T=[{label:"Low",value:"low",icon:"pi pi-arrow-down",color:"#10B981"},{label:"Medium",value:"medium",icon:"pi pi-minus",color:"#F59E0B"},{label:"High",value:"high",icon:"pi pi-arrow-up",color:"#EF4444"},{label:"Urgent",value:"urgent",icon:"pi pi-exclamation-circle",color:"#DC2626"}],P=e=>{let t=(e||"").toLowerCase();return t.includes("toilet")?"clean":t.includes("generator")?"inspect":t.includes("pump")?"service":"standard"},A=(e,t)=>{let a=(e||"").toLowerCase(),l=t?new Date(t):new Date;return a.includes("toilet")||a.includes("portable")?{repeatEveryXDays:7,firstMaintenanceDate:new Date(l.getTime()+6048e5),serviceType:"cleaning",estimatedDuration:15,priority:"medium"}:a.includes("generator")||a.includes("power")?{repeatEveryXDays:30,firstMaintenanceDate:new Date(l.getTime()+2592e6),serviceType:"inspection",estimatedDuration:30,priority:"medium"}:a.includes("pump")||a.includes("compressor")?{repeatEveryXDays:14,firstMaintenanceDate:new Date(l.getTime()+12096e5),serviceType:"inspection",estimatedDuration:45,priority:"medium"}:{repeatEveryXDays:30,firstMaintenanceDate:new Date(l.getTime()+2592e6),serviceType:"inspection",estimatedDuration:30,priority:"medium"}};function R(e){let{product:t,enabled:a,onToggle:i,config:r,onChange:o,deliveryDate:u}=e,{state:x}=(0,n.a)(),{formData:h}=x,[p,v]=(0,s.useState)(!1),[g,f]=(0,s.useState)([]),[b,y]=(0,s.useState)(!1),[j,R]=(0,s.useState)(r.scheduleType||"interval"),[z,M]=(0,s.use
1State)(r.weekDays||[]),[F,E]=(0,s.useState)(r.endCondition||"rental_end"),[_,W]=(0,s.useState)(r.endDate?new Date(r.endDate):null),[B,L]=(0,s.useState)(r.occurrenceCount||10);(0,s.useEffect)(()=>{a&&O()},[a]),(0,s.useEffect)(()=>{a&&!r.firstMaintenanceDate&&o({requiresMaintenance:!0,...A(null==t?void 0:t.name,u),continuesUntilTermination:!0,frequencyPer7Days:1})},[a,null==t?void 0:t.name,u]);let O=async()=>{y(!0);try{let e=await S.getTaskTypes();if(f(e),!r.taskTypeId&&e.length>0){let a=e.find(e=>e.name.toLowerCase().includes(P(null==t?void 0:t.name)))||e[0];o({...r,taskTypeId:a._id,taskTypeName:a.name,estimatedDuration:a.defaultDuration||r.estimatedDuration})}}catch(e){console.error("Error loading task types:",e)}finally{y(!1)}},q=e=>{i(e),e?(o({requiresMaintenance:!0,...A(null==t?void 0:t.name,u),continuesUntilTermination:!0,frequencyPer7Days:1,scheduleType:"interval",endCondition:"rental_end"}),O(),R("interval"),E("rental_end")):o({requiresMaintenance:!1})};return(0,l.jsxs)("div",{className:"inline-maintenance-config",children:[(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)(N.X,{inputId:"maintenance-".concat((null==t?void 0:t._id)||"default"),checked:a,onChange:e=>q(e.checked)}),(0,l.jsx)("label",{htmlFor:"maintenance-".concat((null==t?void 0:t._id)||"default"),className:"cursor-pointer font-medium",children:"Maintenance"})]}),a&&(0,l.jsxs)("div",{className:"ml-6 mt-2 p-3 surface-100 border-round",children:[(0,l.jsxs)("div",{className:"grid main-controls",children:[(0,l.jsxs)("div",{className:"col-12 md:col-6 lg:col-3",children:[(0,l.jsx)("label",{className:"text-sm text-600 block mb-1",children:"First Service"}),(0,l.jsx)(w.f,{value:r.firstMaintenanceDate?new Date(r.firstMaintenanceDate):null,onChange:e=>o({...r,firstMaintenanceDate:e.value}),dateFormat:"dd/mm/yy",minDate:new Date,showIcon:!0,className:"p-inputtext-sm w-full"})]}),(0,l.jsxs)("div",{className:"col-12 md:col-6 lg:col-3",children:[(0,l.jsx)("label",{className:"text-sm text-600 block mb-1",children:"Frequency"}),"once"===j?(0,l.jsx)("div",{className:"text-sm mt-2",children:"One-time service"}):"daily"===j?(0,l.jsx)("div",{className:"text-sm mt-2",children:"Every day"}):"weekly"===j?(0,l.jsx)("div",{className:"text-sm mt-2",children:"Weekly (see advanced)"}):"monthly"===j?(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)("span",{className:"text-sm",children:"Day"}),(0,l.jsx)(d.R,{value:r.monthDay||1,onValueChange:e=>o({...r,monthDay:e.value}),min:1,max:31,className:"p-inputtext-sm",style:{width:"50px"}}),(0,l.jsx)("span",{className:"text-sm",children:"of month"})]}):(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)("span",{className:"text-sm",children:"Every"}),(0,l.jsx)(d.R,{value:r.repeatEveryXDays,onValueChange:e=>o({...r,repeatEveryXDays:e.value}),min:1,max:365,className:"p-inputtext-sm",style:{width:"60px"}}),(0,l.jsx)("span",{className:"text-sm",children:"days"})]})]}),(0,l.jsxs)("div",{className:"col-12 md:col-6 lg:col-3",children:[(0,l.jsx)("label",{className:"text-sm text-600 block mb-1",children:"Task Type"}),b?(0,l.jsx)("div",{className:"flex align-items-center justify-content-center",style:{height:"32px"},children:(0,l.jsx)(D.G,{style:{width:"20px",height:"20px"}})}):(0,l.jsx)(m.L,{value:r.taskTypeId,options:g,onChange:e=>{let t=g.find(t=>t._id===e.value);o({...r,taskTypeId:e.value,taskTypeName:null==t?void 0:t.name,estimatedDuration:(null==t?void 0:t.defaultDuration)||r.estimatedDuration})},optionLabel:"name",optionValue:"_id",placeholder:"Select task",className:"p-inputtext-sm w-full",showClear:!0})]}),(0,l.jsxs)("div",{className:"col-12 md:col-6 lg:col-3",children:[(0,l.jsx)("label",{className:"text-sm text-600 block mb-1",children:"Duration"}),(0,l.jsx)(m.L,{value:r.estimatedDuration||30,options:I,onChange:e=>o({...r,estimatedDuration:e.value}),placeholder:"Duration",className:"p-inputtext-sm w-full"})]})]}),h.deliveryCoordinates&&(0,l.jsxs)("div",{className:"mt-3",children:[(0,l.jsx)("label",{className:"text-sm text-600 block mb-2",children:"Route Assignment"}),(0,l.jsx)(C.Z,{deliveryCoordinates:h.deliveryCoordinates,vendorId:h.vendorId,currentRoute:r.route,onRouteChange:e=>{o({...r,route:e})},productId:null==t?void 0:t._id,productName:null==t?void 0:t.name,maintenanceDate:r.firstMaintenanceDate})]}),(0,l.jsx)("div",{className:"mt-3",children:p?(0,l.jsx)(c.z,{label:"Less Options",icon:"pi pi-angle-up",className:"p-button-text p-button-sm",onClick:()=>v(!1)}):(0,l.jsx)(c.z,{label:"More Options",icon:"pi pi-angle-down",className:"p-button-text p-button-sm",onClick:()=>v(!0)})}),p&&(0,l.jsx)("div",{className:"mt-3 pt-3 border-top-1 surface-border",children:(0,l.jsxs)("div",{className:"grid",children:[(0,l.jsxs)("div",{className:"col-12 md:col-6",children:[(0,l.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Priority"}),(0,l.jsx)(m.L,{value:r.priority||"medium",options:T,onChange:e=>o({...r,priority:e.value}
1),placeholder:"Select priority",className:"w-full p-inputtext-sm",itemTemplate:e=>(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)("i",{className:e.icon,style:{color:e.color}}),(0,l.jsx)("span",{children:e.label})]}),valueTemplate:e=>{var t,a,s;return e?(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)("i",{className:null===(t=T.find(t=>t.value===e))||void 0===t?void 0:t.icon,style:{color:null===(a=T.find(t=>t.value===e))||void 0===a?void 0:a.color}}),(0,l.jsx)("span",{children:null===(s=T.find(t=>t.value===e))||void 0===s?void 0:s.label})]}):null}})]}),(0,l.jsxs)("div",{className:"col-12 md:col-6",children:[(0,l.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Schedule Type"}),(0,l.jsx)(m.L,{value:j,options:[{label:"One-time",value:"once"},{label:"Daily",value:"daily"},{label:"Every X Days",value:"interval"},{label:"Weekly",value:"weekly"},{label:"Monthly",value:"monthly"}],onChange:e=>{R(e.value),o({...r,scheduleType:e.value,repeatEveryXDays:"daily"===e.value?1:"weekly"===e.value?7:"monthly"===e.value?30:r.repeatEveryXDays})},placeholder:"Select schedule type",className:"w-full p-inputtext-sm"})]}),"weekly"===j&&(0,l.jsxs)("div",{className:"col-12",children:[(0,l.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Select Days"}),(0,l.jsx)("div",{className:"flex flex-wrap gap-2",children:[{label:"Mon",value:1},{label:"Tue",value:2},{label:"Wed",value:3},{label:"Thu",value:4},{label:"Fri",value:5},{label:"Sat",value:6},{label:"Sun",value:0}].map(e=>(0,l.jsxs)("div",{className:"flex align-items-center",children:[(0,l.jsx)(N.X,{inputId:"day-".concat(e.value),checked:z.includes(e.value),onChange:t=>{let a=t.checked?[...z,e.value]:z.filter(t=>t!==e.value);M(a),o({...r,weekDays:a})}}),(0,l.jsx)("label",{htmlFor:"day-".concat(e.value),className:"ml-2 text-sm",children:e.label})]},e.value))})]}),(0,l.jsxs)("div",{className:"col-12 md:col-6",children:[(0,l.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"End Condition"}),(0,l.jsx)(m.L,{value:F,options:[{label:"Until rental ends",value:"rental_end"},{label:"Specific date",value:"date"},{label:"After X occurrences",value:"count"},{label:"No end date",value:"never"}],onChange:e=>{E(e.value),o({...r,endCondition:e.value,continuesUntilTermination:"rental_end"===e.value})},placeholder:"Select end condition",className:"w-full p-inputtext-sm"})]}),"date"===F&&(0,l.jsxs)("div",{className:"col-12 md:col-6",children:[(0,l.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"End Date"}),(0,l.jsx)(w.f,{value:_,onChange:e=>{W(e.value),o({...r,endDate:e.value})},dateFormat:"dd/mm/yy",minDate:new Date,showIcon:!0,className:"p-inputtext-sm w-full"})]}),"count"===F&&(0,l.jsxs)("div",{className:"col-12 md:col-6",children:[(0,l.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Number of Occurrences"}),(0,l.jsx)(d.R,{value:B,onValueChange:e=>{L(e.value),o({...r,occurrenceCount:e.value})},min:1,max:100,className:"p-inputtext-sm w-full"})]}),(0,l.jsxs)("div",{className:"col-12",children:[(0,l.jsx)("label",{className:"text-sm font-medium mb-1 block",children:"Access Requirements / Special Notes"}),(0,l.jsx)(k.g,{value:r.accessRequirements||"",onChange:e=>o({...r,accessRequirements:e.target.value}),rows:3,placeholder:"Enter any special access requirements, gate codes, or notes for the maintenance team...",className:"w-full p-inputtext-sm",autoResize:!0})]})]})})]})]})}a(42674);var z=a(38039);function M(e){let{rows:t=5}=e;return(0,l.jsxs)(r.E.div,{initial:{opacity:0}
1,animate:{opacity:1},transition:{duration:.3},className:"space-y-3",children:[(0,l.jsxs)("div",{className:"flex items-center gap-4 p-3 bg-gray-50 rounded",children:[(0,l.jsx)(z.O,{width:"80px",height:"20px"}),(0,l.jsx)(z.O,{width:"150px",height:"20px"}),(0,l.jsx)(z.O,{width:"100px",height:"20px"}),(0,l.jsx)(z.O,{width:"80px",height:"20px"}),(0,l.jsx)(z.O,{width:"120px",height:"20px"})]}),Array.from({length:t}).map((e,t)=>(0,l.jsxs)("div",{className:"flex items-center gap-4 py-3 border-b",children:[(0,l.jsx)(z.O,{width:"60px",height:"60px",shape:"square"}),(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)(z.O,{width:"60%",height:"18px",className:"mb-1"}),(0,l.jsx)(z.O,{width:"40%",height:"14px"})]}),(0,l.jsx)(z.O,{width:"80px",height:"16px"}),(0,l.jsx)(z.O,{width:"60px",height:"16px"}),(0,l.jsx)(z.O,{width:"100px",height:"32px"})]},t))]})}var F=a(94890),E=a(19505),_=a(29150),W=a(78739),B=a(2793),L=a(37942),O=e=>{let{product:t,selectedAssets:a=[],onAssetsChange:n,visible:i,onHide:r,rentalDuration:o=1,startDate:d,endDate:u,openEnded:p=!1,chargeReturnDay:v=!0}=e,{getTerm:w,getPlural:k}=(0,y.m)(),{token:S}=(0,b.v9)(e=>null==e?void 0:e.auth),[C,I]=(0,s.useState)(!0),[T,P]=(0,s.useState)(""),[A,R]=(0,s.use
1State)([]),[z,M]=(0,s.useState)(()=>new Set(a.map(e=>e.assetId))),[O,q]=(0,s.useState)("manual"),[U,V]=(0,s.useState)(a.length||1),[G,Z]=(0,s.useState)("oldest"),[H,Q]=(0,s.useState)(10),[X,Y]=(0,s.useState)(0),K=[{label:"Oldest first",value:"oldest"},{label:"Newest first",value:"newest"},{label:"Least used",value:"least-used"}];(0,s.useEffect)(()=>{i&&t&&(q("manual"),Y(0),P(""),I(!0),(async()=>{try{var e;let l=u;if(u&&!1===v){let e=new Date(u);e.setDate(e.getDate()-1),l=e.toISOString()}let s=await g.Z.get("".concat(f.x,"/product/assets/").concat(t._id),{headers:{authorization:"Bearer ".concat(S)},params:{startDate:d,endDate:l,openEnded:p}});if(Array.isArray(null===(e=s.data)||void 0===e?void 0:e.assets)){let e=new Set(a.map(e=>e.assetId)),l=a.map(e=>{var a;return{...e,status:"selected",lastMaintenanceDate:e.lastMaintenanceDate||new Date().toISOString(),usageCount:null!==(a=e.usageCount)&&void 0!==a?a:0,condition:e.condition||"good",location:e.location||(null==t?void 0:t.depot)||"Main Warehouse",notes:e.notes||""}}),n=s.data.assets.filter(e=>"available"===e.status&&!e.isUnderMaintenance&&!e.hasConflictingBooking).map(e=>{var a;return{...e,status:"available",lastMaintenanceDate:e.lastMaintenanceDate||new Date().toISOString(),usageCount:null!==(a=e.usageCount)&&void 0!==a?a:0,condition:e.condition||"good",location:e.location||(null==t?void 0:t.depot)||"Main Warehouse",notes:e.notes||"Recently serviced"}}),i=[...l],r=new Set(l.map(e=>e.assetId));n.forEach(e=>{r.has(e.assetId)||i.push(e)}),R(i),M(e)}else R([])}catch(e){P("Failed to load available assets. Showing sample data."),R(Array.from({length:97},(e,a)=>({assetId:"".concat((null==t?void 0:t._id)||"p","-AST-").concat(a+1),assetNumber:"AST-undefined-".concat(String(a+1).padStart(3,"0")),status:"available",lastMaintenanceDate:new Date(Date.now()-13*864e5).toISOString(),usageCount:27,condition:"Good",location:"Main Warehouse",notes:"Recently serviced"}))),M(new Set)}finally{I(!1)}})())},[i,t,d,u,p,v,S]);let $=(0,s.useMemo)(()=>A.slice(X,X+H),[A,X,H]),J=e=>{M(t=>{let a=new Set(t);return a.has(e)?a.delete(e):a.add(e),R(t=>t.map(t=>t.assetId===e?{...t,status:a.has(e)?"selected":"available"}:t)),a})},ee=()=>{if(!A.length)return;let e=[...A];"oldest"===G?e.sort((e,t)=>new Date(e.lastMaintenanceDate)-new Date(t.lastMaintenanceDate)):"newest"===G?e.sort((e,t)=>new Date(t.lastMaintenanceDate)-new Date(e.lastMaintenanceDate)):"least-used"===G&&e.sort((e,t)=>{var a,l;return(null!==(a=e.usageCount)&&void 0!==a?a:0)-(null!==(l=t.usageCount)&&void 0!==l?l:0)});let t=Math.max(0,Math.min(U||0,e.length)),a=new Set(e.slice(0,t).map(e=>e.assetId));M(a),R(e=>e.map(e=>({...e,status:a.has(e.assetId)?"selected":"available"})))},et=(0,l.jsx)("div",{className:"flex align-items-center justify-content-between w-full",children:(0,l.jsxs)("div",{className:"text-2xl font-semibold",children:["Select ",k("asset").toLowerCase()," for ",(0,j.RZ)(null==t?void 0:t.productName)||"AAA",p&&(0,l.jsx)("span",{style:{color:"#FD8A3B",marginLeft:"12px",fontSize:"16px"},children:"(Open-Ended Order)"})]})});return(0,l.jsxs)(F.V,{visible:i,onHide:r,header:et,maximizable:!0,modal:!0,style:{width:"50vw",maxWidth:"100vw"},contentStyle:{paddingTop:0},children:[(0,l.jsx)(B.o,{className:"flex-col items-start  border-noround		border-noround-right	 border-bottom-none	",left:()=>(0,l.jsx)(l.Fragment,{children:"auto"===O&&(0,l.jsxs)("div",{className:"flex align-items-center gap-3 mb-3 mt-3",children:[(0,l.jsx)("span",{className:"text-600",children:"Quantity"}),(0,l.jsx)(m.L,{value:U,options:[1,2,3,4,5,10,15,20].map(e=>({label:String(e),value:e})),onChange:e=>V(e.value),className:"w-6rem",size:"small"}),(0,l.jsx)("span",{className:"text-600",children:"Strategy"}),(0,l.jsx)(m.L,{value:G,options:K,onChange:e=>Z(e.value),size:"small",className:"w-14rem"}),(0,l.jsx)(c.z,{size:"small",label:"Apply",onClick:ee,className:"p-button-sm"})]})}),right:()=>(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)("div",{className:"flex align-items-center gap-4",children:[(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)(W.E,{inputId:"manual",value:"manual",checked:"manual"===O,onChange:e=>q(e.value)}),(0,l.jsx)("label",{htmlFor:"manual",className:"font-medium",children:"Manual selection"})]}),(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)(W.E,{inputId:"auto",value:"auto",checked:"auto"===O,onChange:e=>q(e.value)}),(0,l.jsx)("label",{htmlFor:"auto",className:"font-medium",children:"Auto assign"})]})]})}),role:"toolbar","aria-label":"Product list toolbar"}),!!T&&(0,l.jsx)(h.v,{className:"mb-3",severity:"warn",text:T}),(0,l.jsx)("div",{className:"surface-0 border-1 border-200 border-noround ",children:C?(0,l.jsx)("div",{className:"flex align-items-center justify-content-center py-6",children:(0,l.jsx)(D.G,{})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(E.w,{value:$,className:"p-datatable-sm",emptyMessage:"No available ".concat(k("asset").toLowerCase()),showGridlines:!1,responsiveLayout:"scroll",children:["manual"===O&&(0,l.jsx)(_.s,{header:()=>(0,l.jsx)(N.X,{checked:$.every(e=>z.has(e.assetId)),onChange:e=>{let t=new Set(z);
1e.checked?$.forEach(e=>t.add(e.assetId)):$.forEach(e=>t.delete(e.assetId)),M(t),R(e=>e.map(e=>t.has(e.assetId)?{...e,status:"selected"}:{...e,status:"available"}))}},"select-all"),body:e=>(0,l.jsx)(N.X,{inputId:"chk-".concat(e.assetId),checked:z.has(e.assetId),onChange:()=>J(e.assetId)},e.assetId),style:{width:56}}),(0,l.jsx)(_.s,{sortable:!0,field:"assetNumber",header:"".concat(w("asset")," number")}),(0,l.jsx)(_.s,{sortable:!0,header:"Status",body:e=>{let t="success";return"selected"===e.status&&(t="info"),"maintenance"===e.status&&(t="warning"),(0,l.jsx)(x.V,{value:(0,j.RZ)("selected"===e.status?"Selected":e.status),severity:t,style:{background:"#FFF3D6",color:"#B36A00",borderRadius:999,fontWeight:600},className:"px-3 py-1 text-sm"})}}),(0,l.jsx)(_.s,{sortable:!0,header:"Condition",body:e=>(0,l.jsx)(x.V,{value:(0,j.RZ)(String(e.condition).charAt(0).toUpperCase()+String(e.condition).slice(1)),severity:"warning",style:{background:"#FFEFD6",color:"#B36A00",borderRadius:999,fontWeight:600},className:"px-3 py-1 text-sm"})}),(0,l.jsx)(_.s,{sortable:!0,field:"location",header:"Location"}),(0,l.jsx)(_.s,{sortable:!0,field:"usageCount",header:"Usage count"})]}),(0,l.jsx)(L.Z,{page:Math.floor(X/H)+1,rows:H,totalRecords:A.length,onPageChange:e=>{Y(e.page*e.rows),Q(e.rows)},rowsPerPageOptions:[10,25,50]})]})}),(0,l.jsxs)("div",{className:"mt-4 flex align-items-center justify-content-between",children:[(0,l.jsxs)("div",{className:"text-900 font-semibold",children:[z.size," of ",A.length," ",k("asset").toLowerCase()," selected"]}),(0,l.jsx)(c.z,{label:"Confirm",onClick:()=>{n(A.filter(e=>z.has(e.assetId)).map(e=>({...e,productId:t._id,status:"Rental"===t.status?"rented":"sold"}))),r()},disabled:0===z.size,className:"px-7 py-3",style:{background:"#FD8A3B",borderColor:"#FD8A3B",color:"#fff",borderRadius:8,fontWeight:700}})]})]})},q=a(14392),U=a(37996);let V=new Map;function G(e){let{selectedLevel:t=null,onLevelChange:a,eligibleSubtotal:n=0,onCalculationChange:i,customerType:r="account",categoryId:d=null,productId:c=null,token:u,vendorId:x,selectedProducts:p=[],rentalDuration:v=1,chargeableDaysForProduct:b=null,externalCalculations:j=null,vendorSettings:N=null}=e,{getTerm:w,getPlural:k}=(0,y.m)(),[D,S]=(0,s.useState)([]),[C,I]=(0,s.useState)(!1),[T,P]=(0,s.useState)(j||{}
1),[A,R]=(0,s.useState)(null);(0,s.useEffect)(()=>{z()},[r,d,c,u,x]),(0,s.useEffect)(()=>{j&&P(j)},[j]),(0,s.useEffect)(()=>{t&&p.length>0&&D.find(e=>e._id===t)&&M(t)},[p,v,b,n]);let z=async()=>{try{I(!0),R(null);let e=new URLSearchParams;r&&e.append("customerType",r),d&&e.append("categoryId",d),c&&e.append("productId",c),x&&e.append("vendorId",x);let t=await g.Z.get("".concat(f.x,"/damage-waiver/levels?").concat(e.toString()),{headers:{authorization:"Bearer ".concat(u)}});t.data.success&&S(t.data.data||[])}catch(e){console.error("Error fetching damage waiver levels:",e),R("Failed to load damage waiver options")}finally{I(!1)}},M=async e=>{if(e)try{let t=D.find(t=>t._id===e);if(!t){console.error("Damage waiver level not found:",e);return}let a=p.filter(e=>{let t=e.selectedAssets&&e.selectedAssets.length>0,a=!0===e.damageWaiverEnabled;return t&&a});if(0===a.length||0===n){P({}),i&&i({waiverAmount:0,taxAmount:0,totalAmount:0});return}let l=n*t.rate/100,s=N||await F(),r=(null==s?void 0:s.damageWaiverTaxable)&&s.damageWaiverTaxRate||0,o=l*r/100,d={waiverAmount:Math.round(100*l)/100,taxAmount:Math.round(100*o)/100,totalAmount:Math.round(100*(l+o))/100,rate:t.rate,taxRate:r,taxable:(null==s?void 0:s.damageWaiverTaxable)||!1,eligibleSubtotal:n};i&&i(d),P(t=>({...t,[e]:d}))}catch(a){console.error("Error calculating waiver:",a);let t={waiverAmount:Math.round(5*eligibleSubtotalForWaiver)/100,taxAmount:0,totalAmount:Math.round(5*eligibleSubtotalForWaiver)/100,rate:5,taxRate:0,taxable:!1,fallback:!0,eligibleSubtotal:eligibleSubtotalForWaiver};i&&i(t),P(a=>({...a,[e]:t}))}},F=(0,s.useCallback)(async()=>{if(!x||!u)return null;if(N)return N;let e="".concat(x);if(V.has(e))return V.get(e);try{let t=await g.Z.get("".concat(f.x,"/damage-waiver/settings"),{headers:{authorization:"Bearer ".concat(u)},params:{vendorId:x}});if(t.data.success){let a=t.data.data;return V.set(e,a),a}}catch(e){console.error("Error fetching vendor settings:",e)}return null},[x,u,N]),E=async e=>{a&&a(e),e?await M(e):(P({}),i&&i({waiverAmount:0,taxAmount:0,totalAmount:0}))};if(C)return(0,l.jsx)(o.Z,{className:"w-full",children:(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(U.bfl,{className:"w-6 h-6 text-blue-600"}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:w("damageWaiver")||"Damage Waiver"}),(0,l.jsx)("p",{className:"text-sm text-gray-600",children:"Loading waiver options..."})]})]})});if(A)return(0,l.jsx)(o.Z,{className:"w-full",children:(0,l.jsx)(h.v,{severity:"error",text:A})});if(0===D.length)return(0,l.jsx)(o.Z,{className:"w-full",children:(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)(U.bfl,{className:"w-6 h-6 text-gray-400"}),(0,l.jsxs)("div",{children:[(0,l.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:w("damageWaiver")||"Damage Waiver"}),(0,l.jsx)("p",{className:"text-sm text-gray-600",children:"No damage waiver options available"})]})]})});let _=[{label:"No Protection",value:null},...D.map(e=>({label:"".concat(e.name," (").concat(e.rate,"% of rental value)"),value:e._id}))],W=T[t]||null,B=D.find(e=>e._id===t);return(0,l.jsx)(o.Z,{className:"w-full surface-200",children:(0,l.jsxs)("div",{className:"space-y-6",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsxs)("label",{className:"block text-xl font-medium mb-3 text-900",children:[w("damageWaiver")||"Damage waiver"," protection"]}),W&&W.totalAmount>0&&(0,l.jsxs)("div",{className:"text-right",children:[(0,l.jsx)("p",{className:"text-sm text-gray-600",children:"Waiver Cost"}),(0,l.jsxs)("p",{className:"text-lg font-bold text-blue-600",children:["\xa3",W.totalAmount.toFixed(2)]})]})]}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"block  font-semibold mb-2 text-900",children:"Protection level"}),(0,l.jsx)(m.L,{value:t,options:_,onChange:e=>E(e.value),placeholder:"Select protection level",className:"w-full"})]}),W&&(0,l.jsxs)("div",{className:"bg-gray-50 p-4 rounded-lg",children:[(0,l.jsx)("h4",{className:"font-medium text-gray-900 mb-2",children:"Cost breakdown"}),(0,l.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,l.jsxs)("div",{className:"flex justify-between",children:[(0,l.jsx)("span",{children:"Eligible equipment value:"}),(0,l.jsxs)("span",{children:["\xa3",(W.eligibleSubtotal||n).toFixed(2)]})]}),(0,l.jsxs)("div",{className:"flex justify-between",children:[(0,l.jsxs)("span",{children:["Waiver amount (",W.rate,"%):"]}),(0,l.jsxs)("span",{children:["\xa3",W.waiverAmount.toFixed(2)]})]}),W.taxAmount>0&&(0,l.jsxs)("div",{className:"flex justify-between",children:[(0,l.jsxs)("span",{children:["Tax (",W.taxRate,"%):"]}),(0,l.jsxs)("span",{children:["\xa3",W.taxAmount.toFixed(2)]})]}),(0,l.jsx)(q.i,{}),(0,l.jsxs)("div",{className:"flex justify-between font-bold",children:[(0,l.jsx)("span",{children:"Total waiver cost:"}),(0,l.jsxs)("span",{children:["\xa3",W.totalAmount.toFixed(2)]})]}),W.fallback&&(0,l.jsx)("div",{className:"text-xs text-amber-600 mt-1",children:"* Using fallback calculation"})]})]}),B&&(0,l.jsx)("div",{className:"p-4 rounded-lg",children:(0,l.jsx)("div",{className:"flex items-start gap-2",children:(0,l.jsx)("div",{className:"text-sm text-900",children:(0,l.jsxs)("label",{className:"mt-1 text-sm block",children:[(0,l.jsx)("strong",{children:"Coverage:"})," ",B.rate,"% of equipment value |",(0,l.jsx)("strong",{children:" Rate:"})," ",B.rate,"% of rental value"]})})})})]})]})})}
1var Z=a(91026),H=a(20859),Q=a(63781),X=a(98971),Y=a(12758);let K=[{label:"Per Visit",value:"per_visit"},{label:"Per Hour",value:"per_hour"},{label:"Per Day",value:"per_day"},{label:"Per Week",value:"per_week"},{label:"Per Unit / Visit",value:"per_unit_per_visit"},{label:"Fixed",value:"fixed"}],$=[{label:"One-Off",value:"one_off"},{label:"Daily",value:"daily"},{label:"Weekly",value:"weekly"},{label:"Monthly",value:"monthly"}],J=[{label:"Until Off-Hire",value:"until_off_hire"},{label:"On Date",value:"on_date"}],ee=[{label:"Sunday",value:0},{label:"Monday",value:1},{label:"Tuesday",value:2},{label:"Wednesday",value:3},{label:"Thursday",value:4},{label:"Friday",value:5},{label:"Saturday",value:6}],et={per_visit:"Per Visit",per_hour:"Per Hour",per_day:"Per Day",per_week:"Per Week",per_unit_per_visit:"Per Unit / Visit",fixed:"Fixed"},ea={serviceTemplateId:null,serviceName:"",description:"",serviceCategory:"other",billingBasis:"per_visit",chargeable:!0,rate:0,plannedQuantity:1,plannedHours:0,duration:0,taxRate:0,plannedAmount:0,isIndependentItem:!0,linkedOrderLineId:null,linkedOrderLineName:"",linkedProductId:null,linkedProductName:"",linkedAssetNumbers:[],initialServiceDate:null,scheduleType:"one_off",recurringDayOfWeek:null,recurrenceEndRule:"until_off_hire",endDate:null,timeWindow:"",showInCalendar:!0,assignedTo:null,assignedToName:"",templateSnapshot:{}};function el(e,t){if(!1===e.chargeable)return 0;let a=Number(e.rate)||0,l=Number(e.plannedHours)||0,s=Number(e.duration)||1,n=1;if("per_unit_per_visit"===e.billingBasis&&!e.isIndependentItem&&e.linkedOrderLineId&&t){let a=t.find(t=>(t._id||t.productId)===e.linkedOrderLineId);a&&(n=Number(a.quantity)||1)}switch(e.billingBasis){case"per_visit":case"fixed":default:return a;case"per_hour":return a*l;case"per_day":case"per_week":return a*s;case"per_unit_per_visit":return a*n}}function es(){let{state:e,updateFormData:t}=(0,n.a)(),{formData:a}=e,{token:i,user:r}=(0,b.v9)(e=>
1null==e?void 0:e.auth),o=(0,s.useRef)(null),[h,p]=(0,s.useState)(!1),[v,y]=(0,s.useState)(null),[j,D]=(0,s.useState)({...ea}),[S,C]=(0,s.useState)([]),[I,T]=(0,s.useState)(!1),[P,A]=(0,s.useState)([]),[R,z]=(0,s.useState)(null),[M,E]=(0,s.useState)([]),_=a.serviceLines||[],W=[{label:"Independent Item",value:"__independent__"},...(a.products||[]).map((e,t)=>({label:"".concat(e.productName||e.name||"Product"," x ").concat(e.quantity||1),value:e._id||e.productId||"product-".concat(t),productId:e.productId,productName:e.productName||e.name}))];(0,s.useEffect)(()=>{let e=async()=>{T(!0);try{let e=await g.Z.get("".concat(f.x,"/service-templates/list?limit=100&activeOnly=true"),{headers:{Authorization:"Bearer ".concat(i)}});e.data.success&&C(e.data.data.map(e=>({label:e.name,value:e._id,...e})))}catch(e){console.error("Error fetching service templates:",e)}finally{T(!1)}};i&&e()},[i]),(0,s.useEffect)(()=>{let e=async()=>{try{let e=null==r?void 0:r._id,t=await g.Z.get("".concat(f.x,"/staff/list"),{params:e?{vendorId:e,limit:500}:{limit:500},headers:{Authorization:"Bearer ".concat(i)}});t.data.success&&E((t.data.data||[]).map(e=>({label:e.name,value:e._id})))}catch(e){console.error("Error fetching staff:",e)}};i&&e()},[i,null==r?void 0:r._id]);let B=e=>{y(e);let t={..._[e]};if(t.initialServiceDate&&(t.initialServiceDate=new Date(t.initialServiceDate)),t.endDate&&(t.endDate=new Date(t.endDate)),t.linkedOrderLineId&&!t.isIndependentItem){let e=(a.products||[]).find(e=>(e._id||e.productId)===t.linkedOrderLineId);A((null==e?void 0:e.selectedAssets)||[])}else A([]);D(t),p(!0)},L=e=>{let t=S.find(t=>t.value===e);t&&D(e=>({...e,serviceTemplateId:t._id,serviceName:t.name,description:t.description||"",serviceCategory:t.serviceCategory||"other",billingBasis:t.billingBasis||"per_visit",rate:t.defaultRate||0,scheduleType:t.allowRecurring?e.scheduleType:"one_off",templateSnapshot:{allowRecurring:t.allowRecurring,requiresProductLink:t.requiresProductLink,defaultDuration:t.defaultDuration}}))},O=e=>{let t=W.find(t=>t.value===e),l=(a.products||[]).find(t=>(t._id||t.productId)===e);A((null==l?void 0:l.selectedAssets)||[]),D(a=>({...a,isIndependentItem:!1,linkedOrderLineId:e,linkedOrderLineName:(null==t?void 0:t.productName)||"",linkedProductId:(null==t?void 0:t.productId)||null,linkedProductName:(null==t?void 0:t.productName)||"",linkedAssetNumbers:[]}))},U=e=>{if("__independent__"===e){D(e=>({...e,isIndependentItem:!0,linkedOrderLineId:null,linkedOrderLineName:"",linkedProductId:null,linkedProductName:"",linkedAssetNumbers:[]})),A([]),z(null);return}let t=_.find((t,a)=>t.linkedOrderLineId===e&&a!==v);t?z({productVal:e,existingServiceName:t.serviceName}):(z(null),O(e))},V=e=>{t({serviceLines:_.filter((t,a)=>a!==e)})},G=j.scheduleType&&"one_off"!==j.scheduleType;return(0,l.jsxs)("div",{className:"mt-4",children:[(0,l.jsx)(Y.F,{ref:o}),(0,l.jsxs)("div",{className:"flex align-items-center justify-content-between mb-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("label",{className:"text-900 font-semibold",style:{fontSize:"1rem"},children:"Services"}),(0,l.jsxs)("span",{className:"text-500 ml-2",style:{fontSize:"0.8rem"},children:["(",_.length," line",1!==_.length?"s":"",")"]})]}),(0,l.jsx)(c.z,{label:"Add Service",icon:"pi pi-plus",className:"p-button-outlined p-button-sm",onClick:()=>{y(null),D({...ea}),A([]),p(!0)}})]}),_.length>0&&(0,l.jsxs)("div",{className:"surface-card border-round-xl p-3 mb-3",children:[(0,l.jsxs)("table",{style:{width:"100%",borderCollapse:"collapse"},children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{style:{borderBottom:"1px solid #e5e7eb",fontSize:"0.75rem",fontWeight:600,color:"#667085",textAlign:"left"},children:[(0,l.jsx)("th",{style:{padding:"8px"},children:"Service"}),(0,l.jsx)("th",{style:{padding:"8px"},children:"Linked To"}),(0,l.jsx)("th",{style:{padding:"8px"},children:"Billing"}),(0,l.jsx)("th",{style:{padding:"8px"},children:"Rate"}),(0,l.jsx)("th",{style:{padding:"8px"},children:"Assigned To"}),(0,l.jsx)("th",{style:{padding:"8px"},children:"Schedule"}),(0,l.jsx)("th",{style:{padding:"8px"},children:"Amount"}),(0,l.jsx)("th",{style:{padding:"8px",textAlign:"center"},children:"Actions"})]})}),(0,l.jsx)("tbody",{children:_.map((e,t)=>{var s;return(0,l.jsxs)("tr",{style:{borderBottom:"1px solid #f3f4f6",fontSize:"0.8rem"},children:[(0,l.jsx)("td",{style:{padding:"8px"},children:(0,l.jsx)("span",{className:"font-medium text-900",children:e.serviceName})}),(0,l.jsx)("td",{style:{padding:"8px"},children:e.isIndependentItem?(0,l.jsx)(x.V,{value:"Independent",severity:"secondary",className:"text-xs"}):(0,l.jsxs)("div",{children:[(0,l.jsx)("span",{className:"text-700",children:e.linkedProductName||e.linkedOrderLineName}),(0,l.jsx)("div",{className:"text-500",style:{fontSize:"0.7rem"},children:(null===(s=e.linkedAssetNumbers)||void 0===s?void 0:s.length)>0?"".concat(e.linkedAssetNumbers.length," asset(s): ").concat(e.linkedAssetNumbers.join(", ")):"All assets"})]})}),(0,l.jsx)("td",{style:{padding:"8px"},children:(0,l.jsx)(x.V,{value:et[e.billingBasis]||e.billingBasis,style:{background:"#F4F3FF",color:"#6941C6"},className:"text-xs",rounded:!0})}),(0,l.jsx)("td",{style:{padding:"8px"},children:Number(e.rate).toFixed(2)}),(0,l.jsx)("td",{style:{padding:"8px"},children:(0,l.jsx)("span",{className:"text-700",style:{fontSize:"0.8rem"},children:e.assignedToName||"-"})}),(0,l.jsx)("td",{style:{padding:"8px"},children:(0,l.jsx)(x.V,{value:"one_off"===e.scheduleType?"One-Off":e.scheduleType.charAt(0).toUpperCase()+e.scheduleType.slice(1),style:{background:"one_off"===e.scheduleType?"#F2F4F7":"#ECFDF3",color:"one_off"===e.scheduleType?"#344054":"#027A48"},className:"text-xs",rounded:!0})}),(0,l.jsx)("td",{style:{padding:"8px",fontWeight:600},children:Number(e.plannedAmount||el(e,a.products)).toFixed(2)}),(0,l.jsx)("td",{style:{padding:"8px",textAlign:"center"},children:(0,l.jsxs)("div",{className:"flex align-items-center justify-content-center gap-2",children:[(0,l.jsx)(c.z,{icon:"pi pi-pencil",className:"p-button-text p-button-sm",onClick:()=>B(t),tooltip:"Edit"}),(0,l.jsx)(c.z,{icon:"pi pi-trash",className:"p-button-text p-button-danger p-button-sm",onClick:()=>V(t),tooltip:"Remove"})]})})]},t)})})]}),(0,l.jsxs)("div",{className:"flex justify-content-end mt-3 pt-2",style:{borderTop:"1px solid #e5e7eb"},children:[(0,l.jsx)("span",{className:"text-700 mr-3",style:{fontSize:"0.85rem"},children:"Services Total:"}),(0,l.jsx)("span",{className:"text-900 font-bold",style:{fontSize:"0.95rem"},children:_.reduce((e,t)=>
1e+Number(t.plannedAmount||el(t,a.products)),0).toFixed(2)})]})]}),(0,l.jsxs)(F.V,{header:null!==v?"Edit Service Line":"Add Service Line",visible:h,onHide:()=>p(!1),style:{width:"700px"},modal:!0,dismissableMask:!0,children:[(0,l.jsxs)("div",{className:"grid formgrid p-fluid",children:[(0,l.jsxs)("div",{className:"col-12 mb-3",children:[(0,l.jsxs)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:["Service Template ",(0,l.jsx)("span",{style:{color:"#F04438"},children:"*"})]}),(0,l.jsx)(m.L,{value:j.serviceTemplateId,options:S,onChange:e=>L(e.value),placeholder:"Select a service template",loading:I,filter:!0,filterPlaceholder:"Search templates..."})]}),(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Service Name"}),(0,l.jsx)(u.o,{value:j.serviceName,onChange:e=>D(t=>({...t,serviceName:e.target.value})),placeholder:"Service name"})]}),(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Linked Product"}),(0,l.jsx)(m.L,{value:j.isIndependentItem?"__independent__":j.linkedOrderLineId,options:W,onChange:e=>U(e.value),placeholder:"Select product or Independent Item"})]}),R&&(0,l.jsx)("div",{className:"col-12 mb-3",children:(0,l.jsxs)("div",{className:"border-round p-3 flex align-items-center justify-content-between",style:{background:"#FFFAEB",border:"1px solid #FEC84B"},children:[(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)("i",{className:"pi pi-exclamation-triangle",style:{color:"#DC6803"}}),(0,l.jsxs)("span",{className:"text-800",style:{fontSize:"0.85rem"},children:["This product already has a service: ",(0,l.jsx)("strong",{children:R.existingServiceName})]})]}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(c.z,{label:"Cancel",size:"small",text:!0,onClick:()=>z(null),className:"p-button-sm"}),(0,l.jsx)(c.z,{label:"Add Anyway",size:"small",severity:"warning",onClick:()=>{O(R.productVal),z(null)},className:"p-button-sm"})]})]})}),!j.isIndependentItem&&P.length>0&&(0,l.jsxs)("div",{className:"col-12 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Assets to Service"}),(0,l.jsxs)("div",{className:"surface-100 border-round p-3",children:[(0,l.jsxs)("div",{className:"flex align-items-center gap-2 mb-2",children:[(0,l.jsx)(N.X,{inputId:"allAssets",checked:!j.linkedAssetNumbers||0===j.linkedAssetNumbers.length,onChange:e=>{D(e=>({...e,linkedAssetNumbers:[]}))}}),(0,l.jsxs)("label",{htmlFor:"allAssets",className:"text-800 font-medium",style:{fontSize:"0.85rem"},children:["All Assets (",P.length,")"]})]}),(0,l.jsx)("div",{className:"flex flex-wrap gap-3 mt-2 pt-2",style:{borderTop:"1px solid #e5e7eb"},children:P.map(e=>{let t=!j.linkedAssetNumbers||0===j.linkedAssetNumbers.length,a=t||j.linkedAssetNumbers.includes(e.assetNumber);return(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)(N.X,{inputId:"asset-".concat(e.assetNumber),checked:a,onChange:a=>{if(t&&!a.checked){let t=P.map(e=>e.assetNumber).filter(t=>t!==e.assetNumber);D(e=>({...e,linkedAssetNumbers:t}))}else if(!t){let t;(t=a.checked?[...j.linkedAssetNumbers,e.assetNumber]:j.linkedAssetNumbers.filter(t=>t!==e.assetNumber)).length===P.length&&(t=[]),D(e=>({...e,linkedAssetNumbers:t}))}}}),(0,l.jsx)("label",{htmlFor:"asset-".concat(e.assetNumber),className:"text-700",style:{fontSize:"0.8rem",fontFamily:"monospace"},children:e.assetNumber})]},e.assetNumber)})})]})]}),(0,l.jsx)(q.i,{className:"col-12 my-2"}),(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Billing Basis"}),(0,l.jsx)(m.L,{value:j.billingBasis,options:K,onChange:e=>D(t=>({...t,billingBasis:e.value}))})]}),(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Charging"}),(0,l.jsxs)("div",{className:"flex align-items-center gap-2",style:{height:42},children:[(0,l.jsx)(N.X,{inputId:"chargeable-toggle",checked:!1===j.chargeable,onChange:e=>D(t=>({...t,chargeable:!e.checked,rate:e.checked?0:t.rate}))}),(0,l.jsx)("label",{htmlFor:"chargeable-toggle",style:{fontSize:"0.85rem",cursor:"pointer"},children:"Included in rental — no separate charge"})]})]}),!1!==j.chargeable&&(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Rate"}),(0,l.jsx)(d.R,{value:j.rate,onValueChange:e=>D(t=>{var a;return{...t,rate:null!==(a=e.value)&&void 0!==a?a:0}}),mode:"decimal",minFractionDigits:2,maxFractionDigits:2,min:0,inputStyle:{width:"100%"},style:{width:"100%"}})]}),"per_hour"===j.billingBasis&&(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Planned Hours"}),(0,l.jsx)(d.R,{value:j.plannedHours,onValueChange:e=>D(t=>{var a;return{...t,plannedHours:null!==(a=e.value)&&void 0!==a?a:0}}),min:0,mode:"decimal",minFractionDigits:1,maxFractionDigits:2,inputStyle:{width:"100%"},style:{width:"100%"}})]}),("per_day"===j.billingBasis||"per_week"===j.billingBasis)&&(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsxs)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:["Duration (","per_day"===j.billingBasis?"days":"weeks",")"]}),(0,l.jsx)(d.R,{value:j.duration,onValueChange:e=>D(t=>{var a;return{...t,duration:null!==(a=e.value)&&void 0!==a?a:0}}),min:0,inputStyle:{width:"100%"},style:{width:"100%"}})]}),(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Tax Rate (%)"}),(0,l.jsx)(d.R,{value:j.taxRate,onValueChange:e=>D(t=>{var a;
1return{...t,taxRate:null!==(a=e.value)&&void 0!==a?a:0}}),min:0,max:100,suffix:"%",inputStyle:{width:"100%"},style:{width:"100%"}})]}),(0,l.jsx)("div",{className:"col-12 mb-3",children:(0,l.jsxs)("div",{className:"surface-100 border-round p-3 flex justify-content-between align-items-center",children:[(0,l.jsx)("span",{className:"text-700",style:{fontSize:"0.85rem"},children:"Planned Amount:"}),(0,l.jsx)("span",{className:"text-900 font-bold",style:{fontSize:"1.1rem"},children:el(j,a.products).toFixed(2)})]})}),(0,l.jsx)(q.i,{className:"col-12 my-2"}),(0,l.jsx)("div",{className:"col-12 mb-2",children:(0,l.jsx)("label",{className:"text-900 font-semibold",style:{fontSize:"0.9rem"},children:"Scheduling"})}),(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Schedule Type"}),(0,l.jsx)(m.L,{value:j.scheduleType,options:$,onChange:e=>D(t=>({...t,scheduleType:e.value}))})]}),(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Initial Service Date"}),(0,l.jsx)(w.f,{value:j.initialServiceDate,onChange:e=>D(t=>({...t,initialServiceDate:e.value})),dateFormat:"dd/mm/yy",showIcon:!0,placeholder:"Select date",style:{width:"100%"}})]}),"weekly"===j.scheduleType&&(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Recurring Service Day"}),(0,l.jsx)(m.L,{value:j.recurringDayOfWeek,options:ee,onChange:e=>D(t=>({...t,recurringDayOfWeek:e.value})),placeholder:"Select day"})]}),"monthly"===j.scheduleType&&(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Recurring Day of Month"}),(0,l.jsx)(d.R,{value:j.recurringDayOfWeek,onValueChange:e=>D(t=>({...t,recurringDayOfWeek:e.value})),min:1,max:31,inputStyle:{width:"100%"},style:{width:"100%"}})]}),G&&(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Recurrence End Rule"}),(0,l.jsx)(m.L,{value:j.recurrenceEndRule,options:J,onChange:e=>D(t=>({...t,recurrenceEndRule:e.value}))})]}),G&&"on_date"===j.recurrenceEndRule&&(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"End Date"}),(0,l.jsx)(w.f,{value:j.endDate,onChange:e=>D(t=>({...t,endDate:e.value})),dateFormat:"dd/mm/yy",showIcon:!0,placeholder:"Select end date",style:{width:"100%"}})]}),G&&(0,l.jsx)("div",{className:"col-12 mb-3",children:(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)(N.X,{inputId:"showInCalendar",checked:j.showInCalendar,onChange:e=>D(t=>({...t,showInCalendar:e.checked}))}),(0,l.jsx)("label",{htmlFor:"showInCalendar",className:"text-800",style:{fontSize:"0.85rem"},children:"Show in tenant calendar"})]})}),(0,l.jsxs)("div",{className:"col-12 md:col-6 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Assigned To"}),(0,l.jsx)(m.L,{value:j.assignedTo,options:[{label:"Unassigned",value:null},...M],onChange:e=>{let t=M.find(t=>t.value===e.value);D(a=>({...a,assignedTo:e.value,assignedToName:(null==t?void 0:t.label)||""}))},placeholder:"Select staff member",showClear:!0})]}),(0,l.jsxs)("div",{className:"col-12 mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900",style:{fontSize:"0.85rem",fontWeight:500},children:"Notes / Description"}),(0,l.jsx)(k.g,{value:j.description,onChange:e=>D(t=>({...t,description:e.target.value})),rows:2,autoResize:!0,placeholder:"Optional notes..."})]})]}),(0,l.jsxs)("div",{className:"flex justify-content-end gap-2 pt-3",style:{borderTop:"1px solid var(--surface-border)"},children:[(0,l.jsx)(c.z,{label:"Cancel",outlined:!0,onClick:()=>p(!1),className:"p-button-sm"}),(0,l.jsx)(c.z,{label:null!==v?"Update":"Add",onClick:()=>{var e,l,s;if(!j.serviceTemplateId||!j.serviceName){null===(e=o.current)||void 0===e||e.show({severity:"error",summary:"Validation",detail
1:"Please select a service template",life:2e3});return}let n=(null==j?void 0:j.assignedTo)&&"object"==typeof j.assignedTo?null!==(l=j.assignedTo.value)&&void 0!==l?l:null:null!==(s=j.assignedTo)&&void 0!==s?s:null,i=(null==j?void 0:j.assignedToName)||(null==j?void 0:j.assignedTo)&&"object"==typeof j.assignedTo&&j.assignedTo.label||"",r={...j,assignedTo:n,assignedToName:i,plannedAmount:el({...j,assignedTo:n},a.products)},d=[..._];null!==v?d[v]=r:d.push(r),t({serviceLines:d}),p(!1)},className:"p-button-sm"})]})]})]})}var en=a(66095);function ei(){var e,t;let{getTerm:a,getPlural:N}=(0,y.m)(),{state:w,updateFormData:k,completeStep:D,setValidation:S}=(0,n.a)(),{formData:C}=w,{token:I,user:T}=(0,b.v9)(e=>null==e?void 0:e.auth),P=(0,b.v9)(e=>{var t,a;return null==e?void 0:null===(a=e.auth)||void 0===a?void 0:null===(t=a.user)||void 0===t?void 0:t.currencyKey})||(null==T?void 0:T.currencyKey),A=null==T?void 0:null===(e=T.preferences)||void 0===e?void 0:e.quickTips,[z,E]=(0,s.useState)([]),[_,W]=(0,s.useState)(0),[U,V]=(0,s.use
1State)(C.products||[]),[Y,K]=(0,s.useState)(!0),[$,J]=(0,s.useState)(""),[ee,et]=(0,s.useState)(""),[ea,el]=(0,s.useState)(null),[ei,er]=(0,s.useState)([]),[eo,ed]=(0,s.useState)("all"),ec=[{label:"All",value:"all"},{label:"Rental",value:"rental"},{label:"Sale",value:"sale"}],[eu,em]=(0,s.useState)({}),[ex,eh]=(0,s.useState)({}),[ep,ev]=(0,s.useState)(C.orderDiscount||0),[eg,ef]=(0,s.useState)(!0),[eb,ey]=(0,s.useState)(!0),[ej,eN]=(0,s.useState)(!1),[ew,ek]=(0,s.useState)(null),[eD,eS]=(0,s.useState)({}),[eC,eI]=(0,s.useState)(!1),[eT,eP]=(0,s.useState)(null),[eA,eR]=(0,s.useState)(0),[ez,eM]=(0,s.useState)(C.damageWaiverLevel||null),[eF,eE]=(0,s.useState)(C.damageWaiverCalculations||{waiverAmount:0,taxAmount:0,totalAmount:0}),[e_,eW]=(0,s.useState)(!1),[eB,eL]=(0,s.useState)(!0),[eO,eq]=(0,s.useState)(null),[eU,eV]=(0,s.useState)(C.depositType||"noDeposit"),[eG,eZ]=(0,s.useState)(C.depositPercentage||0),[eH,eQ]=(0,s.useState)(C.depositFixedAmount||0),[eX,eY]=(0,s.useState)(C.deliveryCharge||0),[eK,e$]=(0,s.useState)(C.collectionCharge||0),[eJ,e0]=(0,s.useState)(10),[e1,e2]=(0,s.useState)(0),[e3,e6]=(0,s.useState)({}),e5=C.openEnded?"Open ended":C.chargingStartDate&&C.expectedReturnDate?(0,j.pi)(new Date(C.chargingStartDate),new Date(C.expectedReturnDate)):1,e9=(0,s.useCallback)(e=>{let t=(null==e?void 0:e.rateDefinition)||(null==e?void 0:e.rateDefinitionSnapshot),a=(null==t?void 0:t.baseUnit)||(null==t?void 0:t.rateType)||e.rate||"daily",l=a;"weekly"===a&&(l="week"),"monthly"===a&&(l="month"),"hourly"===a&&(l="hour"),"nightly"===a&&(l="night");let s=e.rentPrice||e.price||0,n="week"===l,i="hour"===l,r="night"===l,o="block"===l,d=Number(e.salePrice),c=!isNaN(d)&&d>0;return{rate:s,period:l,baseUnit:l,isWeekly:n,isHourly:i,isNightly:r,isBlock:o,isSaleProduct:"Sale"===e.status||c,chargeableDays:(null==t?void 0:t.chargeableDays)||["Mon","Tue","Wed","Thu","Fri"],rentalDaysPerWeek:(null==t?void 0:t.rentalDaysPerWeek)||((null==t?void 0:t.chargeableDays)||["Mon","Tue","Wed","Thu","Fri"]).length,minimumRentalPeriod:(null==t?void 0:t.minimumRentalPeriod)||1,minimumRentalUnit:(null==t?void 0:t.minimumRentalUnit)||"day",blockConfig:null==t?void 0:t.blockConfig}},[]),e4=e=>{let t=String(e||"").trim().match(/^(\d{1,2}):(\d{2})$/);return t?{hh:Math.min(23,Math.max(0,Number(t[1]))),mm:Math.min(59,Math.max(0,Number(t[2])))}:null},e7=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],e8=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],l=new Set(a||[]),s=0,n=new Date(e);for(;n<t;){let e=new Date(n.getFullYear(),n.getMonth(),n.getDate(),0,0,0,0),a=new Date(e);a.setDate(e.getDate()+1);let i=n,r=t<a?t:a,o=e7[e.getDay()];(0===l.size||l.has(o))&&(s+=Math.floor((r-i)/6e4)),n=r}return Math.max(0,s)},te=(e,t)=>{let a=new Date(t);return a.getTime()<=e.getTime()&&(a=new Date(a.getTime()+864e5)),a},tt=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{hh:0,mm:0},l=e?new Date(e):null;if(!l||isNaN(l.getTime()))return null;let s=e4(t)||a;return new Date(l.getFullYear(),l.getMonth(),l.getDate(),s.hh,s.mm,0,0)},ta=(e,t,a)=>(null==e?void 0:e[t])||a||null,tl=(0,s.useCallback)(e=>{let{baseUnit:t,chargeableDays:a,minimumRentalPeriod:l,minimumRentalUnit:s,rentalDaysPerWeek:n}=e9(e),i=ta(e,"lineChargingStartDate",C.chargingStartDate),r=ta(e,"lineExpectedReturnDate",C.expectedReturnDate),o=i?new Date(i):null,d=r?new Date(r):null;if(!o||!d)return 1;if(C.openEnded){let e=l||1;return"day"===s||"night"===s?e:"week"===s?e*(a.length||7):"month"===s?e*(a.length||7)*4:e}let c=new Date(o.getFullYear(),o.getMonth(),o.getDate()),u=new Date(d.getFullYear(),d.getMonth(),d.getDate());if("hour"===t){let e=tt(i,C.chargingStartTime,{hh:0,mm:0}),t=tt(r,C.returnTime,{hh:0,mm:0});if(!e||!t||t<=e)return 1;let n=e8(e,t,a),o=Math.floor(n/60)+(n%60>=30?1:0);o=Math.max(o,1);let d=0,c=Number(l||0);return c>0&&("hour"===s?d=c:"day"===s||"night"===s?d=24*c:"week"===s?d=168*c:"month"===s&&(d=720*c)),Math.max(o,d||1)}if("night"===t)return Math.max(Math.floor((u-c)/864e5),l||1);let m=0,x=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=7>(Number(n)||7)&&a&&a.length>0,p=eb?u:new Date(u.getTime()-864e5);for(let e=new Date(c);e<=p;e.setDate(e.getDate()+1)){let t=x[e.getDay()];(!h||a.includes(t))&&m++}let v=l||1;return"day"===s||"night"===s?Math.max(m,v):"week"===s?Math.max(m,7*v):"month"===s?Math.max(m,30*v):Math.max(m,v,1)},[C.chargingStartDate,C.expectedReturnDate,e9,eb]),ts=(0,s.useCallback)(e=>{let{baseUnit:t,chargeableDays:a,minimumRentalPeriod:l,minimumRentalUnit:s,blockConfig:n,rentalDaysPerWeek:r}=e9(e),o=ta(e,"lineChargingStartDate",C.chargingStartDate),d=ta(e,"lineExpectedReturnDate",C.expectedReturnDate),c=o?new Date(o):null,u=d?new Date(d):null;if(C.openEnded){if("hour"===t){let e=Number(r||(null==a?void 0:a.length)||7),t=Number(l||1);return"hour"===s?t:"day"===s||"night"===s?24*t:"week"===s?t*e*24:"month"===s?t*e*96:Math.max(t,1)}if("night"===t||"block"===t)return Math.max(l||1,1);
1if("week"===t){let e=l||1,t=a.length||7;return"week"===s?e:Math.ceil(e/t)}return"month"===t?"month"===s?l||1:(l||1)/30:Math.max(l||1,1)}if(!c||!u)return 1;let m=new Date(c.getFullYear(),c.getMonth(),c.getDate()),x=new Date(u.getFullYear(),u.getMonth(),u.getDate()),h=tl(e);if(l>0&&("hour"===s||"day"===s||"night"===s||("week"===s?a.length:"month"===s&&a.length)),"hour"===t){let e=tt(o,C.chargingStartTime,{hh:0,mm:0}),t=tt(d,C.returnTime,{hh:0,mm:0});if(!e||!t)return 1;let n=te(e,t),i=e8(e,n,a),c=Math.floor(i/60);c+=i%60>=30?1:0,c=Math.max(1,c);let u=Number(r||(null==a?void 0:a.length)||7),m=0,x=Number(l||0);return x>0&&("hour"===s?m=x:"day"===s||"night"===s?m=24*x:"week"===s?m=x*u*24:"month"===s&&(m=x*u*96)),Math.max(c,m||1)}if("night"===t){let e=o?new Date(o):null,t=d?new Date(d):null;return e&&t?Math.max(Math.floor((t-e)/864e5),l):1}if("block"===t){let e=Number((null==n?void 0:n.length)||1),t=(null==n?void 0:n.unit)||"week",i=(null==n?void 0:n.roundingRule)||"next_unit",o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],d=new Set(a||[]),c=0,u=eb?x:new Date(x.getTime()-864e5);for(let e=new Date(m);e<=u;e.setDate(e.getDate()+1)){let t=o[e.getDay()];d.has(t)&&(c+=1)}let h=0,p=Number(l||0);if(p>0){let e=Number(r||(null==a?void 0:a.length)||7);"day"===s||"night"===s?h=p:"week"===s?h=p*e:"month"===s&&(h=p*e*4)}let v=Number(r||(null==a?void 0:a.length)||7),g=7*e;"day"===t&&(g=1*e),"month"===t&&(g=30*e);let f=v*e;"day"===t&&(f=1*e),"month"===t&&(f=4*v*e);let b=0;if("none"===i){let e=Math.max(c,h,1);b=f?e/f:0}else b=g?Math.max(0,Math.floor((x-m)/864e5))/g:0;let y=b;"next_unit"===i?y=Math.ceil(b):"round_down"===i&&(y=Math.floor(b));let j=0;if("none"===i)j=f?h/f:0;else{let e=Math.ceil((h||0)*(v?7/v:1));j=g?e/g:0}return j&&y<j&&(y=j),Math.max(y,1)}if("week"===t){var p;let t=(null==e?void 0:null===(p=e.rateDefinition)||void 0===p?void 0:p.partialWeeksHandling)||"roundUpToFullWeek",n=a.length||7,i=l||1,r="week"===s?i:Math.ceil(i/n);return"roundUpToFullWeek"===t?Math.max(Math.ceil(h/n),r):Math.max(h/n,r)}let v=l||1;return"month"===t?Math.max((0,i.W9)({baseUnit:t,chargeableDays:h}),"month"===s?v:Math.ceil(v/30)):Math.max(h,v)},[tl,e9,C.chargingStartDate,C.expectedReturnDate,eb]);(0,s.useEffect)(()=>{let e={};U.forEach(t=>{t.selectedAssets?e[t.productId]=t.selectedAssets:t.quantity&&t.isQuantityBased&&(e[t.productId]=[{assetNumber:"quantity-based",quantity:t.quantity}])}),eS(e)},[U]),(0,s.useEffect)(()=>{tn()},[T]);let tn=async()=>{try{var e;eL(!0);let t=(null==T?void 0:T._id)||(null==T?void 0:T.vendor),a=await g.Z.get("".concat(f.x,"/damage-waiver/settings"),{headers:{authorization:"Bearer ".concat(I)},params:{vendorId:t}});if(null===(e=a.data)||void 0===e?void 0:e.success){let e=a.data.data;eW((null==e?void 0:e.damageWaiverEnabled)||!1),eq(e)}else eW(!1),eq(null)}catch(e){console.error("Failed to fetch damage waiver settings:",e),eW(!1),eq(null)}finally{eL(!1)}};(0,s.useEffect)(()=>{k({orderDiscount:ep})},[ep]),(0,s.useEffect)(()=>{let e=setTimeout(()=>et($),350);return()=>clearTimeout(e)},[$]),(0,s.useEffect)(()=>{e2(0)},[ee,ea,eo]),(0,s.useEffect)(()=>{let e=!1;return(async()=>{let t=null==T?void 0:T._id;if(t&&I)try{var a;let l=await g.Z.post("".concat(f.x,"/product/order-wizard-product-categories"),{vendorId:t},{headers:{authorization:"Bearer ".concat(I),"Content-Type":"application/json"}});!e&&(null===(a=l.data)||void 0===a?void 0:a.success)&&Array.isArray(l.data.data)&&er(l.data.data)}catch(t){e||console.error("Failed to fetch wizard categories:",t)}})(),()=>{e=!0}},[T,I]),(0,s.useEffect)(()=>{let e=!1;return(async()=>{let t=null==T?void 0:T._id;if(!t||!I){K(!1);return}try{var a,l;K(!0);let s=new URLSearchParams({search:ee,page:String(e1+1),limit:String(eJ),productType:eo});ea&&s.set("categoryName",ea),C.depot&&s.set("depotId",C.depot);let n=await g.Z.post("".concat(f.x,"/product/order-wizard-products?").concat(s.toString()),{vendorId:t},{headers:{authorization:"Bearer ".concat(I),"Content-Type":"application/json"}});if(e)return;if(null===(a=n.data)||void 0===a?void 0:a.success){E(n.data.data||[]);let e=n.data.pagination;W(null!==(l=null==e?void 0:e.total)&&void 0!==l?l:0)}}catch(t){e||console.error("Failed to fetch products:",t)}finally{e||K(!1)}})(),()=>{e=!0}},[ee,ea,eo,e1,eJ,T,I,C.depot]),(0,s.useEffect)(()=>{let e=Math.max(1,Math.ceil(_/eJ)||1)-1;e1>e&&e2(e)},[_,eJ,e1]),(0,s.useEffect)(()=>{let e=async()=>{try{var e;let t=await g.Z.get("".concat(f.x,"/settings/hire-duration-rules"),{headers:{authorization:"Bearer ".concat(I
1)}});if(null===(e=t.data)||void 0===e?void 0:e.data){let e=!1!==t.data.data.chargeReturnDay;ey(e),k({chargeReturnDay:e})}}catch(e){console.error("Failed to fetch hire duration rules:",e)}};I&&e()},[I]);let ti=e=>{let t=z.find(t=>t._id===e);if(t){if(t.isQuantityBased){var a;eP(t),eR((null===(a=U.find(t=>t.productId===e))||void 0===a?void 0:a.quantity)||0),eI(!0)}else ek(t),eN(!0)}},tr=(e,t,a)=>{eS(l=>({...l,[e]:(l[e]||[]).map(e=>e.assetId===t?{...e,overridePrice:"number"==typeof a?a:null}:e)})),V(l=>{let s=l.map(l=>{if(l.productId!==e)return l;let s=(l.selectedAssets||[]).map(e=>e.assetId===t?{...e,overridePrice:"number"==typeof a?a:null}:e);return{...l,selectedAssets:s}});return k({products:s}),s})},to=(e,t,a)=>{V(l=>{let s=l.map(l=>l.productId===e?{...l,[t]:a||null}:l);return k({products:s}),s})},td=(e,t)=>{V(a=>{let l=a.map(a=>a.productId===e?{...a,discount:t||null}:a);return k({products:l}),l})},tc=Number(null==C?void 0:null===(t=C.customerDetails)||void 0===t?void 0:t.defaultDiscountPercent)||0,tu=(e,t)=>{e6(a=>({...a,[e]:"boolean"==typeof t?t:!a[e]}))},tm=(e,t)=>{var a,l,s;let n=z.find(t=>t._id===e);if(!n)return;let i=null==n?void 0:n.isQuantityBased,r=Number(n.salePrice),o=!isNaN(r)&&r>0?r:null!==(s=null!==(l=null!==(a=n.overrideUnitPrice)&&void 0!==a?a:n.rentPrice)&&void 0!==l?l:n.price)&&void 0!==s?s:0;if(i){let a=Number(t)||0,l=Array.from({length:a},(t,a)=>({assetId:"".concat(e,"-unit-").concat(a+1),assetNumber:"quantity-based",label:"Unit ".concat(a+1),quantity:1,overridePrice:o}));eS(t=>({...t,[e]:l})),V(t=>{let s=t.filter(t=>t.productId!==e);if(a>0){var i,r,o,d,c,u,m,x,h,p,v,g,f;let e={productId:n._id,name:n.productName||n.name,productName:n.productName||n.name,sku:n.sku,category:(null===(i=n.category)||void 0===i?void 0:i.name)||"Uncategorized",dailyRate:n.rentPrice||n.price||0,quantity:a,selectedAssets:l,image:(null===(r=n.images)||void 0===r?void 0:r[0])||"/images/product/placeholder.webp",maintenanceRequired:n.maintenanceRequired||!1,damageWaiverEnabled:!!n.damageWaiverEnabled,currency:P,product:n._id,price:n.rentPrice||n.salePrice||0,salePrice:n.salePrice,rentPrice:n.rentPrice||n.price||0,rateDefinition:null==n?void 0:n.rateDefinition,partialWeeksHandling:null==n?void 0:null===(o=n.rateDefinition)||void 0===o?void 0:o.partialWeeksHandling,rate:n.rate,taxRate:null!==(f=null==n?void 0:null===(d=n.taxClass)||void 0===d?void 0:d.taxRate)&&void 0!==f?f:20,taxClassName:(null==n?void 0:null===(c=n.taxClass)||void 0===c?void 0:c.name)||"VAT",taxMode:(null==n?void 0:null===(u=n.taxClass)||void 0===u?void 0:u.mode)||"simple",taxParts:(null==n?void 0:null===(m=n.taxClass)||void 0===m?void 0:m.parts)||[],xeroTaxTypeId:null==n?void 0:null===(x=n.taxClass)||void 0===x?void 0:x.xeroTaxTypeId,quickBooksTaxId:null==n?void 0:null===(h=n.taxClass)||void 0===h?void 0:h.quickBooksTaxId,zohoTaxId:null==n?void 0:null===(p=n.taxClass)||void 0===p?void 0:p.zohoTaxId,rentalDaysPerWeek:null==n?void 0:null===(v=n.rateDefinition)||void 0===v?void 0:v.rentalDaysPerWeek,minimumRentalPeriod:null==n?void 0:null===(g=n.rateDefinition)||void 0===g?void 0:g.minimumRentalPeriod,isQuantityBased:!0,overrideUnitPrice:null};s.push(e)}return k({products:s}),s});return}let d=(t||[]).map(e=>({...e,overridePrice:"number"==typeof e.overridePrice?e.overridePrice:o}));eS(t=>({...t,[e]:d})),V(t=>{let a=t.filter(t=>t.productId!==e);if(d.length>0){var l,s,i,r,o,c,u,m,x,h,p,v,g;let e={productId:n._id,name:n.productName||n.name,productName:n.productName||n.name,sku:n.sku,category:(null===(l=n.category)||void 0===l?void 0:l.name)||"Uncategorized",dailyRate:n.rentPrice||n.price||0,quantity:d.length,selectedAssets:d,image:(null===(s=n.images)||void 0===s?void 0:s[0])||"/images/product/placeholder.webp",maintenanceRequired:n.maintenanceRequired||!1,damageWaiverEnabled:!!n.damageWaiverEnabled,currency:P,product:n._id,price:n.rentPrice||n.salePrice||0,salePrice:n.salePrice,rentPrice:n.rentPrice||n.price||0,rateDefinition:null==n?void 0:n.rateDefinition,partialWeeksHandling:null==n?void 0:null===(i=n.rateDefinition)||void 0===i?void 0:i.partialWeeksHandling,rate:n.rate,taxRate:null!==(g=null==n?void 0:null===(r=n.taxClass)||void 0===r?void 0:r.taxRate)&&void 0!==g?g:20,taxClassName:(null==n?void 0:null===(o=n.taxClass)||void 0===o?void 0:o.name)||"VAT",taxMode:(null==n?void 0:null===(c=n.taxClass)||void 0===c?void 0:c.mode)||"simple",taxParts:(null==n?void 0:null===(u=n.taxClass)||void 0===u?void 0:u.parts)||[],xeroTaxTypeId:null==n?void 0:null===(m=n.taxClass)||void 0===m?void 0:m.xeroTaxTypeId,quickBooksTaxId:null==n?void 0:null===(x=n.taxClass)||void 0===x?void 0:x.quickBooksTaxId,zohoTaxId:null==n?void 0:null===(h=n.taxClass)||void 0===h?void 0:h.zohoTaxId,rentalDaysPerWeek:null==n?void 0:null===(p=n.rateDefinition)||void 0===p?void 0:p.rentalDaysPerWeek,minimumRentalPeriod:null==n?void 0:null===(v=n.rateDefinition)||void 0===v?void 0:v.minimumRentalPeriod,isQuantityBased:!1,overrideUnitPrice:null};a.push(e)}return k({products:a}),a})},tx=(0,s.useCallback)(e=>{let t=Number(e.salePrice),a=!isNaN(t)&&t>0,l="Sale"===e.status;return a||l},[]),th=e=>{var t,a,l,s,n,i;if(tx(e))return 0;let{baseUnit:r,isWeekly:o,isHourly:d,isNightly:c,isBlock:u}=e9(e),m=ts(e),x=(null==e?void 0:null===(t=e.rateDefinition)||void 0===t?void 0:t.partialWeeksHandling)||"roundUpToFullWeek",h=null!==(s=null!==(l=null!==(a=e.overrideUnitPrice)&&void 0!==a?a:e.rentPrice)&&void 0!==l?l:e.price)&&void 0!==s?s:0,p=[],v=Array.isArray(e.selectedAssets)?e.selectedAssets:[];if(p=v.length>0?v.map(e=>"number"==typeof e.overridePrice?e.overridePrice:h):Array.from({length:e.quantity||0},()=>h),d)return p.reduce((e,t)=>
1e+t*m,0);if(c)return p.reduce((e,t)=>e+t*m,0);if(u)return p.reduce((e,t)=>e+t*m,0);if(o&&"chargePerDay"===x){let t=tl(e),a=(null==e?void 0:null===(n=e.rateDefinition)||void 0===n?void 0:n.rentalDaysPerWeek)||(null==e?void 0:e.rentalDaysPerWeek)||7,l=Math.floor(t/a),s=t%a,r=Number(null==e?void 0:null===(i=e.rateDefinition)||void 0===i?void 0:i.subsequentDayRate),o=Number.isFinite(r)&&r>0&&s>0;return p.reduce((e,t)=>e+t*l+(o?s*r:s/a*t),0)}return p.reduce((e,t)=>e+t*m,0)},tp=(0,s.useCallback)(e=>{let t=Number(e.salePrice),a=!isNaN(t)&&t>0?null!=e.overrideUnitPrice?e.overrideUnitPrice:t:null!=e.overrideUnitPrice?e.overrideUnitPrice:e.price||0,l=Array.isArray(e.selectedAssets)?e.selectedAssets:[];return l.length>0?l.reduce((e,t)=>e+("number"==typeof t.overridePrice?t.overridePrice:a),0):(e.quantity||0)*a},[]),tv=()=>U.reduce((e,t)=>tx(t)?e+tp(t):e+th(t),0),tg=()=>U.reduce((e,t)=>{var a,l;let s=tx(t)?tp(t):th(t),n=0;return"advanced"===t.taxMode&&(null===(a=t.taxParts)||void 0===a?void 0:a.length)?t.taxParts.forEach(e=>{n+=e.rate/100*s}):n=(null!==(l=t.taxRate)&&void 0!==l?l:20)/100*s,e+n},0),tf=()=>{let e=tv(),t=e*ep/100,a=eF.totalAmount||0;switch(eU){case"percentage":return(e-t+a)*eG/100;case"fixedAmount":return eH;default:return 0}},tb=e=>{let t=U.find(t=>t.productId===e.productId),a=(null==t?void 0:t.selectedAssets)||[];if(0===a.length)return null;let s=Number(e.salePrice),n=!isNaN(s)&&s>0;return(0,l.jsxs)("div",{className:"mt-2 border-round-md p-2 surface-border",children:[(0,l.jsx)("div",{className:"mb-1 text-sm font-medium",children:e.isQuantityBased?"Selected units:":"Selected assets:"}),(0,l.jsx)("div",{className:"flex flex-column gap-2",children:a.map(t=>{var a,i,r,o;let c=n?null!==(a=e.overrideUnitPrice)&&void 0!==a?a:s:null!==(o=null!==(r=null!==(i=e.overrideUnitPrice)&&void 0!==i?i:e.rentPrice)&&void 0!==r?r:e.price)&&void 0!==o?o:0,u="number"==typeof t.overridePrice?t.overridePrice:c;return(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)(x.V,{value:(0,j.RZ)(t.label||t.assetNumber),severity:"info",className:"mr-2"}),(0,l.jsx)("span",{className:"text-xs text-500",children:"Unit price"}),(0,l.jsx)(d.R,{value:u,onValueChange:a=>tr(e.productId,t.assetId,a.value),mode:"currency",currency:P||"GBP",locale:"en-GB",className:"w-8rem"})]},t.assetId)})})]})};return(0,l.jsx)(r.E.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.3},className:"space-y-6",children:(0,l.jsxs)("div",{className:"p-3 surface-card border-round-xl",children:[eu.products&&(0,l.jsx)(h.v,{severity:"error",text:eu.products}),eu.assets&&(0,l.jsx)(h.v,{severity:"warn",text:eu.assets}),eu.maintenance&&(0,l.jsx)(h.v,{severity:"warn",text:eu.maintenance}),(0,l.jsx)(B.o,{className:"flex-col items-start ",left:()=>(0,l.jsx)(Q.U,{value:eo,options:ec,onChange:e=>ed(e.value),className:"p-button-sm text-500 prodcut-type",style:{color:"#087"}}),right:()=>(0,l.jsxs)("div",{className:"flex gap-2 justify-content-end align-items-end",children:[(0,l.jsx)("div",{className:"flex gap-3",children:(0,l.jsxs)(H.D,{iconPosition:"right",className:"w-20rem",children:[(0,l.jsx)(Z.S,{className:"pi pi-search",style:{opacity:$?0:1}}),(0,l.jsx)(u.o,{style:{fontSize:"12px",fontWeight:400},className:"w-full",placeholder:"Search product",value:$,onChange:e=>J(e.target.value)})]})}),(0,l.jsx)("div",{className:"",children:(0,l.jsx)(m.L,{value:ea,options:ei,onChange:e=>el(e.value),placeholder:"Select category",style:{width:"220px",height:"32px",fontSize:"12px"},showClear:!0})})]}),role:"toolbar","aria-label":"Product list toolbar"}),Y?(0,l.jsx)(M,{rows:7}):(0,l.jsxs)("div",{className:"overflow-hidden border-1 border-100",children:[(0,l.jsx)(X.Z,{tableName:"productBuilder",columns:{image:"Image",name:"Product name",category:"Category",minPeriod:"Min rented period",rate:"Rate",stock:"Stock",selection:"Selection"},data:z,renderColumnBody:(e,t)=>{var a,s,n,i,r,o,d,u,m,h,p,v,g,b,y,N,w,k,D;switch(e){case"image":return(0,l.jsx)("div",{className:"flex align-items-center",children:(0,l.jsx)("img",{onError:e=>e.currentTarget.src="/images/product/placeholder.webp",src:"".concat(f.Q).concat(null===(a=t.images)||void 0===a?void 0:a[0]),alt:t.name,className:"border-round-xl",style:{width:40,height:40,objectFit:"cover"}})});case"name":let S=t.productName||t.name||"Unknown Product";return(0,l.jsx)("div",{className:"flex align-items-center gap-2",children:(0,l.jsx)("label",{className:"text-sm font-medium",children:(0,j.RZ)(S)})});case"category":return(0,j.RZ)((null===(s=t.category)||void 0===s?void 0:s.name)||"Uncategorized");case"minPeriod":let I=(null==t?void 0:null===(n=t.rateDefinition)||void 0===n?void 0:n.minimumRentalPeriod)||0;return(0,l.jsxs)("label",{className:"px-3 py-1 border-round-2xl text-sm font-medium",style:{background:"#fde6c8"},children:[I," ",(null==t?void 0:null===(i=t.rateDefinition)||void 0===i?void 0:i.baseUnit)=="block"?null==t?void 0:null===(o=t.rateDefinition)||void 0===o?void 0:null===(r=o.blockConfig)||void 0===r?void 0:r.unit:null==t?void 0:null===(d=t.rateDefinition)||void 0===d?void 0:d.baseUnit]});case"rate":let{rate:T,baseUnit:A}=e9(t),z=t.salePrice;if(z)return(0,l.jsxs)("div",{className:"flex flex-column",children:[(0,l.jsx)("label",{className:"text-sm font-medium",children:(0,j.xG)(z,P)}),(null===(g=t.taxClass)||void 0===g?void 0:g.mode)==="advanced"&&(null===(y=t.taxClass)||void 0===y?void 0:null===(b=y.parts)||void 0===b?void 0:b.length)>0&&(0,l.jsx)("div",{className:"flex flex-wrap gap-1 mt-1 opacity-70",children:t.taxClass.parts.map((e,t)=>
1(0,l.jsxs)("span",{className:"px-1 text-[9px] border-1 surface-border border-round",title:e.name,children:[e.rate,"%"]},t))})]});let M="day";return"week"===A?M="week":"month"===A?M="month":"hour"===A?M="hour":"night"===A?M="night":"block"===A&&(M=(null==t?void 0:null===(m=t.rateDefinition)||void 0===m?void 0:null===(u=m.blockConfig)||void 0===u?void 0:u.unit)||"week"),(0,l.jsxs)("div",{className:"flex flex-column",children:[(0,l.jsxs)("label",{className:"text-sm font-medium",children:[(0,j.xG)(T,P)," ",(0,l.jsxs)("span",{className:"text-600",children:["/",M]})]}),(null===(h=t.taxClass)||void 0===h?void 0:h.mode)==="advanced"&&(null===(v=t.taxClass)||void 0===v?void 0:null===(p=v.parts)||void 0===p?void 0:p.length)>0&&(0,l.jsx)("div",{className:"flex flex-wrap gap-1 mt-1 opacity-70",children:t.taxClass.parts.map((e,t)=>(0,l.jsxs)("span",{className:"px-1 text-[9px] border-1 surface-border border-round",title:e.name,children:[e.rate,"%"]},t))})]});case"stock":let F=t.quantity||0;return(0,l.jsxs)("label",{className:"px-3 py-1 text-sm font-medium border-round-2xl",style:{background:F<=3?"#ffd1d4":F<12?"#e6f0ff":"#d6f7ea",color:F<=3?"#b4232c":F<12?"#2563eb":"#059669"},children:[F," available"]});case"selection":let E=U.find(e=>e.productId===t._id),_=(null==E?void 0:E.selectedAssets)||[],W=(null==E?void 0:E.quantity)||0;if(t.isQuantityBased){let{rate:e,isWeekly:a}=e9(t),s=E?ts(E):ts({...t,minimumRentalPeriod:null==t?void 0:null===(N=t.rateDefinition)||void 0===N?void 0:N.minimumRentalPeriod,rentalDaysPerWeek:null==t?void 0:null===(w=t.rateDefinition)||void 0===w?void 0:w.rentalDaysPerWeek}),n=W>0?W*(null!==(D=null!==(k=null==E?void 0:E.overrideUnitPrice)&&void 0!==k?k:null==E?void 0:E.salePrice)&&void 0!==D?D:e)*((null==E?void 0:E.salePrice)?1:s):0;return(0,l.jsxs)("div",{className:"flex align-items-center gap-3 white-space-nowrap",children:[(0,l.jsx)(c.z,{size:"small",label:W>0?"".concat(W," reserved"):"Reserve units",className:"p-button-sm ".concat(W>0?"p-button-success":"p-button-outlined"),onClick:()=>ti(t._id)}),W>0&&(0,l.jsxs)("span",{className:"text-sm font-semibold text-700",children:["= ",(0,j.xG)(n,P)," ",C.openEnded&&(0,l.jsx)("span",{className:"text-orange-500 ml-1",children:"(Min Period)"})]})]})}let B=null;if(E){if(tx(E)){let e=tp(E);B=(0,j.xG)(e,P)}else{let e=th(E),t=E.taxRate/100*e;B=(0,j.xG)(e+t,P)}}return(0,l.jsxs)("div",{className:"flex align-items-center gap-3 white-space-nowrap",children:[(0,l.jsx)(c.z,{size:"small",label:_.length>0?"".concat(_.length," assets"):"Select assets",className:"p-button-sm p-button-outlined",style:{borderColor:"#fd7e14",color:"#fd7e14",background:"transparent"},onClick:()=>ti(t._id)}),B&&(0,l.jsxs)("span",{className:"text-sm font-semibold text-700",children:["= ",B]})]});case"maintenance":let L=U.find(e=>e.productId===t._id),O=(null==L?void 0:L.quantity)||0,q=eD[t._id]||[];if(!(t.isQuantityBased?O>0:q.length>0))return(0,l.jsx)("span",{className:"text-500",children:"---"});if(!t.maintenanceRequired)return(0,l.jsx)(x.V,{value:"Not required",severity:"secondary",className:"opacity-60"});return(0,l.jsx)(R,{productId:t._id,productName:t.name,onConfigChange:e=>handleMaintenanceConfigChange(t._id,e),compact:!0});default:return t[e]||""}},loading:Y}),(0,l.jsx)("div",{style:{marginTop:"-13px"},className:"",children:(0,l.jsx)(L.Z,{page:e1+1,rows:eJ,totalRecords:_,onPageChange:e=>{e2(e.page),e0(e.rows)},rowsPerPageOptions:[10,25,50]})})]}),U.length>0&&(0,l.jsxs)("div",{className:"mt-6 surface-card border-1 border-200 px-2 py-3 border-round-xl",children:[(0,l.jsxs)("div",{className:"flex justify-content-between align-items-center w-full",children:[(0,l.jsx)("div",{className:"col-12 md:col-6",children:(0,l.jsxs)("h4",{className:"mb-4 text-lg font-semibold",children:["Selected products (",U.length,")",(0,l.jsx)(v.C,{value:U.reduce((e,t)=>{var a;return e+(t.isQuantityBased?t.quantity:(null===(a=t.selectedAssets)||void 0===a?void 0:a.length)||0)},0)+(U.some(e=>e.isQuantityBased)?" units/assets":" assets"),severity:"info",className:"ml-2"})]})}),(0,l.jsx)("div",{className:"col-12 md:col-6",children:(0,l.jsx)(u.o,{value:C.textItem||"",onChange:e=>k({textItem:e.target.value}),className:"w-full",placeholder:"Enter text"})})]}),(0,l.jsx)(q.i,{}),(0,l.jsx)(p.J,{multiple:!0,children:U.map((e,t)=>{var a,s,n,i,r,o,d,u,m,x,h,v,g,b,y,N;let w=tx(e),{baseUnit:k,isWeekly:D,isHourly:S,isNightly:I,isBlock:T}=e9(e),A=ts(e),R=null==e?void 0:null===(a=e.rateDefinition)||void 0===a?void 0:a.partialWeeksHandling,z=0,M=A;if(w)tp(e),z=0;else if(D&&"chargePerDay"===R){let t=tl(e),a=e.rentalDaysPerWeek||(null==e?void 0:null===(r=e.rateDefinition)||void 0===r?void 0:r.rentalDaysPerWeek)||7,l=null!==(u=null!==(d=null!==(o=e.overrideUnitPrice)&&void 0!==o?o:e.rentPrice)&&void 0!==d?d:e.price)&&void 0!==u?u:0,s=e.selectedAssets||[];
1z=(!e.isQuantityBased&&s.length>0?s.map(e=>"number"==typeof e.overridePrice?e.overridePrice:l):Array.from({length:e.quantity||0},()=>l)).reduce((e,l)=>e+l/a*t,0),M="".concat(t," days")}else w||(z=th(e));let F=0,E=[];w||("advanced"===e.taxMode&&(null===(m=e.taxParts)||void 0===m?void 0:m.length)?e.taxParts.forEach(e=>{let t=e.rate/100*z;F+=t,E.push({name:e.name||e.type||"Tax",amount:t,rate:e.rate})}):(F=(null!==(x=e.taxRate)&&void 0!==x?x:20)/100*z,E.push({name:e.taxClassName||"VAT",amount:F,rate:null!==(h=e.taxRate)&&void 0!==h?h:20})));let _=w?0:z+F,W=w?tp(e):0,B=w?null!==(g=null!==(v=e.overrideUnitPrice)&&void 0!==v?v:e.price)&&void 0!==g?g:0:null!==(N=null!==(y=null!==(b=e.overrideUnitPrice)&&void 0!==b?b:e.rentPrice)&&void 0!==y?y:e.price)&&void 0!==N?N:0;return(0,l.jsxs)(p.U,{header:(0,l.jsxs)("div",{className:"flex w-full align-items-center justify-content-between gap-3",children:[(0,l.jsxs)("div",{className:"flex align-items-center gap-3 min-w-0",children:[(0,l.jsx)("img",{src:"".concat(f.Q).concat(e.image),alt:e.name,onError:e=>e.currentTarget.src="/images/product/placeholder.webp",className:"border-1 surface-border border-round-md object-cover",style:{width:56,height:56}}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)("p",{className:"m-0 text-900 font-medium truncate",children:(0,j.RZ)(e.name)}),!0===e.damageWaiverEnabled?(0,l.jsx)("span",{className:"px-2 py-1 text-xs border-round-lg bg-green-50 text-green-700",children:"DW"}):(0,l.jsx)("span",{className:"px-2 py-1 text-xs border-round-lg bg-red-50 text-red-600",children:"No DW"}),e.maintenanceRequired&&(0,l.jsx)("span",{className:"px-2 py-1 text-xs border-round-lg bg-blue-50 text-blue-700",children:"Maint."})]}),w?(0,l.jsxs)("div",{className:"text-700 text-sm mt-1",children:[e.quantity," ",e.isQuantityBased?"units":"assets"," ","\xd7"," ",(0,j.xG)(B,P)]}):(0,l.jsxs)("div",{className:"text-700 text-sm mt-1",children:[(0,l.jsxs)("span",{className:"mr-2",children:[e.quantity," ",e.isQuantityBased?"units":"assets"]}),(0,l.jsx)("span",{className:"opacity-60",children:"\xd7"}),(0,l.jsxs)("span",{className:"mx-2",children:[(0,j.xG)(B,P),"/","week"===k?"week":"month"===k?"month":"hour"===k?"hour":"night"===k?"night":"block"===k?null==e?void 0:null===(n=e.rateDefinition)||void 0===n?void 0:null===(s=n.blockConfig)||void 0===s?void 0:s.unit:"day"]}),(0,l.jsx)("span",{className:"opacity-60",children:"\xd7"}),(0,l.jsxs)("span",{className:"mx-2",children:[M," ",C.openEnded&&(0,l.jsx)("span",{className:"text-orange-500 font-bold ml-1",children:"(Min Period)"})]}),(0,l.jsx)("span",{className:"opacity-60",children:"+"}),(0,l.jsx)("span",{className:"ml-2",children:"advanced"===e.taxMode?(0,l.jsxs)("div",{className:"flex flex-column gap-1",children:[(0,l.jsxs)("span",{className:"font-bold",children:["Bundle (",e.taxRate,"%)"]}),(0,l.jsx)("div",{className:"flex flex-wrap gap-1",children:E.map((e,t)=>(0,l.jsxs)("span",{className:"text-[9px] bg-white-alpha-20 px-1 border-round border-1 border-white-alpha-10",children:[e.name,": ",e.rate,"%"]},t))})]}):"".concat(e.taxRate,"% tax")})]}),!w&&(null==e?void 0:null===(i=e.rateDefinition)||void 0===i?void 0:i.minimumRentalPeriod)>0&&(0,l.jsxs)("div",{className:"mt-1 text-xs text-orange-600",children:["Minimum rental period"," ",null==e?void 0:e.rateDefinition.minimumRentalPeriod," ",(null==e?void 0:e.rateDefinition.minimumRentalUnit)==="week"?"weeks":(null==e?void 0:e.rateDefinition.minimumRentalUnit)==="month"?"months":(null==e?void 0:e.rateDefinition.minimumRentalUnit)==="hour"?"hours":(null==e?void 0:e.rateDefinition.minimumRentalUnit)==="night"?"nights":"days"]})]})]}),(0,l.jsxs)("div",{className:"text-right",children:[(0,l.jsx)("div",{className:"text-900 font-semibold text-lg",children:w?(0,j.xG)(W,P):(0,j.xG)(_,P)}),(0,l.jsx)("div",{className:"text-700 text-xs mt-1",children:w?"Sale total":"Rental total (incl. tax)"}),!w&&(0,l.jsxs)("div",{className:"text-700 text-xs mt-1",children:["Excl. tax ",(0,j.xG)(z,P)]})]})]}),children:[tb(e),(0,l.jsxs)("div",{className:"mt-3 flex align-items-center gap-3 flex-wrap",children:[(0,l.jsx)("span",{className:"text-sm text-700 font-medium",children:"Line discount"}),(0,l.jsx)(en.Z,{value:e.discount||null,customerTierPercent:tc,currency:P||"GBP",onCh
1ange:t=>td(e.productId,t)})]}),!w&&(0,l.jsx)("div",{className:"mt-3 p-2 border-1 surface-border border-round",children:e3[e.productId]?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex align-items-center justify-content-between mb-2",children:[(0,l.jsx)("div",{className:"text-xs text-600 font-medium",children:"Custom Dates (Optional)"}),(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(e.lineChargingStartDate||e.lineExpectedReturnDate)&&(0,l.jsx)("button",{type:"button",className:"p-button-link text-xs",style:{border:"none",background:"none",color:"#DC2626",cursor:"pointer"},onClick:()=>{to(e.productId,"lineChargingStartDate",null),to(e.productId,"lineExpectedReturnDate",null),tu(e.productId,!1)},children:"Clear"}),(0,l.jsx)("button",{type:"button",style:{border:"none",background:"none",color:"#9CA3AF",cursor:"pointer"},onClick:()=>tu(e.productId,!1),children:(0,l.jsx)("i",{className:"pi pi-chevron-up",style:{fontSize:10}})})]})]}),(0,l.jsxs)("div",{className:"grid",children:[(0,l.jsxs)("div",{className:"col-12 md:col-6",children:[(0,l.jsx)("label",{className:"text-xs text-600 block mb-1",children:"Rent From"}),(0,l.jsx)("input",{type:"date",className:"p-inputtext p-component w-full",value:e.lineChargingStartDate||"",onChange:t=>to(e.productId,"lineChargingStartDate",t.target.value)})]}),(0,l.jsxs)("div",{className:"col-12 md:col-6",children:[(0,l.jsx)("label",{className:"text-xs text-600 block mb-1",children:"Rent To"}),(0,l.jsx)("input",{type:"date",className:"p-inputtext p-component w-full",value:e.lineExpectedReturnDate||"",onChange:t=>to(e.productId,"lineExpectedReturnDate",t.target.value)})]})]})]}):(0,l.jsxs)("div",{className:"flex align-items-center gap-2 cursor-pointer",style:{fontSize:11,color:"#6B7280"},onClick:()=>tu(e.productId,!0),children:[(0,l.jsx)("i",{className:"pi pi-calendar-plus",style:{fontSize:11}}),(0,l.jsx)("span",{children:e.lineChargingStartDate||e.lineExpectedReturnDate?"Custom dates set":"Override dates"})]})}),(0,l.jsxs)("div",{className:"mt-3 flex flex-column md:flex-row gap-2 md:gap-3 md:justify-content-end",children:[(0,l.jsx)(c.z,{label:e.isQuantityBased?"Modify quantity":"Modify asset selection",icon:"pi pi-pencil",className:"p-button-sm p-button-outlined",onClick:()=>ti(e.productId)}),(0,l.jsx)(c.z,{label:"Remove all",icon:"pi pi-trash",className:"p-button-sm p-button-danger p-button-outlined",onClick:()=>e.isQuantityBased?tm(e.productId,0):tm(e.productId,[])})]})]},"selected-".concat(e.productId,"-").concat(t))})})]}),U.length>0&&!eB&&e_&&(0,l.jsxs)("div",{className:"mt-6",children:[(0,l.jsx)(G,{selectedLevel:ez,onLevelChange:e=>{eM(e),k({damageWaiverLevel:e})},eligibleSubtotal:U.reduce((e,t)=>{var a;let l=t.isQuantityBased?t.quantity>0:((null===(a=eD[t.productId])||void 0===a?void 0:a.length)||0)>0,s=!0===t.damageWaiverEnabled;return l&&s?tx(t)?e+tp(t):e+th(t):e},0),onCalculationChange:e=>{eE(e),k({damageWaiverCalculations:e,damageWaiverAmount:e.totalAmount||0})},token:I,vendorId:null==T?void 0:T._id,selectedProducts:U,rentalDuration:e5,chargeableDaysForProduct:tl,externalCalculations:eF,vendorSettings:eO}),A&&(0,l.jsx)(l.Fragment,{children:eg&&(0,l.jsxs)("div",{className:"p-3 border-round-lg mb-4 mt-4 border-500 border-1 surface-card",children:[(0,l.jsxs)("div",{className:"flex align-items-center justify-content-between",children:[(0,l.jsxs)("div",{className:"flex align-items-center",children:[(0,l.jsx)("img",{className:"mr-2",src:"/layout/images/blueshow.svg",alt:""}),(0,l.jsx)("span",{className:"text-xs",style:{fontWeight:500,color:"#4B85FA"},children:"Quick tips for getting started"})]}),(0,l.jsx)("button",{type:"button",onClick:()=>ef(!1),className:"p-1 border-none cursor-pointer",style:{background:"transparent",color:"#4B85FA",borderRadius:12},"aria-label":"Close tips",children:(0,l.jsx)("img",{className:"mr-2",src:"/layout/images/x-circle.svg",alt:""})})]}),(0,l.jsx)("div",{className:"grid mt-2 text-xs font-medium",children:(0,l.jsxs)("ul",{children:[(0,l.jsx)("li",{children:"Damage waiver provides protection against accidental damage"}
1),(0,l.jsx)("li",{children:"Coverage applies to the rental period only"}),(0,l.jsx)("li",{children:"Premium is calculated as a percentage of equipment value"}),(0,l.jsx)("li",{children:"Tax may apply to the waiver premium"})]})})]})})]}),U.length>0&&(0,l.jsxs)(o.Z,{className:"mt-5 border-1 surface-100 border-400 overflow-hidden",children:[(0,l.jsx)("div",{className:"border-bottom-1 surface-border p-3",children:(0,l.jsx)("div",{className:"flex align-items-center justify-content-between",children:(0,l.jsx)("label",{className:"m-0 text-900 text-lg font-semibold",children:"Security deposit"})})}),(0,l.jsxs)("div",{className:"p-3",children:[(0,l.jsxs)("div",{className:"mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900 text-sm font-medium",children:"Deposit type"}),(0,l.jsx)(m.L,{value:eU,options:[{label:"No deposit",value:"noDeposit"},{label:"Percentage of order total",value:"percentage"},{label:"Fixed amount",value:"fixedAmount"}],onChange:e=>{eV(e.value),k({depositType:e.value,depositAmount:tf()})},placeholder:"Select",className:"w-full"})]}),"percentage"===eU&&(0,l.jsxs)("div",{className:"mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900 text-sm font-medium",children:"Deposit percentage (%)"}),(0,l.jsx)(d.R,{value:eG,onValueChange:e=>{let t=e.value||0;eZ(t),k({depositPercentage:t,depositAmount:tf()})},suffix:"%",min:0,max:100,showButtons:!0,buttonLayout:"horizontal",className:"w-full"})]}),"fixedAmount"===eU&&(0,l.jsxs)("div",{className:"mb-3",children:[(0,l.jsx)("label",{className:"block mb-2 text-900 text-sm font-medium",children:"Fixed deposit amount"}),(0,l.jsx)(d.R,{value:eH,onValueChange:e=>{let t=e.value||0;eQ(t),k({depositFixedAmount:t,depositAmount:tf()})},min:0,showButtons:!0,buttonLayout:"horizontal",className:"w-full"})]}),"noDeposit"!==eU&&tf()>0&&(0,l.jsxs)("div",{className:"surface-card border-round-md py-2 overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex align-items-center justify-content-between p-3",children:[(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)("img",{src:"/layout/images/orangeshow.svg",alt:"icon"}),(0,l.jsx)("span",{className:"text-primary font-medium text-xs",children:"Calculated deposit"})]}),(0,l.jsx)("span",{className:"font-semibold",style:{color:"#FD7E14",fontSize:"26px",lineHeight:1},children:(0,j.xG)(tf(),P)})]}),(0,l.jsx)("label",{className:"px-3 pb-3 text-xs",children:"Security deposit will be shown on a separate receipt"})]})]})]}),U.length>0&&(0,l.jsxs)(o.Z,{className:"mt-5 border-1 border-200 overflow-hidden",children:[(0,l.jsx)("div",{className:"border-bottom-1 surface-border p-3",children:(0,l.jsx)("div",{className:"flex align-items-center justify-content-between",children:(0,l.jsx)("label",{className:"m-0 text-900 text-lg font-semibold",children:"Delivery & Collection Charges"})})}),(0,l.jsxs)("div",{className:"p-3 grid",children:[(0,l.jsxs)("div",{className:"mb-3 col-12 md:col-6",children:[(0,l.jsx)("label",{className:"block mb-2 text-900 text-sm font-medium",children:"Delivery Charge"}),(0,l.jsx)(d.R,{value:eX,onValueChange:e=>{let t=e.value||0;eY(t),k({deliveryCharge:t})},min:0,showButtons:!0,buttonLayout:"horizontal",className:"w-full"})]}),(0,l.jsxs)("div",{className:"mb-3 col-12 md:col-6",children:[(0,l.jsx)("label",{className:"block mb-2 text-900 text-sm font-medium",children:"Collection Charge"}),(0,l.jsx)(d.R,{value:eK,onValueChange:e=>{let t=e.value||0;e$(t),k({collectionCharge:t})},min:0,showButtons:!0,buttonLayout:"horizontal",className:"w-full"})]}),(eX>0||eK>0)&&(0,l.jsx)("div",{className:"surface-card border-round-md py-2 overflow-hidden w-full",children:(0,l.jsxs)("div",{className:"flex align-items-center justify-content-between p-3 w-full",children:[(0,l.jsxs)("div",{className:"flex align-items-center gap-2",children:[(0,l.jsx)("img",{src:"/layout/images/orangeshow.svg",alt:"icon"}),(0,l.jsx)("span",{className:"text-primary font-medium text-xs",children:"Total Charges"})]}),(0,l.jsx)("span",{className:"font-semibold",style:{color:"#FD7E14",fontSize:"26px",lineHeight:1},children:(0,j.xG)(eX+eK,P)})]})})]})]}),(0,l.jsx)(q.i,{}),(0,l.jsx)(es,{}),(0,l.jsx)(q.i,{}),U.length>0&&(0,l.jsxs)(o.Z,{className:"border-1 border-blue-300 surface-card",children:[(0,l.jsxs)("div",{className:"flex align-items-center gap-2 mb-3 text-blue-600",children:[(0,l.jsx)("img",{src:"/layout/images/blueshow.svg",alt:"icon"}),(0,l.jsxs)("label",{className:"font-medium text-xs",children:[a("order")," summary"]})]}),(0,l.jsxs)("div",{className:"flex flex-column md:flex-row md:align-items-start md:justify-content-between gap-4",children:[(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("h4",{className:"m-0 mb-2 font-semibold text-sm",children:"Discount"}),(0,l.jsx)("div",{className:"p-2 mb-4",children:(0,l.jsx)(d.R,{value:ep,onValueChange:e=>ev(e.value||0),suffix:"%",min:0,max:100,showButtons:!0,inputClassName:"w-full text-xl",className:"w-full"})}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("label",{className:"m-0 mb-3 font-semibold text-sm",children:[a("product")," details"]}
1),(0,l.jsxs)("div",{className:"grid text-sm text-700",children:[(0,l.jsxs)("div",{className:"col-6 md:col-3 mb-3",children:[(0,l.jsxs)("div",{className:"mb-1",children:["Number of ",N("product").toLowerCase()]}),(0,l.jsx)("div",{className:"text-900",children:U.length})]}),(0,l.jsxs)("div",{className:"col-6 md:col-3 mb-3",children:[(0,l.jsx)("div",{className:"mb-1",children:"Units/Assets"}),(0,l.jsx)("div",{className:"text-900",children:U.reduce((e,t)=>{var a;return e+(t.isQuantityBased?t.quantity:(null===(a=t.selectedAssets)||void 0===a?void 0:a.length)||0)},0)})]}),(0,l.jsxs)("div",{className:"col-6 md:col-3 mb-3",children:[(0,l.jsxs)("div",{className:"mb-1",children:[a("rental")," period"]}),(0,l.jsx)("div",{className:"text-900",children:e5})]}),(0,l.jsxs)("div",{className:"col-6 md:col-3 mb-3",children:[(0,l.jsx)("div",{className:"mb-1",children:"Discount"}),(0,l.jsxs)("div",{className:"text-900",children:[ep||0,"%"]})]})]})]})]}),(0,l.jsx)("div",{className:"hidden md:block border-left-1 surface-border mx-2"}),(0,l.jsxs)("div",{className:"md:w-20rem w-full",children:[(0,l.jsx)("h4",{className:"m-0 mb-3 text-900",children:"Pricing"}),(0,l.jsxs)("div",{className:"flex align-items-center justify-content-between mb-2 text-700",children:[(0,l.jsx)("span",{children:"Sub total"}),(0,l.jsx)("span",{className:"text-900",children:(0,j.xG)(tv(),P)})]}),(0,l.jsxs)("div",{className:"flex align-items-center justify-content-between mb-2 text-700 pt-2",style:{borderTop:"1px solid var(--surface-200)"},children:[(0,l.jsx)("span",{className:"font-bold",children:"Taxes"}),(0,l.jsx)("span",{className:"text-900 font-bold",children:(0,j.xG)(tg(),P)})]}),Object.entries((()=>{let e={};return U.forEach(t=>{var a,l;let s=tx(t)?tp(t):th(t);if("advanced"===t.taxMode&&(null===(a=t.taxParts)||void 0===a?void 0:a.length))t.taxParts.forEach(t=>{let a=t.name||t.type||"Tax",l=t.rate/100*s;e[a]=(e[a]||0)+l});else{let a=t.taxClassName||"VAT",n=(null!==(l=t.taxRate)&&void 0!==l?l:20)/100*s;e[a]=(e[a]||0)+n}}),e})()).map(e=>{let[t,a]=e;return(0,l.jsxs)("div",{className:"flex align-items-center justify-content-between mb-1 text-600 px-2",style:{fontSize:"12px"},children:[(0,l.jsx)("span",{children:t}),(0,l.jsx)("span",{children:(0,j.xG)(a,P)})]},t)}),(0,l.jsxs)("div",{className:"flex align-items-center justify-content-between mb-2 text-700",children:[(0,l.jsx)("span",{children:"Discount"}),(0,l.jsxs)("span",{className:"text-900",children:[ep||0,"%"]})]}),eF.totalAmount>0&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"mt-2 pt-2 flex align-items-center justify-content-between",children:[(0,l.jsx)("label",{className:"text-sm",children:"Damage Waiver"}),(0,l.jsx)("label",{className:"text-900",children:(0,j.xG)(eF.totalAmount,P)})]}),eF.taxAmount>0&&(0,l.jsxs)("label",{className:"text-xs",children:["(includes tax: ",(0,j.xG)(eF.taxAmount,P),")"]})]}),tf()>0&&(0,l.jsxs)("div",{className:"flex align-items-center justify-content-between mb-2 text-700",children:[(0,l.jsx)("span",{children:"Deposit"}),(0,l.jsx)("span",{className:"text-900",children:(0,j.xG)(tf(),P)})]}),(0,l.jsxs)("div",{className:"border-top-1 surface-border mt-3 pt-3 flex align-items-center justify-content-between",children:[(0,l.jsx)("span",{className:"text-900 font-semibold",children:"Total"}),(0,l.jsx)("span",{className:"text-900 font-bold",children:(0,j.xG)((()=>{let e=tv(),t=tg(),a=(e+t)*ep/100;return e+t-a+(eF.totalAmount||0)+tf()+(eX+eK)})(),P)})]})]})]})]}),ew&&(0,l.jsx)(O,{product:ew,selectedAssets:eD[ew._id]||[],onAssetsChange:e=>{tm(ew._id,e),eN(!1),ek(null)},visible:ej,onHide:()=>{eN(!1),ek(null)},rentalDuration:tl(ew),startDate:C.chargingStartDate,endDate:C.expectedReturnDate,openEnded:C.openEnded,chargeReturnDay:eb}),(0,l.jsx)(F.V,{header:()=>(0,l.jsx)("label",{className:"font-medium text-lg",children:"Select Units For - ".concat((null==eT?void 0:eT.productName)||(null==eT?void 0:eT.name)||"")}),visible:eC,onHide:()=>{eI(!1),eP(null),eR(0)},className:"p-fluid",style:{width:"450px"},footer:(0,l.jsxs)("div",{className:"flex gap-2 align-items-center justify-content-between w-full",children:[(0,l.jsx)(c.z,{label:"Cancel",className:"p-button-text p-button-secondary border-1 border-300 surface-0 text-900 px-5",onClick:()=>{eI(!1),eP(null),eR(0)}}),(0,l.jsx)(c.z,{label:"Reserve",className:"p-button-warning px-8",onClick:()=>
1{if(!eT)return;let e=Math.max(0,Math.min(eA||0,(null==eT?void 0:eT.quantity)||0));tm(eT._id,e),eI(!1),eP(null),eR(0)},disabled:eA<0||eA>((null==eT?void 0:eT.quantity)||0)})]}),children:(0,l.jsxs)("div",{className:"space-y-4 px-2",children:[(0,l.jsx)("div",{className:"flex gap-3 mt-2",children:(0,l.jsxs)("div",{className:"flex-1",children:[(0,l.jsx)("label",{className:"block text-sm font-medium mb-2",children:"Quantity to Reserve *"}),(0,l.jsx)(d.R,{value:eA,onValueChange:e=>eR(e.value||0),min:0,max:(null==eT?void 0:eT.quantity)||0,placeholder:"Enter quantity",className:"w-full",showButtons:!0}),eA>((null==eT?void 0:eT.quantity)||0)&&(0,l.jsx)("small",{className:"text-red-500",children:"Cannot reserve more than available quantity"})]})}),eA>0&&(0,l.jsxs)("div",{className:"surface-card border-1 border-blue-300 p-3 border-round",children:[(0,l.jsx)("div",{className:"text-sm font-medium text-900",children:"Reservation Summary:"}),(0,l.jsx)("div",{className:"text-900 ",children:(()=>{let e=eT||{},{isWeekly:t}=e9(e),a=ts(e),s=e.salePrice||e.rentPrice||e.price||0,n=eA*s*(e.salePrice?1:a);return(0,l.jsxs)(l.Fragment,{children:[eA," units \xd7"," ",(0,j.xG)(s,P),e.salePrice?"":" \xd7 ".concat(a," ").concat(t?"weeks":"days")," ","="," ",(0,j.xG)(n,P)]})})()})]})]})})]})})}},62186:function(){},16712:function(){}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.