1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-BcDtPg_r.js","assets/react-vendor-DhSP975V.js","assets/_commonjs-dynamic-modules-BHR_E30J.js"])))=>i.map(i=>d[i]); 2import{u as e,B as s,_ as r}from"./index-BRTDjk9K.js";import{k as i,r as a,j as t}from"./react-vendor-DhSP975V.js";import{H as n}from"./Header-Cs9IpE4J.js";import{B as o}from"./badge-BM65uDYM.js";import{S as d}from"./switch-v4UFVtl2.js";import{S as c}from"./skeleton-xarS4TZU.js";import{u as l}from"./use-toast-VS3PAP1g.js";import{u as m}from"./useSubscription-B5rmSgxu.js";import{b as u}from"./AppProtected-LVckdBot.js";import{u as p}from"./useWorkspaceRole-CpKppsdU.js";import{u as x}from"./formatDistanceToNow-Dg-DDeOJ.js";import{b as h,u as f,c as g}from"./query-vendor-n0_7bG_F.js";import{s as j}from"./client-dIm-I_1l.js";import{u as b}from"./useAuth-B7Ivpqlt.js";import{W as v,av as y,x as w,au as N,an as k,bA as _,h as S}from"./icons-vendor-DGAlFwT6.js";import"./ui-vendor-DdP2sx6P.js";import"./supabase-vendor-BlcNSqHb.js";import"./input-CD1u45TZ.js";import"./alert-dialog-DE5qkilm.js";import"./dialog-BJz8_4t4.js";import"./label-CGScN9or.js";import"./Trans-DnhvXxtZ.js";import"./links-DS6srBkI.js";import"./select-DcZ5m3oV.js";import"./useWorkspaceMembers-CJUde1Hy.js";async function L(e){const{data:s,error:r}=await j.functions.invoke("download-compliance-doc",{body:{documentId:e.id}}),i=null==s?void 0:s.url;if(r||!i)throw new Error((null==s?void 0:s.error)??(null==r?void 0:r.message)??"Could not create a download link.");const a=document.createElement("a");a.href=i,a.download="",document.body.appendChild(a),a.click(),a.remove()}function A(e){const{activeWorkspace:s}=x(),r=(null==s?void 0:s.id)??null,i=f({queryKey:["workspace-documents",r,e],enabled:!!r,queryFn:async()=>{const s=j.from("workspace_documents").select("id, title, doc_type, version, signed_on, storage_path, file_size, created_at").eq("workspace_id",r).order("created_at",{ascending:!1}),i="invoices"===e?s.eq("doc_type","invoice"):s.neq("doc_type","invoice"),{data:a,error:t}=await i;if(t)throw t;return a??[]}});return{documents:i.data??[],isLoading:i.isLoading,isError:i.isError,download:L,refetch:i.refetch}}const C=[{key:"dpa",href:"/compliance/Black-Ice-DPA-v1.2.pdf",file:"Black-Ice-DPA-v1.2.pdf"},{key:"caiq",href:"/compliance/Black-Ice-CSA-CAIQ-v1.1.0.pdf",file:"Black-Ice-CSA-CAIQ-v1.1.0.pdf"},{key:"ci",href:"/compliance/Black-Ice-CI-Security-Scanning.md",file:"Black-Ice-CI-Security-Scanning.md"},{key:"owasp",href:"/compliance/Black-Ice-OWASP-Top-10-2025-Assessment.md",file:"Black-Ice-OWASP-Top-10-2025-Assessment.md"},{key:"samm",href:"/compliance/Black-Ice-SAMM-Assessment.md",file:"Black-Ice-SAMM-Assessment.md"},{key:"security",href:"/legal/security",file:null},{key:"subprocessors",href:"/legal/sub-processors",file:null}];function E(e){return e?("number"==typeof e?new Date(1e3*e):new Date(e)).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"}):""}function I({icon:e,children:s}){return t.jsxs("h2",{className:"text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2 uppercase tracking-wide",children:[t.jsx(e,{className:"w-4 h-4 text-primary"}),s]})}function B(){const{t:L}=e("documents"),B=i(),{toast:q}=l(),{isLoading:P,currentPeriodEnd:T,openBillingPortal:F,stripeCustomerId:U}=m(),{isPro:W,tier:D}=u(),{canManage:O,isLoading:z}=p(),{activeWorkspace:M}=x(),R=W&&O,{documents:$,isLoading:K,download:Q}=A("agreements"),H=function(){const{user:e}=b(),{activeWorkspace:s}=x(),r=h(),i=(null==s?void 0:s.id)??null,a=["subprocessor-subscription",i,null==e?void 0:e.id],{data:t,isLoading:n}=f({queryKey:a,enabled:!!i&&!!(null==e?void 0:e.id),queryFn:async()=>{const{data:s,error:r}=await j.from("subprocessor_subscriptions").select("id, email").eq("workspace_id",i).eq("user_id",e.id).maybeSingle();if(r)throw r;return s}}),o=g({mutationFn:async s=>{if(!i||!(null==e?void 0:e.id))throw new Error("No workspace selected");if(s){const{error:s}=await j.from("subprocessor_subscriptions").upsert({workspace_id:i,user_id:e.id,email:e.email??""},{onConflict:"workspace_id,user_id"});if(s)throw s}else{const{error:s}=await j.from("subprocessor_subscriptions").delete().eq("workspace_id",i).eq("user_id",e.id);if(s)throw s}},onSuccess:()=>
2r.invalidateQueries({queryKey:a})});return{isSubscribed:!!t,email:(null==t?void 0:t.email)??(null==e?void 0:e.email)??"",isLoading:n,toggle:o.mutate,isToggling:o.isPending}}(),{invoices:V,isLoading:Y,isError:Z}=function(e){const{user:s}=b(),r=f({queryKey:["invoices",null==s?void 0:s.id],enabled:e&&!!(null==s?void 0:s.id),staleTime:3e5,queryFn:async()=>{const{data:e,error:s}=await j.functions.invoke("list-invoices",{});if(s)throw new Error(s.message);return(null==e?void 0:e.invoices)??[]}});return{invoices:r.data??[],isLoading:r.isLoading,isError:r.isError}}(R),{documents:G,isLoading:J,download:X}=A("invoices"),[ee,se]=a.useState(!1);return t.jsxs("div",{className:"page-container",children:[t.jsx(n,{title:L("page.title"),subtitle:L("page.subtitle")}),t.jsx("div",{className:"p-6 space-y-8 max-w-4xl",children:R?t.jsxs(t.Fragment,{children:[t.jsxs("section",{children:[t.jsx(I,{icon:v,children:L("agreements.heading")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:L("agreements.description",{workspace:(null==M?void 0:M.name)??""})}),K?t.jsx(c,{className:"h-20 w-full rounded-xl"}):0===$.length?t.jsx("div",{className:"dashboard-card text-sm text-muted-foreground",children:L("agreements.empty")}):t.jsx("div",{className:"space-y-2",children:$.map(e=>t.jsxs("div",{className:"dashboard-card flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[t.jsx("div",{className:"w-10 h-10 shrink-0 rounded-xl bg-primary/10 border border-primary/20 flex items-center justify-center text-primary",children:t.jsx(v,{className:"w-5 h-5"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("h3",{className:"font-medium text-foreground truncate",children:e.title}),t.jsx(o,{variant:"secondary",className:"text-xs",children:L(`agreements.types.${e.doc_type}`,{defaultValue:L("agreements.types.other")})})]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:[e.version?L("agreements.version",{version:e.version}
2):null,e.signed_on?L("agreements.signedOn",{date:E(e.signed_on)}):null].filter(Boolean).join(" · ")})]})]}),t.jsxs(s,{variant:"outline",size:"sm",onClick:()=>(async e=>{try{await Q(e)}catch(s){q({title:L("agreements.downloadFailed"),description:s instanceof Error?s.message:void 0,variant:"destructive"})}})(e),children:[t.jsx(y,{className:"w-4 h-4 mr-2"}),L("agreements.download")]})]},e.id))})]}),t.jsxs("section",{children:[t.jsx(I,{icon:w,children:L("standard.heading")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:L("standard.description")}),t.jsx("div",{className:"space-y-2",children:C.map(e=>t.jsxs("a",{href:e.href,target:e.file?"_blank":void 0,rel:"noopener noreferrer",className:"dashboard-card flex items-center justify-between gap-4 group hover:border-primary/30 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[t.jsx("div",{className:"w-10 h-10 shrink-0 rounded-xl bg-primary/10 border border-primary/20 flex items-center justify-center text-primary",children:t.jsx(w,{className:"w-5 h-5"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"font-medium text-foreground",children:L(`standard.items.${e.key}.title`)}),t.jsx("p",{className:"text-sm text-muted-foreground",children:L(`standard.items.${e.key}.description`)})]})]}),t.jsxs("span",{className:"text-sm text-muted-foreground group-hover:text-primary flex items-center gap-1 shrink-0",children:[L("standard.open"),t.jsx(N,{className:"w-4 h-4"})]})]},e.key))}),t.jsxs(s,{className:"mt-3",variant:"outline",onClick:async()=>{se(!0);try{const e=new(0,(await r(async()=>{const{default:e}=await import("./jszip.min-BcDtPg_r.js").then(e=>e.j);return{default:e}},__vite__mapDeps([0,1,2]))).default);await Promise.all(C.filter(e=>e.file).map(async s=>{const r=await fetch(s.href);if(!r.ok)throw new Error(`Failed to fetch ${s.file}`);e.file(s.file,await r.blob())}));const s=await e.generateAsync({type:"blob"}),i=URL.createObjectURL(s),a=document.createElement("a");a.href=i,a.download="black-ice-compliance-pack.zip",a.click(),URL.revokeObjectURL(i)}catch{q({title:L("standard.packFailed"),variant:"destructive"})}finally{se(!1)}},disabled:ee,children:[t.jsx(y,{className:"w-4 h-4 mr-2"}),L(ee?"standard.preparingPack":"standard.downloadPack")]})]}),t.jsxs("section",{children:[t.jsx(I,{icon:k,children:L("subprocessors.heading")}),t.jsxs("div",{className:"dashboard-card flex items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:L("subprocessors.description")}),t.jsx("p",{className:"text-sm text-foreground",children:L("subprocessors.toggleLabel",{email:H.email})}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:H.isSubscribed?L("subprocessors.subscribed"):L("subprocessors.notSubscribed")})]}),t.jsx(d,{checked:H.isSubscribed,disabled:H.isLoading||H.isToggling,onCheckedChange:e=>H.toggle(e,{onError:()=>q({title:L("subprocessors.failed"),variant:"destructive"})})})]})]}),t.jsxs("section",{children:[t.jsx(I,{icon:_,children:L("billing.heading")}),t.jsxs("div",{className:"dashboard-card space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:L("billing.plan")}),t.jsx("p",{className:"font-medium text-foreground capitalize",children:D}),T&&t.jsx("p",{className:"text-xs text-muted-foreground",children:L("billing.renews",{date:E(T.toISOString())})})]}),U&&t.jsx(s,{variant:"outline",size:"sm",onClick:()=>F(),children:L("billing.manage")})]}),t.jsx("div",{className:"border-t border-border/40 pt-4",children:Y||J?t.jsx(c,{className:"h-16 w-full rounded-lg"}):Z?t.jsx("p",{className:"text-sm text-muted-foreground",children:L("billing.unavailable")}):0===V.length&&0===G.length?t.jsx("p",{className:"text-sm text-muted-foreground",children:L("billing.empty")}):t.jsxs("ul",{className:"divide-y divide-border/40",children:[G.map(e=>t.jsxs("li",{className:"py-2 flex items-center justify-between gap-4 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("p",{className:"text-foreground truncate",children:e.title}),t.jsx(o,{variant:"secondary",className:"text-xs",children:L("billing.uploadedBy")})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:E(e.signed_on??e.created_at)})]}),t.jsx(s,{variant:"link",className:"h-auto p-0 text-primary hover:underline shrink-0",onClick:()=>(async e=>{try{await X(e)}catch(s){q({title:L("agreements.downloadFailed"),description:s instanceof Error?s.message:void 0,variant:"destructive"})}})(e),children:L("billing.download")})]},e.id)),V.map(e=>t.jsxs("li",{className:"py-2 flex items-center justify-between gap-4 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-foreground truncate",children:L("billing.invoice",{number:e.number??e.id.slice(-8)})}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[E(e.created)," ·"," ",(e.total/100).toLocaleStr
2ing(void 0,{style:"currency",currency:(e.currency||"eur").toUpperCase()}),e.status?` · ${e.status}`:""]})]}),t.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.hostedUrl&&t.jsx("a",{className:"text-primary hover:underline",href:e.hostedUrl,target:"_blank",rel:"noopener noreferrer",children:L("billing.view")}),e.pdfUrl&&t.jsx("a",{className:"text-primary hover:underline",href:e.pdfUrl,target:"_blank",rel:"noopener noreferrer",children:L("billing.pdf")})]})]},e.id))]})})]})]})]}):P||z?t.jsx(c,{className:"h-32 w-full rounded-xl"}):W?t.jsxs("div",{className:"dashboard-card",children:[t.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-muted/50 border border-border/40 flex items-center justify-center text-muted-foreground",children:t.jsx(S,{className:"w-5 h-5"})}),t.jsx("h3",{className:"font-medium text-foreground",children:L("gate.roleTitle")})]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:L("gate.roleBody")})]}):t.jsxs("div",{className:"dashboard-card flex flex-col gap-3 items-start",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-muted/50 border border-border/40 flex items-center justify-center text-muted-foreground",children:t.jsx(S,{className:"w-5 h-5"})}),t.jsx("h3",{className:"font-medium text-foreground",children:L("gate.upgradeTitle")})]}),t.jsx("p",{className:"text-sm text-muted-foreground",children:L("gate.upgradeBody")}),t.jsx(s,{onClick:()=>B("/app/pricing"),children:L("gate.upgradeCta")})]})})]})}export{B as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.