PageSourceSearch

https://login.lappa.org/static/js/route-pdf-import-review.21aa92dc.chunk.js

js lappa.org collected 2026-09-28 05:41:09 UTC 113,924 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunklappa_app=self.webpackChunklappa_app||[]).push([[6272],{23123:(e,n,l)=>{l.r(n),l.d(n,{default:()=>ll});var t=l(65043),i=l(41591),r=l(83003),a=l(45847),o=l(91232),d=l(33852),u=l(72476),s=l(56373),c=l(52399),v=l(49376),m=l(47386),_=l(70579);const p=e=>{let{title:n,children:l}=e;return(0,_.jsxs)("section",{className:"PdfImportReviewPage__section",children:[(0,_.jsx)("h2",{className:"PdfImportReviewPage__sectionTitle",children:n}),(0,_.jsx)("div",{className:"PdfImportReviewPage__sectionBody",children:l})]})};var g=l(14808),h=l(61176),f=l(98139),b=l.n(f);const y=e=>null==e||"string"===typeof e&&""===e.trim(),x=e=>{let{label:n,required:l=!1,value:t,htmlFor:i,className:r,children:a}=e;return(0,_.jsxs)("div",{className:b()("PdfImportReviewPage__field",{"PdfImportReviewPage__field--empty":l&&y(t)},r),children:[(0,_.jsxs)("label",{className:"PdfImportReviewPage__label",htmlFor:i,children:[n,l?(0,_.jsx)("span",{className:"PdfImportReviewPage__required","aria-hidden":"true",children:"*"}):null]}),(0,_.jsx)("div",{className:"PdfImportReviewPage__control PdfImportReviewPage__control--plainInput",children:a})]})};var C=l(97914);const w=(e,n,l)=>{(0,t.useLayoutEffect)((()=>{if(!n||null===e||void 0===e||!e.current)return;const l=e.current.querySelector(".SelectFilter__clear, .TextFilterInput__clear, .PdfImportReviewPage__textareaClear");l&&l.setAttribute("aria-label",n)}),[n,e,l])},k=e=>{let{clearAriaLabel:n="Clear",allowClear:l=!0,value:i,...r}=e;const a=(0,t.useRef)(null);return w(a,l?n:null,i),(0,_.jsx)("div",{ref:a,className:"PdfImportReviewPage__clearableControl",children:(0,_.jsx)(C.Mf,{allowClear:l,value:i,...r})})},j=e=>{let{clearAriaLabel:n="Clear",allowClear:l=!0,clearValue:i="",value:r,...a}=e;const o=(0,t.useRef)(null);return w(o,l?n:null,r),(0,_.jsx)("div",{ref:o,className:"PdfImportReviewPage__clearableControl",children:(0,_.jsx)(C.dN,{allowClear:l,clearValue:i,value:r,...a})})},S=[{value:"SGD",label:"SGD"},{value:"EUR",label:"EUR"},{value:"USD",label:"USD"},{value:"GBP",label:"GBP"},{value:"PLN",label:"PLN"},{value:"AUD",label:"AUD"}],A=e=>{if(!e)return;if(e instanceof Date)return e;const n=new Date(`${e}T00:00:00`);return Number.isNaN(n.getTime())?void 0:n},N=e=>{if(!(e instanceof Date)||Number.isNaN(e.getTime()))return null;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`},P=e=>{var n,l;let{values:t,onChange:i}=e;return(0,_.jsxs)("div",{className:"PdfImportReviewPage__grid PdfImportReviewPage__grid--2",children:[(0,_.jsx)(x,{label:"Invoice number",required:!0,value:t.invoice_number,htmlFor:"pdf-review-invoice-number",children:(0,_.jsx)(k,{id:"pdf-review-invoice-number",width:"100%",height:36,clearAriaLabel:"Clear invoice number",value:null!==(n=t.invoice_number)&&void 0!==n?n:"",onChange:e=>i("invoice_number",e.target.value)})}),(0,_.jsx)(x,{label:"Invoice date",required:!0,value:t.invoice_date,htmlFor:"pdf-review-invoice-date",children:(0,_.jsx)("div",{className:"PdfImportReviewPage__dateShell",children:(0,_.jsx)(g.Ay,{labelDisabled:!0,label:"",allowRange:!1,isLimited:!1,value:A(t.invoice_date),onChange:e=>i("invoice_date",N(e)),placeholder:"Select date",isClearable:!0,clearOnlyWhenHasValue:!0,prefix:(0,_.jsx)("span",{className:"PdfImportReviewPage__datePrefix",children:(0,_.jsx)("img",{src:h.A,alt:"",width:20,height:20,draggable:!1})})})})}),(0,_.jsx)(x,{label:"Due date",required:!0,value:t.due_date,htmlFor:"pdf-review-due-date",children:(0,_.jsx)("div",{className:"PdfImportReviewPage__dateShell",children:(0,_.jsx)(g.Ay,{labelDisabled:!0,label:"",allowRange:!1,isLimited:!1,value:A(t.due_date),onChange:e=>i("due_date",N(e)),placeholder:"Select date",isClearable:!0,clearOnlyWhenHasValue:!0,prefix:(0,_.jsx)("span",{className:"PdfImportReviewPage__datePrefix",children:(0,_.jsx)("img",{src:h.A,alt:"",width:20,height:20,draggable:!1})})})})}),(0,_.jsx)(x,{label:"Currency",required:!0,value:t.currency,htmlFor:"pdf-review-currency",children:(0,_.jsx)(j,{id:"pdf-review-currency",width:"100%",height:36,clearAriaLabel:"Clear currency",options:S,value:null!==(l=t.currency)&&void 0!==l?l:"",onChange:e=>i("currency",e.target.value),placeholder:"Select currency"})})]})};l(86032);const I=44,R=e=>{let{id:n,label:l,htmlFor:i,options:r,value:a,onChange:o,placeholder:d,allowClear:u=!0,clearValue:s="",clearAriaLabel:c,addButtonTitle:v,onAddClick:m,required:p=!1,showAddButton:g=!0,className:h,unmatchedDisplayValue:f,helperText:y,helperId:x,tone:k}=e;const j=(0,t.useRef)(null),S=null!=a&&""!==String(a).trim(),A=p&&!S,N="string"===typeof y&&y.trim().length>0,P=x||(N&&n?`${n}-helper`:void 0),R="string"===typeof f&&f.trim().length>0?f.trim():void 0,M=c||(l?`Clear ${l.toLowerCase()}`:"Clear");return w(j,u?M:null,a),(0,_.jsxs)("div",{className:b()("PdfImportReviewPage__selectWithAdd",A&&"PdfImportReviewPage__selectWithAdd--empty","warning"===k&&"PdfImportReviewPage__selectWithAdd--warning",h),children:[l?(0,_.jsxs)("label",{className:"PdfImportReviewPage__label",htmlFor:i||n,children:[l,p?(0,_.jsx)("span",{className:"PdfImportReviewPage__required","aria-hidden":"true",children:"*"}):null]}):null,(0,_.jsxs)("div",{className:"field-renderer__row",children:[(0,_.jsx)("div",{ref:j,className:"field-renderer__control PdfImportReviewPage__control PdfImportReviewPage__control--plainInput",children:(0,_.jsx)(C.dN,{id:n,width:"100%",height:I,allowClear:u,clearValue:s,options:r,value:null!==a&&void 0!==a?a:"",onCh
1ange:o,placeholder:d,ariaLabel:l,ariaDescribedBy:N?P:void 0,fallbackLabel:R})}),g?(0,_.jsx)("button",{type:"button",className:"field-renderer__circle-btn PdfImportReviewPage__addonBtn","aria-label":v,title:v,onClick:e=>{e.preventDefault(),e.stopPropagation(),"function"===typeof m&&m(e)},children:(0,_.jsx)("span",{className:"field-renderer__plus PdfImportReviewPage__addonBtnPlus","aria-hidden":"true",children:"+"})}):null]}),N?(0,_.jsx)("p",{id:P,className:"PdfImportReviewPage__selectHelper PdfImportReviewPage__selectHelper--warning",role:"status",children:y}):null]})};var M=l(52240),L=l(25514);const T=()=>{const e=(0,c.Ay)(),{regNumbers:n=[],fetching:l=!1}=(0,r.d4)((e=>{var n;return null!==(n=e.vatRegistration)&&void 0!==n?n:{}})),i=Array.isArray(n)&&n.length>0,a=(0,t.useRef)(!1),[o,d]=(0,t.useState)(i);(0,t.useEffect)((()=>{i?d(!0):a.current||(a.current=!0,Promise.resolve(e((0,L.bU)())).finally((()=>{d(!0)})))}),[i,e]);return{vatNumberOptions:(0,t.useMemo)((()=>{return i?(e=(0,M.rK)(n,["vat_number","tin_number"],"id"),(Array.isArray(e)?e:[]).filter((e=>e&&"object"===typeof e))):[];var e}),[i,n]),vatOptionsLoading:!o||l&&!i}},F=e=>{var n;if(!e||"object"!==typeof e)return!1;const l=e.value,t=String(null!==(n=e.label)&&void 0!==n?n:"").trim();return""!==l&&null!=l&&""!==t},E=function(){let{currency:e=null,ocrCustomerLabel:n="",loadBanks:l=!0,loadCustomers:i=!0,includeOcrCustomerOption:a=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const o=(0,c.Ay)(),{banks:d=[],customers:u=[],getBanksLoading:s=!1,getCustomersLoading:m=!1}=(0,r.d4)((e=>{var n;return null!==(n=e.documents)&&void 0!==n?n:{}})),_=Array.isArray(d)&&d.length>0,p=Array.isArray(u)&&u.length>0,g=(0,t.useRef)(!1),h=(0,t.useRef)(!1),[f,b]=(0,t.useState)(!l||_),[y,x]=(0,t.useState)(!i||p);(0,t.useEffect)((()=>{l?_?b(!0):g.current||(g.current=!0,Promise.resolve(o((0,v.Wx)())).finally((()=>{b(!0)}))):b(!0)}),[l,_,o]),(0,t.useEffect)((()=>{i?p?x(!0):h.current||(h.current=!0,Promise.resolve(o((0,v.gJ)())).finally((()=>{x(!0)}))):x(!0)}),[i,p,o]);return{bankOptions:(0,t.useMemo)((()=>{const n=Array.isArray(d)?d:[],l="string"===typeof e?e.toLowerCase():null;return n.filter((e=>{var n,t;return!(!e||"object"!==typeof e)&&(!l||(null===(n=e.bank_currency)||void 0===n||null===(t=n.toLowerCase)||void 0===t?void 0:t.call(n))===l)})).map((e=>{var n;return{value:null==(null===e||void 0===e?void 0:e.id)||""===(null===e||void 0===e?void 0:e.id)?"":String(e.id),label:null!==(n=e.name)&&void 0!==n?n:"Unnamed bank"}})).filter(F)}),[d,e]),customerOptions:(0,t.useMemo)((()=>{const e=(Array.isArray(u)?u:[]).map((e=>({value:null==(null===e||void 0===e?void 0:e.id)||""===(null===e||void 0===e?void 0:e.id)?"":String(e.id),label:null==(null===e||void 0===e?void 0:e.name)?"":String(e.name)}))).filter(F);if(!a)return e;const l=null==n?"":String(n).trim();if(!l)return e;return e.some((e=>String(e.label).trim()===l))?e:[{value:l,label:l},...e]}),[u,n,a]),banks:d,customers:u,bankOptionsLoading:l&&(!f||s&&!_),customerOptionsLoading:i&&(!y||m&&!p)}};var D=l(76930),q=l(84555),V=l(18944),B=l(10413),O=l(39025);const $=[{value:"",label:""},{value:"BIS3",label:"Peppol (Standard \u2013 BIS 3.0) (default)"},{value:"PINT",label:"Peppol (International \u2013 PINT)"},{value:"Croatia (Fiskalizacija 2.0)",label:"Croatia (Fiskalizacija 2.0)"},{value:"Poland (KSeF)",label:"Poland (KSeF)"},{value:"Email",label:"Email"}],U=["BIS3","PINT","Email","Croatia (Fiskalizacija 2.0)","Poland (KSeF)"],W=e=>String(null!==e&&void 0!==e?e:"").trim(),H=e=>W(e).toLowerCase().replace(/\s+/g,""),z=e=>W(e).toLowerCase().replace(/\s+/g," "),Y=e=>"BIS3"===e||"PINT"===e,G=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const l=W(e);if(!l)return"";const t=l.toLowerCase(),i=(Array.isArray(n)?n:[]).find((e=>[null===e||void 0===e?void 0:e.code,null===e||void 0===e?void 0:e.iso_code_2,null===e||void 0===e?void 0:e.iso_code_3,null===e||void 0===e?void 0:e.country_code].some((e=>null!=e&&W(e).toLowerCase()===t))));return null!=(null===i||void 0===i?void 0:i.code)&&""!==W(i.code)?String(i.code):""},K=e=>{if(!e)return{fieldErrors:{}}
1;const n={},l=W(e.name),t=W(e.country_id),i=W(e.city),r=W(e.contact_person),a=W(e.email),o=W(e.address_line_1),d=W(e.tax_number),u=W(e.postal_code),s=W(e.sending_method),c=W(e.peppol_id);return l||(n.name="This field is required"),t||(n.country_id="This field is required"),i||(n.city="This field is required"),r||(n.contact_person="This field is required"),a?(e=>{const n=W(e);return!!n&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n)})(a)||(n.email="Enter a valid email address"):n.email="This field is required",o||(n.address_line_1="This field is required"),d||(n.tax_number="This field is required"),u||(n.postal_code="This field is required"),s?U.includes(s)||(n.sending_method="Invalid sending method"):n.sending_method="This field is required",Y(s)&&(c?c.includes(":")||(n.peppol_id="Peppol ID must contain a colon (:)"):n.peppol_id="This field is required"),Object.keys(n).length>0?{fieldErrors:n}:null};var J=l(86178),Z=l.n(J),Q=l(95354),X=l(71087),ee=l(73816),ne=l(59128);const le=44,te=e=>{if(null==e||""===e)return;const n=Z()(e,["YYYY-MM-DD","DD.MM.YYYY",Z().ISO_8601],!0);if(n.isValid())return n.toDate();const l=Z()(e);return l.isValid()?l.toDate():void 0},ie=e=>{let{label:n,required:l=!1,htmlFor:t,error:i,helpText:r,children:a}=e;return(0,_.jsxs)("div",{className:"AddSupplierVatNumberModal__field"+(i?" AddSupplierVatNumberModal__field--error":""),children:[n?(0,_.jsxs)("label",{className:"AddSupplierVatNumberModal__label",htmlFor:t,children:[n,l?(0,_.jsx)("span",{className:"AddSupplierVatNumberModal__required","aria-hidden":"true",children:"*"}):null]}):null,(0,_.jsx)("div",{className:"AddSupplierVatNumberModal__control",children:a}),i?(0,_.jsx)("div",{className:"AddSupplierVatNumberModal__errorText",children:i}):r?(0,_.jsx)("div",{className:"AddSupplierVatNumberModal__helpText",children:r}):null]})},re=e=>{let{id:n,value:l,onChange:t,placeholder:i,isClearable:r=!0}=e;return(0,_.jsx)("div",{className:"PdfImportReviewPage__dateShell",children:(0,_.jsx)(g.Ay,{labelDisabled:!0,label:"",allowRange:!1,isLimited:!1,value:l,onChange:t,placeholder:i,isClearable:r,clearOnlyWhenHasValue:!0,prefix:(0,_.jsx)("span",{className:"PdfImportReviewPage__datePrefix",children:(0,_.jsx)("img",{src:h.A,alt:"",width:20,height:20,draggable:!1})})})})},ae=e=>{var n,l,i,r;let{data:a,onChange:o,onChangeMany:d,fieldErrors:u={},countries:s=[],reasons:c=[],germanyStates:v=[],typeOfActivityList:m=[],periodicityOptions:p=[],vatCountryStates:g={}}=e;const h=e=>{"function"!==typeof d?Object.entries(e).forEach((e=>{let[n,l]=e;return o(n,l)})):d(e)},{t:f}=(0,D.Bd)(),b=(0,t.useMemo)((()=>{var e;return null!==a&&void 0!==a&&a.country_id&&null!==(e=null===g||void 0===g?void 0:g[a.country_id])&&void 0!==e?e:[]}),[null===a||void 0===a?void 0:a.country_id,g]),y=Array.isArray(b)&&b.length>0,x=(0,ne.S9)(null===a||void 0===a?void 0:a.country_id),w=(0,O.KA)(null===a||void 0===a?void 0:a.country_id),S="tin_number"===(0,O.EH)(a,g),A=(0,t.useMemo)((()=>s.map((e=>({value:e.code,label:e.name_no_article||e.name||e.code})))),[s]),N=(0,t.useMemo)((()=>[{value:"",label:""},...c.map((e=>({value:String(e.id),label:e.name})))]),[c]),P=(0,t.useMemo)((()=>[{value:"",label:""},...b.map((e=>({value:e,label:e})))]),[b]),I=(0,t.useMemo)((()=>v.map((e=>({value:String(e.id),label:e.name})))),[v]),R=(0,t.useMemo)((()=>[{value:"",label:""},...m.map((e=>({value:String(e.id),label:e.description})))]),[m]),M=(0,t.useMemo)((()=>Array.isArray(p)&&p.length?p:[{value:"",label:""}]),[p]),L=(0,t.useMemo)((()=>{const e=null===a||void 0===a?void 0:a.reason_for_registration_id;if(null==e||""===e)return"";const n=Number(e);return Number.isFinite(n)&&0===n?"":String(e)}),[null===a||void 0===a?void 0:a.reason_for_registration_id]),T=Boolean((null===a||void 0===a?void 0:a.country_id)&&null!=(null===a||void 0===a?void 0:a.reason_for_registration_id)&&""!==String(a.reason_for_registration_id).trim()),F=(0,t.useMemo)((()=>{var e,n;return null!==v&&void 0!==v&&v.length?null!==a&&void 0!==a&&a.germany_state_id?(null===(n=v.find((e=>e.id===+a.germany_state_id)))||void 0===n?void 0:n.scheme)||"":(null===(e=v[0])||void 0===e?void 0:e.sc
1heme)||"":""}),[null===a||void 0===a?void 0:a.germany_state_id,v]),E=te(null===a||void 0===a?void 0:a.from_date),q=te(null!==(n=null===a||void 0===a?void 0:a.due_date)&&void 0!==n?n:null===a||void 0===a?void 0:a.nexus_date),V=te(null===a||void 0===a?void 0:a.till_date),B=f("settings:labels.selectDate")||"Select date",$=e=>{var n,l,t;if(""===e||null==e)return void h({country_id:"",province:null,tin_number:"",vat_number:""});const i=null!==(n=null===a||void 0===a?void 0:a.country_id)&&void 0!==n?n:"",r=(null!==(l=g[i])&&void 0!==l?l:[]).length>0,o=(null!==(t=g[e])&&void 0!==t?t:[]).length>0,d={country_id:e};o&&!(0,ne.S9)(e)&&(d.vat_number=""),o&&!r||(d.province=null,d.tin_number=""),o&&(0,ne.S9)(e)&&(d.tin_number=""),h(d)},U=S?(0,_.jsx)(ie,{label:f("vatReg.tin"),required:!0,htmlFor:"add-supplier-vat-tin",error:u.tin,children:(0,_.jsx)(k,{id:"add-supplier-vat-tin",width:"100%",height:le,allowClear:!0,clearAriaLabel:"Clear TIN",value:null!==(l=null===a||void 0===a?void 0:a.tin_number)&&void 0!==l?l:"",onChange:e=>o("tin_number",e.target.value)})}):(0,_.jsx)(ie,{label:f("vatReg.vatNum"),required:!0,htmlFor:"add-supplier-vat-number",error:u.vatNumber,children:(0,_.jsx)(k,{id:"add-supplier-vat-number",width:"100%",height:le,allowClear:!0,clearAriaLabel:"Clear VAT number",value:null!==(i=null===a||void 0===a?void 0:a.vat_number)&&void 0!==i?i:"",onChange:e=>o("vat_number",e.target.value)})});return(0,_.jsxs)("div",{className:"AddSupplierVatNumberModal__form",children:[(0,_.jsxs)("div",{className:"AddSupplierVatNumberModal__row",children:[U,(0,_.jsx)(ie,{label:f("vatReg.country"),required:!0,htmlFor:"add-supplier-vat-country",error:u.country,children:(0,_.jsx)(C.BJ,{id:"add-supplier-vat-country",width:"100%",height:le,allowClear:!0,options:A,value:(null===a||void 0===a?void 0:a.country_id)||null,onChange:e=>$(e.target.value),onClear:()=>$(""),placeholder:f("settings:labels.selectCountry")||"Select country",ariaLabel:f("vatReg.country")||"Country",noOptionsText:"No countries found"})})]}),y?(0,_.jsxs)("div",{className:"AddSupplierVatNumberModal__row",children:[(0,_.jsx)(ie,{label:f("vatReg.province"),required:w,htmlFor:"add-supplier-vat-province",error:u.province,children:(0,_.jsx)(j,{id:"add-supplier-vat-province",width:"100%",height:le,allowClear:!0,clearAriaLabel:"Clear province",options:P,value:(null===a||void 0===a?void 0:a.province)||(null===a||void 0===a?void 0:a.state)||"",onChange:e=>(e=>{const n={province:e||null,state:e||null};var l,t,i,r;x?e?(n.tin_number=String(null!==(l=a.tin_number)&&void 0!==l?l:"").trim()||String(null!==(t=a.vat_number)&&void 0!==t?t:"").trim(),n.vat_number=""):(n.vat_number=String(null!==(i=a.vat_number)&&void 0!==i?i:"").trim()||String(null!==(r=a.tin_number)&&void 0!==r?r:"").trim(),n.tin_number=""):(n.tin_number=e?a.tin_number:"",n.vat_number=""),h(n)})(e.target.value),placeholder:f("vatReg.province")})}),(0,_.jsx)("div",{className:"AddSupplierVatNumberModal__rowSpacer","aria-hidden":"true"})]}):null,(0,_.jsxs)("div",{className:"AddSupplierVatNumberModal__row",children:[(0,_.jsx)(ie,{label:f("settings:labels.reasonForRegistration")||f("vatReg.reasonForReg"),required:!0,htmlFor:"add-supplier-vat-reason",error:u.reason,children:(0,_.jsx)(j,{id:"add-supplier-vat-reason",width:"100%",height:le,allowClear:!0,clearAriaLabel:"Clear reason",options:N,value:L,onChange:e=>{const n=e.target.value;o("reason_for_registration_id",""===n||null==n?null:n)},placeholder:"Select reason"})}),(0,_.jsx)(ie,{label:f("taxSettings.stateAssignedPayment"),required:T,htmlFor:"add-supplier-vat-periodicity",error:u.periodicity,children:(0,_.jsx)(j,{id:"add-supplier-vat-periodicity",width:"100%",height:le,allowClear:!0,clearAriaLabel:"Clear periodicity",options:M,value:(0,ee.Q$)(null===a||void 0===a?void 0:a.periodicity),disabled:!T,onChange:e=>o("periodicity",e.target.value),placeholder:"Select periodicity"})})]}),T?null:(0,_.jsx)("div",{className:"AddSupplierVatNumberModal__scheduleHint",children:f("taxSettings.selectCountryAndReasonForSchedule")}),(0,_.jsxs)("div",{className:"AddSupplierVatNumberModal__row",children:[(0,_.jsx)(ie,{label:f("settings:labels.validFrom")||"Valid from",required:!0,htmlFor:"add-supplier-vat-from",children:(0,_.jsx)(re,{id:"add-supplier-vat-from",value:E,onChange:e=>o("from_date",e?(0,X.y5)(e):null),placeholder:B})}),(0,_.jsx)(ie,{label:f("settings:labels.validTill")||f("taxSett
1ings.validTill"),htmlFor:"add-supplier-vat-till",children:(0,_.jsx)(re,{id:"add-supplier-vat-till",value:V,onChange:e=>o("till_date",e?(0,X.y5)(e):null),placeholder:B})})]}),(0,_.jsxs)("div",{className:"AddSupplierVatNumberModal__row",children:[(0,_.jsx)(ie,{label:f("settings:labels.nexusEstablished")||"Nexus Established",htmlFor:"add-supplier-vat-due",children:(0,_.jsx)(re,{id:"add-supplier-vat-due",value:q,onChange:e=>{const n=e?(0,X.y5)(e):null;o("due_date",n),o("nexus_date",n)},placeholder:B})}),(0,_.jsx)("div",{className:"AddSupplierVatNumberModal__rowSpacer","aria-hidden":"true"})]}),"CZE"===(null===a||void 0===a?void 0:a.country_id)?(0,_.jsx)(ie,{label:f("settings:labels.typeOfActivity")||"Type of activity",htmlFor:"add-supplier-vat-activity",children:(0,_.jsx)(j,{id:"add-supplier-vat-activity",width:"100%",height:le,allowClear:!0,clearAriaLabel:"Clear type of activity",options:R,value:null!=(null===a||void 0===a?void 0:a.type_of_activity_id)?String(a.type_of_activity_id):"",onChange:e=>{const n=e.target.value;o("type_of_activity_id",""===n?null:Number(n))},placeholder:"Select type of activity"})}):null,"DEU"===(null===a||void 0===a?void 0:a.country_id)&&(null===v||void 0===v?void 0:v.length)>0?(0,_.jsxs)("div",{className:"AddSupplierVatNumberModal__deuBlock",children:[(0,_.jsx)("div",{className:"AddSupplierVatNumberModal__deuTitle",children:"Country specifics"}),(0,_.jsxs)("div",{className:"AddSupplierVatNumberModal__row",children:[(0,_.jsx)(ie,{label:f("taxSettings.editVatModalLand"),required:!0,htmlFor:"add-supplier-vat-land",children:(0,_.jsx)(j,{id:"add-supplier-vat-land",width:"100%",height:le,allowClear:!0,clearAriaLabel:"Clear land",options:I,value:null!==a&&void 0!==a&&a.germany_state_id?String(a.germany_state_id):String(v[0].id),onChange:e=>o("germany_state_id",e.target.value),placeholder:"Select land"})}),(0,_.jsx)(ie,{label:`${f("vatReg.stNum")}${F?`(${F})`:""}`,required:!0,htmlFor:"add-supplier-vat-steuernummer",error:u.steuernummer,children:(0,_.jsx)(k,{id:"add-supplier-vat-steuernummer",width:"100%",height:le,allowClear:!0,clearAriaLabel:"Clear Steuernummer",value:null!==(r=null===a||void 0===a?void 0:a.steuernummer)&&void 0!==r?r:"",onChange:e=>o("steuernummer",e.target.value)})})]})]}):null,(0,_.jsxs)("div",{className:"AddSupplierVatNumberModal__toggles",children:[(0,_.jsx)("div",{className:"AddSupplierVatNumberModal__toggle",children:(0,_.jsx)(Q.A,{label:f("vatReg.appLovat"),checked:2===(null===a||void 0===a?void 0:a.vat_agent_id),onChange:e=>o("vat_agent_id",e?2:null)})}),(0,_.jsx)("div",{className:"AddSupplierVatNumberModal__toggle",children:(0,_.jsx)(Q.A,{label:f("taxSettings.editVatModalReportViaLtax"),checked:null==(null===a||void 0===a?void 0:a.send_reminder)||Boolean(a.send_reminder),onChange:e=>o("send_reminder",e)})})]})]})},oe=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(null==e||"object"!==typeof e||Array.isArray(e))return null;if(!Array.isArray(n))return null;for(const l of n){if(!Array.isArray(l)||0===l.length)continue;let n=e,t=!0;for(const e of l){if(null==n||"object"!==typeof n||Array.isArray(n)){t=!1;break}n=n[e]}if(t)if("number"!==typeof n){if("string"===typeof n){const e=n.trim();if(!e)continue;const l=Number(e);if(!Number.isNaN(l)){if(l>0)return e;continue}return e}}else if(Number.isFinite(n)&&n>0)return n}return null};var de=l(33587);const ue=[["vat_number","id"],["id"]],se=/^[0-9]{2,3}\/[0-9]{3}\/[0-9]{5}/,ce=(e,n)=>se.test(n),ve=e=>null==e?"":String(e).trim().toLowerCase(),me=(e,n)=>{if(!n)return!0;const l=(e=>[null===e||void 0===e?void 0:e.country_id,null===e||void 0===e?void 0:e.country_code,null===e||void 0===e?void 0:e.iso_code_3,null===e||void 0===e?void 0:e.iso_code_2].map(ve).filter(Boolean))(e);return 0===l.length||l.includes(n)},_e=(e,n)=>{const l=Array.isArray(e)?e:[],t=n&&"object"===typeof n?n:{},i=ve(t.vat_number),r=ve(t.tin_number),a=ve(t.country_id),o=ve(t.state);let d=[];if(i)d=l.filter((e=>e&&"object"===typeof e&&ve(e.vat_number)===i));else{if(!r)return{status:"unlinked",id:null};d=l.filter((e=>e&&"object"===typeof e&&ve(e.tin_number)===r))}if(d=d.filter((e=>me(e,a))),d=d.filter((e=>((e,n)=>{var l;if(!n)return!0;const t=ve(null!==(l=null===e||void 0===e?void 0:e.state)&&void 0!==l?l:null===e||void 0===e?void 0:e.province);return!t||t===n})(e,o))),1===d.length){var u;const e=null===(u=d[0])||void 0===u?void 0:u.id;return null==e||""===e?{status:"unlinked",id:null}:{status:"linked",id:String(e)}}return d.length>1?{status:"ambiguous",id:null}:{status:"unlinked",id:null}},pe=async e=>{let{formData:n,vatCountryStates:l,customDispatch:t,t:i,onLinked:r}=e;const a=((e,n)=>{var l;let{vatCountryStates:t={},t:i}=n;if(!e)return{fieldErrors:{}}
1;const r=e.country_id,a=e.reason_for_registration_id,o=e.province,d=(e.vat_number||"").trim(),u=(e.tin_number||"").trim(),s=e.steuernummer,c=e.germany_state_id,v=null!==(l=t[r])&&void 0!==l?l:[],m=Array.isArray(v)&&v.length>0;if(!r)return{fieldErrors:{country:`${i("vatReg.country")} is required`}};if(null==a||""===String(a).trim())return{fieldErrors:{reason:`${i("vatReg.reasonForReg")} is required`}};if(m){if((0,O.KA)(r)&&!o)return{fieldErrors:{province:i("vatReg.province")}};const e=(0,O.EH)({country_id:r,province:o,state:o,tin_number:u,vat_number:d},t);if("tin_number"===e&&!u)return{fieldErrors:{tin:i("vatReg.enterTinNumber")}};if("vat_number"===e&&!d)return{fieldErrors:{vatNumber:i("vatReg.enterVatNum")}}}else if(!d)return{fieldErrors:{vatNumber:i("vatReg.enterVatNum")}};return"DEU"===r&&!c||"DEU"===r&&!String(null!==s&&void 0!==s?s:"").trim()?{fieldErrors:{steuernummer:i("vatReg.enterStNum")}}:"DEU"===r&&c&&!ce(Number(c),s)?{fieldErrors:{steuernummer:i("vatReg.invalidVal")}}:null==(0,ee.Oi)(e.periodicity)?{fieldErrors:{periodicity:i("taxSettings.reportingScheduleRequired")}}:null})(n,{vatCountryStates:l,t:i});if(a)return{ok:!1,fieldErrors:a.fieldErrors};const o=function(e){var n;let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const t=e.country_id,i=e.reason_for_registration_id,r={country_id:t,from_date:e.from_date,reason_for_registration_id:Number.parseInt(String(i),10),send_reminder:Boolean(e.send_reminder)};(0,O.O3)(r,e,l),"DEU"===t&&(r.germany_state_id=Number(e.germany_state_id),r.steuernummer=e.steuernummer),"CZE"===t&&e.type_of_activity_id&&(r.type_of_activity_id=e.type_of_activity_id),e.till_date&&(r.till_date=e.till_date),2===e.vat_agent_id&&(r.vat_agent_id=2),1===Number(i)&&(r.calculate_threshold=!1!==e.calculate_threshold);const a=null!==(n=e.due_date)&&void 0!==n?n:e.nexus_date;return a&&(r.due_date="string"===typeof a?a:(0,X.y5)(a)),r.periodicity=(0,ee.Oi)(e.periodicity),r}(n,l);try{const e=await t((0,L.n6)(o));if("string"===typeof e)return{ok:!1,serverError:e||i("eprSettings.serverError")};if(e&&e.error)return{ok:!1,serverError:i("eprSettings.serverError")};const n=oe(e,ue);if(null!=n){const e=String(n);return null===r||void 0===r||r(e),await t((0,L.bU)()),{ok:!0,vatNumberId:e,linkStatus:"linked",linkedDirectly:!0,notice:null}}const l=await t((0,L.bU)());if(l&&l.error)return{ok:!0,vatNumberId:null,linkStatus:"refresh_failed"};const a=_e(l,o);return{ok:!0,vatNumberId:a.id,linkStatus:a.status}}catch(d){return{ok:!1,serverError:(0,de.SU)(d,i("eprSettings.serverError"))}}},ge=e=>{let{open:n,onClose:l,onCreated:i,supplier:a=null}=e;const{t:o}=(0,D.Bd)(),u=(0,c.eo)(),v=(0,t.useMemo)((()=>(0,s.O)(u)),[u]),p=(0,r.d4)((e=>e.other.countries))||[],g=(0,r.d4)((e=>e.other.typeOfActivityList))||[],h=(0,r.d4)((e=>e.vatRegistration.reasons))||[],f=(0,r.d4)((e=>e.vatRegistration.germanyStates))||[],b=(0,r.d4)((e=>e.vatRegistration.vatCountryStates))||{},y=(0,r.d4)((e=>e.vatRegistration.regCountries))||[],x=(0,r.d4)((e=>e.vatRegistration.adding)),[C,w]=(0,t.useState)(null),[k,j]=(0,t.useState)({}),[S,A]=(0,t.useState)(null),[N,P]=(0,t.useState)([]),[I,R]=(0,t.useState)(!1),M=(0,t.useCallback)((()=>{w(null),j({}),A(null),P([]),R(!1)}),[]),T=(0,t.useCallback)((()=>{I||x||(M(),null===l||void 0===l||l())}),[x,l,M,I]);(0,t.useEffect)((()=>{n?(w((e=>{var n;let{germanyStates:l,supplier:t,countries:i}=e;const r=(0,O.wI)(l),a=String(null!==(n=null===t||void 0===t?void 0:t.vat_number)&&void 0!==n?n:"").trim(),o=G(null===t||void 0===t?void 0:t.country_code,i);return{...r,...a?{vat_number:a}:{},...o?{country_id:o}:{}}})({germanyStates:f,supplier:a,countries:p})),j({}),A(null),P([]),p.length||v((0,m.Zv)()).catch((()=>{})),h.length||v((0,L._y)()).catch((()=>{})),f.length||v((0,L.Ye)()).catch((()=>{})),(!b||"object"===typeof b&&!Array.isArray(b)&&0===Object.keys(b).length||Array.isArray(b)&&0===b.length)&&v((0,L.et)()).catch((()=>{})),g.length||v((0,m.PO)()).catch((()=>{})),y.length||v((0,L.$W)()).catch((()=>{}))):M()}),[n,a]),(0,t.useEffect)((()=>{n&&C&&!C.germany_state_id&&null!==f&&void 0!==f&&f[0]&&w((e=>e?{...e,germany_state_id:String(f[0].id)}:e))}),[n,C,f]),(0,t.useEffect)((()=>
1{if(!n||!a)return;const e=G(null===a||void 0===a?void 0:a.country_code,p);e&&w((n=>{var l;return!n||String(null!==(l=n.country_id)&&void 0!==l?l:"").trim()?n:{...n,country_id:e}}))}),[n,a,p]),(0,t.useEffect)((()=>{if(!n||!C)return;const e=C.country_id,l=C.reason_for_registration_id,t=Boolean(e&&""!==String(e).trim()),i=null!=l&&""!==String(l).trim()&&0!==Number(l);if(!t||!i)return P([]),void(C.periodicity&&w((e=>e?{...e,periodicity:""}:e)));let r=!1;return v((0,B.fu)({country_id:e,reason_for_registration_id:l})).then((e=>{r||(!e||"object"===typeof e&&e.error?P([]):Array.isArray(e)?P([{value:"",label:""},...e]):P([]))})).catch((()=>{r||P([])})),()=>{r=!0}}),[n,null===C||void 0===C?void 0:C.country_id,null===C||void 0===C?void 0:C.reason_for_registration_id]);const F=(0,t.useCallback)(((e,n)=>{j({}),A(null),w((l=>l?{...l,[e]:n}:l))}),[]),E=(0,t.useCallback)((e=>{j({}),A(null),w((n=>n?{...n,...e}:n))}),[]),$=(0,t.useMemo)((()=>!(C&&!I&&!x)||(0,O.W2)(C,{vatCountryStates:b,germanyStates:f,validateSteuernummer:ce})),[x,C,f,I,b]),U=(0,t.useCallback)((async()=>{if(!C||I||x||$)return;R(!0),A(null),j({});const e=await pe({formData:C,vatCountryStates:b,customDispatch:v,t:o,onLinked:e=>{null===i||void 0===i||i({vatNumberId:e,linkStatus:"linked",notice:null})}});if(!e.ok)return e.fieldErrors&&j(e.fieldErrors),e.serverError&&A(e.serverError),void R(!1);var n,t;e.linkedDirectly||(null===i||void 0===i||i({vatNumberId:null!==(n=e.vatNumberId)&&void 0!==n?n:null,linkStatus:null!==(t=e.linkStatus)&&void 0!==t?t:"unlinked"}));R(!1),M(),null===l||void 0===l||l()}),[x,v,C,$,l,i,M,I,o,b]);return n?(0,_.jsx)(q.A,{open:n,onClose:T,title:"Add supplier VAT number",width:"100%",padding:20,closeOnOverlayClick:!I&&!x,closeOnEsc:!I&&!x,className:"AddSupplierVatNumberModal",content:(0,_.jsxs)("div",{className:"AddSupplierVatNumberModal__body",children:[S?(0,_.jsx)("div",{className:"AddSupplierVatNumberModal__banner",children:(0,_.jsx)(d.A,{status:"critical",message:S,onDismiss:()=>A(null)})}):null,C?(0,_.jsx)(ae,{data:C,onChange:F,onChangeMany:E,fieldErrors:k,countries:p,reasons:h,germanyStates:f,typeOfActivityList:g,periodicityOptions:N,vatCountryStates:b&&!Array.isArray(b)?b:{}}):null]}),footer:(0,_.jsx)(V.A,{onCancel:T,onConfirm:U,cancelText:o("taxSettings.cancel")||"Cancel",confirmText:o("settings:buttons.addRegistrationInfo")||o("vatReg.addRegInfo")||"Add registration info",confirmDisabled:$,confirmLoading:I||x,variant:"primary"})}):null};var he=l(4845),fe=l(45633);const be="local",ye="global",xe=[{value:"",label:""},{value:"eur",label:"EUR"},{value:"usd",label:"USD"},{value:"gbp",label:"GBP"},{value:"pln",label:"PLN"}],Ce=[{value:be,label:"Local"},{value:ye,label:"Global"}],we=["eur","usd","gbp","pln"],ke=e=>{const n=String(null!==e&&void 0!==e?e:"").trim().toLowerCase();return we.includes(n)?n:""},je=e=>e===be?be:ye,Se=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const l={account_number:"",bank_identifier:""};return(Array.isArray(n)?n:[]).forEach((n=>{var t;null!==n&&void 0!==n&&n.id&&(l[n.id]=String(null!==(t=null===e||void 0===e?void 0:e[n.id])&&void 0!==t?t:""))})),l},Ae=44,Ne=e=>{let{label:n,required:l=!1,htmlFor:t,error:i,children:r}=e;return(0,_.jsxs)("div",{className:"AddBankingInfoModal__field"+(i?" AddBankingInfoModal__field--error":""),children:[n?(0,_.jsxs)("label",{className:"AddBankingInfoModal__label",htmlFor:t,children:[n,l?(0,_.jsx)("span",{className:"AddBankingInfoModal__required","aria-hidden":"true",children:"*"}):null]}):null,(0,_.jsx)("div",{className:"AddBankingInfoModal__control",children:r}),i?(0,_.jsx)("div",{className:"AddBankingInfoModal__errorText",children:i}):null]})},Pe=e=>{let{value:n,onChange:l}=e;const t=n===be?be:ye;return(0,_.jsx)("div",{className:"AddBankingInfoModal__locationToggle",role:"group","aria-label":"Location",children:Ce.map((e=>{const n=t===e.value;return(0,_.jsx)("button",{type:"button",className:"AddBankingInfoModal__locationOption"+(n?" is-selected":""),"aria-pressed":n,onClick:()=>l(e.value),children:e.label},e.value)}))})},Ie=e=>{let{id:n,value:l,onChange:t,clearAriaLabel:i,showValue:r,onToggleShow:a}=e;return(0,_.jsxs)("div",{className:"AddBankingInfoModal__accountNumberWrap",children:[(0,_.jsx)(k,{id:n,width:"100%",height:Ae,showSearchIcon:!1,type:r?"text":"password",autoComplete:"off",clearAriaLabel:i,value:null!==l&&void 0!==l?l:"",onChange:t}),(0,_.jsx)("button",{type:"button",className:"AddBankingInfoModal__eyeToggle",onClick:a,"aria-label":r?"Hide account number":"Show account number",title:r?"Hide account number":"Show account number",children:(0,_.jsx)("img",{src:r?fe.A:he.A,alt:"",width:18,height:18,draggable:!1})})]})},Re=e=>{var n,l,i,r,a;let{data:o,onChange:d,onLocationChange:u,fieldErrors:s={},dynamicTemplate:c=[],mappingLoading:v=!1}=e;const[m,p]=(0,t.useState)(!1);if(!o)return null;const g=Boolean(String(null!==(n=o.bank_currency)&&void 0!==n?n:"").trim());return(0,_.jsxs)("div",{className:"AddBankingInfoModal__form",children:[(0,_.jsx)(Ne,{label:"Currency",required:!0,htmlFor:"add-bank-currency",error:s.bank_currency,children:(0,_.jsx)(j,{id:"add-bank-currency",width:"100%",height:Ae,allowClear:!0,clearAriaLabel:"Clear currency",options:xe,value:null!==(l=o.bank_currency)&&void 0!==l?l:"",onChange:e=>d("bank_currency",e.target.value),placeholder:"Select currency"})}),(0,_.jsx)(Ne,{label:"Location",htmlFor:"add-bank-location",children:(0,_.jsx)(Pe,{value:o.location,onChange:e=>{"function"!==typeof u?d("location",e):u(e)}})}),g?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Ne,{label:"Bank name",required:!0,htmlFor:"add-bank-name",error:s.name,children:(0,_.jsx)(k,{id:"add-bank-name",width:"100%",height:Ae,clearAriaLabel:"Clear bank name",value:null!==(i=o.name)&&void 0!==i?i:"",onCh
1ange:e=>d("name",e.target.value)})}),(0,_.jsx)(Ne,{label:"Account holder",required:!0,htmlFor:"add-bank-account-holder",error:s.account_holder,children:(0,_.jsx)(k,{id:"add-bank-account-holder",width:"100%",height:Ae,showSearchIcon:!1,clearAriaLabel:"Clear account holder",value:null!==(r=o.account_holder)&&void 0!==r?r:"",onChange:e=>d("account_holder",e.target.value)})}),(0,_.jsx)(Ne,{label:"Account name",htmlFor:"add-bank-account-name",error:s.account_name,children:(0,_.jsx)(k,{id:"add-bank-account-name",width:"100%",height:Ae,showSearchIcon:!1,clearAriaLabel:"Clear account name",value:null!==(a=o.account_name)&&void 0!==a?a:"",onChange:e=>d("account_name",e.target.value)})}),v?(0,_.jsx)("p",{className:"AddBankingInfoModal__mappingStatus",role:"status",children:"Loading banking field requirements\u2026"}):c.map((e=>{var n,l;const t="account_number"===e.id;return(0,_.jsx)(Ne,{label:e.label,required:Boolean(e.required),htmlFor:`add-bank-${e.id}`,error:s[e.id],children:t?(0,_.jsx)(Ie,{id:`add-bank-${e.id}`,clearAriaLabel:`Clear ${e.label}`,value:null!==(n=o[e.id])&&void 0!==n?n:"",onChange:n=>d(e.id,n.target.value),showValue:m,onToggleShow:()=>p((e=>!e))}):(0,_.jsx)(k,{id:`add-bank-${e.id}`,width:"100%",height:Ae,clearAriaLabel:`Clear ${e.label}`,value:null!==(l=o[e.id])&&void 0!==l?l:"",onChange:n=>d(e.id,n.target.value)})},e.id)}))]}):null]})},Me="Banking information was created, but it could not be linked automatically. Please select it from the list.",Le="Banking information was created, but it does not match the invoice currency. Please select or create banking information for this currency.",Te=[["bank","id"],["id"]],Fe=e=>null==e?"":String(e).trim().toLowerCase().replace(/\s+/g,""),Ee=e=>null==e?"":String(e).trim().toLowerCase(),De=(e,n)=>{const l=ke(e),t=ke(n);return!(!l||!t)&&l===t},qe=e=>{let{createdBank:n,createdId:l,refreshed:t,payload:i,invoiceCurrency:r}=e;const a=n&&String(n.id)===String(l)?n:(Array.isArray(t)?t:[]).find((e=>String(null===e||void 0===e?void 0:e.id)===String(l)));return!(!a||De(a.bank_currency,r))||!a&&!De(i.bank_currency,r)},Ve=async e=>{let{formData:n,dynamicTemplate:l,invoiceCurrency:t,customDispatch:i}=e;const r=function(e){var n,l,t;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!e)return{fieldErrors:{}};const r={},a=String(null!==(n=e.name)&&void 0!==n?n:"").trim(),o=String(null!==(l=e.account_holder)&&void 0!==l?l:"").trim(),d=String(null!==(t=e.bank_currency)&&void 0!==t?t:"").trim();return a||(r.name="Bank name is required"),o||(r.account_holder="Account holder is required"),d||(r.bank_currency="Currency is required"),(Array.isArray(i)?i:[]).forEach((n=>{var l;null!==n&&void 0!==n&&n.required&&null!==n&&void 0!==n&&n.id&&(String(null!==(l=null===e||void 0===e?void 0:e[n.id])&&void 0!==l?l:"").trim()||(r[n.id]=`${n.label||n.id} is required`))})),Object.keys(r).length>0?{fieldErrors:r}:null}(n,l);if(r)return{ok:!1,fieldErrors:r.fieldErrors};const a=function(e){var n,l,t,i,r,a;let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const d=je(null===e||void 0===e?void 0:e.location),u=Se(e,o),s=String(null!==(n=u.account_number)&&void 0!==n?n:"").trim(),c=String(null!==(l=u.bank_identifier)&&void 0!==l?l:"").trim();return{name:String(null!==(t=null===e||void 0===e?void 0:e.name)&&void 0!==t?t:"").trim(),account_holder:String(null!==(i=null===e||void 0===e?void 0:e.account_holder)&&void 0!==i?i:"").trim(),account_name:String(null!==(r=null===e||void 0===e?void 0:e.account_name)&&void 0!==r?r:"").trim(),bank_currency:String(null!==(a=null===e||void 0===e?void 0:e.bank_currency)&&void 0!==a?a:"").trim().toLowerCase(),location:d,is_default:!1,account_number:s,bank_identifier:c,dynamicFields:{account_number:s,bank_identifier:c}}}(n,l);try{var o;const e=await i((0,v.pP)(a));if("string"===typeof e)return{ok:!1,serverError:(0,de.SU)(e,"Failed to create banking information.")};if(e&&e.error)return{ok:!1,serverError:(0,de.SU)(e,"Failed to create banking information.")};const n=null!==(o=null===e||void 0===e?void 0:e.bank)&&void 0!==o?o:null,l=oe(e,Te);if(null!=l){const e=await i((0,v.Wx)());return qe({createdBank:n,createdId:l,refreshed:e,payload:a,invoiceCurrency:t})?{ok:!0,bankId:null,linkStatus:"currency_mismatch",notice:Le}:{ok:!0,bankId:String(l),linkStatus:"linked",notice:null}}const r=await i((0,v.Wx)());if(r&&r.error)return{ok:!0,bankId:null,linkStatus:"refresh_failed",notice:Me};const d=((e,n)=>{const l=Array.isArray(e)?e:[],t=Fe(null===n||void 0===n?void 0:n.account_number),i=Fe(null===n||void 0===n?void 0:n.bank_identifier),r=Ee(null===n||void 0===n?void 0:n.bank_currency);if(!t)return{status:"unlinked",id:null};let a=l.filter((e=>e&&"object"===typeof e&&Fe(e.account_number)===t));if(i){const e=a.filter((e=>Fe(e.bank_identifier)===i));e.length>0&&(a=e)}if(r){const e=a.filter((e=>Ee(e.bank_currency)===r));e.length>0&&(a=e)}if(1===a.length){var o;const e=null===(o=a[0])||void 0===o?void 0:o.id;return null==e||""===e?{status:"unlinked",id:null}:{status:"linked",id:String(e)}}return a.length>1?{status:"ambiguous",id:null}:{status:"unlinked",id:null}})(r,a);return"linked"!==d.status?{ok:!0,bankId:null,linkStatus:d.status,notice:Me}:qe({createdBank:null,createdId:d.id,refreshed:r,payload:a,invoiceCurrency:t})?{ok:!0,bankId:null,linkStatus:"currency_mismatch",notice:Le}:{ok:!0,bankId:d.id,linkStatus:"linked",notice:null}}catch(d){return{ok:!1,serverError:(0,de.SU)(d,"Failed to create banking information.")}}},Be=e=>{let{open:n,onClose:l,supplier:i,invoiceCurrency:r,onCreated:a}=e;const o=(0,c.eo)(),u=(0,t.useMemo)((()=>(0,s.O)(o)),[o]),[m,p]=(0,t.useState)(null),[g,h]=(0,t.useState)({}),[f,b]=(0,t.useState)(null),[y,x]=(0,t.useState)(!1),[C,w]=(0,t.useState)(null),[k,j]=(0,t.useState)(!1),[S,A]=(0,t.useState)([]),N=(0,t.useCallback)((()=>{p(null),h({}),b(null),x(!1),w(null),j(!1),A([])}),[]),P=(0,t.useCallback)((()=>{y||(N(),null===l||void 0===l||l())}),[l,N,y]);(0,t.useEffect)((()=>{n?(p(function(){var e,n,l;let{supplier:t={},invoiceCurrency:i=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r=ye,a=String(null!==(e=null===t||void 0===t?void 0:t.iban)&&void 0!==e?e:"").trim(),o=String(null!==(n=null===t||void 0===t?void 0:t.bank_identifier)&&void 0!==n?n:"").trim();return{name:String(null!==(l=null===t||void 0===t?void 0:t.bank_name)&&void 0!==l?l:"").trim(),account_holder:"",account_name:"",bank_currency:ke(i),location:r,is_default:!1,account_number:a,bank_identifier:o}}({supplier:i,invoiceCurrency:r})),h({}),b(null),w(null),A([])):N()}),[n,i,r,N]),(0,t.useEffect)((()=>
1{if(!n||null===m||void 0===m||!m.bank_currency)return w(null),void j(!1);let e=!1;const l=m.bank_currency;return j(!0),u((0,v.uo)(l)).then((n=>{e||(n&&!n.error&&"object"===typeof n?w(n):w(null))})).catch((()=>{e||w(null)})).finally((()=>{e||j(!1)})),()=>{e=!0}}),[n,null===m||void 0===m?void 0:m.bank_currency,u]),(0,t.useEffect)((()=>{if(!n||!C||null===m||void 0===m||!m.bank_currency)return void A([]);const e=je(m.location),l=((e,n,l)=>{if(!e||!n||!l)return[];const t=e[n];if(!t)return[];const i=[],r=(e,n,l)=>{i.push({id:e,label:n,required:l})};return"eur"===l?(t.account_number_field&&r("account_number",t.account_number_field,!0),t.bank_code_field&&r("bank_identifier",t.bank_code_field,"global"===n),i):"usd"===l?(t.account_number_field&&r("account_number",t.account_number_field,!0),t.bank_code_field&&r("bank_identifier",t.bank_code_field,!0),i):"gbp"===l?("local"===n?(t.account_number_field&&r("account_number",t.account_number_field,!0),t.bank_code_field&&r("bank_identifier",t.bank_code_field,!0)):(t.account_number_field&&r("account_number",t.account_number_field,!1),t.bank_code_field&&r("bank_identifier",t.bank_code_field,!0)),i):"pln"===l?("local"===n?(t.account_number_field&&r("account_number",t.account_number_field,!0),t.bank_code_field&&r("bank_identifier",t.bank_code_field,!1)):(t.account_number_field&&r("account_number",t.account_number_field,!0),t.bank_code_field&&r("bank_identifier",t.bank_code_field,!0)),i):(t.account_number_field&&r("account_number",t.account_number_field,!0),t.bank_code_field&&r("bank_identifier",t.bank_code_field,!0),i)})(C,e,m.bank_currency);A(l),p((e=>{var n,t;if(!e||e.bank_currency!==m.bank_currency)return e;const i=Se(e,l);return String(null!==(n=e.account_number)&&void 0!==n?n:"")===i.account_number&&String(null!==(t=e.bank_identifier)&&void 0!==t?t:"")===i.bank_identifier?e:{...e,...i}}))}),[n,C,null===m||void 0===m?void 0:m.bank_currency,null===m||void 0===m?void 0:m.location]);const I=(0,t.useCallback)(((e,n)=>{if(h((n=>{if(null===n||void 0===n||!n[e])return n;const l={...n};return delete l[e],l})),b(null),"bank_currency"===e&&!n)return w(null),A([]),void p((e=>e?{...e,bank_currency:"",account_number:"",bank_identifier:""}:e));p((l=>l?{...l,[e]:n}:l))}),[]),R=(0,t.useCallback)((e=>{const n=je(e);b(null),h((e=>{if(!e)return{};const n={...e};return delete n.location,delete n.account_number,delete n.bank_identifier,n})),p((e=>e?{...e,location:n}:e))}),[]),M=(0,t.useMemo)((()=>{var e,n;return!(m&&!y&&!k)||(!m.bank_currency||(!String(null!==(e=m.name)&&void 0!==e?e:"").trim()||(!String(null!==(n=m.account_holder)&&void 0!==n?n:"").trim()||S.some((e=>{var n;return(null===e||void 0===e?void 0:e.required)&&!String(null!==(n=null===m||void 0===m?void 0:m[e.id])&&void 0!==n?n:"").trim()})))))}),[S,m,k,y]),L=(0,t.useCallback)((async()=>{var e,n,t;if(!m||y||M)return;x(!0),b(null),h({});const i=await Ve({formData:{...m,location:je(m.location)},dynamicTemplate:S,invoiceCurrency:r,customDispatch:u});if(!i.ok)return i.fieldErrors&&h(i.fieldErrors),i.serverError&&b(i.serverError),void x(!1);null===a||void 0===a||a({bankId:null!==(e=i.bankId)&&void 0!==e?e:null,linkStatus:null!==(n=i.linkStatus)&&void 0!==n?n:"unlinked",notice:null!==(t=i.notice)&&void 0!==t?t:null}),x(!1),N(),null===l||void 0===l||l()}),[u,S,m,r,M,l,a,N,y]);return n?(0,_.jsx)(q.A,{open:n,onClose:P,title:"Add banking information",width:440,padding:20,closeOnOverlayClick:!y,closeOnEsc:!y,className:"AddBankingInfoModal",content:(0,_.jsxs)("div",{className:"AddBankingInfoModal__body",children:[f?(0,_.jsx)("div",{className:"AddBankingInfoModal__banner",children:(0,_.jsx)(d.A,{status:"critical",message:f,onDismiss:()=>b(null)})}):null,m?(0,_.jsx)(Re,{data:{...m,location:m.location===be?be:ye},onChange:I,onLocationChange:R,fieldErrors:g,dynamicTemplate:S,mappingLoading:k}):null]}),footer:(0,_.jsx)(V.A,{onCancel:P,onConfirm:L,cancelText:"Cancel",confirmText:"Add banking information",confirmDisabled:M,confirmLoading:y,variant:"primary"})}):null};var Oe=l(27522);const $e=44,Ue=e=>{let{label:n,required:l=!1,htmlFor:t,error:i,children:r}=e;return(0,_.jsxs)("div",{className:"AddCustomerModal__field"+(i?" AddCustomerModal__field--error":""),children:[n?(0,_.jsxs)("label",{className:"AddCustomerModal__label",htmlFor:t,children:[n,l?(0,_.jsx)("span",{className:"AddCustomerModal__required","aria-hidden":"true",children:"*"}):null]}):null,(0,_.jsx)("div",{className:"AddCustomerModal__control",children:r}),i?(0,_.jsx)("div",{className:"AddCustomerModal__errorText",children:i}):null]})},We=e=>{var n,l,i,r,a,o,d,u,s,c,v,m;let{data:p,onChange:g,fieldErrors:h={},countryOptions:f=[],languageOptions:b=[]}=e;const{t:y}=(0,D.Bd)("einvoice"),x=null!==(n=null===p||void 0===p?void 0:p.sending_method)&&void 0!==n?n:"",w="Croatia (Fiskalizacija 2.0)"!==x&&"Poland (KSeF)"!==x&&"Email"!==x,S=(0,t.useMemo)((()=>(Array.isArray(b)?b:[]).map((e=>({value:e.value,label:e.label}
1)))),[b]),A=(e,n)=>g(e,n);return(0,_.jsx)("div",{className:"AddCustomerModal__form",children:(0,_.jsxs)("div",{className:"AddCustomerModal__columns",children:[(0,_.jsxs)("div",{className:"AddCustomerModal__column",children:[(0,_.jsx)(Ue,{label:y("labels.name"),required:!0,htmlFor:"add-customer-name",error:h.name,children:(0,_.jsx)(k,{id:"add-customer-name",width:"100%",height:$e,showSearchIcon:!1,clearAriaLabel:"Clear name",value:null!==(l=null===p||void 0===p?void 0:p.name)&&void 0!==l?l:"",onChange:e=>A("name",e.target.value)})}),(0,_.jsx)(Ue,{label:y("labels.peppolId"),required:w,htmlFor:"add-customer-peppol-id",error:h.peppol_id,children:(0,_.jsx)(k,{id:"add-customer-peppol-id",width:"100%",height:$e,showSearchIcon:!1,clearAriaLabel:"Clear Peppol ID",value:null!==(i=null===p||void 0===p?void 0:p.peppol_id)&&void 0!==i?i:"",onChange:e=>A("peppol_id",e.target.value)})}),(0,_.jsx)(Ue,{label:y("labels.contactPerson"),required:!0,htmlFor:"add-customer-contact-person",error:h.contact_person,children:(0,_.jsx)(k,{id:"add-customer-contact-person",width:"100%",height:$e,showSearchIcon:!1,clearAriaLabel:"Clear contact person",value:null!==(r=null===p||void 0===p?void 0:p.contact_person)&&void 0!==r?r:"",onChange:e=>A("contact_person",e.target.value)})}),(0,_.jsx)(Ue,{label:y("labels.invoicingEmail"),required:!0,htmlFor:"add-customer-email",error:h.email,children:(0,_.jsx)(k,{id:"add-customer-email",width:"100%",height:$e,showSearchIcon:!1,type:"email",clearAriaLabel:"Clear email",value:null!==(a=null===p||void 0===p?void 0:p.email)&&void 0!==a?a:"",onChange:e=>A("email",e.target.value)})}),(0,_.jsx)(Ue,{label:y("labels.preferredLanguageForPdf"),htmlFor:"add-customer-language",error:h.language,children:(0,_.jsx)(C.BJ,{id:"add-customer-language",width:"100%",height:$e,allowClear:!0,options:S,value:(null===p||void 0===p?void 0:p.language)||null,onChange:e=>A("language",e.target.value),onClear:()=>A("language",""),placeholder:y("labels.searchLanguage")||"Search language",ariaLabel:y("labels.preferredLanguageForPdf")||"Preferred language for PDF",noOptionsText:"No languages found"})}),(0,_.jsx)(Ue,{label:y("labels.taxNumber"),required:!0,htmlFor:"add-customer-tax-number",error:h.tax_number,children:(0,_.jsx)(k,{id:"add-customer-tax-number",width:"100%",height:$e,showSearchIcon:!1,clearAriaLabel:"Clear tax number",value:null!==(o=null===p||void 0===p?void 0:p.tax_number)&&void 0!==o?o:"",onChange:e=>A("tax_number",e.target.value)})}),(0,_.jsx)(Ue,{label:y("labels.sendingMethod"),required:!0,htmlFor:"add-customer-sending-method",error:h.sending_method,children:(0,_.jsx)(j,{id:"add-customer-sending-method",width:"100%",height:$e,allowClear:!1,options:$,value:null!==(d=null===p||void 0===p?void 0:p.sending_method)&&void 0!==d?d:"",onChange:e=>A("sending_method",e.target.value),placeholder:y("labels.sendingMethod")||"Sending method"})})]}),(0,_.jsxs)("div",{className:"AddCustomerModal__column",children:[(0,_.jsx)(Ue,{label:y("labels.country"),required:!0,htmlFor:"add-customer-country",error:h.country_id,children:(0,_.jsx)(C.BJ,{id:"add-customer-country",width:"100%",height:$e,allowClear:!0,options:f,value:(null===p||void 0===p?void 0:p.country_id)||null,onChange:e=>A("country_id",e.target.value),onClear:()=>A("country_id",""),placeholder:y("labels.country")||"Country",ariaLabel:y("labels.country")||"Country",noOptionsText:"No countries found"})}),(0,_.jsx)(Ue,{label:y("labels.city"),required:!0,htmlFor:"add-customer-city",error:h.city,children:(0,_.jsx)(k,{id:"add-customer-city",width:"100%",height:$e,showSearchIcon:!1,clearAriaLabel:"Clear city",value:null!==(u=null===p||void 0===p?void 0:p.city)&&void 0!==u?u:"",onChange:e=>A("city",e.target.value)})}),(0,_.jsx)(Ue,{label:y("labels.state"),htmlFor:"add-customer-state",error:h.state,children:(0,_.jsx)(k,{id:"add-customer-state",width:"100%",height:$e,showSearchIcon:!1,clearAriaLabel:"Clear state",value:null!==(s=null===p||void 0===p?void 0:p.state)&&void 0!==s?s:"",onChange:e=>A("state",e.target.value)})}),(0,_.jsx)(Ue,{label:y("labels.addressLine1"),required:!0,htmlFor:"add-customer-address-line-1",error:h.address_line_1,children:(0,_.jsx)(k,{id:"add-customer-address-line-1",width:"100%",height:$e,showSearchIcon:!1,clearAriaLabel:"Clear address line 1",value:null!==(c=null===p||void 0===p?void 0:p.address_line_1)&&void 0!==c?c:"",onCh
1ange:e=>A("address_line_1",e.target.value)})}),(0,_.jsx)(Ue,{label:y("labels.addressLine2"),htmlFor:"add-customer-address-line-2",error:h.address_line_2,children:(0,_.jsx)(k,{id:"add-customer-address-line-2",width:"100%",height:$e,showSearchIcon:!1,clearAriaLabel:"Clear address line 2",value:null!==(v=null===p||void 0===p?void 0:p.address_line_2)&&void 0!==v?v:"",onChange:e=>A("address_line_2",e.target.value)})}),(0,_.jsx)(Ue,{label:y("labels.postalCode"),required:!0,htmlFor:"add-customer-postal-code",error:h.postal_code,children:(0,_.jsx)(k,{id:"add-customer-postal-code",width:"100%",height:$e,showSearchIcon:!1,clearAriaLabel:"Clear postal code",value:null!==(m=null===p||void 0===p?void 0:p.postal_code)&&void 0!==m?m:"",onChange:e=>A("postal_code",e.target.value)})})]})]})})},He="Customer was created, but it could not be linked automatically. Please select it from the list.",ze=[["customer","id"],["id"]],Ye=async e=>{let{formData:n,customDispatch:l}=e;const t=K(n);if(t)return{ok:!1,fieldErrors:t.fieldErrors};const i=(e=>({name:W(null===e||void 0===e?void 0:e.name),peppol_id:W(null===e||void 0===e?void 0:e.peppol_id),contact_person:W(null===e||void 0===e?void 0:e.contact_person),email:W(null===e||void 0===e?void 0:e.email),language:W(null===e||void 0===e?void 0:e.language),country_id:W(null===e||void 0===e?void 0:e.country_id),city:W(null===e||void 0===e?void 0:e.city),state:W(null===e||void 0===e?void 0:e.state),address_line_1:W(null===e||void 0===e?void 0:e.address_line_1),address_line_2:W(null===e||void 0===e?void 0:e.address_line_2),postal_code:W(null===e||void 0===e?void 0:e.postal_code),tax_number:W(null===e||void 0===e?void 0:e.tax_number),sending_method:W(null===e||void 0===e?void 0:e.sending_method)}))(n);try{const e=await l((0,v.BG)(i));if("string"===typeof e)return{ok:!1,serverError:e||"Failed to create customer."};if(e&&e.error)return{ok:!1,serverError:"string"===typeof e.error?e.error:"Failed to create customer."};const n=oe(e,ze);if(null!=n)return await l((0,v.gJ)()),{ok:!0,customerId:String(n),linkStatus:"linked",notice:null};const t=await l((0,v.gJ)());if(t&&t.error)return{ok:!0,customerId:null,linkStatus:"refresh_failed",notice:He};const r=((e,n)=>{const l=Array.isArray(e)?e:[],t=z(null===n||void 0===n?void 0:n.name),i=H(null===n||void 0===n?void 0:n.tax_number),r=H(null===n||void 0===n?void 0:n.email);if(!t)return{status:"unlinked",id:null};if(i){const e=l.filter((e=>e&&"object"===typeof e&&H(e.tax_number)===i&&z(e.name)===t));if(1===e.length){var a;const n=null===(a=e[0])||void 0===a?void 0:a.id;return null==n||""===n?{status:"unlinked",id:null}:{status:"linked",id:String(n)}}if(e.length>1)return{status:"ambiguous",id:null}}if(r){const e=l.filter((e=>e&&"object"===typeof e&&H(e.email)===r&&z(e.name)===t));if(1===e.length){var o;const n=null===(o=e[0])||void 0===o?void 0:o.id;return null==n||""===n?{status:"unlinked",id:null}:{status:"linked",id:String(n)}}if(e.length>1)return{status:"ambiguous",id:null}}return{status:"unlinked",id:null}})(Array.isArray(t)?t:[],i);return"linked"===r.status?{ok:!0,customerId:r.id,linkStatus:"linked",notice:null}:{ok:!0,customerId:null,linkStatus:r.status,notice:He}}catch(r){return{ok:!1,serverError:(0,de.SU)(r,"Failed to create customer.")}}},Ge=e=>{let{open:n,onClose:l,customer:i,onCreated:a}=e;const{t:o}=(0,D.Bd)("einvoice"),u=(0,c.eo)(),v=(0,t.useMemo)((()=>(0,s.O)(u)),[u]),p=(0,r.d4)((e=>{var n;return null===(n=e.other)||void 0===n?void 0:n.countries}))||[],{languages_list:g=[]}=(0,r.d4)((e=>{var n;return null!==(n=e.customers)&&void 0!==n?n:{}})),[h,f]=(0,t.useState)(null),[b,y]=(0,t.useState)({}),[x,C]=(0,t.useState)(null),[w,k]=(0,t.useState)(!1),j=(0,t.useMemo)((()=>(Array.isArray(p)?p:[]).map((e=>({value:e.code,label:e.name_no_article||e.name||e.code})))),[p]),S=(0,t.useMemo)((()=>(Array.isArray(g)?g:[]).map((e=>({value:e.code,label:e.name})))),[g]),A=(0,t.useCallback)((()=>{f(null),y({}),C(null),k(!1)}),[]),N=(0,t.useCallback)((()=>{w||(A(),null===l||void 0===l||l())}),[l,A,w]);(0,t.useEffect)((()=>{n?(f(function(){var e,n,l,t,i,r,a,o,d;let{customer:u={},countries:s=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{name:W(null!==(e=null!==(n=null===u||void 0===u?void 0:u.company_name)&&void 0!==n?n:null===u||void 0===u?void 0:u.customer_name)&&void 0!==e?e:""),peppol_id:"",contact_person:"",email:W(null!==(l=null===u||void 0===u?void 0:u.email)&&void 0!==l?l:""),language:"",tax_number:W(null!==(t=null!==(i=null===u||void 0===u?void 0:u.vat_number)&&void 0!==i?i:null===u||void 0===u?void 0:u.registration_code)&&void 0!==t?t:""),sending_method:"",country_id:G(null===u||void 0===u?void 0:u.country_code,s),city:W(null!==(r=null===u||void 0===u?void 0:u.city)&&void 0!==r?r:""),state:"",address_line_1:W(null!==(a=null!==(o=null===u||void 0===u?void 0:u.address_line_1)&&void 0!==o?o:null===u||void 0===u?void 0:u.address_full)&&void 0!==a?a:""),address_line_2:"",postal_code:W(null!==(d=null===u||void 0===u?void 0:u.postal_code)&&void 0!==d?d:"")}}({customer:i,countries:p})),y({}),C(null)):A()}),[n,i,A]),(0,t.useEffect)((()=>{n&&(v((0,m.Zv)()).catch((()=>{})),v((0,Oe.qD)()).catch((()=>{})))}),[n,v]),(0,t.useEffect)((()=>
1{if(!n||!i)return;const e=G(null===i||void 0===i?void 0:i.country_code,p);e&&f((n=>{var l;return!n||String(null!==(l=n.country_id)&&void 0!==l?l:"").trim()?n:{...n,country_id:e}}))}),[n,i,p]);const P=(0,t.useCallback)(((e,n)=>{y((n=>{if(!n[e])return n;const l={...n};return delete l[e],l})),C(null),f((l=>l?{...l,[e]:n}:l))}),[]),I=(0,t.useMemo)((()=>!(h&&!w)||!(e=>{if(!e||"object"!==typeof e)return!1;if(!W(e.name))return!1;if(!W(e.country_id))return!1;if(!W(e.city))return!1;if(!W(e.contact_person))return!1;if(!W(e.email))return!1;if(!W(e.address_line_1))return!1;if(!W(e.tax_number))return!1;if(!W(e.postal_code))return!1;if(!W(e.sending_method))return!1;if(Y(e.sending_method)){const n=W(e.peppol_id);if(!n||!n.includes(":"))return!1}return!0})(h)),[h,w]),R=(0,t.useCallback)((async()=>{var e,n,t;if(!h||w||I)return;k(!0),C(null),y({});const i=await Ye({formData:h,customDispatch:v});if(!i.ok)return i.fieldErrors&&y(i.fieldErrors),i.serverError&&C(i.serverError),void k(!1);null===a||void 0===a||a({customerId:null!==(e=i.customerId)&&void 0!==e?e:null,linkStatus:null!==(n=i.linkStatus)&&void 0!==n?n:"unlinked",notice:null!==(t=i.notice)&&void 0!==t?t:null}),k(!1),A(),null===l||void 0===l||l()}),[v,h,I,l,a,A,w]);return n?(0,_.jsx)(q.A,{open:n,onClose:N,title:"Add customer",width:680,padding:20,closeOnOverlayClick:!w,closeOnEsc:!w,className:"AddCustomerModal",content:(0,_.jsxs)("div",{className:"AddCustomerModal__body",children:[x?(0,_.jsx)("div",{className:"AddCustomerModal__banner",children:(0,_.jsx)(d.A,{status:"critical",message:x,onDismiss:()=>C(null)})}):null,h?(0,_.jsx)(We,{data:h,onChange:P,fieldErrors:b,countryOptions:j,languageOptions:S}):null]}),footer:(0,_.jsx)(V.A,{onCancel:N,onConfirm:R,cancelText:o("buttons.cancel")||"Cancel",confirmText:"Add customer",confirmDisabled:I,confirmLoading:w,variant:"primary"})}):null},Ke=e=>"string"!==typeof e?"":e.trim(),Je=e=>{let{id:n,recognizedValue:l,isLoading:t=!1}=e;const i=(e=>null!==e&&void 0!==e&&""!==e)(n),r=Ke(l),a=r.length>0,o=!t&&!i&&a;return{hasResolvedId:i,hasRecognizedValue:a,recognizedValue:r,isLoading:Boolean(t),isUnmatched:o,selectValue:i?String(n):"",unmatchedDisplayValue:o?r:void 0}},Ze=e=>{var n,l,i,a,o,d,u;let{party:v,vatNumberId:p,bankId:g,currency:h,onChange:f,onVatNumberIdChange:b,onBankChange:y,idPrefix:w="pdf-review-supplier"}=e;const j=(0,c.eo)(),S=(0,t.useMemo)((()=>(0,s.O)(j)),[j]),A=(0,r.d4)((e=>{var n;return null===(n=e.other)||void 0===n?void 0:n.countries}))||[],{vatNumberOptions:N,vatOptionsLoading:P}=T(),{bankOptions:M,bankOptionsLoading:L}=E({currency:h,loadBanks:!0,loadCustomers:!1,includeOcrCustomerOption:!1}),[F,D]=(0,t.useState)(!1),[q,V]=(0,t.useState)(null),[B,O]=(0,t.useState)(!1),[$,U]=(0,t.useState)(null);(0,t.useEffect)((()=>{Array.isArray(A)&&A.length>0||S((0,m.Zv)()).catch((()=>{}))}),[A,S]);const W=(e,n)=>{f({...v,[e]:""===n?null:n})},H=null!==(n=null!==(l=null!==(i=null===v||void 0===v?void 0:v.name)&&void 0!==i?i:null===v||void 0===v?void 0:v.company_name)&&void 0!==l?l:null===v||void 0===v?void 0:v.supplier_name)&&void 0!==n?n:"",z=Ke(null===v||void 0===v?void 0:v.vat_number),Y=Ke(null===v||void 0===v?void 0:v.bank_name),G=Je({id:p,recognizedValue:z,isLoading:P}),K=Je({id:g,recognizedValue:Y,isLoading:L}),J=(0,t.useMemo)((()=>(Array.isArray(A)?A:[]).map((e=>({value:e.code,label:e.name_no_article||e.name||e.code})))),[A]),Z=(0,t.useMemo)((()=>function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const l=Ke(e);if(!l)return null;const t=(Array.isArray(n)?n:[]).find((e=>(null===e||void 0===e?void 0:e.code)===l||(null===e||void 0===e?void 0:e.iso_code_2)===l||(null===e||void 0===e?void 0:e.iso_code_3)===l||(null===e||void 0===e?void 0:e.country_code)===l));return null!=(null===t||void 0===t?void 0:t.code)&&""!==String(t.code).trim()?String(t.code):l}(null===v||void 0===v?void 0:v.country_code,A)),[null===v||void 0===v?void 0:v.country_code,A]);return(0,_.jsxs)("div",{className:"PdfImportReviewPage__party PdfImportReviewPage__party--supplier",children:[(0,_.jsxs)("div",{className:"PdfImportReviewPage__partyStack",children:[(0,_.jsx)(x,{label:"Supplier name",required:!0,value:H,htmlFor:`${w}-name`,children:(0,_.jsx)(k,{id:`${w}-name`,width:"100%",height:I,clearAriaLabel:"Clear supplier name",value:H,onChange:e=>{const n=e.target.value;
1f({...v,name:""===n?null:n,company_name:""===n?null:n})}})}),(0,_.jsx)(x,{label:"Registration code / Company number",required:!0,value:null===v||void 0===v?void 0:v.registration_code,htmlFor:`${w}-reg`,children:(0,_.jsx)(k,{id:`${w}-reg`,width:"100%",height:I,clearAriaLabel:"Clear registration code / company number",value:null!==(a=null===v||void 0===v?void 0:v.registration_code)&&void 0!==a?a:"",onChange:e=>W("registration_code",e.target.value)})}),(0,_.jsxs)("div",{className:"PdfImportReviewPage__grid PdfImportReviewPage__grid--2",children:[(0,_.jsx)(x,{label:"Street",required:!0,value:null===v||void 0===v?void 0:v.address_line_1,htmlFor:`${w}-street`,children:(0,_.jsx)(k,{id:`${w}-street`,width:"100%",height:I,clearAriaLabel:"Clear street",value:null!==(o=null===v||void 0===v?void 0:v.address_line_1)&&void 0!==o?o:"",onChange:e=>W("address_line_1",e.target.value)})}),(0,_.jsx)(x,{label:"Postal code",required:!0,value:null===v||void 0===v?void 0:v.postal_code,htmlFor:`${w}-postal`,children:(0,_.jsx)(k,{id:`${w}-postal`,width:"100%",height:I,clearAriaLabel:"Clear postal code",value:null!==(d=null===v||void 0===v?void 0:v.postal_code)&&void 0!==d?d:"",onChange:e=>W("postal_code",e.target.value)})})]}),(0,_.jsxs)("div",{className:"PdfImportReviewPage__grid PdfImportReviewPage__grid--2",children:[(0,_.jsx)(x,{label:"City",required:!0,value:null===v||void 0===v?void 0:v.city,htmlFor:`${w}-city`,children:(0,_.jsx)(k,{id:`${w}-city`,width:"100%",height:I,clearAriaLabel:"Clear city",value:null!==(u=null===v||void 0===v?void 0:v.city)&&void 0!==u?u:"",onChange:e=>W("city",e.target.value)})}),(0,_.jsx)(x,{label:"Country",required:!0,value:null===v||void 0===v?void 0:v.country_code,htmlFor:`${w}-country`,children:(0,_.jsx)(C.BJ,{id:`${w}-country`,width:"100%",height:I,allowClear:!0,options:J,value:Z,onChange:e=>W("country_code",e.target.value),onClear:()=>W("country_code",""),placeholder:"Select country",ariaLabel:"Country",noOptionsText:"No countries found"})})]})]}),(0,_.jsxs)("div",{className:"PdfImportReviewPage__partyStack PdfImportReviewPage__partyStack--withAdd",children:[(0,_.jsx)(R,{id:`${w}-vat`,label:"Supplier VAT number",options:N,value:G.selectValue,onChange:e=>{const n=e.target.value;V(null),n?null===b||void 0===b||b(n):null===b||void 0===b||b(null)},placeholder:"Select supplier VAT number",allowClear:!0,clearAriaLabel:"Clear supplier VAT number",required:!0,className:"PdfImportReviewPage__selectWithAdd--withAddon",addButtonTitle:G.isUnmatched?"Add recognized VAT number":"Add supplier VAT number",onAddClick:()=>{V(null),D(!0)},unmatchedDisplayValue:G.unmatchedDisplayValue,helperText:G.isUnmatched?"Recognized from the PDF, but not found in your saved VAT numbers.":void 0,helperId:`${w}-vat-ocr-mismatch`,tone:G.isUnmatched?"warning":void 0}),q?(0,_.jsx)("p",{className:"PdfImportReviewPage__selectHelper PdfImportReviewPage__selectHelper--warning",role:"status",children:q}):null,(0,_.jsx)(R,{id:`${w}-bank`,label:"Banking info",options:M,value:K.selectValue,onChange:e=>{U(null),null===y||void 0===y||y(""===e.target.value?null:e.target.value)},placeholder:"Select or add banking info",allowClear:!0,clearAriaLabel:"Clear banking info",required:!0,className:"PdfImportReviewPage__selectWithAdd--withAddon",addButtonTitle:K.isUnmatched?"Add recognized banking information":"Add banking information",onAddClick:()=>{U(null),O(!0)},unmatchedDisplayValue:K.unmatchedDisplayValue,helperText:K.isUnmatched?"Recognized from the PDF, but not found in your saved banking information.":void 0,helperId:`${w}-bank-ocr-mismatch`,tone:K.isUnmatched?"warning":void 0}),$?(0,_.jsx)("p",{className:"PdfImportReviewPage__selectHelper PdfImportReviewPage__selectHelper--warning",role:"status",children:$}):null]}),(0,_.jsx)(ge,{open:F,onClose:()=>D(!1),onCreated:e=>{var n,l;const t=null!==(n=null===e||void 0===e?void 0:e.vatNumberId)&&void 0!==n?n:null;if("linked"===(null!==(l=null===e||void 0===e?void 0:e.linkStatus)&&void 0!==l?l:"unlinked")&&null!=t&&""!==t)return null===b||void 0===b||b(String(t)),void V(null);V("VAT number was created, but it could not be linked automatically. Please select it from the list.")},supplier:v}),(0,_.jsx)(Be,{open:B,onClose:()=>O(!1),supplier:v,invoiceCurrency:h,onCreated:e=>{var n,l,t;const i=null!==(n=null===e||void 0===e?void 0:e.bankId)&&void 0!==n?n:null,r=null!==(l=null===e||void 0===e?void 0:e.linkStatus)&&void 0!==l?l:"unlinked",a=null!==(t=null===e||void 0===e?void 0:e.notice)&&void 0!==t?t:null;if("linked"===r&&null!=i&&""!==i)return null===y||void 0===y||y(String(i)),void U(null);U(a||"Banking information was created, but it could not be linked automatically. Please select it from the list.")}})]})},Qe=e=>{let{party:n,customerId:l,onChange:i,onCustomerIdChange:r,idPrefix:a="pdf-review-customer"}=e;const[o,d]=(0,t.useState)(!1),[u,s]=(0,t.useState)(null),c=function(){for(var e=arguments.length,n=new Array(e),l=0;l<e;l++)n[l]=arguments[l];for(const t of n){const e=Ke(t);if(e)return e}return""}(null===n||void 0===n?void 0:n.company_name,null===n||void 0===n?void 0:n.customer_name,null===n||void 0===n?void 0:n.vat_number,null===n||void 0===n?void 0:n.registration_code),{customerOptions:v,customerOptionsLoading:m}=E({ocrCustomerLabel:c,loadBanks:!1,loadCustomers:!0,includeOcrCustomerOption:!1}
1),p=Je({id:l,recognizedValue:c,isLoading:m});return(0,_.jsxs)("div",{className:"PdfImportReviewPage__party",children:[(0,_.jsx)(R,{id:`${a}-customer`,label:"Select or add customer",options:v,value:p.selectValue,onChange:e=>{s(null);const n=e.target.value;n?null===r||void 0===r||r(n):null===r||void 0===r||r(null)},placeholder:"Select or add customer",allowClear:!0,clearAriaLabel:"Clear customer",required:!0,className:"PdfImportReviewPage__selectWithAdd--withAddon",addButtonTitle:p.isUnmatched?"Add recognized customer":"Add customer",onAddClick:()=>{s(null),d(!0)},unmatchedDisplayValue:p.unmatchedDisplayValue,helperText:p.isUnmatched?"Recognized from the PDF, but not found in your saved customers.":void 0,helperId:`${a}-customer-ocr-mismatch`,tone:p.isUnmatched?"warning":void 0}),u?(0,_.jsx)("p",{className:"PdfImportReviewPage__selectHelper PdfImportReviewPage__selectHelper--warning",role:"status",children:u}):null,(0,_.jsx)(Ge,{open:o,onClose:()=>d(!1),customer:n,onCreated:e=>{var n,l,t;const i=null!==(n=null===e||void 0===e?void 0:e.customerId)&&void 0!==n?n:null,a=null!==(l=null===e||void 0===e?void 0:e.linkStatus)&&void 0!==l?l:"unlinked",o=null!==(t=null===e||void 0===e?void 0:e.notice)&&void 0!==t?t:null;if("linked"===a&&null!=i&&""!==i)return null===r||void 0===r||r(String(i)),void s(null);s(o||"Customer was created, but it could not be linked automatically. Please select it from the list.")}})]})};var Xe=l(21743),en=l(85984);const nn=e=>""===e||void 0===e?null:e,ln=e=>{if(""===e||null==e)return null;const n=Number(String(e).replace(",","."));return Number.isFinite(n)?n:null},tn=e=>Math.round(100*(Number(e)+Number.EPSILON))/100,rn=e=>["VAT","GST","SalesTax","NoTax"].includes(e)?e:"NoTax",an=e=>Array.isArray(e)?e.map(((e,n)=>((e,n)=>{var l,t,i,r,a,o,d,u,s,c,v;return{id:(null===e||void 0===e?void 0:e.id)||crypto.randomUUID(),rowIndex:String(null!==(l=null===e||void 0===e?void 0:e.no)&&void 0!==l?l:n+1),sku:null!==(t=null===e||void 0===e?void 0:e.sku)&&void 0!==t?t:"",description:null!==(i=null!==(r=null===e||void 0===e?void 0:e.name)&&void 0!==r?r:null===e||void 0===e?void 0:e.description)&&void 0!==i?i:"",quantity:null!==(a=null===e||void 0===e?void 0:e.quantity)&&void 0!==a?a:"",unit_price:null!==(o=null===e||void 0===e?void 0:e.unit_price)&&void 0!==o?o:"",discount_value:null!==(d=null===e||void 0===e?void 0:e.discount_value)&&void 0!==d?d:"",discount_type:"amount"===(null===e||void 0===e?void 0:e.discount_type)?"amount":"percentage",tax_type:rn(null!==(u=null===e||void 0===e?void 0:e.tax_type)&&void 0!==u?u:"NoTax"),tax_value:null!==(s=null!==(c=null!==(v=null===e||void 0===e?void 0:e.tax_rate)&&void 0!==v?v:null===e||void 0===e?void 0:e.tax_percent)&&void 0!==c?c:null===e||void 0===e?void 0:e.tax_value)&&void 0!==s?s:""}})(e,n))):[],on=e=>Array.isArray(e)?e.map((e=>(e=>{var n;const{taxAmount:l,discountApplied:t}=(0,en.GZ)(e),i="string"===typeof(null===e||void 0===e?void 0:e.description)?e.description.trim():null===e||void 0===e?void 0:e.description;return{id:null===e||void 0===e?void 0:e.id,name:nn(i||null),sku:nn(null===e||void 0===e?void 0:e.sku),quantity:ln(null===e||void 0===e?void 0:e.quantity),unit_price:ln(null===e||void 0===e?void 0:e.unit_price),discount_type:"amount"===(null===e||void 0===e?void 0:e.discount_type)?"amount":"percentage",discount_value:ln(null===e||void 0===e?void 0:e.discount_value),discount_total:tn(t||0),tax_type:rn(null!==(n=null===e||void 0===e?void 0:e.tax_type)&&void 0!==n?n:"NoTax"),tax_rate:ln(null===e||void 0===e?void 0:e.tax_value),tax_value:tn(l||0)||null,amount_tax_inclusive:!1}})(e))):[],dn=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const l=(e||[]).find((e=>"NoTax"!==(null===e||void 0===e?void 0:e.tax_type)&&""!==(null===e||void 0===e?void 0:e.tax_value)&&null!=(null===e||void 0===e?void 0:e.tax_value)));if(!l)return n;const t=ln(l.tax_value);return null==t?n:t},un=(e,n)=>{if(!(e=>{if(null===e||void 0===e||""===e)return!1;const n=Number(e);return!!Number.isFinite(n)&&0!==n})(null===e||void 0===e?void 0:e.discount_value))return"\u2014";const l=(e=>{const n=Number(e);return Number.isFinite(n)?(Number.isInteger(n),String(n)):String(null!==e&&void 0!==e?e:"").trim()})(e.discount_value);if("amount"===(null===e||void 0===e?void 0:e.discount_type)){const e=String(n||"").trim().toUpperCase();return e?`${l} ${e}`:l}return`${l}%`};var sn=l(16404);const cn=()=>(0,_.jsx)("svg",{width:16,height:16,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:(0,_.jsx)("path",{d:"M18 6L6 18M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),vn=(0,t.forwardRef)((function(e,n){let{id:l,className:i,value:r="",onChange:a,clearAriaLabel:o="Clear",rows:d=3,...u}=e;const s=(0,t.useRef)(null),c=String(null!==r&&void 0!==r?r:"").length>0,v=(0,t.useCallback)((e=>{s.current=e,((e,n)=>{"function"===typeof e?e(n):e&&"current"in e&&(e.current=n)})(n,e)}),[n]);return(0,_.jsxs)("div",{className:b()("PdfImportReviewPage__textareaShell",c&&"PdfImportReviewPage__textareaShell--hasClear"),children:[(0,_.jsx)("textarea",{...u,ref:v,id:l,className:b()("PdfImportReviewPage__textarea",i),rows:d,value:null!==r&&void 0!==r?r:"",onChange:a}),c?(0,_.jsx)("button",{type:"button",className:"PdfImportReviewPage__textareaClear","aria-label":o,title:o,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation(),null===a||void 0===a||a({target:{value:""},currentTarget:{value:""}}),requestAnimationFrame((()=>{var e;null===(e=s.current)||void 0===e||e.focus()}))},children:(0,_.jsx)(cn,{})}):null]})})),mn=44,_n=e=>{let{label:n,htmlFor:l,required:t=!1,className:i,children:r}=e;return(0,_.jsxs)("div",{className:b()("PdfImportReviewPage__modalField",i),children:[(0,_.jsxs)("label",{className:"PdfImportReviewPage__modalFieldLabel",htmlFor:l,children:[n,t?(0,_.jsx)("span",{className:"PdfImportReviewPage__required","aria-hidden":"true",children:"*"}):null]}),(0,_.jsx)("div",{className:"PdfImportReviewPage__modalFieldControl PdfImportReviewPage__control--plainInput",children:r})]})},pn=e=>{var n,l,i,r,a,o,d,u;let{draft:s,setDraft:c,currency:v}=e;const{t:m}=(0,D.Bd)("einvoice"),p=(0,t.useRef)(null),g=[{label:m("labels.noTax"),value:"NoTax"},{label:m("labels.salesTax"),value:"SalesTax"},{label:"VAT",value:"VAT"},{label:"GST",value:"GST"}],h="NoTax"===s.tax_type||"No tax"===s.tax_type,f=(0,t.useMemo)((()=>[{label:"%",value:"percentage"},{label:(null===sn.Qn||void 0===sn.Qn?void 0:(0,sn.Qn)(v))||v,value:"amount"}]),[v]);return function(e,n){let l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3;(0,t.useEffect)((()=>{const n=e.current;if(!n)return;const t=()=>{const e=getComputedStyle(n),t=parseFloat(e.lineHeight)||20,i=parseFloat(e.paddingTop)+parseFloat(e.paddingBottom);return t*l+i};let i=t(),r=0;const a=()=>{n.style.overflow="hidden",n.style.boxSizing="border-box",n.style.minHeight=`${i}px`,n.style.height="auto",n.style.height=`${Math.max(i,n.scrollHeight)}px`},o=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(a)};n.addEventListener("input",o);const d=new ResizeObserver((()=>{i=t(),o()}));return d.observe(n),o(),()=>{cancelAnimationFrame(r),n.removeEventListener("input",o),d.disconnect()}}),[e,n,l])}(p,s.description,3),(0,_.jsxs)("div",{className:"PdfImportReviewPage__itemModalContent",children:[(0,_.jsx)(_
1n,{label:m("labels.sku"),htmlFor:"pdf-review-item-sku",children:(0,_.jsx)(k,{id:"pdf-review-item-sku",width:"100%",height:mn,clearAriaLabel:`Clear ${m("labels.sku")}`,value:null!==(n=s.sku)&&void 0!==n?n:"",onChange:e=>c((n=>({...n,sku:e.target.value}))),autoComplete:"off"})}),(0,_.jsx)(_n,{label:m("labels.description"),htmlFor:"pdf-review-item-description",required:!0,className:"PdfImportReviewPage__modalField--description",children:(0,_.jsx)(vn,{ref:p,id:"pdf-review-item-description",className:"PdfImportReviewPage__modalTextarea",rows:3,clearAriaLabel:`Clear ${m("labels.description")}`,value:null!==(l=s.description)&&void 0!==l?l:"",onChange:e=>c((n=>({...n,description:e.target.value}))),autoComplete:"off"})}),(0,_.jsx)(_n,{label:m("labels.quantity"),htmlFor:"pdf-review-item-quantity",required:!0,children:(0,_.jsx)(k,{id:"pdf-review-item-quantity",width:"100%",height:mn,clearAriaLabel:`Clear ${m("labels.quantity")}`,value:String(null!==(i=s.quantity)&&void 0!==i?i:""),onChange:e=>c((n=>({...n,quantity:e.target.value}))),onBlur:()=>c((e=>{var n;return{...e,quantity:(0,sn.pO)(null!==(n=e.quantity)&&void 0!==n?n:"0")}})),inputMode:"numeric",autoComplete:"off"})}
1),(0,_.jsx)(_n,{label:m("labels.unitPrice"),htmlFor:"pdf-review-item-unit-price",required:!0,children:(0,_.jsx)(k,{id:"pdf-review-item-unit-price",width:"100%",height:mn,clearAriaLabel:`Clear ${m("labels.unitPrice")}`,value:String(null!==(r=s.unit_price)&&void 0!==r?r:""),onChange:e=>c((n=>({...n,unit_price:e.target.value}))),onBlur:()=>c((e=>{var n;return{...e,unit_price:(0,sn.BH)(null!==(n=e.unit_price)&&void 0!==n?n:"0")}})),inputMode:"decimal",autoComplete:"off"})}),(0,_.jsxs)("div",{className:"PdfImportReviewPage__modalDiscountRow",children:[(0,_.jsx)(_n,{label:m("labels.discount"),htmlFor:"pdf-review-item-discount",children:(0,_.jsx)(k,{id:"pdf-review-item-discount",width:"100%",height:mn,clearAriaLabel:`Clear ${m("labels.discount")}`,value:String(null!==(a=s.discount_value)&&void 0!==a?a:""),onChange:e=>c((n=>({...n,discount_value:e.target.value}))),onBlur:()=>c((e=>{var n,l,t;return{...e,discount_value:"percentage"===(null!==(n=e.discount_type)&&void 0!==n?n:"percentage")?(0,sn.UO)(null!==(l=e.discount_value)&&void 0!==l?l:"0"):(0,sn.BH)(null!==(t=e.discount_value)&&void 0!==t?t:"0")}})),inputMode:"decimal",autoComplete:"off"})}
1),(0,_.jsx)(_n,{label:m("labels.discountType"),htmlFor:"pdf-review-item-discount-type",children:(0,_.jsx)(j,{id:"pdf-review-item-discount-type",width:"100%",height:mn,clearAriaLabel:`Clear ${m("labels.discountType")}`,options:f,value:null!==(o=s.discount_type)&&void 0!==o?o:"percentage",onChange:e=>{const n=e.target.value;c((e=>{var l,t;return{...e,discount_type:n,discount_value:""===n?e.discount_value:"percentage"===n?(0,sn.UO)(null!==(l=e.discount_value)&&void 0!==l?l:"0"):(0,sn.BH)(null!==(t=e.discount_value)&&void 0!==t?t:"0")}}))},ariaLabel:m("labels.discountType")})})]}),(0,_.jsx)(_n,{label:m("labels.taxType"),htmlFor:"pdf-review-item-tax-type",children:(0,_.jsx)(j,{id:"pdf-review-item-tax-type",width:"100%",height:mn,clearAriaLabel:`Clear ${m("labels.taxType")}`,options:g,value:null!==(d=s.tax_type)&&void 0!==d?d:"NoTax",onChange:e=>{const n=e.target.value;c((e=>({...e,tax_type:n,tax_value:"NoTax"===n||""===n?"0":e.tax_value})))},ariaLabel:m("labels.taxType")})}),(0,_.jsx)(_n,{label:m("labels.taxRatePercent"),htmlFor:"pdf-review-item-tax-rate",children:(0,_.jsx)(k,{id:"pdf-review-item-tax-rate",width:"100%",height:mn,clearAriaLabel:`Clear ${m("labels.taxRatePercent")}`,disabled:h,value:String(null!==(u=s.tax_value)&&void 0!==u?u:""),onChange:e=>c((n=>({...n,tax_value:e.target.value}))),onBlur:()=>c((e=>{var n;return{...e,tax_value:"NoTax"===e.tax_type?"0":(0,sn.UO)(null!==(n=e.tax_value)&&void 0!==n?n:"0")}})),onFocus:e=>{h&&e.currentTarget.blur()},inputMode:"decimal",autoComplete:"off"})})]})},gn=e=>{let{open:n,onClose:l,title:t,draft:i,setDraft:r,currency:a,onSave:o,isValid:d,cancelText:u="Cancel",saveText:s="Save"}=e;return(0,_.jsx)(q.A,{open:n,onClose:l,title:t,width:600,padding:24,className:"PdfImportReviewPage__lineItemModalV2",content:(0,_.jsx)("div",{className:"PdfImportReviewPage__lineItemModalBody",children:(0,_.jsx)(pn,{draft:i,setDraft:r,currency:a})}),footer:(0,_.jsx)(V.A,{onCancel:l,onConfirm:o,cancelText:u,confirmText:s,confirmDisabled:!d,variant:"primary"})})},hn=e=>{let{visible:n,onClose:l,onConfirm:t,title:i="Confirm action",description:r="",confirmText:a="Confirm",cancelText:o="Cancel",tone:u="critical",loading:s=!1,error:c=null}=e;return(0,_.jsx)(q.A,{open:n,onClose:l,title:i,width:480,padding:24,className:"PdfImportReviewPage__confirmModalV2",content:(0,_.jsxs)("div",{className:"PdfImportReviewPage__confirmModalBody",children:[r?(0,_.jsx)("p",{className:"PdfImportReviewPage__confirmModalText",children:r}):null,c?(0,_.jsx)(d.A,{status:"critical",message:c}):null]}),footer:(0,_.jsx)(V.A,{onCancel:l,onConfirm:t,cancelText:o,confirmText:a,confirmDisabled:s,confirmLoading:s,variant:"critical"===u?"danger":"primary"})})},fn=e=>{let{lineItems:n,currency:l,onChange:i}=e;const[r,a]=(0,t.useState)((()=>an(n))),o=(0,t.useCallback)((e=>{a((n=>{const l="function"===typeof e?e(n):e,t=on(l),r=function(e){let{vatPercentage:n=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=0,t=0,i=0,r=0;for(const a of e||[]){const{sub:e,taxAmount:n,amount:o,discountApplied:d}=(0,en.GZ)(a);l+=Number(e)||0,t+=Number(n)||0,i+=Number(o)||0,r+=Number(d)||0}return{subtotal_amount:tn(l),discount_amount:tn(r),tax_amount:tn(t),total_amount:tn(i),vat_percentage:dn(e,n)}}(l);return i(t,r),l}))}),[i]);return(0,_.jsx)("div",{className:"PdfImportReviewPage__lineItemsV2",children:(0,_.jsx)(Xe.A,{rows:r,setRows:o,currency:l||"EUR",ItemModalComponent:gn,ConfirmModalComponent:hn,formatDiscountDisplay:un})})},bn=e=>{if(null==e||""===e)return"\u2014";const n=Number(e);return Number.isFinite(n)?n.toFixed(2):"\u2014"},yn=e=>{if(null==e||""===e)return"\u2014";const n=Number(e);return Number.isFinite(n)?`${n}%`:"\u2014"},xn=e=>{let{totals:n}=e;return(0,_.jsxs)("div",{className:"PdfImportReviewPage__grid PdfImportReviewPage__grid--totals",children:[(0,_.jsx)(x,{label:"Subtotal amount",value:n.subtotal_amount,children:(0,_.jsx)("div",{className:"PdfImportReviewPage__totalsValue",children:bn(n.subtotal_amount)})}),(0,_.jsx)(x,{label:"Discount amount",value:n.discount_amount,children:(0,_.jsx)("div",{className:"PdfImportReviewPage__totalsValue",children:bn(n.discount_amount)})}),(0,_.jsx)(x,{label:"Tax amount",value:n.tax_amount,children:(0,_.jsx)("div",{className:"PdfImportReviewPage__totalsValue",children:bn(n.tax_amount)})}),(0,_.jsx)(x,{label:"Total amount",value:n.total_amount,children:(0,_.jsx)("div",{className:"PdfImportReviewPage__totalsValue PdfImportReviewPage__totalsValue--emphasis",children:bn(n.total_amount)})}),(0,_.jsx)(x,{label:"VAT percentage",value:n.vat_percentage,children:(0,_.jsx)("div",{className:"PdfImportReviewPage__totalsValue",children:yn(n.vat_percentage)})})]})};
1var Cn=l(72969),wn=l(29370);const kn=e=>{var n;let{pdfFile:l,sourceFileUrl:i,documentId:r}=e;const a=null!==(n=null!==l&&void 0!==l?l:i)&&void 0!==n?n:null,o=(0,t.useMemo)((()=>(0,wn.tR)(a)),[a]),d=a?String(a).split("/").filter(Boolean).pop():null,u=`${null!==r&&void 0!==r?r:""}:${null!==a&&void 0!==a?a:""}`;return(0,_.jsx)("div",{className:"PdfImportReviewPage__previewSticky",children:(0,_.jsxs)("aside",{className:"PdfImportReviewPage__preview",children:[(0,_.jsxs)("div",{className:"PdfImportReviewPage__previewHeader",children:[(0,_.jsx)("h2",{className:"PdfImportReviewPage__sectionTitle",children:"Source PDF"}),d?(0,_.jsx)("span",{className:"PdfImportReviewPage__previewFile",children:d}):null]}),(0,_.jsx)("div",{className:"PdfImportReviewPage__previewBody"+(o?" PdfImportReviewPage__previewBody--pdf":""),children:o?(0,_.jsx)("iframe",{id:"pdf-import-review-pdf-frame",className:"PdfImportReviewPage__previewFrame",src:`${o}${wn.vK}`,title:d?`Source PDF \u2014 ${d}`:"Source PDF"},u):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)("img",{src:Cn.A,alt:"",width:40,height:40,draggable:!1}),(0,_.jsx)("p",{children:"PDF preview will appear here."})]})})]})})},jn=e=>{let{open:n,onClose:l,onDiscard:t,onSaveDraft:i,saving:r=!1,error:a=null}=e;return n?(0,_.jsx)(q.A,{open:n,onClose:l,title:"Discard changes?",width:440,padding:20,closeOnOverlayClick:!r,closeOnEsc:!r,className:"UnsavedChangesModal",content:(0,_.jsxs)("div",{className:"UnsavedChangesModal__body",children:[(0,_.jsx)("p",{className:"UnsavedChangesModal__text",children:"You have unsaved changes."}),(0,_.jsx)("p",{className:"UnsavedChangesModal__text",children:"If you leave now, your changes will be lost."}),(0,_.jsx)("p",{className:"UnsavedChangesModal__text",children:"To keep your progress, save the draft before leaving."}),a?(0,_.jsx)("div",{className:"UnsavedChangesModal__banner",children:(0,_.jsx)(d.A,{status:"critical",message:a})}):null]}),footer:(0,_.jsx)(V.A,{onCancel:t,onConfirm:i,cancelText:"Discard changes",confirmText:"Save draft",cancelDisabled:r,confirmDisabled:r,confirmLoading:r,variant:"primary"})}):null},Sn=e=>null==e||"object"!==typeof e||Array.isArray(e)?{}:e,An=e=>{var n,l,t,i,r,a,o,d,u,s,c,v,m,_,p,g,h,f;const b=Sn(e),y=null!==(n=null!==(l=b.company_name)&&void 0!==l?l:b.supplier_name)&&void 0!==n?n:"",x=null!==(t=null!==(i=b.street)&&void 0!==i?i:b.address_line_1)&&void 0!==t?t:null,C=null!==(r=null!==(a=b.address_full)&&void 0!==a?a:x)&&void 0!==r?r:"";return{supplier_name:null!==(o=b.supplier_name)&&void 0!==o?o:null,company_name:null!==(d=b.company_name)&&void 0!==d?d:null,name:y,vat_number:null!==(u=b.vat_number)&&void 0!==u?u:"",registration_code:null!==(s=b.registration_code)&&void 0!==s?s:"",address:C,address_full:null!==(c=b.address_full)&&void 0!==c?c:null,address_line_1:x,email:null!==(v=b.email)&&void 0!==v?v:null,country_code:null!==(m=b.country_code)&&void 0!==m?m:null,city:null!==(_=b.city)&&void 0!==_?_:null,postal_code:null!==(p=b.postal_code)&&void 0!==p?p:null,bank_name:null!==(g=b.bank_name)&&void 0!==g?g:null,iban:null!==(h=b.iban)&&void 0!==h?h:null,bank_identifier:null!==(f=b.bank_identifier)&&void 0!==f?f:null}},Nn=e=>{var n,l,t,i,r,a,o,d,u,s;const c=Sn(e);return{customer_name:null!==(n=c.customer_name)&&void 0!==n?n:null,company_name:null!==(l=c.company_name)&&void 0!==l?l:null,vat_number:null!==(t=c.vat_number)&&void 0!==t?t:null,registration_code:null!==(i=c.registration_code)&&void 0!==i?i:null,email:null!==(r=c.email)&&void 0!==r?r:null,country_code:null!==(a=c.country_code)&&void 0!==a?a:null,city:null!==(o=c.city)&&void 0!==o?o:null,postal_code:null!==(d=c.postal_code)&&void 0!==d?d:null,address_full:null!==(u=c.address_full)&&void 0!==u?u:null,address_line_1:null!==(s=c.address_line_1)&&void 0!==s?s:null}},Pn=e=>Array.isArray(e)?e.map(((e,n)=>((e,n)=>{var l,t,i,r,a,o,d,u,s,c,v,m,_,p,g,h,f;const b=Sn(e),y=null!==(l=null!==(t=b.description)&&void 0!==t?t:b.name)&&void 0!==l?l:null,x=null!==(i=null!==(r=b.tax_rate)&&void 0!==r?r:b.tax_percent)&&void 0!==i?i:null;return{no:null!==(a=b.no)&&void 0!==a?a:n+1,id:b.id,sku:null!==(o=b.sku)&&void 0!==o?o:null,description:y,name:null!==(d=b.name)&&void 0!==d?d:y,quantity:null!==(u=b.quantity)&&void 0!==u?u:null,unit_price:null!==(s=b.unit_price)&&void 0!==s?s:null,tax_type:null!==(c=b.tax_type)&&void 0!==c?c:null,tax_percent:null!==(v=null!==(m=b.tax_percent)&&void 0!==m?m:b.tax_rate)&&void 0!==v?v:null,tax_value:null!==(_=b.tax_value)&&void 0!==_?_:null,tax_rate:x,discount_type:null!==(p=b.discount_type)&&void 0!==p?p:null,discount_value:null!==(g=b.discount_value)&&void 0!==g?g:null,discount_total:null!==(h=b.discount_total)&&void 0!==h?h:null,total:null!==(f=b.total)&&void 0!==f?f:null}})(e,n))):[],In=(e,n)=>{var l,t,i,r,a,o,d,u,s;const c=Sn(n);return{subtotal_amount:null!==(l=null!==(t=e.total_excluding_tax)&&void 0!==t?t:c.subtotal_amount)&&void 0!==l?l:null,discount_amount:null!==(i=null!==(r=e.total_discount_amounts)&&void 0!==r?r:c.discount_amount)&&void 0!==i?i:null,tax_amount:null!==(a=null!==(o=e.total_tax_amounts)&&void 0!==o?o:c.tax_amount)&&void 0!==a?a:null,total_amount:null!==(d=null!==(u=e.total)&&void 0!==u?u:c.total_amount)&&void 0!==d?d:null,vat_percentage:null!==(s=c.vat_percentage)&&void 0!==s?s:null}},Rn=e=>{var n,l,t,i,r,a,o,d,u,s,c,v,m,_,p,g,h,f,b,y,x,C,w,k,j,S,A,N,P,I,R,M,L,T;const F=Sn(e),E=Sn(F.data),D=Sn(E.scan),q=Sn(D.supplier),V=Sn(D.customer),B=Sn(D.totals),O=Pn(F.line_items);return{form:{id:null!==(n=F.id)&&void 0!==n?n:null,file:null!==(l=F.file)&&void 0!==l?l:null,status:null!==(t=F.status)&&void 0!==t?t:null,type:null!==(i=F.type)&&void 0!==i?i:null,invoice_type:null!==(r=F.invoice_type)&&void 0!==r?r:null,order_reference:null!==(a=F.order_reference)&&void 0!==a?a:null,reference_invoice_number:null!==(o=F.reference_invoice_number)&&void 0!==o?o:null,discount_description:null!==(d=F.discount_description)&&void 0!==d?d:null,note:null!==(u=F.note)&&void 0!==u?u:"",invoice_number:null!==(s=null!==(c=F.inv_number)&&void 0!==c?c:D.invoice_number)&&void 0!==s?s:"",invoice_date:null!==(v=null!==(m=F.created_date)&&void 0!==m?m:D.invoice_date)&&void 0!==v?v:null,due_date:null!==(_=null!==(p=F.due_date)&&void 0!==p?p:D.due_date)&&void 0!==_?_:null,currency:null!==(g=null!==(h=F.currency)&&void 0!==h?h:D.currency)&&void 0!==g?g:"",customer_id:null!==(f=null!==(b=F.customer)&&void 0!==b?b:E.customer_id)&&void 0!==f?f:null,vat_number_id:null!==(y=null!==(x=F.vat_number_id)&&void 0!==x?x:E.vat_number_id)&&void 0!==y?y:null,
1sales_tax_number_id:null!==(C=null!==(w=F.sales_tax_number_id)&&void 0!==w?w:E.sales_tax_number_id)&&void 0!==C?C:null,tax_number_id:null!==(k=null!==(j=F.tax_number_id)&&void 0!==j?j:E.tax_number_id)&&void 0!==k?k:null,bank_id:null!==(S=null!==(A=F.bank_id)&&void 0!==A?A:E.bank_id)&&void 0!==S?S:null,supplier:An(q),customer:Nn(V),line_items:O,totals:In(F,B)},draftMeta:{id:null!==(N=F.id)&&void 0!==N?N:null,documentId:null!==(P=F.id)&&void 0!==P?P:null,pdfFile:null!==(I=F.file)&&void 0!==I?I:null,status:null!==(R=F.status)&&void 0!==R?R:null,source:null!==(M=F.source)&&void 0!==M?M:"pdf_import",source_file_url:null!==(L=null!==(T=F.file)&&void 0!==T?T:F.source_file_url)&&void 0!==L?L:null}}},Mn=e=>null==e?"":String(e).trim(),Ln=e=>Mn(e).toUpperCase(),Tn=/^\d{4}-\d{2}-\d{2}$/,Fn=["SGD","EUR","USD","GBP","PLN","AUD"],En=e=>(e=>{const n=Number(e);return Number.isInteger(n)&&n>0})(e)?Number(e):null,Dn=e=>{const n=Mn(e);if(!n)return null;const l=n.toLowerCase();return"vat_invoice"===l?"vat_invoice":"sales_tax_invoice"===l?"sales_tax_invoice":"vat_document"===l?"vat_invoice":"sales_tax_document"===l?"sales_tax_invoice":null},qn=e=>Mn(e).toUpperCase()||"",Vn=e=>{const n=Mn(e);if(!Tn.test(n))return!1;const l=new Date(`${n}T00:00:00`);return!Number.isNaN(l.getTime())},Bn=e=>{if(""===e||null==e)return null;const n="string"===typeof e?e.replace(",",".").trim():e,l=Number(n);return Number.isFinite(l)?l:null},On=e=>!(!e||"object"!==typeof e)&&[e.name,e.description,e.sku,e.quantity,e.unit_price,e.discount_value,e.tax_rate,e.tax_value,e.total].some((e=>""!==Mn(e))),$n=e=>[["vat_number_id",En(null===e||void 0===e?void 0:e.vat_number_id)],["sales_tax_number_id",En(null===e||void 0===e?void 0:e.sales_tax_number_id)],["tax_number_id",En(null===e||void 0===e?void 0:e.tax_number_id)]].filter((e=>{let[,n]=e;return null!=n})),Un=function(e){var n;let{partial:l=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const t=Mn(null!==(n=null===e||void 0===e?void 0:e.company_name)&&void 0!==n?n:null===e||void 0===e?void 0:e.name),i=Mn(null===e||void 0===e?void 0:e.address_line_1),r=Mn(null===e||void 0===e?void 0:e.city),a=Mn(null===e||void 0===e?void 0:e.postal_code),o=qn(null===e||void 0===e?void 0:e.country_code);if(!l)return{company_name:t,street:i,city:r,postal_code:a,country_code:o};const d={};return t&&(d.company_name=t),i&&(d.street=i),r&&(d.city=r),a&&(d.postal_code=a),o&&(d.country_code=o),d},Wn=function(e){var n,l,t;let{requireComplete:i=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=Mn(null!==(n=null===e||void 0===e?void 0:e.name)&&void 0!==n?n:null===e||void 0===e?void 0:e.description),a=Bn(null===e||void 0===e?void 0:e.quantity),o=Bn(null===e||void 0===e?void 0:e.unit_price),d=Mn(null===e||void 0===e?void 0:e.sku),u=Mn(null===e||void 0===e?void 0:e.discount_type),s=Bn(null===e||void 0===e?void 0:e.discount_value),c=Bn(null!==(l=null!==(t=null===e||void 0===e?void 0:e.tax_rate)&&void 0!==t?t:null===e||void 0===e?void 0:e.tax_percent)&&void 0!==l?l:null===e||void 0===e?void 0:e.tax_value),v=Mn(null===e||void 0===e?void 0:e.tax_type);if(i)return{name:r,...d?{sku:d}:{},quantity:a,unit_price:o,...u?{discount_type:u}:{},...null!=s?{discount_value:s}:{},...null!=c?{tax_rate:c}:{},...v?{tax_type:v}:{},amount_tax_inclusive:!0===(null===e||void 0===e?void 0:e.amount_tax_inclusive)};const m={};return r&&(m.name=r),d&&(m.sku=d),null!=a&&(m.quantity=a),null!=o&&(m.unit_price=o),u&&(m.discount_type=u),null!=s&&(m.discount_value=s),null!=c&&(m.tax_rate=c),v&&(m.tax_type=v),!0!==(null===e||void 0===e?void 0:e.amount_tax_inclusive)&&!1!==(null===e||void 0===e?void 0:e.amount_tax_inclusive)||(m.amount_tax_inclusive=!0===e.amount_tax_inclusive),m},Hn=e=>(Array.isArray(e)?e:[]).filter(On).map((e=>Wn(e,{requireComplete:!0}))),zn=e=>e.customer_id?"Select a saved customer before creating the invoice.":e.bank_id?"Select saved banking information before creating the invoice.":e.tax_reference?"ambiguous"===e.tax_reference?"Only one resolved tax reference can be used when creating the invoice. Please keep just one tax ID selected.":"Select a saved VAT, sales tax, or tax number before creating the invoice.":e.invoice_number||e.invoice_date||e.due_date||e.currency||e.document_type?"Complete the required invoice details before creating the invoice.":e.supplier_company_name||e.supplier_street||e.supplier_city||e.supplier_postal_code||e.supplier_country?"Complete the required supplier details before creating the invoice.":e.line_items?"
1invalid_item"===e.line_items?"Each submitted line item must include a description, quantity, and unit price.":"Add at least one line item before creating the invoice.":"Invoice could not be created. Please check the form and try again.",Yn=function(e){var n;let{countries:l=[],countriesLoading:t=!1,countriesReady:i=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={};if(!e||"object"!==typeof e)return{isValid:!1,ok:!1,message:"Invoice could not be created. Please check the form and try again.",errors:{form:!0}};En(e.customer_id)||(r.customer_id=!0),En(e.bank_id)||(r.bank_id=!0);const a=$n(e);0===a.length?r.tax_reference="missing":a.length>1&&(r.tax_reference="ambiguous"),Mn(e.invoice_number)||(r.invoice_number=!0),Vn(e.invoice_date)||(r.invoice_date=!0),Vn(e.due_date)||(r.due_date=!0),(e=>{const n=Ln(e);return n.length>0&&Fn.includes(n)})(e.currency)||(r.currency=!0),Dn(e.type)||(r.document_type=!0);const o=null!==(n=e.supplier)&&void 0!==n?n:{},d=Un(o);d.company_name||(r.supplier_company_name=!0),d.street||(r.supplier_street=!0),d.city||(r.supplier_city=!0),d.postal_code||(r.supplier_postal_code=!0),function(e,n){let{countriesLoading:l=!1,countriesReady:t=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(l||!t)return!1;const i=qn(e);return!!i&&(Array.isArray(n)?n:[]).some((e=>[null===e||void 0===e?void 0:e.code,null===e||void 0===e?void 0:e.iso_code_2,null===e||void 0===e?void 0:e.iso_code_3,null===e||void 0===e?void 0:e.country_code].map(qn).includes(i)))}(d.country_code,l,{countriesLoading:t,countriesReady:i})||(r.supplier_country=!0);const u=Hn(e.line_items);0===u.length?r.line_items="missing":u.some((e=>!e.name||null==e.quantity||null==e.unit_price))&&(r.line_items="invalid_item");const s=0===Object.keys(r).length;return{isValid:s,ok:s,errors:r,message:s?null:zn(r)}},Gn=function(e,n){let{allowMissing:l=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const t=$n(n);if(1!==t.length)l||t.length;else{const[n,l]=t[0];e[n]=l}},Kn=(e,n)=>{let{status:l}=n;const t={status:l};if(!e||"object"!==typeof e)return t;const i=Dn(e.type),r=En(e.customer_id),a=En(e.bank_id),o=Mn(e.invoice_number),d=Mn(e.invoice_date),u=Mn(e.due_date),s=Ln(e.currency),c=Mn(e.order_reference),v=null==e.note?"":String(e.note);if("new"===l)return t.customer_id=r,t.bank_id=a,t.invoice_number=o,t.invoice_date=d,t.due_date=u,t.currency=s,t.document_type=i,t.note=v,t.supplier_data=Un(e.supplier),t.line_items=Hn(e.line_items),c&&(t.order_reference=c),Gn(t,e),t;null!=r&&(t.customer_id=r),null!=a&&(t.bank_id=a),o&&(t.invoice_number=o),Vn(d)&&(t.invoice_date=d),Vn(u)&&(t.due_date=u),s&&(t.currency=s),i&&(t.document_type=i),c&&(t.order_reference=c),""!==v&&(t.note=v);const m=Un(e.supplier,{partial:!0});Object.keys(m).length>0&&(t.supplier_data=m);const _=(p=e.line_items,(Array.isArray(p)?p:[]).filter(On).map((e=>Wn(e,{requireComplete:!1}))).filter((e=>Object.keys(e).length>0)));var p;return _.length>0&&(t.line_items=_),Gn(t,e,{allowMissing:!0}),t};var Jn=l(19853),Zn=l.n(Jn);const Qn=e=>{if(null==e)return null;try{if("function"===typeof structuredClone)return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))},Xn=(e,n)=>e?"string"===typeof e&&e.trim()?e:"string"===typeof e.error&&e.error.trim()?e.error:"string"===typeof e.message&&e.message.trim()?e.message:n:n,el=e=>Xn(e,"Failed to load imported invoice."),nl=e=>null==e||"string"!==typeof e&&(!!Array.isArray(e)||"object"===typeof e&&!e.error),ll=()=>{var e,n,l;const{draftId:g}=(0,a.g)(),h=(0,a.Zp)(),f=(0,c.eo)(),b=(0,t.useMemo)((()=>(0,s.O)(f)),[f]),y=(0,r.d4)((e=>{var n;return null!==(n=e.other)&&void 0!==n?n:{}})),x=(0,t.useMemo)((()=>Array.isArray(y.countries)?y.countries:[]),[y.countries]),C=Boolean(y.fetchingCountries),w=!C&&Array.isArray(x)&&x.length>0;(0,t.useEffect)((()=>{w||C||b((0,m.Zv)()).catch((()=>{}))}),[C,w,b]);const[k,j]=(0,t.useState)(!0),[S,A]=(0,t.useState)(!1),[N,I]=(0,t.useState)(null),[R,M]=(0,t.useState)(null),[L,T]=(0,t.useState)(null),[F,E]=(0,t.useState)(null),[D,q]=(0,t.useState)(!1),[V,B]=(0,t.useState)(!1),[O,$]=(0,t.useState)(null),[U,W]=(0,t.useState)(!1),[H,z]=(0,t.useState)(null),[Y,G]=(0,t.useState)(!1),[K,J]=(0,t.useState)(!1),Z=(0,t.useRef)(null),Q=(0,t.useRef)(null),X=(0,t.useRef)(!1);(0,t.useEffect)((()=>{let e=!1;return(async()=>
1{if(j(!0),A(!1),I(null),T(null),E(null),M(null),q(!1),B(!1),$(null),W(!1),z(null),G(!1),J(!1),Z.current=null,X.current=!1,Q.current&&(clearTimeout(Q.current),Q.current=null),!g)return A(!0),void j(!1);try{const n=await b((0,v.yI)(g));if(e)return;if(n&&n.error)return I(el(n)),T(null),E(null),M(null),A(!1),void j(!1);const l=(e=>{if(!e||"object"!==typeof e||Array.isArray(e))return null;if(e.error)return null;const n=e.document;return null==n||"object"!==typeof n||Array.isArray(n)?null==e.id||null==e.data&&null==e.is_ai_scanned&&"draft"!==e.status?null:e:n})(n);if(!((e,n)=>{var l;return!(!e||"object"!==typeof e||Array.isArray(e))&&String(e.id)===String(n)&&"draft"===e.status&&(!0===(null===e||void 0===e?void 0:e.is_ai_scanned)||Boolean(null===e||void 0===e||null===(l=e.data)||void 0===l?void 0:l.scan))})(l,g))return I(null),A(!0),T(null),E(null),M(null),void j(!1);const{form:t,draftMeta:i}=Rn(l);T(t),E(Qn(t)),M(i),A(!1),I(null),j(!1)}catch(n){if(e)return;I(el(n)),A(!1),T(null),E(null),M(null),j(!1)}})(),()=>{e=!0,Q.current&&(clearTimeout(Q.current),Q.current=null)}}),[g,b]);const ee=(0,t.useMemo)((()=>!Y&&((e,n)=>!(!e||!n)&&!Zn()(e,n))(L,F)),[Y,L,F]),ne=!(0,t.useMemo)((()=>Yn(L,{countries:x,countriesLoading:C,countriesReady:w})),[x,C,w,L]).isValid||U||K||Y,le=K||U||Y,te=(0,t.useCallback)((()=>{h("/documents")}),[h]),ie=(0,t.useCallback)((()=>{z(null)}),[]),re=null!==(e=null!==(n=null===R||void 0===R?void 0:R.documentId)&&void 0!==n?n:null===L||void 0===L?void 0:L.id)&&void 0!==e?e:g,ae=(0,t.useCallback)((()=>{V||K||(q(!1),$(null),Z.current=null)}),[K,V]),oe=(0,t.useCallback)((e=>{"function"===typeof e&&(Y?e():ee?(Z.current=e,$(null),q(!0)):e())}),[Y,ee]),de=(0,t.useCallback)((()=>{oe(te)}),[oe,te]),ue=(0,t.useCallback)((async()=>{if(!L||!re)return{ok:!1,error:"Draft could not be saved. Please try again."};const e=Kn(L,{status:"draft"});try{const n=await b((0,v.vc)({documentId:re,payload:e}));return nl(n)?(E(Qn(L)),{ok:!0}):{ok:!1,error:Xn(n,"Draft could not be saved. Please try again.")}}catch(n){return{ok:!1,error:Xn(n,"Draft could not be saved. Please try again.")}}}),[b,re,L]),se=(0,t.useCallback)((async()=>{if(!le){J(!0),z(null);try{const e=await ue();if(null!==e&&void 0!==e&&e.ok)return void z({status:"success",message:"Draft saved successfully.",context:"draft"});z({status:"error",message:(null===e||void 0===e?void 0:e.error)||"Draft could not be saved. Please try again.",context:"draft"})}finally{J(!1)}}}),[le,ue]),ce=(0,t.useCallback)((()=>{if(V||K)return;const e=Z.current;q(!1),$(null),Z.current=null,null===e||void 0===e||e()}),[K,V]),ve=(0,t.useCallback)((async()=>{if(!(V||K||U)){B(!0),J(!0),$(null);try{const e=await ue();if(null!==e&&void 0!==e&&e.ok){const e=Z.current;return q(!1),$(null),Z.current=null,z({status:"success",message:"Draft saved successfully.",context:"draft"}),void(null===e||void 0===e||e())}$((null===e||void 0===e?void 0:e.error)||"Draft could not be saved. Please try again.")}catch(e){$(Xn(e,"Draft could not be saved. Please try again."))}finally{B(!1),J(!1)}}}),[K,U,V,ue]),me=(0,t.useCallback)((async()=>{if(U||Y||K)return;const e=Yn(L,{countries:x,countriesLoading:C,countriesReady:w});if(!e.isValid)return void z({status:"error",message:e.message||"Invoice could not be created. Please check the form and try again.",context:"finalization"});const n=Kn(L,{status:"new"});W(!0),z(null);try{const e=await b((0,v.vc)({documentId:re,payload:n}));if(!nl(e))return void z({status:"error",message:Xn(e,"Invoice could not be created. Please check the form and try again."),context:"finalization"});G(!0),E(Qn(L)),q(!1),$(null),Z.current=null,z({status:"success",message:"Invoice created successfully. You\u2019ll be redirected to Documents shortly.",context:"finalization"}),X.current||(X.current=!0,Q.current=setTimeout((()=>{Q.current=null,te()}),2e3))}catch(l){z({status:"error",message:Xn(l,"Invoice could not be created. Please check the form and try again."),context:"finalization"})}finally{W(!1)}}),[x,C,w,b,re,K,Y,U,L,te]);if(k)return(0,_.jsxs)("div",{className:"PdfImportReviewPage",children:[(0,_.jsx)(i.m,{children:(0,_.jsx)("title",{children:"Review imported invoice \u2014 L\u2019Invoice"})}),(0,_.jsx)(o.Y,{fullWidth:!0,children:(0,_.jsx)("p",{className:"PdfImportReviewPage__status",children:"Loading imported invoice\u2026"})})]});
1if(N||S||!L||!R){const e=Boolean(N);return(0,_.jsxs)("div",{className:"PdfImportReviewPage",children:[(0,_.jsx)(i.m,{children:(0,_.jsx)("title",{children:e?"Failed to load imported invoice \u2014 L\u2019Invoice":"Imported draft unavailable \u2014 L\u2019Invoice"})}),(0,_.jsxs)(o.Y,{fullWidth:!0,children:[(0,_.jsx)(u.A,{title:e?"Failed to load imported invoice":"Imported draft unavailable",subtitle:"Return to Documents and open the draft again.",backLabel:"Documents",onBack:te}),(0,_.jsx)(d.A,{status:e?"critical":"warning",message:N||"Return to Documents and open the draft again."}),(0,_.jsx)("div",{className:"PdfImportReviewPage__actions",children:(0,_.jsx)("div",{className:"PdfImportReviewPage__actionsGroup",children:(0,_.jsx)("button",{type:"button",className:"PdfImportReviewPage__btn PdfImportReviewPage__btn--primary",onClick:te,children:"Back to Documents"})})})]})]})}return(0,_.jsxs)("div",{className:"PdfImportReviewPage",children:[(0,_.jsx)(i.m,{children:(0,_.jsx)("title",{children:"Review imported invoice \u2014 L\u2019Invoice"})}),(0,_.jsxs)(o.Y,{fullWidth:!0,children:[(0,_.jsx)(u.A,{title:"Review imported invoice",subtitle:"Review the extracted data, make any necessary changes, and save the invoice.",backLabel:"Documents",onBack:de}),H?(0,_.jsx)("div",{className:"PdfImportReviewPage__banner",children:(0,_.jsx)(d.A,{status:"success"===H.status?"success":"critical",message:H.message,onDismiss:ie})}):null,(0,_.jsxs)("div",{className:"PdfImportReviewPage__layout",children:[(0,_.jsxs)("div",{className:"PdfImportReviewPage__formColumn",children:[(0,_.jsx)(p,{title:"Document basics",children:(0,_.jsx)(P,{values:L,onChange:(e,n)=>{T((l=>({...l,[e]:""===n?null:n})))}})}),(0,_.jsx)(p,{title:"Supplier",children:(0,_.jsx)(Ze,{party:L.supplier,vatNumberId:L.vat_number_id,bankId:L.bank_id,currency:L.currency,idPrefix:"pdf-review-supplier",onVatNumberIdChange:e=>T((n=>e?{...n,vat_number_id:e,sales_tax_number_id:null,tax_number_id:null}:{...n,vat_number_id:null})),onBankChange:e=>T((n=>({...n,bank_id:e}))),onChange:e=>T((n=>({...n,supplier:e})))})}),(0,_.jsx)(p,{title:"Customer",children:(0,_.jsx)(Qe,{party:L.customer,customerId:L.customer_id,idPrefix:"pdf-review-customer",onCustomerIdChange:e=>T((n=>({...n,customer_id:e}))),onChange:e=>T((n=>({...n,customer:e})))})}),(0,_.jsx)(p,{title:"Line items",children:(0,_.jsx)(fn,{lineItems:L.line_items,currency:L.currency,onChange:(e,n)=>T((l=>({...l,line_items:e,totals:n})))})}),(0,_.jsx)(p,{title:"Totals",children:(0,_.jsx)(xn,{totals:L.totals})}),(0,_.jsx)(p,{title:"Comment / Note",children:(0,_.jsx)(vn,{id:"pdf-review-note",rows:3,clearAriaLabel:"Clear comment / note",value:null!==(l=L.note)&&void 0!==l?l:"",onChange:e=>T((n=>({...n,note:e.target.value})))})})]}),(0,_.jsx)("div",{className:"PdfImportReviewPage__previewColumn",children:(0,_.jsx)(kn,{documentId:R.documentId,pdfFile:R.pdfFile,sourceFileUrl:R.source_file_url})})]}),(0,_.jsx)("div",{className:"PdfImportReviewPage__actions",children:(0,_.jsxs)("div",{className:"PdfImportReviewPage__actionsGroup",children:[(0,_.jsx)("button",{type:"button",className:"PdfImportReviewPage__btn PdfImportReviewPage__btn--secondary",onClick:de,children:"Cancel"}),(0,_.jsx)("button",{type:"button",className:"PdfImportReviewPage__btn PdfImportReviewPage__btn--secondary",onClick:()=>{le||se()},disabled:le,"aria-disabled":le,children:K?"Saving draft...":"Save draft"}),(0,_.jsx)("button",{type:"button",className:"PdfImportReviewPage__btn PdfImportReviewPage__btn--primary",onClick:()=>{ne||me()},disabled:ne,"aria-disabled":ne,children:U?"Creating invoice...":"Create invoice"})]})})]}),(0,_.jsx)(jn,{open:D,onClose:ae,onDiscard:ce,onSaveDraft:ve,saving:V,error:O})]})}},27378:(e,n,l)=>{l.d(n,{A:()=>a});l(65043);var t=l(66823),i=l(26699),r=l(70579);const a=e=>{let{label:n,onChange:l,checked:a}=e;const o=(0,r.jsx)("input",{type:"checkbox",onChange:e=>l(e.target.checked),checked:a}),d=(0,r.jsx)("span",{className:"slider round"});return n?(0,r.jsx)(t.a,{display:"flex",alignItems:"start",gap:"4",children:(0,r.jsxs)("label",{className:"toggle-switch-with-label",children:[(0,r.jsxs)("span",{className:"switch",children:[o,d]}),"string"===typeof n||"number"===typeof n?(0,r.jsx)(i.E,{as:"span",variant:"bodyMd",children:n}):(0,r.jsx)("span",{className:"toggle-switch-with-label__text",children:n})]})}
1):(0,r.jsx)(t.a,{display:"flex",alignItems:"start",gap:"4",children:(0,r.jsxs)("label",{className:"switch",children:[o,d]})})}},29370:(e,n,l)=>{l.d(n,{Ay:()=>a,tR:()=>r,vK:()=>i});var t=l(59217);const i="#toolbar=1&statusbar=0&view=FitH&zoom=FitW";function r(e){if(null==e)return"";const n=String(e).trim();if(!n)return"";if(/^(https?:|blob:|data:)/i.test(n))return n;const l=function(e){if(null==e)return"";let n=String(e).trim();return n?/^(https?:|blob:|data:)/i.test(n)?n:(n=n.replace(/^(\.\.\/)+/,""),n=n.replace(/^\/+/,""),n.startsWith("media/")?`/${n}`:n.startsWith("documents/")?`/media/${n}`:n?`/${n}`:""):""}(n);if(!l)return"";if(/^(https?:|blob:|data:)/i.test(l))return l;const i=String(t.VY||"").replace(/\/$/,"");return i?`${i}${l}`:l}const a=r},38230:(e,n,l)=>{l.d(n,{A:()=>d});var t=l(65043),i=l(97950),r=l(35047),a=l(13397),o=(l(87909),l(56011),l(70579));const d=e=>{let{actions:n=[],rowId:l,openRowId:d,setOpenRowId:u,containerSelector:s,className:c="",menuClassName:v="",iconFill:m="rgba(112, 112, 112, 1)",showTriggerWhenEmpty:_=!1}=e;const p=(0,t.useRef)(null),g=(0,t.useRef)(null),[h,f]=(0,t.useState)({top:0,right:0}),[b,y]=(0,t.useState)(!1),[x,C]=(0,t.useState)(!1),[w,k]=(0,t.useState)("bottom"),j=(null!=d&&null!=l&&(String(d),String(l)),n.filter((e=>!1!==e.visible)));(0,t.useEffect)((()=>{null!=d&&String(d)!==String(l)&&x&&(C(!1),y(!1))}),[d,l,x]);const S=()=>{y(!1),C(!1),u&&u(null)},A=()=>"function"===typeof s?s():"string"===typeof s&&document.querySelector(s)||document.body;(0,t.useEffect)((()=>{let e;if(x&&p.current){if(!A())return;const n=(p.current.querySelector(".Polaris-Icon")||p.current).getBoundingClientRect(),l=window.innerWidth,t=36,i=260,r=Math.min(j.length*t,i),a=window.innerHeight-n.bottom-8,o=n.top-8;let d="bottom";a<r&&o>a&&(d="top"),k(d);let u,s=l-(n.right-n.width/2);l-s<188&&(s=l-180-8),"bottom"===d?u=n.bottom+6:(u=n.top-r-6,u<8&&(u=8)),f({to
1p:u,right:Math.max(8,s)}),e=setTimeout((()=>{y(!0)}),10)}else y(!1);return()=>{e&&clearTimeout(e)}}),[x,s,j.length]),(0,t.useEffect)((()=>{if(!b)return;const e=e=>{!g.current||g.current.contains(e.target)||p.current.contains(e.target)||S()},n=()=>{S()},l=()=>{S()};return document.addEventListener("mousedown",e),window.addEventListener("resize",n),window.addEventListener("scroll",l,!0),()=>{document.removeEventListener("mousedown",e),window.removeEventListener("resize",n),window.removeEventListener("scroll",l,!0)}}),[b]);return j&&0!==j.length?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{ref:p,className:`dots-button dropdown-actions-dots ${c}`,onClick:e=>{e.stopPropagation();const n=!x;C(n),u&&u(n?l:null)},style:{display:"inline-block"},children:(0,o.jsx)(a.$,{variant:"tertiary",icon:(0,o.jsx)(r.Mg,{fill:m}),accessibilityLabel:"More actions"})}),b&&x&&(()=>{const e=A();return e?(0,i.createPortal)((0,o.jsx)("div",{ref:g,style:{position:"fixed",top:h.top,right:h.right,background:"white",border:"1px solid #e1e3e5",borderRadius:"8px",boxShadow:"0 6px 16px rgba(0,0,0,0.12)",zIndex:1e5,minWidth:180,maxWidth:"calc(100vw - 16px)",maxHeight:260,overflowY:"auto",overflowX:"hidden"},className:`row-actions-portal-dropdown row-actions-portal-dropdown--${w}${v?` ${v}`:""}`,children:j.map(((e,n)=>{const l="BankActions__item "+("delete"===e.variant?"BankActions__delete":"");return(0,o.jsx)("button",{onClick:(t=e.onClick,e=>{null===e||void 0===e||e.stopPropagation(),null===t||void 0===t||t(e),S()}),disabled:e.disabled,className:l,style:{opacity:e.disabled?.5:1,cursor:e.disabled?"not-allowed":"pointer"},children:e.label},n);var t}))}),e):null})()]}):_?(0,o.jsx)("div",{className:`dots-button dropdown-actions-dots ${c}`,style:{display:"inline-block"},children:(0,o.jsx)(a.$,{variant:"tertiary",icon:(0,o.jsx)(r.Mg,{fill:m}),accessibilityLabel:"More actions",disabled:!0})}):null}},39025:(e,n,l)=>{l.d(n,{EH:()=>c,KA:()=>d,O3:()=>m,W2:()=>p,pN:()=>v,wI:()=>_});var t=l(73816),i=l(71087),r=l(59128),a=l(86178),o=l.n(a);function d(e){return(0,r.WU)(e)}function u(e){var n,l;return String(null!==(n=null!==(l=null===e||void 0===e?void 0:e.province)&&void 0!==l?l:null===e||void 0===e?void 0:e.state)&&void 0!==n?n:"").trim()}function s(e){var n;let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const t=null!==(n=null===l||void 0===l?void 0:l[e])&&void 0!==n?n:[];return Array.isArray(t)&&t.length>0}function c(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return null!==e&&void 0!==e&&e.country_id&&s(e.country_id,n)?(0,r.S9)(e.country_id)&&!u(e)?"vat_number":"tin_number":"vat_number"}function v(e){var n;let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const t={...e&&"object"===typeof e?e:{}},i=t.country_id;if(!s(i,l))return t;const a=u(t),o={...t,province:a||"",state:a||""};var d;if(!(0,r.S9)(i))return{...o,tin_number:null!==(d=t.tin_number)&&void 0!==d?d:""};if(!a){var c,v;const e=String(null!==(c=null!==(v=t.vat_number)&&void 0!==v?v:t.tin_number)&&void 0!==c?c:"").trim();return{...o,vat_number:e,tin_number:""}}return{...o,tin_number:String(null!==(n=t.tin_number)&&void 0!==n?n:"").trim(),vat_number:""}}function m(e,n){var l;let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var i;if(!s(null===n||void 0===n?void 0:n.country_id,t))return e.vat_number=String(null!==(i=null===n||void 0===n?void 0:n.vat_number)&&void 0!==i?i:"").trim(),e;const r=u(n);var a;return"tin_number"===c(n,t)?(e.tin_number=String(null!==(a=null===n||void 0===n?void 0:n.tin_number)&&void 0!==a?a:"").trim(),e.vat_number="",e.state=r,e):(e.vat_number=String(null!==(l=null===n||void 0===n?void 0:n.vat_number)&&void 0!==l?l:"").trim(),e.tin_number="",e.state="",e)}function _(e){const n=null===e||void 0===e?void 0:e[0];return{id:null,vat_number:"",country_id:"",reason_for_registration_id:null,from_date:(0,i.y5)(o()().startOf("day").toDate()),till_date:null,nexus_date:null,due_date:null,periodicity:"",vat_agent_id:null,
1send_reminder:!0,type_of_activity_id:null,steuernummer:"",germany_state_id:null!=n?String(n.id):"",province:null,tin_number:"",status:"new",calculate_threshold:!0}}function p(e){var n,l,i;let{vatCountryStates:r={},germanyStates:a,validateSteuernummer:o=()=>!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return!0;if(!e.country_id||""===String(e.country_id).trim())return!0;const u=e.reason_for_registration_id;if(null==u||""===String(u).trim()||0===Number(u))return!0;const s=null!==(n=null===r||void 0===r?void 0:r[e.country_id])&&void 0!==n?n:[],v=Array.isArray(s)&&s.length>0,m=c(e,r);if(v){var _,p;if(d(e.country_id)&&!e.province)return!0;if("tin_number"===m){if(!String(null!==(p=e.tin_number)&&void 0!==p?p:"").trim())return!0}else if(!String(null!==(_=e.vat_number)&&void 0!==_?_:"").trim())return!0}else if(!String(null!==(l=e.vat_number)&&void 0!==l?l:"").trim())return!0;if(!String(null!==(i=e.from_date)&&void 0!==i?i:"").trim())return!0;if(null==(0,t.Oi)(e.periodicity))return!0;if("DEU"===e.country_id&&(null===a||void 0===a?void 0:a.length)>0){var g;const n=e.germany_state_id;if(null==n||""===String(n).trim())return!0;if(!String(null!==(g=e.steuernummer)&&void 0!==g?g:"").trim())return!0;if(o){if(!o(Number(n),e.steuernummer))return!0}}return!1}},56011:()=>{},59128:(e,n,l)=>{l.d(n,{Bt:()=>o,Ky:()=>t,PC:()=>s,S9:()=>d,WU:()=>m,XM:()=>v,gO:()=>i,jr:()=>u,u_:()=>c,y0:()=>_});const t=["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming"],i=["Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland and Labrador","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon"],r={Alabama:"AL",Alaska:"AK",Arizona:"AZ",Arkansas:"AR",California:"CA",Colorado:"CO",Connecticut:"CT",Delaware:"DE",Florida:"FL",Georgia:"GA",Hawaii:"HI",Idaho:"ID",Illinois:"IL",Indiana:"IN",Iowa:"IA",Kansas:"KS",Kentucky:"KY",Louisiana:"LA",Maine:"ME",Maryland:"MD",Massachusetts:"MA",Michigan:"MI",Minnesota:"MN",Mississippi:"MS",Missouri:"MO",Montana:"MT",Nebraska:"NE",Nevada:"NV","New Hampshire":"NH","New Jersey":"NJ","New Mexico":"NM","New York":"NY","North Carolina":"NC","North Dakota":"ND",Ohio:"OH",Oklahoma:"OK",Oregon:"OR",Pennsylvania:"PA","Rhode Island":"RI","South Carolina":"SC","South Dakota":"SD",Tennessee:"TN",Texas:"TX",Utah:"UT",Vermont:"VT",Virginia:"VA",Washington:"WA","West Virginia":"WV",Wisconsin:"WI",Wyoming:"WY"},a={Alberta:"AB","British Columbia":"BC",Manitoba:"MB","New Brunswick":"NB","Newfoundland and Labrador":"NL","Northwest Territories":"NT","Nova Scotia":"NS",Nunavut:"NU",Ontario:"ON","Prince Edward Island":"PE",Quebec:"QC",Saskatchewan:"SK",Yukon:"YT"};function o(e){const n=String(null!==e&&void 0!==e?e:"").trim().toUpperCase();return"USA"===n||"US"===n}function d(e){const n=String(null!==e&&void 0!==e?e:"").trim().toUpperCase();return"CAN"===n||"CA"===n||"CANADA"===n}function u(e){const n=String(null!==e&&void 0!==e?e:"").trim().toUpperCase();return"ARE"===n||"AE"===n||"UAE"===n}function s(e){var n;let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(1!==Number(null===e||void 0===e?void 0:e.type_of_report))return!1;const t=Number(null===e||void 0===e?void 0:e.reason_for_registration_id);if(1!==t&&4!==t)return!1;const i=String(null!==(n=null===e||void 0===e?void 0:e.customer_country_id)&&void 0!==n?n:"").trim().toUpperCase();return!!i&&(!!function(e){const n=String(null!==e&&void 0!==e?e:"").trim().toUpperCase();return"GBR"===n||"GB"===n||"UK"===n}(i)||(l||[]).some((e=>{var n;return String(null!==(n=null===e||void 0===e?void 0:e.code)&&void 0!==n?n:"").trim().toUpperCase()===i})))}function c(e,n){const l=null===n||void 0===n?void 0:n.state_rate;return l&&"object"===typeof l&&Object.keys(l).length>0}function v(e){return o(e)||d(e)}function m(e){return o(e)}function _(e,n){if(null==n)return"";const l=String(n).trim();if(""===l)return"";const t=o(e),i=d(e);return t||i?/^[A-Za-z]{2}$/.test(l)?l.toUpperCase():t?r[l]||l:a[l]||l:l}},62902:(e,n,l)=>{l.d(n,{A:()=>t.A});var t=l(38230)},74123:(e,n,l)=>{l.d(n,{A:()=>c});var t=l(65043),i=l(26699),r=l(11568),a=l(44154),o=l(13397),d=l(68547),u=l(33852),s=l(70579);const c=e=>{let{visible:n,onClose:l,onConfirm:c,title:v="Confirm action",description:m="",caption:_,highlight:p,tone:g="critical",error:h=null,loading:f=!1,confirmText:b="Confirm",cancelText:y="Cancel",requireAcknowledge:x=!1,acknowledgeLabel:C="I understand this action cannot be undone.",extra:w}=e;const[k,j]=(0,t.useState)(!1),S=(0,t.useMemo)((()=>(e=>({critical:"danger",warning:"warning",success:"success",info:"info",neutral:"note"}[e]||"note"))(g)),[g]),A=(0,t.useMemo)((()=>(e=>"critical"===e?{tone:"critical",variant:"plain"}:{variant:"primary"})(g)),[g]),N=!f&&(!x||k);return(0,s.jsx)(d.A,{title:v,iconType:S,description:(0,s.jsxs)("div",{style:{display:"grid",gap:8},children:[m&&(0,s.jsx)(i.E,{as:"p",variant:"bodyMd",children:m}),p&&(0,s.jsx)("div",{children:(0,s.jsx)(r.E,{status:"critical"===g?"critical":"info",children:p})}),_&&(0,s.jsx)(i.E,{as:"p",tone:"subdued",variant:"bodySm",children:_})]}
1),visible:n,onClose:l,content:w||null,footer:(0,s.jsxs)("div",{style:{display:"grid",gap:12},children:[h&&(0,s.jsx)(u.A,{status:"critical",message:h}),x&&(0,s.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"flex-start",cursor:"pointer"},children:[(0,s.jsx)("input",{type:"checkbox",checked:k,onChange:e=>j(e.target.checked),style:{marginTop:4}}),(0,s.jsx)("span",{style:{lineHeight:1.4},children:C})]}),(0,s.jsxs)(a.e,{fullWidth:!0,children:[(0,s.jsx)(o.$,{onClick:l,disabled:f,children:y}),(0,s.jsx)(o.$,{...A,loading:f,disabled:!N,onClick:c,children:b})]})]})})}},87909:()=>{},95354:(e,n,l)=>{l.d(n,{A:()=>t});const t=l(27378).A}}]);
2//# sourceMappingURL=route-pdf-import-review.21aa92dc.chunk.js.map

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.