1import{r as y,j as e,I as i}from"./index-Dax1O5zv.js";import"./vendor-firebase-COTvcdYZ.js";const E=["Conditional Partial","Unconditional Partial","Conditional Final","Unconditional Final"],L={"Conditional Partial":"Waives lien rights for payments received to date, once payment clears","Unconditional Partial":"Permanently waives lien rights for payments received to date","Conditional Final":"Waives all lien rights once final payment clears","Unconditional Final":"Permanently waives all lien rights â payment confirmed"},m={pending:{badge:"bg-amber-100 text-amber-700 border-amber-200",dot:"bg-amber-400",label:"Pending",icon:"schedule"},received:{badge:"bg-blue-100 text-blue-700 border-blue-200",dot:"bg-blue-400",label:"Received",icon:"mark_email_read"},signed:{badge:"bg-green-100 text-green-700 border-green-200",dot:"bg-green-500",label:"Signed",icon:"check_circle"}},A=[{value:"plumbing",label:"Plumbing",icon:"plumbing"},{value:"framing",label:"Framing",icon:"foundation"},{value:"electrical",label:"Electrical",icon:"electrical_services"},{value:"hvac",label:"HVAC",icon:"heat_pump"},{value:"roofing",label:"Roofing",icon:"roofing"},{value:"concrete",label:"Concrete",icon:"deployed_code"},{value:"painting",label:"Painting",icon:"format_paint"},{value:"general",label:"General",icon:"construction"},{value:"other",label:"Other",icon:"category"}];function N(t){return A.find(l=>l.value===t)||{value:t||"other",label:t||"Other",icon:"category"}}function z(t){if(t===""||t===void 0||t===null)return"";const l=parseFloat(t);return isNaN(l)?"":"$"+l.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:2})}function b(t){if(!t)return"";try{return new Date(t+"T00:00:00").toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return t}}function $({waiver:t,milestones:l,onUpdate:r,onRemove:x,readOnly:a}){const[d,j]=y.useState(!t.contractor),u=m[t.status]??m.pending;return l.find(n=>n.id===t.milestoneId),e.jsxs("div",{className:"bg-white rustic-border rounded-xl overflow-hidden shadow-sm transition-all hover:shadow-md",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 items-center px-6 lg:px-8 py-5 gap-3 md:gap-4",children:[e.jsxs("div",{className:"col-span-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-surface-container-low flex items-center justify-center text-primary-container shrink-0",children:e.jsx(i,{name:N(t.trade).icon,size:18})}),e.jsxs("div",{className:"min-w-0",children:[a?e.jsx("p",{className:"w-full text-sm font-semibold font-heading py-0.5 text-primary truncate",children:t.contractor||e.jsx("span",{className:"text-outline italic",children:"No name"})}):e.jsx("input",{type:"text",value:t.contractor,onChange:n=>r({contractor:n.target.value}),placeholder:"Contractor / subcontractor name...",className:"w-full text-sm font-semibold font-heading bg-transparent border-b border-transparent hover:border-outline-variant focus:border-primary focus:outline-none py-0.5 text-primary truncate"}),e.jsx("p",{className:"text-xs text-outline mt-0.5 truncate",children:t.type})]})]}),e.jsx("div",{className:"col-span-2 text-sm font-medium font-heading text-primary",children:t.amount?z(t.amount):e.jsx("span",{className:"text-outline italic",children:"--"})}),e.jsx("div",{className:"col-span-2 flex justify-center",children:e.jsxs("span",{className:`px-3 py-1 rounded-full text-xs font-semibold flex items-center gap-1 ${u.badge} border`,children:[e.jsx(i,{name:u.icon,size:14,filled:t.status==="signed"}),u.label]})}),e.jsx("div",{className:"col-span-2 text-sm text-outline font-heading",children:t.status==="signed"&&t.dateReceived?b(t.dateReceived):t.status==="pending"?e.jsx("span",{className:"italic text-amber-500",children:"Awaiting Sign"}):t.dateReceived?b(t.dateReceived):e.jsx("span",{className:"text-outline",children:"--"})}),e.jsxs("div",{className:"col-span-2 flex justify-end gap-1.5 items-center",children:[!a&&t.status==="pending"&&e.jsx("button",{onClick:()=>r({status:"received"}),className:"px-3 py-1.5 bg-primary-container text-on-primary-container rounded text-xs font-heading font-medium hover:bg-primary hover:text-on-primary transition-colors whitespace-nowrap",children:"Sign Now"}),!a&&t.status==="received"&&e.jsx("button",{onClick:()=>r({status:"signed"}),className:"px-3 py-1.5 bg-green-600 text-white rounded text-xs font-heading font-medium hover:bg-green-700 transition-colors whitespace-nowrap",children:"Mark Signed"}),t.status==="signed"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"p-1.5 text-outline hover:text-primary transition-colors","aria-label":"View",children:e.jsx(i,{name:"visibility",size:18})}),e.jsx("button",{className:"p-1.5 text-outline hover:text-primary transition-colors","aria-label":"Download",children:e.jsx(i,{name:"download",size:18})})]}),!a&&t.status!=="pending"&&e.jsx("button",{onClick:()=>r({status:"pending"}),className:"text-outline hover:text-on-surface transition-colors p-1.5","aria-label":"Reset to Pending",children:e.jsx(i,{name:"restart_alt",size:16})}),e.jsx("button",{onClick:()=>j(!d),className:"text-outline hover:text-on-surface transition-colors p-1.5","aria-label":d?"Collapse":"Expand",children:e.jsx(i,{name:d?"expand_less":"expand_more",size:18})}),!a&&e.jsx("button",{onClick:x,className:"text-red-300 hover:text-red-500 transition-colors p-1.5","aria-label":"Remove",children:e.jsx(i,{name:"delete",size:16})})]})]}),d&&e.jsxs("div",{className:"px-6 lg:px-8 pb-5 border-t border-outline-variant pt-4 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-outline mb-1 block",children:"Trade"}),a?e.jsx("p",{className:"w-full text-sm px-3 py-1.5",children:N(t.trade).label}):e.jsx("select",{value:t.trade||"general",onChange:n=>r({trade:n.target.value}),className:"w-full text-sm border border-outline-variant rounded-xl px-3 py-1.5 bg-surface focus:outline-none focus:ring-1 focus:ring-primary/40",children:A.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-outline mb-1 block",children:"Waiver Type"}),a?e.jsx("p",{className:"w-full text-sm px-3 py-1.5",children:t.type}
1):e.jsx("select",{value:t.type,onChange:n=>r({type:n.target.value}),className:"w-full text-sm border border-outline-variant rounded-xl px-3 py-1.5 bg-surface focus:outline-none focus:ring-1 focus:ring-primary/40",children:E.map(n=>e.jsx("option",{children:n},n))}),t.type&&e.jsx("p",{className:"text-xs text-outline mt-1 italic",children:L[t.type]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-outline mb-1 block",children:"Amount Covered ($)"}),a?e.jsx("p",{className:"w-full text-sm px-3 py-1.5",children:t.amount?z(t.amount):"--"}):e.jsx("input",{type:"number",min:"0",value:t.amount,onChange:n=>r({amount:n.target.value}),placeholder:"0",className:"w-full text-sm border border-outline-variant rounded-xl px-3 py-1.5 bg-surface focus:outline-none focus:ring-1 focus:ring-primary/40"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-outline mb-1 block",children:"Through Date"}),a?e.jsx("p",{className:"w-full text-sm px-3 py-1.5",children:t.throughDate?b(t.throughDate):"--"}):e.jsx("input",{type:"date",value:t.throughDate,onChange:n=>r({throughDate:n.target.value}),className:"w-full text-sm border border-outline-variant rounded-xl px-3 py-1.5 bg-surface focus:outline-none focus:ring-1 focus:ring-primary/40"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-outline mb-1 block",children:"Date Received"}),a?e.jsx("p",{className:"w-full text-sm px-3 py-1.5",children:t.dateReceived?b(t.dateReceived):"--"}):e.jsx("input",{type:"date",value:t.dateReceived,onChange:n=>r({dateReceived:n.target.value}),className:"w-full text-sm border border-outline-variant rounded-xl px-3 py-1.5 bg-surface focus:outline-none focus:ring-1 focus:ring-primary/40"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-outline mb-1 block",children:"Linked Draw / Milestone"}),a?e.jsx("p",{className:"w-full text-sm px-3 py-1.5",children:t.milestoneId?l.find(n=>n.id===t.milestoneId)?.title||t.milestoneId:t.drawRef||"--"}):l.length>0?e.jsxs("select",{value:t.milestoneId,onChange:n=>r({milestoneId:n.target.value}),className:"w-full text-sm border border-outline-variant rounded-xl px-3 py-1.5 bg-surface focus:outline-none focus:ring-1 focus:ring-primary/40",children:[e.jsx("option",{value:"",children:"-- none --"}),l.map(n=>e.jsxs("option",{value:n.id,children:[n.title,n.done||n.progress>=100?" â":""]},n.id))]}):e.jsx("input",{type:"text",value:t.drawRef,onChange:n=>r({drawRef:n.target.value}),placeholder:"Draw #, invoice ref...",className:"w-full text-sm border border-outline-variant rounded-xl px-3 py-1.5 bg-surface focus:outline-none focus:ring-1 focus:ring-primary/40"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-outline mb-1 block",children:"Status"}),a?e.jsx("span",{className:`text-xs px-3 py-1 rounded-full border ${m[t.status]?.badge} font-semibold`,children:m[t.status]?.label||t.status}):e.jsx("div",{className:"flex gap-2 flex-wrap",children:Object.keys(m).map(n=>e.jsx("button",{onClick:()=>r({status:n}),className:`text-xs px-3 py-1 rounded-full border transition-colors ${t.status===n?m[n].badge+" font-semibold":"border-outline-variant text-outline hover:border-primary hover:text-primary"}`,children:m[n].label},n))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-outline mb-1 block",children:"Notes"}),a?e.jsx("p",{className:"w-full text-sm px-3 py-1.5",children:t.notes||"--"}):e.jsx("input",{type:"text",value:t.notes,onChange:n=>r({notes:n.target.value}),placeholder:"Storage location, notary, exceptions...",className:"w-full text-sm border border-outline-variant rounded-xl px-3 py-1.5 bg-surface focus:outline-none focus:ring-1 focus:ring-primary/40"})]})]})]})}const q=["All","Pending","Received","Signed"];function B({project:t,updateProject:l,member:r,readOnly:x}){const a=!!r,[d,j]=y.useState("All"),[u,n]=y.useState(!1),o=t?.lienWaivers??[],D=t?.timeline?.milestones??[];function w(){l({lienWaivers:[...o,{id:`lien_${Date.now()}_${Math.random().toString(36).slice(2)}`,contractor:"",type:"Conditional Partial",trade:"general",amount:"",throughDate:"",dateReceived:"",milestoneId:"",drawRef:"",status:"pending",notes:""}]})}
1function P(s,c){l({lienWaivers:o.map(g=>g.id===s?{...g,...c}:g)})}function T(s){confirm("Remove this lien waiver?")&&l({lienWaivers:o.filter(c=>c.id!==s)})}function W(){l({lienWaivers:o.map(s=>s.status==="pending"?{...s,status:"received"}:s)})}const p=o.filter(s=>s.status==="pending").length,I=o.filter(s=>s.status==="received").length,C=o.filter(s=>s.status==="signed").length,v=o.length,k=v>0?Math.round(C/v*100):0,R=d.toLowerCase(),S=R==="all"?o:o.filter(s=>s.status===R),h={};S.forEach(s=>{const c=s.trade||"general";h[c]||(h[c]=[]),h[c].push(s)});const _=new Set(o.map(s=>s.trade||"general"));return e.jsxs("div",{className:a?"max-w-7xl mx-auto":"px-4 md:px-12 py-12 pb-32 max-w-7xl mx-auto",children:[!a&&e.jsxs("div",{className:"mb-10 flex flex-col md:flex-row md:items-end justify-between gap-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-headline-lg text-headline-lg text-primary",children:"Lien Waivers"}),e.jsx("p",{className:"font-body-lg text-body-lg text-on-surface-variant max-w-2xl",children:"Review and manage legal clearances for all active trades. Ensure all contractors have signed the necessary documentation before proceeding with payments."})]}),e.jsxs("div",{className:"flex gap-3 shrink-0",children:[e.jsxs("button",{onClick:()=>n(!u),className:"px-5 py-2.5 bg-white rustic-border text-primary-container rounded-lg font-heading text-sm font-medium hover:bg-surface-container-low transition-colors flex items-center gap-2",children:[e.jsx(i,{name:"filter_list",size:18}),"Filter"]}),!x&&p>0&&e.jsxs("button",{onClick:W,className:"px-5 py-2.5 bg-primary-container text-on-primary-container rounded-lg font-heading text-sm font-medium hover:bg-primary hover:text-on-primary transition-all shadow-sm flex items-center gap-2",children:[e.jsx(i,{name:"edit_square",size:18}),"Sign Pending"]}),!x&&e.jsxs("button",{onClick:w,className:"px-5 py-2.5 bg-primary text-on-primary rounded-lg font-heading text-sm font-medium hover:bg-primary-dim transition-colors flex items-center gap-2",children:[e.jsx(i,{name:"add",size:18}),"Add Waiver"]})]})]}),a&&e.jsxs("div",{className:"flex items-center gap-2 bg-primary/5 border border-primary/20 rounded-xl px-4 py-3 mb-6 text-sm text-primary",children:[e.jsx(i,{name:"sync",size:16})," Changes you make here sync to the project owner in real time."]}),u&&e.jsx("div",{className:"flex gap-2 mb-6 flex-wrap",children:q.map(s=>{const c=s==="All"?o.length:s==="Pending"?p:s==="Received"?I:C;return e.jsxs("button",{onClick:()=>j(s),className:`text-xs px-4 py-1.5 rounded-full border transition-colors font-heading font-medium ${d===s?"bg-primary text-on-primary border-primary":"border-outline-variant text-on-surface-variant hover:border-primary hover:text-primary"}`,children:[s," ",e.jsxs("span",{className:"opacity-60",children:["(",c,")"]})]},s)})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 mb-10",children:[e.jsxs("div",{className:"bg-white p-7 rounded-xl rustic-border soft-elevation flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-outline uppercase tracking-widest mb-1",children:"Total Requests"}),e.jsx("h3",{className:"text-4xl font-bold text-primary font-heading",children:String(v).padStart(2,"0")})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-2 text-outline",children:[e.jsx(i,{name:"assignment",size:16}),e.jsxs("span",{className:"text-sm",children:["Across ",_.size," active trade",_.size!==1?"s":""]})]})]}),e.jsxs("div",{className:"bg-amber-50 p-7 rounded-xl border border-amber-200 shadow-sm flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-amber-700 uppercase tracking-widest mb-1",children:"Action Required"}),e.jsx("h3",{className:"text-4xl font-bold text-amber-700 font-heading",children:String(p).padStart(2,"0")})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-2 text-amber-600",children:[e.jsx(i,{name:"pending_actions",size:16}),e.jsx("span",{className:"text-sm",children:"Awaiting digital signature"})]})]}),e.jsxs("div",{className:"bg-green-50 p-7 rounded-xl border border-green-200 shadow-sm flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-primary-container uppercase tracking-widest mb-1",children:"Compliance Rate"}),e.jsxs("h3",{className:"text-4xl font-bold text-primary-container font-heading",children:[k,"%"]})]}),e.jsx("div",{className:"mt-4 w-full bg-stone-200 h-1.5 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-primary-container h-full rounded-full transition-all duration-500",style:{width:`${k}%`}})})]})]}),p>0&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-xl p-4 mb-6 text-sm text-amber-700 flex items-center gap-3",children:[e.jsx(i,{name:"warning",size:20,className:"text-amber-500 shrink-0"}),e.jsxs("span",{children:[e.jsxs("strong",{children:[p," waiver",p!==1?"s":""," pending."]})," Never release a draw payment without collecting the corresponding lien waiver."]})]}),o.length===0?e.jsxs("div",{className:"text-center py-20 text-outline",children:[e.jsx(i,{name:"shield",size:48,className:"mx-auto mb-4 text-outline-variant"}),e.jsx("p",{className:"font-medium font-heading text-lg text-on-surface",children:"No lien waivers tracked yet"}),e.jsx("p",{className:"text-sm mt-2 max-w-md mx-auto",children:"Add a waiver for each contractor draw. Never pay without collecting the corresponding waiver."}),!x&&e.jsxs("button",{onClick:w,className:"mt-6 px-6 py-2.5 bg-primary text-on-primary rounded-lg font-heading text-sm font-medium hover:bg-primary-dim transition-colors inline-flex items-center gap-2",children:[e.jsx(i,{name:"add",size:16})," Add First Waiver"]})]}):S.length===0?e.jsxs("div",{className:"text-center py-16 text-outline text-sm",children:["No ",d.toLowerCase()," waivers found."]}):e.jsx("div",{className:"space-y-8",children:Object.entries(h).map(([s,c])=>{const g=N(s);return e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-outline-variant pb-2",children:[e.jsx(i,{name:g.icon,size:22,className:"text-primary-container"}),e.jsx("h2",{className:"font-headline-md text-headline-md text-primary",children:g.label})]}),e.jsxs("div",{className:"hidden md:grid grid-cols-12 px-6 lg:px-8 py-2 text-outline text-xs font-semibold uppercase tracking-wider",children:[e.jsx("div",{className:"col-span-4",children:"Vendor Name"}),e.jsx("div",{className:"col-span-2",children:"Amount"}),e.jsx("div",{className:"col-span-2 text-center",children:"Status"}),e.jsx("div",{className:"col-span-2",children:"Date"}),e.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),e.jsx("div",{className:"grid grid-cols-1 gap-3",children:c.map(f=>e.jsx($,{waiver:f,milestones:D,onUpdate:F=>P(f.id,F),onRemove:()=>T(f.id),readOnly:x},f.id))})]},s)})})]})}export{B as default};
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.