import{u as w,ce as D,v as Q,y as B,cV as R,a as E,ca as F,fa as $,j as e,C as q,f7 as A,B as H,bQ as O,c1 as V,cX as x,cd as i,S as p}from"./bundle.CHKSNOJF.js";import{u as G}from"./useScrollToLineItem-sxrHkdu2.js";import{C as M}from"./ClientSelector-BbBNOaqF.js";import{u as U,I as X,a as z}from"./useProductColumns-DDQWs8XU.js";import{u as J,Q as K,a as W}from"./useProductQuoteColumns-DdidO12w.js";import{u as Y,T as Z}from"./TasksTabLabel-DmAIy7nE.js";import{H as ee}from"./HiddenResourceTaxesAlert-C69Wv9gV.js";import{T as se}from"./TaxDataBadge-Bjb17WSy.js";import{T as te}from"./TaxExemptBadge-C-aioGkw.js";import"./UserUnsubscribedTooltip-CmrNR5P-.js";import"./ClientActionButtons-q9eajqVG.js";import"./InvoiceViewer-DkbHIsNq.js";import"./PaymentTermsTooltip-BYtyFn5d.js";function he(){const[o]=w(),[C]=D(),h=Q(),f=B(),j=R(),{quote:s,errors:r,isDefaultTerms:y,isDefaultFooter:g,client:a,setIsDefaultFooter:T,setIsDefaultTerms:v,invoiceSum:_}=j,l=E(),I=Y(),b=U(),k=J(),S=F();G(!!(s&&a));const{handleChange:n,handleInvitationChange:L,handleLineItemChange:c,handleLineItemPropertyChange:m,handleCreateLineItem:u,handleDeleteLineItem:d,handleContactCanSignChange:N}=$({client:a});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-12 gap-4",children:[e.jsx(q,{className:"col-span-12 xl:col-span-4 h-max px-6 py-2 shadow-sm",style:{borderColor:l.$24},children:e.jsxs("div",{className:"flex flex-col space-y-4",children:[s&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-9",children:[e.jsx("span",{className:"text-sm font-medium",style:{color:l.$22},children:o("status")}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(A,{entity:s}),s&&s.sync?.dn_completed&&s.sync?.invitations[0]?.dn_id&&e.jsx(H,{variant:"green",style:{backgroundColor:S.$3},children:e.jsx(O,{className:"font-medium",to:`/docuninja/${s.sync?.invitations[0]?.dn_id}`,children:o("signed_document")})})]})]}),e.jsx(te,{isTaxExempt:!!s.client?.is_tax_exempt})]}),e.jsx(M,{resource:s,onChange:t=>n("client_id",t),onClearButtonClick:()=>n("client_id",""),onLocationChange:t=>n("location_id",t),onContactCheckboxChange:L,onContactCanSignCheckboxChange:N,errorMessage:r?.errors.client_id,textOnly:!0,readonly:!0,afterClientName:e.jsx(se,{resource:s})})]})}),e.jsx(K,{handleChange:n,errors:r}),e.jsxs("div",{className:"col-span-12",children:[s&&e.jsx(ee,{className:"mb-2",resource:s}),e.jsxs(V,{tabs:[o("products"),o("tasks")],defaultTabIndex:C.get("table")==="tasks"?1:0,formatTabLabel:t=>{if(t===1)return e.jsx(Z,{lineItems:s?.line_items||[]})},children:[e.jsx("div",{children:s&&a?e.jsx(x,{type:"product",resource:s,items:s.line_items.filter(t=>t.type_id===i.Product),columns:h?.settings.sync_invoice_quote_columns?b:k,relationType:"client_id",onLineItemChange:c,onSort:t=>n("line_items",t),onLineItemPropertyChange:m,onCreateItemClick:()=>u(i.Product),onDeleteRowClick:d}):e.jsx(p,{})}),e.jsx("div",{children:s&&a?e.jsx(x,{type:"task",resource:s,items:s.line_items.filter(t=>t.type_id===i.Task),columns:I,relationType:"client_id",onLineItemChange:c,onSort:t=>n("line_items",t),onLineItemPropertyChange:m,onCreateItemClick:()=>u(i.Task),onDeleteRowClick:d}):e.jsx(p,{})})]})]}),e.jsx(W,{handleChange:n,errors:r,isDefaultFooter:g,isDefaultTerms:y,setIsDefaultFooter:T,setIsDefaultTerms:v}),s&&e.jsx(X,{relationType:"client_id",resource:s,invoiceSum:_,onChange:(t,P)=>n(t,P)})]}),f?.show_pdf_preview&&e.jsx("div",{className:"my-4",children:s&&e.jsx(z,{for:"invoice",resource:s,entity:"quote",relationType:"client_id",endpoint:"/api/v1/live_preview?entity=:entity",withRemoveLogoCTA:!0,observable:!0,initiallyVisible:!1})})]})}export{he as default};
