| 1 |
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{T as t,a as n,k as r,w as i}from"./client-DSw2TdH4.js";import{d as a,l as ee,n as o}from"./chunk-62JRHF6Z-DiDTZQg1.js";import{n as te}from"./QueryClientProvider-B5vEWYBq.js";import{t as s}from"./useQuery-DfiorXB9.js";import{t as c}from"./useMutation-DLyYCmQ0.js";import{t as ne}from"./arrow-left-6oh0roqT.js";import{t as re}from"./RichTextEditor-COtD6BDe.js";import{t as ie}from"./calendar-CXLctOwE.js";import{n as ae}from"./info-3cB5_JmI.js";import{t as oe}from"./chevron-right-BWg4-zJH.js";import{n as se,r as l}from"./ToastContext-C3zxW_t3.js";import{t as ce}from"./PrintModal-DJVIzPGw.js";import{t as le}from"./clock-CjtzezMg.js";import{t as ue}from"./copy-U0zQj-x7.js";import{t as de}from"./download-nyR-1mBX.js";import{t as fe}from"./external-link-BuJwWh2y.js";import{t as pe}from"./file-box-CoNayqNA.js";import{t as me}from"./file-text-Lz0jvfRs.js";import{t as he}from"./folder-open-DwF8LQ8c.js";import{t as ge}from"./history-By7-L8e_.js";import{t as _e}from"./layers-DxbB-A8k.js";import{t as u}from"./loader-circle-Ck-s1kyS.js";import{t as d}from"./package-BxMzbAJg.js";import{t as ve}from"./pen-line-BfvyDGk3.js";import{t as ye}from"./pencil-BWVOR29z.js";import{t as be}from"./plus-BOBCZqrh.js";import{t as f}from"./printer-CkXBzcv8.js";import{t as xe}from"./save-DBrAXLwf.js";import{t as Se}from"./shopping-cart-BThep2sF.js";import{t as Ce}from"./tag-CRG5RPh_.js";import{t as we}from"./trash-2-CUF18zKt.js";import{t as p}from"./triangle-alert-Bb8T_5WO.js";import{t as Te}from"./x-DIT5l0_1.js";import{n as Ee}from"./AuthContext-DM3YxV_q.js";import{n as m,t as h}from"./Card-BT_YWvIC.js";import{t as g}from"./Button-C_-d0X5W.js";import{t as De}from"./ConfirmModal-lZYjzFL6.js";import{n as Oe}from"./currency-DS4qMz4d.js";import{a as ke,i as Ae,s as je,v as _}from"./date-G9KUauqz.js";import{n as Me}from"./useUiSettings-BoONraTd.js";import{t as Ne}from"./NumberInput-BhsGuNcX.js";import{t as Pe}from"./purify.es-DaBa283-.js";import{n as Fe}from"./libraryFiles-CZJbXn67.js";import{ProjectModal as Ie,n as v,t as Le}from"./ProjectsPage-BuB2O1SW.js";var y=e(r(),1),b=i();function x(e){return e>=1e3?`${(e/1e3).toFixed(2)}kg`:`${Math.round(e)}g`}function Re({status:e,t}){let n={active:`bg-bambu-green/20 text-bambu-green`,completed:`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400`,archived:`bg-bambu-gray/20 text-bambu-gray`},r=n[e]||n.active,i={active:t(`projectDetail.status.active`),completed:t(`projectDetail.status.completed`),archived:t(`projectDetail.status.archived`)};return(0,b.jsx)(`span`,{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[e]||e.charAt(0).toUpperCase()+e.slice(1)})}function ze({icon:e,label:t,value:n,subValue:r,hint:i,color:a=`text-bambu-gray`}){return(0,b.jsx)(h,{children:(0,b.jsx)(m,{className:`p-4`,children:(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,title:i,children:[(0,b.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark ${a}`,children:(0,b.jsx)(e,{className:`w-5 h-5`})}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:t}),(0,b.jsx)(`p`,{className:`text-xl font-semibold text-white`,children:n}),r&&(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray/70`,children:r})]})]})})})}function Be({archives:e,t}){return e.length===0?(0,b.jsxs)(`div`,{className:`text-center py-8 text-bambu-gray`,children:[(0,b.jsx)(d,{className:`w-12 h-12 mx-auto mb-2 opacity-50`}),(0,b.jsx)(`p`,{children:t(`projectDetail.noPrints`)})]}):(0,b.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3`,children:e.map(e=>(0,b.jsxs)(o,{to:`/archives?search=${encodeURIComponent(e.print_name||``)}`,className:`group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors`,children:[e.thumbnail_path?(0,b.jsx)(`img`,{src:n.getArchiveThumbnail(e.id),alt:e.print_name||`Print`,className:`w-full h-full object-cover`}):(0,b.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-bambu-gray`,children:(0,b.jsx)(d,{className:`w-8 h-8`})}),e.status===`failed`&&(0,b.jsx)(`div`,{className:`absolute inset-0 bg-red-500/30 flex items-center justify-center`,children:(0,b.jsx)(ae,{className:`w-8 h-8 text-white`})}),e.status===`completed`&&(0,b.jsx)(`div`,{className:`absolute top-1 right-1`,children:(0,b.jsx)(l,{className:`w-4 h-4 text-bambu-green`})}),(0,b.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,b.jsx)(`p`,{className:`text-xs text-white truncate`,children:e.print_name||`Unknown`})})]},e.id))})}function Ve({priority:e,t}){let n={low:{color:`bg-gray-500/20 text-gray-400`,label:t(`projectDetail.priority.low`)},normal:{color:`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400`,label:t(`projectDetail.priority.normal`)},high:{color:`bg-orange-100 dark:bg-orange-500/20 text-orange-700 dark:text-orange-400`,label:t(`projectDetail.priority.high`)},urgent:{color:`bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400`,label:t(`projectDetail.priority.urgent`)}},{color:r,label:i}=n[e]||n.normal;return(0,b.jsxs)(`span`,{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[e===`urgent`&&(0,b.jsx)(p,{className:`w-3 h-3`}),i]})}function S(e,t){if(!e)return null;let n=_(e);if(!n)return null;let r=new Date,i=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return i<0?{color:`text-red-700 dark:text-red-400`,label:t(`projectDetail.dueDate.overdue`)}:i===0?{color:`text-orange-700 dark:text-orange-400`,label:t(`projectDetail.dueDate.today`)}:i<=3?{color:`text-yellow-700 dark:text-yellow-400`,label:t(`projectDetail.dueDate.daysLeft`,{count:i})}:{color:`text-bambu-gray`,label:t(`projectDetail.dueDate.daysLeft`,{count:i})}}function C(){let{id:e}=a(),r=ee(),{t:i}=t(),p=te(),{showToast:_}=se(),{hasPermission:C}=Ee(),[He,w]=(0,y.useState)(!1),[Ue,T]=(0,y.useState)(!1),[We,E]=(0,y.useState)(``),[D,O]=(0,y.useState)(null),k=parseInt(e||`0`,10),{data:A,isLoading:Ge,error:j}=s({queryKey:[`project`,k],queryFn:()=>n.getProject(k),enabled:k>0}),{data:Ke,isLoading:qe}=s({queryKey:[`project-archives`,k],queryFn:()=>n.getProjectArchives(k),enabled:k>0}),{data:M,isLoading:Je}=s({queryKey:[`project-bom`,k],queryFn:()=>n.getProjectBOM(k),enabled:k>0}),{data:N,isLoading:Ye}=s({queryKey:[`project-timeline`,k],queryFn:()=>n.getProjectTimeline(k,20),enabled:k>0}),{data:Xe}=Me(),{data:P}=s({queryKey:[`project-folders`,k],queryFn:()=>n.getLibraryFoldersByProject(k),enabled:k>0}),{data:F,isLoading:Ze}=s({queryKey:[`project-files`,k],queryFn:()=>n.getLibraryFiles(null,!1,k),enabled:k>0}),Qe=(0,y.useMemo)(()=>{let e=new Map;for(let t of F??[])if(t.folder_id!=null){let n=e.get(t.folder_id)??[];n.push(t),e.set(t.folder_id,n)}return e},[F]),{data:$e}=s({queryKey:[`project-file-progress`,k],queryFn:()=>n.getProjectFileProgress(k),enabled:k>0}),I=(0,y.useMemo)(()=>{let e=new Map;for(let t of $e??[])e.set(t.file_id,t.completed_count);return e},[$e]),L=(0,y.useMemo)(()=>{let e=A?.target_sets;if(!e||!F)return null;let t=F.filter(e=>Fe(e));return t.length===0?null:Math.min(...t.map(t=>Math.min(I.get(t.id)??0,e)))},[A?.target_sets,F,I]),R=Oe(Xe?.currency||`USD`),et=Xe?.time_format||`system`,z=c({mutationFn:e=>n.updateProject(k,e),onSuccess:()=>{p.invalidateQueries({queryKey:[`project`,k]}),p.invalidateQueries({queryKey:[`projects`]}),w(!1),T(!1),_(i(`projectDetail.toast.projectUpdated`),`success`)},onError:e=>{_(e.message,`error`)}}),tt=()=>{E(A?.notes||``),T(!0)},nt=()=>{z.mutate({notes:We})},rt=()=>{T(!1),E(``)},[B,it]=(0,y.useState)(``),[at,ot]=(0,y.useState)(1),[V,st]=(0,y.useState)(``),[ct,lt]=(0,y.useState)(``),[ut,dt]=(0,y.useState)(``),[ft,H]=(0,y.useState)(!1),[U,pt]=(0,y.useState)(!1),[W,G]=(0,y.useState)(null),[K,mt]=(0,y.useState)(``),[ht,gt]=(0,y.useState)(1),[q,_t]=(0,y.useState)(``),[vt,yt]=(0,y.useState)(``),[bt,xt]=(0,y.useState)(``),[J,Y]=(0,y.useState)({isOpen:!1,title:``,message:``,onConfirm:()=>{}}),X=c({mutationFn:e=>n.createBOMItem(k,e),onSuccess:()=>{p.invalidateQueries({queryKey:[`project-bom`,k]}),p.invalidateQueries({queryKey:[`project`,k]}),it(``),ot(1),st(``),lt(``),dt(``),H(!1),_(i(`projectDetail.toast.partAdded`),`success`)},onError:e=>_(e.message,`error`)}),Z=c({mutationFn:({itemId:e,data:t})=>n.updateBOMItem(k,e,t),onSuccess:()=>{p.invalidateQueries({queryKey:[`project-bom`,k]}),p.invalidateQueries({queryKey:[`project`,k]}),G(null)},onError:e=>_(e.message,`error`)}),St=c({mutationFn:e=>n.deleteBOMItem(k,e),onSuccess:()=>{p.invalidateQueries({queryKey:[`project-bom`,k]}),p.invalidateQueries({queryKey:[`project`,k]}),_(i(`projectDetail.toast.partRemoved`),`success`)},onError:e=>_(e.message,`error`)}),Ct=e=>{e.preventDefault(),B.trim()&&X.mutate({name:B.trim(),quantity_needed:at,unit_price:V?parseFloat(V):void 0,sourcing_url:ct.trim()||void 0,remarks:ut.trim()||void 0})},wt=e=>{let t=e.is_complete?0:e.quantity_needed;Z.mutate({itemId:e.id,data:{quantity_acquired:t}})},Tt=(e,t)=>{Y({isOpen:!0,title:i(`projectDetail.bom.deletePart`),message:i(`projectDetail.bom.deleteConfirm`,{name:t}),onConfirm:()=>{Y(e=>({...e,isOpen:!1})),St.mutate(e)}})},Et=e=>{G(e),mt(e.name),gt(e.quantity_needed),_t(e.unit_price?.toString()||``),yt(e.sourcing_url||``),xt(e.remarks||``)},Dt=e=>{e.preventDefault(),!(!W||!K.trim())&&Z.mutate({itemId:W.id,data:{name:K.trim(),quantity_needed:ht,unit_price:q?parseFloat(q):void 0,sourcing_url:vt.trim()||void 0,remarks:bt.trim()||void 0}})},Ot=()=>{G(null)},kt=async()=>{try{let{blob:e,filename:t}=await n.exportProjectZip(Number(k)),r=URL.createObjectURL(e),a=document.createElement(`a`);a.href=r,a.download=t||`${A?.name||`project`}_${new Date().toISOString().split(`T`)[0]}.zip`,a.click(),URL.revokeObjectURL(r),_(i(`projectDetail.toast.projectExported`),`success`)}catch(e){_(e.message,`error`)}},Q=c({mutationFn:()=>n.createTemplateFromProject(k),onSuccess:()=>{p.invalidateQueries({queryKey:[`projects`]}),_(i(`projectDetail.toast.templateCreated`),`success`)},onError:e=>_(e.message,`error`)}),At=e=>ke(e,et,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});if(Ge)return(0,b.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,b.jsx)(u,{className:`w-8 h-8 animate-spin text-bambu-green`})});if(j||!A)return(0,b.jsxs)(`div`,{className:`text-center py-24`,children:[(0,b.jsx)(`p`,{className:`text-bambu-gray`,children:j?`${i(`common.error`)}: ${j.message}`:i(`projectDetail.notFound`)}),(0,b.jsx)(g,{variant:`secondary`,className:`mt-4`,onClick:()=>r(`/projects`),children:i(`projectDetail.backToProjects`)})]});let $=A.stats,jt=$?.progress_percent??0,Mt=$?.parts_progress_percent??0;return(0,b.jsxs)(`div`,{className:`p-4 md:p-8 space-y-8`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,b.jsx)(o,{to:`/projects`,className:`hover:text-white transition-colors`,children:i(`nav.projects`)}),(0,b.jsx)(oe,{className:`w-4 h-4`}),(0,b.jsx)(`span`,{className:`text-white`,children:A.name})]}),(0,b.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,b.jsx)(`button`,{onClick:()=>r(`/projects`),className:`p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors`,children:(0,b.jsx)(ne,{className:`w-5 h-5 text-bambu-gray`})}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`w-4 h-4 rounded-full shrink-0`,style:{backgroundColor:A.color||`#6b7280`}}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h1`,{className:`text-2xl font-bold text-white`,children:A.name}),A.description&&(0,b.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:A.description})]})]}),(0,b.jsx)(Re,{status:A.status,t:i})]}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsxs)(g,{variant:`secondary`,onClick:kt,disabled:!C(`projects:read`),title:C(`projects:read`)?i(`projectDetail.exportProject`):i(`projectDetail.noExportPermission`),children:[(0,b.jsx)(de,{className:`w-4 h-4 mr-2`}),i(`projectDetail.export`)]}),(0,b.jsxs)(g,{onClick:()=>w(!0),disabled:!C(`projects:update`),title:C(`projects:update`)?void 0:i(`projectDetail.noEditPermission`),children:[(0,b.jsx)(ve,{className:`w-4 h-4 mr-2`}),i(`common.edit`)]})]})]}),(A.target_count||A.target_parts_count||A.target_sets)&&(0,b.jsx)(h,{children:(0,b.jsxs)(m,{className:`p-4 space-y-4`,children:[A.target_count&&(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,b.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:i(`projectDetail.progress.platesProgress`)}),(0,b.jsxs)(`span`,{className:`text-sm font-medium text-white`,children:[$?.total_archives||0,` / `,A.target_count,` `,i(`projectDetail.progress.printJobs`)]})]}),(0,b.jsx)(`div`,{className:`h-3 bg-bambu-dark rounded-full overflow-hidden`,children:(0,b.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${Math.min(jt,100)}%`,backgroundColor:jt>=100?`#22c55e`:A.color||`#6b7280`}})}),(0,b.jsxs)(`div`,{className:`flex justify-between mt-1`,children:[(0,b.jsx)(`span`,{className:`text-xs text-bambu-gray/70`,children:i(`projectDetail.progress.percentComplete`,{percent:jt.toFixed(0)})}),$?.remaining_prints!=null&&$.remaining_prints>0&&(0,b.jsx)(`span`,{className:`text-xs text-bambu-gray/70`,children:i(`projectDetail.progress.remaining`,{count:$.remaining_prints})})]})]}),A.target_parts_count&&(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,b.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:i(`projectDetail.progress.partsProgress`)}),(0,b.jsxs)(`span`,{className:`text-sm font-medium text-white`,children:[$?.completed_prints||0,` / `,A.target_parts_count,` `,i(`projectDetail.progress.parts`)]})]}),(0,b.jsx)(`div`,{className:`h-3 bg-bambu-dark rounded-full overflow-hidden`,children:(0,b.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${Math.min(Mt,100)}%`,backgroundColor:Mt>=100?`#22c55e`:A.color||`#6b7280`}})}),(0,b.jsxs)(`div`,{className:`flex justify-between mt-1`,children:[(0,b.jsx)(`span`,{className:`text-xs text-bambu-gray/70`,children:i(`projectDetail.progress.percentComplete`,{percent:Mt.toFixed(0)})}),$?.remaining_parts!=null&&$.remaining_parts>0&&(0,b.jsx)(`span`,{className:`text-xs text-bambu-gray/70`,children:i(`projectDetail.progress.remaining`,{count:$.remaining_parts})})]})]}),A.target_sets?(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,b.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:i(`projectDetail.progress.setsProgress`)}),(0,b.jsxs)(`span`,{className:`text-sm font-medium text-white`,children:[L??0,` / `,A.target_sets,` `,i(`projectDetail.progress.sets`)]})]}),(0,b.jsx)(`div`,{className:`h-3 bg-bambu-dark rounded-full overflow-hidden`,children:(0,b.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${Math.min((L??0)/A.target_sets*100,100)}%`,backgroundColor:(L??0)>=A.target_sets?`#22c55e`:A.color||`#6b7280`}})}),(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:i(`projectDetail.progress.setsHint`)})]}):null]})}),$&&(0,b.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,b.jsx)(h,{children:(0,b.jsx)(m,{className:`p-4`,children:(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark text-bambu-green`,children:(0,b.jsx)(d,{className:`w-5 h-5`})}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`projectDetail.stats.printJobs`)}),(0,b.jsxs)(`p`,{className:`text-xl font-semibold text-white`,children:[$.total_archives,` `,(0,b.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray`,children:i(`projectDetail.stats.total`)})]}),$.failed_prints>0&&(0,b.jsx)(`p`,{className:`text-sm text-status-error`,children:i(`projectDetail.stats.failed`,{count:$.failed_prints})}),(0,b.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`projectDetail.stats.partsPrinted`,{count:$.completed_prints})})]})]})})}),(0,b.jsx)(ze,{icon:le,label:i(`projectDetail.stats.printTime`),value:je($.total_print_time_hours),color:`text-yellow-600 dark:text-yellow-400`}),(0,b.jsx)(ze,{icon:f,label:i(`projectDetail.stats.filamentUsed`),value:x($.total_filament_grams),color:`text-purple-600 dark:text-purple-400`})]}),A.rollup_stats&&(0,b.jsx)(h,{children:(0,b.jsxs)(m,{className:`p-4`,children:[(0,b.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2 mb-3`,children:[(0,b.jsx)(v,{className:`w-5 h-5`}),i(`projectDetail.rollup.title`,{count:A.descendant_count})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:i(`projectDetail.stats.printJobs`)}),(0,b.jsx)(`p`,{className:`text-lg font-semibold text-white`,children:A.rollup_stats.total_archives}),(0,b.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`projectDetail.stats.partsPrinted`,{count:A.rollup_stats.completed_prints})})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:i(`projectDetail.stats.printTime`)}),(0,b.jsx)(`p`,{className:`text-lg font-semibold text-white`,children:je(A.rollup_stats.total_print_time_hours)})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:i(`projectDetail.stats.filamentUsed`)}),(0,b.jsx)(`p`,{className:`text-lg font-semibold text-white`,children:x(A.rollup_stats.total_filament_grams)})]}),(()=>{let e=A.rollup_stats.estimated_cost+A.rollup_stats.total_energy_cost+(A.rollup_stats.total_wear_cost??0)+A.rollup_stats.bom_cost;return e<=0?null:(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:i(`projectDetail.cost.totalCost`)}),(0,b.jsxs)(`p`,{className:`text-lg font-semibold text-bambu-green`,children:[R,e.toFixed(2)]})]})})()]}),A.rollup_stats.progress_percent!==null&&(0,b.jsxs)(`div`,{className:`mt-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,b.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:i(`projectDetail.rollup.progress`)}),(0,b.jsx)(`span`,{className:`text-sm font-medium text-white`,children:i(`projectDetail.rollup.percentComplete`,{percent:A.rollup_stats.progress_percent.toFixed(0)})})]}),(0,b.jsx)(`div`,{className:`h-3 bg-bambu-dark rounded-full overflow-hidden`,children:(0,b.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${Math.min(A.rollup_stats.progress_percent,100)}%`,backgroundColor:A.rollup_stats.progress_percent>=100?`#22c55e`:A.color||`#6b7280`}})})]})]})}),$&&(()=>{let e=$.estimated_cost+$.total_energy_cost+($.total_wear_cost??0)+$.bom_cost;return $.estimated_cost>0||e>0||A.budget!==null})()&&(0,b.jsx)(h,{children:(0,b.jsxs)(m,{className:`p-4`,children:[(0,b.jsx)(`h2`,{className:`text-lg font-semibold text-white mb-3`,children:i(`projectDetail.cost.title`)}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:i(`projectDetail.cost.filamentCost`)}),(0,b.jsxs)(`p`,{className:`text-lg font-semibold text-white`,children:[R,$.estimated_cost.toFixed(2)]})]}),$.total_energy_kwh>0&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:i(`projectDetail.cost.energy`)}),(0,b.jsxs)(`p`,{className:`text-lg font-semibold text-white`,children:[$.total_energy_kwh.toFixed(3),` kWh`,$.total_energy_cost>0&&(0,b.jsxs)(`span`,{className:`text-sm text-bambu-gray ml-1`,children:[`(`,R,$.total_energy_cost.toFixed(2),`)`]})]})]}),($.total_wear_cost??0)>0&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:i(`projectDetail.cost.wear`)}),(0,b.jsxs)(`p`,{className:`text-lg font-semibold text-white`,children:[R,$.total_wear_cost.toFixed(2)]})]}),(()=>{let e=$.estimated_cost+$.total_energy_cost+($.total_wear_cost??0)+$.bom_cost;return e<=0?null:(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:i(`projectDetail.cost.totalCost`)}),(0,b.jsxs)(`p`,{className:`text-lg font-semibold text-bambu-green`,children:[R,e.toFixed(2)]}),$.bom_cost>0&&(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray/70`,children:i(`projectDetail.cost.includesBom`)})]})})(),A.budget!==null&&(()=>{let e=$.estimated_cost+$.total_energy_cost+($.total_wear_cost??0)+$.bom_cost,t=A.budget-e;return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:i(`projectDetail.cost.budget`)}),(0,b.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[i(`projectDetail.cost.total`),`: `,(0,b.jsxs)(`span`,{className:`text-white font-semibold`,children:[R,A.budget.toFixed(2)]})]}),(0,b.jsxs)(`p`,{className:`text-sm ${t>=0?`text-bambu-green`:`text-red-700 dark:text-red-400`}`,children:[i(`projectDetail.cost.remaining`),`: `,(0,b.jsxs)(`span`,{className:`font-semibold`,children:[R,t.toFixed(2)]})]})]})})()]})]})}),A.children&&A.children.length>0&&(0,b.jsx)(h,{children:(0,b.jsxs)(m,{className:`p-4`,children:[(0,b.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2 mb-3`,children:[(0,b.jsx)(v,{className:`w-5 h-5`}),i(`projectDetail.subProjects.title`,{count:A.children.length})]}),(0,b.jsx)(`div`,{className:`space-y-2`,children:A.children.map(e=>(0,b.jsxs)(o,{to:`/projects/${e.id}`,className:`flex items-center justify-between gap-4 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,b.jsx)(`div`,{className:`w-3 h-3 rounded-full flex-shrink-0`,style:{backgroundColor:e.color||`#6b7280`}}),(0,b.jsx)(`span`,{className:`text-white truncate`,children:e.name}),(0,b.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded flex-shrink-0 ${e.status===`completed`?`bg-status-ok/20 text-status-ok`:e.status===`archived`?`bg-bambu-gray/20 text-bambu-gray`:`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400`}`,children:e.status}),e.descendant_count>0&&(0,b.jsxs)(`span`,{className:`text-xs text-bambu-gray flex-shrink-0 inline-flex items-center gap-1`,children:[(0,b.jsx)(v,{className:`w-3 h-3`}),e.descendant_count]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-4 text-sm text-bambu-gray flex-shrink-0`,children:[e.total_archives>0&&(0,b.jsx)(`span`,{className:`hidden sm:inline`,children:i(`projectDetail.subProjects.jobs`,{count:e.total_archives})}),e.total_filament_grams>0&&(0,b.jsx)(`span`,{className:`hidden md:inline`,children:x(e.total_filament_grams)}),e.total_cost>0&&(0,b.jsxs)(`span`,{className:`hidden md:inline`,children:[R,e.total_cost.toFixed(2)]}),e.progress_percent!==null&&(0,b.jsxs)(`span`,{children:[e.progress_percent.toFixed(0),`%`]})]})]},e.id))})]})}),A.parent_id&&A.parent_name&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(_e,{className:`w-4 h-4 text-bambu-gray`}),(0,b.jsx)(`span`,{className:`text-bambu-gray`,children:i(`projectDetail.partOf`)}),(0,b.jsx)(o,{to:`/projects/${A.parent_id}`,className:`text-bambu-green hover:underline`,children:A.parent_name})]}),(A.tags||A.due_date||A.priority!==`normal`)&&(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[A.priority&&A.priority!==`normal`&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-bambu-gray uppercase`,children:i(`projectDetail.priorityLabel`)}),(0,b.jsx)(Ve,{priority:A.priority,t:i})]}),A.due_date&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(ie,{className:`w-4 h-4 text-bambu-gray`}),(0,b.jsx)(`span`,{className:`text-sm text-white`,children:Ae(A.due_date,{year:`numeric`,month:`short`,day:`numeric`})}),S(A.due_date,i)&&(0,b.jsxs)(`span`,{className:`text-xs ${S(A.due_date,i).color}`,children:[`(`,S(A.due_date,i).label,`)`]})]}),A.tags&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(Ce,{className:`w-4 h-4 text-bambu-gray`}),(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:A.tags.split(`,`).map((e,t)=>(0,b.jsx)(`span`,{className:`px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded`,children:e.trim()},t))})]})]}),(0,b.jsx)(h,{children:(0,b.jsxs)(m,{className:`p-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,b.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,b.jsx)(me,{className:`w-5 h-5`}),i(`projectDetail.notes.title`)]}),Ue?(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsxs)(g,{variant:`secondary`,size:`sm`,onClick:rt,disabled:z.isPending,children:[(0,b.jsx)(Te,{className:`w-4 h-4 mr-1`}),i(`common.cancel`)]}),(0,b.jsxs)(g,{size:`sm`,onClick:nt,disabled:z.isPending,children:[z.isPending?(0,b.jsx)(u,{className:`w-4 h-4 animate-spin mr-1`}):(0,b.jsx)(xe,{className:`w-4 h-4 mr-1`}),i(`common.save`)]})]}):(0,b.jsxs)(g,{variant:`secondary`,size:`sm`,onClick:tt,disabled:!C(`projects:update`),title:C(`projects:update`)?void 0:i(`projectDetail.notes.noEditPermission`),children:[(0,b.jsx)(ve,{className:`w-4 h-4 mr-1`}),i(`common.edit`)]})]}),Ue?(0,b.jsx)(re,{content:We,onChange:E,placeholder:i(`projectDetail.notes.placeholder`)}):A.notes?(0,b.jsx)(`div`,{className:`prose prose-invert prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:Pe.sanitize(A.notes)}}):(0,b.jsx)(`p`,{className:`text-bambu-gray/70 text-sm italic`,children:i(`projectDetail.notes.empty`)})]})}),(0,b.jsx)(h,{children:(0,b.jsxs)(m,{className:`p-4`,children:[(0,b.jsx)(`div`,{className:`flex items-center justify-between mb-3`,children:(0,b.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,b.jsx)(he,{className:`w-5 h-5`}),i(`projectDetail.files.title`)]})}),(0,b.jsxs)(`p`,{className:`text-xs text-bambu-gray mb-3`,children:[(0,b.jsx)(o,{to:`/files`,className:`text-bambu-green hover:underline`,children:i(`projectDetail.files.linkFolders`)}),` `,i(`projectDetail.files.forQuickAccess`)]}),P&&P.length>0?(0,b.jsx)(`div`,{className:`space-y-4`,children:P.map(e=>{let t=Qe.get(e.id)??[],r=Ze;return(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(o,{to:`/files?folder=${e.id}`,className:`flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors mb-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,b.jsx)(he,{className:`w-5 h-5 text-bambu-green shrink-0`}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`p`,{className:`text-sm text-white truncate`,children:e.name}),(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`projectDetail.files.fileCount`,{count:e.file_count})})]})]}),(0,b.jsx)(oe,{className:`w-4 h-4 text-bambu-gray shrink-0`})]}),r?(0,b.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-bambu-gray text-sm`,children:(0,b.jsx)(u,{className:`w-4 h-4 animate-spin`})}):t.length===0?(0,b.jsx)(`p`,{className:`text-bambu-gray/60 text-xs italic px-3`,children:i(`projectDetail.files.noFiles`)}):(0,b.jsx)(`div`,{className:`space-y-1 pl-3`,children:t.map(e=>{let t=Fe(e);return(0,b.jsxs)(`div`,{className:`flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors`,children:[(0,b.jsx)(`div`,{className:`w-10 h-10 shrink-0 rounded bg-bambu-dark overflow-hidden flex items-center justify-center`,children:e.thumbnail_path?(0,b.jsx)(`img`,{src:n.getLibraryFileThumbnailUrl(e.id),alt:e.print_name||e.filename,className:`w-full h-full object-cover`}):(0,b.jsx)(pe,{className:`w-5 h-5 text-bambu-gray/40`})}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`p`,{className:`text-sm text-white truncate`,title:e.print_name||e.filename,children:e.print_name||e.filename}),(0,b.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded font-medium ${e.file_type===`3mf`?`bg-bambu-green/20 text-bambu-green`:e.file_type===`gcode`||e.file_type===`gcode.3mf`?`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400`:`bg-bambu-gray/20 text-bambu-gray`}`,children:e.file_type.toUpperCase()})]}),t&&(()=>{let t=I.get(e.id)??0,n=A.target_sets;if(!n)return t>0?(0,b.jsxs)(`span`,{className:`shrink-0 text-xs px-1.5 py-0.5 rounded-full bg-bambu-dark text-bambu-gray`,title:i(`projectDetail.files.printedCount`,{count:t}),children:[t,`×`]}):null;let r=Math.min(t/n*100,100),a=t>=n?`text-status-ok`:t>0?`text-status-warning`:`text-bambu-gray`,ee=t>=n?`bg-status-ok`:t>0?`bg-status-warning`:`bg-bambu-gray`;return(0,b.jsxs)(`div`,{className:`shrink-0 w-20`,title:i(`projectDetail.files.progressTooltip`,{done:t,target:n}),children:[(0,b.jsxs)(`p`,{className:`text-xs font-medium text-right ${a}`,children:[t,` / `,n]}),(0,b.jsx)(`div`,{className:`h-1 bg-bambu-dark rounded-full overflow-hidden mt-1`,children:(0,b.jsx)(`div`,{className:`h-full ${ee}`,style:{width:`${r}%`}})})]})})(),t&&(0,b.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:(0,b.jsx)(`button`,{onClick:()=>O(e),title:i(`common.print`),className:`p-1.5 rounded hover:bg-bambu-green/20 text-bambu-green transition-colors`,children:(0,b.jsx)(f,{className:`w-4 h-4`})})})]},e.id)})})]},e.id)})}):(0,b.jsx)(`p`,{className:`text-bambu-gray/70 text-sm italic`,children:i(`projectDetail.files.empty`)})]})}),(0,b.jsx)(h,{children:(0,b.jsxs)(m,{className:`p-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,b.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,b.jsx)(Se,{className:`w-5 h-5`}),i(`projectDetail.bom.title`),$&&$.bom_total_items>0&&(0,b.jsxs)(`span`,{className:`text-sm font-normal text-bambu-gray`,children:[`(`,i(`projectDetail.bom.acquired`,{completed:$.bom_completed_items,total:$.bom_total_items}),`)`]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[M&&M.some(e=>e.is_complete)&&(0,b.jsx)(`button`,{onClick:()=>pt(!U),className:`text-xs px-2 py-1 rounded transition-colors ${U?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:i(U?`projectDetail.bom.showAll`:`projectDetail.bom.hideDone`)}),!ft&&(0,b.jsxs)(g,{variant:`secondary`,size:`sm`,onClick:()=>H(!0),disabled:!C(`projects:update`),title:C(`projects:update`)?void 0:i(`projectDetail.bom.noAddPermission`),children:[(0,b.jsx)(be,{className:`w-4 h-4 mr-1`}),i(`projectDetail.bom.addPart`)]})]})]}),ft&&(0,b.jsxs)(`form`,{onSubmit:Ct,className:`bg-bambu-dark rounded-lg p-4 mb-4 space-y-3`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,b.jsx)(`input`,{type:`text`,value:B,onChange:e=>it(e.target.value),className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:i(`projectDetail.bom.partNamePlaceholder`),autoFocus:!0}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(Ne,{value:at,onChange:ot,fallback:1,className:`w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green`,min:1,placeholder:i(`projectDetail.bom.qty`)}),(0,b.jsx)(`input`,{type:`number`,step:`0.01`,value:V,onChange:e=>st(e.target.value),className:`flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:i(`projectDetail.bom.price`,{currency:R})})]})]}),(0,b.jsx)(`input`,{type:`url`,value:ct,onChange:e=>lt(e.target.value),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:i(`projectDetail.bom.sourcingUrlPlaceholder`)}),(0,b.jsx)(`input`,{type:`text`,value:ut,onChange:e=>dt(e.target.value),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:i(`projectDetail.bom.remarksPlaceholder`)}),(0,b.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,b.jsx)(g,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>H(!1),children:i(`common.cancel`)}),(0,b.jsx)(g,{type:`submit`,size:`sm`,disabled:!B.trim()||X.isPending,children:X.isPending?(0,b.jsx)(u,{className:`w-4 h-4 animate-spin`}):i(`projectDetail.bom.addPart`)})]})]}),Je?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,b.jsx)(u,{className:`w-6 h-6 animate-spin text-bambu-green`})}):M&&M.length>0?(0,b.jsxs)(`div`,{className:`space-y-2`,children:[M.filter(e=>!U||!e.is_complete).map(e=>(0,b.jsx)(`div`,{className:`p-3 rounded-lg transition-colors ${e.is_complete?`bg-status-ok/10`:`bg-bambu-dark`}`,children:W?.id===e.id?(0,b.jsxs)(`form`,{onSubmit:Dt,className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,b.jsx)(`input`,{type:`text`,value:K,onChange:e=>mt(e.target.value),className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:i(`projectDetail.bom.partName`),autoFocus:!0}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(Ne,{value:ht,onChange:gt,fallback:1,className:`w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green`,min:1,placeholder:i(`projectDetail.bom.qty`)}),(0,b.jsx)(`input`,{type:`number`,step:`0.01`,value:q,onChange:e=>_t(e.target.value),className:`flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:i(`projectDetail.bom.price`,{currency:R})})]})]}),(0,b.jsx)(`input`,{type:`url`,value:vt,onChange:e=>yt(e.target.value),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:i(`projectDetail.bom.sourcingUrlPlaceholder`)}),(0,b.jsx)(`input`,{type:`text`,value:bt,onChange:e=>xt(e.target.value),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:i(`projectDetail.bom.remarksPlaceholder`)}),(0,b.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,b.jsx)(g,{type:`button`,variant:`secondary`,size:`sm`,onClick:Ot,children:i(`common.cancel`)}),(0,b.jsx)(g,{type:`submit`,size:`sm`,disabled:!K.trim()||Z.isPending,children:Z.isPending?(0,b.jsx)(u,{className:`w-4 h-4 animate-spin`}):i(`common.save`)})]})]}):(0,b.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,b.jsx)(`button`,{onClick:()=>C(`projects:update`)&&wt(e),disabled:Z.isPending||!C(`projects:update`),title:C(`projects:update`)?void 0:i(`projectDetail.bom.noUpdatePermission`),className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors shrink-0 ${e.is_complete?`bg-status-ok border-status-ok text-white`:C(`projects:update`)?`border-bambu-gray hover:border-bambu-green`:`border-bambu-gray/50 cursor-not-allowed`}`,children:e.is_complete&&(0,b.jsx)(l,{className:`w-3 h-3`})}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,b.jsxs)(`p`,{className:`text-sm font-medium ${e.is_complete?`text-bambu-gray line-through`:`text-white`}`,children:[e.name,(0,b.jsxs)(`span`,{className:`text-bambu-gray font-normal ml-2`,children:[`x`,e.quantity_needed]})]}),e.unit_price!==null&&(0,b.jsxs)(`span`,{className:`text-xs text-bambu-green whitespace-nowrap`,children:[R,(e.unit_price*e.quantity_needed).toFixed(2)]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,b.jsx)(`button`,{onClick:()=>C(`projects:update`)&&Et(e),disabled:!C(`projects:update`),className:`p-1 rounded transition-colors shrink-0 ${C(`projects:update`)?`hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white`:`text-bambu-gray/50 cursor-not-allowed`}`,title:C(`projects:update`)?i(`common.edit`):i(`projectDetail.bom.noEditPermission`),children:(0,b.jsx)(ye,{className:`w-4 h-4`})}),(0,b.jsx)(`button`,{onClick:()=>C(`projects:update`)&&Tt(e.id,e.name),disabled:!C(`projects:update`),className:`p-1 rounded transition-colors shrink-0 ${C(`projects:update`)?`hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400`:`text-bambu-gray/50 cursor-not-allowed`}`,title:C(`projects:update`)?i(`common.delete`):i(`projectDetail.bom.noDeletePermission`),children:(0,b.jsx)(we,{className:`w-4 h-4`})})]})]}),e.sourcing_url&&(0,b.jsxs)(`a`,{href:e.sourcing_url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 mt-1 text-xs text-blue-700 dark:text-blue-400 hover:text-blue-900 dark:hover:text-blue-300 transition-colors`,onClick:e=>e.stopPropagation(),children:[(0,b.jsx)(fe,{className:`w-3 h-3 shrink-0`}),(0,b.jsx)(`span`,{className:`truncate`,children:(()=>{try{return new URL(e.sourcing_url).hostname.replace(`www.`,``)}catch{return e.sourcing_url}})()})]}),e.remarks&&(0,b.jsx)(`p`,{className:`mt-1 text-xs text-bambu-gray/80 italic`,children:e.remarks})]})]})},e.id)),$&&$.bom_cost>0&&(0,b.jsxs)(`div`,{className:`pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm`,children:[(0,b.jsx)(`span`,{className:`text-bambu-gray`,children:i(`projectDetail.bom.totalCost`)}),(0,b.jsxs)(`span`,{className:`text-white font-medium`,children:[R,$.bom_cost.toFixed(2)]})]})]}):(0,b.jsx)(`p`,{className:`text-bambu-gray/70 text-sm italic`,children:i(`projectDetail.bom.empty`)})]})}),(0,b.jsx)(h,{children:(0,b.jsxs)(m,{className:`p-4`,children:[(0,b.jsx)(`div`,{className:`flex items-center justify-between mb-3`,children:(0,b.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,b.jsx)(ge,{className:`w-5 h-5`}),i(`projectDetail.timeline.title`)]})}),Ye?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,b.jsx)(u,{className:`w-6 h-6 animate-spin text-bambu-green`})}):N&&N.length>0?(0,b.jsx)(`div`,{className:`space-y-3`,children:N.slice(0,10).map((e,t)=>(0,b.jsxs)(`div`,{className:`flex gap-3`,children:[(0,b.jsxs)(`div`,{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0 ${e.event_type===`print_completed`?`bg-status-ok/20 text-status-ok`:e.event_type===`print_failed`?`bg-status-error/20 text-status-error`:e.event_type===`print_started`?`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:[e.event_type===`print_completed`&&(0,b.jsx)(l,{className:`w-4 h-4`}),e.event_type===`print_failed`&&(0,b.jsx)(ae,{className:`w-4 h-4`}),e.event_type===`print_started`&&(0,b.jsx)(f,{className:`w-4 h-4`}),e.event_type===`queued`&&(0,b.jsx)(Le,{className:`w-4 h-4`}),e.event_type===`project_created`&&(0,b.jsx)(be,{className:`w-4 h-4`})]}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`p`,{className:`text-sm text-white`,children:e.title}),e.description&&(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray truncate`,children:e.description}),(0,b.jsx)(`p`,{className:`text-xs text-bambu-gray/70`,children:At(e.timestamp)})]})]},t))}):(0,b.jsx)(`p`,{className:`text-bambu-gray/70 text-sm italic`,children:i(`projectDetail.timeline.empty`)})]})}),!A.is_template&&(0,b.jsx)(`div`,{className:`flex justify-end`,children:(0,b.jsxs)(g,{variant:`secondary`,size:`sm`,onClick:()=>Q.mutate(),disabled:Q.isPending||!C(`projects:create`),title:C(`projects:create`)?void 0:i(`projectDetail.template.noCreatePermission`),children:[Q.isPending?(0,b.jsx)(u,{className:`w-4 h-4 animate-spin mr-2`}):(0,b.jsx)(ue,{className:`w-4 h-4 mr-2`}),i(`projectDetail.template.saveAsTemplate`)]})}),$&&($.queued_prints>0||$.in_progress_prints>0)&&(0,b.jsx)(h,{children:(0,b.jsxs)(m,{className:`p-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,b.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,b.jsx)(Le,{className:`w-5 h-5`}),i(`projectDetail.queue.title`)]}),(0,b.jsx)(o,{to:`/queue?project=${k}`,className:`text-sm text-bambu-green hover:underline`,children:i(`projectDetail.queue.viewAll`)})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[$.in_progress_prints>0&&(0,b.jsx)(`span`,{className:`text-yellow-700 dark:text-yellow-400`,children:i(`projectDetail.queue.printing`,{count:$.in_progress_prints})}),$.queued_prints>0&&(0,b.jsx)(`span`,{className:`text-bambu-gray`,children:i(`projectDetail.queue.queued`,{count:$.queued_prints})})]})]})}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,b.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,b.jsx)(d,{className:`w-5 h-5`}),i(`projectDetail.prints.title`,{count:Ke?.length||0})]})}),qe?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,b.jsx)(u,{className:`w-6 h-6 animate-spin text-bambu-green`})}):(0,b.jsx)(Be,{archives:Ke||[],t:i})]}),He&&(0,b.jsx)(Ie,{t:i,currencySymbol:R,project:{...A,archive_count:$?.total_archives||0,total_items:$?.total_items||0,completed_count:$?.completed_prints||0,failed_count:$?.failed_prints||0,queue_count:$?.queued_prints||0,progress_percent:$?.progress_percent||null,child_count:A.children?.length??0,archives:[]},onClose:()=>w(!1),onSave:e=>z.mutate(e),isLoading:z.isPending}),J.isOpen&&(0,b.jsx)(De,{title:J.title,message:J.message,confirmText:i(`common.delete`),variant:`danger`,onConfirm:J.onConfirm,onCancel:()=>Y(e=>({...e,isOpen:!1}))}),D&&(0,b.jsx)(ce,{mode:`create`,libraryFileId:D.id,archiveName:D.print_name||D.filename,projectId:k,onClose:()=>O(null),onSuccess:()=>{O(null),p.invalidateQueries({queryKey:[`archives`]}),p.invalidateQueries({queryKey:[`queue`]})}})]})}export{C as ProjectDetailPage};
|