(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,70468,e=>{"use strict";var s=e.i(43476),a=e.i(71645);let n=["811","812","712"],l=["Companies","Contacts","Scoring","Zoho Sync","Audit Log","Live Lookup"];function i({d:e,size:a=15}){return(0,s.jsx)("svg",{width:a,height:a,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,s.jsx)("path",{d:e})})}function r(e){return(0,s.jsx)("span",{className:`badge ${e}`,children:e})}let t=["ALL","HOT","WARM","COLD","EXCLUDE"];function c({icon:e,label:a,value:n}){return(0,s.jsxs)("div",{className:"card",children:[(0,s.jsxs)("div",{className:"label",children:[(0,s.jsx)(i,{d:e,size:14}),a]}),(0,s.jsx)("div",{className:"value",children:n})]})}function d({value:e,onChange:a}){return(0,s.jsx)("div",{className:"filter-row",children:t.map(n=>(0,s.jsx)("button",{className:"filter-btn","aria-pressed":e===n,onClick:()=>a(n),children:"ALL"===n?"All bands":n},n))})}function o(){let[e,n]=(0,a.useState)(null),[l,i]=(0,a.useState)(!1),[r,t]=(0,a.useState)(null);async function c(){if(!l){i(!0),t(null);try{let e=await fetch("/api/zoho-sync",{method:"POST"}),s=await e.json();if(!e.ok)throw Error(s.error??`Sync failed (${e.status})`);n(s.rows)}catch(e){t(e instanceof Error?e.message:"Sync failed")}finally{i(!1)}}}return(0,s.jsxs)("section",{className:"panel",style:{marginBottom:16},children:[(0,s.jsxs)("div",{className:"live-search-row",style:{alignItems:"center"},children:[(0,s.jsx)("button",{className:"live-btn",onClick:c,disabled:l,children:l?"Syncing…":"Run live sync"}),(0,s.jsx)("span",{className:"muted",style:{fontSize:12.5},children:"Pushes the non-excluded demo records into the connected Zoho CRM (EU) with real upserts. Run it twice to see creates become updates. The table below is the mocked plan; this panel shows actual API results."})]}),r&&(0,s.jsx)("div",{className:"score-detail",children:(0,s.jsx)("p",{className:"exclusion-note",children:r})}),e&&(0,s.jsx)("div",{className:"table-wrap",children:(0,s.jsxs)("table",{children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Record"}),(0,s.jsx)("th",{children:"Module"}),(0,s.jsx)("th",{children:"Action"}),(0,s.jsx)("th",{children:"Duplicate key hit"}),(0,s.jsx)("th",{children:"Zoho ID"}),(0,s.jsx)("th",{children:"Result"})]})}),(0,s.jsx)("tbody",{children:e.map(e=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:(0,s.jsx)("strong",{children:e.record})}),(0,s.jsx)("td",{children:e.module}),(0,s.jsx)("td",{children:(0,s.jsx)("span",{className:`pill ${"insert"===e.action?"create":"update"===e.action?"update":"error"===e.status?"failed":"skipped"}`,children:e.action})}),(0,s.jsx)("td",{className:"mono",children:e.duplicate_field??"–"}),(0,s.jsx)("td",{className:"mono",children:e.zoho_id??"–"}),(0,s.jsx)("td",{children:(0,s.jsxs)("span",{className:"nowrap",children:[(0,s.jsx)("span",{className:`dot ${"success"===e.status?"ok":"skipped"===e.status?"warn":"error"}`}),e.message]})})]},`${e.module}-${e.record}`))})]})})]})}function h(){let[e,l]=(0,a.useState)(""),[i,r]=(0,a.useState)(null),[t,c]=(0,a.useState)(null),[d,o]=(0,a.useState)(!1),[h,m]=(0,a.useState)(null);async function u(){if(e.trim()&&!d){o(!0),m(null),c(null);try{let s=await fetch(`/api/companies-house?q=${encodeURIComponent(e.trim())}`),a=await s.json();if(!s.ok)throw Error(a.error??`Lookup failed (${s.status})`);r(a.items)}catch(e){r(null),m(e instanceof Error?e.message:"Lookup failed")}finally{o(!1)}}}async function x(e){o(!0),m(null);try{let s=await fetch(`/api/companies-house?number=${encodeURIComponent(e)}`),a=await s.json();if(!s.ok)throw Error(a.error??`Profile fetch failed (${s.status})`);c(a)}catch(e){m(e instanceof Error?e.message:"Profile fetch failed")}finally{o(!1)}}let j=t?[{label:"Active company status",points:15,awarded:"active"===t.company_status,reason:`Companies House status: ${t.company_status}`},{label:"Relevant SIC / industry",points:15,awarded:t.sic_codes.some(e=>n.some(s=>e.startsWith(s))),reason:t.sic_codes.length?`SIC ${t.sic_codes.join(", ")}`:"No SIC codes on record"},{label:"UK-based",points:10,awarded:!0,reason:"Registered with Companies House"},{label:"Fresh data within 30 days",points:10,awarded:!0,reason:"Fetched live just now"}]:[];return(0,s.jsxs)("section",{className:"panel",children:[(0,s.jsxs)("div",{className:"live-search-row",children:[(0,s.jsx)("input",{className:"live-input",type:"search",placeholder:"Search Companies House by company name",value:e,onChange:e=>l(e.target.value),onKeyDown:e=>"Enter"===e.key&&u(),"aria-label":"Company name"}),(0,s.jsx)("button",{className:"live-btn",onClick:u,disabled:d,children:d?"Searching…":"Search"})]}),(0,s.jsxs)("div",{className:"score-detail",children:[(0,s.jsx)("p",{className:"muted",style:{marginBottom:12},children:"Live Companies House API call, the real Stage 2 of this pipeline. The five demo companies are fabricated, so use any real UK company name here."}),h&&(0,s.jsx)("p",{className:"exclusion-note",children:h}),null!==i&&!t&&(0,s.jsxs)("div",{className:"score-rows",children:[0===i.length&&(0,s.jsx)("p",{className:"muted",children:"No matches. A sandbox-environment key searches an empty test register; a Live key searches the real one."}),i.map(e=>(0,s.jsxs)("button",{className:"score-row live-result",onClick:()=>x(e.company_number),children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{children:e.title}),(0,s.jsxs)("div",{className:"why",children:[e.company_number," · ",e.address_snippet]})]}),(0,s.jsxs)("span",{className:"nowrap",children:[(0,s.jsx)("span",{className:`dot ${"active"===e.company_status?"ok":"error"}`}),e.company_status]})]},e.company_number))]}),t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h2",{children:t.company_name}),(0,s.jsxs)("p",{className:"subject-meta",children:[t.company_number," · incorporated ",t.date_of_creation," ·"," ",t.registered_address,t.sandbox&&" · sandbox environment"]}),(0,s.jsx)("div",{className:"score-rows",children:j.map(e=>(0,s.jsxs)("div",{className:`score-row ${e.awarded?"awarded":""}`,children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{children:e.label}),(0,s.jsx)("div",{className:"why",children:e.reason})]}),(0,s.jsx)("div",{className:`pts ${e.awarded?"":"zero"}`,children:e.awarded?`+${e.points}`:"0"})]},e.label))}),(0,s.jsx)("p",{className:"muted",children:"Remaining rubric items (size fit, domain, LinkedIn, decision maker) need the LinkedIn and people-search stages, which stay mocked in this demo."})]})]})]})}function m({contact:e}){if(!e.email)return(0,s.jsx)("span",{className:"muted",children:"missing"});let a="verified"===e.email_verification_status?"ok":"unverified"===e.email_verification_status?"error":"warn";return(0,s.jsxs)("span",{className:"nowrap",children:[(0,s.jsx)("span",{className:`dot ${a}`}),e.email_verification_status,null!=e.email_confidence&&(0,s.jsxs)("span",{className:"muted num",children:[" ",e.email_confidence,"%"]})]})}e.s(["default",0,function({result:e}){let[n,t]=(0,a.useState)("Companies"),[u,x]=(0,a.useState)("ALL"),[j,p]=(0,a.useState)("ALL"),[b,v]=(0,a.useState)("ALL"),[N,y]=(0,a.useState)(e.companies[0].company_number),{companies:_,contacts:f,companyScores:w,contactScores:g,sync:C,audit:k}=e,L=(0,a.useMemo)(()=>{let e=f.filter(e=>"verified"===e.email_verification_status).length,s=_.filter(e=>"HOT"===w[e.company_number].band).length+f.filter(e=>"HOT"===g[e.id].band).length;return{verifiedEmails:e,hot:s,creates:C.filter(e=>"would_create"===e.status).length,updates:C.filter(e=>"would_update"===e.status).length}},[_,f,w,g,C]),S=_.some(e=>e.company_number===N),$=S?w[N]:g[N],M=_.find(e=>e.company_number===N),A=f.find(e=>e.id===N);return(0,s.jsxs)("div",{className:"shell",children:[(0,s.jsxs)("header",{className:"masthead",children:[(0,s.jsx)("h1",{children:"Clay-to-Zoho Enrichment Pipeline"}),(0,s.jsx)("span",{className:"run-meta",children:"demo run · 2026-06-12 09:00 UTC"})]}),(0,s.jsxs)("p",{className:"demo-banner",children:[(0,s.jsx)(i,{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",size:14}),"Demo environment. Companies and people are fabricated sample data. Companies House lookup and Zoho upsert run live when credentials are present; LinkedIn, Apollo and Hunter remain mocked."]}),(0,s.jsxs)("section",{className:"cards","aria-label":"Run summary",children:[(0,s.jsx)(c,{icon:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2 M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2 M10 6h4 M10 10h4 M10 14h4 M10 18h4",label:"Companies processed",value:_.length}),(0,s.jsx)(c,{icon:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2 M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8 M22 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",label:"Contacts found",value:f.length}),(0,s.jsx)(c,{icon:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8 M22 7l-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7 M16 19l2 2 4-4",label:"Verified emails",value:L.verifiedEmails}),(0,s.jsx)(c,{icon:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",label:"HOT records",value:L.hot}),(0,s.jsx)(c,{icon:"M5 12h14 M12 5v14",label:"Zoho creates",value:L.creates}),(0,s.jsx)(c,{icon:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8 M21 3v5h-5 M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16 M8 16H3v5",label:"Zoho updates",value:L.updates})]}),(0,s.jsx)("div",{className:"tabs",role:"tablist","aria-label":"Pipeline views",children:l.map(e=>(0,s.jsx)("button",{role:"tab","aria-selected":n===e,className:"tab",onClick:()=>t(e),children:e},e))}),"Companies"===n&&(0,s.jsxs)("section",{className:"panel",children:[(0,s.jsx)(d,{value:u,onChange:x}),(0,s.jsx)("div",{className:"table-wrap",children:(0,s.jsxs)("table",{children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Company"}),(0,s.jsx)("th",{children:"CH status"}),(0,s.jsx)("th",{children:"Industry"}),(0,s.jsx)("th",{children:"Employees"}),(0,s.jsx)("th",{children:"Score"}),(0,s.jsx)("th",{children:"Band"}),(0,s.jsx)("th",{children:"Enrichment"})]})}),(0,s.jsx)("tbody",{children:_.filter(e=>"ALL"===u||w[e.company_number].band===u).map(e=>{let a=w[e.company_number];return(0,s.jsxs)("tr",{children:[(0,s.jsxs)("td",{children:[(0,s.jsx)("strong",{children:e.company_name}),(0,s.jsxs)("div",{className:"mono muted",children:[e.company_number," · ",e.domain??"no domain"]})]}),(0,s.jsx)("td",{children:(0,s.jsxs)("span",{className:"nowrap",children:[(0,s.jsx)("span",{className:`dot ${"active"===e.companies_house_status?"ok":"error"}`}),e.companies_house_status]})}),(0,s.jsx)("td",{children:e.industry}),(0,s.jsx)("td",{className:"num",children:e.linkedin_employee_count??"–"}),(0,s.jsx)("td",{className:"num",children:a.total}),(0,s.jsx)("td",{children:r(a.band)}),(0,s.jsxs)("td",{className:"muted",children:[e.data_sources.join(", "),(0,s.jsx)("div",{className:"mono",children:e.last_enriched_at.slice(0,10)})]})]},e.company_number)})})]})})]}),"Contacts"===n&&(0,s.jsxs)("section",{className:"panel",children:[(0,s.jsx)(d,{value:j,onChange:p}),(0,s.jsx)("div",{className:"table-wrap",children:(0,s.jsxs)("table",{children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Name"}),(0,s.jsx)("th",{children:"Title"}),(0,s.jsx)("th",{children:"Company"}),(0,s.jsx)("th",{children:"Email"}),(0,s.jsx)("th",{children:"Source"}),(0,s.jsx)("th",{children:"Verification"}),(0,s.jsx)("th",{children:"Score"}),(0,s.jsx)("th",{children:"Band"})]})}),(0,s.jsx)("tbody",{children:f.filter(e=>"ALL"===j||g[e.id].band===j).map(e=>{let a=g[e.id];return(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{children:(0,s.jsxs)("strong",{children:[e.first_name," ",e.last_name]})}),(0,s.jsx)("td",{children:e.job_title}),(0,s.jsx)("td",{children:e.company_name}),(0,s.jsx)("td",{className:"mono",children:e.email??"–"}),(0,s.jsx)("td",{children:e.email_source?(0,s.jsx)("span",{className:"pill",children:e.email_source}):"–"}),(0,s.jsx)("td",{children:(0,s.jsx)(m,{contact:e})}),(0,s.jsx)("td",{className:"num",children:a.total}),(0,s.jsx)("td",{children:r(a.band)})]},e.id)})})]})})]}),"Scoring"===n&&(0,s.jsxs)("section",{className:"panel score-layout",children:[(0,s.jsxs)("div",{className:"score-list",role:"listbox","aria-label":"Select a record to inspect scoring",children:[(0,s.jsx)("div",{className:"group-label",children:"Companies"}),_.map(e=>(0,s.jsxs)("button",{role:"option","aria-selected":N===e.company_number,className:"score-item",onClick:()=>y(e.company_number),children:[(0,s.jsx)("span",{children:e.company_name}),r(w[e.company_number].band)]},e.company_number)),(0,s.jsx)("div",{className:"group-label",children:"Contacts"}),f.map(e=>(0,s.jsxs)("button",{role:"option","aria-selected":N===e.id,className:"score-item",onClick:()=>y(e.id),children:[(0,s.jsxs)("span",{children:[e.first_name," ",e.last_name]}),r(g[e.id].band)]},e.id))]}),(0,s.jsxs)("div",{className:"score-detail",children:[(0,s.jsx)("h2",{children:S?M?.company_name:`${A?.first_name} ${A?.last_name}`}),(0,s.jsx)("p",{className:"subject-meta",children:S?`Company score \xb7 rubric out of 100 \xb7 ${M?.industry}`:`Contact score \xb7 rubric out of 100 \xb7 ${A?.job_title}, ${A?.company_name}`}),(0,s.jsx)("div",{className:"score-rows",children:$.items.map(e=>(0,s.jsxs)("div",{className:`score-row ${e.awarded?"awarded":""}`,children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{children:e.label}),(0,s.jsx)("div",{className:"why",children:e.reason})]}),(0,s.jsx)("div",{className:`pts ${e.awarded?"":"zero"}`,children:e.awarded?`+${e.points}`:"0"})]},e.label))}),(0,s.jsxs)("div",{className:"score-total",children:[(0,s.jsxs)("span",{className:"big num",children:[$.total,"/100"]}),r($.band),(0,s.jsx)("span",{className:"muted",children:"HOT 80+ · WARM 60-79 · COLD 40-59 · EXCLUDE <40"})]}),$.exclusion_reason&&(0,s.jsxs)("p",{className:"exclusion-note",children:["Automatic exclusion: ",$.exclusion_reason,". Exclusion rules override the numeric band."]})]})]}),"Zoho Sync"===n&&(0,s.jsx)(o,{}),"Zoho Sync"===n&&(0,s.jsxs)("section",{className:"panel",children:[(0,s.jsx)("div",{className:"filter-row",children:["ALL","would_create","would_update","skipped","failed"].map(e=>(0,s.jsx)("button",{className:"filter-btn","aria-pressed":b===e,onClick:()=>v(e),children:"ALL"===e?"All":e},e))}),(0,s.jsx)("div",{className:"table-wrap",children:(0,s.jsxs)("table",{children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Record"}),(0,s.jsx)("th",{children:"Module"}),(0,s.jsx)("th",{children:"Action"}),(0,s.jsx)("th",{children:"Duplicate key"}),(0,s.jsx)("th",{children:"Matched ID"}),(0,s.jsx)("th",{children:"Payload"}),(0,s.jsx)("th",{children:"Result"})]})}),(0,s.jsx)("tbody",{children:C.filter(e=>"ALL"===b||e.status===b).map(e=>{let a,n,l="company"===e.record_type?_.find(s=>s.company_number===e.source_record_id)?.company_name:(a=f.find(s=>s.id===e.source_record_id))?`${a.first_name} ${a.last_name}`:void 0;return(0,s.jsxs)("tr",{children:[(0,s.jsxs)("td",{children:[(0,s.jsx)("strong",{children:l??e.source_record_id}),(0,s.jsx)("div",{className:"mono muted",children:e.source_record_id})]}),(0,s.jsx)("td",{children:e.target_module}),(0,s.jsx)("td",{children:(n="would_create"===e.status?"create":"would_update"===e.status?"update":"failed"===e.status?"failed":"skipped",(0,s.jsx)("span",{className:`pill ${n}`,children:e.action}))}),(0,s.jsxs)("td",{children:[(0,s.jsx)("span",{className:"pill",children:e.duplicate_key}),(0,s.jsx)("div",{className:"mono muted",children:e.duplicate_key_value})]}),(0,s.jsx)("td",{className:"mono",children:e.matched_existing_id??"–"}),(0,s.jsx)("td",{children:(0,s.jsxs)("details",{className:"payload",children:[(0,s.jsx)("summary",{children:"view payload"}),(0,s.jsx)("pre",{children:JSON.stringify(e.payload,null,2)})]})}),(0,s.jsxs)("td",{children:[(0,s.jsxs)("span",{className:"nowrap",children:[(0,s.jsx)("span",{className:`dot ${"failed"===e.status?"error":"skipped"===e.status?"warn":"ok"}`}),e.status]}),e.skip_reason&&(0,s.jsx)("div",{className:"muted",children:e.skip_reason})]})]},`${e.record_type}-${e.source_record_id}`)})})]})})]}),"Audit Log"===n&&(0,s.jsx)("section",{className:"panel",children:(0,s.jsx)("div",{className:"table-wrap",children:(0,s.jsxs)("table",{children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{children:"Time"}),(0,s.jsx)("th",{children:"Record"}),(0,s.jsx)("th",{children:"Event"}),(0,s.jsx)("th",{children:"Detail"})]})}),(0,s.jsx)("tbody",{children:k.map(e=>(0,s.jsxs)("tr",{children:[(0,s.jsx)("td",{className:"mono nowrap",children:e.created_at.replace("T"," ").replace(".000Z"," UTC").replace("Z"," UTC")}),(0,s.jsxs)("td",{children:[(0,s.jsx)("span",{className:"pill",children:e.record_type})," ",(0,s.jsx)("span",{className:"mono muted",children:e.source_record_id})]}),(0,s.jsxs)("td",{className:"nowrap",children:[(0,s.jsx)("span",{className:`dot ${e.status}`}),(0,s.jsx)("span",{className:"mono",children:e.event})]}),(0,s.jsx)("td",{children:e.detail})]},e.id))})]})})}),"Live Lookup"===n&&(0,s.jsx)(h,{}),(0,s.jsx)("p",{className:"footnote",children:"Scoring rubric, banding thresholds, waterfall order and upsert keys mirror the production Clay build described in the README. Data is regenerated deterministically on every load."})]})}],70468)}]);