1import{p as we,u as R,j as e,B as V,Z as Se,L as Fe,c as F,C as ke,a7 as pe,e as _e,ab as Ne,t as me,aa as Be,W as We,m as ne,Y as qe,af as ce,ag as xe,n as ae,M as Le,P as Oe,o as $e,g as Ae}from"./index-BHSftCjs.js";import{r as C,a as Me,L as ie}from"./vendor-8evPHt-B.js";import{L as te,g as E,M as he,N as Re,W as X,b as Y,a as Te,c as De,j as Ue,z as ge,e as Ie,O as Ee,P as Ve,w as He,x as Ge,y as Ze,Q as Ke,l as Qe,d as Xe,i as Ye,R as ue}from"./WorkspaceRouter-BtvKmUdW.js";import{M as Pe}from"./Modal-CYxQR3St.js";import{m as ve,a as Je,g as oe}from"./canonical-Dxjq3lPa.js";import{W as es}from"./WzFixDialog-VGm-bBn6.js";import{T as ss}from"./triangle-alert-Cljif_-K.js";import{R as as}from"./refresh-cw-F0qRGoC-.js";import{P as ts}from"./pencil-CbSXr_ay.js";import{B as J}from"./building-2-EHppiFfN.js";import{B as re}from"./briefcase-business-vdW7Iclu.js";import{A as le}from"./file-search-EBZsD4va.js";import{C as fe}from"./circle-alert-DNFYTFJj.js";import{L as ns}from"./landmark-B2OAbn23.js";import{G as cs,T as is,P as os}from"./SidebarBrand-DsW4xGuy.js";import{U as rs}from"./users-WvZkmMVf.js";import{C as ls}from"./clock-D2VTSOSM.js";/** 2 * @license lucide-react v0.563.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ds=[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],ye=we("search-x",ds);/** 7 * @license lucide-react v0.563.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const ms=[["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m14.305 16.53.923-.382",key:"1itpsq"}],["path",{d:"m15.228 13.852-.923-.383",key:"eplpkm"}],["path",{d:"m16.852 12.228-.383-.923",key:"13v3q0"}],["path",{d:"m16.852 17.772-.383.924",key:"1i8mnm"}],["path",{d:"m19.148 12.228.383-.923",key:"1q8j1v"}],["path",{d:"m19.53 18.696-.382-.924",key:"vk1qj3"}],["path",{d:"m20.772 13.852.924-.383",key:"n880s0"}],["path",{d:"m20.772 16.148.924.383",key:"1g6xey"}],["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],ps=we("user-cog",ms);function xs({hint:a,onReview:i,onConfirm:s,busy:d=!1}){const{t:u}=R(),j=!!a.options?.length;return e.jsxs("div",{role:"note",className:"flex gap-3 rounded-lg border border-[var(--eiq-amber-line)] bg-[var(--eiq-amber-soft)] p-3",children:[e.jsx(ss,{className:"mt-0.5 h-4 w-4 shrink-0 text-[var(--eiq-amber)]","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"flex flex-wrap items-baseline gap-x-2 text-sm font-semibold text-slate-900",children:[u(j?"companyPage.wz.question.title":"companyPage.wz.hintTitle"),!j&&e.jsx("span",{className:"text-[11px] font-normal text-slate-500",children:u("companyPage.wz.hintSource")})]}),e.jsx("p",{className:"mt-0.5 text-sm leading-5 text-slate-700",children:a.message})]}),i||s?e.jsxs("div",{className:"flex flex-wrap gap-2",children:[i&&e.jsx(V,{"data-track":"wz_hint_callout.on_review",size:"sm",variant:"outline",className:"bg-white",onClick:i,disabled:d,children:u(j?"companyPage.wz.question.answer":"companyPage.wz.review")}),s&&!j&&e.jsx(V,{"data-track":"wz_hint_callout.on_confirm",size:"sm",variant:"ghost",onClick:s,loading:d,disabled:d,children:u("companyPage.wz.confirmCurrent")})]}):null]})]})}const hs=["lookup","invoice","tables","check","you"];function gs(){const{t:a}=R(),[i,s]=C.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("button",{"data-track":"wz_info_button.company_page_wz_info_open",type:"button",onClick:()=>s(!0),"aria-label":a("companyPage.wz.info.open"),className:"inline-flex h-6 w-6 items-center justify-center rounded-full text-slate-400 transition hover:bg-slate-100 hover:text-slate-700 focus-ring",children:e.jsx(Se,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(Pe,{analyticsName:"wz_info_button.modal",isOpen:i,onClose:()=>
11s(!1),title:a("companyPage.wz.info.title"),size:"md",footer:e.jsx(V,{"data-track":"wz_info_button.company_page_wz_info_close",onClick:()=>s(!1),children:a("companyPage.wz.info.close")}),children:e.jsxs("div",{className:"space-y-5 text-sm text-slate-700",children:[e.jsx("ul",{className:"space-y-2",children:["2003","2008","2025"].map(d=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(te,{version:d}),e.jsx("span",{children:a(`companyPage.wz.info.use.${d}`)})]},d))}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-slate-900",children:a("companyPage.wz.info.howTitle")}),e.jsx("ol",{className:"space-y-1.5",children:hs.map((d,u)=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-slate-100 text-xs font-semibold text-slate-600",children:u+1}),e.jsx("span",{children:a(`companyPage.wz.info.steps.${d}`)})]},d))})]}),e.jsx("p",{className:"rounded-lg bg-slate-50 px-3 py-2 text-slate-600",children:a("companyPage.wz.info.final")})]})})]})}function us({canonical:a,fetched:i,hint:s,gate:d,search:u,derive:j,editable:_=!0,framed:b=!0,editInline:n=!1,onSave:f,onUseCodes:P,onPickCandidate:o,onUseSuggestion:S,onConfirm:p,onSaveFields:r,showCodes:B=!1}){const{t:w,i18n:H}=R(),[y,q]=C.useState(!1),[T,W]=C.useState(null),[v,K]=C.useState(!1),[L,D]=C.useState(!1),G=async()=>{if(!(!p||L)){D(!0);try{await p()}catch{}finally{D(!1)}}},O=m=>new Date(m).toLocaleDateString(H.language?.startsWith("en")?"en-GB":"de-DE"),$=s&&!(s.suggestion&&ve(a,s.suggestion)),U=E.some(m=>{const x=a[m]?.provenance;return x==="manual"||x==="selected"||x==="manualMatch"}),I=E.some(m=>a[m]?.code),A=!!(p&&I&&!s?.options?.length&&($||d?.reasons?.some(m=>m?.kind==="discrepancy")));return e.jsxs("section",{"data-track-view":"wz_canonical_panel.company_page_wz_gate_title_view",className:b?"space-y-4 rounded-lg border border-slate-200 bg-white p-4 sm:rounded-xl sm:p-6":"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("h2",{className:"text-base font-semibold text-slate-950",children:w("companyPage.wz.title")}),e.jsx(gs,{})]}),_&&!(n&&y)&&e.jsx(V,{"data-track":"wz_canonical_panel.company_page_wz_edit_2",size:"sm",variant:"outline",onClick:()=>q(!0),children:w("companyPage.wz.edit")})]}),!(n&&y)&&d?.blocked&&e.jsxs("p",{className:"flex items-center gap-1.5 text-sm font-medium text-[var(--eiq-amber)]",children:[e.jsx(Fe,{className:"h-3.5 w-3.5","aria-hidden":"true"}),w("companyPage.wz.gate.title")]}),!(n&&y)&&I&&!d?.blocked&&e.jsx("p",{className:"text-sm text-slate-600",children:w(U?"companyPage.wz.statusChosen":"companyPage.wz.statusFetched")}),!(n&&y)&&s&&$&&e.jsx(xs,{hint:s,onReview:_?()=>r?W(Je(a)):q(!0):void 0,onConfirm:_&&A?()=>void G():void 0,busy:L}),!(n&&y)&&e.jsx("ul",{className:"divide-y divide-slate-100 overflow-hidden rounded-lg border border-slate-200",children:E.map(m=>{const x=a[m],t=d?.reasons?.some(z=>z?.kind==="missing"&&z.version===m),c=d?.reasons?.some(z=>z?.kind==="discrepancy"&&(z.version===m||z.version==="both"&&m!=="2025")),l=t&&(m==="2003"||m==="2008")?{kind:"missing",version:m}:c?{kind:"discrepancy"}:null,k=l&&_?e.jsx(V,{"data-track":"wz_canonical_panel.button",size:"sm",variant:"outline",className:"bg-white",onClick:()=>r?W(l):q(!0),children:w(l.kind==="missing"?"companyPage.wz.gate.add":"companyPage.wz.gate.check")}):null;return e.jsxs("li",{className:F("flex flex-wrap items-center gap-x-4 gap-y-2 px-3 py-3 sm:px-4",l&&js),children:[e.jsx("div",{className:"flex w-[7rem] shrink-0 items-center",children:e.jsx(te,{version:m})}),x?.code?e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(he,{code:x.code,className:"block"}),(x.candidates?.length??0)>1&&e.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:w("companyPage.wz.narrowable",{count:x.candidates?.length})})]}):x?.candidates?.length?e.jsx("p",{className:F("min-w-0 flex-1 text-sm",t?"font-medium text-[var(--eiq-amber)]":"text-slate-500"),children:w(t?"companyPage.wz.missingMatches":"companyPage.wz.openMatches",{count:x.candidates.length})}):m==="2025"?e.jsx("p",{className:"min-w-0 flex-1 text-sm text-slate-400",children:w("companyPage.wz.notSet")}):e.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium text-[var(--eiq-amber)]",children:w("companyPage.wz.requiredMissing")}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[x?.code&&e.jsx(Re,{provenance:x.provenance}),k]})]},m)})}),!(n&&y)&&i.length>0&&e.jsxs("div",{children:[e.jsxs("button",{"data-track":"wz_canonical_panel.button_2",type:"button","aria-expanded":v,onClick:()=>K(m=>!m),className:"flex w-full items-center justify-between gap-2 text-left text-sm font-semibold text-slate-800 focus-ring",children:[e.jsxs("span",{children:[w("companyPage.wz.fetchedTitle")," ",e.jsx("span",{className:"font-normal tabular-nums text-slate-500",children:i.length})]}),e.jsx(ke,{className:F("h-4 w-4 text-slate-400 transition-transform",v&&"rotate-180"),"aria-hidden":"true"})]}),v&&e.jsx("ul",{className:"mt-3 space-y-2",children:i.map(m=>e.jsxs("li",{className:"rounded-lg border border-slate-200 p-3",children:[e.jsx(fs,{result:m,formatDate:O}),e.jsx("ul",{className:"mt-2 space-y-1.5",children:m.codes.map(x=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(te,{version:x.version}),e.jsx(he,{code:x,className:"flex-1"}
11),a[x.version]?.code?.code===x.code&&e.jsx(pe,{size:"sm",variant:"success",dot:!0,children:w("companyPage.wz.inUse")})]},`${x.version}-${x.code}`))})]},m.id))})]}),T&&r&&e.jsx(es,{issue:T,canonical:a,hint:s,search:u,derive:j,onSaveFields:r,onSavePicker:async m=>{await f(m)},onClose:()=>W(null),showCodes:B}),y&&e.jsx(ys,{canonical:a,fetched:i,hint:$?s:null,search:u,derive:j,formatDate:O,inline:n,onClose:()=>q(!1),onSave:f,onUseCodes:P,onPickCandidate:o,onUseSuggestion:S,onConfirm:A?p:void 0})]})}function fs({result:a,formatDate:i}){const{t:s}=R();return e.jsxs("p",{className:"text-xs text-slate-500",children:[e.jsx("span",{className:"font-semibold text-slate-700",children:s(`companyPage.wz.source.${a.source}`)}),a.fetchedAt&&e.jsxs(e.Fragment,{children:[" · ",s("companyPage.wz.fetchedOn",{date:i(a.fetchedAt)})]})]})}function ys({canonical:a,fetched:i,hint:s,search:d,derive:u,formatDate:j,inline:_,onClose:b,onSave:n,onUseCodes:f,onPickCandidate:P,onUseSuggestion:o,onConfirm:S}){const{t:p}=R(),[r,B]=C.useState(null),[w,H]=C.useState(0),[y,q]=C.useState(!1),T=E.some(t=>{const c=a[t]?.provenance;return c==="manual"||c==="selected"||c==="manualMatch"}),W=T?E.filter(t=>!a[t]?.code&&(a[t]?.candidates?.length??0)>0):[],v=t=>{r?.kind==="search"&&t.kind!=="search"&&H(c=>c+1),B(t)},K=(t,c)=>oe(t.codes).flatMap(l=>{if(l.codes.length===1)return l.codes;const k=c[l.version];return k?[{...k,version:l.version}]:[]}),L=t=>t.inUse??ve(a,t.codes),D=(()=>{if(!r)return!1;if(r.kind==="complete"){const t=W.filter(c=>ze.includes(c));return Object.keys(r.picks).length>0&&t.every(c=>r.picks[c])}if(r.kind==="fetched"){const t=i.find(l=>l.id===r.id);return t?!oe(t.codes).some(l=>de(l.version,l.codes)&&!r.picks[l.version])&&(!L(t)||Object.keys(r.picks).length>0):!1}return!0})(),G=async()=>{if(!(!r||!D)){q(!0);try{if(r.kind==="search")await n(r.value);else if(r.kind==="suggestion"&&s?.suggestion&&o)await o(s.suggestion);else if(r.kind==="confirm"&&S)await S();else if(r.kind==="complete")for(const[t,c]of Object.entries(r.picks))await P(t,c);else if(r.kind==="fetched"){const t=i.find(c=>c.id===r.id);t&&await f(K(t,r.picks),t)}b()}catch{}finally{q(!1)}}},O=(t,c,l,k)=>{const N={...r&&r.kind===t&&(t==="complete"||r.id===c)?r.picks:{}};N[l]?.code===k.code?delete N[l]:N[l]=k,v(t==="fetched"?{kind:t,id:c,picks:N}:{kind:t,picks:N})},$=["register","business"].map(t=>({source:t,rows:i.filter(c=>c.source===t).sort((c,l)=>+!!c.conflict-+!!l.conflict||+!!l.recommended-+!!c.recommended)})).filter(t=>t.rows.length>0),U=e.jsxs(e.Fragment,{children:[e.jsx(V,{"data-track":"wz_canonical_panel.on_close",variant:"ghost",onClick:b,disabled:y,children:p("common.cancel")}),e.jsx(V,{"data-track":"wz_canonical_panel.company_page_wz_save",onClick:()=>void G(),loading:y,disabled:!D,children:p("companyPage.wz.save")})]}),I=!!s?.suggestion?.length&&i.some(t=>!t.conflict&&s.suggestion.every(c=>t.codes.some(l=>l.version===c.version&&l.code===c.code))),A=t=>!!(t.recommended||!T&&L(t)||r?.kind==="fetched"&&r.id===t.id),m=(t,c,l=!1)=>{const k=r?.kind==="fetched"&&r.id===t.id,z=k?r.picks:{},N=!T&&L(t);return e.jsxs(X,{selected:k,onSelect:()=>v({kind:"fetched",id:t.id,picks:z}),title:p("companyPage.wz.groupTitle",{n:c+1,label:bs(t)}),inUse:N,disabled:t.conflict,collapsed:l&&!k,badge:t.recommended?e.jsx(pe,{size:"sm",variant:"primary",children:p("companyPage.wz.recommended")}):void 0,children:[t.conflict&&e.jsx("p",{className:"text-xs text-slate-500",children:p("companyPage.wz.groupConflict",{label:t.providerLabel??""})}),oe(t.codes).map(h=>{const M=a[h.version]?.code;if(h.codes.length===1)return e.jsx(Y,{code:h.codes[0],inUse:N&&M?.code===h.codes[0].code},h.version);const Q=N&&M?{...M,version:h.version}:null;return e.jsxs("div",{className:"space-y-1.5",children:[Q&&e.jsx(Y,{code:Q,inUse:!0}),e.jsx(je,{version:h.version,hideTag:!!Q,required:!Q&&de(h.version,h.codes),needsChoice:N&&!Q||k&&de(h.version,h.codes),candidates:h.codes,picked:z[h.version],onPick:Ce=>O("fetched",t.id,h.version,Ce)})]},h.version)})]},t.id)},x=e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-slate-600",children:p("companyPage.wz.editRule")}),s?.suggestion&&o&&!I&&e.jsxs(X,{selected:r?.kind==="suggestion",onSelect:()=>v({kind:"suggestion"}),title:p("companyPage.wz.optionSuggestion"),meta:p("companyPage.wz.hintSource"),tone:"warning",children:[e.jsx("p",{className:"text-sm text-slate-700",children:s.message}),s.suggestion.map(t=>e.jsx(Y,{code:t},`${t.version}-${t.code}`))]}),S&&e.jsx(X,{selected:r?.kind==="confirm",onSelect:()=>v({kind:"confirm"}),title:p("companyPage.wz.optionKeep"),inUse:!0,children:E.map(t=>{const c=a[t]?.code;return c?e.jsx(Y,{code:{...c,version:t}
11,inUse:!0},t):null})}),W.length>0&&e.jsx(X,{selected:r?.kind==="complete",onSelect:()=>v({kind:"complete",picks:r?.kind==="complete"?r.picks:{}}),title:p("companyPage.wz.optionComplete"),inUse:!0,children:E.map(t=>{const c=a[t];return c?.code?e.jsx(Y,{code:{...c.code,version:t},inUse:!0},t):c?.candidates?.length?e.jsx(je,{version:t,needsChoice:!0,candidates:c.candidates,picked:r?.kind==="complete"?r.picks[t]:void 0,onPick:l=>O("complete","complete",t,l)},t):null})}),$.map(({source:t,rows:c})=>{const l=c.map((h,M)=>({result:h,index:M})),k=c.some(A),z=k?l.filter(({result:h})=>A(h)):l,N=k?l.filter(({result:h})=>!A(h)):[];return e.jsxs("section",{"data-track-view":"wz_canonical_panel.section_view",className:"space-y-2 rounded-lg border border-slate-200 bg-slate-50/60 p-3 sm:p-4",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm",children:[e.jsx("span",{className:"font-semibold text-slate-900",children:p(`companyPage.wz.source.${t}`)}),c[0]&&e.jsxs("span",{className:"text-slate-500",children:[" · ",e.jsx(ws,{result:c[0],formatDate:j})]})]}),e.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:p("companyPage.wz.groupsIntro",{count:c.length})})]}),e.jsxs("div",{className:"space-y-2",children:[z.map(({result:h,index:M})=>m(h,M)),N.length>0&&e.jsxs("details",{"data-track":"wz_canonical_panel.disclosure",className:"group rounded-lg border border-slate-200 bg-white",children:[e.jsxs("summary",{"data-track":"wz_canonical_panel.summary",className:"flex cursor-pointer list-none items-center justify-between gap-2 px-3 py-2.5 text-sm font-semibold text-slate-800 sm:px-4",children:[e.jsxs("span",{children:[p("companyPage.wz.otherGroups")," ",e.jsx("span",{className:"font-normal tabular-nums text-slate-500",children:N.length})]}),e.jsx(ke,{className:"h-4 w-4 text-slate-400 transition-transform group-open:rotate-180","aria-hidden":"true"})]}),e.jsx("div",{className:"space-y-2 border-t border-slate-100 p-2 sm:p-3",children:N.map(({result:h,index:M})=>m(h,M,!0))})]})]})]},t)}),e.jsx(X,{selected:r?.kind==="search",onSelect:()=>{r?.kind!=="search"&&B(null)},title:p("companyPage.wz.optionOwn"),children:e.jsx(Te,{search:d,derive:u,onChange:t=>{t?B({kind:"search",value:t}):r?.kind==="search"&&B(null)},reserveDropdownSpace:!0},w)})]});return _?e.jsxs("div",{className:"space-y-4",children:[x,e.jsx("div",{className:"flex justify-end gap-2",children:U})]}):e.jsx(Pe,{analyticsName:"wz_canonical_panel.modal",isOpen:!0,onClose:b,title:p("companyPage.wz.changeTitle"),size:"lg",footer:U,children:x})}const js="bg-[var(--eiq-amber-soft)]";function bs(a){for(const i of["2008","2003","2025"]){const s=a.codes.filter(d=>d.version===i);if(s.length===1&&s[0].label)return s[0].label}return a.codes[0]?.label??""}function ws({result:a,formatDate:i}){const{t:s}=R();return a.fetchedAt?e.jsx(e.Fragment,{children:s("companyPage.wz.fetchedOn",{date:i(a.fetchedAt)})}):null}const ze=["2003","2008"];function de(a,i){return!ze.includes(a)||i.length<2?!1:a==="2003"?new Set(i.map(s=>s.code.slice(0,5))).size>1:!0}function je({version:a,candidates:i,picked:s,needsChoice:d=!1,hideTag:u=!1,required:j=!1,onPick:_}){const{t:b}=R();return e.jsxs("div",{className:F("flex items-start gap-2",d&&!s&&"-mx-2 rounded-md border border-dashed border-[var(--eiq-amber-line)] bg-[var(--eiq-amber-soft)] px-2 py-1.5"),children:[e.jsx(te,{version:a,className:F(u&&"invisible")}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx("p",{className:F("text-xs leading-5",d&&!s?"font-medium text-[var(--eiq-amber)]":"text-slate-500"),children:d?b("companyPage.wz.needsChoice",{count:i.length}):u?b("companyPage.wz.narrowDown",{count:i.length}):j?b("companyPage.wz.pickRequired",{count:i.length}):b("companyPage.wz.pickOne",{count:i.length})}),e.jsx("div",{"data-track":"wz_canonical_panel.div_11",className:"flex flex-wrap gap-1.5",onClick:n=>n.stopPropagation(),children:i.map(n=>e.jsx(De,{code:n,selected:s?.code===n.code,onClick:()=>_(n)},n.code))})]})]})}function ks({company:a,framed:i=!0}){const{t:s}=R(),d=_e(f=>f.updateCompany),{search:u,derive:j}=Ue(),{hash:_}=Me(),b=C.useRef(null);C.useEffect(()=>{_===`#${ge}`&&b.current?.scrollIntoView({block:"start"})},[_]);const n=async f=>{try{await d(a.id,f)}catch(P){throw me.error(s("companyPage.manualWz.saveFailed"),P instanceof Error?P.message:void 0),P}};return e.jsx("div",{id:ge,ref:b,className:"scroll-mt-20",children:e.jsx(us,{canonical:Qe(a.wz),fetched:Ke(a.wz),hint:Ze(a.wz,s),gate:Ge(a.wz),search:u,derive:j,editable:Ne(a),framed:i,onSave:f=>n(He(f,a.wz)),onUseCodes:(f,P)=>n(Ve(f,P)),onPickCandidate:(f,P)=>n(Ee(f,P)),onUseSuggestion:f=>n(Ie(f)),onConfirm:()=>n(Xe),onSaveFields:n})})}function g({icon:a,label:i,children:s}){return e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(a,{className:"mt-0.5 h-4 w-4 shrink-0 text-slate-400"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.1em] text-slate-400",children:i}),e.jsx("p",{className:"mt-1 break-words text-sm font-medium text-slate-900",children:s})]})]})}function ee({title:a,children:i,className:s}){return e.jsxs("section",{"data-track-view":"company.section_view",className:F("space-y-4 py-5 first:pt-5 last:pb-5",s),children:[e.jsx("h2",{className:"text-base font-semibold text-slate-950",children:a}),i]})}function Z({icon:a,title:i,children:s,loading:d}){return e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-slate-200 bg-slate-50 p-4",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-white text-slate-500",children:d?e.jsx(Ae,{size:"sm"}):a}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:i}),e.jsx("p",{className:"mt-1 text-sm leading-6 text-slate-500",children:s})]})]})}function _s(a){if(!a)return"";
11const i=[a.street,a.house_number].filter(Boolean).join(" "),s=[a.postal_code,a.city].filter(Boolean).join(" ");return[i,s].filter(Boolean).join(", ")}function be(a){return[[a.register_type,a.register_number].filter(Boolean).join(" "),a.register_court].filter(Boolean).join(" · ")}function Ns(a){return a?[a.county,a.state,a.country].filter(Boolean).join(" · "):""}function Ps(a){const i=a.trim();if(!i)return null;const s=/^[a-z][a-z0-9+.-]*:\/\//i.test(i)?i:`https://${i}`;try{const d=new URL(s);return d.protocol==="http:"||d.protocol==="https:"?d.href:null}catch{return null}}function vs(a){return a?[a.street_address,[a.postal_code,a.city].filter(Boolean).join(" ")].filter(Boolean).join(", "):""}function se(a){return a?a.split("_").filter(Boolean).map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" "):""}function zs({variant:a="customer",basePath:i}={}){const{t:s}=R(),d=Be(),{companies:u,currentCompanyId:j,fetchCompanies:_,refreshHandelsregister:b}=_e(),n=C.useMemo(()=>u.find(c=>c.id===j)||u[0]||null,[u,j]),f=Ne(n),P=n?.role==="owner"||n?.role==="admin",o=n?.handelsregister??null,S=!!(n?.handelsregister_lookup_status==="in_progress"||n?.handelsregister_lookup_in_progress||n?.wz_lookup_pending),p=n?.handelsregister_lookup_status,r=n?.handelsregister_lookup_attempts??0,B=n?.handelsregister_lookup_max_attempts??5,w=n?.name||o?.name||s("companyPage.title"),H=n?.legal_form?s(`onboardingV2.company.legalForms.${n.legal_form.toLowerCase()}`,{defaultValue:n.legal_form}):"",y=i||d?.basePath,q=y?a==="partner"?`${y}/settings#company-details`:`${y}/settings/company`:"../settings/company",T=y?a==="partner"?`${y}/team`:`${y}/members`:"../members";Ye(_,3500,{enabled:S});const[W,v]=C.useState(!1),K=async()=>{if(!(W||S||!n)){v(!0);try{await b(n.id),await _(),me.success(s("companyPage.refreshStarted.title"),s("companyPage.refreshStarted.body"))}catch(c){me.error(s("companyPage.refreshFailed.title"),c instanceof Error?c.message:s("companyPage.refreshFailed.body"))}finally{v(!1)}}},L=o?.legal_form||"",D=o?.website?Ps(o.website):null,G=o?.managing_directors??[],O=o?.keywords??[],$=o?.products_and_services??[],U=o?Ns(o.address):"",I=vs(n),A=o?_s(o.address):"",m=o?.matched_query_name||o?.name||"",x=(()=>{switch(o?.match_source){case"invoice_recipient":return s("companyPage.matchSource.invoiceRecipient",{name:m});case"company_name":return s("companyPage.matchSource.companyName",{name:m});case"registration_number":return s("companyPage.matchSource.registrationNumber",{name:m});case"entity_id":return s("companyPage.matchSource.entityId");case"cache_reuse":return s("companyPage.matchSource.cacheReuse");default:return""}})(),t=o?.match_address_status==="seat_differs";return e.jsxs("div",{className:"space-y-6",children:[e.jsx(We,{title:e.jsx(qe,{title:w,info:s("pageInfo.company"),ariaLabel:s("pageInfo.company")}),actions:n?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{type:"button","data-track":"company.refresh_register_data",onClick:()=>void K(),disabled:W||S,className:F(ne({variant:"outline",size:"md"})),children:[e.jsx(as,{className:F("h-4 w-4",(W||S)&&"animate-spin")}),s("common.refresh")]}),f&&e.jsxs(ie,{to:q,"data-track":"company.edit_company",className:F(ne({variant:"outline",size:"md"})),children:[e.jsx(ts,{className:"h-4 w-4"}),s("appOrgV2.company.edit")]})]}):void 0}),n?e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white px-5 sm:px-6",children:[f&&e.jsx(ee,{title:s(a==="partner"?"partnerCockpit.companyProfile.details":"companyPage.companyDetails"),children:e.jsxs("div",{className:"grid grid-cols-1 gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(g,{icon:J,label:s("appOrgV2.company.fields.company"),children:n.name||s("companyPage.emptyValue")}),I&&e.jsx(g,{icon:ce,label:s("companyPage.fields.companyAddress"),children:I}),H&&e.jsx(g,{icon:J,label:s("companyPage.fields.legalForm"),children:H}),n.company_type&&e.jsx(g,{icon:re,label:s("companyPage.fields.companyType"),children:se(n.company_type)}),n.annual_consumption_band&&e.jsx(g,{icon:le,label:s("companyPage.fields.consumptionBand"),children:se(n.annual_consumption_band)})]})}),e.jsx(ee,{title:s("companyPage.masterData"),className:f?"border-t border-slate-200":void 0,children:o?e.jsxs(e.Fragment,{children:[x&&e.jsx("p",{className:"text-sm font-medium text-success-700",children:x}),t&&e.jsx(Z,{icon:e.jsx(fe,{className:"h-5 w-5"}),title:s("companyPage.addressMismatch.title"),children:s("companyPage.addressMismatch.body")}),e.jsxs("div",{className:"grid grid-cols-1 gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[o.name&&e.jsx(g,{icon:J,label:s("companyPage.fields.registerName"),children:o.name}),L&&e.jsx(g,{icon:J,label:s("companyPage.fields.legalForm"),children:L}),o.status&&e.jsx(g,{icon:le,label:s("companyPage.fields.status"),children:o.status}),A&&e.jsx(g,{icon:ce,label:s("companyPage.fields.address"),children:A}),U&&e.jsx(g,{icon:ce,label:s("companyPage.fields.region"),children:U}),be(o)&&e.jsx(g,{icon:ns,label:s("companyPage.fields.register"),children:be(o)}),o.registration_date&&e.jsx(g,{icon:xe,label:s("companyPage.fields.registrationDate"),children:ae(o.registration_date)}),o.entity_id&&e.jsx(g,{icon:ue,label:s("companyPage.fields.entity
11Id"),children:e.jsx("span",{className:"font-mono",children:o.entity_id})}),o.email&&e.jsx(g,{icon:Le,label:s("companyPage.fields.email"),children:e.jsx("a",{"data-track":"company.a",className:"text-primary-600 hover:underline",href:`mailto:${o.email}`,children:o.email})}),o.website&&e.jsx(g,{icon:cs,label:s("companyPage.fields.website"),children:D?e.jsx("a",{"data-track":"company.a_2",className:"text-primary-600 hover:underline",href:D,target:"_blank",rel:"noopener noreferrer",children:o.website}):o.website}),o.phone_number&&e.jsx(g,{icon:Oe,label:s("companyPage.fields.phone"),children:o.phone_number})]}),o.updated_at&&e.jsx("p",{className:"mt-3 font-mono text-[11px] text-slate-400",children:s("companyPage.updatedAt",{date:ae(o.updated_at)})})]}):e.jsx("div",{className:"space-y-4",children:S?e.jsx(Z,{title:s("companyPage.lookup.title"),loading:!0,children:s("companyPage.lookup.body",{attempt:r,max:B})}):p==="retry_pending"?e.jsx(Z,{icon:e.jsx(ye,{className:"h-5 w-5"}),title:s("companyPage.retryPending.title"),children:s("companyPage.retryPending.body",{attempt:r,max:B})}):p==="no_match"?e.jsx(Z,{icon:e.jsx(ye,{className:"h-5 w-5"}),title:s("companyPage.noMatch.title"),children:s("companyPage.noMatch.body",{max:B})}):p==="failed"||p==="unavailable"?e.jsx(Z,{icon:e.jsx(fe,{className:"h-5 w-5"}),title:s("companyPage.lookupFailed.title"),children:s("companyPage.lookupFailed.body")}):e.jsx(Z,{icon:e.jsx(J,{className:"h-5 w-5"}),title:s("companyPage.empty.title"),children:s("companyPage.empty.body")})})}),e.jsx("section",{"data-track-view":"company.section_view_2",className:"border-t border-slate-200 py-5",children:e.jsx(ks,{company:n,framed:!1},n.id)}),o&&G.length>0&&e.jsx(ee,{title:s("companyPage.directors"),className:"border-t border-slate-200",children:e.jsx("ul",{className:"grid gap-3 sm:grid-cols-2",children:G.map((c,l)=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(ps,{className:"mt-0.5 h-4 w-4 shrink-0 text-slate-400"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:c.name}),c.role&&e.jsx("p",{className:"text-xs text-slate-500",children:c.role})]})]},`${c.name}-${l}`))})}),o&&(o.purpose||O.length>0||$.length>0)&&e.jsx(ee,{title:s("companyPage.activity"),className:"border-t border-slate-200",children:e.jsxs("div",{className:"space-y-5",children:[o.purpose&&e.jsx(g,{icon:re,label:s("companyPage.fields.purpose"),children:o.purpose}),O.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(is,{className:"h-4 w-4 text-slate-400"}),e.jsx("h3",{className:"text-sm font-semibold text-slate-900",children:s("companyPage.fields.keywords")})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:O.map((c,l)=>e.jsx(pe,{className:"bg-slate-100 text-slate-700",children:c},`${c}-${l}`))})]}),$.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(os,{className:"h-4 w-4 text-slate-400"}),e.jsx("h3",{className:"text-sm font-semibold text-slate-900",children:s("companyPage.fields.products")})]}),e.jsx("ul",{className:"list-inside list-disc space-y-0.5 text-sm text-slate-700",children:$.map((c,l)=>e.jsx("li",{children:c},`${c}-${l}`))})]})]})}),P&&e.jsx(ee,{title:s(a==="partner"?"partnerCockpit.companyProfile.workspace":"companyPage.workspace"),className:"border-t border-slate-200",children:e.jsxs("div",{className:"grid grid-cols-1 gap-5 sm:grid-cols-2 xl:grid-cols-3",children:[n.member_count!==null&&n.member_count!==void 0&&e.jsx(g,{icon:rs,label:s("companyPage.fields.members"),children:a==="partner"?e.jsx(ie,{"data-track":"company.partner_cockpit_settings_manage_team",to:T,className:"text-primary-700 hover:underline",children:s("partnerCockpit.settings.manageTeam")}):n.member_count}),n.role&&e.jsx(g,{icon:$e,label:s("companyPage.fields.yourRole"),children:se(n.role)}),a!=="partner"&&n.platform_role&&e.jsx(g,{icon:re,label:s("companyPage.fields.platformRole"),children:se(n.platform_role)}),n.status&&e.jsx(g,{icon:le,label:s("companyPage.fields.companyStatus"),children:se(n.status)}),a!=="partner"&&n.slug&&e.jsx(g,{icon:ue,label:s("companyPage.fields.workspaceSlug"),children:e.jsx("span",{className:"font-mono",children:n.slug})}),a!=="partner"&&n.created_at&&e.jsx(g,{icon:xe,label:s("companyPage.fields.createdAt"),children:ae(n.created_at)}),a!=="partner"&&n.updated_at&&e.jsx(g,{icon:ls,label:s("companyPage.fields.updatedAt"),children:ae(n.updated_at)})]})})]}):e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white p-5",children:[e.jsx("p",{className:"text-sm text-slate-500",children:s("companyPage.noCompany")}),e.jsx(ie,{to:"/onboarding/company","data-track":"company.create_company",className:F(ne({variant:"primary",size:"md"}),"mt-4"),children:s("createCompany.onboardingTitle")})]})]})}const Vs=Object.freeze(Object.defineProperty({__proto__:null,Company:zs},Symbol.toStringTag,{value:"Module"}));
11export{zs as C,ps as U,us as W,Vs as a};
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.