1import{a as E,u as S,Z as A,r as d,j as e,L as g,g as k,M as D,aA as P,y as T}from"./index-DelWp-6b.js";import{e as I}from"./useEInvoicing-D-U8BVw0.js";import{E as U,e as N,d as G}from"./documentPdf-DhIrqYvD.js";import{Z as L}from"./e-invoicing.types-DAL310GN.js";import{P as F}from"./printer-DiMIwXQt.js";import{D as R}from"./download-B0-Qxbs8.js";import"./useQuery-B9eAwr7I.js";import"./useMutation-CwYdRQCa.js";import"./Modal-XqSNGlu3.js";import"./jspdf.es.min-CdUpFh0h.js";import"./browser-Mn9bJN7n.js";import"./api.service-Lf-HmAnC.js";import"./unwrap-CuJafpqD.js";import"./crud.service-B2C_PX1U.js";import"./plus-BjX2r5pd.js";const m=t=>t?new Date(t).toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"numeric"}):"â";function o({value:t,expect:l}){const s=(t??"").trim().split(""),i=l?Array.from({length:Math.max(l,s.length)},(n,r)=>s[r]??""):s;return i.length===0?e.jsx("span",{className:"text-[11px] text-slate-400",children:"â"}):e.jsx("span",{className:"inline-flex gap-[2px]",children:i.map((n,r)=>e.jsx("span",{className:"w-[17px] h-[21px] flex items-center justify-center text-[11px] font-mono font-semibold",style:{border:"1px solid #cbd5e1",color:n?"#0f172a":"#cbd5e1"},children:n||"·"},r))})}function a({label:t,arabic:l,children:s,plain:i}){return e.jsxs("tr",{children:[e.jsx("td",{className:"align-middle w-[150px]",style:{padding:"6px 12px 6px 0"},children:e.jsx("span",{className:"block text-[10px] font-semibold text-slate-500 whitespace-nowrap",children:t})}),e.jsx("td",{className:"align-middle",style:{padding:"6px 0"},children:s??e.jsx("span",{className:"text-[11.5px] text-slate-900",children:(i==null?void 0:i.trim())||"â"})}),e.jsx("td",{className:"align-middle text-right w-[110px]",style:{padding:"6px 0 6px 12px"},children:e.jsx("span",{className:"block text-[10px] text-slate-500 whitespace-nowrap",dir:"rtl",children:l})})]})}function p({en:t,ar:l}){return e.jsxs("div",{className:"flex items-baseline justify-between px-3 py-1.5 mt-4 mb-1",style:{background:"#f1f5f9",borderTop:"1px solid #cbd5e1"},children:[e.jsx("span",{className:"text-[11px] font-bold text-slate-700 uppercase tracking-wide",children:t}),e.jsx("span",{className:"text-[11px] font-bold text-slate-600",dir:"rtl",children:l})]})}function Z({unit:t,companyName:l,logo:s}){return e.jsxs("div",{className:"doc-sheet bg-white text-slate-900",style:{width:794,minHeight:1123,padding:"46px 54px",fontFamily:"inherit"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-6",children:[e.jsx("table",{className:"text-[10px]",style:{border:"1px solid #94a3b8"},children:e.jsx("tbody",{children:[["Unit Code",t.code,"ÙÙØ¯ اÙÙØØ¯Ø©"],["Certificate Issued",m(t.productionCsidIssuedAt),"ØªØ§Ø±ÙØ® Ø§ÙØ¥ØµØ¯Ø§Ø±"],["Certificate Expires",m(t.productionCsidExpiresAt),"ØªØ§Ø±ÙØ® Ø§ÙØ§ÙØªÙØ§Ø¡"]].map(([i,n,r])=>e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"4px 10px"},children:e.jsx("span",{className:"text-[10px] font-semibold text-slate-600 whitespace-nowrap",children:i})}),e.jsx("td",{style:{padding:"4px 10px"},children:e.jsx("span",{className:"text-[10px] font-mono text-slate-900 whitespace-nowrap",children:n})}),e.jsx("td",{style:{padding:"4px 10px"},children:e.jsx("span",{className:"text-[10px] text-slate-500 whitespace-nowrap",dir:"rtl",children:r})})]},i))})}),e.jsx("div",{className:"text-right shrink-0",children:s?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:s,alt:"",style:{maxHeight:44,maxWidth:160,objectFit:"contain",marginInlineStart:"auto"}}),e.jsx("p",{className:"text-[10px] text-slate-400 mt-1",children:l})]}):e.jsx("p",{className:"text-lg font-black tracking-tight text-slate-800",children:l})})]}),e.jsxs("div",{className:"text-center mt-7 mb-1",children:[e.jsx("h1",{className:"text-[15px] font-bold text-slate-800",children:"EGS Unit â ZATCA Registration"}),e.jsx("p",{className:"text-[13px] text-slate-600 mt-0.5",dir:"rtl",children:"ÙØØ¯Ø© إصدار اÙÙÙØ§ØªÙر â Ø§ÙتسجÙÙ Ù
ع ÙÙØ¦Ø© Ø§ÙØ²Ùاة ÙØ§ÙØ¶Ø±ÙØ¨Ø©"})]}),e.jsx(p,{en:"Unit Details",ar:"Ø¨ÙØ§Ùات اÙÙØØ¯Ø©"}),e.jsx("table",{className:"w-full",children:e.jsxs("tbody",{children:[e.jsx(a,{label:"Name",arabic:"Ø§ÙØ§Ø³Ù
",plain:t.name}),e.jsx(a,{label:"VAT Number",arabic:"Ø§ÙØ±ÙÙ
Ø§ÙØ¶Ø±ÙبÙ",children:e.jsx(o,{value:t.vatNumber,expect:15})}),e.jsx(a,{label:"CR Number",arabic:"Ø§ÙØ³Ø¬Ù Ø§ÙØªØ¬Ø§Ø±Ù",children:t.crNumber?e.jsx(o,{value:t.crNumber,expect:10}):e.jsx("span",{className:"text-[11px] text-slate-400",children:"â"})}),t.groupVatNumber&&e.jsx(a,{label:"Group VAT",arabic:"Ø§ÙØ±ÙÙ
Ø§ÙØ¶Ø±Ùب٠ÙÙÙ
جÙ
ÙØ¹Ø©",children:e.jsx(o,{value:t.groupVatNumber,expect:15})}),e.jsx(a,{label:"Industry",arabic:"اÙÙØ´Ø§Ø·",plain:t.industryName}
1),e.jsx(a,{label:"Common Name",arabic:"اسÙ
Ø§ÙØ´Ùادة",plain:t.commonName})]})}),e.jsx(p,{en:"Address Details",ar:"ØªÙØ§ØµÙÙ Ø§ÙØ¹ÙÙØ§Ù"}),e.jsx("table",{className:"w-full",children:e.jsxs("tbody",{children:[e.jsx(a,{label:"Building Number",arabic:"رÙÙ
اÙÙ
بÙÙ",children:e.jsx(o,{value:t.buildingNumber,expect:4})}),e.jsx(a,{label:"Street",arabic:"Ø§ÙØ´Ø§Ø±Ø¹",plain:t.streetName}),e.jsx(a,{label:"Secondary Number",arabic:"Ø§ÙØ±ÙÙ
اÙÙØ±Ø¹Ù",children:e.jsx(o,{value:t.plotIdentification,expect:4})}),e.jsx(a,{label:"District",arabic:"Ø§ÙØÙ",plain:t.citySubdivisionName}),e.jsx(a,{label:"Postal Code",arabic:"Ø§ÙØ±Ù
ز Ø§ÙØ¨Ø±ÙدÙ",children:e.jsx(o,{value:t.postalZone,expect:5})}),e.jsx(a,{label:"City",arabic:"اÙÙ
دÙÙØ©",plain:t.cityName}),t.additionalStreet&&e.jsx(a,{label:"Additional Street",arabic:"شارع إضاÙÙ",plain:t.additionalStreet}),e.jsx(a,{label:"Country",arabic:"Ø§ÙØ¯ÙÙØ©",plain:"Kingdom of Saudi Arabia"}),e.jsx(a,{label:"Location Address",arabic:"Ø§ÙØ¹ÙÙØ§Ù",plain:t.locationAddress})]})}),e.jsx(p,{en:"ZATCA Status",ar:"ØØ§ÙØ© Ø§ÙØªØ³Ø¬ÙÙ"}),e.jsx("table",{className:"w-full",children:e.jsxs("tbody",{children:[e.jsx(a,{label:"Environment",arabic:"Ø§ÙØ¨Ùئة",plain:t.effectiveEnvironmentName||L[t.effectiveEnvironment]}),e.jsx(a,{label:"Onboarding",arabic:"ØØ§ÙØ© Ø§ÙØ±Ø¨Ø·",plain:t.statusName}),e.jsx(a,{label:"Last Invoice Counter",arabic:"آخر Ø¹Ø¯ÙØ§Ø¯",plain:String(t.lastIcv??0)}),e.jsx(a,{label:"Active",arabic:"Ù
ÙØ¹ÙÙØ©",plain:t.isActive?"Yes":"No"})]})}),t.environmentMismatch&&e.jsx("p",{className:"mt-3 px-3 py-2 text-[10.5px] leading-relaxed",style:{background:"#fef2f2",border:"1px solid #fecaca",color:"#b91c1c"},children:t.environmentMismatch}),e.jsxs("div",{className:"mt-8 pt-3",style:{borderTop:"1px solid #cbd5e1"},children:[e.jsxs("p",{className:"text-[9.5px] leading-relaxed text-slate-500",children:["Printed from ",l,"âs system on ",m(new Date().toISOString()),". This sheet records how this branch is registered with ZATCA and is issued for internal use and review. It is not a government-issued document and carries no official standing."]}),e.jsxs("p",{className:"text-[9.5px] leading-relaxed text-slate-500 mt-1",dir:"rtl",children:["صدر ÙØ°Ø§ اÙÙ
Ø³ØªÙØ¯ Ù
Ù ÙØ¸Ø§Ù
",l," ÙÙØ§Ø³ØªØ®Ø¯Ø§Ù
Ø§ÙØ¯Ø§Ø®ÙÙ ÙØ§ÙÙ
Ø±Ø§Ø¬Ø¹Ø©Ø ÙÙÙ ÙÙØ³ ÙØ«ÙÙØ© ØÙÙÙ
ÙØ© ÙÙØ§ ÙÙØ¹ØªØ¯ ب٠رسÙ
ÙÙØ§."]})]})]})}function ee(){const t=E(),{id:l=""}=S(),{data:s,isLoading:i}=I(l),{settings:n}=A(),r=d.useRef(null),[b,h]=d.useState(!1),[y,j]=d.useState(!1),f=s?`EGS-Unit-${s.code}`:"EGS-Unit",w=async()=>{const c=r.current;if(!c)throw new Error("Document not ready");const{file:x}=await N(c,f);return[x]},v=async()=>{h(!0);try{const c=r.current;if(!c)throw new Error("Document not ready");const{blob:x,fileName:C}=await N(c,f);G(x,C)}catch(c){P.error(T(c,"Could not build the PDF"))}finally{h(!1)}},u=d.useMemo(()=>s?{title:`EGS Unit ${s.code}`,docNumber:s.code,partyName:s.name}:null,[s]);return i?e.jsx("div",{className:"flex items-center justify-center h-[60vh]",children:e.jsx(g,{className:"w-8 h-8 animate-spin text-slate-300"})}):s?e.jsxs("div",{className:"pb-12",children:[e.jsxs("div",{className:"print:hidden sticky top-0 z-20 -mx-4 sm:-mx-6 px-4 sm:px-6 py-3 mb-6 bg-white border-b border-slate-200 shadow-sm flex items-center gap-3 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>t("/billing/e-invoicing/units"),className:"w-9 h-9 rounded-xl flex items-center justify-center text-slate-500 hover:bg-slate-100 shrink-0",children:e.jsx(k,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h1",{className:"text-base font-bold text-slate-800 leading-tight",children:["EGS Unit ",s.code]}),e.jsx("p",{className:"text-[11px] text-slate-400 leading-tight",children:"Registration sheet â read beside the National Address proof"})]}),e.jsxs("button",{type:"button",onClick:()=>window.print(),className:"px-4 py-2 text-sm font-medium text-slate-600 bg-slate-100 hover:bg-slate-200 rounded-xl flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4"})," Print"]}),e.jsxs("button",{type:"button",onClick:()=>j(!0),className:"px-4 py-2 text-sm font-medium text-slate-600 bg-slate-100 hover:bg-slate-200 rounded-xl flex items-center gap-2",children:[e.jsx(D,{className:"w-4 h-4"})," Email"]}),e.jsxs("button",{type:"button",onClick:v,disabled:b,className:"px-5 py-2 text-sm font-semibold text-white rounded-xl disabled:opacity-60 flex items-center gap-2",style:{background:"var(--primary-600)"},children:[b?e.jsx(g,{className:"w-4 h-4 animate-spin"}):e.jsx(R,{className:"w-4 h-4"})," Download PDF"]})]}
1),e.jsx("div",{ref:r,className:"w-fit mx-auto shadow-sm",style:{border:"1px solid #e2e8f0"},children:e.jsx(Z,{unit:s,companyName:n.companyName,logo:n.logo})}),u&&e.jsx(U,{open:y,onClose:()=>j(!1),target:u,senderName:n.companyName,getFiles:w})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-[60vh] gap-3",children:[e.jsx("p",{className:"text-sm text-slate-500",children:"That EGS unit could not be loaded."}),e.jsx("button",{onClick:()=>t("/billing/e-invoicing/units"),className:"text-sm font-semibold text-[var(--primary-600)]",children:"Back to units"})]})}export{ee 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.