1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/onboarding-flags-izowS2nh.js","assets/index-CbvCveKN.js","assets/index-DK9kCj9D.css","assets/trialReward-wcwnIT18.js","assets/onboardingEvents-iM3xWPll.js"])))=>i.map(i=>d[i]); 2import{A as tt,ab as at,k as st,D as rt,r as n,o as $,ao as ot,ad as it,ae as nt,K as j,ak as lt,aj as ct,ap as Se,aq as R,aa as dt,j as e,B as b,z as I,I as X,ah as S,af as ke,a7 as mt,T as ut,U as pt,W as xt,X as ht,_ as Te}from"./index-CbvCveKN.js";import{m as ft,o as gt,n as bt,u as Z,A as vt,c as yt}from"./ActivityFeed-DKSo_sMt.js";import{D as ee,P as jt,e as Nt,E as wt}from"./PageContainer-Bx7SVsdy.js";import{S as _t,a as St}from"./SyncConflictPanel-DL18mOYT.js";import{e as U,L as Ce,C as De}from"./CopyToJobButton-H3qaDm1t.js";import{d as kt}from"./EstimateDocument-D2NBvf9z.js";import{T as Tt}from"./textarea-BGGCYgxW.js";import{P as Ct}from"./PageHeader-ohyr15TW.js";import{S as Dt}from"./SegmentedChoice-Cxa00exZ.js";import{buildEstimatePdf as Ee}from"./estimatePdf-BnRXCDbF.js";import{A as Et,a as Ft,b as Lt,c as Pt,d as Rt,e as At,g as Mt}from"./alert-dialog-BsECSXvh.js";import{S as Bt,u as $t}from"./use-haptic-feedback-8KWyHBMH.js";import{F as It}from"./file-text-DDhZ7a0t.js";import{S as Ot}from"./save-gxAHJ6k7.js";import{D as Fe}from"./download-q_CUCbMH.js";import{S as Le}from"./send-gD9LtlB-.js";import{f as Wt}from"./format-BZAqQT85.js";import"./index-Jf4OHjGl.js";import"./index-CKxf6gP2.js";import"./external-link-DtZsaCxu.js";import"./chevron-down-yKD6BMcU.js";import"./check-Bjw6cCk6.js";import"./chevron-right-f4vsMuAf.js";import"./triangle-alert-BJBV5PBt.js";import"./en-US-wdCzBwgh.js";import"./plus-kYCBPFxU.js";import"./users-BkZzL3s4.js";import"./layout-dashboard-rEexJXnQ.js";import"./ek-mark-light-Y4_w-cFG.js";import"./parseISO-B0WEjCD3.js";import"./plug-BAhKXAxN.js";import"./appUrl-DO9lm0kM.js";import"./checkbox-DibQEMjb.js";import"./index-DlFerWUd.js";import"./paperclip-DvFV8ZAn.js";import"./copy-Bx-FLJpv.js";import"./jobs-BslETRXA.js";import"./git-branch-C91jhlNs.js";import"./radio-group-D0jdXhCj.js";import"./briefcase-DS6QnX-j.js";import"./arrow-right-dw9dfM3J.js";import"./jspdf.es.min-CH-oufHI.js";import"./differenceInCalendarDays-BmAYwV3_.js";/** 3 * @license lucide-react v0.462.0 - ISC 4 * 5 * This source code is licensed under the ISC license. 6 * See the LICENSE file in the root directory of this source tree. 7 */const qt=tt("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),La=()=>{const{id:i}=at(),A=st(),te=rt(),{triggerHaptic:k}=$t(),[s,V]=n.useState(null),[v,Pe]=n.useState([]),[x,Re]=n.useState([]),[Ae,Me]=n.useState(!0),[Be,ae]=n.useState(!1),[$e,T]=n.useState(!1),[Ie,O]=n.useState(!1),[h,se]=n.useState(0),[y,re]=n.useState(0),[_,oe]=n.useState(""),[Oe,ie]=n.useState(""),[We,H]=n.useState(!1),[J,ne]=n.useState(!1),[C,qe]=n.useState("30"),[le,ze]=n.useState("50% deposit required to schedule. Final 50% due upon completion."),[ce,Ue]=n.useState("1-year labor warranty. Equipment manufacturer warranty applies."),[m,Ve]=n.useState(null),[de,He]=n.useState({}),[D,Je]=n.useState(null),[me,Ye]=n.useState({primary:"#2563EB",secondary:"#10B981",accent:"#F59E0B"}),[ue,Ke]=n.useState(null),[N,pe]=n.useState("inherit"),[M,Y]=n.useState(""),[E,Qe]=n.useState({type:"none",value:50});n.useEffect(()=>{i&&xe()},[i]),n.useEffect(()=>{v.length>0&&G()},[v,h,y]);const xe=async()=>{try{const{data:{session:t}}=await $.auth.getSession();if(!((t==null?void 0:t.user)??null))throw new Error("Not authenticated");const r=await ot();r&&Ve({company_name:r.company_name,phone:r.phone,email:r.email,address:r.address,city:r.city,state:r.state,zip:r.zip,logo_url:r.logo_url});const o=await it();if(He(kt(o)),o){const c=o.pdf_color_mode==="bw";Ye(c?{primary:"#1F2937",secondary:"#4B5563",accent:"#6B7280"}:{primary:o.brand_color_primary||"#2563EB",secondary:o.brand_color_secondary||"#10B981",accent:o.brand_color_accent||"#F59E0B"}),Je({business_email:o.business_email,reply_to_email:o.reply_to_email,pdf_color_mode:o.pdf_color_mode||"branded"})}const u=await nt(i);
7if(["approved","completed","superseded"].includes(u.status)){j({title:"This estimate was approved and is locked.",description:"Use Revise to change it."}),A(`/estimates/${i}/view`,{replace:!0});return}V(u),typeof u.notes=="string"&&oe(u.notes||""),ie((u.notes??"").trim());{const c=u.deposit_type;(c==="none"||c==="percent"||c==="fixed"||c==="inherit")&&pe(c);const d=u.deposit_value;Y(d==null?"":String(d))}const p=Number(u.materials_tax_rate),l=Number(u.labor_tax_rate);isNaN(p)||se(p),isNaN(l)||re(l);const z=await lt(i);Pe(z||[]);const L=await ct(i).catch(()=>null);L&&Re(L.map(c=>({id:c.id,title:c.title,description:c.description,is_recommended:c.is_recommended??!1,subtotal:Number(c.subtotal)||0,tax_amount:Number(c.tax_amount)||0,total:Number(c.total)||0,tier_number:c.tier_number})));const g=await Se(i);o&&(qe((o.default_valid_for_days||30).toString()),Qe({type:o.default_deposit_type||"none",value:Number(o.default_deposit_value??50)}),ze(o.default_payment_terms||"50% deposit required to schedule. Final 50% due upon completion."),Ue(o.default_warranty_info||"1-year labor warranty. Equipment manufacturer warranty applies."));const w=await $.from("jobs").select("id, job_number").eq("estimate_id",i).order("created_at").limit(1).maybeSingle().then(c=>c.data,()=>null);Ke(w?{id:w.id,job_number:w.job_number}:null)}catch(t){console.error("Error fetching estimate data:",t),j({title:"Error",description:"Failed to load estimate",variant:"destructive"})}finally{Me(!1)}},B=()=>v.reduce((t,a)=>t+a.total,0),Ge=()=>v.filter(t=>!R(t.category)).reduce((t,a)=>t+a.total,0),Xe=()=>v.filter(t=>R(t.category)).reduce((t,a)=>t+a.total,0),he=()=>Ge()*(h/100),fe=()=>Xe()*(y/100),F=()=>he()+fe(),f=()=>B()+F(),W=x.length>1,ge=x.map(t=>{const a=v.filter(p=>p.tier_id===t.id),r=a.filter(p=>!R(p.category)).reduce((p,l)=>p+l.total,0),o=a.filter(p=>R(p.category)).reduce((p,l)=>p+l.total,0),u=r*(h/100)+o*(y/100);return{id:t.id,title:t.title,tax:u,total:r+o+u}}),K=()=>{if(x.length>1){const t=x.map(a=>Number(a.total)).filter(a=>a>0);return t.length>0?Math.min(...t):f()}return f()},be=()=>{if(x.length>1){const t=x.map(a=>Number(a.total)).filter(a=>a>0);return t.length>0?Math.max(...t):f()}return f()},ve=()=>x.length>1?x.length:1,Ze=async()=>{if(!s||!i)return null;try{const{base64:t,fileName:a}=await Ee(i,{materialsTaxRate:h,laborTaxRate:y,validForDays:C,additionalNotes:_});return{base64:t,fileName:a}}catch(t){return console.error("Error generating PDF for email:",t),null}},et=async(t,a,r,o,u,p)=>{if(je()&&!(!s||!i)){ne(!0);try{await G();let l=null;if(u&&(l=await Ze(),!l))throw new Error("Failed to generate PDF");const{data:{session:z}}=await $.auth.getSession();if(!z)throw new Error("Not authenticated");const L=(m==null?void 0:m.company_name)||"Your HVAC Contractor",g=(D==null?void 0:D.business_email)||(m==null?void 0:m.email)||"",w=(D==null?void 0:D.reply_to_email)||g,c=await $.functions.invoke("send-estimate",{body:{estimateId:i,recipientEmail:t,recipientName:a||void 0,personalMessage:r||void 0,emailSubject:o||void 0,pdfBase64:(l==null?void 0:l.base64)||void 0,pdfFileName:(l==null?void 0:l.fileName)||void 0,contractorBusinessName:L,contractorEmail:g,contractorPhone:(m==null?void 0:m.ph
7one)||void 0,replyToEmail:w,jobDescription:s.job_description||void 0,estimateTotal:K(),minTotal:K(),maxTotal:be(),optionCount:ve(),sendCopyToContractor:p,items:v.map(d=>{var P;return{id:d.id,item_name:d.item_name||((P=d.material)==null?void 0:P.item_name)||`${d.category} Item`,item_description:d.item_description||void 0,category:d.category,quantity:d.quantity,sell_price:d.unit_cost,total:d.total}}),settings:{subtotal:B(),tax_percentage:h,tax_amount:F(),total:f()}}});if(c.error)throw new Error(c.error.message||"Failed to send email");$.auth.getSession().then(({data:{session:d}})=>{d!=null&&d.user.email&&t.trim().toLowerCase()!==d.user.email.toLowerCase()&&(Te(()=>import("./onboarding-flags-izowS2nh.js"),__vite__mapDeps([0,1,2])).then(P=>P.markOnboardingFlag("has_sent_estimate")),Te(()=>import("./trialReward-wcwnIT18.js"),__vite__mapDeps([3,1,2,4])).then(P=>P.announceTrialReward()))}),V(d=>d?{...d,status:"sent"}:null),await yt(i,"sent",`Estimate sent to ${t}`,{recipient_email:t,total:f()}),await te.invalidateQueries({queryKey:["all-estimates"]}),j({title:"Estimate sent",description:`Estimate sent to ${t}`}),T(!1),A(`/estimates/${i}/view`)}catch(l){console.error("Error sending estimate:",l),j({title:"Failed to send",description:l instanceof Error?l.message:"Please try again.",variant:"destructive"})}finally{ne(!1)}}},ye=async(t,a)=>{if(!i)return;const r=a===""?null:Number(a);try{await Z(i,{deposit_type:t,deposit_value:t==="percent"||t==="fixed"?r==null||isNaN(r)?null:r:null},"Save deposit rule")}catch(o){j({title:"Couldn't save the deposit rule",description:o.message,variant:"destructive"})}},Q=t=>{const a=N==="inherit"?E.type:N,r=N==="inherit"?E.value:Number(M||0);return a==="percent"?Math.round(t*r)/100:a==="fixed"?Math.min(r,t):0},G=async()=>{try{const t={estimate_id:i,markup_percentage:0,tax_percentage:h,subtotal:B(),markup_amount:0,tax_amount:F(),total:f()};await Se(i).catch(()=>null)?await ft(i,t):await gt(i,{id:bt(),...t})}catch(t){console.error("Error saving settings:",t)}},{requireWrite:je}=dt(),Ne=async t=>{if(je()){k("success"),ae(!0);try{await G();const a=(s==null?void 0:s.status)||"draft";t==="draft"&&a!=="draft"&&(t=a);const r={status:t,tax_rate:h,materials_tax_rate:h,labor_tax_rate:y};t==="sent"&&(r.updated_at=new Date().toISOString()),await Z(i,r,t==="draft"?"Save draft":"Save changes"),await te.invalidateQueries({queryKey:["all-estimates"]}),j({title:"Saved",description:t==="draft"?"Saved as a draft.":t==="sent"?"Changes saved. The customer's link shows the latest version.":"Changes saved."}),s&&V({...s,status:t})}catch(a){console.error("Error updating estimate:",a);const r=a instanceof Error?a.message:String((a==null?void 0:a.message)||"");j({title:/locked/i.test(r)?"This estimate was approved and is locked.":"Error",description:/locked/i.test(r)?"Use Revise to change it.":"Failed to update estimate",variant:"destructive"})}finally{ae(!1)}}},we=async()=>{if(k("medium"),!(!s||!m))try{const{blob:t,fileName:a}=await Ee(i,{materialsTaxRate:h,laborTaxRate:y,validForDays:C,additionalNotes:_}),r=URL.createObjectURL(t),o=document.createElement("a");o.href=r,o.download=a,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r),await Ne("draft"),j({title:"PDF downloaded",description:`Estimate ${U(s)} is saved.`})}catch(t){console.error("Error generating PDF:",t),j({title:"Error",description:"Failed to generate PDF. Please try again.",variant:"destructive"})}};if(Ae)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(ee,{}),e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("p",{className:"text-muted-foreground",children:"Loading estimateâ¦"})})]});if(!s)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(ee,{}),e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("p",{className:"text-muted-foreground",children:"Estimate not found"})})]});const q="rounded-xl border border-ink/[0.06] bg-card p-5",_e="text-[12.5px] font-normal text-foreground-secondary";return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(ee,{}),e.jsxs(jt,{width:"full",className:"pb-40 md:pb-[72px]",children:[e.jsx(Ct,{className:"mb-5 md:mb-6",title:"Preview & options",badge:e.jsx(Nt,{id:i}),description:"Tax, deposit and notes for this estimate, and the PDF your customer gets.",backTo:`/estimates/${i}/add-items`,backLabel:s?U(s):"Estimate",area:"estimates",icon:It,crumb:"Preview & options"}),e.jsx(_t,{estimateId:i,onResolved:()=>{xe()}}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsx("div",{className:"order-2 hidden min-w-0 lg:order-1 lg:block",children:m&&e.jsx(Ce,{estimate:s,documentOptions:de,items:v,tiers:x,userProfile:m,brandColors:me,subtotal:B(),markup:0,tax:F(),total:f(),taxRate:h,materialsTaxRate:h,laborTaxRate:y,paymentTerms:le,warrantyInfo:ce,validForDays:C,additionalNotes:_})}),e.jsx("div",{className:"order-2 lg:hidden",children:e.jsxs(b,{variant:"outline",className:"h-12 w-full text-[14px]",onClick:()=>O(!0),children:[e.jsx(wt,{className:"mr-2 h-5 w-5",strokeWidth:1.8}),"Preview PDF"]})}),e.jsx("div",{className:"order-1 min-w-0 lg:order-2",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:sticky lg:top-6",children:[e.jsx("h3",{className:"text-[15px] font-semibold",children:"For this estimate"}),e.jsxs("div",{className:`${q} flex flex-col gap-4`,children:[e.jsx(I,{className:"text-[14px] font-semibold",children:"Sales tax"}),e.jsxs("div",{className:"flex items-end justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(I,{htmlFor:"materialsTaxRate",className:_e,children:"Materials tax"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{id:"materialsTaxRate",type:"number",min:"0",max:"100",step:"0.01",value:h,onChange:t=>se(parseFloat(t.target.value)||0),className:"w-24 font-mono"}),e.jsx("span",{className:"text-sm text-foreground-secondary",children:"%"})]})]}),!W&&e.jsxs("p",{className:"pb-2.5 text-[13px] text-foreground-secondary",children:["Tax: ",e.jsxs("span",{className:"font-mono text-foreground",children:["$",he().toFixed(2)]})]})]}),e.jsxs("div",{className:"flex items-end justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(I,{htmlFor:"laborTaxRate",className:_e,children:"Labor tax"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{id:"laborTaxRate",type:"number",min:"0",max:"100",step:"0.01",value:y,onChange:t=>re(parseFloat(t.target.value)||0),className:"w-24 font-mono"}),e.jsx("span",{className:"text-sm text-foreground-secondary",children:"%"})]})]}),!W&&e.jsxs("p",{className:"pb-2.5 text-[13px] text-foreground-secondary",children:["Tax: ",e.jsxs("span",{className:"font-mono text-foreground",children:["$",fe().toFixed(2)]})]})]}),e.jsx("div",{className:"h-px bg-ink/[0.06]"}),W?e.jsx("div",{className:"flex flex-col gap-1.5",children:ge.map(t=>e.jsxs("p",{className:"flex justify-between gap-3 text-[13.5px] text-foreground-secondary",children:[e.jsxs("span",{className:"min-w-0 truncate",children:["Tax on ",t.title]}),e.jsx("span",{className:"font-mono font-medium text-foreground",children:S(t.tax)})]},t.id))}):e.jsxs("p",{className:"flex justify-between text-[13.5px] text-foreground-secondary",children:[e.jsx("span",{children:"Total tax"}),e.jsxs("span",{className:"font-mono font-medium text-foreground",children:["$",F().toFixed(2)]})]}),e.jsx("p",{className:"text-[12.5px] text-foreground-tertiary",children:"Your rates from Settings. Change them here for this estimate only."})]}),e.jsxs("div",{className:`${q} flex flex-col gap-3`,children:[e.jsx(I,{className:"text-[14px] font-semibold",children:"Deposit"}),e.jsx(Dt,{label:"Deposit rule",value:N,onChange:t=>{const a=t;pe(a),a==="percent"&&!M&&Y("50"),ye(a,M||(a==="percent"?"50":""))},options:[{value:"inherit",label:"Default"},{value:"none",label:"None"},{value:"percent",label:"Percent"},{value:"fixed",label:"Fixed"}]}),N==="inherit"&&e.jsxs("p",{className:"text-[12.5px] leading-relaxed text-foreground-secondary",children:["Your default is ",E.type==="none"?"no deposit":E.type==="fixed"?S(E.value):`${E.value}% of the approved total`,". Change it in Settings."]}),(N==="percent"||N==="fixed")&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm text-foreground-secondary",children:N==="percent"?"%":"$"}),e.jsx(X,{type:"number",inputMode:"decimal",min:0,value:M,onChange:t=>Y(t.target.value),onBlur:()=>ye(N,M),className:"h-10 w-28 font-mono"}),e.jsx("span",{className:"font-mono text-[12.5px] text-foreground-secondary",children:(()=>
7{if(!W)return Q(f())>0?`= ${S(Q(f()))} on this total`:"";const t=ge.map(o=>Q(o.total)).filter(o=>o>0);if(!t.length)return"";const a=Math.min(...t),r=Math.max(...t);return a===r?`= ${S(a)} on the chosen option`:`= ${S(a)} to ${S(r)}, by option`})()})]}),e.jsxs("p",{className:"text-[12.5px] leading-relaxed text-foreground-tertiary",children:["Shown on the approval page. When the customer approves, a deposit invoice is created for this amount."," ","Valid for ",C," days after sending (until ",Wt(new Date(Date.now()+Number(C||30)*864e5),"MMM d")," if sent today)."]})]}),e.jsxs("div",{className:`${q} flex flex-col gap-3`,children:[e.jsxs(I,{htmlFor:"notes",className:"text-[14px] font-semibold",children:["Notes ",e.jsx("span",{className:"font-normal text-foreground-tertiary",children:"Optional"})]}),e.jsx(Tt,{id:"notes",value:_,onChange:t=>oe(t.target.value),onBlur:async()=>{if(!i)return;const t=_.trim();if(t!==Oe)try{await Z(i,{notes:t||null},"Save notes"),ie(t)}catch(a){j({title:"Couldn't save notes",description:a.message,variant:"destructive"})}},rows:4,maxLength:500,placeholder:"Add any special notes, disclaimers, or additional terms hereâ¦",className:"resize-none"}),e.jsxs("p",{className:"text-right font-mono text-xs text-foreground-tertiary",children:[_.length,"/500 characters"]}),e.jsx("p",{className:"text-[12.5px] leading-relaxed text-foreground-tertiary",children:"Saved with the estimate. Shown on the preview, the customer's approval page, and the PDF"})]}),e.jsxs("div",{className:`${q} flex flex-col gap-4`,children:[e.jsx("p",{className:"font-mono text-[11.5px] uppercase tracking-[0.08em] text-foreground-tertiary",children:x.length>1?"Pricing options":"Total"}),x.length>1?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("div",{className:"flex flex-col gap-px overflow-hidden rounded-xl border border-ink/[0.06] bg-ink/[0.05]",children:x.map(t=>{const a=v.filter(g=>g.tier_id===t.id),r=a.filter(g=>!R(g.category)).reduce((g,w)=>g+w.total,0),o=a.filter(g=>R(g.category)).reduce((g,w)=>g+w.total,0),u=r*(h/100),p=o*(y/100),l=u+p,L=(t.subtotal||0)+l;return e.jsxs("div",{className:"flex items-center justify-between gap-3 bg-card px-4 py-3",children:[e.jsxs("span",{className:"min-w-0 text-[13.5px] font-semibold",children:[t.title,t.is_recommended&&e.jsx(Bt,{className:"ml-2 inline h-3.5 w-3.5 fill-cta-orange text-cta-orange",strokeWidth:1.8,"aria-label":"Recommended"})]}),e.jsxs("span",{className:"shrink-0 font-mono text-[14px] font-medium",children:["$",L.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]},t.id)})}),e.jsx("p",{className:"text-center text-[12.5px] text-foreground-tertiary",children:"Customer will choose one pricing option"})]}):e.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[e.jsx("span",{className:"text-[14px] font-semibold",children:"Total"}),e.jsx("span",{className:"font-mono text-[22px] font-medium tracking-[-0.02em]",children:S(f())})]}),e.jsx("div",{className:"h-px bg-ink/[0.06]"}),e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsxs(b,{variant:"outline",onClick:()=>{k("light"),Ne("draft")},disabled:Be,className:"h-11 md:h-9 w-full",children:[e.jsx(Ot,{className:"mr-2 h-4 w-4",strokeWidth:1.8}),s!=null&&s.status&&s.status!=="draft"?"Save changes":"Save as Draft"]}),e.jsxs(b,{variant:"outline",onClick:()=>{k("medium"),we()},className:"h-11 md:h-9 w-full",size:"lg",children:[e.jsx(Fe,{className:"mr-2 h-4 w-4",strokeWidth:1.8}),"Download PDF"]}),e.jsxs(b,{"data-write":!0,onClick:async()=>{k("success"),await ke("send",()=>T(!0))&&T(!0)},className:"h-[52px] w-full text-[14.5px]",size:"lg",disabled:J,children:[e.jsx(Le,{className:"mr-2 h-4 w-4",strokeWidth:1.8}),"Send to customer"]}),s&&e.jsx(De,{estimateId:i,estimateStatus:s.status,existingJob:ue,tiers:x.map(t=>({id:t.id,title:t.title,tier_number:t.tier_number,total:t.total||0,is_recommended:t.is_recommended})),approvedTierId:s.approved_tier_id,className:"h-11 md:h-9 w-full"})]})]}),e.jsxs(b,{variant:"ghost",onClick:()=>A(`/estimates/${i}/add-items`),className:"h-11 md:h-9 w-full text-foreground-secondary hover:text-foreground",children:[e.jsx(qt,{className:"mr-2 h-4 w-4",strokeWidth:1.8}),"Back to the estimate"]})]})})]}),i&&e.jsx("div",{className:"mt-8",children:e.jsx(vt,{estimateId:i})})]}),e.jsx(Et,{open:We,onOpenChange:H,children:e.jsxs(Ft,{children:[e.jsxs(Lt,{children:[e.jsxs(Pt,{className:"flex items-center gap-2",children:[e.jsx(mt,{className:"h-6 w-6 text-ok",strokeWidth:1.8,"aria-hidden":"true"}),"PDF Generated Successfully!"]}),e.jsxs(Rt,{className:"text-center py-4",children:["Estimate ",U(s)," has been saved and ready to send to your client."]})]}),e.jsxs(At,{className:"flex-col sm:flex-row sm:justify-center gap-2",children:[e.jsx(b,{variant:"outline",onClick:()=>A("/estimates"),className:"w-full sm:w-auto",children:"View in Estimates"}),e.jsx(b,{variant:"orange",onClick:()=>{H(!1),A("/estimates/new")},className:"w-full sm:w-auto",children:"Create Another"}),e.jsx(Mt,{onClick:()=>H(!1),className:"w-full sm:w-auto",children:"Close"})]})]})}),s&&e.jsx(St,{estimateNumber:U(s),open:$e,onOpenChange:T,onSend:et,defaultEmail:s.client_email||"",defaultName:s.client_name,estimateId:s.id,estimateTotal:f(),minTotal:K(),maxTotal:be(),optionCount:ve(),companyName:(m==null?void 0:m.company_name)||"Your Company",sending:J}),e.jsx(ut,{open:Ie,onOpenChange:O,children:e.jsx(pt,{className:"max-w-[100vw] w-full h-[100dvh] max-h-[100dvh] p-0 m-0 rounded-none border-0 bg-background overflow-hidden",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-ink/[0.06] bg-card p-4",children:[e.jsx(xt,{className:"text-[15px] font-semibold",children:"PDF preview"}),e.jsx(b,{variant:"ghost",size:"icon",onClick:()=>O(!1),className:"h-10 w-10",children:e.jsx(ht,{className:"h-5 w-5",strokeWidth:1.8})})]}
7),e.jsx("div",{className:"flex-1 overflow-auto p-2 touch-pan-x touch-pan-y touch-pinch-zoom",children:e.jsx("div",{className:"transform-gpu origin-top-left w-full",style:{transform:"scale(var(--pdf-scale, 0.48))",width:"calc(100% / var(--pdf-scale, 0.48))","--pdf-scale":"clamp(0.4, calc((100vw - 16px) / 800), 0.6)"},children:m&&s&&e.jsx(Ce,{estimate:s,documentOptions:de,items:v,tiers:x,userProfile:m,brandColors:me,subtotal:B(),markup:0,tax:F(),total:f(),taxRate:h,materialsTaxRate:h,laborTaxRate:y,paymentTerms:le,warrantyInfo:ce,validForDays:C,additionalNotes:_})})}),e.jsx("div",{className:"border-t border-ink/[0.06] bg-card p-4",children:e.jsx(b,{className:"w-full h-12",onClick:()=>O(!1),children:"Close preview"})})]})})}),e.jsxs("div",{className:"fixed left-0 right-0 z-40 flex gap-2 border-t border-ink/[0.06] bg-white/95 px-[18px] py-3 backdrop-blur md:hidden",style:{bottom:"calc(4rem + env(safe-area-inset-bottom))"},children:[e.jsx(b,{onClick:()=>we(),variant:"outline",className:"flex-1 h-12",children:e.jsx(Fe,{className:"h-4 w-4",strokeWidth:1.8})}),e.jsxs(b,{onClick:async()=>{k("success"),await ke("send",()=>T(!0))&&T(!0)},className:"flex-1 h-12",disabled:J,children:[e.jsx(Le,{className:"mr-2 h-4 w-4",strokeWidth:1.8}),"Send"]}),s&&(s.status==="sent"||s.status==="viewed"||s.status==="approved")&&e.jsx(De,{estimateId:i,estimateStatus:s.status,existingJob:ue,tiers:x.map(t=>({id:t.id,title:t.title,tier_number:t.tier_number,total:t.total,is_recommended:t.is_recommended})),approvedTierId:s.approved_tier_id})]})]})};export{La 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.