1import{j as e}from"./vendor-xyflow-Bqj2XMRf.js";import{L as Ge,c as he,r as h}from"./vendor-react-Mx8zmtJs.js";import{g as Le,w as Xe,b as ue,e as Me,f as Ye,A as Fe,I as Ee,S as ge,P as Qe,k as Ke,C as X,Y as Ze,X as U,H as Je,o as me,u as Ie,d as et,ad as Z,s as Ae,D as tt,ae as st}from"./index-C_xpKSSY.js";import{u as pe}from"./useApi-DuF2XD3B.js";import{r as ee,c as te,e as nt,a as at,s as it}from"./risk-ajJztyKg.js";import{E as ze}from"./ErrorDisplay-BLL6uajh.js";import{A as Oe}from"./arrow-right-ChVVABHC.js";import{S as lt}from"./Skeleton-C_UfDS7C.js";import{S as W}from"./SearchableSelect-DRJ0soge.js";import{U as xe}from"./UpgradePrompt-8FDdT6mY.js";import{P as We}from"./PlanBadge-Cpd-W8JD.js";import{C as q,a as fe,G as ot}from"./globe-DjK12W38.js";import{L as V}from"./layers-Bz6zECnT.js";import{Z as se}from"./zap-Cn_rsvr4.js";import{R as be}from"./UpgradeConnectionCard-Det5sggA.js";import{D as rt}from"./download-2Bpt6v_q.js";import{F as je}from"./file-text-CX_DuOZu.js";import{T as ne}from"./triangle-alert-D1u4XH4j.js";import{E as ae}from"./external-link-CAh5tZRv.js";import{G as Re}from"./git-branch-CLBhGT4q.js";import{L as G}from"./loader-circle-D5X8hXw9.js";import{U as ct}from"./user-DLDOj_qz.js";import{C as dt}from"./clock-Dy13U05s.js";import{X as mt}from"./x-Srh7iRtV.js";import{C as Ue}from"./chevron-up-DGEaenMG.js";import{L as pt}from"./list-checks-DNdk2CFh.js";import"./mail-DMs_uPbb.js";import"./circle-check-BSK4rklu.js";/** 2 * @license lucide-react v1.16.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 xt=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],ht=Le("printer",xt);/** 7 * @license lucide-react v1.16.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 ut=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],gt=Le("upload",ut);function Ve(){return e.jsxs("div",{className:"card overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-default bg-surface-2 flex items-center gap-2.5",children:[e.jsx("span",{className:"w-7 h-7 rounded-md bg-accent-soft text-accent grid place-items-center shrink-0",children:e.jsx(Xe,{size:16,strokeWidth:1.8})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase text-ink-4",style:{letterSpacing:"0.09em"},children:"Next step â deploy"}),e.jsx("p",{className:"text-xs text-ink-3 mt-0.5",children:"Looks safe â Validate â Deploy to sandbox"})]})]}),e.jsxs("div",{className:"px-4 py-3.5 space-y-3",children:[e.jsxs("p",{className:"text-[13px] text-ink-2 leading-relaxed m-0",children:["When the impact looks clean, Deplo can deploy the change for you. It runs a ",e.jsx("strong",{className:"text-ink",children:"dry-run validation"})," against your sandbox first and only writes after that succeeds. Production deploys stay blocked."]}),e.jsx("p",{className:"text-xs text-ink-3 leading-relaxed m-0",children:"Validation and deploy run from a ticket proposal, where Deplo generates the Salesforce metadata XML for the change."}),e.jsxs(Ge,{to:"/tickets",className:"btn btn-primary inline-flex items-center gap-1.5 text-xs px-3.5 py-2 no-underline",children:["Open a proposal to deploy",e.jsx(Oe,{size:14,strokeWidth:2})]})]})]})}const ie=[{value:"CustomField",label:"Custom Field",icon:q},{value:"ApexClass",label:"Apex Class",icon:fe},{value:"ApexTrigger",label:"Apex Trigger",icon:Ee},{value:"LightningComponentBundle",label:"LWC",icon:V},{value:"ValidationRule",label:"Validation Rule",icon:ge},{value:"Flow",label:"Flow",icon:se}],ft={CustomField:{name:"Select fieldâ¦"},ApexClass:{name:"Select Apex classâ¦"},ApexTrigger:{name:"Select Apex triggerâ¦"},LightningComponentBundle:{name:"Select LWC bundleâ¦"},ValidationRule:{name:"Select validation ruleâ¦"},Flow:{name:"Select flowâ¦"}};let bt=1;const _=(t="CustomField")=>({id:bt++,componentType:t,objectApiName:"",fieldApiName:"",name:""}),jt={Flow:{label:"Flow",cls:"badge-flow"},ApexClass:{label:"Apex",cls:"badge-apex"},ApexTrigger:{label:"Trigger",cls:"badge-apex"},LightningComponentBundle:{label:"LWC",cls:"badge-lwc"},AuraDefinitionBundle:{label:"Aura",cls:"badge-lwc"},Report:{label:"Report",cls:"badge-report"},Dashboard:{label:"Dashboard",cls:"badge-report"},ValidationRule:{label:"Validation",cls:"badge-validation"},FormulaField:{label:"Formula",cls:"badge-lwc"},WorkflowRule:{label:"Workflow",cls:"badge-validation"}
11,WorkflowFieldUpdate:{label:"WF Action",cls:"badge-validation"},ApprovalProcess:{label:"Approval",cls:"badge-validation"},EmailTemplate:{label:"Email",cls:"badge-other"},PageLayout:{label:"Page Layout",cls:"badge-other"},ListView:{label:"List View",cls:"badge-other"},LightningPage:{label:"Lightning Page",cls:"badge-flow"},PermissionSet:{label:"Perm Set",cls:"badge-other"},Profile:{label:"Profile",cls:"badge-other"}},ye=t=>jt[t]??{label:t,cls:"badge-other"},yt={Flow:se,ApexClass:fe,ApexTrigger:Ee,LightningComponentBundle:q,AuraDefinitionBundle:V,ValidationRule:ge,FormulaField:Re,WorkflowRule:Re,Report:q,Dashboard:q,VisualforcePage:ot},Ne=t=>yt[t]??V;function le(t){return ie.find(s=>s.value===t)?.label??t}function ke(t){return ie.find(s=>s.value===t)?.icon??q}function Nt(t){return t.split(/\*\*(.+?)\*\*/g).map((o,a)=>a%2===1?e.jsx("strong",{className:"text-ink font-semibold",children:o},a):o)}function F(t){return t.components??t.fields??[]}function kt(t){const s=F(t),a=["# Deployment Impact Report","",`**Date:** ${new Date(t.analyzedAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}`,`**Components Analyzed:** ${s.length}`,`**Unique Dependencies:** ${t.uniqueDependencyCount}`,`**Hotspot Components:** ${t.hotspots.length}`,"","## Changeset Components","",...s.map(i=>{const l=le(i.componentType),n=i.fieldLabel?` â ${i.fieldLabel}`:"";return`- **[${l}]** \`${i.displayName}\`${n} · **${i.dependencyCount} deps**`}),""];if(t.hotspots.length>0){a.push("## Hotspot Components (referenced by multiple items)",""),a.push("| Component | Type | Items Impacted |","|---|---|---|");for(const i of t.hotspots)a.push(`| ${i.name} | ${i.type} | ${i.fieldCount} (${i.fields.join(", ")}) |`);a.push("")}t.aiSummary&&a.push("## AI Deployment Risk Assessment","",t.aiSummary,"");const r=t.allDependencies.reduce((i,l)=>(i[l.type]=i[l.type]??[],i[l.type].push(l),i),{});a.push("## All Dependencies","");for(const[i,l]of Object.entries(r)){a.push(`### ${i} (${l.length})`,"");for(const n of l){const c=n.namespace?` [${n.namespace}]`:"",d=n.sfUrl?` â [View](${n.sfUrl})`:"";a.push(`- \`${n.name}\`${c}${d}`)}a.push("")}return a.push("---","*Generated by [Deplo](https://getdeplo.com)*"),a.join(` 12`)}function vt(t,s){const o=new Blob([s],{type:"text/markdown;charset=utf-8"}),a=URL.createObjectURL(o),r=Object.assign(document.createElement("a"),{href:a,download:t});document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(a)}function wt(t){const s=F(t),o=new Date(t.analyzedAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),a=s.map(x=>`<tr><td><code>${x.displayName}</code>${x.fieldLabel?`<br><small>${x.fieldLabel}</small>`:""}</td><td>${le(x.componentType)}</td><td>${x.dependencyCount}</td><td>${x.cached?"Cached":"Fresh"}</td></tr>`).join(""),r=t.hotspots.map(x=>`<tr><td><strong>${x.name}</strong></td><td>${x.type}</td><td>${x.fieldCount}</td><td><small>${x.fields.join(", ")}</small></td></tr>`).join(""),i=t.allDependencies.reduce((x,y)=>(x[y.type]=x[y.type]??[],x[y.type].push(y),x),{}),l=Object.entries(i).map(([x,y])=>`<h3>${x} (${y.length})</h3><ul>${y.map(m=>`<li><code>${m.name}</code>${m.namespace?` <span style="color:#6b675c">[${m.namespace}]</span>`:""}</li>`).join("")}</ul>`).join(""),n=te(t.uniqueDependencyCount),c=n==="high"?"color:#9a2419":n==="medium"?"color:#8a5a14":"color:#0e5a3c",d=`<!DOCTYPE html><html><head><meta charset="utf-8"><title>Deplo â Deployment Impact Report</title> 13<style> 14 body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color:#14120c;margin:0;padding:32px 48px;font-size:13px;line-height:1.6} 15 h1{font-size:20px;margin:0 0 4px}h2{font-size:15px;border-bottom:1px solid #e7e4dc;padding-bottom:6px;margin-top:28px} 16 h3{font-size:13px;font-weight:600;margin:16px 0 6px;color:#3a3830} 17 table{width:100%;border-collapse:collapse;margin:10px 0;font-size:12px} 18 th{padding:7px 10px;background:#f6f2e7;border:1px solid #e7e4dc;text-align:left;font-size:11px;text-transform:uppercase;letter-spacing:.05em;color:#6b675c} 19 td{padding:7px 10px;border:1px solid #e7e4dc;vertical-align:top}tr:nth-child(even) td{background:#faf7ee} 20 code{font-family:'JetBrains Mono','SF Mono',monospace;font-size:11px;background:#f0ece1;padding:1px 5px;border-radius:3px} 21 .meta{color:#6b675c;font-size:12px;margin-bottom:18px}.stats{display:flex;gap:12px;margin-bottom:24px} 22 .stat{background:#faf7ee;border:1px solid #e7e4dc;border-radius:8px;padding:10px 16px;text-align:center} 23 .stat-val{font-size:22px;font-weight:700}.stat-lbl{font-size:11px;color:#6b675c} 24 ul{padding-left:20px;margin:4px 0 12px}li{margin-bottom:3px}small{color:#6b675c} 25 .ai-box{background:#ecf3ec;border-left:3px solid #0e5a3c;padding:12px 16px;border-radius:0 6px 6px 0;margin:12px 0;white-space:pre-wrap} 26 .footer{margin-top:36px;padding-top:12px;border-top:1px solid #e7e4dc;font-size:11px;color:#9c9789} 27 @media print{body{padding:24px}} 28</style></head><body> 29 <h1>Deployment Impact Report</h1> 30 <div class="meta">Generated: ${o} · ${s.length} component${s.length!==1?"s":""} analyzed</div> 31 <div class="stats"> 32 <div class="stat"><div class="stat-val">${s.length}</div><div class="stat-lbl">Components</div></div> 33 <div class="stat"><div class="stat-val" style="${c}">${t.uniqueDependencyCount}</div><div class="stat-lbl">Unique deps</div></div> 34 <div class="stat"><div class="stat-val">${t.hotspots.length}</div><div class="stat-lbl">Hotspots</div></div> 35 </div> 36 <h2>Components in Changeset</h2> 37 <table><thead><tr><th>
37Component</th><th>Type</th><th>Deps</th><th>Source</th></tr></thead><tbody>${a}</tbody></table> 38 ${t.hotspots.length>0?`<h2>Hotspot Components</h2><p style="font-size:12px;color:#6b675c">Referenced by 2+ items in this changeset â highest regression risk.</p><table><thead><tr><th>Component</th><th>Type</th><th>Items</th><th>Referenced By</th></tr></thead><tbody>${r}</tbody></table>`:""} 39 ${t.aiSummary?`<h2>AI Risk Assessment</h2><div class="ai-box">${t.aiSummary}</div>`:""} 40 <h2>All Dependencies</h2>${l} 41 <div class="footer">Generated by Deplo â getdeplo.com</div> 42</body></html>`,g=window.open("","_blank");g&&(g.document.write(d),g.document.close(),g.focus(),setTimeout(()=>{g.print()},400))}function Ct(t){const s=F(t),o=s.map(l=>`⢠[${le(l.componentType)}] \`${l.displayName}\` â ${l.dependencyCount} deps`).join(` 43`),a=t.hotspots.slice(0,3).map(l=>`â ï¸ *${l.name}* (${l.type}) â touches ${l.fieldCount} items`).join(` 44`),r=te(t.uniqueDependencyCount);return[`${r==="high"?"ð´ HIGH":r==="medium"?"ð¡ MEDIUM":"ð¢ LOW"} risk · ${t.uniqueDependencyCount} unique dependencies across ${s.length} components`,"","*Changeset components:*",o,...a?["","*Hotspot components (highest risk):*",a]:[],...t.aiSummary?["","*AI Assessment:*",t.aiSummary.replace(/\*\*(.*?)\*\*/g,"*$1*").slice(0,500)]:[]].join(` 45`)}function $e({orgId:t,componentType:s,objectApiName:o,value:a,onChange:r,disabled:i}){const[l,n]=h.useState(0),c=s==="ValidationRule",d=t&&(!c||!!o),g=pe(()=>d?me.getMetadataList(t,s,o,l>0):Promise.resolve({items:[],cachedAt:""}),[t,s,o,l]),x=h.useMemo(()=>(g.data?.items??[]).map(f=>({value:f.name,label:f.label,meta:f.extra??f.name})),[g.data]),y=g.data?.cachedAt,m=y?`Cached ${new Date(y).toLocaleTimeString()} · Click to refresh from Salesforce`:"Click to pull latest from Salesforce",j=d?g.loading?"Loadingâ¦":ft[s].name:c?"Pick object first":"Select org first";return e.jsxs("div",{className:"flex items-center gap-1.5 w-full min-w-0",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(W,{options:x,value:a,onChange:r,placeholder:j,disabled:i||!d||g.loading})}),e.jsx("button",{type:"button",onClick:()=>n(f=>f+1),disabled:!d||g.loading,title:m,className:"shrink-0 p-1.5 rounded-md text-ink-4 hover:text-ink hover:bg-surface-2 disabled:opacity-30 transition-colors",children:e.jsx(be,{size:11,strokeWidth:2,className:g.loading?"animate-spin":""})})]})}function St({entry:t,orgId:s,onUpdate:o,showField:a}){const r=pe(()=>s?me.getObjects(s):Promise.resolve([]),[s]),i=pe(()=>s&&t.objectApiName&&a?me.getFields(s,t.objectApiName):Promise.resolve([]),[s,t.objectApiName,a]),l=h.useMemo(()=>(r.data??[]).map(c=>({value:c.apiName,label:c.label,meta:c.apiName})),[r.data]),n=h.useMemo(()=>(i.data??[]).map(c=>({value:c.apiName,label:c.label,meta:`${c.apiName} · ${c.type}`})),[i.data]);return e.jsxs(e.Fragment,{children:[e.jsx(W,{options:l,value:t.objectApiName,onChange:c=>o(t.id,{objectApiName:c,fieldApiName:""}),placeholder:s?r.loading?"Loading objectsâ¦":"Select objectâ¦":"Select org first",disabled:!s||r.loading}),a&&e.jsx(W,{options:n,value:t.fieldApiName,onChange:c=>{const d=i.data?.find(g=>g.apiName===c);o(t.id,{fieldApiName:c,fieldLabel:d?.label})},placeholder:t.objectApiName?i.loading?"Loading fieldsâ¦":"Select fieldâ¦":"Pick object first",disabled:!t.objectApiName||i.loading})]})}function At({entry:t,orgId:s,onUpdate:o,onRemove:a,removable:r}){const i=t.componentType==="CustomField",l=t.componentType==="ValidationRule",n=i||l,c=i,d=!i,g=ke(t.componentType);return e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"shrink-0 w-40 relative",children:[e.jsx("select",{value:t.componentType,onChange:x=>o(t.id,{componentType:x.target.value,objectApiName:"",fieldApiName:"",name:"",fieldLabel:null}),className:"input pl-9 pr-7 appearance-none cursor-pointer text-[12.5px] font-medium",children:ie.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))}),e.jsx(g,{size:13,strokeWidth:1.7,className:"absolute left-3 top-1/2 -translate-y-1/2 text-accent pointer-events-none"}),e.jsx(X,{size:12,strokeWidth:2,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-ink-4 pointer-events-none"})]}),e.jsxs("div",{className:`flex-1 min-w-0 grid gap-2 ${n?"grid-cols-1 sm:grid-cols-2":"grid-cols-1"}`,children:[n&&e.jsx(St,{entry:t,orgId:s,onUpdate:o,showField:c}),l&&e.jsx($e,{orgId:s,componentType:"ValidationRule",objectApiName:t.objectApiName,value:t.name,onChange:x=>o(t.id,{name:x}),disabled:!t.objectApiName}),d&&!l&&e.jsx($e,{orgId:s,componentType:t.componentType,value:t.name,onChange:x=>o(t.id,{name:x})})]}),r&&e.jsx("button",{onClick:()=>a(t.id),className:"mt-1 p-2 text-ink-4 hover:text-risk-high hover:bg-risk-high-bg rounded-md transition-colors shrink-0",title:"Remove c
45omponent","aria-label":"Remove component",children:e.jsx(Ze,{size:13,strokeWidth:1.7})})]})}function zt({report:t}){const s=F(t),o=h.useMemo(()=>{const m=new Map;for(const j of s){const f=new Map;for(const k of j.rawDependencies??[])f.set(k.type,(f.get(k.type)??0)+1);m.set(j.displayName,f)}return m},[s]),a=h.useMemo(()=>{const m=new Map;for(const j of t.allDependencies)m.set(j.type,(m.get(j.type)??0)+1);return Array.from(m.entries()).sort((j,f)=>f[1]-j[1]).slice(0,8)},[t.allDependencies]);if(s.length===0||a.length===0)return null;const r=640,i=44,l=Math.max(s.length,a.length)*i+24,n=8,c=r-8,d=12,g=m=>d+m*i+i/2,x=m=>d+m*i+i/2,y=Math.max(...a.map(([,m])=>m));return e.jsxs("div",{className:"card overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-default bg-surface-2 flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-[11px] font-semibold uppercase text-ink-4",style:{letterSpacing:"0.09em"},children:"Dependency fan-out"}),e.jsx("p",{className:"text-xs text-ink-3 mt-0.5",children:"Components â dependency types they pull in"})]})}),e.jsxs("div",{className:"px-4 py-4 overflow-x-auto",children:[e.jsxs("svg",{viewBox:`0 0 ${r} ${l}`,className:"w-full",style:{minWidth:480,height:l},children:[s.map((m,j)=>{const f=o.get(m.displayName);return f?a.map(([k],z)=>{if(!f.has(k))return null;const C=Math.min(.55,.18+(f.get(k)??0)/8),v=g(j),w=x(z),R=(n+c)/2;return e.jsx("path",{d:`M ${n+140} ${v} C ${R} ${v}, ${R} ${w}, ${c-140} ${w}`,fill:"none",stroke:"var(--accent)",strokeOpacity:C,strokeWidth:"1.5"},`${m.displayName}-${k}`)}):null}),s.map((m,j)=>{const f=g(j),k=ke(m.componentType);return e.jsxs("g",{children:[e.jsx("rect",{x:n,y:f-16,width:140,height:32,rx:"6",fill:"var(--surface)",stroke:"var(--border)"}),e.jsx("foreignObject",{x:n+8,y:f-12,width:124,height:24,children:e.jsxs("div",{className:"flex items-center gap-1.5 h-full",children:[e.jsx(k,{size:11,strokeWidth:1.8,className:"text-accent shrink-0"}),e.jsx("span",{className:"text-[11px] font-semibold text-ink truncate",title:m.displayName,children:m.displayName})]})}),e.jsx("text",{x:n+138,y:f+3,textAnchor:"end",fontSize:"9",fill:"var(--ink-4)",children:m.dependencyCount})]},m.displayName)}),a.map(([m,j],f)=>{const k=x(f),z=Ne(m),C=j/y>.7,v=C?"var(--risk-high-bg)":"var(--accent-soft)",w=C?"var(--risk-high)":"var(--border)",R=C?"var(--risk-high)":"var(--accent)";return e.jsxs("g",{children:[e.jsx("rect",{x:c-140,y:k-16,width:140,height:32,rx:"6",fill:v,stroke:w,strokeWidth:"1"}),e.jsx("foreignObject",{x:c-132,y:k-12,width:124,height:24,children:e.jsxs("div",{className:"flex items-center gap-1.5 h-full",children:[e.jsx(z,{size:11,strokeWidth:1.8,style:{color:R},className:"shrink-0"}),e.jsx("span",{className:"text-[11px] font-semibold truncate",style:{color:R},children:ye(m).label}),e.jsx("span",{className:"text-[10px] ml-auto tabular",style:{color:R},children:j})]})})]},m)})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px] text-ink-4",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm",style:{background:"var(--accent)"}}),"shared dependency"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm",style:{background:"var(--risk-high)"}}),"highest fan-out type"]})]})]})]})}function Rt({hotspot:t}){const s=ye(t.type),o=Ne(t.type);return e.jsxs("div",{className:"flex items-start justify-between gap-4 px-4 py-3 border-b border-default last:border-0 hover:bg-surface-2 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0 flex-1",children:[e.jsx("span",{className:"w-7 h-7 rounded-sm bg-surface-2 grid place-items-center text-ink-3 shrink-0",children:e.jsx(o,{size:13,strokeWidth:1.7})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-ink truncate",children:t.name}),e.jsxs("p",{className:"text-xs text-ink-3 mt-0.5",children:["References:"," ",t.fields.map(a=>e.jsx("code",{className:"text-[10px] bg-surface-2 border border-default rounded px-1 mx-0.5 mono",children:a},a))]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("span",{className:`chip ${s.cls}`,children:s.label}),e.jsx("span",{className:"chip bg-risk-high-bg text-risk-high tabular",children:t.fieldCount})]})]})}function $t({deps:t}){const s=h.useMemo(()=>t.reduce((r,i)=>(r[i.type]=r[i.type]??[],r[i.type].push(i),r),{}),[t]),[o,a]=h.useState({});return e.jsx("div",{className:"space-y-2",children:Object.entries(s).map(([r,i])=>{const l=o[r]??!0,n=ye(r),c=Ne(r);return e.jsxs("div",{className:"card overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(d=>({...d,[r]:!l})),className:"w-full flex items-center justify-between px-4 py-2.5 bg-surface-2 hover:bg-surface transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-6 h-6 rounded-sm bg-surface grid place-items-center text-ink-3",children:e.jsx(c,{size:11,strokeWidth:1.7})}),e.jsx("span",{className:`chip ${n.cls}`,children:n.label}),e.jsxs("span",{className:"text-xs text-ink-3",children:[i.length," component",i.length!==1?"s":""]})]}),e.jsx(X,{size:13,strokeWidth:2,className:`text-ink-4 transition-transform ${l?"":"-rotate-90"}`})]}),l&&e.jsx("div",{children:i.map(d=>e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 hover:bg-surface-2 border-b border-default last:border-0 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-sm text-ink truncate font-medium",children:d.name}),d.namespace&&e.jsx("span",{className:"text-xs text-ink-4 mono shrink-0",children:d.namespace})]}),d.sfUrl&&e.jsx("a",{href:d.sfUrl,target:"_blank",rel:"noreferrer",className:"text-ink-4 hover:text-accent transition-colors shrink-0 ml-4",children:e.jsx(ae,{size:12,strokeWidth:1.8})})]},d.id))})]},r)})})}function Tt({comp:t}
45){const s=t.componentType,o=nt(s,t.dependencyCount),a=at(s,t.dependencyCount),r=it(s),i=r!=null&&t.dependencyCount===0&&o!=="safe",l=ke(t.componentType);return e.jsxs("div",{className:"px-4 py-3 border-b border-default last:border-0 hover:bg-surface-2 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 chip bg-surface-2 text-ink-3 shrink-0",children:[e.jsx(l,{size:10,strokeWidth:1.8}),le(t.componentType)]}),e.jsx("p",{className:"text-sm mono text-ink truncate font-medium",children:t.displayName})]}),t.fieldLabel&&e.jsx("p",{className:"text-xs text-ink-3 mt-0.5 truncate",children:t.fieldLabel})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.fieldType&&e.jsx("span",{className:"chip bg-surface-2 text-ink-3 mono",children:t.fieldType}),e.jsxs("span",{className:`${a.chipClass} tabular`,title:r??void 0,children:[a.label," · ",t.dependencyCount," dep",t.dependencyCount!==1?"s":""]}),t.cached&&e.jsx("span",{className:"chip bg-surface-2 text-ink-4",children:"cached"})]})]}),i&&e.jsxs("p",{className:"text-[11.5px] text-ink-3 mt-2 ml-1 leading-snug",children:[e.jsx("span",{className:"font-semibold text-ink-2",children:"Heads up: "}),r]})]})}function Te({report:t}){const s=ue(),[o,a]=h.useState(!1),r=`deplo-deploy-impact-${new Date(t.analyzedAt).toISOString().slice(0,10)}`;async function i(){a(!0);try{const{channel:l}=await Je.postMessage(`ð Deployment Impact: ${F(t).length} component${F(t).length!==1?"s":""}`,Ct(t));s.success(`Posted to #${l}`)}catch(l){s.error(l instanceof Error?l.message:"Failed to post to Slack")}finally{a(!1)}}return e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>vt(`${r}.md`,kt(t)),className:"btn btn-sm flex items-center gap-1.5",children:[e.jsx(rt,{size:12,strokeWidth:1.8})," Markdown"]}),e.jsxs("button",{type:"button",onClick:()=>wt(t),className:"btn btn-sm flex items-center gap-1.5",children:[e.jsx(je,{size:12,strokeWidth:1.8})," Export PDF"]}),e.jsxs("button",{type:"button",onClick:()=>void i(),disabled:o,className:"btn btn-sm flex items-center gap-1.5",children:[o?e.jsx(be,{size:12,strokeWidth:1.8,className:"animate-spin"}):e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("path",{d:"M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"})}),"Share to Slack"]})]})}function ce({n:t,l:s}){return e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"tabular font-semibold leading-none text-ink",style:{fontSize:22,letterSpacing:"-0.02em"},children:t}),e.jsx("div",{className:"text-[10.5px] font-semibold uppercase text-ink-3 mt-1",style:{letterSpacing:".06em"},children:s})]})}function Dt({report:t}){const[s,o]=h.useState(!0),a=F(t),r=ee(t.uniqueDependencyCount),i=a.some(m=>{const j=m.componentType;return j==="ValidationRule"||j==="ApexTrigger"||j==="Flow"}),l=r.level==="safe"&&i?ee(1):r,n=l.cssVar,c=l.label==="Caution"?"Medium":l.label.replace(" risk",""),d=l.level==="high",g=l.level==="medium",x=d?"linear-gradient(180deg, var(--risk-high-bg), color-mix(in srgb, var(--risk-high-bg) 35%, var(--surface)))":g?"linear-gradient(180deg, var(--risk-med-bg), color-mix(in srgb, var(--risk-med-bg) 35%, var(--surface)))":"linear-gradient(180deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 40%, var(--surface)))",y=d?"color-mix(in srgb, var(--risk-high) 22%, var(--border))":g?"color-mix(in srgb, var(--risk-med) 22%, var(--border))":"color-mix(in srgb, var(--accent) 22%, var(--border))";return e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"card card-pop overflow-hidden",style:{padding:0,background:x,borderColor:y},children:e.jsxs("div",{className:"flex items-center gap-[22px] flex-wrap",style:{padding:"20px 24px"},children:[e.jsx("div",{className:"grid place-items-center shrink-0 shadow-sm",style:{width:52,height:52,borderRadius:12,background:"white",color:n},children:e.jsx(ne,{size:24,strokeWidth:1.6})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[e.jsxs("span",{className:`chip ${d?"chip-high":g?"chip-med":"chip-low"}`,children:[c.toUpperCase()," RISK"]}),e.jsx("span",{className:"text-[12.5px] text-ink-3",children:d?"High-risk changeset. Review the affected components carefully.":g?"Deployable with caveats. Review the affected components.":i&&r.level==="safe"?"No metadata dependents, but this changeset has runtime side-effects â verify data loads and integrations.":"Looks deployable. Verify hotspots before pushing."})]}),e.jsxs("h2",{className:"m-0 mb-1",style:{fontSize:18},children:["This changeset touches"," ",e.jsx("span",{className:"tabular text-ink font-semibold",children:t.uniqueDependencyCount})," ","downstream component",t.uniqueDependencyCount===1?"":"s","."]}),e.jsxs("p",{className:"text-[13px] text-ink-3 m-0",children:[e.jsx("span",{className:"tabular text-ink font-semibold",children:a.length})," change",a.length===1?"":"s",t.hotspots.length>0&&e.jsxs(e.Fragment,{children:[" · ",e.jsxs("span",{style:{color:"var(--risk-high)",fontWeight:600},children:[t.hotspots.length," hotspot",t.hotspots.length===1?"":"s"]})]})]})]}),e.jsxs("div",{className:"flex gap-3.5 shrink-0",children:[e.jsx(ce,{n:String(a.length),l:"Changes"}),e.jsx(ce,{n:String(t.uniqueDependencyCount),l:"Affected"}),e.jsx(ce,{n:String(t.hotspots.length),l:"Hotspots"})]})]})}),e.jsxs("div",{className:"grid gap-5 grid-cols-1 lg:grid-cols-[minmax(0,460px)_minmax(0,1fr)]",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold uppercase text-ink-3 tracking-[.08em] m-0 mb-3",children:"Changes in this deploy"}),e.jsx("div",{className:"card overflow-hidden",style:{padding:0},children:a.map(m=>e.jsx(Tt,{comp:m},m.displayName))}),t.aiSummary&&e.jsxs("div",{className:"card mt-3.5",style:{padding:18,background:"var(--surface-2)"},children:[e.jsxs("div",{className:"flex items-center gap-2",style:{marginBottom:s?10:0},children:[e.jsx("span",{className:"grid place-items-center text-white",style:{width:22,height:22,borderRadius:6,background:"linear-gradient(135deg, #c9821e, #b67413)"},children:e.jsx(U,{size:12,strokeWidth:2})}),e.jsx("strong",{className:"text-[13.5px] text-ink",children:"AI verdict"}),e.jsx("span",{className:"chip",style:{padding:"2px 6px",fontSize:10},children:"Claude Sonnet"}),e.jsxs("button",{type:"button",onClick:()=>o(m=>!m),className:"btn btn-ghost btn-sm ml-auto flex items-center gap-1 text-xs",children:[s?"Collapse":"Expand",e.jsx(X,{size:11,strokeWidth:2,className:"transition-transform",style:{transform:s?"rotate(180deg)":"none"}})]})]}),s&&e.jsx("p",{className:"m-0 text-[13.5px] leading-relaxed text-ink-2 whitespace-pre-line",children:Nt(t.aiSummary)})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold uppercase text-ink-3 tracking-[.08em] m-0 mb-3",children:"Impact fan-out"}),a.length>=2&&t.allDependencies.length>0?e.jsx(zt,{report:t}):e.jsx("div",{className:"card flex items-center justify-center text-center",style:{minHeight:460,padding:16},children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-ink-3 m-0 mb-1.5",children:"No cross-component impact to chart yet."}),e.jsx("p",{className:"text-xs text-ink-4 m-0",children:"Add 2+ components to see how they fan out across dependents."})]})})]})]}),t.hotspots.length>0&&e.jsxs("div",{className:"card overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-default bg-surface-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase text-ink-4",style:{letterSpacing:"0.09em"},children:"Hotspot components"}),e.jsx("p",{className:"text-xs text-ink-3 mt-0.5",children:"Referenced by multiple items â highest regression risk"})]}),e.jsx("span",{className:"chip bg-risk-high-bg text-risk-high tabular",children:t.hotspots.length})]}),t.hotspots.map(m=>e.jsx(Rt,{hotspot:m},m.name+m.type))]}),t.allDependencies.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsxs("h3",{className:"text-[11px] font-semibold uppercase text-ink-4",style:{letterSpacing:"0.09em"},children:["All dependencies (",t.uniqueDependencyCount,")"]})}),e.jsx($t,{deps:t.allDependencies})]}),t.allDependencies.length===0&&!i&&e.jsxs("div",{className:"card p-8 text-center",children:[e.jsx("div",{className:"w-10 h-10 rounded-md bg-accent-soft text-accent grid place-items-center mx-auto mb-3",children:e.jsx(ge,{size:18,strokeWidth:1.7})}),e.jsx("p",{className:"text-[14px] font-semibold text-ink",children:"No depen
45dencies found"}),e.jsx("p",{className:"text-[12px] text-ink-3 mt-1",children:"This changeset appears safe to deploy."})]}),e.jsx(Pt,{report:t,hasSideEffect:i}),e.jsx(Ve,{}),e.jsxs("p",{className:"text-xs text-ink-4 text-right",children:["Analyzed ",new Date(t.analyzedAt).toLocaleString()," ·"," ",a.filter(m=>m.cached).length," cached / ",a.filter(m=>!m.cached).length," fresh"]})]})}function Pt({report:t,hasSideEffect:s}){const o=F(t),a=o.some(l=>l.componentType==="ValidationRule"),i=[o.some(l=>l.componentType==="ApexClass"||l.componentType==="ApexTrigger")?{text:"Run all Apex unit tests on a sandbox"}:{text:"Run dependent flows / processes in a sandbox"},{text:`Verify rollback plan for ${o.length} component${o.length===1?"":"s"}`},a?{text:"Confirm validation rules wonât block scheduled data loads or integrations"}:{text:"Confirm scheduled jobs / integrations are unaffected"},t.hotspots.length>0?{text:`Review the ${t.hotspots.length} hotspot component${t.hotspots.length===1?"":"s"} flagged above`}:{text:"Notify stakeholders in the appropriate Slack channel"},s?{text:"Smoke-test record creation / DML paths post-deploy"}:{text:"Schedule a deployment window outside business hours"}];return e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold uppercase text-ink-3 tracking-[.08em] m-0 mb-3",children:"Pre-flight checklist"}),e.jsx("div",{className:"card overflow-hidden",style:{padding:4},children:i.map((l,n)=>e.jsx(Lt,{item:l.text,done:l.done},n))})]})}function Lt({item:t,done:s}){const[o,a]=h.useState(!!s);return e.jsxs("button",{type:"button",onClick:()=>a(r=>!r),className:"w-full flex items-center gap-2.5 px-3.5 py-2.5 rounded-md text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"grid place-items-center shrink-0",style:{width:18,height:18,borderRadius:5,border:`1.5px solid ${o?"var(--accent)":"var(--border-strong)"}`,background:o?"var(--accent)":"transparent",color:"white"},children:o&&e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}),e.jsx("span",{className:"text-[13.5px]",style:{color:o?"var(--ink-3)":"var(--ink)",textDecoration:o?"line-through":"none"},children:t})]})}function Mt({embedded:t=!1}={}){const[s]=he(),o=s.get("orgId"),a=s.get("object"),r=s.get("field"),i=s.get("name"),l=s.get("type"),n=ue(),{orgs:c,loading:d,error:g,refetch:x}=Me(),y={data:c,loading:d,error:g,refetch:x},m=y.data??[],j=h.useMemo(()=>a&&r?{..._("CustomField"),objectApiName:a,fieldApiName:r}:l==="ValidationRule"&&a&&i?{..._("ValidationRule"),objectApiName:a,name:i}:l&&i?{..._(l),name:i}:_(),[]),[f,k]=h.useState(o??""),[z,C]=h.useState([j]),[v,w]=h.useState(null),[R,E]=h.useState(!1),[T,I]=h.useState(null);h.useEffect(()=>{const p=y.data;p&&(o&&p.find(A=>A.id===o)?k(o):!f&&p.length===1&&k(p[0].id))},[y.data]);const D=h.useRef(!1),u=h.useMemo(()=>m.map(p=>({value:p.id,label:p.orgName??"Unnamed org",meta:`${p.orgType??"unknown"} · ${p.sfOrgId}`})),[m]);function S(p,A){C(B=>B.map(H=>H.id===p?{...H,...A}:H))}function P(p){C(A=>A.filter(B=>B.id!==p))}function O(p="CustomField"){C(A=>[...A,_(p)])}function Y(p){return p.componentType==="CustomField"?!!p.objectApiName&&!!p.fieldApiName:p.componentType==="ValidationRule"?!!p.objectApiName&&!!p.name:!!p.name}const L=z.filter(Y),M=!!f&&L.length>=1&&!R;function oe(){return L.map(p=>p.componentType==="CustomField"?{componentType:"CustomField",objectApiName:p.objectApiName,fieldApiName:p.fieldApiName}:p.componentType==="ValidationRule"?{componentType:"ValidationRule",objectApiName:p.objectApiName,name:p.name}:{componentType:p.componentType,name:p.name})}const re=h.useCallback(async()=>{if(M){I(null),w(null),E(!0);try{const p=await Ye.runImpact(f,oe());w(p)}catch(p){I(p),p instanceof Fe&&n.error(p.friendlyMessage)}finally{E(!1)}}},[M,f,L,n]);return h.useEffect(()=>{D.current||!(a&&r||l&&i)||f&&M&&(D.current=!0,re())},[f,M]),e.jsxs("div",{className:t?"space-y-7":"space-y-7 max-w-4xl",children:[!t&&e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsx("h1",{className:"text-ink font-semibold m-0",style:{fontSize:34,letterSpacing:"-0.025em",lineHeight:1.05},title:"Deploy Impact analyzes pending changes. We don't push deployments â you do that in Salesforce.",children:"Deploy Impact"}),e.jsx(We,{}
45),v&&e.jsx("span",{className:"chip chip-med",style:{padding:"4px 10px",fontSize:11.5},children:"Open"})]}),e.jsx("p",{className:"text-ink-3 text-[14px] m-0",children:v?`${F(v).length} component${F(v).length===1?"":"s"} · analyzed ${new Date(v.analyzedAt).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}`:"Add the metadata components you're about to deploy. Get a unified risk report across all their dependencies."})]}),v&&e.jsx(Te,{report:v})]}),t&&v&&e.jsx("div",{className:"flex justify-end",children:e.jsx(Te,{report:v})}),y.error?e.jsx(ze,{error:y.error,onRetry:y.refetch}):y.loading?e.jsx(lt,{lines:4}):m.length===0?e.jsxs("div",{className:"card p-8 text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-ink-3",children:"No orgs connected yet."}),e.jsx("a",{href:"/orgs",className:"btn btn-primary text-sm inline-flex",children:"Connect an org"})]}):e.jsxs("div",{className:"card p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-semibold text-ink-2 mb-1.5",children:"Salesforce org"}),e.jsx(W,{options:u,value:f,onChange:p=>{k(p),w(null),I(null)},placeholder:"Select an orgâ¦"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsxs("label",{className:"text-[12px] font-semibold text-ink-2",children:["Components to deploy",e.jsxs("span",{className:"ml-1 text-ink-4 text-xs font-normal",children:["(",z.length," / 15)"]})]})}),e.jsx("div",{className:"space-y-2",children:z.map(p=>e.jsx(At,{entry:p,orgId:f,onUpdate:S,onRemove:P,removable:z.length>1},p.id))}),z.length<15&&e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-ink-4 mr-1",children:"Add:"}),ie.map(p=>{const A=p.icon;return e.jsxs("button",{onClick:()=>O(p.value),className:"inline-flex items-center gap-1 chip bg-surface-2 text-ink-2 hover:text-ink hover:bg-surface transition-colors border border-default",children:[e.jsx(Qe,{size:10,strokeWidth:2.4}),e.jsx(A,{size:11,strokeWidth:1.7}),p.label]},p.value)})]})]}),T!=null&&(Ke(T)?e.jsx(xe,{title:"Monthly limit reached",description:T.message,onDismiss:()=>I(null)}):e.jsx(ze,{error:T,inline:!0})),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>void re(),disabled:!M,className:"btn btn-primary justify-center",children:R?e.jsxs(e.Fragment,{children:[e.jsx(be,{size:14,strokeWidth:1.8,className:"animate-spin"}),"Analyzing ",L.length," component",L.length!==1?"s":"","â¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(se,{size:14,strokeWidth:1.8}),"Run impact report"]})}),L.length>0&&!R&&e.jsxs("p",{className:"text-xs text-ink-4",children:[L.length," component",L.length!==1?"s":""," · counts as 1 analysis"]})]})]}),v&&e.jsx(Dt,{report:v})]})}const Ft=`<?xml version="1.0" encoding="UTF-8"?> 46<Package xmlns="http://soap.sforce.com/2006/04/metadata"> 47 <types> 48 <members>Account.Industry</members> 49 <members>Lead.Status</members> 50 <name>CustomField</name> 51 </types> 52 <types> 53 <members>LeadConverter</members> 54 <name>ApexClass</name> 55 </types> 56 <version>59.0</version> 57</Package>`;function Et({embedded:t=!1}={}){Ie(t?null:{title:"Change Set Risk Report â Deplo",description:"Pre-flight risk report for any Salesforce change set â paste package.xml, see what depends on it before you deploy."});const s=ue(),{status:o}=et(),[a,r]=he(),{orgs:i,loading:l}=Me(),[n,c]=h.useState(a.get("orgId")??""),[d,g]=h.useState(""),[x,y]=h.useState(""),[m,j]=h.useState("input"),[f,k]=h.useState(null),[z,C]=h.useState(null),[v,w]=h.useState(null),[R,E]=h.useState(null),[T,I]=h.useState(a.get("mode")==="paste"?"paste":"recent"),[D,u]=h.useState(14),[S,P]=h.useState(null),[O,Y]=h.useState(!1),[L,M]=h.useState(new Set),oe=h.useRef(null),A=!((o?.tier??"free")==="free"&&!o?.watch?.active);h.useEffect(()=>{!n&&i.length>0&&c(i[0].id)},[i]);const B=async()=>{if(!A)return;const b=d.trim();if(!b){s.error("Paste a package.xml first.");return}j("previewing"),w(null),k(null);try{const $=await Z.preview(b);if(k($),j("preview"),n){const N=new URLSearchParams(a);N.set("orgId",n),r(N,{replace:!0})}}catch($){Q($),j("input")}},H=async()=>
57{if(!(!A||!f)){if(!n){s.error("Pick a target org first.");return}if(f.components.length===0){s.error("No analyzable components in this change set.");return}j("analyzing"),w(null);try{const b=await Z.analyze({orgId:n,name:x.trim()||void 0,components:f.components});C(b),j("report")}catch(b){Q(b),j("preview")}}},Q=b=>{b instanceof Fe?b.status===402||b.code==="UPGRADE_REQUIRED"?E(b.friendlyMessage):(w(b.friendlyMessage),s.error(b.friendlyMessage)):(w("Something went wrong."),s.error("Something went wrong."))},ve=()=>{k(null),C(null),w(null),j("input")},we=async b=>{if(!A)return;if(!n){s.error("Pick an org first.");return}const $=b??D;Y(!0),w(null),P(null),M(new Set);try{const N=await Z.recent(n,$);P(N);const K=new URLSearchParams(a);K.set("orgId",n),K.set("mode","recent"),K.set("days",String($)),r(K,{replace:!0})}catch(N){Q(N)}finally{Y(!1)}},Be=async()=>{if(!A||!S)return;if(!n){s.error("Pick a target org first.");return}const b=S.components.filter(N=>L.has(N.id));if(b.length===0){s.error("Select at least one component to analyze.");return}const $=b.map(N=>N.componentType==="CustomField"?{componentType:"CustomField",objectApiName:N.objectApiName,fieldApiName:N.name}:N.componentType==="ValidationRule"?{componentType:"ValidationRule",objectApiName:N.objectApiName,name:N.name}:{componentType:N.componentType,name:N.name});j("analyzing"),w(null);try{const N=await Z.analyze({orgId:n,name:x.trim()||`Recent ${S.windowDays}d (${$.length})`,components:$});C(N),j("report")}catch(N){Q(N),j("input")}},He=b=>{M($=>{const N=new Set($);return N.has(b)?N.delete(b):N.add(b),N})},_e=()=>{S&&M(new Set(S.components.map(b=>b.id)))},qe=()=>M(new Set),Ce=h.useMemo(()=>i.map(b=>({value:b.id,label:b.orgName??b.sfOrgId})),[i]),Se=i.find(b=>b.id===n)?.orgName??"â";return e.jsxs("div",{children:[!t&&e.jsxs("header",{className:"mb-5",children:[e.jsxs("h1",{className:"text-2xl font-bold text-ink flex items-center gap-2",children:[e.jsx(V,{size:20,className:"text-accent"}),"Change Set Risk Report"]}),e.jsxs("p",{className:"text-sm text-ink-3 mt-1 max-w-prose",children:["Paste a change set's ",e.jsx("code",{className:"text-[12px] bg-surface-2 px-1 rounded",children:"package.xml"}),' and see exactly what depends on it in your target org â flows, classes, layouts, reports, and more â before you click "Deploy". Works with anything sfdx, Workbench, or the standard Metadata API can export.']})]}),!A&&e.jsx(xe,{title:"Change Set Risk Report is a paid feature",description:"Pre-flight risk analysis for SF deployments requires a Pro plan or higher."}),R&&e.jsx(xe,{title:"Upgrade required",description:R,onDismiss:()=>E(null)}),e.jsx(It,{current:m,mode:T}),(m==="input"||m==="previewing"||m==="preview"||m==="analyzing")&&e.jsx(Bt,{mode:T,onModeChange:b=>{if(b===T)return;I(b),k(null),w(null),j("input");const $=new URLSearchParams(a);$.set("mode",b),r($,{replace:!0})},disabled:!A||m==="analyzing"}),v&&e.jsxs("div",{className:"card p-3 bg-risk-high-bg border-risk-high text-sm text-risk-high mb-4 flex items-start gap-2",children:[e.jsx(ne,{size:14,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:v})]}),T==="recent"&&(m==="input"||m==="previewing"||m==="analyzing")&&e.jsx(_t,{orgs:Ce,orgsLoading:l,selectedOrgId:n,onOrgChange:c,window:D,onWindowChange:b=>{u(b),we(b)},onFetch:()=>we(),loading:O,analyzing:m==="analyzing",result:S,selectedIds:L,onToggleId:He,onSelectAll:_e,onClearSelection:qe,changeSetName:x,onNameChange:y,onAnalyze:Be,disabled:!A}),T==="paste"&&(m==="input"||m==="previewing")&&e.jsx(Ot,{orgs:Ce,orgsLoading:l,selectedOrgId:n,onOrgChange:c,changeSetName:x,onNameChange:y,packageXml:d,onXmlChange:g,onUseSample:()=>g(Ft),onPreview:B,previewing:m==="previewing",disabled:!A}),T==="paste"&&(m==="preview"||m==="analyzing")&&f&&e.jsx(Wt,{preview:f,targetOrgName:Se,analyzing:m==="analyzing",onBack:ve,onAnalyze:H}),m==="report"&&z&&e.jsxs("div",{ref:oe,children:[e.jsx(Ut,{report:z,targetOrgName:Se,onReset:ve,onPrint:()=>window.print()}),e.jsx("div",{className:"mt-6",children:e.jsx(Ve,{})})]})]})}function It({current:t,mode:s}){const o=s==="recent"?[{id:["input","previewing"],label:"Pick changes"},{id:["analyzing","report"],label:"Review report"}]:[{id:["input","previewing"],label:"Paste change set"},{id:["preview","analyzing"],label:"Confirm"},{id:["report"],label:"Review report"}];return e.jsx("div",{className:"flex items-center gap-2 mb-5 text-[11.5px] font-medium",children:o.map((a,r)=>
57{const i=a.id.includes(t),l=r<o.findIndex(n=>n.id.includes(t));return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:` 58 w-5 h-5 rounded-full grid place-items-center text-[10px] font-semibold 59 ${i?"bg-accent text-white":l?"bg-accent-soft text-accent-ink":"bg-surface-2 text-ink-4"} 60 `,children:r+1}),e.jsx("span",{className:i?"text-ink":l?"text-ink-2":"text-ink-4",children:a.label}),r<o.length-1&&e.jsx(Oe,{size:12,className:"text-ink-4"})]},r)})})}function Ot(t){return e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-ink-3 mb-1.5",children:"Target org (where this will deploy)"}),t.orgsLoading?e.jsx("div",{className:"h-9 rounded-md bg-surface-2 animate-pulse"}):e.jsx(W,{options:t.orgs,value:t.selectedOrgId,onChange:t.onOrgChange,placeholder:"Pick the target org"}),e.jsx("p",{className:"text-[10.5px] text-ink-4 mt-1",children:"Dependencies are resolved against THIS org â usually production."})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-ink-3 mb-1.5",children:["Change set name ",e.jsx("span",{className:"text-ink-4 font-normal",children:"(optional)"})]}),e.jsx("input",{type:"text",value:t.changeSetName,onChange:s=>
60t.onNameChange(s.target.value),placeholder:"Q2 Lead Updates",disabled:t.disabled,className:"input w-full text-sm py-2 disabled:opacity-50",maxLength:120}),e.jsx("p",{className:"text-[10.5px] text-ink-4 mt-1",children:"Appears in the report header. Helps when sharing with the team."})]})]}),e.jsxs("label",{className:"block text-xs font-medium text-ink-3 mb-1.5",children:["package.xml",e.jsx("button",{type:"button",onClick:t.onUseSample,className:"ml-2 text-[10.5px] text-accent hover:underline",children:"Use sample"})]}),e.jsx("textarea",{value:t.packageXml,onChange:s=>t.onXmlChange(s.target.value),disabled:t.disabled,placeholder:`<?xml version="1.0" encoding="UTF-8"?> 61<Package xmlns="http://soap.sforce.com/2006/04/metadata"> 62 <types> 63 <members>Account.Revenue__c</members> 64 <name>CustomField</name> 65 </types> 66</Package>`,rows:12,spellCheck:!1,className:"input w-full text-[12.5px] font-mono py-2 leading-relaxed disabled:opacity-50"}),e.jsxs("p",{className:"text-[10.5px] text-ink-4 mt-1",children:["Export a package.xml from Workbench (Migration â Retrieve), sfdx (",e.jsx("code",{className:"bg-surface-2 px-1 rounded",children:"sf project retrieve"}),"), or any MDAPI client. Max 256KB."]}),e.jsx("div",{className:"flex justify-end gap-2 mt-4",children:e.jsxs("button",{type:"button",onClick:t.onPreview,disabled:t.disabled||t.previewing||!t.packageXml.trim(),className:"btn btn-primary text-sm disabled:opacity-40",children:[t.previewing?e.jsx(G,{size:14,className:"animate-spin"}):e.jsx(je,{size:14}),e.jsx("span",{className:"ml-1.5",children:"Parse change set"})]})})]})}function Wt({preview:t,targetOrgName:s,analyzing:o,onBack:a,onAnalyze:r}){const[i,l]=h.useState(!1),n=h.useMemo(()=>{const c=new Map;for(const d of t.components)c.has(d.componentType)||c.set(d.componentType,[]),c.get(d.componentType).push(d);return c},[t]);return e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap mb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-ink",children:"Confirm what to analyze"}),e.jsxs("p",{className:"text-xs text-ink-3 mt-0.5",children:[e.jsx("strong",{children:t.components.length})," of ",e.jsx("strong",{children:t.totalMembers})," components are analyzable. Target: ",e.jsx("strong",{children:s}),"."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:a,className:"btn btn-ghost text-sm",disabled:o,children:[e.jsx(mt,{size:14}),e.jsx("span",{className:"ml-1.5",children:"Back"})]}),e.jsxs("button",{type:"button",onClick:r,disabled:o||t.components.length===0,className:"btn btn-primary text-sm disabled:opacity-40",children:[o?e.jsx(G,{size:14,className:"animate-spin"}):e.jsx(U,{size:14}),e.jsx("span",{className:"ml-1.5",children:o?"Analyzingâ¦":`Analyze ${t.components.length} components`})]})]})]}),t.truncated&&e.jsxs("div",{className:"text-[11px] text-amber-700 bg-amber-500/10 border border-amber-500/40 rounded px-2 py-1.5 mb-3",children:[e.jsx(ne,{size:11,className:"inline mr-1"}),"This change set has more than ",t.maxComponents," supported components â only the first"," ",t.maxComponents," will be analyzed. Split into a smaller change set to get full coverage."]}),e.jsxs("div",{className:"border border-default rounded-md overflow-hidden mb-3",children:[e.jsxs("button",{type:"button",onClick:()=>l(c=>!c),className:"w-full flex items-center justify-between gap-2 px-3 py-2 bg-surface-2 text-xs font-medium text-ink-2 hover:bg-surface transition-colors",children:[e.jsxs("span",{children:[t.components.length," components to analyze across ",n.size," types"]}),i?e.jsx(Ue,{size:12}):e.jsx(X,{size:12})]}),i&&e.jsx("div",{className:"p-3 text-xs space-y-2 max-h-72 overflow-y-auto",children:[...n.entries()].map(([c,d])=>e.jsxs("div",{children:[e.jsxs("div",{className:"text-[10.5px] font-semibold uppercase tracking-wider text-ink-3 mb-1",children:[c," (",d.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:d.map((g,x)=>e.jsx("span",{className:"font-mono text-[10.5px] text-ink-2 bg-surface-2 border border-default rounded px-1.5 py-0.5",children:g.componentType==="CustomField"?`${g.objectApiName}.${g.fieldApiName}`:g.componentType==="ValidationRule"?`${g.objectApiName}.${g.name}`:g.name},x))})]},c))})]}),t.unsupportedTypes.length>0&&e.jsxs("div",{className:"text-[11px] text-ink-3 bg-surface-2 border border-default rounded px-3 py-2 mb-2",children:[e.jsx("strong",{children:"Skipped"})," â ",t.unsupportedTypes.reduce((c,d)=>c+d.memberCount,0)," components in ",t.unsupportedTypes.length," type",t.unsupportedTypes.length===1?"":"s"," that Deplo doesn't analyze yet:",e.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:t.unsupportedTypes.map((c,d)=>e.jsxs("span",{className:"font-mono text-[10.5px] bg-surface px-1.5 py-0.5 rounded border border-default",children:[c.typeName," (",c.memberCount,")"]},d))})]}),t.malformedMembers.length>0&&e.jsxs("div",{className:"text-[11px] text-risk-high bg-risk-high-bg border border-risk-high rounded px-3 py-2",children:[e.jsxs("strong",{children:["Couldn't parse ",t.malformedMembers.length," member",t.malformedMembers.length===1?"":"s",":"]}),e.jsxs("ul",{className:"mt-1 space-y-0.5 list-disc list-inside",children:[t.malformedMembers.slice(0,5).map((c,d)=>e.jsxs("li",{children:[e.jsxs("code",{className:"font-mono text-[10.5px] bg-surface px-1 rounded",children:[c.typeName,"/",c.member]})," â ",c.reason]},d)),t.malformedMembers.length>5&&e.jsxs("li",{className:"text-ink-3 italic",children:["â¦and ",t.malformedMembers.length-5," more"]})]})]})]})}function Ut({report:t,targetOrgName:s,onReset:o,onPrint:a}){const r=ee(t.uniqueDependencyCount),i=te(t.uniqueDependencyCount),l=h.useMemo(()=>{const n={};for(const c of t.allDependencies){const d=c.type??"Other";(n[d]??(n[d]=[])).push(c)}return n},[t]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"card p-4 mb-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded-full ${r.chipClass}`,children:[i," risk"]}),e.jsxs("span",{className:"text-[11px] text-ink-3",children:["Target: ",e.jsx("strong",{className:"text-ink-2",children:s})]})]}),e.jsx("h2",{className:"text-lg font-semibold text-ink",children:t.name??`Change set (${t.components.length} components)`}),e.jsxs("p",{className:"text-xs text-ink-3 mt-0.5",children:["Analyzed ",new Date(t.analyzedAt).toLocaleStr
66ing()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:a,className:"btn btn-ghost text-sm",children:[e.jsx(ht,{size:14}),e.jsx("span",{className:"ml-1.5",children:"Print / PDF"})]}),e.jsxs("button",{type:"button",onClick:o,className:"btn btn-ghost text-sm",children:[e.jsx(gt,{size:14}),e.jsx("span",{className:"ml-1.5",children:"New change set"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mt-4 pt-4 border-t border-default",children:[e.jsx(J,{label:"Components",value:t.components.length}),e.jsx(J,{label:"Unique dependencies",value:t.uniqueDependencyCount,highlight:r.chipClass}),e.jsx(J,{label:"Hotspots",value:t.hotspots.length,highlight:t.hotspots.length>0?"text-risk-high":void 0}),e.jsx(J,{label:"Types touched",value:Object.keys(l).length})]})]}),t.aiSummary&&e.jsxs("div",{className:"card p-4 mb-3 border-l-2 border-l-accent",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(U,{size:13,className:"text-accent"}),e.jsx("span",{className:"text-xs font-semibold text-ink-2 uppercase tracking-wider",children:"AI risk assessment"})]}),e.jsx("div",{className:"text-sm text-ink leading-relaxed whitespace-pre-wrap",children:t.aiSummary})]}),t.hotspots.length>0&&e.jsxs("div",{className:"card p-4 mb-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-ink mb-1",children:["Hotspot dependencies",e.jsx("span",{className:"text-[11px] text-ink-3 font-normal ml-2",children:"Referenced by 2+ items in this change set"})]}),e.jsx("p",{className:"text-[11px] text-ink-3 mb-3",children:"These are the regression-risk multipliers â touching the wrong one ripples through multiple change-set items at once."}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"text-[10.5px] uppercase tracking-wider text-ink-3 border-b border-default",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left py-1.5 pr-2 font-semibold",children:"Component"}),e.jsx("th",{className:"text-left py-1.5 pr-2 font-semibold w-32",children:"Type"}),e.jsx("th",{className:"text-right py-1.5 pl-2 font-semibold w-16",children:"Items"}),e.jsx("th",{className:"text-left py-1.5 pl-2 font-semibold",children:"Referenced by"})]})}),e.jsx("tbody",{children:t.hotspots.map((n,c)=>e.jsxs("tr",{className:"border-b border-default last:border-b-0",children:[e.jsx("td",{className:"py-1.5 pr-2",children:n.sfUrl?e.jsxs("a",{href:n.sfUrl,target:"_blank",rel:"noreferrer",className:"text-accent hover:underline inline-flex items-center gap-1",children:[n.name,e.jsx(ae,{size:10})]}):e.jsx("span",{className:"text-ink",children:n.name})}),e.jsx("td",{className:"py-1.5 pr-2 text-[11px] text-ink-3 font-mono",children:n.type}),e.jsx("td",{className:"py-1.5 pl-2 text-right",children:e.jsx("span",{className:"text-sm font-semibold text-risk-high",children:n.fieldCount})}),e.jsx("td",{className:"py-1.5 pl-2 text-[11px] text-ink-3 truncate max-w-md",children:n.fields.join(", ")})]},c))})]})})]}),e.jsxs("div",{className:"card p-4 mb-3",children:[e.jsx("h3",{className:"text-sm font-semibold text-ink mb-3",children:"Per-component impact"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"text-[10.5px] uppercase tracking-wider text-ink-3 border-b border-default",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left py-1.5 pr-2 font-semibold",children:"Component"}),e.jsx("th",{className:"text-left py-1.5 pr-2 font-semibold w-28",children:"Type"}),e.jsx("th",{className:"text-right py-1.5 pl-2 font-semibold w-24",children:"Dependencies"}),e.jsx("th",{className:"text-left py-1.5 pl-2 font-semibold w-20",children:"Risk"})]})}),e.jsx("tbody",{children:t.components.map((n,c)=>{const d=ee(n.dependencyCount),g=te(n.dependencyCount);return e.jsxs("tr",{className:"border-b border-default last:border-b-0",children:[e.jsx("td",{className:"py-1.5 pr-2 font-mono text-[12px] text-ink",children:n.displayName}),e.jsx("td",{className:"py-1.5 pr-2 text-[11px] text-ink-3",children:n.componentType}),e.jsx("td",{className:"py-1.5 pl-2 text-right font-semibold text-ink",children:n.dependencyCount}),e.jsx("td",{className:"py-1.5 pl-2",children:e.jsx("span",{className:`text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded ${d.chipClass}`,children:g})})]},c)})})]})})]}),Object.keys(l).length>0&&e.jsxs("div",{className:"card p-4 mb-3",children:[e.jsxs("h3",{className:"text-sm font-semibold text-ink mb-3",children:["What this change set touches",e.jsxs("span",{className:"text-[11px] text-ink-3 font-normal ml-2",children:[t.uniqueDependencyCount," unique dependencies across ",Object.keys(l).length," types"]})]}),e.jsx("div",{className:"space-y-3",children:Object.entries(l).sort((n,c)=>c[1].length-n[1].length).map(([n,c])=>e.jsx(Vt,{type:n,deps:c},n))})]}),(t.unsupportedTypes.length>0||t.malformedMembers.length>0)&&e.jsxs("div",{className:"card p-4 text-[11.5px] text-ink-3 leading-relaxed",children:[e.jsx("div",{className:"font-semibold text-ink-2 mb-1",children:"Notes"}),t.unsupportedTypes.length>0&&e.jsxs("div",{children:[e.jsxs("strong",{children:[t.unsupportedTypes.reduce((n,c)=>n+c.memberCount,0)," components skipped"]})," ","(",t.unsupportedTypes.map(n=>`${n.typeName}: ${n.memberCount}`).join(", "),") â Deplo doesn't analyze these types yet, so the report covers the supported subset."]}),t.malformedMembers.length>0&&e.jsxs("div",{className:"mt-1",children:[e.jsxs("strong",{children:[t.malformedMembers.length," member",t.malformedMembers.length===1?"":"s"," skipped"]})," ","due to formatting issues (most commonly wildcard ",e.jsx("code",{children:"*"})," entries which Deplo doesn't expand yet)."]})]})]})}function Vt({type:t,deps:s}){const[o,a]=h.useState(s.length<=10);return e.jsxs("div",{className:"border border-default rounded-md overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>a(r=>!r),className:"w-full flex items-center justify-between gap-2 px-3 py-2 bg-surface-2 text-xs font-medium text-ink-2 hover:bg-surface transition-colors",children:[e.jsxs("span",{children:[t," ",e.jsxs("span",{className:"text-ink-3 font-normal",children:["(",s.length,")"]})]}),o?e.jsx(Ue,{size:12}):e.jsx(X,{size:12})]}),o&&e.jsx("ul",{className:"p-2 text-xs grid grid-cols-1 md:grid-cols-2 gap-1",children:s.map(r=>e.jsx("li",{className:"px-2 py-1 hover:bg-surface-2 rounded transition-colors",children:r.sfUrl?e.jsxs("a",{href:r.sfUrl,target:"_blank",rel:"noreferrer",className:"text-accent hover:underline inline-flex items-center gap-1",children:[r.name,e.jsx(ae,{size:10})]}):e.jsx("span",{className:"text-ink",children:r.name})},r.id))})]})}function J({label:t,value:s,highlight:o}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-ink-4",children:t}),e.jsx("div",{className:`text-2xl font-bold mt-0.5 ${o??"text-ink"}`,children:s})]})}function Bt({mode:t,onModeChange:s,disabled:o}){return e.jsxs("div",{className:"flex items-center gap-1 mb-3",role:"tablist",children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":t==="recent",onClick:()=>s("recent"),disabled:o,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors disabled:opacity-50 ${t==="recent"?"text-ink border-accent":"text-ink-3 border-transparent hover:text-ink-2"}`,children:[e.jsx(U,{size:14}),e.jsx("span",{children:"Pick from sandbox"}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-ink-4 ml-1",children:"recommended"})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":t==="paste",onClick:()=>s("paste"),disabled:o,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors disabled:opacity-50 ${t==="paste"?"text-ink border-accent":"text-ink-3 border-transparent hover:text-ink-2"}`,children:[e.jsx(je,{size:14}),e.jsx("span",{children:"Paste package.xml"})]})]})}const Ht=[7,14,30,60,90],De={ApexClass:e.jsx(fe,{size:11}),ApexTrigger:e.jsx(se,{size:11}),LightningComponentBundle:e.jsx(V,{size:11}),ValidationRule:e.jsx(pt,{size:11}),CustomField:e.jsx(tt,{size:11}),Flow:e.jsx(U,{size:11})},de={ApexClass:"Apex Class",ApexTrigger:"Apex Trigger",LightningComponentBundle:"LWC",ValidationRule:"Validation Rule",CustomField:"Custom Field",Flow:"Flow"};function _t({orgs:t,orgsLoading:s,selectedOrgId:o,onOrgChange:a,window:r,onWindowChange:i,onFetch:l,loading:n,analyzing:c,result:d,selectedIds:g,onToggleId:x,onSelectAll:y,onClearSelection:m,changeSetName:j,onNameChange:f,onAnalyze:k,disabled:z}){const[C,v]=h.useState(new Set),[w,R]=h.useState(""),[E,T]=h.useState(""),I=h.useMemo(()=>
66{if(!d)return[];const u=E.trim().toLowerCase();return d.components.filter(S=>!(C.size>0&&!C.has(S.componentType)||w&&S.lastModifiedBy!==w||u&&!S.label.toLowerCase().includes(u)&&!S.name.toLowerCase().includes(u)))},[d,C,w,E]),D=g.size;return e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-3 items-end mb-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-ink-3 mb-1.5",children:"Target org (sandbox or prod)"}),s?e.jsx("div",{className:"h-9 rounded-md bg-surface-2 animate-pulse"}):e.jsx(W,{options:t,value:o,onChange:a,placeholder:"Pick an org"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-ink-3 mb-1.5",children:"Modified in the last"}),e.jsx("div",{className:"flex gap-1",children:Ht.map(u=>e.jsxs("button",{type:"button",onClick:()=>i(u),disabled:z||n,className:`flex-1 text-xs py-2 rounded-md border transition-colors ${r===u?"bg-accent-soft text-accent-ink border-accent/40 font-semibold":"bg-surface-2 text-ink-3 border-default hover:bg-surface"}`,children:[u,"d"]},u))})]}),e.jsxs("button",{type:"button",onClick:l,disabled:z||n||!o,className:"btn btn-primary text-sm disabled:opacity-40 whitespace-nowrap",children:[n?e.jsx(G,{size:14,className:"animate-spin"}):e.jsx(Ae,{size:14}),e.jsx("span",{className:"ml-1.5",children:d?"Refresh list":"Fetch changes"})]})]}),e.jsx("p",{className:"text-[10.5px] text-ink-4 mb-3",children:"Pulls every Apex / LWC / Flow / Validation Rule / Custom Field modified in the chosen window. No Workbench, sfdx, or package.xml needed."}),n&&e.jsxs("div",{className:"card p-6 text-center text-sm text-ink-3",children:[e.jsx(G,{size:16,className:"inline animate-spin mr-2"}),"Walking Tooling API for recently-modified componentsâ¦"]}),!n&&!d&&e.jsx("div",{className:"card p-6 text-center text-[12px] text-ink-3 italic",children:`Pick an org + window above, then "Fetch changes" to see what's been modified.`}),!n&&d&&d.components.length===0&&e.jsxs("div",{className:"card p-6 text-center text-sm text-ink-3",children:["No components modified in the last ",d.windowDays," days. Try a wider window."]}),!n&&d&&d.components.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-3 text-[11px]",children:[e.jsxs("span",{className:"text-ink-3",children:[d.components.length," modified components:"]}),Object.entries(d.countsByType).filter(([,u])=>u>0).map(([u,S])=>{const P=C.has(u);return e.jsxs("button",{type:"button",onClick:()=>{const O=new Set(C);P?O.delete(u):O.add(u),v(O)},className:`flex items-center gap-1 px-2 py-1 rounded-full border transition-colors text-[10.5px] ${P?"bg-accent-soft text-accent-ink border-accent/40 font-semibold":"bg-surface-2 text-ink-2 border-default hover:bg-surface"}`,children:[De[u],e.jsx("span",{children:de[u]}),e.jsx("span",{className:"text-ink-4",children:S})]},u)}),C.size>0&&e.jsx("button",{type:"button",onClick:()=>v(new Set),className:"text-[10px] text-ink-4 hover:text-ink-2 italic ml-1",children:"clear"})]}),d.truncatedTypes.length>0&&e.jsxs("div",{className:"text-[11px] text-amber-700 bg-amber-500/10 border border-amber-500/40 rounded px-2 py-1.5 mb-3 inline-block",children:[e.jsx(ne,{size:11,className:"inline mr-1"}),d.truncatedTypes.map(u=>de[u]).join(", ")," ","capped at 200 â narrow your window for full coverage."]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-1 min-w-[200px]",children:[e.jsx(Ae,{size:12,className:"text-ink-4"}),e.jsx("input",{type:"text",value:E,onChange:u=>T(u.target.value),placeholder:"Filter by nameâ¦",className:"input flex-1 text-xs py-1.5"})]}),d.modifiers.length>1&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ct,{size:11,className:"text-ink-4"}),e.jsxs("select",{value:w,onChange:u=>R(u.target.value),className:"input text-xs py-1.5 pr-7",children:[e.jsx("option",{value:"",children:"All modifiers"}),d.modifiers.map(u=>e.jsx("option",{value:u,children:u},u))]})]}),e.jsx("button",{type:"button",onClick:y,className:"text-[11px] text-accent hover:underline px-1",children:"Select all visible"}),D>0&&e.jsxs("button",{type:"button",onClick:m,className:"text-[11px] text-ink-4 hover:text-ink-2 px-1",children:["Clear (",D,")"]})]}),e.jsxs("div",{className:"overflow-x-auto mb-4 max-h-[480px] overflow-y-auto border border-default rounded-md",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-surface-2 border-b border-default sticky top-0 z-10",children:e.jsxs("tr",{className:"text-[10.5px] uppercase tracking-wider text-ink-3",children:[e.jsx("th",{className:"text-left py-2 px-2 font-semibold w-8"}),e.jsx("th",{className:"text-left py-2 px-2 font-semibold",children:"Component"}),e.jsx("th",{className:"text-left py-2 px-2 font-semibold w-32",children:"Type"}),e.jsx("th",{className:"text-left py-2 px-2 font-semibold w-40",children:"Modified by"}),e.jsx("th",{className:"text-right py-2 px-2 font-semibold w-28",children:"Modified"})]})}),e.jsx("tbody",{children:I.map(u=>{const S=g.has(u.id);return e.jsxs("tr",{onClick:()=>x(u.id),className:`border-b border-default last:border-b-0 cursor-pointer transition-colors ${S?"bg-accent-soft/40 hover:bg-accent-soft/60":"hover:bg-surface-2"}`,children:[e.jsx("td",{className:"py-1.5 px-2",children:e.jsx("input",{type:"checkbox",checked:S,onChange:()=>x(u.id),onClick:P=>P.stopPropagation(),className:"rounded"})}),e.jsx("td",{className:"py-1.5 px-2",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-sm text-ink truncate max-w-md",children:u.label}),u.sfUrl&&e.jsx("a",{href:u.sfUrl,target:"_blank",rel:"noreferrer",onClick:P=>P.stopPropagation(),className:"text-ink-4 hover:text-accent",title:"Open in Salesforce",children:e.jsx(ae,{size:10})})]})}),e.jsx("td",{className:"py-1.5 px-2",children:e.jsxs("span",{className:"text-[11px] text-ink-2 inline-flex items-center gap-1",children:[De[u.componentType]," ",de[u.componentType]]})}),e.jsx("td",{className:"py-1.5 px-2 text-[11px] text-ink-3 truncate max-w-[14rem]",children:u.lastModifiedBy}),e.jsxs("td",{className:"py-1.5 px-2 text-right text-[11px] text-ink-3",children:[e.jsx(dt,{size:9,className:"inline mr-1"}),qt(u.lastModifiedDate)]})]},u.id)})})]}),I.length===0&&e.jsx("div",{className:"text-center py-6 text-[11px] text-ink-4",children:"No components match the current filters."})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3 justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-[240px]",children:[e.jsxs("label",{className:"block text-xs font-medium text-ink-3 mb-1.5",children:["Change set name ",e.jsx("span",{className:"text-ink-4 font-normal",children:"(optional)"})]}),e.jsx("input",{type:"text",value:j,onChange:u=>f(u.target.value),placeholder:`Recent ${r}d (${D} components)`,disabled:z,className:"input w-full text-sm py-2 disabled:opacity-50",maxLength:120})]}),e.jsxs("button",{type:"button",onClick:k,disabled:z||c||D===0,className:"btn btn-primary text-sm disabled:opacity-40 whitespace-nowrap",children:[c?e.jsx(G,{size:14,className:"animate-spin"}):e.jsx(U,{size:14}),e.jsx("span",{className:"ml-1.5",children:c?"Analyzingâ¦":`Analyze ${D}
66 selected`})]})]})]})]})}function qt(t){const s=Math.floor((Date.now()-new Date(t).getTime())/864e5);return s<1?"today":s===1?"yesterday":s<30?`${s}d ago`:s<365?`${Math.round(s/30)}mo ago`:`${(s/365).toFixed(1)}y ago`}function Ns(){Ie({title:"Change Risk",description:"Pre-flight risk report for any Salesforce change â pick components or a change set and see what depends on them before you deploy.",noindex:!0});const[t,s]=he(),o=t.get("source")==="changeset"?"changeset":"components",[a,r]=h.useState(o);function i(l){if(l===a)return;r(l);const n=new URLSearchParams(t);l==="changeset"?n.set("source","changeset"):n.delete("source"),s(n,{replace:!0})}return e.jsxs("div",{className:"space-y-6 max-w-4xl",children:[e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsx("h1",{className:"text-ink font-semibold m-0",style:{fontSize:34,letterSpacing:"-0.025em",lineHeight:1.05},children:"Change Risk"}),e.jsx(We,{})]}),e.jsx("p",{className:"text-ink-3 text-[14px] m-0",children:"See everything that depends on a change before you ship it. Pick the components by hand, or pull in a whole change set."})]})}),e.jsxs("div",{role:"tablist","aria-label":"Change source",className:"inline-flex rounded-lg border border-default bg-surface-1 p-0.5",children:[e.jsx(Pe,{active:a==="components",onClick:()=>i("components"),icon:e.jsx(st,{size:15,strokeWidth:1.75}),label:"Pick components"}),e.jsx(Pe,{active:a==="changeset",onClick:()=>i("changeset"),icon:e.jsx(V,{size:15,strokeWidth:1.75}),label:"From a change set"})]}),a==="components"?e.jsx(Mt,{embedded:!0}):e.jsx(Et,{embedded:!0})]})}function Pe({active:t,onClick:s,icon:o,label:a}){return e.jsxs("button",{type:"button",role:"tab","aria-selected":t,onClick:s,className:` 67 flex items-center gap-2 px-3.5 py-1.5 rounded-md text-[13px] font-medium transition-colors 68 ${t?"bg-surface text-ink shadow-sm":"text-ink-3 hover:text-ink"} 69 `,children:[o,a]})}export{Ns 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.