1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[23015],{401177:function(e,l,s){s.d(l,{Z:function(){return t}});var t=(0,s(507783).Z)("plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]])},374075:function(e,l,s){s.d(l,{Z:function(){return t}});var t=(0,s(507783).Z)("trash","IconTrash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]])},923015:function(e,l,s){s.r(l),s.d(l,{default:function(){return z}});var t=s(785893),i=s(667294),o=s(180253),a=s(281374),n=s(84888),r=s(598793),d=s(991449),c=s(491578),u=s(878108),h=s(941281),x=s(280102),m=s(6277),f=s(474922),p=s(888198),v=s(401177),j=s(374075),g=s(97283),y=s(920691);function z(e){let{opened:l,onClose:s,taskId:z,equipmentGroups:C}=e,b=(0,y.f0)(),[I,k]=(0,i.useState)(()=>{let e={};return C.forEach(l=>{l.materialVariantId&&(e[l.materialVariantId]=[{toolId:"",hours:0}])}),e}),E=(e,l,s,t)=>{k(i=>({...i,[e]:i[e].map((e,i)=>i===l?{...e,[s]:t}:e)}))},Z=e=>{k(l=>({...l,[e]:[...l[e]||[],{toolId:"",hours:0}]}))},M=(e,l)=>{k(s=>({...s,[e]:s[e].filter((e,s)=>s!==l)}))},w=(0,i.useMemo)(()=>{let e={};
1return C.forEach(l=>{l.tools.forEach(l=>{l.id&&(e[l.id]=l)})}),e},[C]),V=(0,i.useMemo)(()=>{let e=0;return Object.values(I).forEach(l=>{l.forEach(l=>{if(l.toolId&&l.hours>0){var s;let t=w[l.toolId];e+=l.hours*(null!==(s=null==t?void 0:t.hourlyCost)&&void 0!==s?s:0)}})}),e},[I,w]),q=async()=>{let e=Object.values(I).flat().filter(e=>e.toolId&&e.hours>0);if(0===e.length){s();return}try{await b.mutateAsync({taskId:z,dto:{usages:e}}),(0,f.c0)({title:"Success",message:"Equipment usage recorded",color:"teal",icon:(0,t.jsx)(p.Z,{size:18})}),s()}catch(e){(0,f.c0)({title:"Error",message:"Failed to record equipment usage",color:"red",icon:(0,t.jsx)(g.Z,{size:18})})}};return(0,t.jsx)(o.u,{opened:l,onClose:s,title:"Record Equipment Usage",centered:!0,size:"lg",children:(0,t.jsxs)(a.K,{gap:"md",children:[C.map(e=>{let l=e.materialVariantId;if(!l)return null;let s=I[l]||[],i=e.tools.filter(e=>e.id).map(e=>({label:"".concat(e.name||"Unnamed").concat(e.assetTagId?" (".concat(e.assetTagId,")"):""),value:e.id}));return(0,t.jsxs)(n.x,{children:[(0,t.jsxs)(r.x,{size:"sm",fw:600,mb:4,children:[e.description||e.materialVariantCode||"Equipment",e.materialVariantCode?" (".concat(e.materialVariantCode,")"):""]}),s.map((e,o)=>{var a;let x=e.toolId?w[e.toolId]:null,m=e.hours*(null!==(a=null==x?void 0:x.hourlyCost)&&void 0!==a?a:0);return(0,t.jsxs)(d.Z,{gap:"xs",mb:6,align:"flex-end",children:[(0,t.jsx)(c.Ph,{label:0===o?"Tool":void 0,placeholder:"Select tool...",data:i,value:e.toolId||null,onChange:e=>E(l,o,"toolId",e||""),searchable:!0,style:{flex:2},size:"sm"}),(0,t.jsx)(u.Y,{label:0===o?"Hours":void 0,placeholder:"0",value:e.hours||void 0,onChange:e=>E(l,o,"hours","number"==typeof e?e:0),min:0,precision:2,style:{flex:1},size:"sm"}),(0,t.jsxs)(n.x,{style:{flex:1,minWidth:80},children:[0===o&&(0,t.jsx)(r.x,{size:"xs",c:"dimmed",mb:4,children:"Hourly Rate"}),(0,t.jsx)(r.x,{size:"sm",children:(null==x?void 0:x.hourlyCost)!=null?"$".concat(x.hourlyCost.toFixed(2)):"-"})]}),(0,t.jsxs)(n.x,{style:{flex:1,minWidth:80},children:[0===o&&(0,t.jsx)(r.x,{size:"xs",c:"dimmed",mb:4,children:"Cost"}),(0,t.jsxs)(r.x,{size:"sm",children:["$",m.toFixed(2)]})]}),(0,t.jsx)(h.A,{color:"red",variant:"subtle",size:"sm",onClick:()=>M(l,o),disabled:s.length<=1,children:(0,t.jsx)(j.Z,{size:14})})]},o)}),(0,t.jsx)(x.z,{variant:"subtle",size:"xs",leftIcon:(0,t.jsx)(v.Z,{size:14}),onClick:()=>Z(l),mt:4,children:"Add Another"}),(0,t.jsx)(m.i,{mt:"sm"})]},l)}),(0,t.jsx)(d.Z,{justify:"space-between",children:(0,t.jsxs)(r.x,{size:"sm",fw:600,children:["Total Equipment Cost: $",V.toFixed(2)]})}),(0,t.jsxs)(d.Z,{justify:"flex-end",gap:"xs",children:[(0,t.jsx)(x.z,{variant:"default",size:"sm",onClick:s,children:"Skip"}),(0,t.jsx)(x.z,{size:"sm",loading:b.isPending,onClick:q,children:"Record Usage"})]})]})})}}}]);
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.