1import{reactExports as e,jsxRuntimeExports as t,Link as r}from"./react-vendor-Cl5BoUFb.js";import{ue as s,Button as a,Card as o,CardHeader as n,CardTitle as i,CardContent as l,cn as d,Table as c,TableHeader as p,TableRow as m,TableHead as x,TableBody as u,TableCell as g,TooltipProvider as h,Tooltip as b,TooltipTrigger as f,Badge as y,TooltipContent as j,Sheet as v,SheetContent as _,SheetHeader as N,SheetTitle as C,SheetDescription as w,Label as S,Select as P,SelectTrigger as k,SelectValue as F,SelectContent as A,SelectItem as I,Textarea as D,Input as R}from"./ui-vendor-CVwrz00e.js";import{ComplianceLayout as M}from"./ComplianceLayout-BUvuPhC6.js";import{useAuth$1 as L,supabase as E,useMe as T}from"./main-OLIzgs0k.js";import{ExcelJS as V}from"./exceljs.min-BljWKd3H.js";import{VENDOR_CATEGORIES as O}from"./vendorCategories-CJfeL3S0.js";import{useRopaActivities as G}from"./useRopaActivities-1mWQAqT2.js";import{useVendors as z}from"./useVendors-B_ugWi4r.js";import{Download as $,Plus as B,WandSparkles as q,Pencil as U,Trash2 as H,X as W,ChevronDown as Y}from"./icons-vendor-BUK3cUnC.js";import"./Header-BZn6RWTw.js";import"./nav-lib-tIVQ3Mlj.js";import"./index-YHYuFPvV.js";import"./query-vendor-Ct1xBef-.js";import"./analytics-lib-CvkHC-Ld.js";import"./video-modal-C9YG8PUQ.js";import"./feature-flags-lib-C1N11fmc.js";import"./useSubscription-Di7N8j6o.js";
1const J="002247";function X(){return{type:"pattern",pattern:"solid",fgColor:{argb:"FF"+J}}}function Z(){const e={style:"thin",color:{argb:"FFCCCCCC"}};return{top:e,left:e,bottom:e,right:e}}function K(e,t,r,s){e.addRow([t]);const a=e.getRow(1);a.height=28,a.getCell(1).font={bold:!0,color:{argb:"FFFFFFFF"},size:13},a.getCell(1).fill=X(),a.getCell(1).alignment={vertical:"middle",horizontal:"left"},e.mergeCells(1,1,1,r),e.addRow([`Source: HotelComply | Generated: ${s}`]);const o=e.getRow(2);o.height=18,o.getCell(1).font={italic:!0,color:{argb:"FF666666"},size:9},o.getCell(1).fill={type:"pattern",pattern:"solid",fgColor:{argb:"FFF2F2F2"}},o.getCell(1).alignment={vertical:"middle",horizontal:"left"},e.mergeCells(2,1,2,r)}function Q(e,t){e.addRow(t);const r=e.getRow(3);r.height=20,t.forEach((e,t)=>{const s=r.getCell(t+1);s.font=function(e=!0){return{bold:!0,color:{argb:e?"FFFFFFFF":"FF"+J},size:10}}(!0),s.fill=X(),s.alignment={vertical:"middle",horizontal:"left",wrapText:!0},s.border=Z()}),e.views=[{state:"frozen",xSplit:0,ySplit:3}]}function ee(e,t){t.forEach((t,r)=>{e.getColumn(r+1).width=t})}function te(e,t,r,s){const a=r%2==0;e.addRow(t);const o=e.lastRow;o.height=16,t.forEach((e,t)=>{const r=o.getCell(t+1);r.font={size:10},r.alignment={vertical:"middle",horizontal:"left",wrapText:!0},r.border=Z(),r.fill=a?{type:"pattern",pattern:"solid",fgColor:{argb:"FFE6F7FB"}}:{type:"pattern",pattern:"solid",fgColor:{argb:"FFFFFFFF"}}}),s&&s.forEach(({col:e,value:t})=>{const r=function(e){const t=(e||"").toLowerCase();return"yes"===t?{type:"pattern",pattern:"solid",fgColor:{argb:"FFFF0000"}}:"maybe"===t||"uncertain"===t?{type:"pattern",pattern:"solid",fgColor:{argb:"FFFFA500"}}:"no"===t?{type:"pattern",pattern:"solid",fgColor:{argb:"FF008000"}}:null}(t);if(r){const t=o.getCell(e);t.fill=r,t.font={size:10,bold:!0,color:{argb:"FFFFFFFF"}}}})}const re=["health","medical","biometric","genetic","racial","ethnic","religious","sexual","mental health","passport","precise location"],se=["financial","credit card","payment","bank","billing","transaction","pci"];function ae(e){return re.some(t=>e.toLowerCase().includes(t))}function oe(e){return se.some(t=>e.toLowerCase().includes(t))}function ne(e,t,r){return r.some(e=>ae(e))?"critical":r.some(e=>oe(e))||r.length>2?"high":"medium"}const ie=["Data Collection Point","Data Sharing/Sale","Pixel or Tracking Tech","Vendor or System"],le=["Identifiers (name, email, phone)","Commercial Information","Internet/Network Activity","Geolocation Data","Audio/Visual Information","Professional/Employment Info","Education Information","Biometric Information","Facial Recognition / CCTV Data","Vehicle & License Plate Data","Call Recordings (Voice Data)","Inferences & Predicted Preferences","Financial Records","Sensitive Personal Information","Inferences"],de=["Booking & Reservations","Guest Services","Marketing Communications","Loyalty Programs","Legal Compliance","Security & Fraud Prevention","Analytics & Insights","Third-party Sharing","Security & Surveillance","Loyalty Program Management","Financial Management & Tax Compliance","Legal Compliance & Incident Response","Valet & Parking Operations","HR & Employment Management"],ce=["API Integration","File Transfer (SFTP/FTP)","Direct Database Access","Email","Manual/Paper","Third-party Platform"],pe=["Yes","No","Maybe","Uncertain"],me=["Signed â Current","Signed â Expired","In Progress","Not Started","Not Required"],xe=["Analytics","Advertising / Retargeting","Social Media","Heatmap / Session Recording","Live Chat","Other"],ue=["Controller","Processor / Service Provider","Third Party","Contractor"],ge=["No Gap â DPA Signed","Amber â In Negotiation","Red â No DPA","Not Applicable"];function he({label:e,value:r,options:s,onChange:a,placeholder:o}){return t.jsxs("div",{className:"space-y-2",children:[t.jsx(S,{children:e}),t.jsxs(P,{value:r||"",onValueChange:a,children:[t.jsx(k,{children:t.jsx(F,{placeholder:o||`Select ${e.toLowerCase()}`})}),t.jsx(A,{children:s.map(e=>t.jsx(I,{value:e,children:e},e))})]})]})}function be({label:e,value:r,onChange:s,placeholder:a,multiline:o}){return t.jsxs("div",{className:"space-y-2",children:[t.jsx(S,{children:e}),o?t.jsx(D,{value:r||"",onChange:e=>s(e.target.value),placeholder:a,rows:2,className:"resize-none"}):t.jsx(R,{value:r||"",onChange:e=>s(e.target.value),placeholder:a})]})}function fe({form:e,set:r}){return t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsx(he,{label:"PI Category",value:e.pi_category,options:le,onChange:e=>r("pi_category",e),placeholder:"Select PI category"}),t.jsx(be,{label:"Source of PI",value:e.source_of_pi,onChange:e=>r("source_of_pi",e),placeholder:"e.g. Booking form, PMS"}),t.jsx(be,{label:"Collection Method",value:e.collection_method,onChange:e=>r("collection_method",e),placeholder:"e.g. Online form, staff entry"}),t.jsx(be,{label:"Storage Location",value:e.storage_location,onChange:e=>r("storage_location",e),placeholder:"e.g. Opera PMS, Supabase"}),t.jsx(he,{label:"Business Purpose",value:e.business_purpose,options:de,onCh
1ange:e=>r("business_purpose",e)}),t.jsx(be,{label:"Retention Period",value:e.retention_period,onChange:e=>r("retention_period",e),placeholder:"e.g. 7 years, 90 days"})]})}function ye({form:e,set:r}){return t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsx(be,{label:"PI Shared",value:e.pi_shared,onChange:e=>r("pi_shared",e),placeholder:"e.g. Name, email, stay history"}),t.jsx(be,{label:"Recipient",value:e.recipient,onChange:e=>r("recipient",e),placeholder:"e.g. Salesforce CRM, Google Ads"}),t.jsx(he,{label:"Transfer Method",value:e.transfer_method,options:ce,onChange:e=>r("transfer_method",e)}),t.jsx(be,{label:"Rights Granted",value:e.rights_granted,onChange:e=>r("rights_granted",e),placeholder:"e.g. Use for marketing"}),t.jsx(he,{label:"Constitutes Sale?",value:e.constitutes_sale,options:pe,onChange:e=>r("constitutes_sale",e)}),t.jsx(he,{label:"DPA Status",value:e.dpa_status,options:me,onChange:e=>r("dpa_status",e)})]})}function je({form:e,set:r}){return t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[t.jsx(be,{label:"Vendor Name",value:e.vendor_name,onChange:e=>r("vendor_name",e),placeholder:"e.g. Google Analytics, Meta Pixel"}),t.jsx(he,{label:"Pixel Type",value:e.pixel_type,options:xe,onChange:e=>r("pixel_type",e)}),t.jsx(be,{label:"Pixel Purpose",value:e.pixel_purpose,onChange:e=>r("pixel_purpose",e),placeholder:"e.g. Conversion tracking"}),t.jsx(be,{label:"PI Collected",value:e.pi_collected,onChange:e=>r("pi_collected",e),placeholder:"e.g. IP address, browser type"}),t.jsx(he,{label:"Constitutes Sale?",value:e.constitutes_sale,options:pe,onChange:e=>r("constitutes_sale",e)}),t.jsx(be,{label:"Opt-Out Mechanism",value:e.opt_out_mechanism,onChange:e=>r("opt_out_mechanism",e),placeholder:"e.g. Cookie banner, GPC signal"})]})}function ve({form:e,set:r}){return t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[t.jsx(be,{label:"System / Vendor Name",value:e.system_vendor_name,onChange:e=>r("system_vendor_name",e),placeholder:"e.g. Oracle Opera, Mailchimp"}),t.jsx(he,{label:"Vendor Category",value:e.vendor_category,options:O,onChange:e=>r("vendor_category",e)}),t.jsx(be,{label:"Role",value:e.role,onChange:e=>r("role",e),placeholder:"e.g. Processes reservations"}),t.jsx(be,{label:"PI Collected",value:e.pi_collected,onChange:e=>r("pi_collected",e),placeholder:"e.g. Guest name, credit card"}),t.jsx(be,{label:"Source of PI",value:e.source_of_pi,onChange:e=>r("source_of_pi",e),placeholder:"e.g. Front desk, OTA"}),t.jsx(he,{label:"CPRA Classification",value:e.cpra_classification,options:ue,onChange:e=>r("cpra_classification",e)}),t.jsx(he,{label:"DPA Gap Status",value:e.dpa_gap_status,options:ge,onChange:e=>r("dpa_gap_status",e)}),t.jsx(be,{label:"Priority Action",value:e.priority_action,onChange:e=>r("priority_action",e),placeholder:"e.g. Request signed DPA"})]})}function _e({value:e}){if(!e)return t.jsx("span",{className:"text-muted-foreground",children:"â"});const r=e.toLowerCase(),s="yes"===r?"bg-red-100 text-red-700 border-red-200":"maybe"===r||"uncertain"===r?"bg-amber-100 text-amber-700 border-amber-200":"no"===r?"bg-green-100 text-green-700 border-green-200":"bg-muted text-muted-foreground border-border";return t.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ${s}`,children:e})}function Ne({value:e}){if(!e)return t.jsx("span",{className:"text-muted-foreground",children:"â"});const r=e.toLowerCase(),s=r.includes("red")||r.includes("no dpa")?"bg-red-100 text-red-700 border-red-200":r.includes("amber")||r.includes("negotiation")?"bg-amber-100 text-amber-700 border-amber-200":r.includes("signed")||r.includes("no gap")?"bg-green-100 text-green-700 border-green-200":"bg-muted text-muted-foreground border-border";return t.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium border ${s}`,children:e})}function Ce(){const{user:S}=L(),{me:P}=T(),{activities:k,updateActivity:F}=G(),{vendors:A}=z(),{dataMapEntries:I}=function(){const{user:t}=L(),[r,s]=e.useState([]),[a,o]=e.useState(!1),[n,i]=e.useState(null),l=e.useCallback(async()=>
1{if(t){o(!0),i(null);try{const{data:e,error:r}=await E.from("data_map_entries").select("id, category, source, purpose, storage, entry_type, entry_data, agent_status, created_at").eq("user_id",t.id).eq("entry_type","agent_seeded").in("agent_status",["pending_review","approved"]).order("created_at",{ascending:!1});if(r)throw r;s(e||[])}catch(e){i(e)}finally{o(!1)}}},[t]);return e.useEffect(()=>{l()},[l]),{dataMapEntries:r,isLoading:a,error:n,refetch:l}}(),[D,R]=e.useState([]),[O,J]=e.useState(!1),[X,Z]=e.useState(!1),[re,se]=e.useState(!1),[de,ce]=e.useState("Data Collection Point"),[pe,me]=e.useState({}),[xe,ue]=e.useState("Data Collection Point"),[ge,he]=e.useState("all"),[be,Ce]=e.useState(null),[we,Se]=e.useState([]),[Pe,ke]=e.useState(null),Fe=e=>ke(t=>t===e?null:e),[Ae,Ie]=e.useState(null),[De,Re]=e.useState(""),[Me,Le]=e.useState(!1),[Ee,Te]=e.useState(null),[Ve,Oe]=e.useState({}),[Ge,ze]=e.useState(null),[$e,Be]=e.useState(!1),[qe,Ue]=e.useState(!1),He=e=>{Te(e.id),Oe(e.entry_data),ze(null),Be(!1),ke(null)},We=()=>{Te(null),Oe({}),ze(null),Be(!1),Ue(!1)},Ye=(e,t)=>Oe(r=>({...r,[e]:t})),Je=async()=>{if(S&&Ee){ze(null),Be(!1),Ue(!0);try{const{error:e}=await E.from("data_map_entries").update({entry_data:Ve}).eq("id",Ee).eq("user_id",S.id);if(e)throw e;R(e=>e.map(e=>e.id===Ee?{...e,entry_data:Ve}:e)),Be(!0),await new Promise(e=>setTimeout(e,500)),We()}catch(e){ze((null==e?void 0:e.message)||"Save failed. Please try again.")}finally{Ue(!1)}}},Xe=({value:e})=>
1{const r=(null==e?void 0:e.split(", ").filter(Boolean))??[];if(0===r.length)return t.jsx("span",{className:"text-muted-foreground",children:"â"});const s=r.slice(0,2),a=r.length-2;return t.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.map(e=>t.jsx("span",{className:"inline-flex items-center rounded-full bg-cyan-50 text-cyan-700 border border-cyan-200 px-2 py-0.5 text-xs font-medium",children:e},e)),a>0&&t.jsxs("span",{className:"inline-flex items-center rounded-full bg-muted text-muted-foreground px-2 py-0.5 text-xs",children:["+",a," more"]})]})},Ze=({value:e,id:r})=>{const s=e??"",a=s.length>60;return t.jsxs("span",{className:"flex items-start gap-1",children:[t.jsx("span",{children:a?s.slice(0,60)+"â¦":s||"â"}),a&&t.jsx("button",{onClick:e=>{e.stopPropagation(),Fe(r)},className:"flex-shrink-0 text-muted-foreground hover:text-foreground mt-0.5","aria-label":"Show full detail",children:t.jsx(Y,{className:"h-3 w-3 transition-transform "+(Pe===r?"rotate-180":"")})})]})},Ke=(e,t)=>me(r=>({...r,[e]:t}));e.useEffect(()=>{Qe()},[S]),e.useEffect(()=>{(null==P?void 0:P.hotel_id)&&et(P.hotel_id)},[null==P?void 0:P.hotel_id]);const Qe=async()=>{if(S)try{const{data:e,error:t}=await E.from("data_map_entries").select("id, entry_type, entry_data").eq("user_id",S.id).order("created_at",{ascending:!1});if(t)throw t;R(e||[])}catch(e){s.error("Failed to load data map")}},et=async e=>{try{const{data:t,error:r}=await E.from("ropa_vendor_links").select("\n vendor_id,\n ropa_activity_id,\n data_categories_shared,\n hotel_vendors!inner(id, vendor_name, products_services),\n dsar_ropa_activities!inner(id, activity_name, personal_data_categories, legal_basis)\n ").eq("hotel_vendors.hotel_id",e);if(r)return;Se(t||[])}catch(t){}},tt=function(t){return e.useMemo(()=>{const e=[];for(const s of t){if(!s.ropaActivityId||0===s.ropaDataCategories.length)continue;if(0===s.vendorDataCategories.length)continue;const t=s.ropaDataCategories.filter(e=>!s.vendorDataCategories.some(t=>t.toLowerCase().includes(e.toLowerCase().split(" ")[0])||e.toLowerCase().includes(t.toLowerCase().split(" ")[0])));if(0===t.length)continue;const r=ne(s.vendorDataCategories,s.ropaDataCategories,t),a=t.some(ae),o=t.some(oe);let n="CPRA §1798.100",i="category_mismatch";a?(n="GDPR Art. 9 / CPRA §1798.121",i="spi_denied"):o&&(n="PCI DSS / CPRA §1798.100",i="financial_denied"),e.push({vendorId:s.vendorId,vendorName:s.vendorName,ropaActivityId:s.ropaActivityId,ropaActivityName:s.ro
1paActivityName??"",conflictType:i,severity:r,vendorClaims:s.vendorDataCategories.join(", ")||"Not documented",ropaClaims:s.ropaDataCategories.join(", "),description:`${s.vendorName} is not documented as collecting ${t.join(", ")}, but the linked processing activity "${s.ropaActivityName}" records this data as actively processed.`,regulation:n})}const r={critical:0,high:1,medium:2,low:3};return e.sort((e,t)=>r[e.severity]-r[t.severity])},[t])}(e.useMemo(()=>we.map(e=>({vendorId:e.hotel_vendors.id,vendorName:e.hotel_vendors.vendor_name,vendorDataCategories:[...e.hotel_vendors.products_services??[],...e.data_categories_shared??[]],ropaActivityId:e.dsar_ropa_activities.id,ropaActivityName:e.dsar_ropa_activities.activity_name,ropaDataCategories:e.dsar_ropa_activities.personal_data_categories??[]})),[we])),rt=e.useMemo(()=>{const e=new Map;for(const t of tt){const r=t.vendorName.toLowerCase(),s=e.get(r)??[];s.push(t),e.set(r,s)}return e},[tt]),st=e.useMemo(()=>{const e=new Map;for(const t of we)e.set(t.hotel_vendors.vendor_name.toLowerCase(),{activity_name:t.dsar_ropa_activities.activity_name,legal_basis:t.dsar_ropa_activities.legal_basis});return e},[we]),at=async e=>{if(S)try{const{error:t}=await E.from("data_map_entries").delete().eq("id",e);if(t)throw t;R(t=>t.filter(t=>t.id!==e)),s.success("Entry deleted")}catch(t){s.error("Failed to delete entry")}},ot=D.filter(e=>"Pixel or Tracking Tech"===e.entry_type),nt=D.filter(e=>"Vendor or System"===e.entry_type),it=e.useMemo(()=>new Set(tt.map(e=>e.vendorName.toLowerCase())),[tt]),lt=e.useMemo(()=>new Set(we.map(e=>e.hotel_vendors.vendor_name.toLowerCase())),[we]),dt=e.useMemo(()=>"orphaned"===ge?nt.filter(e=>{var t;const r=((null==(t=e.entry_data)?void 0:t.system_vendor_name)??"").toLowerCase();return r&&!lt.has(r)}):"conflicts"===ge?nt.filter(e=>{var t;const r=((null==(t=e.entry_data)?void 0:t.system_vendor_name)??"").toLowerCase();return r&&it.has(r)}):nt,[nt,ge,lt,it]),ct=e.useMemo(()=>nt.filter(e=>{var t;const r=((null==(t=e.entry_data)?void 0:t.system_vendor_name)??"").toLowerCase();return r&&!lt.has(r)}).length,[nt,lt]),pt=e.useMemo(()=>(k??[]).map(e=>{var t,r,s,a;return{id:e.id,pi_category:(null==(t=e.personal_data_categories)?void 0:t.join(", "))||"",source_of_pi:(null==(r=e.source_of_pi)?void 0:r.join(", "))||(null==(s=e.data_subject_categories)?void 0:s.join(", "))||"",collection_method:e.description||"â",storage_location:(null==(a=e.service_providers)?void 0:a.join(", "))||"â",business_purpose:e.primary_purpose||e.purpose||e.activity_name,retention_period:e.retention_period||""}}),[k]),mt=e.useMemo(()=>I?I.map(e=>{var t,r,s;return{id:e.id,source:"data_map",pi_category:e.category??"â",source_of_pi:e.source??"â",collection_method:(null==(t=e.entry_data)?void 0:t.collection_method)??"â",storage_location:e.storage??"â",business_purpose:e.purpose??"â",retention_period:(null==(r=e.entry_data)?void 0:r.retention_period)??"â",legal_basis:(null==(s=e.entry_data)?void 0:s.legal_basis)??"â",agent_status:e.agent_status}}):[],[I]),xt=e.useMemo(()=>[...pt,...mt],[pt,mt]),ut=e.useMemo(()=>A.map(e=>{var t;const r="service_provider"===e.vendor_type?"Service Provider":"third_party"===e.vendor_type?"Third Party":"subprocessor"===e.vendor_type?"Contractor":"â",s="sale"===e.data_transfer_type||"onward_sale"===e.data_transfer_type?"Yes":"sharing"===e.data_transfer_type?"Maybe":"service_provision"===e.data_transfer_type?"No":"Uncertain",a=e.has_dpa?"non_compliant"===e.compliance_status?"Signed â Expired":"Signed â Current":"pending"===e.compliance_status?"In Progress":"Not Started";return{id:e.id,pi_shared:(null==(t=e.products_services)?void 0:t.join(", "))||"â",recipient:e.vendor_name,transfer_method:e.integration_type||"â",rights_granted:r,constitutes_sale:s,dpa_status:a}}),[A]),gt=[{type:"Data Collection Point",label:"Data Inventory",list:xt},{type:"Data Sharing/Sale",label:"Data Sharing & Sale",list:ut},{type:"Pixel or Tracking Tech",label:"Pixels & Tracking",list:ot},{type:"Vendor or System",label:"System Data Map",list:nt}];return t.jsxs(M,{children:[t.jsxs("div",{className:"max-w-7xl mx-auto
1space-y-4",children:[t.jsxs("div",{className:"flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl md:text-3xl font-semibold tracking-tight text-foreground",children:"Data Map"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Document where guest data comes from, how it's shared, and which vendors hold it â optimized for CPRA audits."}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Generated from your ROPA Builder entries"}),t.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[t.jsx(r,{to:"/dashboard/ropa",className:"px-4 py-1.5 rounded-full text-sm font-medium border transition-colors bg-transparent text-muted-foreground border-border hover:border-brand-cyan hover:text-brand-cyan",children:"ROPA Builder"}),t.jsx("span",{className:"px-4 py-1.5 rounded-full text-sm font-medium border bg-brand-cyan text-white border-brand-cyan cursor-default",children:"Data Map"})]})]}),t.jsxs(a,{onClick:async()=>{Z(!0);try{await async function(e,t=[]){const r=new V.Workbook;r.creator="HotelComply",r.created=new Date;const s=(new Date).toISOString().slice(0,10),a=r.addWorksheet("I â Data Inventory"),o=["PI Category","Source of PI","Collection Method","Storage Location","Business Purpose","Retention Period"];K(a,"I â Data Inventory",o.length,s),Q(a,o),ee(a,[28,28,25,28,30,22]),e.filter(e=>!e.entry_type||"Data Collection Point"===e.entry_type).forEach((e,t)=>{const r=e.entry_data||{};te(a,[r.pi_category||e.category||"",r.source_of_pi||e.source||"",r.collection_method||"",r.storage_location||e.storage||"",r.business_purpose||e.purpose||"",r.retention_period||""],t)});const n=r.addWorksheet("II â Data Sharing & Sale"),i=["PI Shared","Recipient","Transfer Method","Rights Granted","Constitutes Sale?","DPA Status"];K(n,"II â Data Sharing & Sale",i.length,s),Q(n,i),ee(n,[28,28,25,30,22,22]),e.filter(e=>"Data Sharing/Sale"===e.entry_type).forEach((e,t)=>{const r=e.entry_data||{},s=r.constitutes_sale||"";te(n,[r.pi_shared||"",r.recipient||"",r.transfer_method||"",r.rights_granted||"",s,r.dpa_status||""],t,[{col:5,value:s}])});const l=r.addWorksheet("III â Pixels & Tracking"),d=["Vendor Name","Pixel Type","Pixel Purpose","PI Collected","Constitutes Sale?","Opt-Out Mechanism"];K(l,"III â Pixels & Tracking",d.length,s),Q(l,d),ee(l,[28,25,30,30,22,30]),e.filter(e=>"Pixel or Tracking Tech"===e.entry_type).forEach((e,t)=>{const r=e.entry_data||{},s=r.constitutes_sale||"";te(l,[r.vendor_name||"",r.pixel_type||"",r.pixel_purpose||"",r.pi_collected||"",s,r.opt_out_mechanism||""],t,[{col:5,value:s}])});const c=r.addWorksheet("IV â System Data Map"),p=["System / Vendor Name","Vendor Category","Role","PI Collected","Source of PI","CPRA Classification","DPA Gap Status","Priority Action","Linked ROPA Activity","Legal Basis","GDPR Flags","Department"];K(c,"IV â System Data Map",p.length,s),Q(c,p),ee(c,[30,25,25,28,25,25,22,30,35,25,30,25]),e.filter(e=>"Vendor or System"===e.entry_type).forEach((e,r)=>{var s,a;const o=e.entry_data||{},n=o.dpa_gap_status||"",i=function(e,t){if(!e)return null;const r=e.toLowerCase();return t.find(e=>e.activity_name.toLowerCase().includes(r)||r.includes(e.activity_name.toLowerCase().replace(/ â .*$/,"").trim()))??null}(o.system_vendor_name||"",t);te(c,[o.system_vendor_name||"",o.vendor_category||"",o.role||"",o.pi_collected||"",o.source_of_pi||"",o.cpra_classification||"",n,o.priority_action||"",i?i.activity_name:"Orphaned System",i?i.legal_basis:"",(null==(s=null==i?void 0:i.gdpr_flags)?void 0:s.join("; "))??"",(null==(a=null==i?void 0:i.department_responsible)?void 0:a.join(", "))??""],r,[{col:7,value:n}])});const m=await r.xlsx.writeBuffer(),x=new Blob([m],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}),u=URL.createObjectURL(x),g=document.createElement("a");g.href=u,g.download=`HotelComply_Data_Map_${s}.xlsx`,document.body.appendChild(g),g.click(),document.body.removeChild(g),URL.revokeObjectURL(u)}(D),s.success("Excel exported")}catch(e){s.error("Failed to export Excel")}finally{Z(!1)}},disabled:X||0===D.length,variant:"outline",className:"gap-2",children:[t.jsx($,{className:"h-4 w-4"}),X?"Exportingâ¦":"Export Excel"]})]}),t.jsxs(o,{children:[t.jsx(n,{children:t.jsx(i,{children:"Add Entry"})}),t.jsxs(l,{className:"space-y-5",children:[t.jsx("div",{className:"flex flex-wrap gap-2",children:ie.map(e=>t.jsx("button",{onClick:()=>{ce(e),me({})},className:["px-4 py-1.5 rounded-full text-sm font-medium border transition-colors",de===e?"bg-brand-cyan text-white border-brand-cyan":"bg-transparent text-muted-foreground border-border hover:border-brand-cyan hover:text-brand-cyan"].join(" "),children:e},e))}),"Data Collection Point"===de&&t.jsx(fe,{form:pe,set:Ke}),"Data Sharing/Sale"===de&&t.jsx(ye,{form:pe,set:Ke}),"Pixel or Tracking Tech"===de&&t.jsx(je,{form:pe,set:Ke}),"Vendor or System"===de&&t.jsx(ve,{form:pe,set:Ke}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(a,{onClick:async()=>
1{if(!S)return;if(Object.values(pe).some(e=>e&&""!==e.trim())){J(!0);try{const{data:e,error:t}=await E.from("data_map_entries").insert([{user_id:S.id,entry_type:de,entry_data:pe,category:pe.pi_category||pe.vendor_category||"",source:pe.source_of_pi||pe.recipient||"",purpose:pe.business_purpose||pe.pixel_purpose||"",storage:pe.storage_location||pe.system_vendor_name||""}]).select("id, entry_type, entry_data").single();if(t)throw t;R(t=>[e,...t]),me({}),s.success("Entry added")}catch(e){s.error("Failed to add entry")}finally{J(!1)}}else s.error("Please fill in at least one field before adding an entry")},disabled:O,className:"gap-2 bg-brand-cyan text-white hover:bg-brand-cyan/90",children:[t.jsx(B,{className:"h-4 w-4"}),"Add Entry"]}),t.jsxs(a,{onClick:async()=>{se(!0);try{const e=`Suggest CCPA/CPRA data mapping for a hotel. Entry type: ${de}. Current form values: ${JSON.stringify(pe)}. Provide suggestions for any empty fields.`,{data:t,error:r}=await E.functions.invoke("suggest-ccpa-details",{body:{prompt:e,context:"data_mapping"}});if(r)throw r;if(null==t?void 0:t.suggestions){const e=t.suggestions;me(t=>({...t,...e.category&&!t.pi_category?{pi_category:e.category}:{},...e.source&&!t.source_of_pi?{source_of_pi:e.source}:{},...e.purpose&&!t.business_purpose?{business_purpose:e.purpose}:{},...e.storage&&!t.storage_location?{storage_location:e.storage}:{}})),s.success("AI suggestions applied")}}catch(e){s.error("Failed to get AI suggestions")}finally{se(!1)}},disabled:re,variant:"outline",className:"gap-2",children:[t.jsx(q,{className:"h-4 w-4"}),re?"Getting AI Suggestionsâ¦":"Get AI Suggestions"]})]})]})]}),0===xt.length?t.jsx(o,{children:t.jsx(l,{className:"flex flex-col items-center justify-center py-16 text-center gap-4",children:t.jsx("p",{className:"text-muted-foreground max-w-sm",children:"Your data map will populate after onboarding or when you add processing activities."})})}):t.jsxs(o,{children:[t.jsx(n,{children:t.jsx(i,{children:"Current Data Map"})}),t.jsxs(l,{className:"space-y-4",children:[t.jsx("div",{className:"flex flex-wrap gap-2",children:gt.map(({type:e,label:r,list:s})=>t.jsxs("button",{onClick:()=>{ue(e),he("all")},className:["px-4 py-1.5 rounded-full text-sm font-medium border transition-colors",xe===e?"bg-brand-cyan text-white border-brand-cyan":"bg-transparent text-muted-foreground border-border hover:border-brand-cyan hover:text-brand-cyan"].join(" "),children:[r," (",s.length,")"]},e))}),"Vendor or System"===xe&&t.jsxs("div",{className:"flex items-center gap-4 py-3 px-1 mb-2 border-b border-gray-100",children:[t.jsxs("button",{onClick:()=>he("all"),className:d("flex items-center gap-1.5 text-sm transition-colors","all"===ge?"text-foreground font-medium":"text-muted-foreground hover:text-foreground"),children:[t.jsx("span",{className:"font-semibold",children:nt.length}),t.jsx("span",{children:"Systems"})]}),t.jsx("span",{className:"text-gray-200",children:"|"}),t.jsxs("button",{onClick:()=>he("orphaned"),className:d("flex items-center gap-1.5 text-sm transition-colors","orphaned"===ge?"text-amber-700 font-medium":ct>0?"text-amber-600 hover:text-amber-700":"text-muted-foreground hover:text-foreground"),children:[t.jsx("span",{className:"font-semibold",children:ct}),t.jsx("span",{children:"Orphaned"})]}),t.jsx("span",{className:"text-gray-200",children:"|"}),t.jsxs("button",{onClick:()=>he("conflicts"),className:d("flex items-center gap-1.5 text-sm transition-colors","conflicts"===ge?"text-red-700 font-medium":tt.length>0?"text-red-600 hover:text-red-700":"text-muted-foreground hover:text-foreground"),children:[t.jsx("span",{className:"font-semibold",children:tt.length}),t.jsx("span",{children:"Conflicts"}),tt.length>0&&t.jsx("span",{className:"ml-1 inline-flex items-center justify-center h-4 w-4 rounded-full bg-red-100 text-red-700 text-xs font-bold",children:"!"})]})]}),"Data Collection Point"===xe&&t.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:t.jsxs(c,{className:"w-full text-sm border-collapse",children:[t.jsx(p,{className:"bg-muted/40",children:t.jsxs(m,{children:[t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"PI Category"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Source of PI"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40 hidden md:table-cell",children:"Collection Method"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40 hidden md:table-cell",children:"Storage Location"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Business Purpose"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Retention Period"})]})}),t.jsx(u,{children:0===xt.length?t.jsx(m,{children:t.jsxs(g,{colSpan:6,className:"text-center text-muted-foreground py-8",children:["No data inventory entries yet. Complete onboarding or add processing activities in the ",t.jsx("strong",{children:"ROPA Builder"}),"."]})}):xt.map(e=>{const r=Pe===e.id;return t.jsxs(t.Fragment,{children:[t.jsxs(m,{className:"border-b border-border hover:bg-muted/20 transition-colors cursor-pointer",onClick:()=>Fe(e.id),children:[t.jsx(g,{className:"py-2 px-4 align-top text-sm font-medium",children:Ae===e.id?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("select",{value:De,onChange:e=>Re(e.target.value),onClick:e=>e.stopPropagation(),className:"text-sm border border-input rounded-md px-2 py-1 bg-background focus:outline-none focus:ring-1 focus:ring-ring",children:[t.jsx("option",{value:"",children:"Select PI category"}),le.map(e=>t.jsx("option",{value:e,children:e},e))]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(a,{size:"sm",disabled:Me,onClick:t=>{t.stopPropagation(),(async e=>{if(De){Le(!0);try{await F(e,{personal_data_categories:[De]}),Ie(null)}catch(t){}finally{Le(!1)}}})(e.id)},children:Me?"Savingâ¦":"Save"}),t.jsx(a,{size:"sm",variant:"outline",onClick:e=>{e.stopPropagation(),Ie(null)},children:"Cancel"})]})]}):t.jsxs("div",{className:"flex items-start gap-1",children:[t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5 flex-wrap",children:[t.jsx(Xe,{value:e.pi_category}),"data_map"===e.source&&t.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-amber-100 text-amber-700 border border-amber-200",children:"AI"})]}),"data_map"!==e.source&&t.jsx("button",{onClick:t=>{var r;t.stopPropagation(),Ie(e.id),Re((null==(r=e.pi_category)?void 0:r.split(", ")[0])||"")},className:"flex-shrink-0 text-muted-foreground hover:text-[#00ACC6] transition-colors","aria-label":"Edit PI category",children:t.jsx(U,{className:"h-3.5 w-3.5"})})]})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ze,{value:e.source_of_pi,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm hidden md:table-cell",children:t.jsx(Ze,{value:e.collection_method,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm hidden md:table-cell",children:t.jsx(Ze,{value:e.storage_location,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ze,{value:e.business_purpose,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ze,{value:e.retention_period,id:e.id})})]},e.id),r&&t.jsx(m,{children:t.jsx(g,{colSpan:6,className:"bg-muted/30 px-6 py-4 border-b",children:t.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-3 text-sm",children:[["PI Category",e.pi_category],["Source of PI",e.source_of_pi],["Collection Method",e.collection_method],["Storage Location",e.storage_location],["Business Purpose",e.business_purpose],["Retention Period",e.retention_period]].map(([e,r])=>t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground font-medium uppercase text-xs tracking-wide",children:e}),t.jsx("p",{className:"mt-0.5 text-foreground",children:r||"â"})]},e))})})},`${e.id}-detail`)]})})})]})}),"Data Sharing/Sale"===xe&&t.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:t.jsxs(c,{className:"w-full text-sm border-collapse",children:[t.jsx(p,{className:"bg-muted/40",children:t.jsxs(m,{children:[t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"PI Shared"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Recipient"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40 hidden md:table-cell",children:"Transfer Method"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40 hidden md:table-cell",children:"Rights Granted"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Constitutes Sale/Sharing?"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"DPA Status"})]})}),t.jsx(u,{children:0===ut.length?t.jsx(m,{children:t.jsxs(g,{colSpan:6,className:"text-center text-muted-foreground py-8",children:["No vendors found. Add vendors in the ",t.jsx("strong",{children:"Vendor Hub"})," to populate this view."]})}):ut.map(e=>{const r=Pe===e.id;return t.jsxs(t.Fragment,{children:[t.jsxs(m,{className:"border-b border-border hover:bg-muted/20 transition-colors cursor-pointer",onClick:()=>Fe(e.id),children:[t.jsx(g,{className:"py-2 px-4 align-top text-sm font-medium",children:t.jsx(Xe,{value:e.pi_shared})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ze,{value:e.recipient,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm hidden md:table-cell",children:t.jsx(Ze,{value:e.transfer_method,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm hidden md:table-cell",children:t.jsx(Ze,{value:e.rights_granted,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(_e,{value:e.constitutes_sale})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ze,{value:e.dpa_status,id:e.id})})]},e.id),r&&t.jsx(m,{children:t.jsx(g,{colSpan:6,className:"bg-muted/30 px-6 py-4 border-b",children:t.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-3 text-sm",children:[["PI Shared",e.pi_shared],["Recipient",e.recipient],["Transfer Method",e.transfer_method],["Rights Granted",e.rights_granted],["Constitutes Sale/Sharing",e.constitutes_sale],["DPA Status",e.dpa_status]].map(([e,r])=>t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground font-medium uppercase text-xs tracking-wide",children:e}),t.jsx("p",{className:"mt-0.5 text-foreground",children:r||"â"})]},e))})})},`${e.id}-detail`)]})})})]})}),"Pixel or Tracking Tech"===xe&&t.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:t.jsxs(c,{className:"w-full text-sm border-collapse",children:[t.jsx(p,{className:"bg-muted/40",children:t.jsxs(m,{children:[t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Vendor"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Type"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Purpose"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"PI Collected"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Constitutes Sale/Sharing?"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Opt-Out Mechanism"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40 sticky right-0 bg-background border-l border-border text-right",children:"Actions"})]})}),t.jsx(u,{children:0===ot.length?t.jsx(m,{children:t.jsxs(g,{colSpan:7,className:"text-center text-muted-foreground py-8",children:["No tracking technologies documented yet. Select ",t.jsx("strong",{children:"Pixel or Tracking Tech"})," in the form above to manually add pixels, analytics tags, and session recording tools."]})}):ot.map(e=>{const r=e.entry_data||{},s=Pe===e.id;return t.jsxs(t.Fragment,{children:[t.jsxs(m,{className:"border-b border-border hover:bg-muted/20 transition-colors cursor-pointer",onClick:()=>Fe(e.id),children:[t.jsx(g,{className:"py-2 px-4 align-top text-sm font-medium",children:t.jsx(Ze,{value:r.vendor_name,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ze,{value:r.pixel_type,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ze,{value:r.pixel_purpose,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ze,{value:r.pi_collected,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(_e,{value:r.constitutes_sale||""})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ze,{value:r.opt_out_mechanism,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm sticky right-0 bg-background border-l border-border text-right",children:t.jsxs("div",{className:"flex justify-end items-center gap-1",children:[t.jsx("button",{onClick:t=>{t.stopPropagation(),Ee===e.id?We():He(e)},className:"text-[#00ACC6] hover:text-[#00ACC6]/80 p-1","aria-label":"Edit entry",children:t.jsx(U,{className:"h-3.5 w-3.5"})}),t.jsx("button",{onClick:t=>{t.stopPropagation(),at(e.id)},className:"text-red-500 hover:text-red-700 p-1","aria-label":"Delete entry",children:t.jsx(H,{className:"h-3.5 w-3.5"})})]})})]},e.id),Ee===e.id&&t.jsx(m,{children:t.jsx(g,{colSpan:7,className:"p-0 border-t-2 border-[#00ACC6]",children:t.jsxs("div",{className:"bg-muted/20 px-6 py-5 space-y-4 animate-in fade-in slide-in-from-top-1 duration-150",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("p",{className:"text-sm font-semibold text-foreground",children:["Editing: ",r.vend
1or_name||"Entry"]}),t.jsx("button",{onClick:We,className:"text-muted-foreground hover:text-foreground","aria-label":"Close",children:t.jsx(W,{className:"h-4 w-4"})})]}),t.jsx(je,{form:Ve,set:Ye}),Ge&&t.jsx("p",{className:"text-sm text-red-600 rounded-md bg-red-50 border border-red-200 px-3 py-2",children:Ge}),$e&&t.jsx("p",{className:"text-sm text-emerald-700 font-medium rounded-md bg-emerald-50 border border-emerald-200 px-3 py-2",children:"Saved successfully."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(a,{onClick:Je,disabled:qe,size:"sm",className:"bg-brand-cyan text-white hover:bg-brand-cyan/90",children:qe?"Savingâ¦":"Save Changes"}),t.jsx(a,{variant:"outline",size:"sm",onClick:We,children:"Cancel"})]})]})})}),s&&Ee!==e.id&&t.jsx(m,{children:t.jsx(g,{colSpan:7,className:"bg-muted/30 px-6 py-4 border-b",children:t.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-3 text-sm",children:[["Vendor",r.vendor_name],["Type",r.pixel_type],["Purpose",r.pixel_purpose],["PI Collected",r.pi_collected],["Constitutes Sale/Sharing",r.constitutes_sale],["Opt-Out Mechanism",r.opt_out_mechanism]].map(([e,r])=>t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground font-medium uppercase text-xs tracking-wide",children:e}),t.jsx("p",{className:"mt-0.5 text-foreground",children:r||"â"})]},e))})})},`${e.id}-detail`)]})})})]})}),"Vendor or System"===xe&&t.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:t.jsxs(c,{className:"w-full text-sm border-collapse",children:[t.jsx(p,{className:"bg-muted/40",children:t.jsxs(m,{children:[t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"System/Vendor"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Category"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Role"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"PI Collected"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40 hidden md:table-cell",children:"CPRA Classification"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"DPA Gap Status"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40",children:"Linked Activity"}),t.jsx(x,{className:"py-2 px-4 text-left text-xs font-semibold text-muted-foreground uppercase tracking-wide border-b border-border bg-muted/40 sticky right-0 bg-background border-l border-border text-right",children:"Actions"})]})}),t.jsx(u,{children:0===dt.length?t.jsx(m,{children:t.jsx(g,{colSpan:8,className:"text-center text-muted-foreground py-8",children:"all"!==ge?`No ${ge} vendors found.`:t.jsxs(t.Fragment,{children:["No entries yet. Select ",t.jsx("strong",{children:"Vendor or System"})," above to add your first entry."]})})}):dt.map(e=>{var r;const s=e.entry_data||{},o=(s.system_vendor_name??"").toLowerCase(),n=rt.get(o)??[],i=null==(r=n[0])?void 0:r.severity,l=st.get(o),c=Pe===e.id;return t.jsxs(t.Fragment,{children:[t.jsxs(m,{className:"border-b border-border hover:bg-muted/20 transition-colors cursor-pointer",onClick:()=>Fe(e.id),children:[t.jsx(g,{className:"py-2 px-4 align-top text-sm font-medium",children:t.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[t.jsx(Ze,{value:s.system_vendor_name,id:e.id}),n.length>0&&t.jsx(h,{children:t.jsxs(b,{children:[t.jsx(f,{asChild:!0,children:t.jsx(y,{className:d("text-xs cursor-pointer","critical"===i&&"bg-red-100 text-red-700 border-red-200","high"===i&&"bg-orange-100 text-orange-700 border-orange-200","medium"===i&&"bg-yellow-100 text-yellow-700 border-yellow-200"),onClick:e=>{e.stopPropagation(),Ce(n[0])},children:"â Conflict"})}),t.jsx(j,{className:"max-w-xs text-xs",children:n[0].description})]})})]})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ze,{value:s.vendor_category,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ze,{value:s.role,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ze,{value:s.pi_collected,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm hidden md:table-cell",children:t.jsx(Ze,{value:s.cpra_classification,id:e.id})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:t.jsx(Ne,{value:s.dpa_gap_status||""})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm",children:l?t.jsxs("div",{className:"space-y-1",children:[t.jsx("p",{className:"text-sm text-foreground",children:l.activity_name}),t.jsx(y,{variant:"outline",className:"text-xs",children:l.legal_basis})]}):t.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No linked activity"})}),t.jsx(g,{className:"py-2 px-4 align-top text-sm sticky right-0 bg-background border-l border-border text-right",children:t.jsxs("div",{className:"flex justify-end items-center gap-1",children:[t.jsx("button",{onClick:t=>{t.stopPropagation(),Ee===e.id?We():He(e)},className:"text-[#00ACC6] hover:text-[#00ACC6]/80 p-1","aria-label":"Edit entry",children:t.jsx(U,{className:"h-3.5 w-3.5"})}),t.jsx("button",{onClick:t=>{t.stopPropagation(),at(e.id)},className:"text-red-500 hover:text-red-700 p-1","aria-label":"Delete entry",children:t.jsx(H,{className:"h-3.5 w-3.5"})})]})})]},e.id),Ee===e.id&&t.jsx(m,{children:t.jsx(g,{colSpan:8,className:"p-0 border-t-2 border-[#00ACC6]",children:t.jsxs("div",{className:"bg-muted/20 px-6 py-5 space-y-4 animate-in fade-in slide-in-from-top-1 duration-150",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("p",{className:"text-sm font-semibold text-foreground",children:["Editing: ",s.system_vendor_name||"Entry"]}),t.jsx("button",{onClick:We,className:"text-muted-foreground hover:text-foreground","aria-label":"Close",children:t.jsx(W,{className:"h-4 w-4"})})]}),t.jsx(ve,{form:Ve,set:Ye}),Ge&&t.jsx("p",{className:"text-sm text-red-600 rounded-md bg-red-50 border border-red-200 px-3 py-2",children:Ge}),$e&&t.jsx("p",{className:"text-sm text-emerald-700 font-medium rounded-md bg-emerald-50 border border-emerald-200 px-3 py-2",children:"Saved successfully."}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(a,{onClick:Je,disabled:qe,size:"sm",className:"bg-brand-cyan text-white hover:bg-brand-cyan/90",children:qe?"Savingâ¦":"Save Changes"}),t.jsx(a,{variant:"outline",size:"sm",onClick:We,children:"Cancel"})]})]})})}),c&&Ee!==e.id&&t.jsx(m,{children:t.jsx(g,{colSpan:8,className:"bg-muted/30 px-6 py-4 border-b",children:t.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-3 text-sm",children:[["System/Vendor",s.system_vendor_name],["Category",s.vendor_category],["Role",s.role],["PI Collected",s.pi_collected],["CPRA Classification",s.cpra_classification],["DPA Gap Status",s.dpa_gap_status],["Linked A
1ctivity",null==l?void 0:l.activity_name]].map(([e,r])=>t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground font-medium uppercase text-xs tracking-wide",children:e}),t.jsx("p",{className:"mt-0.5 text-foreground",children:r||"â"})]},e))})})},`${e.id}-detail`)]})})})]})})]})]})]}),t.jsx(v,{open:null!==be,onOpenChange:()=>Ce(null),children:t.jsxs(_,{side:"right",className:"w-[420px] sm:w-[540px]",children:[t.jsxs(N,{children:[t.jsxs(C,{className:"flex items-center gap-2",children:[t.jsx("span",{className:d("inline-block w-2 h-2 rounded-full","critical"===(null==be?void 0:be.severity)&&"bg-red-500","high"===(null==be?void 0:be.severity)&&"bg-orange-500","medium"===(null==be?void 0:be.severity)&&"bg-yellow-500")}),"Data Category Conflict"]}),t.jsx(w,{children:null==be?void 0:be.regulation})]}),be&&t.jsxs("div",{className:"mt-6 space-y-6",children:[t.jsx("div",{className:"rounded-md bg-red-50 border border-red-200 p-4",children:t.jsx("p",{className:"text-sm text-red-800",children:be.description})}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Vendor Record Says"}),t.jsx("div",{className:"rounded-md border p-3 text-sm",children:be.vendorClaims})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"ROPA Activity Says"}),t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3 text-sm",children:be.ropaClaims})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm font-medium",children:"Resolve this conflict:"}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs(a,{variant:"outline",className:"justify-start",onClick:()=>Ce(null),children:["Edit Vendor Record",t.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:["Update what ",be.vendorName," collects"]})]}),t.jsxs(a,{variant:"outline",className:"justify-start",onClick:()=>Ce(null),children:["Edit Processing Activity",t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"Update what the ROPA records"})]})]})]})]})]})})]})}export{Ce 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.