@preventive/triage 1.0.0-alpha.7 → 1.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/save-error-reason.ts +20 -7
- package/out/client-sync.js +14 -14
- package/out/graph.js +5 -4
- package/out/prism.js +2 -2
- package/out/view.css +1 -1
- package/out/view.js +56 -53
- package/package.json +1 -1
- package/server/sse-server.ts +57 -30
- package/server/sync-handlers.ts +8 -0
package/out/graph.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
var mt=globalThis[Symbol.for("@rray/frontend")];if(!mt)throw new Error("@rray/frontend global not installed; view.js must run before lazy bundles import this wrapper");var{LitElement:xt,html:E,nothing:Ot,unsafeCSS:Ve,render:Me,StateElement:ao,classMap:Se,repeat:vt,styleMap:$e}=mt;var yt=`*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}:host{display:grid;grid-template-columns:1fr 300px;grid-template-rows:auto 1fr;grid-template-areas:"topbar right" "stage right";min-height:0;border:1px solid var(--border);border-radius:8px;overflow:hidden;background:var(--graph-canvas-bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,sans-serif;font-size:12px}.graph2-layout{display:contents}.graph2-topbar{grid-area:topbar;display:flex;flex-direction:column;gap:.5rem;padding:.6rem .75rem;font-size:.825rem;background:var(--surface);backdrop-filter:var(--glass-blur);border-bottom:1px solid var(--graph-divider)}.graph2-topbar-row{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;padding:0}.graph2-topbar .g2-spacer{flex:1}.graph2-topbar triage-selector{margin-left:auto}.g2-icon-btn{width:28px;height:28px;border-radius:5px;background:var(--graph-hover-bg);border:1px solid var(--border);color:var(--muted);display:grid;place-items:center;font-family:inherit;&:hover{color:var(--accent);border-color:var(--accent)}& svg{display:block}}.g2-path-filter-wrap{position:relative;flex:0 0 14rem;padding-right:22px}.g2-path-filter-wrap .g2-path-filter-clear{position:absolute;right:4px;top:50%;transform:translateY(-50%);display:grid;place-items:center;width:18px;height:18px;background:transparent;border:0;border-radius:50%;color:var(--muted);font:400 10px/1 inherit;font-family:inherit;&:hover{color:var(--text);background:var(--surface-active)}}.g2-path-filter:placeholder-shown~.g2-path-filter-clear{display:none}.g2-topbar-toggle{display:inline-flex;align-items:center;height:30px;box-sizing:border-box;gap:8px;padding:5px 10px;background:var(--graph-hover-bg);border:1px solid var(--border);border-radius:6px;color:var(--muted);font:500 11px/1 inherit;font-family:inherit;white-space:nowrap;&:hover{color:var(--text);border-color:var(--accent)}&.on{color:var(--text)}&.on .g2-switch{background:color-mix(in srgb,var(--accent) 22%,transparent)}&.on .g2-switch:after{transform:translate(12px);background:var(--accent)}}.g2-trash-btn.on{background:color-mix(in srgb,var(--accent) 16%,transparent);border-color:var(--accent);color:var(--accent)}.graph2-right{grid-area:right;border-left:1px solid var(--graph-divider);background:var(--surface);backdrop-filter:var(--glass-blur);display:flex;flex-direction:column;overflow:hidden;padding:14px}.g2-panel-title{font-family:inherit;font-weight:600;font-size:11px;line-height:1;letter-spacing:.14em;text-transform:uppercase;color:var(--muted);opacity:.85;margin:14px 0 8px;display:flex;align-items:baseline;gap:6px;&:first-child{margin-top:0}}.g2-count{color:var(--muted);opacity:.6;font-weight:400;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;text-transform:none;letter-spacing:0;font-size:10px}.g2-panel-title-row{justify-content:space-between;gap:8px}#g2-top-pkgs-block{margin-top:14px;flex:1 1 0;min-height:0;display:flex;flex-direction:column}.g2-mini-tabs{display:flex;gap:1px;background:var(--graph-divider);border-radius:4px;overflow:hidden}.g2-mini-tab{background:transparent;border:0;color:var(--muted);font-family:inherit;font-weight:500;font-size:11px;line-height:1.4;text-transform:none;letter-spacing:0;padding:2px 7px;&:hover{color:var(--text);background:var(--graph-hover-bg)}&.on{background:var(--surface-active);color:var(--accent)}}.g2-switch{width:26px;height:14px;background:var(--border);border-radius:8px;position:relative;transition:background .15s;flex-shrink:0;&:after{content:"";position:absolute;top:2px;left:2px;width:10px;height:10px;border-radius:50%;background:var(--muted);transition:transform .15s,background .15s}}.graph2-stage{grid-area:stage;position:relative;background:var(--graph-canvas-bg);overflow:hidden;cursor:grab;&:active{cursor:grabbing}& canvas{position:absolute;inset:0;width:100%;height:100%;display:block}}.g2-stage-overlay{position:absolute;top:12px;left:12px;z-index:3;display:flex;flex-direction:column;gap:4px;pointer-events:none;max-width:calc(100% - 60px)}.g2-stage-overlay>*{pointer-events:auto}.g2-stage-stats{position:absolute;bottom:10px;left:12px;z-index:2;display:flex;flex-wrap:wrap;gap:2px 14px;font:500 10px/1.4 ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;color:var(--muted);opacity:.7;text-transform:uppercase;letter-spacing:.06em;pointer-events:none;max-width:calc(100% - 80px);& b{font-weight:600;color:var(--text);opacity:1}}.g2-stage-overlay-tr{position:absolute;top:12px;right:12px;z-index:3;pointer-events:auto}.g2-focus-pkg-btn{width:28px;height:28px;display:grid;place-items:center;background:var(--surface);backdrop-filter:var(--glass-blur);border:1px solid var(--border);border-radius:6px;color:var(--accent);box-shadow:var(--shadow-glass);&:hover{border-color:var(--accent);background:var(--surface-active)}& svg{display:block}}.g2-back-btn{display:inline-flex;align-items:center;gap:4px;padding:6px 11px;background:var(--surface);backdrop-filter:var(--glass-blur);border:1px solid var(--border);border-radius:6px;color:var(--accent);font:500 11px/1 inherit;font-family:inherit;box-shadow:var(--shadow-glass);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;align-self:flex-start;&:hover{border-color:var(--accent);background:var(--surface-active)}}.g2-zoom-ctrl{position:absolute;right:12px;bottom:12px;display:flex;flex-direction:column;background:var(--surface);backdrop-filter:var(--glass-blur);border:1px solid var(--border);border-radius:6px;overflow:hidden;z-index:3;box-shadow:var(--shadow-glass);& button{width:28px;height:28px;background:transparent;border:0;color:var(--muted);border-bottom:1px solid var(--graph-divider);display:grid;place-items:center;font-family:inherit;font-size:13px;&:last-child{border-bottom:0}&:hover{color:var(--accent);background:var(--surface-active)}}}.g2-zoom-pct{font:500 9px/1 ui-monospace,monospace;color:var(--muted);padding:5px 0;text-align:center;border-bottom:1px solid var(--graph-divider)}.g2-zoom-ctrl .g2-zoom-fit-btn{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;font-weight:600;font-size:9px;line-height:1;letter-spacing:-.02em;text-transform:lowercase}.g2-tooltip{position:absolute;background:var(--surface);backdrop-filter:var(--glass-blur);border:1px solid var(--border);border-radius:7px;padding:9px 11px;pointer-events:none;min-width:170px;max-width:260px;opacity:0;transition:opacity .12s;z-index:10;box-shadow:var(--shadow-glass);&.show{opacity:1}}.g2-tt-path{font:500 11px/1.3 ui-monospace,monospace;color:var(--text);word-break:break-all;margin-bottom:4px}.g2-tt-head{display:flex;align-items:center;gap:6px;margin-bottom:6px;flex-wrap:wrap}.g2-tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.g2-tt-pkg{font-size:10px;color:var(--muted);word-break:break-all}.g2-tt-badge{display:inline-block;font-size:8px;padding:2px 4px;background:color-mix(in srgb,var(--accent) 22%,transparent);color:var(--accent);border-radius:3px;text-transform:uppercase;letter-spacing:.08em;font-weight:600}.g2-tooltip .tree-count-chips{margin-top:6px}:host-context(body.theme-light) .graph2-right .tree-count-chip.medium,:host-context(body.theme-light) .g2-tooltip .tree-count-chip.medium{color:#fff}.g2-selection-card{background:var(--graph-hover-bg);border:1px solid var(--border);border-radius:8px;overflow:hidden}.g2-sel-head{padding:11px 13px;border-bottom:1px solid var(--graph-divider);display:flex;align-items:center;gap:8px}.g2-sel-file-head{padding:11px 13px;border-bottom:1px solid var(--graph-divider);display:flex;flex-direction:column;gap:6px}.g2-sel-path{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;font-weight:600;font-size:12px;line-height:1.3;color:var(--text);word-break:break-all}.g2-sel-pkg-row{display:flex;align-items:center;gap:6px;min-width:0}.g2-sel-pkg{font-size:11px;color:var(--muted);word-break:break-all;min-width:0}.g2-sel-fullpath{padding:7px 13px;border-bottom:1px solid var(--graph-divider);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;font-size:10px;line-height:1.3;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.g2-sel-size{padding:5px 13px 7px;border-bottom:1px solid var(--graph-divider);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;font-size:10px;line-height:1.3;color:var(--muted);font-variant-numeric:tabular-nums}.g2-sel-dot{width:11px;height:11px;border-radius:50%;box-shadow:0 0 0 3px color-mix(in srgb,var(--dot) 22%,transparent);flex-shrink:0}.g2-sel-id{font:600 12px/1 ui-monospace,monospace;color:var(--text);word-break:break-all;flex:1;min-width:0}.g2-sel-grp{font:500 9px/1 ui-monospace,monospace;color:var(--muted);text-transform:uppercase;letter-spacing:.08em;flex-shrink:0}.g2-sel-body{padding:11px 13px}.g2-sel-row{display:flex;justify-content:space-between;gap:12px;font-size:11px;padding:5px 0;border-bottom:1px solid var(--graph-divider);&:last-child{border-bottom:0}.k{color:var(--muted);flex-shrink:0}.v{color:var(--text);font-family:ui-monospace,monospace;word-break:break-all;text-align:right;min-width:0}}.g2-sel-section{padding:9px 13px;border-top:1px solid var(--graph-divider)}.g2-sel-section-label{font-family:inherit;font-weight:600;font-size:11px;line-height:1;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);opacity:.85;margin-bottom:5px}.g2-sel-section-empty{color:var(--muted);opacity:.55;font-size:11px;font-style:italic}.g2-sel-jumps{padding:11px 13px;display:flex;gap:5px;flex-wrap:wrap;border-top:1px solid var(--graph-divider)}.g2-sel-jump{background:var(--surface-active);border:1px solid var(--border);color:var(--accent);border-radius:4px;padding:2px 8px;font-family:inherit;font-weight:500;font-size:11px;line-height:1.3;&:hover{border-color:var(--accent)}}.g2-sel-file-list{list-style:none;margin:0;padding:0;max-height:110px;overflow:hidden auto;-webkit-app-region:no-drag;app-region:no-drag;&::-webkit-scrollbar{width:4px}&::-webkit-scrollbar-thumb{background:var(--border);border-radius:2px}& li{padding:0}}.g2-sel-file-link{display:flex;align-items:center;gap:6px;width:100%;background:transparent;border:0;border-radius:3px;padding:3px 6px;font:400 11px/1.4 ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;color:var(--accent);text-align:left;&:hover{background:var(--graph-hover-bg)}.g2-sel-file-dot{width:7px;height:7px;border-radius:50%;flex-shrink:0}.g2-sel-file-path{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}}.g2-empty-state{background:var(--graph-hover-bg);border:1px dashed var(--border);border-radius:8px;padding:18px 14px;text-align:center;color:var(--muted);font-size:11px;line-height:1.5;& strong{color:var(--text);display:block;margin-bottom:4px;font-weight:500}}.g2-dist-bar{width:100%;height:5px;border-radius:3px;overflow:hidden;display:flex;background:var(--surface-active);margin-bottom:8px;>span{display:block;height:100%}}.g2-dist-list{display:flex;flex-direction:column;gap:2px;flex:1 1 0;min-height:0;overflow-y:auto;overscroll-behavior:none;-webkit-app-region:no-drag;app-region:no-drag;scrollbar-gutter:stable;scrollbar-width:thin;scrollbar-color:var(--border) transparent;&::-webkit-scrollbar{width:5px}&::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}}.g2-dist-empty{color:var(--muted);opacity:.55;font-size:10px;font-style:italic;padding:6px 0;text-align:center}.g2-dist-item{display:grid;grid-template-columns:8px 1fr auto auto;gap:8px;align-items:center;font-size:10px;padding:4px 6px;margin:0 -6px;background:transparent;border:0;border-radius:4px;font-family:inherit;text-align:left;width:calc(100% + 12px);&:hover{background:var(--graph-hover-bg)}&.on{background:var(--surface-active);.g2-dist-name{color:var(--accent)}}.g2-dist-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.g2-dist-name{color:var(--muted);font-family:ui-monospace,monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.g2-dist-count{font-family:ui-monospace,monospace;color:var(--text)}.g2-dist-pct{font-family:ui-monospace,monospace;color:var(--muted);width:36px;text-align:right;opacity:.85}}@media print{:host{display:none!important}}
|
|
2
|
-
`;var
|
|
3
|
-
`;var wt=`.toolbar{display:flex;flex-direction:column;gap:.5rem;margin-bottom:1rem;padding:.6rem .75rem;background:var(--surface);backdrop-filter:var(--glass-blur);border:1px solid var(--border);border-radius:6px;box-shadow:var(--shadow-glass);font-size:.825rem;& label{color:var(--muted);margin-right:.15rem}& select{height:30px;box-sizing:border-box;background:var(--bg);color:var(--text);border:1px solid var(--border);border-radius:4px;padding:.25rem .4rem;font-size:.8rem;&:focus{border-color:var(--accent);outline:none}}& select.sort-select{padding:.3rem 1.7rem .3rem .55rem;min-width:8.5rem;font-weight:500;appearance:none;-webkit-appearance:none;background:transparent}:is(analyzer-select,repo-filter,findings-sort){position:relative;display:inline-block;&:after{content:"";position:absolute;right:.7rem;top:50%;width:.35rem;height:.35rem;border-right:1.5px solid var(--muted);border-bottom:1.5px solid var(--muted);transform:translateY(-70%) rotate(45deg);pointer-events:none}}& range-slider{color:var(--accent);margin:0 .25rem}.conf-vals{color:var(--text);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.72rem;font-variant-numeric:tabular-nums;.dash{color:var(--muted);margin:0 .15rem}}& conf-filter{display:inline-flex;align-items:center;height:30px;box-sizing:border-box;padding:0 .55rem;gap:.5rem;background:transparent;border:1px solid var(--border);border-radius:4px;.conf-range-label{color:var(--muted);font-size:.7rem;font-weight:500;letter-spacing:.04em}& range-slider{margin:0}}& input[type=text]{background:var(--bg);color:var(--text);border:1px solid var(--border);border-radius:4px;padding:.25rem .4rem;font-size:.8rem;flex:1;min-width:8rem;&:focus{border-color:var(--accent);outline:none}}.sep{border-left:1px solid var(--border);height:1.2rem}.result-count{color:var(--muted);margin-left:auto}.checkbox-label{display:inline-flex;align-items:center;gap:.25rem;color:var(--muted);& input{margin:0}}}.trash-btn{height:30px;box-sizing:border-box;background:var(--bg);color:var(--text);border:1px solid var(--border);border-radius:4px;padding:.25rem .55rem;font-size:.8rem;font-family:inherit;&:hover{border-color:var(--accent)}&.active{border-color:var(--critical);color:var(--critical)}}.toolbar .trash-btn{margin-left:auto}triage-selector,slide-triage-tabs{display:inline-flex;height:30px;box-sizing:border-box;border:1px solid var(--border);border-radius:4px;overflow:hidden}.toolbar triage-selector{margin-left:auto}triage-selector.is-empty{display:none}.triage-state-btn{background:transparent;border:none;color:var(--muted);padding:0 .55rem;display:inline-flex;align-items:center;transition:background .12s,color .12s;font-family:inherit;font-size:.8rem;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}&.active{background:var(--surface-active)}}.triage-state-btn.active.triage-state-deleted{color:var(--critical)}.triage-state-btn.active.triage-state-fixed{color:var(--green, #4ade80)}.triage-state-btn.active.triage-state-inprogress{color:var(--warning, #d97706)}.triage-state-btn.active.triage-state-invalid{color:var(--muted)}.triage-state-btn.active.triage-state-ignored{color:var(--accent, #2563eb)}entity-search{display:contents}view-mode-buttons{display:inline-flex;height:30px;box-sizing:border-box;border:1px solid var(--border);border-radius:4px;overflow:hidden;.view-mode-btn{background:transparent;border:none;color:var(--muted);padding:.28rem .5rem;display:inline-flex;align-items:center;justify-content:center;transition:background .12s,color .12s;font-family:inherit;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}&.active{color:var(--accent);background:var(--surface-active)}& svg{display:block}}}source-filter{display:inline-flex;height:30px;box-sizing:border-box;border:1px solid var(--border);border-radius:4px;overflow:hidden;.source-chip{background:transparent;border:none;color:var(--muted);padding:0 .55rem;display:inline-flex;align-items:center;transition:background .12s,color .12s;font-family:inherit;font-size:.75rem;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}&.active{color:var(--accent);background:var(--surface-active)}}}annotation-filter{display:inline-flex;height:30px;box-sizing:border-box;border:1px solid var(--border);border-radius:4px;overflow:hidden;.annotation-chip{position:relative;background:transparent;border:none;color:var(--muted);padding:0 .45rem;display:inline-flex;align-items:center;transition:background .12s,color .12s;cursor:pointer;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}&.sel-with,&.sel-without{color:var(--accent);background:var(--surface-active)}&.sel-with .flag-cloth{fill:var(--accent)}&.sel-without:after{content:"";position:absolute;left:18%;right:18%;top:50%;height:1.5px;background:currentcolor;border-radius:1px;transform:rotate(-20deg);transform-origin:center;pointer-events:none}& svg{display:block}}}.toolbar-row{display:flex;gap:.75rem;flex-wrap:wrap;align-items:center}.search-row{display:inline-flex;align-items:center;gap:.65rem;flex:1 1 14rem;min-width:12rem}toolbar-search,.toolbar-search{display:inline-flex;align-items:center;gap:.5rem;flex:1;min-width:0;height:30px;box-sizing:border-box;padding:0 .65rem;background:var(--bg);border:1px solid var(--border);border-radius:6px;&:has(input:focus){border-color:var(--accent)}>svg{color:var(--muted);flex-shrink:0}&[kind] input[type=text],&.toolbar-search input[type=text]{flex:1;min-width:0;background:transparent;border:0;outline:none;color:var(--text);font:inherit;font-size:.8rem;padding:0;&:focus{border:0}&::placeholder{color:var(--muted)}&:focus::placeholder{color:transparent}&::-webkit-search-cancel-button{display:none}}}.search-negate-btn{flex-shrink:0;width:20px;height:20px;display:grid;place-items:center;background:transparent;color:var(--muted);border:0;border-radius:3px;padding:0;transition:background .12s,color .12s;& svg{width:13px;height:13px}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .08)}&.active{color:var(--accent);background:rgb(from var(--text) r g b / .1)}}@media(width<=1200px){.toolbar-row.sev-row .search-row{flex-basis:100%}}.findings-content.with-details .toolbar{max-width:1200px}severity-chips{display:inline-flex;height:30px;box-sizing:border-box;border:1px solid var(--border);border-radius:4px;overflow:hidden}.sev-chip{display:inline-flex;align-items:center;gap:.4rem;background:transparent;border:0;padding:0 .6rem;color:var(--muted);font-family:inherit;font-size:.8rem;transition:background .12s,color .12s;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}.sd{width:8px;height:8px;border-radius:2px;flex-shrink:0;background:currentcolor}.n{align-self:flex-start;margin:1px -5px 0;color:var(--muted);font-variant-numeric:tabular-nums;font-size:8.5px;font-weight:600;background:var(--bg);border-radius:999px;padding:0 3px;min-width:11px;text-align:center;line-height:11px}&.active{color:var(--text);.n{color:var(--text)}}&.critical .sd{background:var(--critical)}&.high .sd{background:var(--high)}&.medium .sd{background:var(--medium)}&.low .sd{background:var(--low)}&.high_bug .sd{background:var(--high-bug)}&.bug .sd{background:var(--bug)}&.informational .sd{background:var(--info)}&.critical.active{background:rgb(from var(--critical) r g b / .25)}&.high.active{background:rgb(from var(--high) r g b / .25)}&.medium.active{background:rgb(from var(--medium) r g b / .25)}&.low.active{background:rgb(from var(--low) r g b / .25)}&.high_bug.active{background:rgb(from var(--high-bug) r g b / .25)}&.bug.active{background:rgb(from var(--bug) r g b / .25)}&.informational.active{background:rgb(from var(--info) r g b / .25)}}triage-filter{display:inline-flex;align-items:center;background:var(--surface);border:1px solid var(--border);border-radius:6px;padding:3px;height:30px;gap:1px;& button{width:22px;height:22px;background:transparent;border:0;border-radius:4px;padding:0;display:grid;place-items:center;position:relative;transition:background .12s;&:hover{background:rgb(from var(--text) r g b / .06)}&.active{background:rgb(from var(--text) r g b / .08);box-shadow:0 0 0 1px var(--border)}}.td{width:12px;height:12px;border-radius:50%;border:1.5px solid currentcolor;background:transparent;transition:background .12s}& button.active .td{background:currentcolor}.td.none{border-style:dashed;color:var(--muted)}.td.r{color:#fc5855}.td.b{color:#30aff8}.td.g{color:#68c36d}.td.x{color:#6e7278}.count{position:absolute;top:-2px;right:-2px;background:var(--bg);color:var(--muted);font-size:8.5px;font-weight:600;border-radius:999px;padding:0 3px;min-width:11px;text-align:center;line-height:11px;font-variant-numeric:tabular-nums}}
|
|
4
|
-
`;var ce=["critical","high","medium","low","high_bug","bug","informational"],Nt="node_modules";function Ue(){return Nt}function Ye(e){return typeof e!="number"||!Number.isFinite(e)?null:`${e.toLocaleString()} B`}function Wt(){return{showAll:!1,selected:null,focusedPkg:null,topPkgsTab:"issues",edgeOpacity:.22,nodeSize:1,showLabels:!1,selectedSeverities:new Set,selectedColors:new Set,pathFilter:"",hidden:new Set,solo:null,graphState:null,layoutCache:null}}var ge=Wt(),M=new Proxy(ge,{get(e,t){return ge[t]},set(e,t,n){return ge[t]=n,!0},has(e,t){return t in ge},deleteProperty(e,t){return delete ge[t]},ownKeys(){return Reflect.ownKeys(ge)},getOwnPropertyDescriptor(e,t){return Object.getOwnPropertyDescriptor(ge,t)}});function Mt(){M.graphState?._cleanup&&M.graphState._cleanup(),M.graphState=null}function Gt(e){e&&(ge=e)}function Ke(e){if(!e)return null;let t=Ue()==="node_modules"?/^(?:.*\/)?node_modules\/(@[^/]+\/[^/]+|[^/]+)/u:/^(?:.*\/)?dependencies\/(@[^/]+\/[^/]+|[^/]+)/u,n=e.match(t);if(n)return n[1];let c=e.indexOf("/");return c>0?e.slice(0,c):"/"}var Vt=["#4e9af1","#f28e2b","#59a14f","#e15759","#76b7b2","#edc948","#b07aa1","#ff9da7","#9c755f","#5cd1e5","#f1ce63","#d37295","#a0cbe8","#86bcb6","#8cd17d","#b6992d","#499894","#e15759","#e879c7","#d4a6c8"],St=["#2f8aef","#d2691e","#2ea043","#e63946","#2e9a92","#b88817","#9560e8","#d24a9c","#8a5d40","#0891b2","#a07a14","#c14e8e","#1f7ad0","#549b94","#3fb95f","#a07a14","#2a8278","#cb2c40","#c026d3","#965f93"];function Ut(){if(typeof document>"u")return!1;let e=document.body?.classList;return!!e&&(e.contains("theme-light")||e.contains("theme-pink"))}var st=new Map;function ie(e){let t=Ut()?St:Vt,c=`${t===St?"l":"d"}:${e??"__own__"}`;if(st.has(c))return st.get(c);let p=e??"__own__",x=0;for(let o of p)x=x*37+o.codePointAt(0)|0;let S=((x%t.length+t.length)%t.length*7+3)%t.length,R=t[S];return st.set(c,R),R}function $t(e){if(!e)return 0;let t=0;for(let n of ce)t+=e[n]??0;return t}function Yt(e){if(!e)return null;for(let t of ce)if((e[t]??0)>0)return t;return null}function zt(e,t,n,c,p,x,f,S={}){let R=S.pkgOf??Ke,o=new Set(t),y=new Map,b=new Map;for(let d of t){let $=(e[d].imports??[]).filter(N=>o.has(N));y.set(d,$);for(let N of $)b.has(N)||b.set(N,[]),b.get(N).push(d)}let C=t.map(d=>{let $=n.get(d),N=c?.get(d)??null,h=$t($),G=R(d)??"__own__",j=Yt($);return{id:d,file:d,pkg:G,x:0,y:0,deg:0,issue:j,totalIssues:h,own:$,subtree:N,size:typeof e[d]?.size=="number"?e[d].size:null,severitySet:p?.get(d)??null,colorSet:x?.get(d)??null,findings:f?.get(d)??null,isHub:!1,label:d.split("/").pop()??d}}),r=new Map(C.map(d=>[d.file,d])),I=new Map;for(let d of t)for(let $ of y.get(d)??[]){let[N,h]=d<$?[d,$]:[$,d],G=`${N}\0${h}`,j=I.get(G);if(!j){let D=r.get(N),A=r.get(h);if(!D||!A)continue;j={a:N,b:h,cross:D.pkg!==A.pkg,fromLo:!1,fromHi:!1},I.set(G,j),D.deg++,A.deg++}d===N?j.fromLo=!0:j.fromHi=!0}let Z=[...I.values()],g=new Map;for(let d=0;d<Z.length;d++){let $=Z[d];g.has($.a)||g.set($.a,[]),g.has($.b)||g.set($.b,[]),g.get($.a).push(d),g.get($.b).push(d)}let k=new Map;for(let d of C)k.set(d.pkg,(k.get(d.pkg)??0)+1);let L=[...k.entries()].toSorted((d,$)=>$[1]-d[1]).map(([d])=>d),P=new Map;for(let d of C)P.has(d.pkg)||P.set(d.pkg,[]),P.get(d.pkg).push(d);let _={files:t,nodes:C,nodeByFile:r,edges:Z,adj:g,importsOf:y,importedBy:b,packages:L,pkgCount:k,byPkg:P};return Kt(_),_}function Kt(e){for(let t of e.nodes)t.isHub=!1;for(let t of e.edges)t.cross&&(t.fromLo&&(e.nodeByFile.get(t.b).isHub=!0),t.fromHi&&(e.nodeByFile.get(t.a).isHub=!0));for(let t of e.nodes){let n=e.importedBy.get(t.file);(!n||n.length===0)&&(t.isHub=!0)}}function Xe(e,t){if(!t||t==="/"||t==="__own__")return e;for(let n of["node_modules","dependencies",Ue()]){let c=n+"/"+t+"/",p=e.indexOf(c);if(p>=0)return e.slice(p+c.length)}return e.startsWith(t+"/")?e.slice(t.length+1):e}function Ct(e,t){let n=t.extraTopRow,c=t.hideAllFiles??!1,p=t.triageCounts??{inprogress:0,fixed:0,invalid:0,deleted:0},x=t.triageStates??["inprogress","fixed","invalid","deleted"],f={};for(let r of ce)f[r]=0;for(let r of e.nodes)if(r.severitySet)for(let I of r.severitySet)f[I]!==void 0&&f[I]++;let S=ce.some(r=>f[r]>0||M.selectedSeverities.has(r)),R=["none","red","blue","green","gray"],o={none:0,red:0,blue:0,green:0,gray:0};for(let r of e.nodes)if(r.colorSet)for(let I of r.colorSet)o[I]!==void 0&&o[I]++;let y=R.some(r=>o[r]>0||M.selectedColors.has(r)),b=E`<triage-selector variant="graph" .counts="${p}" .states="${x}"></triage-selector>`,C=c?null:E`<button type="button" class="${Se({"g2-topbar-toggle":!0,on:M.showAll})}" data-g2-show-all aria-pressed="${String(M.showAll)}"><span>All files</span><span class="g2-switch"></span></button>`;return E`<div class="graph2-topbar">${n?E`<div class="graph2-topbar-row graph2-topbar-row-extra toolbar-row">${n} ${C}<div class="g2-spacer"></div>${b}</div>`:null}<div class="graph2-topbar-row graph2-topbar-row-main toolbar-row sev-row">${S?E`<severity-chips .counts="${f}" .selected="${[...M.selectedSeverities]}" kind="graph"></severity-chips>`:null} ${y?E`<triage-filter .counts="${o}" .selected="${[...M.selectedColors]}" kind="graph"></triage-filter>`:null}<div class="toolbar-search g2-path-filter-wrap"><svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> <input type="text" class="g2-path-filter" id="g2-path-filter" placeholder="filter path/package…" .value="${M.pathFilter}"> <button type="button" class="g2-path-filter-clear" id="g2-path-filter-clear" title="Clear filter" aria-label="Clear filter">✕</button></div>${n?null:C}<div class="g2-spacer"></div>${n?null:b} <button type="button" class="g2-icon-btn" id="g2-fullscreen" title="Toggle fullscreen">⛶</button></div></div>`}function Xt(e,t){let n=e.split("/").filter(Boolean),c=t.split("/").filter(Boolean),p=0;for(;p<n.length&&p<c.length&&n[p]===c[p];)p++;let x=n.length-p,f=c.slice(p).join("/");return x===0?"./"+f:"../".repeat(x)+f}function Zt(e,t){if(!t&&t!=="")return e;let n=Xt(t,e);return n.length<e.length?n:e}function at(e,t,n,c){let p=n.length;if(p===0)return E`<div class="g2-sel-section"><div class="g2-sel-section-label">${t} (${p})</div><div class="g2-sel-section-empty">none</div></div>`;let x=n.map(f=>({file:f,display:Zt(f,c)}));return x.sort((f,S)=>f.display.localeCompare(S.display)),E`<div class="g2-sel-section"><div class="g2-sel-section-label">${t} (${p})</div><ul class="g2-sel-file-list">${x.map(({file:f,display:S})=>{let R=e.nodeByFile.get(f),o=R?ie(R.pkg):"#666";return E`<li><button type="button" class="g2-sel-file-link" data-g2-select="${f}" title="${f}"><span class="g2-sel-file-dot" style="${$e({background:o})}"></span> <span class="g2-sel-file-path">${S}</span></button></li>`})}</ul></div>`}function Ie(e){if(!e)return E`<div class="g2-sel-section-empty">none</div>`;let n=["critical","high","medium","low","high_bug","bug","informational"].filter(c=>(e[c]??0)>0);return n.length===0?E`<div class="g2-sel-section-empty">none</div>`:E`<div class="tree-count-chips">${n.map(c=>E`<span class="${`tree-count-chip ${c}`}">${e[c]} ${c.replaceAll("_"," ")}</span>`)}</div>`}function Pt(e){let t=0;for(let f of e.edges)f.cross&&t++;let n=e.edges.length-t,c=0;for(let f of e.nodes)c+=f.totalIssues;let p=e.nodes.length===0?"0.0":(e.edges.length*2/e.nodes.length).toFixed(1),x=M.focusedPkg==="__own__"?"own source":M.focusedPkg;return E`<main class="graph2-stage"><canvas id="g2-canvas"></canvas>${M.focusedPkg?E`<div class="g2-stage-overlay"><button type="button" class="g2-back-btn" id="g2-back-to-full" title="Back to the full graph">← ${x}</button></div>`:null}<div id="g2-focus-overlay-slot" class="g2-stage-overlay-tr"></div><div class="g2-stage-stats"><span><b>${e.nodes.length}</b> files</span> <span><b>${e.packages.length}</b> packages</span> <span><b>${e.edges.length}</b> edges (${n} intra · ${t} cross)</span> <span><b>${c}</b> issues</span> <span>avg degree <b>${p}</b></span></div><div class="g2-zoom-ctrl"><button id="g2-zoom-in" title="Zoom in">+</button><div class="g2-zoom-pct" id="g2-zoom-pct">100%</div><button id="g2-zoom-out" title="Zoom out">−</button> <button id="g2-zoom-fit" class="g2-zoom-fit-btn" title="Fit to view">fit</button></div><div class="g2-tooltip" id="g2-tooltip"></div></main>`}function _t(e){let t=null;if(M.selected){let c=e.nodeByFile.get(M.selected);c&&(t=c.pkg)}else M.solo&&(t=M.solo);return!t||(e.pkgCount.get(t)??0)<=1||M.focusedPkg===t?null:E`<button type="button" class="g2-focus-pkg-btn" data-g2-focus-pkg="${t}" title="${`Focus on ${t==="__own__"?"own source":t}'s graph`}"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M8 4.6 L4 11 M8 4.6 L12 11 M5 11.4 L11 11.4" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/><circle cx="8" cy="3.6" r="2" fill="currentColor"/><circle cx="3.6" cy="11.4" r="2" fill="currentColor"/><circle cx="12.4" cy="11.4" r="2" fill="currentColor"/></svg></button>`}function Ft(){return E`<aside class="graph2-right"><div class="g2-panel-title">Selection</div><div id="g2-selection-area"></div><div id="g2-top-pkgs-block"></div></aside>`}function Lt(e){let t=M.showAll&&e.nodes.length>0&&e.nodes.every(p=>typeof p.size=="number"),n=e.nodes.some(p=>p.totalIssues>0),c=M.topPkgsTab;return c==="size"&&!t&&(c="files"),c==="issues"&&!n&&(c="files"),E`<div class="g2-panel-title g2-panel-title-row"><span>Packages</span><div class="g2-mini-tabs">${n?E`<button type="button" class="${Se({"g2-mini-tab":!0,on:c==="issues"})}" data-g2-top-pkgs="issues">Issues</button>`:null} <button type="button" class="${Se({"g2-mini-tab":!0,on:c==="files"})}" data-g2-top-pkgs="files">Files</button> ${t?E`<button type="button" class="${Se({"g2-mini-tab":!0,on:c==="size"})}" data-g2-top-pkgs="size">Size</button>`:null}</div></div>${eo(e,c)}`}function Rt(e,t={}){let n=M.selected;if(n){let c=e.nodeByFile.get(n);return c?Jt(e,c,n,t):E`<div class="g2-empty-state"><strong>File not in current view</strong>Adjust filters or pick another file.</div>`}return M.solo?Qt(e,M.solo):E`<div class="g2-empty-state">Click a node or a package row to inspect.</div>`}function Jt(e,t,n,c){let p=ie(t.pkg),x=t.pkg==="__own__"?"own source":t.pkg,f=Xe(n,t.pkg),S=e.importedBy.get(n)??[],R=e.importsOf.get(n)??[],o=n.lastIndexOf("/"),y=o>=0?n.slice(0,o):"";return E`<div class="g2-selection-card"><div class="g2-sel-file-head"><div class="g2-sel-path">${f}</div><div class="g2-sel-pkg-row"><span class="g2-sel-dot" style="${$e({"--dot":p,background:p})}"></span> <span class="g2-sel-pkg">${x}</span></div></div><div class="g2-sel-fullpath" title="${n}">${n}</div>${Ye(t.size)?E`<div class="g2-sel-size">${Ye(t.size)}</div>`:null}<div class="g2-sel-section"><div class="g2-sel-section-label">Own findings</div>${Ie(t.own)}</div><div class="g2-sel-section"><div class="g2-sel-section-label">Subtree findings</div>${Ie(t.subtree)}</div><div class="g2-sel-jumps">${t.totalIssues>0?E`<button type="button" class="g2-sel-jump" data-g2-jump-findings="${n}">Findings →</button>`:null} ${c.isBundleContext?t.origFile?E`<button type="button" class="g2-sel-jump" data-bundle-view-source="${t.origFile}">View source →</button>`:null:E`<button type="button" class="g2-sel-jump" data-g2-jump-file="${n}">Files →</button>`}</div>${at(e,"Imported by",S,y)} ${at(e,"Imports",R,y)}</div>`}function Qt(e,t){let n=e.nodes.filter(b=>b.pkg===t),c=n.length;if(c===0)return E`<div class="g2-empty-state"><strong>Package has no files in view</strong> Toggle "All files" to widen the file set, or pick another package.</div>`;let p=ie(t),x=t==="__own__"?"own source":t,f={};for(let b of ce)f[b]=0;for(let b of n)if(b.own)for(let C of ce)f[C]+=b.own[C]??0;let S=0,R=0;for(let b of e.edges){let C=e.nodeByFile.get(b.a),r=e.nodeByFile.get(b.b);!C||!r||(C.pkg===t&&r.pkg===t?R++:(C.pkg===t||r.pkg===t)&&S++)}let o=0;for(let b of n)b.isHub&&o++;let y=new Set;for(let b of n)for(let C of e.importedBy.get(b.file)??[]){let r=e.nodeByFile.get(C);r&&r.pkg!==t&&y.add(C)}return E`<div class="g2-selection-card"><div class="g2-sel-head"><span class="g2-sel-dot" style="${$e({"--dot":p,background:p})}"></span> <span class="g2-sel-id">${x}</span> <span class="g2-sel-grp">package</span></div><div class="g2-sel-body"><div class="g2-sel-row"><span class="k">Files</span><span class="v">${c}</span></div><div class="g2-sel-row"><span class="k">Hubs</span><span class="v">${o}</span></div><div class="g2-sel-row"><span class="k">Intra edges</span><span class="v">${R}</span></div><div class="g2-sel-row"><span class="k">Cross edges</span><span class="v">${S}</span></div></div><div class="g2-sel-section"><div class="g2-sel-section-label">Findings</div>${Ie(f)}</div>${at(e,"Imported by",[...y])}</div>`}function eo(e,t){let n=e.nodes.length||1,c=t??M.topPkgsTab,p=M.selectedSeverities,x=M.selectedColors,f=p.size>0,S=x.size>0,R=f||S,o=new Map,y=new Map,b=0,C=0;for(let g of e.nodes){let k;if(R){if(k=0,g.findings)for(let L of g.findings)f&&!p.has(L.severity)||S&&!x.has(L.color)||k++}else k=g.totalIssues;o.set(g.pkg,(o.get(g.pkg)??0)+k),b+=k,typeof g.size=="number"&&(y.set(g.pkg,(y.get(g.pkg)??0)+g.size),C+=g.size)}let r;c==="issues"?r=e.packages.filter(g=>(o.get(g)??0)>0).toSorted((g,k)=>{let L=o.get(g)??0,P=o.get(k)??0;return P!==L?P-L:(e.pkgCount.get(k)??0)-(e.pkgCount.get(g)??0)}):c==="size"?r=e.packages.filter(g=>(y.get(g)??0)>0).toSorted((g,k)=>{let L=y.get(g)??0,P=y.get(k)??0;return P!==L?P-L:(e.pkgCount.get(k)??0)-(e.pkgCount.get(g)??0)}):r=[...e.packages].toSorted((g,k)=>{let L=e.pkgCount.get(g)??0,P=e.pkgCount.get(k)??0;return P!==L?P-L:(o.get(k)??0)-(o.get(g)??0)});let I=g=>c==="issues"?b>0?((o.get(g)??0)/b*100).toFixed(2):"0":c==="size"?C>0?((y.get(g)??0)/C*100).toFixed(2):"0":(e.pkgCount.get(g)/n*100).toFixed(2),Z=c==="issues"?"No packages with issues":c==="size"?"No packages with size":"No packages";return E`<div class="g2-dist-bar">${e.packages.map(g=>{let k=ie(g);return E`<span style="${$e({background:k,width:`${I(g)}%`})}"></span>`})}</div><div class="g2-dist-list">${r.length===0?E`<div class="g2-dist-empty">${Z}</div>`:null} ${vt(r,g=>g,g=>{let k=ie(g),L=e.pkgCount.get(g)??0,P=o.get(g)??0,_=y.get(g)??0,d=c==="issues"?P:c==="size"?Ye(_):L,$=c==="issues"?b>0?(P/b*100).toFixed(1):"0.0":c==="size"?C>0?(_/C*100).toFixed(1):"0.0":(L/n*100).toFixed(1),N=g==="__own__"?"own source":g,h=M.solo===g;return E`<button type="button" class="${Se({"g2-dist-item":!0,on:h})}" data-g2-pkg="${g}" title="${N}"><span class="g2-dist-dot" style="${$e({background:k})}"></span><span class="g2-dist-name">${N}</span><span class="g2-dist-count">${d}</span><span class="g2-dist-pct">${$}%</span></button>`})}</div>`}var lt=class extends xt{static properties={graph:{attribute:!1},options:{attribute:!1}};static styles=[Ve(wt),Ve(kt),Ve(yt)];constructor(){super(),this.graph=null,this.options={}}render(){return this.graph?E`<div class="graph2-layout">${Ct(this.graph,this.options)} ${Pt(this.graph)} ${Ft()}</div>`:E``}};customElements.define("graph-layout",lt);function to(e){let t=new Map;for(let[n,c]of e.importsOf){let p=e.nodeByFile.get(n);if(p)for(let x of c){let f=e.nodeByFile.get(x);f&&p.pkg!==f.pkg&&(t.set(p.pkg,(t.get(p.pkg)??0)+1),t.set(f.pkg,(t.get(f.pkg)??0)+1))}}return t}function oo(e){if(e.packages.length===0)return null;let t=new Set;for(let[n,c]of e.importedBy){let p=e.nodeByFile.get(n);if(p)for(let x of c){let f=e.nodeByFile.get(x);if(f&&f.pkg!==p.pkg){t.add(p.pkg);break}}}for(let n of e.packages)if(!t.has(n))return n;return null}var ro=5;function It(e,t){let n=new Map;for(let x of e.nodes)t.has(x.pkg)&&(n.has(x.pkg)||n.set(x.pkg,[]),n.get(x.pkg).push(x));for(let x of n.values())x.sort((f,S)=>f.isHub!==S.isHub?f.isHub?-1:1:S.deg-f.deg);let c=new Map,p=new Map;for(let[x,f]of t){let S=n.get(x);if(!S||S.length===0)continue;let R=S.length,o=0;for(let k of S)if(k.isHub)o++;else break;let y=o>0&&o<=ro,b=y?o:0,C=R-b,r=f.groupR,I=Array.from({length:R}),Z=Array.from({length:R});for(let k=0;k<R;k++){let L=k*137.508*Math.PI/180,P;if(k<b)P=b<=1?0:Math.sqrt(k/(b-1))*.3*r;else{let _=k-b;P=C<=1?.4*r:(.4+Math.sqrt(_/(C-1))*.6)*r}I[k]=f.x+Math.cos(L)*P,Z[k]=f.y+Math.sin(L)*P}let g=Array.from({length:R},()=>!1);for(let k=0;k<R;k++){let L=S[k],P,_;y&&L.isHub?(_=0,P=b):y?(_=b,P=R):(_=0,P=R);let d=0,$=0,N=0,h=e.importsOf.get(L.file);if(h)for(let A of h){let q=c.get(A);q!==void 0&&(d+=q,$+=p.get(A),N++)}let G=e.importedBy.get(L.file);if(G)for(let A of G){let q=c.get(A);q!==void 0&&(d+=q,$+=p.get(A),N++)}let j=!1;if(N>0){d/=N,$/=N;let A=d-f.x,q=$-f.y;A*A+q*q>1&&(j=!0)}let D=-1;if(j){let A=1/0;for(let q=_;q<P;q++){if(g[q])continue;let l=I[q]-d,F=Z[q]-$,O=l*l+F*F;O<A&&(A=O,D=q)}}else for(let A=_;A<P;A++)if(!g[A]){D=A;break}g[D]=!0,L.x=I[D],L.y=Z[D],c.set(L.file,L.x),p.set(L.file,L.y)}}}function At(e,t,n){let c=t/2,p=n/2,x=Math.min(t,n)/2;if(e.packages.length===0)return;let S=oo(e),R=to(e),o=(S?e.packages.filter(l=>l!==S):[...e.packages]).toSorted((l,F)=>{let O=(R.get(F)??0)-(R.get(l)??0);return O!==0?O:(e.pkgCount.get(F)??0)-(e.pkgCount.get(l)??0)}),y=o.length,b;y<=0?b=0:y<=6?b=.65:y<=20?b=.82:b=.95;let C=Math.max(1,Math.sqrt(50/Math.max(1,y))),r=.22,I=.12,Z=.04,g=new Map,k;if(S){let l=e.pkgCount.get(S)??0,F=Math.min(r,(.012+Math.sqrt(l)*.004)*C);k=Math.max(y<=6?.4:y<=20?.36:.34,F+I+Z),g.set(S,{x:c,y:p,size:l,groupR:F*x})}else y<=1?k=0:y<=6?k=.4:y<=20?k=.32:k=.3;if(y===0){It(e,g);return}let L=new Map;for(let l of e.edges){if(!l.cross)continue;let F=e.nodeByFile.get(l.a)?.pkg,O=e.nodeByFile.get(l.b)?.pkg;if(!F||!O||F===O)continue;L.has(F)||L.set(F,new Map),L.has(O)||L.set(O,new Map);let ee=L.get(F),J=L.get(O);ee.set(O,(ee.get(O)??0)+1),J.set(F,(J.get(F)??0)+1)}let P=Math.max(1,Math.min(10,Math.round(Math.sqrt(y)/1.2))),_=Array.from({length:P+1});for(let l=0;l<=P;l++)_[l]=Math.floor(l*l/(P*P)*y);_[P]=y;let d=.2,$=Array.from({length:P}),N=Array.from({length:P});for(let l=0;l<P;l++){let F=_[l],O=_[l+1];$[l]=O-F;let ee=0;for(let J=F;J<O;J++)ee+=e.pkgCount.get(o[J])??0;N[l]=ee}let h=Array.from({length:P});for(let l=0;l<P;l++){let F=(_[l]+_[l+1]-1)/2/Math.max(1,y-1);h[l]=Math.sqrt(Math.max(0,F))}let G=Array.from({length:P});G[0]=h[0];for(let l=1;l<P;l++){let F=$[l-1],O=N[l-1],ee=F>0?O/F:1,J=1+d*Math.sqrt(Math.max(0,ee-1));G[l]=G[l-1]+(h[l]-h[l-1])*J}let j=Array.from({length:P});for(let l=0;l<P;l++)j[l]=G[l]-h[l];let D=Array.from({length:y}),A=Array.from({length:y}),q=0;for(let l=0;l<y;l++){for(;q<P-1&&l>=_[q+1];)q++;let F=l*137.508%360*Math.PI/180,ee=(y<=1?0:Math.sqrt(l/(y-1)))+j[q],J=y===1?S?k:0:k+ee*(b-k);D[l]=c+Math.cos(F)*J*x,A[l]=p+Math.sin(F)*J*x}for(let l=0;l<P;l++){let F=_[l],O=_[l+1],ee=O-F;if(ee===0)continue;let J=Array.from({length:ee},()=>!1);for(let Ce=F;Ce<O;Ce++){let ve=o[Ce],Ae=L.get(ve),de=0,ae=0,se=0;if(Ae)for(let[te,oe]of Ae){let pe=g.get(te);pe&&(de+=pe.x*oe,ae+=pe.y*oe,se+=oe)}let ye=!1;if(se>0){de/=se,ae/=se;let te=de-c,oe=ae-p;te*te+oe*oe>1&&(ye=!0)}let ue=-1;if(ye){let te=1/0;for(let oe=0;oe<ee;oe++){if(J[oe])continue;let pe=F+oe,He=D[pe]-de,Ee=A[pe]-ae,Fe=He*He+Ee*Ee;Fe<te&&(te=Fe,ue=oe)}}else for(let te=0;te<ee;te++)if(!J[te]){ue=te;break}J[ue]=!0;let Pe=F+ue,_e=e.pkgCount.get(ve)??0,Be=Math.min(I,(.012+Math.sqrt(_e)*.004)*C);g.set(ve,{x:D[Pe],y:A[Pe],size:_e,groupR:Be*x})}}It(e,g)}function Bt(e,t,n){let c=t/2,p=n/2,x=Math.min(t,n)/2,f=e.nodes.length;if(f===0)return;let S=[...e.nodes].toSorted((R,o)=>o.deg-R.deg);for(let R=0;R<f;R++){let o=S[R],y=R*137.508%360*Math.PI/180,b=f<=1?0:Math.sqrt(R/(f-1));o.x=c+Math.cos(y)*b*.85*x,o.y=p+Math.sin(y)*b*.85*x}}function Ht(e,t,n,c){let p=e.length,x=c||760,f=n||1100,S=Math.sqrt(f*x/Math.max(p,1))*1.1,R=_=>{let d=0;for(let $ of _)d=d*31+$.codePointAt(0)|0;return d},o=Math.ceil(Math.sqrt(p*f/x)),y=Math.ceil(p/o),b=x/(y+1),C=f/(o+1),r=e.map((_,d)=>{let $=d%o,N=Math.floor(d/o),h=R(_);return{file:_,x:($+1)*C+(h%100-50)*C*.4,y:(N+1)*b+((h>>7)%100-50)*b*.4,dx:0,dy:0}}),I=new Map(r.map((_,d)=>[_.file,d])),Z=[];for(let _ of e)for(let d of t.get(_)??[])I.has(d)&&Z.push([I.get(_),I.get(d)]);let g=new Map;for(let _=0;_<p;_++){let d=Ke(r[_].file)??"__own__";g.has(d)||g.set(d,[]),g.get(d).push(_)}let k=Math.min(500,Math.max(180,100+p*3)),L=Math.min(f,x)/6,P=.3;for(let _=0;_<k;_++){let d=L*Math.pow(P/L,_/k);for(let h of r)h.dx=0,h.dy=0;for(let h=0;h<p;h++)for(let G=h+1;G<p;G++){let j=r[h],D=r[G],A=j.x-D.x,q=j.y-D.y,l=Math.sqrt(A*A+q*q);if(l<.01){let O=R(j.file+D.file);A=(O%100-50)*.01||.5,q=((O>>7)%100-50)*.01||.5,l=Math.sqrt(A*A+q*q)}let F=S*S/l;j.dx+=A/l*F,j.dy+=q/l*F,D.dx-=A/l*F,D.dy-=q/l*F}for(let[h,G]of Z){let j=r[h],D=r[G],A=j.x-D.x,q=j.y-D.y,l=Math.sqrt(A*A+q*q)||.01,F=l*l/S;j.dx-=A/l*F,j.dy-=q/l*F,D.dx+=A/l*F,D.dy+=q/l*F}let $=.055*Math.min(1,d/(L*.3));for(let[,h]of g){if(h.length<2)continue;let G=0,j=0;for(let D of h)G+=r[D].x,j+=r[D].y;G/=h.length,j/=h.length;for(let D of h)r[D].dx+=(G-r[D].x)*$,r[D].dy+=(j-r[D].y)*$}let N=50;for(let h of r){let G=Math.sqrt(h.dx*h.dx+h.dy*h.dy)||.01;h.x+=h.dx/G*Math.min(G,d),h.y+=h.dy/G*Math.min(G,d),h.x=Math.max(N,Math.min(f-N,h.x)),h.y=Math.max(N,Math.min(x-N,h.y))}}return r}var Et={critical:"#ff5470",high:"#ff9d4a",medium:"#f4d35e",low:"#67c2ff",high_bug:"#a06c3f",bug:"#7a6d62",informational:"#218bff"},ct={dark:{bg:"#0c0c0c",grid:"rgba(255, 255, 255, 0.022)",selectRing:"#ffffff",edgeIntra:"rgba(180, 195, 215, ALPHA)",hubRing:"rgba(255, 255, 255, ALPHA)",labelFill:"rgba(230, 233, 238, 0.78)",labelShadow:"rgba(12, 12, 12, 0.98)",labelOutline:"rgba(12, 12, 12, 0.9)",labelDefault:"rgba(200, 210, 225, 0.78)",labelHover:"rgba(230, 237, 243, 0.95)",labelSelected:"#fff"},light:{bg:"#f6f8fa",grid:"rgba(0, 0, 0, 0.04)",selectRing:"#0969da",edgeIntra:"rgba(50, 70, 100, ALPHA)",hubRing:"rgba(0, 0, 0, ALPHA)",labelFill:"rgba(40, 50, 70, 0.85)",labelShadow:"rgba(255, 255, 255, 0.95)",labelOutline:"rgba(255, 255, 255, 0.9)",labelDefault:"rgba(50, 60, 80, 0.85)",labelHover:"rgba(20, 25, 35, 0.95)",labelSelected:"#000"},pink:{bg:"#fff0f7",grid:"rgba(0, 0, 0, 0.04)",selectRing:"#0969da",edgeIntra:"rgba(50, 70, 100, ALPHA)",hubRing:"rgba(0, 0, 0, ALPHA)",labelFill:"rgba(40, 50, 70, 0.85)",labelShadow:"rgba(255, 255, 255, 0.95)",labelOutline:"rgba(255, 255, 255, 0.9)",labelDefault:"rgba(50, 60, 80, 0.85)",labelHover:"rgba(20, 25, 35, 0.95)",labelSelected:"#000"}};function no(){let e=document.body.classList;return e.contains("theme-pink")?ct.pink:e.contains("theme-light")?ct.light:ct.dark}function ze(e){return Math.max(0,Math.min(255,Math.round(e*255))).toString(16).padStart(2,"0")}function io(e,t,n){let p=e.querySelector("graph-layout")?.shadowRoot;if(!p)return;let x=p.querySelector("#g2-canvas"),f=p.querySelector("#g2-tooltip"),S=p.querySelector(".graph2-stage"),R=p.querySelector("#g2-zoom-pct");if(!x)return;Mt();let o=x.getContext("2d"),y=window.devicePixelRatio||1,b=0,C=0,r={tx:0,ty:0,k:1},I=null,Z=0,g=0,k=!0,L=!0;function P(){if(!k)return;let s=M.layoutCache,u=M.focusedPkg;if(s&&s.files===t.files&&s.w===g&&s.h===Z&&s.focused===u)for(let v of t.nodes){let i=s.pos.get(v.file);i&&(v.x=i.x,v.y=i.y)}else{if(u)if(t.nodes.length>50)Bt(t,g,Z);else{let i=Ht(t.files,t.importsOf,g,Z),m=new Map(i.map(z=>[z.file,z]));for(let z of t.nodes){let T=m.get(z.file);T&&(z.x=T.x,z.y=T.y)}}else At(t,g,Z);let v=new Map;for(let i of t.nodes)v.set(i.file,{x:i.x,y:i.y});M.layoutCache={files:t.files,w:g,h:Z,pos:v,focused:u}}k=!1}function _(){if(t.nodes.length===0)return{k:1,tx:C/2,ty:b/2};let s=-1/0,u=-1/0,v=1/0,i=1/0;for(let a of t.nodes)a.x<v&&(v=a.x),a.y<i&&(i=a.y),a.x>s&&(s=a.x),a.y>u&&(u=a.y);let m=Math.max(20,u-i),z=Math.max(20,s-v),T=(v+s)/2,W=(i+u)/2,V=Math.min(C,b)*.1,Y=Math.min((C-V*2)/z,(b-V*2)/m,4),K=Math.max(.05,Y);return{k:K,tx:C/2-T*K,ty:b/2-W*K}}function d(){let s=_();r.k=s.k,r.tx=s.tx,r.ty=s.ty}function $(s,u){return[s*r.k+r.tx,u*r.k+r.ty]}function N(s,u){return[(s-r.tx)/r.k,(u-r.ty)/r.k]}function h(s){return!M.hidden.has(s.pkg)}function G(s){if(M.selectedSeverities.size>0){let v=s.severitySet;if(!v)return!0;let i=!1;for(let m of M.selectedSeverities)if(v.has(m)){i=!0;break}if(!i)return!0}if(M.selectedColors.size>0){let v=s.colorSet;if(!v)return!0;let i=!1;for(let m of M.selectedColors)if(v.has(m)){i=!0;break}if(!i)return!0}if(M.solo&&s.pkg!==M.solo)return!0;let u=M.pathFilter;if(u){let v=u.toLowerCase(),i=s.file.toLowerCase().includes(v),m=s.pkg&&s.pkg.toLowerCase().includes(v);if(!i&&!m)return!0}return!1}function j(s){let u=(s.isHub?4.9:3.5)*M.nodeSize,v=Math.max(.6,Math.min(1.6,r.k));return u*v}function D(){let s=S.getBoundingClientRect(),u=b,v=C;C=Math.max(80,s.width),b=Math.max(80,s.height),y=window.devicePixelRatio||1,x.width=C*y,x.height=b*y,x.style.width=C+"px",x.style.height=b+"px",o.setTransform(y,0,0,y,0,0),(g===0||Z===0)&&(g=C,Z=b,k=!0),P();let i=v>0&&(Math.abs(C-v)/v>.15||Math.abs(b-u)/u>.15);(L||i)&&(d(),L=!1),O()}let A=null,q=!0,l=!1,F=!1;function O(){q=!0,!(l||F)&&(l=!0,A=requestAnimationFrame(()=>{l=!1,q&&!F&&(q=!1,ee())}))}function ee(){let s=no();o.fillStyle=s.bg,o.fillRect(0,0,C,b),J(s);let u=M.selected,v=u?t.nodeByFile.get(u):null;if(M.focusedPkg&&t.nodes.length<=50){Ce(s,u,v);return}for(let i of t.edges){let m=t.nodeByFile.get(i.a),z=t.nodeByFile.get(i.b);if(!m||!z||!h(m)||!h(z))continue;let T=M.edgeOpacity;u?T=i.a===u||i.b===u?.85:M.edgeOpacity*.25:I&&(i.a===I||i.b===I)&&(T=Math.min(.9,T+.5)),G(m)&&G(z)&&(T=Math.min(T,.04));let[W,V]=$(m.x,m.y),[Y,K]=$(z.x,z.y);if(i.cross){let a=o.createLinearGradient(W,V,Y,K);a.addColorStop(0,ie(m.pkg)+ze(T)),a.addColorStop(1,ie(z.pkg)+ze(T)),o.strokeStyle=a,o.lineWidth=.85}else o.strokeStyle=s.edgeIntra.replace("ALPHA",String(T*.7)),o.lineWidth=.55;o.beginPath(),o.moveTo(W,V),o.lineTo(Y,K),o.stroke()}for(let i of t.nodes){if(!h(i))continue;let m=i.file===I,z=i.file===u;if(!i.isHub&&!m&&!z||G(i)&&!m&&!z)continue;let[T,W]=$(i.x,i.y),Y=j(i)*(z?6:m?4.5:3),K=o.createRadialGradient(T,W,0,T,W,Y),a=ie(i.pkg);K.addColorStop(0,a+"55"),K.addColorStop(1,a+"00"),o.fillStyle=K,o.beginPath(),o.arc(T,W,Y,0,Math.PI*2),o.fill()}for(let i of t.nodes){if(!h(i))continue;let[m,z]=$(i.x,i.y),T=j(i),W=1,V=u&&i.file===u;if(u&&!V&&(W=(t.adj.get(u)??[]).some(K=>{let a=t.edges[K];return a.a===i.file||a.b===i.file})?1:.25),!V&&G(i)&&(W=Math.min(W,.1)),o.fillStyle=ie(i.pkg)+ze(W),o.beginPath(),o.arc(m,z,T,0,Math.PI*2),o.fill(),i.isHub&&(o.strokeStyle=s.hubRing.replace("ALPHA",String(.55*W)),o.lineWidth=.8,o.stroke()),i.issue){let Y=Et[i.issue],K=T+(i.issue==="critical"?4.2:i.issue==="high"?3.4:2.8),a=i.issue==="critical"?1.8:i.issue==="high"?1.5:i.issue==="medium"?1.3:1.1;o.strokeStyle=Y,o.globalAlpha=W,o.lineWidth=a,o.beginPath(),o.arc(m,z,K,0,Math.PI*2),o.stroke(),o.globalAlpha=1}}if(r.k>1.4){let m=0;if(r.k<9&&!M.showLabels)for(let T of t.nodes){if(!h(T))continue;let[W,V]=$(T.x,T.y);if(!(W<0||W>C||V<0||V>b)&&(m++,m>=50))break}let z=r.k>=9||m<50;if(M.showLabels||z){o.font="10px ui-monospace, SFMono-Regular, Menlo, Monaco, monospace",o.fillStyle=s.labelFill,o.textAlign="left",o.textBaseline="middle";let T=11,W=2,V=250,Y=(w,H)=>w>-V&&w<C+V&&H>-V&&H<b+V,K=[];for(let w of t.nodes){if(!h(w))continue;let[H,X]=$(w.x,w.y);if(!Y(H,X))continue;let Q=j(w);K.push({file:w.file,x0:H-Q,x1:H+Q,y0:X-Q,y1:X+Q})}let a=[];for(let w of t.nodes){if(!h(w)||!w.isHub&&r.k<2.4)continue;let[H,X]=$(w.x,w.y);if(!Y(H,X))continue;let Q=j(w),re=H+Q+4,ne=X+1,ke=o.measureText(w.label).width+W,Te=w.file===M.selected,Oe=w.file===I,qe=Te?3:Oe?2:w.isHub?1:0;a.push({file:w.file,n:w,tx:re,ty:ne,prio:qe,x0:re-W,x1:re+ke,y0:ne-T/2,y1:ne+T/2})}a.sort((w,H)=>H.prio-w.prio);let B=[],U=(w,H)=>w.x0<H.x1&&H.x0<w.x1&&w.y0<H.y1&&H.y0<w.y1;for(let w of a){let H=!1;for(let X of K)if(X.file!==w.file&&U(w,X)){H=!0;break}if(!H){for(let X of B)if(U(w,X)){H=!0;break}}H||B.push(w)}for(let w of B)o.fillText(w.n.label,w.tx,w.ty)}}if(v&&h(v)){let[i,m]=$(v.x,v.y),z=j(v);o.strokeStyle=s.selectRing,o.lineWidth=1.5,o.beginPath(),o.arc(i,m,z+5,0,Math.PI*2),o.stroke()}R&&(R.textContent=`${Math.round(r.k*100)}%`)}function J(s){if(r.k<.4)return;let u=80,v=(r.tx%u+u)%u,i=(r.ty%u+u)%u;o.strokeStyle=s.grid,o.lineWidth=1,o.beginPath();for(let m=v;m<C;m+=u)o.moveTo(m,0),o.lineTo(m,b);for(let m=i;m<b;m+=u)o.moveTo(0,m),o.lineTo(C,m);o.stroke()}function Ce(s,u,v){let i=ie(M.focusedPkg),m=new Set;if(I){m.add(I);for(let a of t.adj.get(I)??[]){let B=t.edges[a];m.add(B.a),m.add(B.b)}}let z=a=>(a.isHub?6:4)*M.nodeSize;for(let a of t.edges){let B=t.nodeByFile.get(a.a),U=t.nodeByFile.get(a.b);if(!B||!U||!h(B)||!h(U))continue;let w=a.fromLo&&a.fromHi,H=!w&&a.fromHi,X=H?U:B,Q=H?B:U,re=I&&(a.a===I||a.b===I),ne=u&&(a.a===u||a.b===u),ke=(u||I)&&!re&&!ne,Te=z(X),Oe=z(Q),[qe,pt]=$(X.x,X.y),[ft,gt]=$(Q.x,Q.y),Ze=ft-qe,Je=gt-pt,Qe=Math.sqrt(Ze*Ze+Je*Je)||1,et=Ze/Qe,tt=Je/Qe,be=qe+et*(Te+1.5),he=pt+tt*(Te+1.5),me=ft-et*(Oe+3.5),xe=gt-tt*(Oe+3.5),ut=Math.min(Qe*.15,30),Le=(be+me)/2-tt*ut,Re=(he+xe)/2+et*ut;o.beginPath(),o.moveTo(be,he),o.quadraticCurveTo(Le,Re,me,xe);let we;if(ne?we=.9:re?we=.85:ke?we=.05:we=Math.min(.85,M.edgeOpacity*3),o.strokeStyle=i+ze(we),o.lineWidth=ne||re?1.5:.85,o.stroke(),ke)continue;let le=Math.max(5,7),fe=le*.42,De=.9,ot=2*(1-De)*(Le-be)+2*De*(me-Le),rt=2*(1-De)*(Re-he)+2*De*(xe-Re),bt=Math.sqrt(ot*ot+rt*rt)||1,je=ot/bt,Ne=rt/bt;if(o.beginPath(),o.moveTo(me,xe),o.lineTo(me-je*le+Ne*fe,xe-Ne*le-je*fe),o.lineTo(me-je*le-Ne*fe,xe-Ne*le+je*fe),o.closePath(),o.fillStyle=i+ze(Math.min(1,we+.15)),o.fill(),w){let nt=1.8*(Le-be)+.2*(me-Le),it=2*(1-.1)*(Re-he)+2*.1*(xe-Re),ht=Math.sqrt(nt*nt+it*it)||1,We=nt/ht,Ge=it/ht;o.beginPath(),o.moveTo(be,he),o.lineTo(be+We*le-Ge*fe,he+Ge*le+We*fe),o.lineTo(be+We*le+Ge*fe,he+Ge*le-We*fe),o.closePath(),o.fill()}}for(let a of t.nodes){if(!h(a))continue;let[B,U]=$(a.x,a.y),w=z(a),H=a.file===I,X=a.file===u,Q=(u||I)&&!m.has(a.file)&&!X?.15:1;if(o.globalAlpha=Q,X||H||a.isHub){let re=w*(X?4:H?3:2.4),ne=o.createRadialGradient(B,U,w*.6,B,U,re);ne.addColorStop(0,i+ze(X?.4:.25)),ne.addColorStop(1,i+"00"),o.fillStyle=ne,o.beginPath(),o.arc(B,U,re,0,Math.PI*2),o.fill()}if(o.fillStyle=i,o.beginPath(),o.arc(B,U,w,0,Math.PI*2),o.fill(),a.isHub&&(o.strokeStyle=s.hubRing.replace("ALPHA","0.55"),o.lineWidth=.9,o.stroke()),a.issue){let re=Et[a.issue],ne=w+(a.issue==="critical"?4.2:a.issue==="high"?3.4:2.8),ke=a.issue==="critical"?1.8:a.issue==="high"?1.5:a.issue==="medium"?1.3:1.1;o.strokeStyle=re,o.lineWidth=ke,o.beginPath(),o.arc(B,U,ne,0,Math.PI*2),o.stroke()}o.globalAlpha=1}o.font="600 11px ui-monospace, SFMono-Regular, Menlo, Monaco, monospace",o.textAlign="center",o.textBaseline="top",o.lineJoin="round";let T=13,W=2,V=[];for(let a of t.nodes){if(!h(a))continue;let[B,U]=$(a.x,a.y),w=z(a),H=U+w+4,X=o.measureText(a.label).width/2+W,Q=a.file===u,re=a.file===I,ne=Q?3:re?2:a.isHub?1:0;V.push({n:a,sx:B,ty:H,halfW:X,isSel:Q,isHov:re,prio:ne,x0:B-X,x1:B+X,y0:H,y1:H+T})}V.sort((a,B)=>B.prio-a.prio);let Y=[],K=(a,B)=>a.x0<B.x1&&B.x0<a.x1&&a.y0<B.y1&&B.y0<a.y1;for(let a of V){let B=!1;for(let U of Y)if(K(a,U)){B=!0;break}B||Y.push(a)}for(let a of Y){let{n:B,sx:U,ty:w,isSel:H,isHov:X}=a,Q=(u||I)&&!m.has(B.file)&&!H?.2:1;o.globalAlpha=Q,o.shadowColor=s.labelShadow,o.shadowBlur=4,o.strokeStyle=s.labelOutline,o.lineWidth=3,o.strokeText(B.label,U,w),o.shadowBlur=0,o.fillStyle=H?s.labelSelected:X?s.labelHover:s.labelDefault,o.fillText(B.label,U,w),o.globalAlpha=1}if(v&&h(v)){let[a,B]=$(v.x,v.y),U=z(v);o.strokeStyle=s.selectRing,o.lineWidth=1.8,o.beginPath(),o.arc(a,B,U+4,0,Math.PI*2),o.stroke()}R&&(R.textContent=`${Math.round(r.k*100)}%`)}function ve(s,u){let v=null,i=1/0,m=6;for(let z of t.nodes){if(!h(z))continue;let[T,W]=$(z.x,z.y),V=T-s,Y=W-u,K=V*V+Y*Y,a=j(z)+m;K<a*a&&K<i&&(i=K,v=z)}return v}function Ae(s,u,v){if(!f)return;let i=S.getBoundingClientRect(),m=ie(s.pkg),z=s.pkg==="__own__"?"own source":s.pkg,T=Xe(s.file,s.pkg);Me(E`<div class="g2-tt-path">${T}</div><div class="g2-tt-head"><span class="g2-tt-dot" style="${`background:${m}`}"></span> <span class="g2-tt-pkg">${z}</span></div>${s.totalIssues>0?Ie(s.own):null}`,f),f.classList.add("show");let W=f.offsetWidth,V=f.offsetHeight,Y=u-i.left,K=v-i.top,a=i.width,B=i.height,U=12,w=Y+U;w+W>a-4&&(w=Y-W-U),w<4&&(w=4);let H=K+U;H+V>B-4&&(H=K-V-U),H<4&&(H=4),f.style.left=`${w}px`,f.style.top=`${H}px`}function de(){f&&f.classList.remove("show")}let ae=!1,se=null,ye=!1,ue=s=>{s.button===0&&(s.target.closest(".g2-stage-overlay, .g2-stage-overlay-tr, .g2-zoom-ctrl")||(ae=!0,ye=!1,se={x:s.clientX,y:s.clientY,tx:r.tx,ty:r.ty}))},Pe=s=>{let u=S.getBoundingClientRect(),v=s.clientX-u.left,i=s.clientY-u.top;if(ae){let T=s.clientX-se.x,W=s.clientY-se.y;Math.abs(T)+Math.abs(W)>3&&(ye=!0),r.tx=se.tx+T,r.ty=se.ty+W,de(),O();return}let m=ve(v,i),z=I;I=m?.file??null,x.style.cursor=m?"default":"grab",m?Ae(m,s.clientX,s.clientY):z&&de(),I!==z&&O()},_e=s=>{if(ae&&!ye){let u=S.getBoundingClientRect(),v=s.clientX-u.left,i=s.clientY-u.top,m=ve(v,i);M.selected=m?.file??null,n(),O()}ae=!1},Be=()=>{let s=I!==null;I=null,de(),s&&O()},te=s=>{s.preventDefault();let u=S.getBoundingClientRect(),v=s.clientX-u.left,i=s.clientY-u.top,m=Math.exp(-s.deltaY*.0015),z=_();if(m<1&&r.k<=z.k*1.0001){r.k=z.k;let Y=Math.min(.4,(1-m)*3);r.tx+=(z.tx-r.tx)*Y,r.ty+=(z.ty-r.ty)*Y,O();return}let[T,W]=N(v,i),V=Math.max(z.k,Math.min(9.99,r.k*m));r.k=V,r.tx=v-T*r.k,r.ty=i-W*r.k,O()};S.addEventListener("mousedown",ue),window.addEventListener("mousemove",Pe),window.addEventListener("mouseup",_e),S.addEventListener("mouseleave",Be),S.addEventListener("wheel",te,{passive:!1});function oe(s){let u=_().k;s=Math.max(u,Math.min(9.99,s));let v=C/2,i=b/2,[m,z]=N(v,i);r.k=s,r.tx=v-m*r.k,r.ty=i-z*r.k,O()}let pe=p.querySelector("#g2-zoom-in"),He=p.querySelector("#g2-zoom-out"),Ee=p.querySelector("#g2-zoom-fit");pe?.addEventListener("click",()=>oe(r.k*1.4)),He?.addEventListener("click",()=>oe(r.k/1.4)),Ee?.addEventListener("click",()=>{d(),O()}),D();let Fe=new ResizeObserver(()=>D());Fe.observe(S);let dt=new MutationObserver(s=>{for(let u of s){let v=(u.oldValue||"").includes("report-fullscreen"),i=document.body.classList.contains("report-fullscreen");if(v!==i){g=0,Z=0,k=!0,L=!0,M.layoutCache=null,setTimeout(()=>D(),80);return}O()}});dt.observe(document.body,{attributes:!0,attributeFilter:["class"],attributeOldValue:!0}),O(),M.graphState={requestDraw:O,_cleanup:()=>{F=!0,cancelAnimationFrame(A),Fe.disconnect(),dt.disconnect(),S.removeEventListener("mousedown",ue),window.removeEventListener("mousemove",Pe),window.removeEventListener("mouseup",_e),S.removeEventListener("mouseleave",Be),S.removeEventListener("wheel",te)}}}function Xo(e,t){let n=document.querySelector("graph-layout")?.shadowRoot;if(!n)return;let c=Tt(e),p=n.querySelector("#g2-selection-area");p&&Me(Rt(c,t),p);let x=n.querySelector("#g2-focus-overlay-slot");x&&Me(_t(c),x)}function Zo(e){let t=document.querySelector("graph-layout")?.shadowRoot;if(!t)return;let n=t.querySelector("#g2-top-pkgs-block");n&&Me(Lt(Tt(e)),n)}function Tt(e){let t=zt(e.treeData,e.files,e.ownCounts,e.transitiveCounts,e.severitySets,e.colorSets,e.fileFindings,e.options);if(e.strippedToOrig)for(let n of t.nodes)n.origFile=e.strippedToOrig.get(n.file);return t}export{Gt as _swapGraph2Impl,io as attachGraph2Interaction,Tt as buildGraphFromPrep,Xo as refreshSidebar,Zo as refreshTopPkgs};
|
|
1
|
+
var Ct=globalThis[Symbol.for("@rray/frontend")];if(!Ct)throw new Error("@rray/frontend global not installed; view.js must run before lazy bundles import this wrapper");var{LitElement:_t,html:G,nothing:Jt,unsafeCSS:ct,render:je,StateElement:vo,classMap:Ce,repeat:Rt,styleMap:Qe}=Ct;var Lt=`*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}:host{display:grid;grid-template-columns:1fr 300px;grid-template-rows:auto 1fr;grid-template-areas:"topbar right" "stage right";min-height:0;border:1px solid var(--border);border-radius:8px;overflow:hidden;background:var(--graph-canvas-bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,sans-serif;font-size:12px}.graph2-layout{display:contents}.graph2-topbar{grid-area:topbar;display:flex;flex-direction:column;gap:.5rem;padding:.6rem .75rem;font-size:.825rem;background:var(--surface);backdrop-filter:var(--glass-blur);border-bottom:1px solid var(--graph-divider)}.graph2-topbar-row{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;padding:0}.graph2-topbar .g2-spacer{flex:1}.graph2-topbar triage-selector{margin-left:auto}.g2-icon-btn{width:28px;height:28px;border-radius:5px;background:var(--graph-hover-bg);border:1px solid var(--border);color:var(--muted);display:grid;place-items:center;font-family:inherit;&:hover{color:var(--accent);border-color:var(--accent)}& svg{display:block}}.g2-path-filter-wrap{position:relative;flex:0 0 14rem;padding-right:22px}.g2-path-filter-wrap .g2-path-filter-clear{position:absolute;right:4px;top:50%;transform:translateY(-50%);display:grid;place-items:center;width:18px;height:18px;background:transparent;border:0;border-radius:50%;color:var(--muted);font:400 10px/1 inherit;font-family:inherit;&:hover{color:var(--text);background:var(--surface-active)}}.g2-path-filter:placeholder-shown~.g2-path-filter-clear{display:none}.g2-topbar-toggle{display:inline-flex;align-items:center;height:30px;box-sizing:border-box;gap:8px;padding:5px 10px;background:var(--graph-hover-bg);border:1px solid var(--border);border-radius:6px;color:var(--muted);font:500 11px/1 inherit;font-family:inherit;white-space:nowrap;&:hover{color:var(--text)}&.on{color:var(--text)}&.on .g2-switch{background:color-mix(in srgb,var(--accent) 22%,transparent)}&.on .g2-switch:after{transform:translate(12px);background:var(--accent)}}.g2-trash-btn.on{background:color-mix(in srgb,var(--accent) 16%,transparent);border-color:var(--accent);color:var(--accent)}.graph2-right{grid-area:right;border-left:1px solid var(--graph-divider);background:var(--surface);backdrop-filter:var(--glass-blur);display:flex;flex-direction:column;overflow:hidden;padding:14px}.g2-panel-title{font-family:inherit;font-weight:600;font-size:11px;line-height:1;letter-spacing:.14em;text-transform:uppercase;color:var(--muted);opacity:.85;margin:14px 0 8px;display:flex;align-items:baseline;gap:6px;&:first-child{margin-top:0}}.g2-count{color:var(--muted);opacity:.6;font-weight:400;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;text-transform:none;letter-spacing:0;font-size:10px}.g2-panel-title-row{justify-content:space-between;gap:8px}#g2-top-pkgs-block{margin-top:14px;flex:1 1 0;min-height:0;display:flex;flex-direction:column}.g2-mini-tabs{display:flex;gap:1px;background:var(--graph-divider);border-radius:4px;overflow:hidden}.g2-mini-tab{background:transparent;border:0;color:var(--muted);font-family:inherit;font-weight:500;font-size:11px;line-height:1.4;text-transform:none;letter-spacing:0;padding:2px 7px;&:hover{color:var(--text);background:var(--graph-hover-bg)}&.on{background:var(--surface-active);color:var(--accent)}}.g2-switch{width:26px;height:14px;background:var(--border);border-radius:8px;position:relative;transition:background .15s;flex-shrink:0;&:after{content:"";position:absolute;top:2px;left:2px;width:10px;height:10px;border-radius:50%;background:var(--muted);transition:transform .15s,background .15s}}.graph2-stage{grid-area:stage;position:relative;background:var(--graph-canvas-bg);overflow:hidden;cursor:grab;&:active{cursor:grabbing}& canvas{position:absolute;inset:0;width:100%;height:100%;display:block}}.g2-stage-overlay{position:absolute;top:12px;left:12px;z-index:3;display:flex;flex-direction:column;gap:4px;pointer-events:none;max-width:calc(100% - 60px)}.g2-stage-overlay>*{pointer-events:auto}.g2-stage-stats{position:absolute;bottom:10px;left:12px;z-index:2;display:flex;flex-wrap:wrap;gap:2px 14px;font:500 10px/1.4 ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;color:var(--muted);opacity:.7;text-transform:uppercase;letter-spacing:.06em;pointer-events:none;max-width:calc(100% - 80px);& b{font-weight:600;color:var(--text);opacity:1}}.g2-stage-overlay-tr{position:absolute;top:12px;right:12px;z-index:3;pointer-events:auto}.g2-focus-pkg-btn{width:28px;height:28px;display:grid;place-items:center;background:var(--surface);backdrop-filter:var(--glass-blur);border:1px solid var(--border);border-radius:6px;color:var(--accent);box-shadow:var(--shadow-glass);&:hover{border-color:var(--accent);background:var(--surface-active)}& svg{display:block}}.g2-back-btn{display:inline-flex;align-items:center;gap:4px;padding:6px 11px;background:var(--surface);backdrop-filter:var(--glass-blur);border:1px solid var(--border);border-radius:6px;color:var(--accent);font:500 11px/1 inherit;font-family:inherit;box-shadow:var(--shadow-glass);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;align-self:flex-start;&:hover{border-color:var(--accent);background:var(--surface-active)}}.g2-zoom-ctrl{position:absolute;right:12px;bottom:12px;display:flex;flex-direction:column;background:var(--surface);backdrop-filter:var(--glass-blur);border:1px solid var(--border);border-radius:6px;overflow:hidden;z-index:3;box-shadow:var(--shadow-glass);& button{width:28px;height:28px;background:transparent;border:0;color:var(--muted);border-bottom:1px solid var(--graph-divider);display:grid;place-items:center;font-family:inherit;font-size:13px;&:last-child{border-bottom:0}&:hover{color:var(--accent);background:var(--surface-active)}}}.g2-zoom-pct{font:500 9px/1 ui-monospace,monospace;color:var(--muted);padding:5px 0;text-align:center;border-bottom:1px solid var(--graph-divider)}.g2-zoom-ctrl .g2-zoom-fit-btn{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;font-weight:600;font-size:9px;line-height:1;letter-spacing:-.02em;text-transform:lowercase}.g2-tooltip{position:absolute;background:var(--surface);backdrop-filter:var(--glass-blur);border:1px solid var(--border);border-radius:7px;padding:9px 11px;pointer-events:none;min-width:170px;max-width:260px;opacity:0;transition:opacity .12s;z-index:10;box-shadow:var(--shadow-glass);&.show{opacity:1}}.g2-tt-path{font:500 11px/1.3 ui-monospace,monospace;color:var(--text);word-break:break-all;margin-bottom:4px}.g2-tt-head{display:flex;align-items:center;gap:6px;margin-bottom:6px;flex-wrap:wrap}.g2-tt-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.g2-tt-pkg{font-size:10px;color:var(--muted);word-break:break-all}.g2-tt-badge{display:inline-block;font-size:8px;padding:2px 4px;background:color-mix(in srgb,var(--accent) 22%,transparent);color:var(--accent);border-radius:3px;text-transform:uppercase;letter-spacing:.08em;font-weight:600}.g2-tooltip .tree-count-chips{margin-top:6px}:host-context(body.theme-light) .graph2-right .tree-count-chip.medium,:host-context(body.theme-light) .g2-tooltip .tree-count-chip.medium{color:#fff}.g2-selection-card{background:var(--graph-hover-bg);border:1px solid var(--border);border-radius:8px;overflow:hidden}.g2-sel-head{padding:11px 13px;border-bottom:1px solid var(--graph-divider);display:flex;align-items:center;gap:8px}.g2-sel-file-head{padding:11px 13px;border-bottom:1px solid var(--graph-divider);display:flex;flex-direction:column;gap:6px}.g2-sel-path{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;font-weight:600;font-size:12px;line-height:1.3;color:var(--text);word-break:break-all}.g2-sel-pkg-row{display:flex;align-items:center;gap:6px;min-width:0}.g2-sel-pkg{font-size:11px;color:var(--muted);word-break:break-all;min-width:0}.g2-sel-fullpath{padding:7px 13px;border-bottom:1px solid var(--graph-divider);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;font-size:10px;line-height:1.3;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.g2-sel-size{padding:5px 13px 7px;border-bottom:1px solid var(--graph-divider);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;font-size:10px;line-height:1.3;color:var(--muted);font-variant-numeric:tabular-nums}.g2-sel-dot{width:11px;height:11px;border-radius:50%;box-shadow:0 0 0 3px color-mix(in srgb,var(--dot) 22%,transparent);flex-shrink:0}.g2-sel-id{font:600 12px/1 ui-monospace,monospace;color:var(--text);word-break:break-all;flex:1;min-width:0}.g2-sel-grp{font:500 9px/1 ui-monospace,monospace;color:var(--muted);text-transform:uppercase;letter-spacing:.08em;flex-shrink:0}.g2-sel-body{padding:11px 13px}.g2-sel-row{display:flex;justify-content:space-between;gap:12px;font-size:11px;padding:5px 0;border-bottom:1px solid var(--graph-divider);&:last-child{border-bottom:0}.k{color:var(--muted);flex-shrink:0}.v{color:var(--text);font-family:ui-monospace,monospace;word-break:break-all;text-align:right;min-width:0}}.g2-sel-section{padding:9px 13px;border-top:1px solid var(--graph-divider)}.g2-sel-section-label{font-family:inherit;font-weight:600;font-size:11px;line-height:1;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);opacity:.85;margin-bottom:5px}.g2-sel-section-empty{color:var(--muted);opacity:.55;font-size:11px;font-style:italic}.g2-sel-jumps{padding:11px 13px;display:flex;gap:5px;flex-wrap:wrap;border-top:1px solid var(--graph-divider)}.g2-sel-jump{background:var(--surface-active);border:1px solid var(--border);color:var(--accent);border-radius:4px;padding:2px 8px;font-family:inherit;font-weight:500;font-size:11px;line-height:1.3;&:hover{border-color:var(--accent)}}.g2-sel-file-list{list-style:none;margin:0;padding:0;max-height:110px;overflow:hidden auto;-webkit-app-region:no-drag;app-region:no-drag;&::-webkit-scrollbar{width:4px}&::-webkit-scrollbar-thumb{background:var(--border);border-radius:2px}& li{padding:0}}.g2-sel-file-link{display:flex;align-items:center;gap:6px;width:100%;background:transparent;border:0;border-radius:3px;padding:3px 6px;font:400 11px/1.4 ui-monospace,SFMono-Regular,Menlo,Monaco,monospace;color:var(--accent);text-align:left;&:hover{background:var(--graph-hover-bg)}.g2-sel-file-dot{width:7px;height:7px;border-radius:50%;flex-shrink:0}.g2-sel-file-path{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}}.g2-empty-state{background:var(--graph-hover-bg);border:1px dashed var(--border);border-radius:8px;padding:18px 14px;text-align:center;color:var(--muted);font-size:11px;line-height:1.5;& strong{color:var(--text);display:block;margin-bottom:4px;font-weight:500}}.g2-dist-bar{width:100%;height:5px;border-radius:3px;overflow:hidden;display:flex;background:var(--surface-active);margin-bottom:8px;>span{display:block;height:100%}}.g2-dist-list{display:flex;flex-direction:column;gap:2px;flex:1 1 0;min-height:0;overflow-y:auto;overscroll-behavior:none;-webkit-app-region:no-drag;app-region:no-drag;scrollbar-gutter:stable;scrollbar-width:thin;scrollbar-color:var(--border) transparent;&::-webkit-scrollbar{width:5px}&::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}}.g2-dist-empty{color:var(--muted);opacity:.55;font-size:10px;font-style:italic;padding:6px 0;text-align:center}.g2-dist-item{display:grid;grid-template-columns:8px 1fr auto auto;gap:8px;align-items:center;font-size:10px;padding:4px 6px;margin:0 -6px;background:transparent;border:0;border-radius:4px;font-family:inherit;text-align:left;width:calc(100% + 12px);&:hover{background:var(--graph-hover-bg)}&.on{background:var(--surface-active);.g2-dist-name{color:var(--accent)}}.g2-dist-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}.g2-dist-name{color:var(--muted);font-family:ui-monospace,monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.g2-dist-count{font-family:ui-monospace,monospace;color:var(--text)}.g2-dist-pct{font-family:ui-monospace,monospace;color:var(--muted);width:36px;text-align:right;opacity:.85}}@media print{:host{display:none!important}}
|
|
2
|
+
`;var Ft=`.tree-count-chips{display:inline-flex;gap:.25rem;flex-wrap:wrap}.tree-count-chip{display:inline-block;font-size:.65rem;font-weight:600;text-transform:uppercase;letter-spacing:.03em;padding:.1rem .4rem;border-radius:3px;line-height:1.3;&.critical{background:var(--critical);color:#fff}&.high{background:var(--high);color:#fff}&.medium{background:var(--medium);color:#000}&.low{background:var(--low);color:#000}&.high_bug{background:var(--high-bug);color:#fff}&.bug{background:var(--bug);color:#fff}&.informational{background:var(--info);color:#fff}}
|
|
3
|
+
`;var Ht=`.toolbar{display:flex;flex-direction:column;gap:.5rem;margin-bottom:1rem;padding:.6rem .75rem;background:var(--surface);backdrop-filter:var(--glass-blur);border:1px solid var(--border);border-radius:6px;box-shadow:var(--shadow-glass);font-size:.825rem;& label{color:var(--muted);margin-right:.15rem}& select{height:30px;box-sizing:border-box;background:var(--bg);color:var(--text);border:1px solid var(--border);border-radius:4px;padding:.25rem .4rem;font-size:.8rem;&:focus{border-color:var(--accent);outline:none}}& select.sort-select{padding:.3rem 1.7rem .3rem .55rem;min-width:8.5rem;font-weight:500;appearance:none;-webkit-appearance:none;background:transparent}:is(repo-filter,findings-sort){position:relative;display:inline-block;&:after{content:"";position:absolute;right:.7rem;top:50%;width:.35rem;height:.35rem;border-right:1.5px solid var(--muted);border-bottom:1.5px solid var(--muted);transform:translateY(-70%) rotate(45deg);pointer-events:none}}& analyzer-select{position:relative;display:inline-block}.analyzer-btn{display:inline-flex;align-items:center;gap:.45rem;height:30px;box-sizing:border-box;padding:.3rem .55rem;min-width:8.5rem;background:transparent;color:var(--text);border:1px solid var(--border);border-radius:4px;font-family:inherit;font-size:.8rem;font-weight:500;&:hover{border-color:var(--accent)}&:focus-visible{border-color:var(--accent);outline:none}&.active{color:var(--accent)}.analyzer-btn-label{flex:1;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:18rem}& svg{color:var(--muted);flex-shrink:0}}& range-slider{color:var(--accent);margin:0 .25rem}.conf-vals{color:var(--text);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.72rem;font-variant-numeric:tabular-nums;.dash{color:var(--muted);margin:0 .15rem}}& conf-filter{display:inline-flex;align-items:center;height:30px;box-sizing:border-box;padding:0 .55rem;gap:.5rem;background:transparent;border:1px solid var(--border);border-radius:4px;.conf-range-label{color:var(--muted);font-size:.7rem;font-weight:500;letter-spacing:.04em}& range-slider{margin:0}}& input[type=text]{background:var(--bg);color:var(--text);border:1px solid var(--border);border-radius:4px;padding:.25rem .4rem;font-size:.8rem;flex:1;min-width:8rem;&:focus{border-color:var(--accent);outline:none}}.sep{border-left:1px solid var(--border);height:1.2rem}.result-count{color:var(--muted);margin-left:auto}.checkbox-label{display:inline-flex;align-items:center;gap:.25rem;color:var(--muted);& input{margin:0}}}.analyzer-menu[popover]{position:fixed;inset:auto;margin:0;align-items:stretch;gap:.35rem;padding:.3rem;background:var(--bg);border:1px solid var(--border);border-radius:6px;box-shadow:0 4px 12px #00000040;font-size:.825rem;-webkit-app-region:no-drag;app-region:no-drag}.analyzer-menu[popover]:not(:popover-open){display:none}.analyzer-menu[popover]:popover-open{display:flex}.analyzer-menu-sep{border-left:1px solid var(--border)}.analyzer-menu-col{display:flex;flex-direction:column;gap:1px;min-width:9rem;max-height:60vh;overflow-y:auto}.analyzer-menu-head{padding:.25rem .5rem .2rem;color:var(--muted);font-size:.68rem;font-weight:600;letter-spacing:.05em;text-transform:uppercase}.analyzer-menu-item{display:flex;align-items:center;gap:.45rem;background:transparent;border:0;border-radius:3px;padding:.3rem .5rem;color:var(--text);text-align:left;font-family:inherit;font-size:.78rem;&:before{content:"";width:.8rem;flex-shrink:0}&.active:before{content:"\\2713";color:var(--accent)}&:hover{background:var(--surface)}&.zero{opacity:.45}.analyzer-menu-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:16rem}.analyzer-menu-count{color:var(--muted);font-size:.7rem;font-weight:600;font-variant-numeric:tabular-nums}}.trash-btn{height:30px;box-sizing:border-box;background:var(--bg);color:var(--text);border:1px solid var(--border);border-radius:4px;padding:.25rem .55rem;font-size:.8rem;font-family:inherit;&:hover{border-color:var(--accent)}&.active{border-color:var(--critical);color:var(--critical)}}.toolbar .trash-btn{margin-left:auto}triage-selector,slide-triage-tabs{display:inline-flex;height:30px;box-sizing:border-box;border:1px solid var(--border);border-radius:4px;overflow:hidden}.toolbar triage-selector{margin-left:auto}triage-selector.is-empty{display:none}.triage-state-btn{background:transparent;border:none;color:var(--muted);padding:0 .55rem;display:inline-flex;align-items:center;transition:background .12s,color .12s;font-family:inherit;font-size:.8rem;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}&.active{background:var(--surface-active)}}.triage-state-btn.active.triage-state-deleted{color:var(--critical)}.triage-state-btn.active.triage-state-fixed{color:var(--green, #4ade80)}.triage-state-btn.active.triage-state-inprogress{color:var(--warning, #d97706)}.triage-state-btn.active.triage-state-invalid{color:var(--muted)}.triage-state-btn.active.triage-state-ignored{color:var(--accent, #2563eb)}entity-search{display:contents}view-mode-buttons{display:inline-flex;height:30px;box-sizing:border-box;border:1px solid var(--border);border-radius:4px;overflow:hidden;.view-mode-btn{background:transparent;border:none;color:var(--muted);padding:.28rem .5rem;display:inline-flex;align-items:center;justify-content:center;transition:background .12s,color .12s;font-family:inherit;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}&.active{color:var(--accent);background:var(--surface-active)}& svg{display:block}}}source-filter{display:inline-flex;height:30px;box-sizing:border-box;border:1px solid var(--border);border-radius:4px;overflow:hidden;.source-chip{background:transparent;border:none;color:var(--muted);padding:0 .55rem;display:inline-flex;align-items:center;transition:background .12s,color .12s;font-family:inherit;font-size:.75rem;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}&.active{color:var(--accent);background:var(--surface-active)}}}annotation-filter{display:inline-flex;height:30px;box-sizing:border-box;border:1px solid var(--border);border-radius:4px;overflow:hidden;.annotation-chip{position:relative;background:transparent;border:none;color:var(--muted);padding:0 .45rem;display:inline-flex;align-items:center;transition:background .12s,color .12s;cursor:pointer;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}&.sel-with,&.sel-without{color:var(--accent);background:var(--surface-active)}&.sel-with .flag-cloth{fill:var(--accent)}&.sel-without:after{content:"";position:absolute;left:18%;right:18%;top:50%;height:1.5px;background:currentcolor;border-radius:1px;transform:rotate(-20deg);transform-origin:center;pointer-events:none}& svg{display:block}}}.toolbar-row{display:flex;gap:.75rem;flex-wrap:wrap;align-items:center}.search-row{display:inline-flex;align-items:center;gap:.65rem;flex:1 1 14rem;min-width:12rem}toolbar-search,.toolbar-search{display:inline-flex;align-items:center;gap:.5rem;flex:1;min-width:0;height:30px;box-sizing:border-box;padding:0 .65rem;background:var(--bg);border:1px solid var(--border);border-radius:6px;&:has(input:focus){border-color:var(--accent)}>svg{color:var(--muted);flex-shrink:0}&[kind] input[type=text],&.toolbar-search input[type=text]{flex:1;min-width:0;background:transparent;border:0;outline:none;color:var(--text);font:inherit;font-size:.8rem;padding:0;&:focus{border:0}&::placeholder{color:var(--muted)}&:focus::placeholder{color:transparent}&::-webkit-search-cancel-button{display:none}}}.search-negate-btn{flex-shrink:0;width:20px;height:20px;display:grid;place-items:center;background:transparent;color:var(--muted);border:0;border-radius:3px;padding:0;transition:background .12s,color .12s;& svg{width:13px;height:13px}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .08)}&.active{color:var(--accent);background:rgb(from var(--text) r g b / .1)}}@media(width<=1200px){.toolbar-row.sev-row .search-row{flex-basis:100%}}.findings-content.with-details .toolbar{max-width:1200px}severity-chips{display:inline-flex;height:30px;box-sizing:border-box;border:1px solid var(--border);border-radius:4px;overflow:hidden}.sev-chip{display:inline-flex;align-items:center;gap:.4rem;background:transparent;border:0;padding:0 .6rem;color:var(--muted);font-family:inherit;font-size:.8rem;transition:background .12s,color .12s;&:not(:last-child){border-right:1px solid var(--border)}&:hover{color:var(--text);background:rgb(from var(--text) r g b / .06)}.sd{width:8px;height:8px;border-radius:2px;flex-shrink:0;background:currentcolor}.n{align-self:flex-start;margin:1px -5px 0;color:var(--muted);font-variant-numeric:tabular-nums;font-size:8.5px;font-weight:600;background:var(--bg);border-radius:999px;padding:0 3px;min-width:11px;text-align:center;line-height:11px}&.active{color:var(--text);.n{color:var(--text)}}&.critical .sd{background:var(--critical)}&.high .sd{background:var(--high)}&.medium .sd{background:var(--medium)}&.low .sd{background:var(--low)}&.high_bug .sd{background:var(--high-bug)}&.bug .sd{background:var(--bug)}&.informational .sd{background:var(--info)}&.critical.active{background:rgb(from var(--critical) r g b / .25)}&.high.active{background:rgb(from var(--high) r g b / .25)}&.medium.active{background:rgb(from var(--medium) r g b / .25)}&.low.active{background:rgb(from var(--low) r g b / .25)}&.high_bug.active{background:rgb(from var(--high-bug) r g b / .25)}&.bug.active{background:rgb(from var(--bug) r g b / .25)}&.informational.active{background:rgb(from var(--info) r g b / .25)}}triage-filter{display:inline-flex;align-items:center;background:var(--surface);border:1px solid var(--border);border-radius:6px;padding:3px;height:30px;gap:1px;& button{width:22px;height:22px;background:transparent;border:0;border-radius:4px;padding:0;display:grid;place-items:center;position:relative;transition:background .12s;&:hover{background:rgb(from var(--text) r g b / .06)}&.active{background:rgb(from var(--text) r g b / .08);box-shadow:0 0 0 1px var(--border)}}.td{width:12px;height:12px;border-radius:50%;border:1.5px solid currentcolor;background:transparent;transition:background .12s}& button.active .td{background:currentcolor}.td.none{border-style:dashed;color:var(--muted)}.td.r{color:#fc5855}.td.b{color:#30aff8}.td.g{color:#68c36d}.td.x{color:#6e7278}.count{position:absolute;top:-2px;right:-2px;background:var(--bg);color:var(--muted);font-size:8.5px;font-weight:600;border-radius:999px;padding:0 3px;min-width:11px;text-align:center;line-height:11px;font-variant-numeric:tabular-nums}}
|
|
4
|
+
`;var ke=["critical","high","medium","low","high_bug","bug","informational"],oo="node_modules";function dt(){return oo}function et(t){return typeof t!="number"||!Number.isFinite(t)?null:`${t.toLocaleString()} B`}function no(){return{showAll:!1,splitOwnDirs:!1,packagesView:!1,selected:null,focusedPkg:null,topPkgsTab:"issues",edgeOpacity:.22,nodeSize:1,showLabels:!1,selectedSeverities:new Set,selectedColors:new Set,pathFilter:"",hidden:new Set,solo:null,graphState:null,layoutCache:null}}var _e=no(),y=new Proxy(_e,{get(t,o){return _e[o]},set(t,o,s){return _e[o]=s,!0},has(t,o){return o in _e},deleteProperty(t,o){return delete _e[o]},ownKeys(){return Reflect.ownKeys(_e)},getOwnPropertyDescriptor(t,o){return Object.getOwnPropertyDescriptor(_e,o)}});function It(){y.graphState?._cleanup&&y.graphState._cleanup(),y.graphState=null}function ro(t){t&&(_e=t)}function ft(t){if(!t)return null;let o=dt()==="node_modules"?/^(?:.*\/)?node_modules\/(@[^/]+\/[^/]+|[^/]+)/u:/^(?:.*\/)?dependencies\/(@[^/]+\/[^/]+|[^/]+)/u,s=t.match(o);if(s)return s[1];let l=t.indexOf("/");return l>0?t.slice(0,l):"/"}var so=["#4e9af1","#f28e2b","#59a14f","#e15759","#76b7b2","#edc948","#b07aa1","#ff9da7","#9c755f","#5cd1e5","#f1ce63","#d37295","#a0cbe8","#86bcb6","#8cd17d","#b6992d","#499894","#e15759","#e879c7","#d4a6c8"],At=["#2f8aef","#d2691e","#2ea043","#e63946","#2e9a92","#b88817","#9560e8","#d24a9c","#8a5d40","#0891b2","#a07a14","#c14e8e","#1f7ad0","#549b94","#3fb95f","#a07a14","#2a8278","#cb2c40","#c026d3","#965f93"];function io(){if(typeof document>"u")return!1;let t=document.body?.classList;return!!t&&(t.contains("theme-light")||t.contains("theme-pink"))}var gt=new Map;function ne(t){let o=io()?At:so,l=`${o===At?"l":"d"}:${t??"__own__"}`;if(gt.has(l))return gt.get(l);let k=t??"__own__",x=0;for(let M of k)x=x*37+M.codePointAt(0)|0;let c=((x%o.length+o.length)%o.length*7+3)%o.length,v=o[c];return gt.set(l,v),v}function Bt(t){if(!t)return 0;let o=0;for(let s of ke)o+=t[s]??0;return o}function Tt(t){if(!t)return null;for(let o of ke)if((t[o]??0)>0)return o;return null}function Et(t,o,s,l,k,x,h,c={}){let v=c.pkgOf??ft,M=new Set(o),e=new Map,z=new Map;for(let g of o){let _=(t[g].imports??[]).filter(Y=>M.has(Y));e.set(g,_);for(let Y of _)z.has(Y)||z.set(Y,[]),z.get(Y).push(g)}let R=o.map(g=>{let _=s.get(g),Y=l?.get(g)??null,ee=Bt(_),B=v(g)??"__own__",J=Tt(_);return{id:g,file:g,pkg:B,x:0,y:0,deg:0,issue:J,totalIssues:ee,own:_,subtree:Y,size:typeof t[g]?.size=="number"?t[g].size:null,severitySet:k?.get(g)??null,colorSet:x?.get(g)??null,findings:h?.get(g)??null,isHub:!1,label:g.split("/").pop()??g}}),L=new Map(R.map(g=>[g.file,g])),d=new Map;for(let g of o)for(let _ of e.get(g)??[]){let[Y,ee]=g<_?[g,_]:[_,g],B=`${Y}\0${ee}`,J=d.get(B);if(!J){let T=L.get(Y),E=L.get(ee);if(!T||!E)continue;J={a:Y,b:ee,cross:T.pkg!==E.pkg,fromLo:!1,fromHi:!1},d.set(B,J),T.deg++,E.deg++}g===Y?J.fromLo=!0:J.fromHi=!0}let q=[...d.values()],a=new Map;for(let g=0;g<q.length;g++){let _=q[g];a.has(_.a)||a.set(_.a,[]),a.has(_.b)||a.set(_.b,[]),a.get(_.a).push(g),a.get(_.b).push(g)}let f=new Map;for(let g of R)f.set(g.pkg,(f.get(g.pkg)??0)+1);let A=[...f.entries()].toSorted((g,_)=>_[1]-g[1]).map(([g])=>g),H=new Map;for(let g of R)H.has(g.pkg)||H.set(g.pkg,[]),H.get(g.pkg).push(g);let U={files:o,nodes:R,nodeByFile:L,edges:q,adj:a,importsOf:e,importedBy:z,packages:A,pkgCount:f,byPkg:H};return ao(U),U}function ao(t){for(let o of t.nodes)o.isHub=!1;for(let o of t.edges)o.cross&&(o.fromLo&&(t.nodeByFile.get(o.b).isHub=!0),o.fromHi&&(t.nodeByFile.get(o.a).isHub=!0));for(let o of t.nodes){let s=t.importedBy.get(o.file);(!s||s.length===0)&&(o.isHub=!0)}}function Ot(t){let o=t.packages.map(c=>{let v=t.byPkg.get(c)??[],M={};for(let a of ke)M[a]=0;let e=new Set,z=new Set,R=[],L=0,d=0,q=!1;for(let a of v){if(L+=a.totalIssues,a.own)for(let f of ke)M[f]+=a.own[f]??0;if(a.severitySet)for(let f of a.severitySet)e.add(f);if(a.colorSet)for(let f of a.colorSet)z.add(f);typeof a.size=="number"&&(d+=a.size,q=!0),R.push(a.file)}return{file:c,pkg:c,label:c==="__own__"?"own source":c,fileCount:v.length,size:q?d:null,own:M,totalIssues:L,issue:Tt(M),severitySet:e.size>0?e:null,colorSet:z.size>0?z:null,pathText:R.join(`
|
|
5
|
+
`).toLowerCase(),isHub:!0,x:0,y:0,deg:0}}),s=new Map(o.map(c=>[c.pkg,c])),l=new Map;for(let c of t.edges){if(!c.cross)continue;let v=t.nodeByFile.get(c.a)?.pkg,M=t.nodeByFile.get(c.b)?.pkg;if(!v||!M||v===M)continue;let[e,z]=v<M?[v,M]:[M,v],R=`${e}\0${z}`,L=l.get(R);L||(L={a:e,b:z,cross:!0,count:0,fromLo:!1,fromHi:!1},l.set(R,L),s.get(e).deg++,s.get(z).deg++),L.count++;let d=v===e;c.fromLo&&(d?L.fromLo=!0:L.fromHi=!0),c.fromHi&&(d?L.fromHi=!0:L.fromLo=!0)}let k=[...l.values()],x=new Map;for(let c=0;c<k.length;c++){let v=k[c];x.has(v.a)||x.set(v.a,[]),x.has(v.b)||x.set(v.b,[]),x.get(v.a).push(c),x.get(v.b).push(c)}let h=new Map(o.map(c=>[c.pkg,[]]));for(let c of k)c.fromLo&&h.get(c.a).push(c.b),c.fromHi&&h.get(c.b).push(c.a);return{nodes:o,byPkg:s,nodeByFile:s,edges:k,adj:x,importsOf:h}}function pt(t,o){if(!o||o==="/"||o==="__own__")return t;for(let s of["node_modules","dependencies",dt()]){let l=s+"/"+o+"/",k=t.indexOf(l);if(k>=0)return t.slice(k+l.length)}return t.startsWith(o+"/")?t.slice(o.length+1):t}function qt(t,o){let s=o.extraTopRow,l=o.hideAllFiles??!1,k=o.triageCounts??{inprogress:0,fixed:0,invalid:0,deleted:0},x=o.triageStates??["inprogress","fixed","invalid","deleted"],h={};for(let f of ke)h[f]=0;for(let f of t.nodes)if(f.severitySet)for(let A of f.severitySet)h[A]!==void 0&&h[A]++;let c=ke.some(f=>h[f]>0||y.selectedSeverities.has(f)),v=["none","red","blue","green","gray"],M={none:0,red:0,blue:0,green:0,gray:0};for(let f of t.nodes)if(f.colorSet)for(let A of f.colorSet)M[A]!==void 0&&M[A]++;let e=v.some(f=>M[f]>0||y.selectedColors.has(f)),z=G`<triage-selector variant="graph" .counts="${k}" .states="${x}"></triage-selector>`,R=l?null:G`<button type="button" class="${Ce({"g2-topbar-toggle":!0,on:y.showAll})}" data-g2-show-all aria-pressed="${String(y.showAll)}"><span>All files</span><span class="g2-switch"></span></button>`,d=o.showSplitOwnDirs??!1?G`<button type="button" class="${Ce({"g2-topbar-toggle":!0,on:y.splitOwnDirs})}" data-g2-split-own aria-pressed="${String(y.splitOwnDirs)}" title="Split your own source into a group per top-level directory (off: one 'own source' group)"><span>Split dirs</span><span class="g2-switch"></span></button>`:null,a=o.showPackagesView??!1?G`<button type="button" class="${Ce({"g2-topbar-toggle":!0,on:y.packagesView})}" data-g2-packages-view aria-pressed="${String(y.packagesView)}" title="Show one node per package with aggregated import edges (off: one node per file)"><span>Packages</span><span class="g2-switch"></span></button>`:null;return G`<div class="graph2-topbar">${s?G`<div class="graph2-topbar-row graph2-topbar-row-extra toolbar-row">${s} ${R} ${d} ${a}<div class="g2-spacer"></div>${z}</div>`:null}<div class="graph2-topbar-row graph2-topbar-row-main toolbar-row sev-row">${c?G`<severity-chips .counts="${h}" .selected="${[...y.selectedSeverities]}" kind="graph"></severity-chips>`:null} ${e?G`<triage-filter .counts="${M}" .selected="${[...y.selectedColors]}" kind="graph"></triage-filter>`:null}<div class="toolbar-search g2-path-filter-wrap"><svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg> <input type="text" class="g2-path-filter" id="g2-path-filter" placeholder="filter path/package…" .value="${y.pathFilter}"> <button type="button" class="g2-path-filter-clear" id="g2-path-filter-clear" title="Clear filter" aria-label="Clear filter">✕</button></div>${s?null:R} ${s?null:d} ${s?null:a}<div class="g2-spacer"></div>${s?null:z} <button type="button" class="g2-icon-btn" id="g2-fullscreen" title="Toggle fullscreen">⛶</button></div></div>`}function lo(t,o){let s=t.split("/").filter(Boolean),l=o.split("/").filter(Boolean),k=0;for(;k<s.length&&k<l.length&&s[k]===l[k];)k++;let x=s.length-k,h=l.slice(k).join("/");return x===0?"./"+h:"../".repeat(x)+h}function co(t,o){if(!o&&o!=="")return t;let s=lo(o,t);return s.length<t.length?s:t}function ht(t,o,s,l){let k=s.length;if(k===0)return G`<div class="g2-sel-section"><div class="g2-sel-section-label">${o} (${k})</div><div class="g2-sel-section-empty">none</div></div>`;let x=s.map(h=>({file:h,display:co(h,l)}));return x.sort((h,c)=>h.display.localeCompare(c.display)),G`<div class="g2-sel-section"><div class="g2-sel-section-label">${o} (${k})</div><ul class="g2-sel-file-list">${x.map(({file:h,display:c})=>{let v=t.nodeByFile.get(h),M=v?ne(v.pkg):"#666";return G`<li><button type="button" class="g2-sel-file-link" data-g2-select="${h}" title="${h}"><span class="g2-sel-file-dot" style="${Qe({background:M})}"></span> <span class="g2-sel-file-path">${c}</span></button></li>`})}</ul></div>`}function tt(t){if(!t)return G`<div class="g2-sel-section-empty">none</div>`;let s=["critical","high","medium","low","high_bug","bug","informational"].filter(l=>(t[l]??0)>0);return s.length===0?G`<div class="g2-sel-section-empty">none</div>`:G`<div class="tree-count-chips">${s.map(l=>G`<span class="${`tree-count-chip ${l}`}">${t[l]} ${l.replaceAll("_"," ")}</span>`)}</div>`}function Dt(t){let o=0;for(let h of t.edges)h.cross&&o++;let s=t.edges.length-o,l=0;for(let h of t.nodes)l+=h.totalIssues;let k=t.nodes.length===0?"0.0":(t.edges.length*2/t.nodes.length).toFixed(1),x=y.focusedPkg==="__own__"?"own source":y.focusedPkg;return G`<main class="graph2-stage"><canvas id="g2-canvas"></canvas>${y.focusedPkg?G`<div class="g2-stage-overlay"><button type="button" class="g2-back-btn" id="g2-back-to-full" title="Back to the full graph">← ${x}</button></div>`:null}<div id="g2-focus-overlay-slot" class="g2-stage-overlay-tr"></div><div class="g2-stage-stats"><span><b>${t.nodes.length}</b> files</span> <span><b>${t.packages.length}</b> packages</span> <span><b>${t.edges.length}</b> edges (${s} intra · ${o} cross)</span> <span><b>${l}</b> issues</span> <span>avg degree <b>${k}</b></span></div><div class="g2-zoom-ctrl"><button id="g2-zoom-in" title="Zoom in">+</button><div class="g2-zoom-pct" id="g2-zoom-pct">100%</div><button id="g2-zoom-out" title="Zoom out">−</button> <button id="g2-zoom-fit" class="g2-zoom-fit-btn" title="Fit to view">fit</button></div><div class="g2-tooltip" id="g2-tooltip"></div></main>`}function Nt(t){let o=null;if(y.selected){let l=t.nodeByFile.get(y.selected);l&&(o=l.pkg)}else y.solo&&(o=y.solo);return!o||(t.pkgCount.get(o)??0)<=1||y.focusedPkg===o?null:G`<button type="button" class="g2-focus-pkg-btn" data-g2-focus-pkg="${o}" title="${`Focus on ${o==="__own__"?"own source":o}'s graph`}"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><path d="M8 4.6 L4 11 M8 4.6 L12 11 M5 11.4 L11 11.4" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/><circle cx="8" cy="3.6" r="2" fill="currentColor"/><circle cx="3.6" cy="11.4" r="2" fill="currentColor"/><circle cx="12.4" cy="11.4" r="2" fill="currentColor"/></svg></button>`}function Gt(){return G`<aside class="graph2-right"><div class="g2-panel-title">Selection</div><div id="g2-selection-area"></div><div id="g2-top-pkgs-block"></div></aside>`}function Vt(t){let o=y.showAll&&t.nodes.length>0&&t.nodes.every(k=>typeof k.size=="number"),s=t.nodes.some(k=>k.totalIssues>0),l=y.topPkgsTab;return l==="size"&&!o&&(l="files"),l==="issues"&&!s&&(l="files"),G`<div class="g2-panel-title g2-panel-title-row"><span>Packages</span><div class="g2-mini-tabs">${s?G`<button type="button" class="${Ce({"g2-mini-tab":!0,on:l==="issues"})}" data-g2-top-pkgs="issues">Issues</button>`:null} <button type="button" class="${Ce({"g2-mini-tab":!0,on:l==="files"})}" data-g2-top-pkgs="files">Files</button> ${o?G`<button type="button" class="${Ce({"g2-mini-tab":!0,on:l==="size"})}" data-g2-top-pkgs="size">Size</button>`:null}</div></div>${uo(t,l)}`}function jt(t,o={}){let s=y.selected;if(s){let l=t.nodeByFile.get(s);return l?fo(t,l,s,o):G`<div class="g2-empty-state"><strong>File not in current view</strong>Adjust filters or pick another file.</div>`}return y.solo?po(t,y.solo):G`<div class="g2-empty-state">Click a node or a package row to inspect.</div>`}function fo(t,o,s,l){let k=ne(o.pkg),x=o.pkg==="__own__"?"own source":o.pkg,h=pt(s,o.pkg),c=t.importedBy.get(s)??[],v=t.importsOf.get(s)??[],M=s.lastIndexOf("/"),e=M>=0?s.slice(0,M):"";return G`<div class="g2-selection-card"><div class="g2-sel-file-head"><div class="g2-sel-path">${h}</div><div class="g2-sel-pkg-row"><span class="g2-sel-dot" style="${Qe({"--dot":k,background:k})}"></span> <span class="g2-sel-pkg">${x}</span></div></div><div class="g2-sel-fullpath" title="${s}">${s}</div>${et(o.size)?G`<div class="g2-sel-size">${et(o.size)}</div>`:null}<div class="g2-sel-section"><div class="g2-sel-section-label">Own findings</div>${tt(o.own)}</div><div class="g2-sel-section"><div class="g2-sel-section-label">Subtree findings</div>${tt(o.subtree)}</div><div class="g2-sel-jumps">${o.totalIssues>0?G`<button type="button" class="g2-sel-jump" data-g2-jump-findings="${s}">Findings →</button>`:null} ${l.isBundleContext?o.origFile?G`<button type="button" class="g2-sel-jump" data-bundle-view-source="${o.origFile}">View source →</button>`:null:G`<button type="button" class="g2-sel-jump" data-g2-jump-file="${s}">Files →</button>`}</div>${ht(t,"Imported by",c,e)} ${ht(t,"Imports",v,e)}</div>`}function po(t,o){let s=t.nodes.filter(z=>z.pkg===o),l=s.length;if(l===0)return G`<div class="g2-empty-state"><strong>Package has no files in view</strong> Toggle "All files" to widen the file set, or pick another package.</div>`;let k=ne(o),x=o==="__own__"?"own source":o,h={};for(let z of ke)h[z]=0;for(let z of s)if(z.own)for(let R of ke)h[R]+=z.own[R]??0;let c=0,v=0;for(let z of t.edges){let R=t.nodeByFile.get(z.a),L=t.nodeByFile.get(z.b);!R||!L||(R.pkg===o&&L.pkg===o?v++:(R.pkg===o||L.pkg===o)&&c++)}let M=0;for(let z of s)z.isHub&&M++;let e=new Set;for(let z of s)for(let R of t.importedBy.get(z.file)??[]){let L=t.nodeByFile.get(R);L&&L.pkg!==o&&e.add(R)}return G`<div class="g2-selection-card"><div class="g2-sel-head"><span class="g2-sel-dot" style="${Qe({"--dot":k,background:k})}"></span> <span class="g2-sel-id">${x}</span> <span class="g2-sel-grp">package</span></div><div class="g2-sel-body"><div class="g2-sel-row"><span class="k">Files</span><span class="v">${l}</span></div><div class="g2-sel-row"><span class="k">Hubs</span><span class="v">${M}</span></div><div class="g2-sel-row"><span class="k">Intra edges</span><span class="v">${v}</span></div><div class="g2-sel-row"><span class="k">Cross edges</span><span class="v">${c}</span></div></div><div class="g2-sel-section"><div class="g2-sel-section-label">Findings</div>${tt(h)}</div>${ht(t,"Imported by",[...e])}</div>`}function uo(t,o){let s=t.nodes.length||1,l=o??y.topPkgsTab,k=y.selectedSeverities,x=y.selectedColors,h=k.size>0,c=x.size>0,v=h||c,M=new Map,e=new Map,z=0,R=0;for(let a of t.nodes){let f;if(v){if(f=0,a.findings)for(let A of a.findings)h&&!k.has(A.severity)||c&&!x.has(A.color)||f++}else f=a.totalIssues;M.set(a.pkg,(M.get(a.pkg)??0)+f),z+=f,typeof a.size=="number"&&(e.set(a.pkg,(e.get(a.pkg)??0)+a.size),R+=a.size)}let L;l==="issues"?L=t.packages.filter(a=>(M.get(a)??0)>0).toSorted((a,f)=>{let A=M.get(a)??0,H=M.get(f)??0;return H!==A?H-A:(t.pkgCount.get(f)??0)-(t.pkgCount.get(a)??0)}):l==="size"?L=t.packages.filter(a=>(e.get(a)??0)>0).toSorted((a,f)=>{let A=e.get(a)??0,H=e.get(f)??0;return H!==A?H-A:(t.pkgCount.get(f)??0)-(t.pkgCount.get(a)??0)}):L=[...t.packages].toSorted((a,f)=>{let A=t.pkgCount.get(a)??0,H=t.pkgCount.get(f)??0;return H!==A?H-A:(M.get(f)??0)-(M.get(a)??0)});let d=a=>l==="issues"?z>0?((M.get(a)??0)/z*100).toFixed(2):"0":l==="size"?R>0?((e.get(a)??0)/R*100).toFixed(2):"0":(t.pkgCount.get(a)/s*100).toFixed(2),q=l==="issues"?"No packages with issues":l==="size"?"No packages with size":"No packages";return G`<div class="g2-dist-bar">${t.packages.map(a=>{let f=ne(a);return G`<span style="${Qe({background:f,width:`${d(a)}%`})}"></span>`})}</div><div class="g2-dist-list">${L.length===0?G`<div class="g2-dist-empty">${q}</div>`:null} ${Rt(L,a=>a,a=>{let f=ne(a),A=t.pkgCount.get(a)??0,H=M.get(a)??0,U=e.get(a)??0,g=l==="issues"?H:l==="size"?et(U):A,_=l==="issues"?z>0?(H/z*100).toFixed(1):"0.0":l==="size"?R>0?(U/R*100).toFixed(1):"0.0":(A/s*100).toFixed(1),Y=a==="__own__"?"own source":a,ee=y.solo===a;return G`<button type="button" class="${Ce({"g2-dist-item":!0,on:ee})}" data-g2-pkg="${a}" title="${Y}"><span class="g2-dist-dot" style="${Qe({background:f})}"></span><span class="g2-dist-name">${Y}</span><span class="g2-dist-count">${g}</span><span class="g2-dist-pct">${_}%</span></button>`})}</div>`}var bt=class extends _t{static properties={graph:{attribute:!1},options:{attribute:!1}};static styles=[ct(Ht),ct(Ft),ct(Lt)];constructor(){super(),this.graph=null,this.options={}}render(){return this.graph?G`<div class="graph2-layout">${qt(this.graph,this.options)} ${Dt(this.graph)} ${Gt()}</div>`:G``}};customElements.define("graph-layout",bt);function go(t){let o=new Map;for(let[s,l]of t.importsOf){let k=t.nodeByFile.get(s);if(k)for(let x of l){let h=t.nodeByFile.get(x);h&&k.pkg!==h.pkg&&(o.set(k.pkg,(o.get(k.pkg)??0)+1),o.set(h.pkg,(o.get(h.pkg)??0)+1))}}return o}function ho(t){if(t.packages.length===0)return null;let o=new Set;for(let[s,l]of t.importedBy){let k=t.nodeByFile.get(s);if(k)for(let x of l){let h=t.nodeByFile.get(x);if(h&&h.pkg!==k.pkg){o.add(k.pkg);break}}}for(let s of t.packages)if(!o.has(s))return s;return null}var bo=5;function Wt(t,o){let s=new Map;for(let x of t.nodes)o.has(x.pkg)&&(s.has(x.pkg)||s.set(x.pkg,[]),s.get(x.pkg).push(x));for(let x of s.values())x.sort((h,c)=>h.isHub!==c.isHub?h.isHub?-1:1:c.deg-h.deg);let l=new Map,k=new Map;for(let[x,h]of o){let c=s.get(x);if(!c||c.length===0)continue;let v=c.length,M=0;for(let f of c)if(f.isHub)M++;else break;let e=M>0&&M<=bo,z=e?M:0,R=v-z,L=h.groupR,d=Array.from({length:v}),q=Array.from({length:v});for(let f=0;f<v;f++){let A=f*137.508*Math.PI/180,H;if(f<z)H=z<=1?0:Math.sqrt(f/(z-1))*.3*L;else{let U=f-z;H=R<=1?.4*L:(.4+Math.sqrt(U/(R-1))*.6)*L}d[f]=h.x+Math.cos(A)*H,q[f]=h.y+Math.sin(A)*H}let a=Array.from({length:v},()=>!1);for(let f=0;f<v;f++){let A=c[f],H,U;e&&A.isHub?(U=0,H=z):e?(U=z,H=v):(U=0,H=v);let g=0,_=0,Y=0,ee=t.importsOf.get(A.file);if(ee)for(let E of ee){let I=l.get(E);I!==void 0&&(g+=I,_+=k.get(E),Y++)}let B=t.importedBy.get(A.file);if(B)for(let E of B){let I=l.get(E);I!==void 0&&(g+=I,_+=k.get(E),Y++)}let J=!1;if(Y>0){g/=Y,_/=Y;let E=g-h.x,I=_-h.y;E*E+I*I>1&&(J=!0)}let T=-1;if(J){let E=1/0;for(let I=U;I<H;I++){if(a[I])continue;let p=d[I]-g,F=q[I]-_,W=p*p+F*F;W<E&&(E=W,T=I)}}else for(let E=U;E<H;E++)if(!a[E]){T=E;break}a[T]=!0,A.x=d[T],A.y=q[T],l.set(A.file,A.x),k.set(A.file,A.y)}}}function Ut(t,o,s){let l=o/2,k=s/2,x=Math.min(o,s)/2;if(t.packages.length===0)return;let c=ho(t),v=go(t),M=(c?t.packages.filter(p=>p!==c):[...t.packages]).toSorted((p,F)=>{let W=(v.get(F)??0)-(v.get(p)??0);return W!==0?W:(t.pkgCount.get(F)??0)-(t.pkgCount.get(p)??0)}),e=M.length,z;e<=0?z=0:e<=6?z=.65:e<=20?z=.82:z=.95;let R=Math.max(1,Math.sqrt(50/Math.max(1,e))),L=.22,d=.12,q=.04,a=new Map,f;if(c){let p=t.pkgCount.get(c)??0,F=Math.min(L,(.012+Math.sqrt(p)*.004)*R);f=Math.max(e<=6?.4:e<=20?.36:.34,F+d+q),a.set(c,{x:l,y:k,size:p,groupR:F*x})}else e<=1?f=0:e<=6?f=.4:e<=20?f=.32:f=.3;if(e===0){Wt(t,a);return}let A=new Map;for(let p of t.edges){if(!p.cross)continue;let F=t.nodeByFile.get(p.a)?.pkg,W=t.nodeByFile.get(p.b)?.pkg;if(!F||!W||F===W)continue;A.has(F)||A.set(F,new Map),A.has(W)||A.set(W,new Map);let te=A.get(F),re=A.get(W);te.set(W,(te.get(W)??0)+1),re.set(F,(re.get(F)??0)+1)}let H=Math.max(1,Math.min(10,Math.round(Math.sqrt(e)/1.2))),U=Array.from({length:H+1});for(let p=0;p<=H;p++)U[p]=Math.floor(p*p/(H*H)*e);U[H]=e;let g=.2,_=Array.from({length:H}),Y=Array.from({length:H});for(let p=0;p<H;p++){let F=U[p],W=U[p+1];_[p]=W-F;let te=0;for(let re=F;re<W;re++)te+=t.pkgCount.get(M[re])??0;Y[p]=te}let ee=Array.from({length:H});for(let p=0;p<H;p++){let F=(U[p]+U[p+1]-1)/2/Math.max(1,e-1);ee[p]=Math.sqrt(Math.max(0,F))}let B=Array.from({length:H});B[0]=ee[0];for(let p=1;p<H;p++){let F=_[p-1],W=Y[p-1],te=F>0?W/F:1,re=1+g*Math.sqrt(Math.max(0,te-1));B[p]=B[p-1]+(ee[p]-ee[p-1])*re}let J=Array.from({length:H});for(let p=0;p<H;p++)J[p]=B[p]-ee[p];let T=Array.from({length:e}),E=Array.from({length:e}),I=0;for(let p=0;p<e;p++){for(;I<H-1&&p>=U[I+1];)I++;let F=p*137.508%360*Math.PI/180,te=(e<=1?0:Math.sqrt(p/(e-1)))+J[I],re=e===1?c?f:0:f+te*(z-f);T[p]=l+Math.cos(F)*re*x,E[p]=k+Math.sin(F)*re*x}for(let p=0;p<H;p++){let F=U[p],W=U[p+1],te=W-F;if(te===0)continue;let re=Array.from({length:te},()=>!1);for(let Re=F;Re<W;Re++){let Le=M[Re],fe=A.get(Le),We=0,Ue=0,Ye=0;if(fe)for(let[pe,ie]of fe){let me=a.get(pe);me&&(We+=me.x*ie,Ue+=me.y*ie,Ye+=ie)}let we=!1;if(Ye>0){We/=Ye,Ue/=Ye;let pe=We-l,ie=Ue-k;pe*pe+ie*ie>1&&(we=!0)}let Ke=-1;if(we){let pe=1/0;for(let ie=0;ie<te;ie++){if(re[ie])continue;let me=F+ie,ze=T[me]-We,Xe=E[me]-Ue,nt=ze*ze+Xe*Xe;nt<pe&&(pe=nt,Ke=ie)}}else for(let pe=0;pe<te;pe++)if(!re[pe]){Ke=pe;break}re[Ke]=!0;let ot=F+Ke,it=t.pkgCount.get(Le)??0,ut=Math.min(d,(.012+Math.sqrt(it)*.004)*R);a.set(Le,{x:T[ot],y:E[ot],size:it,groupR:ut*x})}}Wt(t,a)}function mt(t,o,s){let l=o/2,k=s/2,x=Math.min(o,s)/2,h=t.nodes.length;if(h===0)return;let c=[...t.nodes].toSorted((v,M)=>M.deg-v.deg);for(let v=0;v<h;v++){let M=c[v],e=v*137.508%360*Math.PI/180,z=h<=1?0:Math.sqrt(v/(h-1));M.x=l+Math.cos(e)*z*.85*x,M.y=k+Math.sin(e)*z*.85*x}}function xt(t,o,s,l,{groupOf:k=ft}={}){let x=t.length,h=l||760,c=s||1100,v=Math.sqrt(c*h/Math.max(x,1))*1.1,M=g=>{let _=0;for(let Y of g)_=_*31+Y.codePointAt(0)|0;return _},e=Math.ceil(Math.sqrt(x*c/h)),z=Math.ceil(x/e),R=h/(z+1),L=c/(e+1),d=t.map((g,_)=>{let Y=_%e,ee=Math.floor(_/e),B=M(g);return{file:g,x:(Y+1)*L+(B%100-50)*L*.4,y:(ee+1)*R+((B>>7)%100-50)*R*.4,dx:0,dy:0}}),q=new Map(d.map((g,_)=>[g.file,_])),a=[];for(let g of t)for(let _ of o.get(g)??[])q.has(_)&&a.push([q.get(g),q.get(_)]);let f=new Map;for(let g=0;g<x;g++){let _=k(d[g].file)??"__own__";f.has(_)||f.set(_,[]),f.get(_).push(g)}let A=Math.min(500,Math.max(180,100+x*3)),H=Math.min(c,h)/6,U=.3;for(let g=0;g<A;g++){let _=H*Math.pow(U/H,g/A);for(let B of d)B.dx=0,B.dy=0;for(let B=0;B<x;B++)for(let J=B+1;J<x;J++){let T=d[B],E=d[J],I=T.x-E.x,p=T.y-E.y,F=Math.sqrt(I*I+p*p);if(F<.01){let te=M(T.file+E.file);I=(te%100-50)*.01||.5,p=((te>>7)%100-50)*.01||.5,F=Math.sqrt(I*I+p*p)}let W=v*v/F;T.dx+=I/F*W,T.dy+=p/F*W,E.dx-=I/F*W,E.dy-=p/F*W}for(let[B,J]of a){let T=d[B],E=d[J],I=T.x-E.x,p=T.y-E.y,F=Math.sqrt(I*I+p*p)||.01,W=F*F/v;T.dx-=I/F*W,T.dy-=p/F*W,E.dx+=I/F*W,E.dy+=p/F*W}let Y=.055*Math.min(1,_/(H*.3));for(let[,B]of f){if(B.length<2)continue;let J=0,T=0;for(let E of B)J+=d[E].x,T+=d[E].y;J/=B.length,T/=B.length;for(let E of B)d[E].dx+=(J-d[E].x)*Y,d[E].dy+=(T-d[E].y)*Y}let ee=50;for(let B of d){let J=Math.sqrt(B.dx*B.dx+B.dy*B.dy)||.01;B.x+=B.dx/J*Math.min(J,_),B.y+=B.dy/J*Math.min(J,_),B.x=Math.max(ee,Math.min(c-ee,B.x)),B.y=Math.max(ee,Math.min(h-ee,B.y))}}return d}var vt={critical:"#ff5470",high:"#ff9d4a",medium:"#f4d35e",low:"#67c2ff",high_bug:"#a06c3f",bug:"#7a6d62",informational:"#218bff"},yt={dark:{bg:"#0c0c0c",grid:"rgba(255, 255, 255, 0.022)",selectRing:"#ffffff",edgeIntra:"rgba(180, 195, 215, ALPHA)",hubRing:"rgba(255, 255, 255, ALPHA)",labelFill:"rgba(230, 233, 238, 0.78)",labelShadow:"rgba(12, 12, 12, 0.98)",labelOutline:"rgba(12, 12, 12, 0.9)",labelDefault:"rgba(200, 210, 225, 0.78)",labelHover:"rgba(230, 237, 243, 0.95)",labelSelected:"#fff"},light:{bg:"#f6f8fa",grid:"rgba(0, 0, 0, 0.04)",selectRing:"#0969da",edgeIntra:"rgba(50, 70, 100, ALPHA)",hubRing:"rgba(0, 0, 0, ALPHA)",labelFill:"rgba(40, 50, 70, 0.85)",labelShadow:"rgba(255, 255, 255, 0.95)",labelOutline:"rgba(255, 255, 255, 0.9)",labelDefault:"rgba(50, 60, 80, 0.85)",labelHover:"rgba(20, 25, 35, 0.95)",labelSelected:"#000"},pink:{bg:"#fff0f7",grid:"rgba(0, 0, 0, 0.04)",selectRing:"#0969da",edgeIntra:"rgba(50, 70, 100, ALPHA)",hubRing:"rgba(0, 0, 0, ALPHA)",labelFill:"rgba(40, 50, 70, 0.85)",labelShadow:"rgba(255, 255, 255, 0.95)",labelOutline:"rgba(255, 255, 255, 0.9)",labelDefault:"rgba(50, 60, 80, 0.85)",labelHover:"rgba(20, 25, 35, 0.95)",labelSelected:"#000"}};function mo(){let t=document.body.classList;return t.contains("theme-pink")?yt.pink:t.contains("theme-light")?yt.light:yt.dark}function be(t){return Math.max(0,Math.min(255,Math.round(t*255))).toString(16).padStart(2,"0")}function xo(t,o,s,l){let x=t.querySelector("graph-layout")?.shadowRoot;if(!x)return;let h=x.querySelector("#g2-canvas"),c=x.querySelector("#g2-tooltip"),v=x.querySelector(".graph2-stage"),M=x.querySelector("#g2-zoom-pct");if(!h)return;It();let e=h.getContext("2d"),z=window.devicePixelRatio||1,R=0,L=0,d={tx:0,ty:0,k:1},q=null,a=0,f=0,A=!0,H=!0,U=()=>y.packagesView&&(o.canPackagesView??!1)&&!y.focusedPkg,g=null;function _(){return g||(g=Ot(o)),g}function Y(r,b,u){if(r.nodes.length>50){mt(r,b,u);return}let w=xt(r.nodes.map(S=>S.pkg),r.importsOf,b,u,{groupOf:S=>S}),m=new Map(w.map(S=>[S.file,S]));for(let S of r.nodes){let $=m.get(S.pkg);$&&(S.x=$.x,S.y=$.y)}}function ee(){if(!A)return;let r=y.layoutCache,b=y.focusedPkg,u=U(),w=u?_().nodes:o.nodes;if(r&&r.files===o.files&&r.w===f&&r.h===a&&r.focused===b&&(r.pkgView??!1)===u)for(let m of w){let S=r.pos.get(m.file);S&&(m.x=S.x,m.y=S.y)}else{if(u)Y(_(),f,a);else if(b)if(o.nodes.length>50)mt(o,f,a);else{let S=xt(o.files,o.importsOf,f,a),$=new Map(S.map(j=>[j.file,j]));for(let j of o.nodes){let V=$.get(j.file);V&&(j.x=V.x,j.y=V.y)}}else Ut(o,f,a);let m=new Map;for(let S of w)m.set(S.file,{x:S.x,y:S.y});y.layoutCache={files:o.files,w:f,h:a,pos:m,focused:b,pkgView:u}}A=!1}function B(){let r=U()?_().nodes:o.nodes;if(r.length===0)return{k:1,tx:L/2,ty:R/2};let b=-1/0,u=-1/0,w=1/0,m=1/0;for(let i of r)i.x<w&&(w=i.x),i.y<m&&(m=i.y),i.x>b&&(b=i.x),i.y>u&&(u=i.y);let S=Math.max(20,u-m),$=Math.max(20,b-w),j=(w+b)/2,V=(m+u)/2,D=Math.min(L,R)*.1,K=Math.min((L-D*2)/$,(R-D*2)/S,4),n=Math.max(.05,K);return{k:n,tx:L/2-j*n,ty:R/2-V*n}}function J(){let r=B();d.k=r.k,d.tx=r.tx,d.ty=r.ty}function T(r,b){return[r*d.k+d.tx,b*d.k+d.ty]}function E(r,b){return[(r-d.tx)/d.k,(b-d.ty)/d.k]}function I(r){return!y.hidden.has(r.pkg)}function p(r){if(y.selectedSeverities.size>0){let u=r.severitySet;if(!u)return!0;let w=!1;for(let m of y.selectedSeverities)if(u.has(m)){w=!0;break}if(!w)return!0}if(y.selectedColors.size>0){let u=r.colorSet;if(!u)return!0;let w=!1;for(let m of y.selectedColors)if(u.has(m)){w=!0;break}if(!w)return!0}if(y.solo&&r.pkg!==y.solo&&!U())return!0;let b=y.pathFilter;if(b){let u=b.toLowerCase(),w=r.pathText?r.pathText.includes(u):r.file.toLowerCase().includes(u),m=r.pkg&&r.pkg.toLowerCase().includes(u),S=r.label&&r.label.toLowerCase().includes(u);if(!w&&!m&&!S)return!0}return!1}function F(r){let b=(r.isHub?4.9:3.5)*y.nodeSize,u=Math.max(.6,Math.min(1.6,d.k));return b*u}function W(){let r=v.getBoundingClientRect(),b=R,u=L;L=Math.max(80,r.width),R=Math.max(80,r.height),z=window.devicePixelRatio||1,h.width=L*z,h.height=R*z,h.style.width=L+"px",h.style.height=R+"px",e.setTransform(z,0,0,z,0,0),(f===0||a===0)&&(f=L,a=R,A=!0),ee();let w=u>0&&(Math.abs(L-u)/u>.15||Math.abs(R-b)/b>.15);(H||w)&&(J(),H=!1),fe()}let te=null,re=!0,Re=!1,Le=!1;function fe(){re=!0,!(Re||Le)&&(Re=!0,te=requestAnimationFrame(()=>{Re=!1,re&&!Le&&(re=!1,We())}))}function We(){let r=mo();e.fillStyle=r.bg,e.fillRect(0,0,L,R),Ue(r);let b=U(),u=b?_():o,w=b?y.solo:y.selected,m=w?u.nodeByFile.get(w):null,S=m?w:null;if(b&&u.nodes.length<=50){Ke(r);return}if(y.focusedPkg&&u.nodes.length<=50){Ye(r,S,m);return}for(let $ of u.edges){let j=u.nodeByFile.get($.a),V=u.nodeByFile.get($.b);if(!j||!V||!I(j)||!I(V))continue;let D=y.edgeOpacity;S?D=$.a===S||$.b===S?.85:y.edgeOpacity*.25:q&&($.a===q||$.b===q)&&(D=Math.min(.9,D+.5)),p(j)&&p(V)&&(D=Math.min(D,.04));let[K,n]=T(j.x,j.y),[i,C]=T(V.x,V.y);if($.cross){let O=e.createLinearGradient(K,n,i,C);O.addColorStop(0,ne(j.pkg)+be(D)),O.addColorStop(1,ne(V.pkg)+be(D)),e.strokeStyle=O,e.lineWidth=.85}else e.strokeStyle=r.edgeIntra.replace("ALPHA",String(D*.7)),e.lineWidth=.55;e.beginPath(),e.moveTo(K,n),e.lineTo(i,C),e.stroke()}for(let $ of u.nodes){if(!I($))continue;let j=$.file===q,V=$.file===S;if(!$.isHub&&!j&&!V||p($)&&!j&&!V)continue;let[D,K]=T($.x,$.y),i=F($)*(V?6:j?4.5:3),C=e.createRadialGradient(D,K,0,D,K,i),O=ne($.pkg);C.addColorStop(0,O+"55"),C.addColorStop(1,O+"00"),e.fillStyle=C,e.beginPath(),e.arc(D,K,i,0,Math.PI*2),e.fill()}for(let $ of u.nodes){if(!I($))continue;let[j,V]=T($.x,$.y),D=F($),K=1,n=S&&$.file===S;if(S&&!n&&(K=(u.adj.get(S)??[]).some(C=>{let O=u.edges[C];return O.a===$.file||O.b===$.file})?1:.25),!n&&p($)&&(K=Math.min(K,.1)),e.fillStyle=ne($.pkg)+be(K),e.beginPath(),e.arc(j,V,D,0,Math.PI*2),e.fill(),$.isHub&&(e.strokeStyle=r.hubRing.replace("ALPHA",String(.55*K)),e.lineWidth=.8,e.stroke()),$.issue){let i=vt[$.issue],C=D+($.issue==="critical"?4.2:$.issue==="high"?3.4:2.8),O=$.issue==="critical"?1.8:$.issue==="high"?1.5:$.issue==="medium"?1.3:1.1;e.strokeStyle=i,e.globalAlpha=K,e.lineWidth=O,e.beginPath(),e.arc(j,V,C,0,Math.PI*2),e.stroke(),e.globalAlpha=1}}if(d.k>1.4){let j=0;if(d.k<9&&!y.showLabels)for(let D of u.nodes){if(!I(D))continue;let[K,n]=T(D.x,D.y);if(!(K<0||K>L||n<0||n>R)&&(j++,j>=50))break}let V=d.k>=9||j<50;if(y.showLabels||V){e.font="10px ui-monospace, SFMono-Regular, Menlo, Monaco, monospace",e.fillStyle=r.labelFill,e.textAlign="left",e.textBaseline="middle";let D=11,K=2,n=250,i=(P,N)=>P>-n&&P<L+n&&N>-n&&N<R+n,C=[];for(let P of u.nodes){if(!I(P))continue;let[N,X]=T(P.x,P.y);if(!i(N,X))continue;let oe=F(P);C.push({file:P.file,x0:N-oe,x1:N+oe,y0:X-oe,y1:X+oe})}let O=[];for(let P of u.nodes){if(!I(P)||!P.isHub&&d.k<2.4)continue;let[N,X]=T(P.x,P.y);if(!i(N,X))continue;let oe=F(P),xe=N+oe+4,Se=X+1,Fe=e.measureText(P.label).width+K,He=P.file===S,Ie=P.file===q,Ae=He?3:Ie?2:P.isHub?1:0;O.push({file:P.file,n:P,tx:xe,ty:Se,prio:Ae,x0:xe-K,x1:xe+Fe,y0:Se-D/2,y1:Se+D/2})}O.sort((P,N)=>N.prio-P.prio);let Q=[],Z=(P,N)=>P.x0<N.x1&&N.x0<P.x1&&P.y0<N.y1&&N.y0<P.y1;for(let P of O){let N=!1;for(let X of C)if(X.file!==P.file&&Z(P,X)){N=!0;break}if(!N){for(let X of Q)if(Z(P,X)){N=!0;break}}N||Q.push(P)}for(let P of Q)e.fillText(P.n.label,P.tx,P.ty)}}if(m&&I(m)){let[$,j]=T(m.x,m.y),V=F(m);e.strokeStyle=r.selectRing,e.lineWidth=1.5,e.beginPath(),e.arc($,j,V+5,0,Math.PI*2),e.stroke()}M&&(M.textContent=`${Math.round(d.k*100)}%`)}function Ue(r){if(d.k<.4)return;let b=80,u=(d.tx%b+b)%b,w=(d.ty%b+b)%b;e.strokeStyle=r.grid,e.lineWidth=1,e.beginPath();for(let m=u;m<L;m+=b)e.moveTo(m,0),e.lineTo(m,R);for(let m=w;m<R;m+=b)e.moveTo(0,m),e.lineTo(L,m);e.stroke()}function Ye(r,b,u){let w=ne(y.focusedPkg),m=new Set;if(q){m.add(q);for(let n of o.adj.get(q)??[]){let i=o.edges[n];m.add(i.a),m.add(i.b)}}let S=n=>(n.isHub?6:4)*y.nodeSize;for(let n of o.edges){let i=o.nodeByFile.get(n.a),C=o.nodeByFile.get(n.b);if(!i||!C||!I(i)||!I(C))continue;let O=n.fromLo&&n.fromHi,Q=!O&&n.fromHi,Z=Q?C:i,P=Q?i:C,N=q&&(n.a===q||n.b===q),X=b&&(n.a===b||n.b===b),oe=(b||q)&&!N&&!X,xe=S(Z),Se=S(P),[Fe,He]=T(Z.x,Z.y),[Ie,Ae]=T(P.x,P.y),Be=Ie-Fe,Te=Ae-He,Ee=Math.sqrt(Be*Be+Te*Te)||1,Oe=Be/Ee,qe=Te/Ee,ae=Fe+Oe*(xe+1.5),le=He+qe*(xe+1.5),ce=Ie-Oe*(Se+3.5),de=Ae-qe*(Se+3.5),rt=Math.min(Ee*.15,30),ve=(ae+ce)/2-qe*rt,ye=(le+de)/2+Oe*rt;e.beginPath(),e.moveTo(ae,le),e.quadraticCurveTo(ve,ye,ce,de);let ue;if(X?ue=.9:N?ue=.85:oe?ue=.05:ue=Math.min(.85,y.edgeOpacity*3),e.strokeStyle=w+be(ue),e.lineWidth=X||N?1.5:.85,e.stroke(),oe)continue;let ge=Math.max(5,7),se=ge*.42,he=.9,Pe=2*(1-he)*(ve-ae)+2*he*(ce-ve),De=2*(1-he)*(ye-le)+2*he*(de-ye),Ze=Math.sqrt(Pe*Pe+De*De)||1,Ne=Pe/Ze,Me=De/Ze;if(e.beginPath(),e.moveTo(ce,de),e.lineTo(ce-Ne*ge+Me*se,de-Me*ge-Ne*se),e.lineTo(ce-Ne*ge-Me*se,de-Me*ge+Ne*se),e.closePath(),e.fillStyle=w+be(Math.min(1,ue+.15)),e.fill(),O){let at=1.8*(ve-ae)+.2*(ce-ve),Ge=2*(1-.1)*(ye-le)+2*.1*(de-ye),Je=Math.sqrt(at*at+Ge*Ge)||1,Ve=at/Je,$e=Ge/Je;e.beginPath(),e.moveTo(ae,le),e.lineTo(ae+Ve*ge-$e*se,le+$e*ge+Ve*se),e.lineTo(ae+Ve*ge+$e*se,le+$e*ge-Ve*se),e.closePath(),e.fill()}}for(let n of o.nodes){if(!I(n))continue;let[i,C]=T(n.x,n.y),O=S(n),Q=n.file===q,Z=n.file===b,P=(b||q)&&!m.has(n.file)&&!Z?.15:1;if(e.globalAlpha=P,Z||Q||n.isHub){let N=O*(Z?4:Q?3:2.4),X=e.createRadialGradient(i,C,O*.6,i,C,N);X.addColorStop(0,w+be(Z?.4:.25)),X.addColorStop(1,w+"00"),e.fillStyle=X,e.beginPath(),e.arc(i,C,N,0,Math.PI*2),e.fill()}if(e.fillStyle=w,e.beginPath(),e.arc(i,C,O,0,Math.PI*2),e.fill(),n.isHub&&(e.strokeStyle=r.hubRing.replace("ALPHA","0.55"),e.lineWidth=.9,e.stroke()),n.issue){let N=vt[n.issue],X=O+(n.issue==="critical"?4.2:n.issue==="high"?3.4:2.8),oe=n.issue==="critical"?1.8:n.issue==="high"?1.5:n.issue==="medium"?1.3:1.1;e.strokeStyle=N,e.lineWidth=oe,e.beginPath(),e.arc(i,C,X,0,Math.PI*2),e.stroke()}e.globalAlpha=1}e.font="600 11px ui-monospace, SFMono-Regular, Menlo, Monaco, monospace",e.textAlign="center",e.textBaseline="top",e.lineJoin="round";let $=13,j=2,V=[];for(let n of o.nodes){if(!I(n))continue;let[i,C]=T(n.x,n.y),O=S(n),Q=C+O+4,Z=e.measureText(n.label).width/2+j,P=n.file===b,N=n.file===q,X=P?3:N?2:n.isHub?1:0;V.push({n,sx:i,ty:Q,halfW:Z,isSel:P,isHov:N,prio:X,x0:i-Z,x1:i+Z,y0:Q,y1:Q+$})}V.sort((n,i)=>i.prio-n.prio);let D=[],K=(n,i)=>n.x0<i.x1&&i.x0<n.x1&&n.y0<i.y1&&i.y0<n.y1;for(let n of V){let i=!1;for(let C of D)if(K(n,C)){i=!0;break}i||D.push(n)}for(let n of D){let{n:i,sx:C,ty:O,isSel:Q,isHov:Z}=n,P=(b||q)&&!m.has(i.file)&&!Q?.2:1;e.globalAlpha=P,e.shadowColor=r.labelShadow,e.shadowBlur=4,e.strokeStyle=r.labelOutline,e.lineWidth=3,e.strokeText(i.label,C,O),e.shadowBlur=0,e.fillStyle=Q?r.labelSelected:Z?r.labelHover:r.labelDefault,e.fillText(i.label,C,O),e.globalAlpha=1}if(u&&I(u)){let[n,i]=T(u.x,u.y),C=S(u);e.strokeStyle=r.selectRing,e.lineWidth=1.8,e.beginPath(),e.arc(n,i,C+4,0,Math.PI*2),e.stroke()}M&&(M.textContent=`${Math.round(d.k*100)}%`)}function we(r){return Math.min(26,5+Math.sqrt(r.fileCount)*1.7)*y.nodeSize}function Ke(r){let b=_(),u=y.solo&&b.byPkg.has(y.solo)?y.solo:null,w=q??u,m=new Set;if(w){m.add(w);for(let n of b.edges)n.a===w?m.add(n.b):n.b===w&&m.add(n.a)}let S=n=>{if(n.pkg===u||n.pkg===q)return 1;let i=1;return w&&!m.has(n.pkg)&&(i=.2),p(n)&&(i=Math.min(i,.1)),i};for(let n of b.edges){let i=b.byPkg.get(n.a),C=b.byPkg.get(n.b);if(!i||!C||!I(i)||!I(C))continue;let O=n.fromLo&&n.fromHi,Q=!O&&n.fromHi,Z=Q?C:i,P=Q?i:C,N=w!==null&&(n.a===w||n.b===w),X=p(i)&&p(C),oe=w!==null&&!N||X,xe=we(Z),Se=we(P),[Fe,He]=T(Z.x,Z.y),[Ie,Ae]=T(P.x,P.y),Be=Ie-Fe,Te=Ae-He,Ee=Math.sqrt(Be*Be+Te*Te)||1,Oe=Be/Ee,qe=Te/Ee,ae=Fe+Oe*(xe+1.5),le=He+qe*(xe+1.5),ce=Ie-Oe*(Se+3.5),de=Ae-qe*(Se+3.5),rt=Math.min(Ee*.15,30),ve=(ae+ce)/2-qe*rt,ye=(le+de)/2+Oe*rt,ue;X?ue=.05:N?ue=.9:oe?ue=.06:ue=.5;let ge=e.createLinearGradient(ae,le,ce,de);if(ge.addColorStop(0,ne(Z.pkg)+be(ue)),ge.addColorStop(1,ne(P.pkg)+be(ue)),e.beginPath(),e.moveTo(ae,le),e.quadraticCurveTo(ve,ye,ce,de),e.strokeStyle=ge,e.lineWidth=Math.min(3.5,.8+Math.sqrt(n.count)*.3)*(N?1.3:1),e.stroke(),oe)continue;let se=7,he=se*.42,Pe=.9,De=2*(1-Pe)*(ve-ae)+2*Pe*(ce-ve),Ze=2*(1-Pe)*(ye-le)+2*Pe*(de-ye),Ne=Math.sqrt(De*De+Ze*Ze)||1,Me=De/Ne,st=Ze/Ne;if(e.beginPath(),e.moveTo(ce,de),e.lineTo(ce-Me*se+st*he,de-st*se-Me*he),e.lineTo(ce-Me*se-st*he,de-st*se+Me*he),e.closePath(),e.fillStyle=ne(P.pkg)+be(Math.min(1,ue+.15)),e.fill(),O){let Ge=1.8*(ve-ae)+.2*(ce-ve),Je=2*(1-.1)*(ye-le)+2*.1*(de-ye),Ve=Math.sqrt(Ge*Ge+Je*Je)||1,$e=Ge/Ve,lt=Je/Ve;e.beginPath(),e.moveTo(ae,le),e.lineTo(ae+$e*se-lt*he,le+lt*se+$e*he),e.lineTo(ae+$e*se+lt*he,le+lt*se-$e*he),e.closePath(),e.fillStyle=ne(Z.pkg)+be(Math.min(1,ue+.15)),e.fill()}}for(let n of b.nodes){if(!I(n))continue;let[i,C]=T(n.x,n.y),O=we(n),Q=n.pkg===q,Z=n.pkg===u,P=ne(n.pkg),N=S(n);if(Z||Q){let X=O*(Z?2.6:2.2),oe=e.createRadialGradient(i,C,O*.6,i,C,X);oe.addColorStop(0,P+be(Z?.4:.25)),oe.addColorStop(1,P+"00"),e.fillStyle=oe,e.beginPath(),e.arc(i,C,X,0,Math.PI*2),e.fill()}if(e.fillStyle=P+be(N),e.beginPath(),e.arc(i,C,O,0,Math.PI*2),e.fill(),n.issue){let X=vt[n.issue],oe=O+(n.issue==="critical"?4.2:n.issue==="high"?3.4:2.8),xe=n.issue==="critical"?1.8:n.issue==="high"?1.5:n.issue==="medium"?1.3:1.1;e.strokeStyle=X,e.globalAlpha=N,e.lineWidth=xe,e.beginPath(),e.arc(i,C,oe,0,Math.PI*2),e.stroke(),e.globalAlpha=1}}e.font="600 11px ui-monospace, SFMono-Regular, Menlo, Monaco, monospace",e.textAlign="center",e.textBaseline="top",e.lineJoin="round";let $=13,j=2,V=[];for(let n of b.nodes){if(!I(n))continue;let[i,C]=T(n.x,n.y),O=we(n),Q=C+O+4,Z=e.measureText(n.label).width/2+j,P=n.pkg===u,N=n.pkg===q,X=P?1/0:N?1e9:n.fileCount;V.push({p:n,sx:i,ty:Q,isSel:P,isHov:N,prio:X,x0:i-Z,x1:i+Z,y0:Q,y1:Q+$})}V.sort((n,i)=>i.prio-n.prio);let D=[],K=(n,i)=>n.x0<i.x1&&i.x0<n.x1&&n.y0<i.y1&&i.y0<n.y1;for(let n of V){let i=!1;for(let C of D)if(K(n,C)){i=!0;break}i||D.push(n)}for(let n of D){let{p:i,sx:C,ty:O,isSel:Q,isHov:Z}=n;e.globalAlpha=Math.max(.25,S(i)),e.shadowColor=r.labelShadow,e.shadowBlur=4,e.strokeStyle=r.labelOutline,e.lineWidth=3,e.strokeText(i.label,C,O),e.shadowBlur=0,e.fillStyle=Q?r.labelSelected:Z?r.labelHover:r.labelDefault,e.fillText(i.label,C,O),e.globalAlpha=1}if(u){let n=b.byPkg.get(u),[i,C]=T(n.x,n.y);e.strokeStyle=r.selectRing,e.lineWidth=1.8,e.beginPath(),e.arc(i,C,we(n)+4,0,Math.PI*2),e.stroke()}M&&(M.textContent=`${Math.round(d.k*100)}%`)}function ot(r,b){let u=U(),w=u?_():o,m=u&&w.nodes.length<=50,S=null,$=1/0,j=6;for(let V of w.nodes){if(!I(V))continue;let[D,K]=T(V.x,V.y),n=D-r,i=K-b,C=n*n+i*i,O=(m?we(V):F(V))+j;C<O*O&&C<$&&($=C,S=V)}return S}function it(r,b,u){if(!c)return;let w=ne(r.pkg),m=r.pkg==="__own__"?"own source":r.pkg,S=pt(r.file,r.pkg);je(G`<div class="g2-tt-path">${S}</div><div class="g2-tt-head"><span class="g2-tt-dot" style="${`background:${w}`}"></span> <span class="g2-tt-pkg">${m}</span></div>${r.totalIssues>0?tt(r.own):null}`,c),pe(b,u)}function ut(r,b,u){if(!c)return;let w=ne(r.pkg),m=et(r.size);je(G`<div class="g2-tt-path">${r.label}</div><div class="g2-tt-head"><span class="g2-tt-dot" style="${`background:${w}`}"></span> <span class="g2-tt-pkg">${r.fileCount} ${r.fileCount===1?"file":"files"}${m?` \xB7 ${m}`:""}</span></div>${r.totalIssues>0?tt(r.own):null}`,c),pe(b,u)}function pe(r,b){let u=v.getBoundingClientRect();c.classList.add("show");let w=c.offsetWidth,m=c.offsetHeight,S=r-u.left,$=b-u.top,j=u.width,V=u.height,D=12,K=S+D;K+w>j-4&&(K=S-w-D),K<4&&(K=4);let n=$+D;n+m>V-4&&(n=$-m-D),n<4&&(n=4),c.style.left=`${K}px`,c.style.top=`${n}px`}function ie(){c&&c.classList.remove("show")}let me=!1,ze=null,Xe=!1,nt=r=>{r.button===0&&(r.target.closest(".g2-stage-overlay, .g2-stage-overlay-tr, .g2-zoom-ctrl")||(me=!0,Xe=!1,ze={x:r.clientX,y:r.clientY,tx:d.tx,ty:d.ty}))},kt=r=>{let b=v.getBoundingClientRect(),u=r.clientX-b.left,w=r.clientY-b.top;if(me){let $=r.clientX-ze.x,j=r.clientY-ze.y;Math.abs($)+Math.abs(j)>3&&(Xe=!0),d.tx=ze.tx+$,d.ty=ze.ty+j,ie(),fe();return}let m=ot(u,w),S=q;q=m?.file??null,h.style.cursor=m?"default":"grab",m?U()?ut(m,r.clientX,r.clientY):it(m,r.clientX,r.clientY):S&&ie(),q!==S&&fe()},wt=r=>{if(me&&!Xe){let b=v.getBoundingClientRect(),u=r.clientX-b.left,w=r.clientY-b.top,m=ot(u,w);U()?(y.solo=m&&y.solo!==m.pkg?m.pkg:null,y.selected=null,s(),l?.()):(y.selected=m?.file??null,s()),fe()}me=!1},St=()=>{let r=q!==null;q=null,ie(),r&&fe()},Mt=r=>{r.preventDefault();let b=v.getBoundingClientRect(),u=r.clientX-b.left,w=r.clientY-b.top,m=Math.exp(-r.deltaY*.0015),S=B();if(m<1&&d.k<=S.k*1.0001){d.k=S.k;let D=Math.min(.4,(1-m)*3);d.tx+=(S.tx-d.tx)*D,d.ty+=(S.ty-d.ty)*D,fe();return}let[$,j]=E(u,w),V=Math.max(S.k,Math.min(9.99,d.k*m));d.k=V,d.tx=u-$*d.k,d.ty=w-j*d.k,fe()};v.addEventListener("mousedown",nt),window.addEventListener("mousemove",kt),window.addEventListener("mouseup",wt),v.addEventListener("mouseleave",St),v.addEventListener("wheel",Mt,{passive:!1});function $t(r){let b=B().k;r=Math.max(b,Math.min(9.99,r));let u=L/2,w=R/2,[m,S]=E(u,w);d.k=r,d.tx=u-m*d.k,d.ty=w-S*d.k,fe()}let Kt=x.querySelector("#g2-zoom-in"),Xt=x.querySelector("#g2-zoom-out"),Zt=x.querySelector("#g2-zoom-fit");Kt?.addEventListener("click",()=>$t(d.k*1.4)),Xt?.addEventListener("click",()=>$t(d.k/1.4)),Zt?.addEventListener("click",()=>{J(),fe()}),W();let zt=new ResizeObserver(()=>W());zt.observe(v);let Pt=new MutationObserver(r=>{for(let b of r){let u=(b.oldValue||"").includes("report-fullscreen"),w=document.body.classList.contains("report-fullscreen");if(u!==w){f=0,a=0,A=!0,H=!0,y.layoutCache=null,setTimeout(()=>W(),80);return}fe()}});Pt.observe(document.body,{attributes:!0,attributeFilter:["class"],attributeOldValue:!0}),fe(),y.graphState={requestDraw:fe,_cleanup:()=>{Le=!0,cancelAnimationFrame(te),zt.disconnect(),Pt.disconnect(),v.removeEventListener("mousedown",nt),window.removeEventListener("mousemove",kt),window.removeEventListener("mouseup",wt),v.removeEventListener("mouseleave",St),v.removeEventListener("wheel",Mt)}}}function cn(t,o){let s=document.querySelector("graph-layout")?.shadowRoot;if(!s)return;let l=Yt(t),k=s.querySelector("#g2-selection-area");k&&je(jt(l,o),k);let x=s.querySelector("#g2-focus-overlay-slot");x&&je(Nt(l),x)}function dn(t){let o=document.querySelector("graph-layout")?.shadowRoot;if(!o)return;let s=o.querySelector("#g2-top-pkgs-block");s&&je(Vt(Yt(t)),s)}function Yt(t){let o=Et(t.treeData,t.files,t.ownCounts,t.transitiveCounts,t.severitySets,t.colorSets,t.fileFindings,t.options);if(t.strippedToOrig)for(let s of o.nodes)s.origFile=t.strippedToOrig.get(s.file);return o.canPackagesView=t.canPackagesView??!1,o}export{ro as _swapGraph2Impl,xo as attachGraph2Interaction,Yt as buildGraphFromPrep,cn as refreshSidebar,dn as refreshTopPkgs};
|