@preventive/triage 1.0.0-alpha.15 → 1.0.0-alpha.16

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.
@@ -1 +1,83 @@
1
- async function a(t){let e;try{e=await fetch(t,{credentials:"same-origin",headers:{accept:"application/json"}})}catch{return null}if(!e.ok)return null;try{return await e.json()}catch{return null}}async function o(){let t=await a("/api/auth/session"),e=t?.user;return e==null||typeof e.login!="string"?null:{id:e.id,login:e.login,name:typeof e.name=="string"?e.name:null,avatarUrl:typeof e.avatarUrl=="string"?e.avatarUrl:null,role:typeof e.role=="string"?e.role:"none",csrfToken:typeof t.csrfToken=="string"?t.csrfToken:null}}async function i(){let e=(await a("/api/teams"))?.teams;return Array.isArray(e)?e.filter(n=>n!=null&&typeof n.id=="string"&&typeof n.name=="string").map(n=>({id:n.id,name:n.name,reports:Array.isArray(n.reports)?n.reports.filter(r=>r!=null&&typeof r.id=="string"&&typeof r.filename=="string").map(r=>({id:r.id,filename:r.filename})):[]})):[]}async function l(t){let e;try{e=await fetch(`/api/reports/${encodeURIComponent(t)}`,{credentials:"same-origin"})}catch{return null}if(!e.ok)return null;try{return await e.text()}catch{return null}}function s(t){t&&(location.href=t)}async function c(t){try{await fetch("/api/auth/logout",{method:"POST",credentials:"same-origin",headers:t?{"x-csrf-token":t}:{}})}catch{}location.reload()}export{l as fetchReport,s as login,c as logout,o as probeSession,i as probeTeams};
1
+ var U=["admin","manage","triage","view","none"];function fr(r){return typeof r=="string"&&U.includes(r)}function gr(r,e){let t=U.indexOf(r);return t!==-1&&t<=U.indexOf(e)}var br=["dependencies","security"],it={dependencies:"Dependencies",security:"Security"};var vr=Object.freeze([{id:"openai/gpt-6-astra-pro",efforts:["low","medium","high","xhigh","max"]},{id:"openai/gpt-6-astra",efforts:["low","medium","high","xhigh","max"]},{id:"openai/gpt-5.6-sol",efforts:["low","medium","high","xhigh","max"]},{id:"openai/gpt-5.6-terra",efforts:["low","medium","high","xhigh","max"]},{id:"openai/gpt-5.6-luna",efforts:["low","medium","high","xhigh","max"]},{id:"openai/gpt-5.5",efforts:["low","medium","high","xhigh"]},{id:"anthropic/claude-fable-5.1",efforts:["low","medium","high","xhigh","max"]},{id:"anthropic/claude-opus-5",efforts:["low","medium","high","xhigh","max"]},{id:"anthropic/claude-sonnet-5",efforts:["low","medium","high","xhigh","max"]},{id:"anthropic/claude-sonnet-4.6",efforts:["low","medium","high","xhigh","max"]},{id:"anthropic/claude-haiku-4.5",efforts:[]},{id:"moonshotai/kimi-k3",efforts:["low","high","max"]},{id:"google/gemini-3.8-flash",efforts:["low","medium","high","max"]},{id:"google/gemma-4-31b-it",efforts:["low","medium","high","max"]},{id:"qwen/qwen3.6-27b",efforts:["low","medium","high","max"]},{id:"nvidia/nemotron-3-super-120b-a12b",efforts:["low","medium","high","max"]},{id:"deepseek/deepseek-v4",efforts:["low","medium","high","max"]}]),_r="anthropic/claude-opus-5";var O=null,st=0;function ot(){return O?.user.role??null}function Yi(r){if(r!==null&&!fr(r))throw new TypeError(`Unknown managed preview role: ${r}. Expected ${U.join(", ")}.`);st++,O=r===null?null:{user:{id:`preview:${r}`,login:r,name:r[0].toUpperCase()+r.slice(1),role:r,avatarUrl:null,lastSeenAt:Date.now(),lastActivityAt:null},csrfToken:null}}function Ji(r,e){let t=new URL(r,"http://managed-preview.invalid").pathname,i=(e?.method??"GET").toUpperCase();if(i==="POST"&&t==="/api/auth/logout")return Response.json({ok:!0});if(i!=="GET")throw new Error("Changes are not saved in the managed UI preview");if(t==="/api/auth/session")return Response.json(O);if(t==="/api/teams")return Response.json({teams:[]});if(t.startsWith("/api/admin/")&&!gr(O.user.role,"manage"))return Response.json({error:"forbidden"},{status:403});if(["/api/admin/users","/api/admin/teams","/api/admin/repositories"].includes(t)&&O.user.role!=="admin")return Response.json({error:"forbidden"},{status:403});let s={"/api/admin/users":{users:[O.user]},"/api/admin/teams":{teams:[],users:[O.user],repos:[],permissions:br},"/api/admin/repositories":{repositories:[],total:0,connectedCount:0,installUrl:null,tokenMissing:!1},"/api/admin/reports":{reports:[],repos:[],maxBytes:10485760},"/api/admin/bundles":{bundles:[],repos:[],maxBytes:104857600},"/api/admin/history":{history:[]},"/api/admin/models":{models:vr,defaultModel:_r},"/api/admin/scan-results":{bundles:[],results:[]}};return Object.hasOwn(s,t)?Response.json(s[t]):Response.json({error:"not-found"},{status:404})}async function y(r,e){if(e?.signal?.throwIfAborted(),O)return Ji(r,e);let t=st,i=await fetch(r,e);if(t!==st)throw new DOMException("Managed session changed","AbortError");return i}var ze=globalThis,Te=ze.ShadowRoot&&(ze.ShadyCSS===void 0||ze.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,nt=Symbol(),yr=new WeakMap,pe=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==nt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(Te&&e===void 0){let i=t!==void 0&&t.length===1;i&&(e=yr.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&yr.set(t,e))}return e}toString(){return this.cssText}},wr=r=>new pe(typeof r=="string"?r:r+"",void 0,nt),x=(r,...e)=>{let t=r.length===1?r[0]:e.reduce((i,s,o)=>i+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+r[o+1],r[0]);return new pe(t,r,nt)},xr=(r,e)=>{if(Te)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),s=ze.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,r.appendChild(i)}},at=Te?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return wr(t)})(r):r;var{is:Xi,defineProperty:Qi,getOwnPropertyDescriptor:es,getOwnPropertyNames:ts,getOwnPropertySymbols:rs,getPrototypeOf:is}=Object,Ne=globalThis,$r=Ne.trustedTypes,ss=$r?$r.emptyScript:"",os=Ne.reactiveElementPolyfillSupport,ue=(r,e)=>r,lt={toAttribute(r,e){switch(e){case Boolean:r=r?ss:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},Sr=(r,e)=>!Xi(r,e),kr={attribute:!0,type:String,converter:lt,reflect:!1,useDefault:!1,hasChanged:Sr};Symbol.metadata??=Symbol("metadata"),Ne.litPropertyMetadata??=new WeakMap;var R=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=kr){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&Qi(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){let{get:s,set:o}=es(this.prototype,e)??{get(){return this[t]},set(n){this[t]=n}};return{get:s,set(n){let a=s?.call(this);o?.call(this,n),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??kr}static _$Ei(){if(this.hasOwnProperty(ue("elementProperties")))return;let e=is(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(ue("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ue("properties"))){let t=this.properties,i=[...ts(t),...rs(t)];for(let s of i)this.createProperty(s,t[s])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(let[t,i]of this.elementProperties){let s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let s of i)t.unshift(at(s))}else e!==void 0&&t.push(at(e));return t}static _$Eu(e,t){let i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return xr(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){let i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){let o=(i.converter?.toAttribute!==void 0?i.converter:lt).toAttribute(t,i.type);this._$Em=e,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(e,t){let i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){let o=i.getPropertyOptions(s),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:lt;this._$Em=s;let a=n.fromAttribute(t,o.type);this[s]=a??this._$Ej?.get(s)??a,this._$Em=null}}requestUpdate(e,t,i,s=!1,o){if(e!==void 0){let n=this.constructor;if(s===!1&&(o=this[e]),i??=n.getPropertyOptions(e),!((i.hasChanged??Sr)(o,t)||i.useDefault&&i.reflect&&o===this._$Ej?.get(e)&&!this.hasAttribute(n._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:o},n){i&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,n??t??this[e]),o!==!0||n!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[s,o]of this._$Ep)this[s]=o;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[s,o]of i){let{wrapped:n}=o,a=this[s];n!==!0||this._$AL.has(s)||a===void 0||this.C(s,void 0,o,a)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(t)):this._$EM()}catch(i){throw e=!1,this._$EM(),i}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(e){}firstUpdated(e){}};R.elementStyles=[],R.shadowRootOptions={mode:"open"},R[ue("elementProperties")]=new Map,R[ue("finalized")]=new Map,os?.({ReactiveElement:R}),(Ne.reactiveElementVersions??=[]).push("2.1.2");var dt=globalThis,Er=r=>r,Oe=dt.trustedTypes,Ar=Oe?Oe.createPolicy("lit-html",{createHTML:r=>r}):void 0,pt="$lit$",M=`lit$${Math.random().toFixed(9).slice(2)}$`,ut="?"+M,ns=`<${ut}>`,V=document,me=()=>V.createComment(""),fe=r=>r===null||typeof r!="object"&&typeof r!="function",ht=Array.isArray,zr=r=>ht(r)||typeof r?.[Symbol.iterator]=="function",ct=`[
2
+ \f\r]`,he=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Cr=/-->/g,Rr=/>/g,j=RegExp(`>|${ct}(?:([^\\s"'>=/]+)(${ct}*=${ct}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Mr=/'/g,Lr=/"/g,Tr=/^(?:script|style|textarea|title)$/i,mt=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),l=mt(1),In=mt(2),zn=mt(3),k=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),Ir=new WeakMap,F=V.createTreeWalker(V,129);function Nr(r,e){if(!ht(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ar!==void 0?Ar.createHTML(e):e}var Or=(r,e)=>{let t=r.length-1,i=[],s,o=e===2?"<svg>":e===3?"<math>":"",n=he;for(let a=0;a<t;a++){let c=r[a],d,f,p=-1,b=0;for(;b<c.length&&(n.lastIndex=b,f=n.exec(c),f!==null);)b=n.lastIndex,n===he?f[1]==="!--"?n=Cr:f[1]!==void 0?n=Rr:f[2]!==void 0?(Tr.test(f[2])&&(s=RegExp("</"+f[2],"g")),n=j):f[3]!==void 0&&(n=j):n===j?f[0]===">"?(n=s??he,p=-1):f[1]===void 0?p=-2:(p=n.lastIndex-f[2].length,d=f[1],n=f[3]===void 0?j:f[3]==='"'?Lr:Mr):n===Lr||n===Mr?n=j:n===Cr||n===Rr?n=he:(n=j,s=void 0);let h=n===j&&r[a+1].startsWith("/>")?" ":"";o+=n===he?c+ns:p>=0?(i.push(d),c.slice(0,p)+pt+c.slice(p)+M+h):c+M+(p===-2?a:h)}return[Nr(r,o+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},ge=class r{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let o=0,n=0,a=e.length-1,c=this.parts,[d,f]=Or(e,t);if(this.el=r.createElement(d,i),F.currentNode=this.el.content,t===2||t===3){let p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=F.nextNode())!==null&&c.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(let p of s.getAttributeNames())if(p.endsWith(pt)){let b=f[n++],h=s.getAttribute(p).split(M),g=/([.?@])?(.*)/.exec(b);c.push({type:1,index:o,name:g[2],strings:h,ctor:g[1]==="."?Pe:g[1]==="?"?De:g[1]==="@"?He:G}),s.removeAttribute(p)}else p.startsWith(M)&&(c.push({type:6,index:o}),s.removeAttribute(p));if(Tr.test(s.tagName)){let p=s.textContent.split(M),b=p.length-1;if(b>0){s.textContent=Oe?Oe.emptyScript:"";for(let h=0;h<b;h++)s.append(p[h],me()),F.nextNode(),c.push({type:2,index:++o});s.append(p[b],me())}}}else if(s.nodeType===8)if(s.data===ut)c.push({type:2,index:o});else{let p=-1;for(;(p=s.data.indexOf(M,p+1))!==-1;)c.push({type:7,index:o}),p+=M.length-1}o++}}static createElement(e,t){let i=V.createElement("template");return i.innerHTML=e,i}};function q(r,e,t=r,i){if(e===k)return e;let s=i!==void 0?t._$Co?.[i]:t._$Cl,o=fe(e)?void 0:e._$litDirective$;return s?.constructor!==o&&(s?._$AO?.(!1),o===void 0?s=void 0:(s=new o(r),s._$AT(r,t,i)),i!==void 0?(t._$Co??=[])[i]=s:t._$Cl=s),s!==void 0&&(e=q(r,s._$AS(r,e.values),s,i)),e}var Be=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:i}=this._$AD,s=(e?.creationScope??V).importNode(t,!0);F.currentNode=s;let o=F.nextNode(),n=0,a=0,c=i[0];for(;c!==void 0;){if(n===c.index){let d;c.type===2?d=new ie(o,o.nextSibling,this,e):c.type===1?d=new c.ctor(o,c.name,c.strings,this,e):c.type===6&&(d=new Ue(o,this,e)),this._$AV.push(d),c=i[++a]}n!==c?.index&&(o=F.nextNode(),n++)}return F.currentNode=V,s}p(e){let t=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}},ie=class r{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=u,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=q(this,e,t),fe(e)?e===u||e==null||e===""?(this._$AH!==u&&this._$AR(),this._$AH=u):e!==this._$AH&&e!==k&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):zr(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==u&&fe(this._$AH)?this._$AA.nextSibling.data=e:this.T(V.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=ge.createElement(Nr(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(t);else{let o=new Be(s,this),n=o.u(this.options);o.p(t),this.T(n),this._$AH=o}}_$AC(e){let t=Ir.get(e.strings);return t===void 0&&Ir.set(e.strings,t=new ge(e)),t}k(e){ht(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,i,s=0;for(let o of e)s===t.length?t.push(i=new r(this.O(me()),this.O(me()),this,this.options)):i=t[s],i._$AI(o),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let i=Er(e).nextSibling;Er(e).remove(),e=i}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},G=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,o){this.type=1,this._$AH=u,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=u}_$AI(e,t=this,i,s){let o=this.strings,n=!1;if(o===void 0)e=q(this,e,t,0),n=!fe(e)||e!==this._$AH&&e!==k,n&&(this._$AH=e);else{let a=e,c,d;for(e=o[0],c=0;c<o.length-1;c++)d=q(this,a[i+c],t,c),d===k&&(d=this._$AH[c]),n||=!fe(d)||d!==this._$AH[c],d===u?e=u:e!==u&&(e+=(d??"")+o[c+1]),this._$AH[c]=d}n&&!s&&this.j(e)}j(e){e===u?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},Pe=class extends G{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===u?void 0:e}},De=class extends G{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==u)}},He=class extends G{constructor(e,t,i,s,o){super(e,t,i,s,o),this.type=5}_$AI(e,t=this){if((e=q(this,e,t,0)??u)===k)return;let i=this._$AH,s=e===u&&i!==u||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,o=e!==u&&(i===u||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},Ue=class{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){q(this,e)}},Br={M:pt,P:M,A:ut,C:1,L:Or,R:Be,D:zr,V:q,I:ie,H:G,N:De,U:He,B:Pe,F:Ue},as=dt.litHtmlPolyfillSupport;as?.(ge,ie),(dt.litHtmlVersions??=[]).push("3.3.3");var Pr=(r,e,t)=>{let i=t?.renderBefore??e,s=i._$litPart$;if(s===void 0){let o=t?.renderBefore??null;i._$litPart$=s=new ie(e.insertBefore(me(),o),o,void 0,t??{})}return s._$AI(r),s};var ft=globalThis,w=class extends R{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Pr(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return k}};w._$litElement$=!0,w.finalized=!0,ft.litElementHydrateSupport?.({LitElement:w});var ls=ft.litElementPolyfillSupport;ls?.({LitElement:w});(ft.litElementVersions??=[]).push("4.2.2");var S={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},se=r=>(...e)=>({_$litDirective$:r,values:e}),B=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};var be=class extends B{constructor(e){if(super(e),this.it=u,e.type!==S.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===u||e==null)return this._t=void 0,this.it=e;if(e===k)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};be.directiveName="unsafeHTML",be.resultType=1;var L=se(be);var Dr="m5.875 10.154 1.376-.772.023-.067-.023-.037h-.067l-.23-.015-.787-.02-.681-.03-.661-.035-.166-.035-.156-.205.016-.103.14-.094.2.018.442.03.665.046.481.028.714.075h.113l.016-.047-.039-.028-.03-.028-.687-.466-.744-.492-.39-.284-.21-.143-.106-.135-.046-.294.19-.21.258.017.065.018.26.2.557.43.726.535.106.089.042-.03.006-.022-.048-.08-.395-.713-.422-.726-.187-.301-.05-.18a1 1 0 0 1-.03-.213l.218-.296.12-.039.29.039.123.106.18.413.293.65.453.884.133.262.07.242.027.075h.046v-.043l.038-.497.069-.611.067-.787.023-.221.11-.266.218-.143.17.081.14.2-.02.13-.083.54-.163.846-.106.567h.062l.07-.07.287-.382.482-.602.213-.239.248-.264.159-.125h.301l.221.329-.099.34-.31.393-.256.333-.369.496-.23.397.021.032.055-.006.832-.177.45-.081.537-.092.243.113.026.115-.096.236-.573.141-.673.135-1.003.237-.012.01.014.017.452.042.193.01h.473l.88.066.23.153.138.186-.023.141-.354.181-.478-.113-1.116-.266-.383-.096h-.053v.032l.32.312.584.528.731.68.037.168-.094.133-.099-.014-.643-.484-.248-.218-.561-.472H9.08v.05l.129.189.684 1.027.035.315-.05.103-.177.062-.194-.036-.4-.561-.413-.632-.333-.567-.041.023-.197 2.116-.092.108-.212.082-.177-.135-.094-.218.094-.43.113-.561.092-.447.083-.554.05-.184-.004-.013-.04.006-.418.574-.636.858-.503.539-.12.048-.21-.108.02-.193.117-.172.696-.886.42-.549.27-.317-.001-.046h-.016l-1.85 1.201-.328.042-.142-.132.018-.218.067-.071.556-.383Z",oe='<svg class="file-icon" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2 2 5v6l6 3 6-3V5L8 2Z"/><path d="M2 5l6 3 6-3"/><path d="M8 8v6"/></svg>';var Hr={default:{className:"brand-deepview",mark:'<path class="fg" d="M7.843 6.719c-1.605 0-2.926 1.292-3.477 1.947.466.58 1.872 2.024 3.496 2.024s2.907-1.292 3.486-2.005c-.627-.703-1.88-1.966-3.505-1.966m.019 3.857c-1.51 0-2.802-1.263-3.353-1.9.55-.617 1.814-1.852 3.334-1.852 1.51 0 2.698 1.12 3.335 1.852-.533.618-1.787 1.9-3.316 1.9m-.019-3.42c-.826 0-1.577.694-1.577 1.596 0 .789.599 1.577 1.577 1.577.893 0 1.587-.684 1.587-1.577-.01-.779-.627-1.596-1.587-1.596m0 3.069a1.476 1.476 0 0 1-1.482-1.473c0-.722.599-1.491 1.482-1.491.846 0 1.482.693 1.492 1.491 0 .808-.618 1.473-1.492 1.473m.01-2.727c-.637 0-1.264.532-1.264 1.244 0 .627.475 1.235 1.245 1.245.684 0 1.254-.522 1.254-1.244 0-.58-.475-1.236-1.235-1.245m-.02 2.403a1.167 1.167 0 0 1-1.149-1.159c0-.532.456-1.14 1.169-1.149.56 0 1.149.427 1.159 1.15 0 .636-.485 1.158-1.179 1.158m-.769-1.833c-.19.238-.275.494-.237.864l.74.057zm1.026-.294c-.295-.057-.665 0-.912.228l.323.607zm.133.047-.38.56.988.114c-.057-.275-.323-.579-.608-.674m-.124.741.456.912c.21-.209.352-.484.314-.836zm-1.225.504a.97.97 0 0 0 .57.617l.399-.551zm.713.664c.313.076.636.01.845-.161l-.295-.618zm-.637 1.55c0 .028-.028.066-.066.066h-.59c-.028 0-.066-.028-.066-.066s.029-.066.067-.066h.579c.048 0 .076.028.076.066m.712 0c0 .028-.028.066-.066.066h-.437c-.028 0-.066-.028-.066-.066s.028-.066.066-.066h.437c.038 0 .066.028.066.066m.666 0c0 .028-.029.066-.067.066h-.37c-.029 0-.067-.028-.067-.066s.029-.066.067-.066h.37c.038 0 .067.028.067.066m-1.672.351c0 .029-.029.067-.067.067h-.295c-.028 0-.066-.028-.066-.066 0-.029.029-.067.067-.067h.294c.038 0 .066.028.066.066m.694 0c0 .029-.028.067-.066.067h-.409c-.028 0-.066-.028-.066-.066 0-.029.028-.067.066-.067h.399c.038 0 .076.028.076.066m.732 0c0 .029-.029.067-.067.067h-.465c-.029 0-.067-.028-.067-.066 0-.029.029-.067.067-.067h.465c.038 0 .067.028.067.066m-1.093.371a.065.065 0 0 1-.067.066h-.627c-.028 0-.075-.028-.066-.066 0-.028.029-.066.067-.066h.627c.038 0 .066.028.066.066m.684 0a.065.065 0 0 1-.066.066h-.39c-.028 0-.076-.028-.066-.066 0-.028.028-.066.066-.066h.39c.038 0 .066.028.066.066M5.088 6.263c-.019-.105-.114-.19-.237-.19s-.257.104-.257.237.105.238.247.238c.105 0 .218-.076.238-.18h.864v.826l.095-.048V6.31c0-.028-.019-.057-.048-.057h-.902zm-.237.19c-.076 0-.143-.066-.143-.143s.066-.142.143-.142.142.066.142.143c.01.076-.066.142-.143.142m2.89-.323H6.38l.418-.475v-.332a.255.255 0 0 0 .218-.248c0-.123-.114-.256-.256-.256s-.266.114-.266.257c0 .123.095.228.209.247v.284l-.456.523v.893l.095-.047v-.742h1.396c.029 0 .067-.009.067-.057 0-.028-.019-.047-.067-.047m-1.13-1.054c0-.076.066-.152.152-.152s.152.066.152.151c0 .076-.066.152-.152.152s-.152-.066-.152-.152m-.836 5.264h-.874c-.019-.105-.114-.219-.247-.219s-.256.105-.256.257c0 .132.114.275.266.275.104 0 .218-.076.237-.19h.827v.608l-.257.285a.3.3 0 0 0-.095-.019c-.133 0-.256.105-.256.228 0 .133.104.238.237.238.124 0 .247-.105.247-.238a.23.23 0 0 0-.057-.152l.285-.304v-.712c0-.029-.019-.058-.057-.058m-1.121.219a.16.16 0 0 1-.152-.161c0-.077.066-.162.152-.162s.152.066.152.152-.066.171-.152.171m.713 1.14c-.076 0-.143-.066-.143-.143s.066-.133.143-.133.142.067.142.143c0 .066-.066.133-.143.133m5.472-1.377a.24.24 0 0 0-.237.208h-1.13c-.029 0-.038.02-.038.048v.712l-.323.39h-.029a.245.245 0 0 0-.247.247c0 .133.114.256.247.256s.247-.113.247-.256a.26.26 0 0 0-.123-.219l.313-.38v-.674h1.083c.019.105.114.2.238.2.133 0 .266-.105.266-.257 0-.133-.105-.276-.266-.276m-1.758 1.767a.15.15 0 0 1-.143-.152c0-.075.067-.142.143-.142s.152.066.152.143a.15.15 0 0 1-.152.151m1.758-1.33a.15.15 0 0 1-.143-.152.147.147 0 0 1 .294.001.15.15 0 0 1-.152.151M8.917 5.55h-.399a.075.075 0 0 1-.076-.076c0-.028.029-.066.067-.066h.418c.028 0 .066.028.066.066s-.038.076-.076.076m.742 0H9.22c-.038 0-.067-.028-.067-.076 0-.028.029-.066.067-.066h.437c.038 0 .066.028.066.066s-.028.076-.066.076m.883 0h-.598c-.029 0-.067-.028-.067-.076 0-.028.029-.066.067-.066h.598c.028 0 .066.028.066.066s-.028.076-.066.076m-1.282.4h-.741c-.038 0-.076-.029-.076-.067s.028-.076.066-.076h.75c.039 0 .067.038.067.076 0 .029-.028.067-.066.067m.797 0h-.503c-.038 0-.076-.029-.076-.067s.028-.066.066-.066h.513c.038 0 .067.028.067.066 0 .029-.029.067-.067.067m.476 0h-.19c-.039 0-.067-.029-.067-.067s.028-.066.066-.066h.2c.028 0 .066.028.066.066 0 .029-.028.067-.075.067m-1.682.398h-.332c-.039 0-.077-.028-.077-.066s.029-.066.067-.066h.342c.038 0 .076.028.076.066s-.028.066-.076.066m.789 0h-.494c-.038 0-.067-.028-.067-.066s.029-.066.067-.066h.494c.038 0 .066.028.066.066s-.028.066-.066.066m.893 0h-.599c-.038 0-.076-.028-.076-.066s.028-.066.066-.066h.618c.028 0 .066.028.066.066s-.028.066-.076.066m.418.305a.69.69 0 0 0-.674.712c0 .086.019.18.048.257l.085.066c-.028-.085-.057-.171-.057-.304 0-.285.228-.646.598-.646.295 0 .599.228.599.636a.58.58 0 0 1-.599.59.8.8 0 0 1-.237-.048l.123.114a.4.4 0 0 0 .114.01c.39 0 .684-.276.684-.666 0-.313-.266-.712-.684-.722m.353.552-.019-.01-.161.19-.143-.01-.057-.047-.019-.133.19-.2a.28.28 0 0 0-.361.077c-.076.095-.076.209-.038.351l-.247.304.171.152.266-.266c.142.038.285.019.38-.095a.31.31 0 0 0 .038-.313"/>'},"claude-security":{className:"brand-claude",mark:`<path class="fg" d="${Dr}"/>`},"codex-security":{className:"brand-codex",mark:'<path class="fg" d="M11.04 8.364a1.72 1.72 0 0 0-.152-1.432 1.8 1.8 0 0 0-1.925-.846 1.8 1.8 0 0 0-.778-.498 1.8 1.8 0 0 0-.927-.05 1.8 1.8 0 0 0-.827.414 1.77 1.77 0 0 0-.507.767 1.8 1.8 0 0 0-.683.297 1.75 1.75 0 0 0-.499.549 1.75 1.75 0 0 0 .22 2.07 1.72 1.72 0 0 0 .151 1.432 1.8 1.8 0 0 0 1.926.846 1.77 1.77 0 0 0 1.333.587c.78 0 1.47-.496 1.707-1.227a1.8 1.8 0 0 0 .684-.298 1.75 1.75 0 0 0 .499-.548 1.75 1.75 0 0 0-.222-2.063m-2.667 3.678a1.33 1.33 0 0 1-.851-.304l.042-.024 1.413-.804a.23.23 0 0 0 .116-.199V8.747l.597.34q.01.005.011.015v1.629a1.323 1.323 0 0 1-1.328 1.31m-2.857-1.203a1.3 1.3 0 0 1-.158-.879l.042.025 1.414.805a.23.23 0 0 0 .23 0l1.729-.982v.68a.02.02 0 0 1-.01.018l-1.431.814a1.34 1.34 0 0 1-1.816-.48m-.372-3.037a1.32 1.32 0 0 1 .7-.574v1.656a.22.22 0 0 0 .114.197l1.72.979-.598.34a.02.02 0 0 1-.021 0L5.63 9.587a1.304 1.304 0 0 1-.487-1.791zm4.907 1.125L8.327 7.94l.596-.34a.02.02 0 0 1 .02 0l1.43.814a1.3 1.3 0 0 1 .512.528 1.3 1.3 0 0 1-.118 1.4 1.33 1.33 0 0 1-.595.436V9.122a.23.23 0 0 0-.12-.195m.594-.881-.042-.025-1.411-.812a.23.23 0 0 0-.232 0l-1.727.983v-.68a.02.02 0 0 1 .008-.018l1.429-.813a1.34 1.34 0 0 1 1.425.061 1.3 1.3 0 0 1 .55 1.298zM6.908 9.252l-.597-.34a.02.02 0 0 1-.012-.016V7.271c0-.249.073-.493.209-.703s.329-.378.557-.483a1.35 1.35 0 0 1 1.415.18l-.042.023-1.413.804a.23.23 0 0 0-.116.2zm.324-.69.77-.438.77.438v.875l-.768.437-.77-.437z"/>'},deepsec:{className:"brand-vercel",mark:'<path class="fg" d="m8 5.97 3.5 6.062h-7Z"/>'},piolium:{className:"brand-piolium",mark:'<path class="fg" d="M8 6.4 5.6 7.2v2.3c0 1.6 1 2.7 2.4 3.3 1.4-.6 2.4-1.7 2.4-3.3V7.2Z"/>'}},cs={default:["#2563eb","#fff"],"claude-security":["#d97757","#fff"],"codex-security":["#fff","#000"],deepsec:["#000","#fff"],piolium:["#fbb829","#1c1b19"]},gt=Object.fromEntries(Object.entries(Hr).map(([r,{className:e,mark:t}])=>{let[i,s]=cs[r],o=r==="codex-security"||r==="deepsec"?` stroke="${s}" stroke-width=".5"`:"";return[r,`<svg class="file-icon ${e}" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><path class="bg" fill="${i}"${o} d="M3 2h6l4 4v8H3z"/><path fill="rgba(0,0,0,.18)" d="M9 2v4h4Z"/><g fill="${s}">${t}</g></svg>`]})),bt=Object.fromEntries(Object.entries(Hr).map(([r,{className:e,mark:t}])=>[r,`<span class="report-logo ${e}" aria-hidden="true"><svg viewBox="${r==="default"?"3.5 4 9 9":"4 5 8 8"}" width="14" height="14">${t}</svg></span>`]));var{I:ds}=Br,Ur=r=>r;var Fr=r=>r.strings===void 0,jr=()=>document.createComment(""),ne=(r,e,t)=>{let i=r._$AA.parentNode,s=e===void 0?r._$AB:e._$AA;if(t===void 0){let o=i.insertBefore(jr(),s),n=i.insertBefore(jr(),s);t=new ds(o,n,r,r.options)}else{let o=t._$AB.nextSibling,n=t._$AM,a=n!==r;if(a){let c;t._$AQ?.(r),t._$AM=r,t._$AP!==void 0&&(c=r._$AU)!==n._$AU&&t._$AP(c)}if(o!==s||a){let c=t._$AA;for(;c!==o;){let d=Ur(c).nextSibling;Ur(i).insertBefore(c,s),c=d}}}return t},P=(r,e,t=r)=>(r._$AI(e,t),r),ps={},je=(r,e=ps)=>r._$AH=e,Vr=r=>r._$AH,Fe=r=>{r._$AR(),r._$AA.remove()};var I=se(class extends B{constructor(r){if(super(r),r.type!==S.PROPERTY&&r.type!==S.ATTRIBUTE&&r.type!==S.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Fr(r))throw Error("`live` bindings can only contain a single expression")}render(r){return r}update(r,[e]){if(e===k||e===u)return e;let t=r.element,i=r.name;if(r.type===S.PROPERTY){if(e===t[i])return k}else if(r.type===S.BOOLEAN_ATTRIBUTE){if(!!e===t.hasAttribute(i))return k}else if(r.type===S.ATTRIBUTE&&t.getAttribute(i)===e+"")return k;return je(r),e}});var qr=(r,e,t)=>{let i=new Map;for(let s=e;s<=t;s++)i.set(r[s],s);return i},Ve=se(class extends B{constructor(r){if(super(r),r.type!==S.CHILD)throw Error("repeat() can only be used in text expressions")}dt(r,e,t){let i;t===void 0?t=e:e!==void 0&&(i=e);let s=[],o=[],n=0;for(let a of r)s[n]=i?i(a,n):n,o[n]=t(a,n),n++;return{values:o,keys:s}}render(r,e,t){return this.dt(r,e,t).values}update(r,[e,t,i]){let s=Vr(r),{values:o,keys:n}=this.dt(e,t,i);if(!Array.isArray(s))return this.ut=n,o;let a=this.ut??=[],c=[],d,f,p=0,b=s.length-1,h=0,g=o.length-1;for(;p<=b&&h<=g;)if(s[p]===null)p++;else if(s[b]===null)b--;else if(a[p]===n[h])c[h]=P(s[p],o[h]),p++,h++;else if(a[b]===n[g])c[g]=P(s[b],o[g]),b--,g--;else if(a[p]===n[g])c[g]=P(s[p],o[g]),ne(r,c[g+1],s[p]),p++,g--;else if(a[b]===n[h])c[h]=P(s[b],o[h]),ne(r,s[p],s[b]),b--,h++;else if(d===void 0&&(d=qr(n,h,g),f=qr(a,p,b)),d.has(a[p]))if(d.has(a[b])){let m=f.get(n[h]),v=m!==void 0?s[m]:null;if(v===null){let $=ne(r,s[p]);P($,o[h]),c[h]=$}else c[h]=P(v,o[h]),ne(r,s[p],v),s[m]=null;h++}else Fe(s[b]),b--;else Fe(s[p]),p++;for(;h<=g;){let m=ne(r,c[g+1]);P(m,o[h]),c[h++]=m}for(;p<=b;){let m=s[p++];m!==null&&Fe(m)}return this.ut=n,je(r,c),k}});var us=new Map([["openai/gpt-6-astra","GPT-6 Astra"],["openai/gpt-6-astra-pro","GPT-6 Astra Pro"],["openai/gpt-5.6-sol","GPT-5.6 Sol"],["openai/gpt-5.6-terra","GPT-5.6 Terra"],["openai/gpt-5.6-luna","GPT-5.6 Luna"],["anthropic/claude-fable-5.1","Claude Fable 5.1"],["anthropic/claude-opus-5","Claude Opus 5"],["anthropic/claude-sonnet-5","Claude Sonnet 5"],["moonshotai/kimi-k3","Kimi K3"],["z-ai/glm-5.3","GLM 5.3"],["qwen/qwen3.8-max","Qwen3.8 Max"],["deepseek/deepseek-v4.1-flash","DeepSeek V4.1 Flash"],["deepseek/deepseek-v4-pro","DeepSeek V4 Pro"]]),hs=new Map([["openai","OpenAI"],["anthropic","Anthropic"],["moonshotai","Moonshot AI"],["google","Google"],["nvidia","NVIDIA"],["qwen","Qwen"],["deepseek","DeepSeek"],["x-ai","xAI"],["z-ai","Z.ai"]]),ms=new Map([["gpt","GPT"],["gptoss","GPT OSS"],["oss","OSS"],["o","O"],["ai","AI"],["api","API"],["4o","4o"],["k3","K3"],["k4","K4"],["qwen","Qwen"],["kimi","Kimi"],["gemini","Gemini"],["claude","Claude"],["fable","Fable"],["opus","Opus"],["sonnet","Sonnet"],["astra","Astra"],["terra","Terra"],["luna","Luna"],["codex","Codex"],["deepseek","DeepSeek"],["nemotron","Nemotron"],["gemma","Gemma"]]);function Gr(r){let e=r.replace(/:free$/u,"").replaceAll("_","-").split("-").filter(Boolean),t=[];for(let s=0;s<e.length;s++){let o=e[s],n=e[s+1];if(/^\d+$/u.test(o)&&/^\d+$/u.test(n??"")){t.push(`${o}.${n}`),s++;continue}let a=ms.get(o.toLowerCase());t.push(a??(/^(?:[a-z]+\d+|\d+[a-z]+)$/iu.test(o)?o.toUpperCase():o[0]?.toUpperCase()+o.slice(1)))}return t.join(" ").replace(/^GPT (\d)/u,"GPT-$1")}function ve(r){return us.get(r)??Gr(r.includes("/")?r.slice(r.indexOf("/")+1):r)}function _e(r){let e=r.includes("/")?r.split("/")[0]:"other";return{key:e,name:hs.get(e)??(e==="other"?"Other":Gr(e))}}function ye(r){return r==="xhigh"?"Extra high":r?r[0].toUpperCase()+r.slice(1):"Unavailable"}function we(r){return r.efforts.includes("max")?"max":r.efforts.at(-1)??null}async function ae(r,e=fetch){let t=await e("/api/admin/models",{credentials:"same-origin",headers:{accept:"application/json"},signal:r});if(!t.ok)throw new Error(`HTTP ${t.status}`);let i=await t.json();return fs(i)}function fs(r){if(!Array.isArray(r?.models))throw new Error("No model catalogue returned");let e=r.models.filter(t=>typeof t?.id=="string"&&t.id.length>0).map(t=>({id:t.id,efforts:Array.isArray(t.efforts)?[...new Set(t.efforts.filter(i=>typeof i=="string"&&i.length>0))]:[]}));if(e.length===0)throw new Error("No models available");return{models:e,defaultModel:e.find(t=>t.id===r.defaultModel)?.id??e[0].id}}function vt(r){let e=new Map(r.map(i=>[i.id,i])),t=new Set;return r.flatMap(i=>{if(t.has(i.id))return[];let s=i.id.endsWith("-pro")?i.id.slice(0,-4):i.id,o=e.get(s),n=e.get(`${s}-pro`);return!/(?:^|\/)gpt-.+$/u.test(s)||s.endsWith("-pro")||!o||!n?[i]:(t.add(o.id),t.add(n.id),[{...o,pro:n}])})}function _t(r){return[...Map.groupBy(vt(r),t=>_e(t.id).key)].map(([t,i])=>({key:t,models:i}))}function Wr(r,e){if(r.length===0)return[];let t=Math.min(r.length,Math.max(1,e)),i=r.map(d=>d.models.length*2+3),s=i.reduce((d,f)=>d+f,0),o=Math.max(...i);for(;o<s;){let d=Math.floor((o+s)/2),f=0,p=1;for(let b of i)f+b>d&&(p++,f=0),f+=b;p>t?o=d+1:s=d}let n=[],a=[],c=0;for(let[d,f]of r.entries())a.length>0&&(c+i[d]>o||r.length-d===t-n.length-1)&&(n.push(a),a=[],c=0),a.push(f),c+=i[d];return n.push(a),n}var gs=l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m4 6 4 4 4-4"/></svg>`;function Kr(r){if(r==="google")return l`<svg class="google-mark" viewBox="0 0 24 24" aria-hidden="true"><path fill="#4285F4" d="M21.35 12.27c0-.79-.07-1.55-.2-2.27H12v4.3h5.24a4.48 4.48 0 0 1-1.94 2.94v2.45h3.15c1.85-1.7 2.9-4.2 2.9-7.42Z"/><path fill="#34A853" d="M12 21.8c2.64 0 4.86-.87 6.48-2.35l-3.15-2.45c-.87.58-1.98.92-3.33.92-2.56 0-4.73-1.73-5.51-4.06H3.24v2.52A9.8 9.8 0 0 0 12 21.8Z"/><path fill="#FBBC05" d="M6.49 13.86a5.9 5.9 0 0 1 0-3.72V7.62H3.24a9.8 9.8 0 0 0 0 8.76l3.25-2.52Z"/><path fill="#EA4335" d="M12 6.08c1.43 0 2.72.49 3.74 1.45l2.8-2.8C16.85 3.14 14.63 2.2 12 2.2a9.8 9.8 0 0 0-8.76 5.42l3.25 2.52C7.27 7.81 9.44 6.08 12 6.08Z"/></svg>`;let e={openai:"openai",anthropic:"claude",moonshotai:"moonshot",nvidia:"nvidia",qwen:"qwen",deepseek:"deepseek","x-ai":"grok","z-ai":"zai"};return e[r]?l`<span class="provider-mark" style="${`--provider-icon: url('/provider-icons/${e[r]}.svg')`}" aria-hidden="true"></span>`:l`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><rect x="4" y="4" width="12" height="12" rx="3"/><path d="M8 1v3m4-3v3M8 16v3m4-3v3M1 8h3m-3 4h3m12-4h3m-3 4h3"/></svg>`}var yt=class extends w{static properties={loadModels:{attribute:!1},value:{attribute:!1},effort:{attribute:!1},hasExtra:{type:Boolean,attribute:"has-extra"},_models:{state:!0},_error:{state:!0},_menuColumns:{state:!0}};static styles=x`:host{display:block;min-width:0;container:scan-controls/inline-size}*{box-sizing:border-box}.layout{display:grid;grid-template-columns:minmax(13rem,1fr) minmax(14rem,1fr);gap:1.25rem;align-items:start}.layout.with-extra{grid-template-columns:minmax(13rem,.9fr) minmax(14rem,1.2fr) minmax(14rem,auto)}.field{min-width:0}.label{display:flex;justify-content:space-between;align-items:center;margin-bottom:.4rem;color:var(--muted);font-size:.72rem}output{color:var(--text);font-size:.72rem;font-weight:500}details{position:relative}.model-control{position:relative}summary{display:flex;align-items:center;gap:.55rem;padding:.5rem .6rem;border:1px solid var(--border);border-radius:6px;background:var(--bg);color:var(--text);list-style:none;transition:border-color .12s,background .12s}details[open] summary,summary:hover{border-color:var(--muted);background:var(--surface-active)}summary::-webkit-details-marker{display:none}.menu,summary{user-select:none}summary>svg{width:.9rem;height:.9rem;margin-left:auto;color:var(--muted)}.selected-copy{display:grid;gap:.1rem;flex:1;min-width:0}.selected-copy strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.8rem;font-weight:500}.selected-copy small{color:var(--muted);font-size:.63rem}.pro-space{width:3.65rem;flex:0 0 3.65rem}.pro-toggle{position:absolute;right:2.05rem;top:50%;transform:translateY(-50%);display:inline-flex;align-items:center;justify-content:center;gap:.3rem;width:3.65rem;height:1.65rem;padding:.2rem .3rem;border:1px solid var(--border);border-radius:5px;background:var(--bg);color:var(--muted);font:inherit;font-size:.65rem;font-weight:600;cursor:default;user-select:none}.pro-toggle:hover{border-color:var(--muted);color:var(--text)}.pro-track{position:relative;flex:0 0 1.3rem;height:.8rem;border-radius:999px;background:var(--border)}.pro-track::after{content:'';position:absolute;top:.15rem;left:.15rem;width:.5rem;height:.5rem;border-radius:50%;background:var(--muted);transition:transform .12s,background .12s}.pro-toggle[aria-checked=true]{color:var(--accent);border-color:rgb(from var(--accent) r g b / .45);background:rgb(from var(--accent) r g b / .08)}.pro-toggle[aria-checked=true] .pro-track{background:rgb(from var(--accent) r g b / .25)}.pro-toggle[aria-checked=true] .pro-track::after{transform:translateX(.5rem);background:var(--accent)}.icon{display:inline-grid;place-items:center;width:1.7rem;height:1.5rem;flex:0 0 1.7rem;color:var(--text)}.icon svg{display:block;width:1.1rem;height:1.1rem}.provider-mark{display:block;width:1.12rem;height:1.12rem;background:currentColor;-webkit-mask:var(--provider-icon) center/contain no-repeat;mask:var(--provider-icon) center/contain no-repeat}.icon.openai{color:#10a37f}.icon.anthropic{color:#d97757}.icon.moonshotai{color:#8068d9}.icon.google{color:#4285f4}.icon.nvidia{color:#76b900}.icon.qwen{color:#f97316}.icon.deepseek{color:#4d8dff}.icon.moonshotai .provider-mark{transform:scale(.78)}.icon.qwen .provider-mark{transform:scale(.82)}.icon.nvidia .provider-mark{transform:scale(.86)}.icon.deepseek .provider-mark{transform:scale(.9)}.extra{display:flex;min-width:0;min-height:4.9rem;align-items:flex-end;align-self:end;padding-bottom:.05rem}.menu{visibility:hidden;position:fixed;z-index:1000;width:min(46rem,calc(100vw - 1rem));max-height:calc(100dvh - 1rem);overflow:auto;overscroll-behavior:contain;padding:.65rem;border:1px solid var(--border);border-radius:9px;background:var(--surface-active);color:var(--text);box-shadow:0 .65rem 1.8rem rgb(0 0 0 / .55)}details[open] .menu[data-positioned]{visibility:visible}.groups{display:grid;grid-template-columns:repeat(var(--model-columns,1),minmax(0,1fr));gap:1rem;align-items:start}.provider-column{min-width:0}fieldset{min-width:0;margin:0 0 .6rem;padding:0;border:0}fieldset:last-child{margin-bottom:0}legend{display:flex;align-items:center;gap:.45rem;width:100%;min-height:1.9rem;padding:.35rem .5rem .25rem;border-bottom:1px solid rgb(from var(--border) r g b / .7);color:var(--muted);font-size:.64rem;font-weight:700;letter-spacing:.055em;text-transform:uppercase}legend .icon{width:.88rem;height:1.25rem;flex-basis:.88rem}legend .icon svg{width:.88rem;height:.88rem}legend .provider-mark{width:.88rem;height:.88rem}.choice{display:flex;align-items:center;gap:.5rem;padding:.35rem .5rem;border-radius:4px;font-size:.76rem}.choice:hover{background:rgb(from var(--text) r g b / .05)}.choice:has(:checked){color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.choice input{margin:0;accent-color:var(--accent)}.choice span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.slider{--thumb-size:1rem;padding:.15rem .6rem 0}input[type=range]{appearance:none;display:block;width:100%;height:var(--thumb-size);margin:.4rem 0 .5rem;padding:0;border:0;background:0 0}input[type=range]::-webkit-slider-runnable-track{height:.3rem;border-radius:999px;background:linear-gradient(to right,var(--accent) var(--effort-fill),var(--surface-active) var(--effort-fill))}input[type=range]::-moz-range-track{height:.3rem;border-radius:999px;background:linear-gradient(to right,var(--accent) var(--effort-fill),var(--surface-active) var(--effort-fill))}input[type=range]::-webkit-slider-thumb{appearance:none;width:var(--thumb-size);height:var(--thumb-size);margin-top:calc((.3rem - var(--thumb-size))/ 2);border:0;border-radius:50%;background:var(--accent)}input[type=range]::-moz-range-thumb{width:var(--thumb-size);height:var(--thumb-size);border:0;border-radius:50%;background:var(--accent)}input[type=range]:disabled{opacity:.5}.steps{position:relative;height:1.3rem;margin:0 calc(var(--thumb-size)/ 2)}.step{position:absolute;top:0;left:var(--step-position);transform:translateX(-50%);padding:.35rem 0 0;border:0;background:0 0;color:var(--muted);font:inherit;font-size:.62rem;white-space:nowrap;cursor:default}.step::before{content:'';position:absolute;top:0;left:50%;transform:translateX(-50%);width:1px;height:.2rem;background:var(--muted)}.step.active{color:var(--accent)}:is(summary,input,button):focus-visible{outline:2px solid var(--accent);outline-offset:2px}.message{margin:0;color:var(--muted);font-size:.75rem}.error{color:var(--critical,#e5534b)}.retry{margin-left:.5rem;padding:.2rem .4rem;border:1px solid var(--border);border-radius:4px;background:var(--bg);color:var(--text);font:inherit}.layout.with-extra .extra{grid-column:1/-1;align-self:start;min-height:0}.layout.with-extra .extra{grid-column:auto}`;constructor(){super(),this.loadModels=ae,this.value=null,this.effort=null,this.hasExtra=!1,this._models=[],this._error=null,this._menuColumns=1,this._positionRequest=0,this._onOutside=e=>{e.composedPath().includes(this)||this._close()},this._onViewportChange=()=>this._positionMenu()}connectedCallback(){super.connectedCallback(),document.addEventListener("pointerdown",this._onOutside),window.addEventListener("resize",this._onViewportChange),window.addEventListener("scroll",this._onViewportChange,!0),this.hasUpdated&&this._load()}updated(e){e.has("loadModels")&&this.isConnected&&this._load(),e.has("_models")&&this.renderRoot.querySelector("details")?.open&&(this._resetMenuPosition(),this._positionMenu())}disconnectedCallback(){super.disconnectedCallback(),this._controller?.abort(),document.removeEventListener("pointerdown",this._onOutside),window.removeEventListener("resize",this._onViewportChange),window.removeEventListener("scroll",this._onViewportChange,!0)}async _load(){this._controller?.abort();let e=new AbortController;this._controller=e,this._error=null;try{let t=await this.loadModels(e.signal);if(e.signal.aborted)return;this._models=t.models;let i=t.models.find(s=>s.id===this.value);i?i.efforts.includes(this.effort)||this._setEffort(we(i)):this._select(t.defaultModel)}catch(t){e.signal.aborted||(this._error=String(t?.message??t))}}_close(){this._resetMenuPosition();let e=this.renderRoot.querySelector("details");e&&(e.open=!1)}_resetMenuPosition(){this._positionRequest++;let e=this.renderRoot.querySelector(".menu");e&&delete e.dataset.positioned}_toggleMenu(e){this._resetMenuPosition(),e.currentTarget.open&&this._positionMenu()}get _selectedRow(){return vt(this._models).find(e=>e.id===this.value||e.pro?.id===this.value)}async _positionMenu(){let e=++this._positionRequest,t=this.renderRoot.querySelector("details"),i=this.renderRoot.querySelector("summary"),s=this.renderRoot.querySelector(".menu");if(!t?.open||!i||!s)return;let o=i.getBoundingClientRect(),n=6,a=8,c=_t(this._models),d=c.reduce((N,Ie)=>N+Ie.models.length,0),f=Math.min(3,c.length,Math.ceil((d+c.length*1.5)/9)),p=parseFloat(getComputedStyle(s).fontSize),b=0;for(let N of s.querySelectorAll(".choice span, legend")){let Ie=document.createRange();Ie.selectNodeContents(N),b=Math.max(b,Ie.getBoundingClientRect().width)}let h=Math.max(11*p,Math.min(18*p,b+2.5*p)),g=1.3*p+2,m=Math.max(1,Math.min(f,Math.floor((window.innerWidth-a*2-g+p)/(h+p)))),v=Math.min(m*h+(m-1)*p+g,window.innerWidth-a*2),$=Math.max(a,Math.min(o.left,window.innerWidth-v-a));if(this._menuColumns=m,await this.updateComplete,e!==this._positionRequest||!this.isConnected||!t.open)return;s.style.left=`${$}px`,s.style.width=`${v}px`,s.style.setProperty("--model-columns",m),s.style.maxHeight=`${Math.max(0,window.innerHeight-a*2)}px`;let _=s.getBoundingClientRect().height,A=window.innerHeight-o.bottom-n-a,Me=o.top-n-a,Le=A<_&&Me>A?o.top-n-_:o.bottom+n;s.style.bottom="auto",s.style.top=`${Math.max(a,Math.min(Le,window.innerHeight-_-a))}px`,s.dataset.positioned=""}_select(e,{preserveEffort:t=!1,close:i=!0}={}){let s=this._models.find(o=>o.id===e);s&&(this.value=e,this._setEffort(t&&s.efforts.includes(this.effort)?this.effort:we(s)),i&&this._close())}_selectRow(e){let t=this._selectedRow?.pro?.id===this.value;this._select(t&&e.pro?e.pro.id:e.id)}_togglePro(){let e=this._selectedRow;e?.pro&&this._select(this.value===e.pro.id?e.id:e.pro.id,{preserveEffort:!0,close:!1})}_setEffort(e){this.effort=e,this.dispatchEvent(new CustomEvent("model-change",{detail:{model:this.value,effort:e},bubbles:!0,composed:!0}))}render(){if(this._error)return l`<p class="message error" role="alert">Couldn’t load models: ${this._error}<button class="retry" @click="${()=>{this._load()}}">Retry</button></p>`;let e=this._models.find(o=>o.id===this.value);if(!e)return l`<p class="message" role="status">Loading models…</p>`;let t=this._selectedRow,i=_e(e.id),s=Wr(_t(this._models),this._menuColumns);return l`<div class="${`layout ${this.hasExtra?"with-extra":""}`}"><div class="field"><span class="label" id="model-label">Model</span><div class="model-control"><details @toggle="${this._toggleMenu}" @keydown="${o=>{o.key==="Escape"&&(this._close(),this.renderRoot.querySelector("summary")?.focus())}}"><summary aria-labelledby="model-label selected-model" @click="${this._resetMenuPosition}"><span class="${`icon ${i.key}`}">${Kr(i.key)}</span><span class="selected-copy"><strong id="selected-model">${ve(t.id)}</strong><small>${i.name}</small></span>${t.pro?l`<span class="pro-space" aria-hidden="true"></span>`:u}${gs}</summary><div class="menu"><div class="groups">${s.map(o=>l`<div class="provider-column">${o.map(n=>this._modelSection(n))}</div>`)}</div></div></details>${t.pro?l`<button type="button" class="pro-toggle" role="switch" aria-label="Pro model" aria-checked="${e.id===t.pro.id}" @click="${this._togglePro}"><span>Pro</span><span class="pro-track" aria-hidden="true"></span></button>`:u}</div></div>${e.efforts.length>0?this._effortSlider(e.efforts):u} ${this.hasExtra?l`<div class="extra"><slot name="effort-extra"></slot></div>`:u}</div>`}_modelSection({key:e,models:t}){return l`<fieldset><legend><span class="${`icon ${e}`}">${Kr(e)}</span>${_e(t[0].id).name}</legend>${t.map(i=>l`<label class="choice"><input type="radio" name="scan-model" value="${i.id}" .checked="${i.id===this.value||i.pro?.id===this.value}" @change="${()=>{this._selectRow(i),this.renderRoot.querySelector("summary")?.focus()}}"><span>${ve(i.id)}</span></label>`)}</fieldset>`}_effortSlider(e){let t=Math.max(0,e.indexOf(this.effort)),i=Math.max(1,e.length-1);return l`<div class="field"><div class="label"><label for="effort">Effort</label><output for="effort">${ye(e[t])}</output></div><div class="slider" style="${`--effort-fill: calc(var(--thumb-size) / 2 + (100% - var(--thumb-size)) * ${t/i})`}"><input id="effort" type="range" min="0" max="${i}" step="1" .value="${String(t)}" ?disabled="${e.length===1}" aria-valuetext="${ye(e[t])}" @input="${s=>this._setEffort(e[Number(s.target.value)])}"><div class="steps">${e.map((s,o)=>l`<button type="button" class="${`step ${s===this.effort?"active":""}`}" style="${`--step-position: ${o/i*100}%`}" aria-label="${`Set effort to ${ye(s)}`}" aria-pressed="${s===this.effort}" @click="${()=>this._setEffort(s)}">${ye(s)}</button>`)}</div></div></div>`}};customElements.get("scan-model-picker")||customElements.define("scan-model-picker",yt);var E=class extends w{static properties={options:{attribute:!1},value:{attribute:!1},label:{type:String},placeholder:{type:String},disabled:{type:Boolean},_query:{state:!0},_facet:{state:!0},_open:{state:!0}};static styles=x`:host{display:block;min-width:0}*{box-sizing:border-box}button,input{font:inherit;color:var(--text)}button{cursor:default;user-select:none}.trigger{display:flex;align-items:center;gap:.6rem;width:100%;height:2rem;padding:.28rem .5rem;border:1px solid var(--border);border-radius:5px;background:var(--bg);text-align:left;font-size:.76rem}.trigger:hover:not(:disabled){border-color:var(--muted)}.trigger:disabled{opacity:.5}:host([variant=filter]){display:inline-block;max-width:min(20rem,100%)}:host([variant=filter]) .trigger{height:30px;min-width:8.5rem;background:0 0;font-size:.8rem;font-weight:500;border-radius:4px}.name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.option-copy{flex:1;min-width:0;display:grid;gap:.08rem}.secondary{color:var(--muted);font-size:.64rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.avatar{display:grid;place-items:center;flex:0 0 1.5rem;width:1.5rem;height:1.5rem;border-radius:50%;color:var(--accent);background:rgb(from var(--accent) r g b / .13);font-family:sans-serif;font-size:.62rem;font-weight:600}.count,.detail{flex:0 0 auto;color:var(--muted);font-size:.66rem;font-variant-numeric:tabular-nums;white-space:nowrap}svg{flex:0 0 auto;width:.9rem;height:.9rem;color:var(--muted)}.menu{visibility:hidden;position:fixed;inset:auto;margin:0;padding:0;overflow:hidden;border:1px solid var(--border);border-radius:8px;background:var(--bg);color:var(--text);box-shadow:0 .6rem 1.6rem rgb(0 0 0 / .4);user-select:none}.menu:popover-open{display:flex;flex-direction:column}.menu[data-positioned]{visibility:visible}.search{display:flex;align-items:center;gap:.5rem;flex:0 0 auto;padding:.55rem .65rem;border-bottom:1px solid var(--border)}input{flex:1;min-width:0;width:0;padding:.15rem 0;border:0;background:0 0;font-size:.78rem;outline:0}input::placeholder{color:var(--muted)}.search:focus-within{box-shadow:inset 0 -2px var(--accent)}.body{display:flex;min-height:0;flex:1}.facets{width:10.5rem;flex:0 0 auto;padding:.35rem;overflow:auto;overscroll-behavior:none;border-right:1px solid var(--border);background:rgb(from var(--bg) r g b / .25)}.org{display:flex;align-items:center;gap:.4rem;width:100%;padding:.4rem .45rem;border:0;border-radius:4px;background:0 0;text-align:left;font-size:.7rem}.org[aria-pressed=true]{color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.results{flex:1;min-width:0;overflow:auto;overscroll-behavior:none;padding:.3rem}.group+.group{margin-top:.35rem;padding-top:.35rem;border-top:1px solid var(--border)}.heading{position:sticky;top:-.3rem;z-index:1;display:flex;align-items:center;gap:.4rem;margin:0;padding:.4rem .5rem;color:var(--muted);background:var(--bg);font-size:.68rem;font-weight:600}.heading svg{width:.8rem;height:.8rem}.option{display:flex;align-items:center;gap:.65rem;width:100%;padding:.35rem .5rem;border:0;border-radius:4px;background:0 0;text-align:left;font-size:.76rem}.option svg{width:.8rem;height:.8rem;opacity:0;color:var(--accent)}.option[aria-selected=true]{color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.option[aria-selected=true] svg{opacity:1}.option:disabled{opacity:.45}.option:hover:not(:disabled),.org:hover{background:rgb(from var(--text) r g b / .05)}.pinned{padding-bottom:.25rem;margin-bottom:.25rem;border-bottom:1px solid var(--border)}.empty{margin:0;padding:1.3rem .7rem;color:var(--muted);font-size:.76rem}button:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}@media (max-width:40rem){.facets{width:8.5rem}}@media (max-width:28rem){.facets{width:7rem}.option{gap:.35rem}}`;constructor(){super(),this.options=[],this.value=null,this.label="Choose",this.placeholder="Choose",this.disabled=!1,this._query="",this._facet=null,this._open=!1,this._menuHeight=null,this._onViewport=()=>this._position()}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onViewport),window.addEventListener("scroll",this._onViewport,!0)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._onViewport),window.removeEventListener("scroll",this._onViewport,!0)}render(){let e=this.options.find(n=>n.value===this.value),t=this.choices(),s=[...t.pinned,...t.sections.flatMap(n=>n.options)].filter(n=>!n.disabled),o=s.find(n=>n.value===this.value)?.value??s[0]?.value;return l`<button type="button" class="trigger" popovertarget="selector-menu" aria-label="${this.label}" aria-haspopup="dialog" aria-expanded="${this._open}" ?disabled="${this.disabled}">${e?this.optionIcon(e):u}<span class="name">${e?.label??this.placeholder}</span>${e?.detail?l`<span class="detail">${e.detail}</span>`:u} <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m4 6 4 4 4-4"/></svg></button><div class="menu" id="selector-menu" popover="auto" role="dialog" aria-label="${this.label}" @beforetoggle="${this._beforeToggle}" @toggle="${this._toggle}" @keydown="${this._keyDown}"><div class="search"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/></svg> <input type="search" placeholder="${`${this.searchLabel}\u2026`}" aria-label="${this.searchLabel}" aria-controls="selector-options" .value="${I(this._query)}" @input="${n=>{this._query=n.target.value}}"> <span class="count" role="status">${t.count}${t.count===t.total?"":` / ${t.total}`}</span></div><div class="body">${t.showFacets?l`<div class="facets" role="group" aria-label="${this.facetLabel}"><button type="button" class="org" aria-pressed="${t.activeFacet==null}" @click="${()=>this._filterFacet(null)}"><span class="name">${this.allFacetsLabel}</span><span class="count">${t.total}</span></button> ${t.facets.map(n=>l`<button type="button" class="org" title="${n.name}" aria-pressed="${t.activeFacet===n.value}" @click="${()=>this._filterFacet(n.value)}"><span class="name">${n.name}</span><span class="count">${n.count}</span></button>`)}</div>`:u}<div class="results" id="selector-options" role="listbox" aria-label="${this.optionsLabel}">${t.pinned.length>0?l`<div class="pinned">${t.pinned.map(n=>this._option(n,!1,o))}</div>`:u} ${t.sections.map((n,a)=>l`<div class="group" role="group" aria-labelledby="${n.label?`selector-group-${a}`:u}">${n.label?l`<h3 class="heading" id="${`selector-group-${a}`}">${n.organization?l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" aria-hidden="true"><path d="M3 14V3h6v11M9 7h4v7M1 14h14M5 6h2M5 9h2M5 12h2"/></svg>`:u}${n.label}</h3>`:u} ${n.options.map(c=>this._option(c,n.organization,o))}</div>`)} ${t.count?u:l`<p class="empty">${this.options.length>0?this.noMatchesLabel:this.emptyLabel}</p>`}</div></div></div>`}optionIcon(e){return u}optionTitle(e){return e.label}_option(e,t,i){return l`<button type="button" class="option" role="option" ?data-reset="${e.reset}" ?disabled="${e.disabled}" aria-label="${e.label}" title="${this.optionTitle(e)}" aria-selected="${e.value===this.value}" tabindex="${e.value===i?0:-1}" @click="${()=>this._pick(e.value)}"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m3 8 3 3 7-7"/></svg>${this.optionIcon(e)}${e.initials?l`<span class="avatar" aria-hidden="true">${e.initials}</span>`:u}<span class="option-copy"><span class="name">${e.displayLabel??(t?e.name:e.label)}</span>${e.secondary?l`<span class="secondary">${e.secondary}</span>`:u}</span>${e.detail?l`<span class="detail">${e.detail}</span>`:u}</button>`}updated(e){this.disabled&&this._open&&this._close(!1),e.has("options")&&(this._menuHeight=null),this._position(),(e.has("_query")||e.has("_facet"))&&(this.renderRoot.querySelector(".results").scrollTop=0)}_beforeToggle(e){this._open=e.newState==="open",delete e.target.dataset.positioned,this._open&&(this._query="",this._facet=null,this._menuHeight=null)}async _toggle(e){e.newState==="open"&&(await this.updateComplete,!(!this._open||!this.isConnected)&&(this._position(),this.renderRoot.querySelector("input").focus({preventScroll:!0})))}_position(){let e=this.renderRoot.querySelector(".menu");if(!e?.matches(":popover-open"))return;let t=this.renderRoot.querySelector(".trigger").getBoundingClientRect(),i=8,s=e.querySelector(".facets")!=null,o=Math.min(Math.max(t.width,s?560:360),window.innerWidth-i*2),n=window.innerHeight-t.bottom-i-4,a=t.top-i-4;e.style.width=`${o}px`,this._menuHeight??=Math.min(480,e.querySelector(".search").offsetHeight+Math.max(e.querySelector(".results").scrollHeight,e.querySelector(".facets")?.scrollHeight??0)+2);let c=this._menuHeight,d=n<c&&a>n;e.style.maxHeight=`${Math.max(0,Math.min(c,d?a:n))}px`,e.style.left=`${Math.max(i,Math.min(t.left,window.innerWidth-o-i))}px`,e.style.top=`${Math.max(i,d?t.top-e.offsetHeight-4:t.bottom+4)}px`,e.dataset.positioned=""}_filterFacet(e){this._facet=e,this.renderRoot.querySelector("input").focus({preventScroll:!0})}_keyDown(e){if(e.stopPropagation(),e.key==="Escape"){e.preventDefault(),this._close();return}let t=this.renderRoot.querySelector("input"),i=this.renderRoot.activeElement,s=[...this.renderRoot.querySelectorAll(".option:not(:disabled)")],o=s.indexOf(i);if(i!==t&&o<0)return;if(e.key==="Enter"&&i===t){e.preventDefault(),(this.renderRoot.querySelector(".option:not([data-reset]):not(:disabled)")??s[0])?.click();return}let n;if(e.key==="ArrowDown")n=Math.min(o+1,s.length-1);else if(e.key==="ArrowUp")n=o-1;else if(i!==t&&e.key==="Home")n=0;else if(i!==t&&e.key==="End")n=s.length-1;else if(i!==t&&e.key.length===1&&e.key!==" "&&!e.ctrlKey&&!e.metaKey&&!e.altKey){e.preventDefault(),this._query+=e.key,t.focus();return}else return;e.preventDefault();for(let[a,c]of s.entries())c.tabIndex=a===n?0:-1;n<0?t.focus():s[n]?.focus()}_pick(e){this.disabled||!this.options.some(t=>t.value===e&&!t.disabled)||(this._close(),this.dispatchEvent(new CustomEvent(this.changeEvent,{detail:{value:e},bubbles:!0,composed:!0})))}_close(e=!0){this.renderRoot.querySelector(".menu").hidePopover(),this._open=!1,e&&this.renderRoot.querySelector(".trigger").focus({preventScroll:!0})}};function bs(r){if(/^https?:\/\//iu.test(r)){try{let t=new URL(r),i=t.pathname.split("/").filter(Boolean);if(i.length>=2)return{owner:`${t.host}/${i[0]}`,name:i.slice(1).join("/")}}catch{}return{owner:null,name:r}}let e=/^([^\s/:]+)\/(.+)$/u.exec(r);return e?{owner:e[1],name:e[2]}:{owner:null,name:r}}var Zr=r=>r.normalize("NFKC").toLocaleLowerCase(),wt=(r,e)=>r.localeCompare(e,void 0,{numeric:!0,sensitivity:"base"}),xt=Symbol("other repositories");function Yr(r,e="",t=null){let i=r.map(m=>({...m,...m.special?{owner:null,name:m.label}:bs(m.label)})),s=new Map;for(let m of i)m.owner!=null&&s.set(m.owner,(s.get(m.owner)??0)+1);let o=[...s].filter(([,m])=>m>1).toSorted(([m],[v])=>wt(m,v)).map(([m,v])=>({value:m,name:m,count:v})),n=m=>(s.get(m.owner)??0)<=1,a=i.filter(m=>!m.special&&!m.reset&&n(m)).length;a>0&&o.push({value:xt,name:"Other",count:a});let c=o.some(m=>m.value===t)?t:null,d=Zr(e.trim()).split(/\s+/u).filter(Boolean),f=m=>d.every(v=>Zr(m.label).includes(v)),p=i.filter(m=>m.reset||m.special&&f(m)),b=i.filter(m=>!m.reset&&!m.special&&f(m)&&(c==null||(c===xt?n(m):m.owner===c))),h=new Map;for(let m of b){let v=(s.get(m.owner)??0)>1?m.owner:null;h.has(v)||h.set(v,[]),h.get(v).push(m)}let g=[...h].toSorted(([m],[v])=>m==null?1:v==null?-1:wt(m,v)).map(([m,v])=>({label:m??(o.some($=>$.value!==xt)?"Other":null),organization:m!=null,options:v.toSorted(($,_)=>wt($.label,_.label))}));return{facets:o,activeFacet:c,pinned:p,sections:g,count:b.length+p.filter(m=>!m.reset).length,total:i.filter(m=>!m.reset).length,showFacets:o.length>1}}var $t=class extends E{constructor(){super(),this.label="Choose repository",this.placeholder="Choose repository"}get searchLabel(){return"Search repositories"}get optionsLabel(){return"Repositories"}get facetLabel(){return"Filter by organization"}get allFacetsLabel(){return"All organizations"}get noMatchesLabel(){return"No matching repositories"}get emptyLabel(){return"No repositories available"}get changeEvent(){return"repository-change"}choices(){return Yr(this.options,this._query,this._facet)}};customElements.get("repository-selector")||customElements.define("repository-selector",$t);function W(r){return!Number.isFinite(r)||r<0?"\u2014":r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KiB`:r<1073741824?`${(r/1048576).toFixed(1)} MiB`:`${(r/1073741824).toFixed(1)} GiB`}function xe(r){return Array.isArray(r)?r.reduce((e,t)=>({bytes:e.bytes!=null&&Number.isFinite(t.bytes)?e.bytes+t.bytes:null,lines:e.lines!=null&&Number.isFinite(t.lines)?e.lines+t.lines:null}),{bytes:0,lines:0}):{bytes:null,lines:null}}function kt(r){return(r??[]).filter(e=>!["resource:base64","directory"].includes(e.format))}function vs(r){return r.map(e=>{let t=["sourcemap","sourcemaps"].includes(e.kind)||e.filename.toLowerCase().endsWith(".map")?"sourcemap":"stasis",i=t==="sourcemap"?"Sourcemap":"Stasis",s=[];if(typeof e.size=="string"&&!["","\u2014"].includes(e.size)&&s.push(e.size),e.files){s.push(`${e.files.length.toLocaleString()} files`);let{lines:o}=xe(e.files);o!=null&&s.push(`${o.toLocaleString()} LoC`)}return{value:e.id,label:e.filename,detail:i,format:t,secondary:s.join(" \xB7 ")}})}var St=class extends E{static properties={bundles:{attribute:!1}};static styles=[E.styles,x`.bundle-icon{display:inline-flex;align-items:center;justify-content:center;flex:0 0 1.05rem;width:1.05rem;height:1.05rem;color:var(--muted)}.bundle-icon img,.bundle-icon svg{display:block;width:100%;height:100%;opacity:1}.option{gap:.5rem;padding-block:.25rem}.option-copy{gap:0}.option .name{line-height:1.3}.option .bundle-icon{flex-basis:1.35rem;width:1.35rem;height:1.35rem;margin-right:.15rem}.secondary{line-height:1.25;font-variant-numeric:tabular-nums}`];constructor(){super(),this.bundles=[],this.label="Choose bundle",this.placeholder="Choose bundle"}get searchLabel(){return"Search bundles"}get optionsLabel(){return"Bundles"}get noMatchesLabel(){return"No matching bundles"}get emptyLabel(){return"No stored bundles"}get changeEvent(){return"bundle-change"}willUpdate(e){e.has("bundles")&&(this.options=vs(this.bundles))}optionIcon(e){return l`<span class="bundle-icon" aria-hidden="true">${e.format==="sourcemap"?L(oe):l`<img src="./stasis.svg" alt="">`}</span>`}optionTitle(e){return u}choices(){let e=this._query.normalize("NFKC").toLocaleLowerCase().trim().split(/\s+/u).filter(Boolean),t=this.options.filter(i=>e.every(s=>`${i.label} ${i.detail}`.normalize("NFKC").toLocaleLowerCase().includes(s))).toSorted((i,s)=>i.label.localeCompare(s.label,void 0,{numeric:!0,sensitivity:"base"}));return{pinned:[],sections:[{label:null,options:t}],facets:[],showFacets:!1,count:t.length,total:this.options.length}}};customElements.get("bundle-selector")||customElements.define("bundle-selector",St);var Et=class extends E{constructor(){super(),this.label="Choose workspace",this.placeholder="Choose workspace"}get searchLabel(){return"Search workspaces"}get optionsLabel(){return"Workspaces"}get noMatchesLabel(){return"No matching workspaces"}get emptyLabel(){return"No workspaces available"}get changeEvent(){return"workspace-change"}choices(){let e=this._query.normalize("NFKC").toLocaleLowerCase().trim().split(/\s+/u).filter(Boolean),t=this.options.filter(i=>e.every(s=>i.label.normalize("NFKC").toLocaleLowerCase().includes(s))).toSorted((i,s)=>i.label.localeCompare(s.label,void 0,{numeric:!0,sensitivity:"base"}));return{pinned:[],sections:[{label:null,options:t}],facets:[],showFacets:!1,count:t.length,total:this.options.length}}};customElements.get("workspace-selector")||customElements.define("workspace-selector",Et);var $e=r=>({kind:r,sourceId:null,ids:new Set}),At=class extends w{static properties={mode:{type:String},loadSources:{attribute:!1},restore:{attribute:!1},_sources:{state:!0},_loading:{state:!0},_error:{state:!0},_merge:{state:!0},_link:{state:!0}};constructor(){super(),this.mode="link",this._sources=null,this._loading=!1,this._error=null,this._merge=$e("bundle"),this._link=$e("repository")}disconnectedCallback(){super.disconnectedCallback(),this._controller?.abort()}updated(e){if(e.has("loadSources")){this._load();return}e.has("mode")&&this._selectOnlySource(),e.has("restore")&&this._restore(),["_sources","_merge","_link","mode","restore"].some(t=>e.has(t))&&this._notify()}get _current(){return this.mode==="merge"?this._merge:this._link}get _parents(){if(this.mode==="merge")return this._sources?.merge?.bundles??[];let e=this._sources?.link?.reports??[];return this._current.kind==="workspace"?(this._sources?.link?.workspaces??[]).filter(t=>e.some(i=>t.reports.includes(i.id))):(this._sources?.link?.repositories??[]).filter(t=>e.some(i=>i.repoIds.includes(t.id)))}get _parent(){return this._parents.find(e=>e.id===this._current.sourceId)}get _scopeOptions(){let e=this._sources?.link?.reports??[];return this._parents.map(t=>{let i=e.filter(s=>this._current.kind==="workspace"?t.reports.includes(s.id):s.repoIds.includes(t.id)).length;return{value:t.id,label:t.label,detail:`${i} ${i===1?"report":"reports"}`}})}get _inputs(){return this._parent?this.mode==="merge"?(this._sources?.merge?.results??[]).filter(e=>e.bundleId===this._parent.id):(this._sources?.link?.reports??[]).filter(e=>this._current.kind==="workspace"?this._parent.reports.includes(e.id):e.repoIds.includes(this._parent.id)):[]}get selection(){let e=this._parent;return{mode:this.mode,source:e?{kind:this._current.kind,id:e.id,label:e.label??e.filename}:null,inputs:this._loading||this._error?[]:this._inputs.filter(t=>this._current.ids.has(t.id))}}_notify(){this.dispatchEvent(new CustomEvent("report-inputs-change",{detail:this.selection,bubbles:!0,composed:!0}))}async _load(){this._controller?.abort();let e=this._controller=new AbortController;this._loading=!0,this._error=null,this._notify();try{let t=this.loadSources?await this.loadSources(e.signal):{merge:{bundles:[],results:[]},link:{repositories:[],reports:[]}};if(e.signal.aborted)return;this._sources=t,this._merge=$e("bundle"),this._link=$e(Array.isArray(t.link?.workspaces)?"workspace":"repository"),this._selectOnlySource(),this._restore()}catch(t){e.signal.aborted||(this._error=String(t?.message??t))}finally{e.signal.aborted||(this._loading=!1,this._notify())}}_setCurrent(e){this.mode==="merge"?this._merge=e:this._link=e}_selectSource(e){e===this._current.sourceId||!this._parents.some(t=>t.id===e)||(this._setCurrent({...this._current,sourceId:e,ids:new Set}),this._setCurrent({...this._current,ids:new Set(this._inputs.map(t=>t.id))}),this._notify())}_changeKind(e){["workspace","repository"].includes(e)&&(e==="workspace"&&!Array.isArray(this._sources?.link?.workspaces)||(e!==this._link.kind&&(this._link=$e(e)),this._selectOnlySource(),this._notify()))}_selectOnlySource(){this.mode==="link"&&this._current.sourceId==null&&this._parents.length===1&&this._selectSource(this._parents[0].id)}_toggle(e,t){if(!this._inputs.some(s=>s.id===e))return;let i=new Set(this._current.ids);t?i.add(e):i.delete(e),this._setCurrent({...this._current,ids:i}),this._notify()}_selectAll(e){this._setCurrent({...this._current,ids:new Set(e?this._inputs.map(t=>t.id):[])}),this._notify()}_restore(){let e=this.restore;if(!this._sources||e?.mode!==this.mode||!e.source)return;let t=this.mode==="merge"?"bundle":e.source.kind;this.mode==="link"&&(t==="workspace"?!Array.isArray(this._sources.link?.workspaces):t!=="repository")||(this._setCurrent({kind:t,sourceId:e.source.id,ids:new Set}),this._setCurrent({...this._current,ids:new Set(this._inputs.filter(i=>e.inputIds.includes(i.id)).map(i=>i.id))}))}render(){let e=this.mode==="merge",t=this._inputs,i=this.selection.inputs.length,s=Array.isArray(this._sources?.link?.workspaces),o=this._parent?e?"No scan results for this bundle.":`No saved reports in this ${this._current.kind}.`:e?"Choose a bundle to see its scan results.":this._parents.length===0?"No saved reports with app findings.":`Choose a ${this._current.kind} to see its saved reports.`;return l`<section class="panel" aria-label="${e?"Merge scan results":"Link saved reports"}" aria-busy="${this._loading}"><div class="source">${!e&&s?l`<div class="kinds" role="radiogroup" aria-label="Report source">${[["workspace","Workspace"],["repository","Repository"]].map(([n,a])=>l`<button type="button" role="radio" aria-checked="${n===this._link.kind}" @click="${()=>this._changeKind(n)}">${a}</button>`)}</div>`:u}<div class="field">${e?l`<span>Bundle with scan results</span>`:u} ${e?l`<bundle-selector .bundles="${this._parents}" .value="${this._current.sourceId}" ?disabled="${this._loading||this._parents.length===0}" @bundle-change="${n=>this._selectSource(n.detail.value)}"></bundle-selector>`:this._current.kind==="workspace"?l`<workspace-selector .options="${this._scopeOptions}" .value="${this._current.sourceId}" ?disabled="${this._loading}" @workspace-change="${n=>this._selectSource(n.detail.value)}"></workspace-selector>`:l`<repository-selector .options="${this._scopeOptions}" .value="${this._current.sourceId}" ?disabled="${this._loading}" @repository-change="${n=>this._selectSource(n.detail.value)}"></repository-selector>`}</div></div>${this._error?l`<p class="empty" role="alert">Couldn’t load report inputs: ${this._error} <button type="button" @click="${()=>{this._load()}}">Retry</button></p>`:this._loading?l`<p class="empty" role="status">Loading report inputs…</p>`:t.length>0?l`<div class="list-head"><label><input type="checkbox" aria-label="Select all" .checked="${i===t.length}" .indeterminate="${i>0&&i<t.length}" @change="${n=>this._selectAll(n.target.checked)}"><strong>All</strong></label><span>${i} of ${t.length} selected</span></div><div class="list">${t.map(n=>this._row(n))}</div>`:l`<p class="empty">${e&&this._parents.length===0?"No scan results available.":o}</p>`}</section>`}_row(e){let t=this.mode==="link"?e.appFindings:e.findings,i=[e.model?ve(e.model):null,t==null?null:`${t} ${this.mode==="link"?"app ":""}${t===1?"finding":"findings"}`,e.createdAt,e.repo?`${e.repo}${e.directory?`/${e.directory}`:""}`:null].filter(Boolean);return l`<label class="option"><input type="checkbox" .checked="${this._current.ids.has(e.id)}" @change="${s=>this._toggle(e.id,s.target.checked)}">${L(gt[e.analyzer]??gt.default)}<span class="copy"><strong>${e.title??e.filename}</strong><span>${i.join(" \xB7 ")}</span></span></label>`}static styles=x`:host{display:block;min-width:0}*{box-sizing:border-box}.panel{border:1px solid var(--border);border-radius:9px;background:var(--surface);overflow:hidden}.source{display:flex;flex-wrap:wrap;align-items:center;gap:.7rem;padding:.85rem .9rem;border-bottom:1px solid var(--border)}.field{display:grid;flex:1 1 14rem;gap:.3rem;max-width:32rem;min-width:0}.field>span{color:var(--muted);font-size:.72rem}button{padding:.3rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.74rem;cursor:default}.kinds{display:flex;width:fit-content;border:1px solid var(--border);border-radius:5px;overflow:hidden}.kinds button{padding-block:.5rem;border:0;border-radius:0;color:var(--muted)}.kinds button+button{border-left:1px solid var(--border)}.kinds button[aria-checked=true]{color:var(--text);background:var(--surface-active)}.list-head{display:flex;align-items:center;justify-content:space-between;gap:.5rem;padding:.55rem .9rem;border-bottom:1px solid var(--border)}.list-head label{display:flex;align-items:center;gap:.55rem;user-select:none}.list-head strong{color:var(--text);font-size:.74rem;font-weight:600}.list-head>span{color:var(--muted);font-size:.68rem}.list{max-height:24rem;overflow:auto;overscroll-behavior:none}.option{display:flex;align-items:center;gap:.55rem;min-width:0;padding:.35rem .9rem;user-select:none}.option+.option{border-top:1px solid var(--border)}.option:hover{background:var(--surface-active)}input{width:.85rem;height:.85rem;margin:0;flex:0 0 auto;accent-color:var(--accent)}.file-icon{width:1.4rem;height:1.4rem;flex:0 0 auto}.copy{display:flex;align-items:center;justify-content:space-between;gap:.75rem;flex:1;min-width:0}.copy span,.copy strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.copy strong{flex:1;color:var(--text);font-size:.74rem;font-weight:500}.copy span{max-width:55%;color:var(--muted);font-size:.66rem}.empty{margin:0;padding:1rem .9rem;color:var(--muted);font-size:.76rem}button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}`};customElements.get("scan-report-inputs")||customElements.define("scan-report-inputs",At);var _s=l`<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M6 4h7M6 8h7M6 12h7M3 4h.01M3 8h.01M3 12h.01"/></svg>`,ys=l`<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3 3M7 5v4M5 7h4"/></svg>`,Ct=class extends w{static properties={isolate:{type:Boolean},vertical:{type:Boolean,reflect:!0}};constructor(){super(),this.isolate=!1,this.vertical=!1}_select(e){this.isolate!==e&&(this.isolate=e,this.dispatchEvent(new CustomEvent("depth-change",{detail:{isolate:e},bubbles:!0,composed:!0})))}render(){return l`<div class="scan-depth"><div class="depth-options" role="radiogroup" aria-label="Scan depth" aria-orientation="${this.vertical?"vertical":"horizontal"}" aria-describedby="${this.vertical?u:"scan-depth-description"}">${[[!1,"List",_s],[!0,"Isolate",ys]].map(([e,t,i])=>l`<label class="depth-choice"><input type="radio" name="scan-depth" value="${e?"isolate":"list"}" .checked="${this.isolate===e}" @change="${()=>this._select(e)}"><span>${i}${t}</span></label>`)}</div>${this.vertical?u:l`<div class="depth-description" id="scan-depth-description" aria-live="polite"><span class="${this.isolate?"inactive":""}" aria-hidden="${this.isolate}">Regular scan depth</span><span class="${this.isolate?"":"inactive"}" aria-hidden="${!this.isolate}">Deeper search at ~10x the tokens spent</span></div>`}</div>`}static styles=x`:host{display:block;width:19rem;max-width:100%;min-width:0}*{box-sizing:border-box}.scan-depth{display:grid;gap:.4rem;width:100%;min-width:0;user-select:none}.depth-options{display:flex;position:relative;padding:.2rem;border:1px solid var(--border);border-radius:8px;background:var(--bg)}.depth-options::before{content:'';position:absolute;inset:.2rem auto .2rem .2rem;width:calc((100% - .4rem)/ 2);border-radius:5px;background:var(--surface-active);box-shadow:0 1px 3px rgb(0 0 0 / .12),inset 0 0 0 1px rgb(from var(--accent) r g b / .18);transition:transform .16s ease-out}.depth-options:has(input[value=isolate]:checked)::before{transform:translateX(100%)}.depth-choice{position:relative;flex:1;min-width:0}.depth-choice input{position:absolute;width:1px;height:1px;opacity:0}.depth-choice span{display:flex;align-items:center;justify-content:center;gap:.4rem;height:1.9rem;padding:.3rem .65rem;border-radius:5px;color:var(--muted);font-size:.76rem;font-weight:500;transition:color .12s}.depth-choice svg{width:.95rem;height:.95rem;fill:none;stroke:currentColor;stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}.depth-choice:hover span{color:var(--text)}.depth-choice input:checked+span{color:var(--accent)}.depth-choice input:focus-visible+span{outline:2px solid var(--accent);outline-offset:-2px}.depth-description{display:grid;color:var(--muted);font-size:.68rem;line-height:1.4}.depth-description span{grid-area:1/1}.depth-description .inactive{visibility:hidden}@media (prefers-reduced-motion:reduce){.depth-choice span,.depth-options::before{transition:none}}:host([vertical]){width:5.8rem}:host([vertical]) .depth-options{flex-direction:column}:host([vertical]) .depth-options::before{inset:.2rem .2rem auto;width:auto;height:calc((100% - .4rem)/ 2)}:host([vertical]) .depth-options:has(input[value=isolate]:checked)::before{transform:translateY(100%)}:host([vertical]) .depth-choice span{justify-content:flex-start;height:1.7rem;padding:.25rem .5rem;font-size:.72rem}`};customElements.get("scan-depth-toggle")||customElements.define("scan-depth-toggle",Ct);var Rt=["security","generic","correctness"],ws=r=>JSON.stringify([r.mode,r.model,r.effort,r.isolate]);function Mt(r,e){let t=e.models.find(i=>i.id===e.defaultModel)??e.models[0];return t?(r.length>0?r:[{mode:"generic",isolate:!1}]).map(i=>{let s=e.models.find(o=>o.id===i.model)??t;return{...i,mode:Rt.includes(i.mode)?i.mode:"generic",model:s.id,effort:s.efforts.includes(i.effort)?i.effort:we(s),isolate:!!i.isolate}}):[]}function Lt(r){let e=new Set;return r.map(t=>{let i=ws(t),s=e.has(i);return e.add(i),s})}var It=class extends w{static properties={value:{attribute:!1},loadModels:{attribute:!1},_rows:{state:!0},_loading:{state:!0},_error:{state:!0}};constructor(){super(),this.value=[],this._rows=[],this._catalogue={models:[]},this._nextId=0,this._loading=!0,this._error=null}disconnectedCallback(){super.disconnectedCallback(),this._controller?.abort()}updated(e){if(e.has("loadModels")){this._load();return}e.has("value")&&this.value!==this._lastEmitted&&!this._loading&&(this._setRows(this.value),this._notify())}_setRows(e){this._rows=Mt(e,this._catalogue).map(t=>({...t,id:t.id??++this._nextId}))}_notify(){let e=this._loading&&this._rows.length===0?this.value:this._rows.map(({id:i,...s})=>s),t=!this._loading&&!this._error&&e.length>0&&!Lt(e).includes(!0);this._lastEmitted=e,this.dispatchEvent(new CustomEvent("regimes-change",{detail:{value:e,ready:t},bubbles:!0,composed:!0}))}async _load(){this._controller?.abort();let e=this._controller=new AbortController;this._loading=!0,this._error=null,this._notify();try{let t=await this.loadModels(e.signal);if(e.signal.aborted)return;this._catalogue=t,this._sharedModels=()=>Promise.resolve(t),this._setRows(this._rows.length>0?this._rows:this.value)}catch(t){e.signal.aborted||(this._error=String(t?.message??t))}finally{e.signal.aborted||(this._loading=!1,this._notify())}}_change(e,t){let i=this._rows.find(o=>o.id===e);if(!i)return;let s=Mt([{...i,...t}],this._catalogue)[0];s&&(this._rows=this._rows.map(o=>o.id===e?s:o),this._notify())}_add(){let e=this._rows.at(-1);e&&(this._rows=[...this._rows,{...e,id:++this._nextId}],this._notify())}_remove(e){this._rows.length<=1||(this._rows=this._rows.filter(t=>t.id!==e),this._notify())}render(){let e=Lt(this._rows);return l`<section aria-label="Scan regimes" aria-busy="${this._loading}"><div class="heading"><h2>Scan regimes</h2><span>${this._rows.length} ${this._rows.length===1?"regime":"regimes"}</span></div>${this._error?l`<p class="message" role="alert">Couldn’t load models: ${this._error} <button type="button" @click="${()=>{this._load()}}">Retry</button></p>`:this._loading&&this._rows.length===0?l`<p class="message" role="status">Loading models…</p>`:l`${Ve(this._rows,t=>t.id,(t,i)=>this._row(t,i,e[i]))}<div class="footer"><button type="button" class="add" ?disabled="${this._rows.length===0}" @click="${this._add}"><span aria-hidden="true">+</span> Add regime</button><span class="message" role="status">${e.includes(!0)?"Change or remove duplicate regimes to run the scan":"Results from these regimes will be merged"}</span></div>`}</section>`}_row(e,t,i){return l`<div class="${`row${i?" duplicate":""}`}" role="group" aria-label="${`Regime ${t+1}`}" aria-describedby="${i?`duplicate-${e.id}`:u}"><div class="mode" role="radiogroup" aria-label="Scan mode">${Rt.map(s=>l`<label class="mode-choice"><input type="radio" name="${`regime-mode-${e.id}`}" .checked="${e.mode===s}" @change="${()=>this._change(e.id,{mode:s})}"><span>${s[0].toUpperCase()+s.slice(1)}</span></label>`)}</div><scan-model-picker .loadModels="${this._sharedModels}" .value="${I(e.model)}" .effort="${I(e.effort)}" @model-change="${s=>{s.stopPropagation(),this._change(e.id,s.detail)}}"></scan-model-picker><div class="row-actions"><scan-depth-toggle vertical .isolate="${e.isolate}" @depth-change="${s=>{s.stopPropagation(),this._change(e.id,{isolate:s.detail.isolate})}}"></scan-depth-toggle>${i?l`<span class="duplicate-label" id="${`duplicate-${e.id}`}">Duplicate regime</span>`:u}</div><button type="button" class="remove" aria-label="${`Remove regime ${t+1}`}" ?disabled="${this._rows.length===1}" @click="${()=>this._remove(e.id)}"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><path d="m4 4 8 8M12 4l-8 8"/></svg></button></div>`}static styles=x`:host{display:block;min-width:0;container:regime-editor/inline-size}*{box-sizing:border-box}.heading{display:flex;align-items:baseline;gap:.65rem;margin-bottom:.75rem}h2{margin:0;color:var(--text);font-size:.85rem;font-weight:600}.heading>span{color:var(--muted);font-size:.7rem}.row{position:relative;display:grid;grid-template-columns:7.75rem minmax(0,1fr) 5.8rem;align-items:start;gap:1rem;padding:.85rem 0;border-top:1px solid var(--border)}.mode{display:grid;min-width:0;border:1px solid var(--border);border-radius:6px;overflow:hidden;background:var(--bg)}.mode-choice{position:relative;user-select:none}.mode-choice+.mode-choice{border-top:1px solid var(--border)}.mode-choice input{position:absolute;width:1px;height:1px;opacity:0}.mode-choice span{display:block;padding:.2rem .6rem;color:var(--muted);font-size:.72rem;line-height:1.15rem}.mode-choice:hover span{background:var(--surface-active)}.mode-choice input:checked+span{color:var(--accent);background:rgb(from var(--accent) r g b / .1);box-shadow:inset 2px 0 var(--accent);font-weight:600}.mode-choice input:focus-visible+span{outline:2px solid var(--accent);outline-offset:-2px}button{border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.74rem;cursor:default}button{padding:.4rem .55rem;user-select:none}button:hover:not(:disabled){background:var(--surface-active)}button:disabled{opacity:.35}.row-actions{position:relative;display:flex;align-items:center;align-self:stretch;min-height:4.65rem;padding:.8rem 0 .25rem}.remove{position:absolute;top:.15rem;right:0;display:grid;place-items:center;width:1.5rem;height:1.5rem;padding:.25rem;border:0;background:0 0;color:var(--muted)}.duplicate-label{position:absolute;right:.15rem;bottom:-.05rem;transform:rotate(-7deg);padding:.1rem .3rem;border:1px solid rgb(from var(--critical,#e5534b) r g b / .45);border-radius:3px;color:var(--critical,#e5534b);background:var(--surface);font-size:.6rem;line-height:1rem;white-space:nowrap;pointer-events:none;user-select:none}svg{width:1rem;height:1rem}.footer{display:flex;flex-wrap:wrap;align-items:center;gap:.7rem;padding-top:.6rem;border-top:1px solid var(--border)}.add{display:flex;align-items:center;gap:.3rem}.message{margin:0;color:var(--muted);font-size:.7rem}button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}scan-model-picker{grid-row:2;grid-column:1/-1}.mode{grid-column:1;max-width:9rem}.row-actions{grid-column:2}`};customElements.get("scan-regime-editor")||customElements.define("scan-regime-editor",It);var Jr=x`:host{display:block;box-sizing:border-box;color:var(--text)}*{box-sizing:border-box}.wrap{max-width:68rem;margin:0 auto;container:scan-page/inline-size}.head{display:flex;flex-wrap:wrap;align-items:center;gap:.65rem;min-height:2.1rem;margin-bottom:.45rem}.head-title{display:flex;align-items:center;gap:.65rem}h1{margin:0;font-size:1.65rem;font-weight:600;letter-spacing:-.035em}.head-tabs{display:inline-flex;margin-left:.7rem;border:1px solid var(--border);border-radius:6px;overflow:hidden}.head-tabs button{border:0;border-right:1px solid var(--border);padding:.25rem .6rem;color:var(--muted);background:0 0;font:inherit;font-size:.75rem}.head-tabs button:last-child{border-right:0}.head-tabs button.active{color:var(--text);background:var(--surface-active)}.head-tabs button:hover{color:var(--text)}.source-choice.single-repository{grid-template-columns:1fr}.head-actions{margin-left:auto;display:flex;gap:.45rem}button,input,select{font:inherit}button{cursor:default}button:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.intro{margin:0 0 1.15rem;max-width:52rem;color:var(--muted);font-size:.82rem;line-height:1.5}.intro span{display:block}.notice{margin:0 0 1rem;padding:.55rem .7rem;border:1px solid rgb(from var(--accent) r g b / .35);border-radius:7px;color:var(--text);background:rgb(from var(--accent) r g b / .08);font-size:.78rem}.setup{display:grid;gap:.85rem}.panel{border:1px solid var(--border);border-radius:9px;background:var(--surface);overflow:hidden}.panel-head{display:flex;align-items:baseline;justify-content:space-between;gap:.7rem;padding:.72rem .9rem;border-bottom:1px solid var(--border)}.panel-head h2{margin:0;font-size:.86rem;font-weight:600}.panel-head p{margin:0;color:var(--muted);font-size:.72rem}.bundle-choice{display:grid;grid-template-columns:minmax(16rem,1.2fr) minmax(0,1fr);gap:1rem;align-items:end;padding:.85rem .9rem}.field{display:grid;gap:.3rem;min-width:0}.field label,.scope-field>span{color:var(--muted);font-size:.68rem}select{min-width:0;height:2rem;padding:.28rem .5rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font-size:.76rem}.bundle-stats{display:grid;grid-template-columns:repeat(4,max-content);align-items:center;gap:.45rem 1.1rem;min-width:0}.metric{display:inline-flex;align-items:center;gap:.3rem;min-width:0;white-space:nowrap}.metric svg{flex:0 0 auto;width:.85rem;height:.85rem;margin-right:.1rem;color:var(--muted)}.metric strong{min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:.72rem;font-weight:600;font-variant-numeric:tabular-nums}.metric span{color:var(--muted);font-size:.7rem}.mode-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.45rem;padding:.7rem .9rem .85rem}.mode-option{display:grid;gap:.25rem;min-width:0;padding:.55rem .6rem;border:1px solid var(--border);border-radius:6px;color:var(--muted);background:var(--bg);text-align:left}.mode-title{display:flex;align-items:center;gap:.35rem;min-width:0}.mode-title svg{width:.95rem;height:.95rem;flex:0 0 auto;color:var(--muted)}.mode-option strong{color:var(--text);font-size:.75rem;font-weight:600}.mode-option span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.63rem}.mode-option.active{border-color:rgb(from var(--accent) r g b / .55);background:rgb(from var(--accent) r g b / .1)}.mode-option.active .mode-title svg,.mode-option.active strong{color:var(--accent)}.subtype-wrap{border-top:1px solid var(--border);background:rgb(from var(--accent) r g b / .025)}.subtype-options{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.45rem;padding:.7rem .9rem .45rem}.report-subtypes{grid-template-columns:repeat(2,minmax(0,1fr));padding-bottom:.7rem}.subtype-option{display:grid;gap:.12rem;padding:.42rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--muted);background:var(--bg);text-align:left}.subtype-option strong{color:var(--text);font-size:.72rem;font-weight:500}.subtype-option span{font-size:.62rem}.subtype-option.active{border-color:rgb(from var(--accent) r g b / .55);background:rgb(from var(--accent) r g b / .1)}.subtype-option.active strong{color:var(--accent)}.subtype-help{margin:0;padding:.15rem .9rem .72rem;color:var(--muted);font-size:.68rem;line-height:1.4}.source-choice{display:grid;grid-template-columns:minmax(12rem,.8fr) minmax(16rem,1.2fr);gap:.7rem;align-items:end;padding:.85rem .9rem}.source-footer{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:.7rem 1rem;grid-column:1/-1;min-width:0}.scope-slot{justify-self:end;width:min(34rem,100%);min-height:2rem}.source-footer .bundle-stats{min-height:2rem}.scope-toggle{display:flex;align-items:center;justify-content:end;gap:.7rem;min-width:0;min-height:2rem}.scope-options{display:flex;flex-shrink:0;min-width:0;border:1px solid var(--border);border-radius:5px;overflow:hidden;background:var(--bg)}.scope-option{position:relative;flex:1 0 auto;user-select:none}.scope-option+.scope-option{border-left:1px solid var(--border)}.scope-option input{position:absolute;width:1px;height:1px;opacity:0}.scope-option span{display:grid;place-items:center;height:calc(2rem - 2px);padding:.3rem .55rem;color:var(--muted);font-size:.74rem;white-space:nowrap}.scope-option:hover span{color:var(--text);background:var(--surface-active)}.scope-option input:checked+span{color:var(--text);background:var(--surface-active);font-weight:500}.scope-option input:focus-visible+span{outline:2px solid var(--accent);outline-offset:-2px}.scope-description{order:-1;min-width:0;color:var(--muted);font-size:.66rem;line-height:1rem;text-align:right}.scope-field{display:flex;align-items:center;justify-content:end;gap:.5rem;min-width:0;max-width:100%;margin-left:auto}.scope-field select{width:13rem;max-width:100%;flex:1 1 auto}.choice-empty{display:flex;align-items:center;height:2rem;padding:.28rem .5rem;border:1px dashed var(--border);border-radius:5px;color:var(--muted);background:var(--bg);font-size:.72rem}.scope-head{display:flex;align-items:center;gap:.55rem;padding:.72rem .9rem;list-style:none;cursor:default;user-select:none}.scope-head::-webkit-details-marker{display:none}.scope-head:hover{background:var(--surface-active)}.scope-head:focus-visible{outline:2px solid var(--accent);outline-offset:-3px;border-radius:8px}.scope-chevron{width:.85rem;height:.85rem;flex:0 0 auto;transition:transform .15s}.scope-panel[open] .scope-chevron{transform:rotate(90deg)}.scope-panel[open] .scope-head{border-bottom:1px solid var(--border)}.scope-head h2{margin:0;font-size:.86rem;font-weight:600}.scope-head p{display:flex;flex-wrap:wrap;justify-content:end;gap:.15rem .65rem;margin:0 0 0 auto;color:var(--muted);font-size:.7rem;font-variant-numeric:tabular-nums;text-align:right}.scope-head p span{white-space:nowrap}.scope-head p span+span{padding-left:.65rem;border-left:1px solid var(--border)}.scope-grid{display:grid;grid-template-columns:minmax(13rem,.75fr) minmax(0,1.25fr);min-height:0}.scope-pane{min-width:0}.scope-pane+.scope-pane{border-left:1px solid var(--border)}.pane-head{display:flex;align-items:baseline;justify-content:space-between;gap:.5rem;padding:.55rem .75rem;border-bottom:1px solid var(--border)}.pane-head strong{font-size:.72rem;font-weight:600}.pane-head span{color:var(--muted);font-size:.65rem;font-variant-numeric:tabular-nums}.package-list{max-height:22rem;overflow:auto;overscroll-behavior:none}.package-row{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:.45rem;width:100%;padding:.42rem .7rem;border:0;border-bottom:1px solid var(--border);color:var(--text);background:0 0;text-align:left}.package-row:hover{background:var(--surface-active)}.file input,.package-row input{width:.85rem;height:.85rem;accent-color:var(--accent)}.package-name,.package-size{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.package-name{font-size:.7rem}.package-size{color:var(--muted);font-size:.64rem;font-variant-numeric:tabular-nums}.package-row.excluded .package-name{color:var(--muted);text-decoration:line-through}.file-panel{min-width:0}.file-list{display:grid;grid-template-columns:minmax(0,1fr);max-height:22rem;overflow:auto;overscroll-behavior:none}.file{display:flex;align-items:center;gap:.45rem;min-width:0;padding:.35rem .75rem;border-bottom:1px solid var(--border)}.file input{flex:0 0 auto}.file-copy{display:flex;align-items:center;gap:.75rem;flex:1;min-width:0}.file-path{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.72rem}.file-meta{flex:0 1 auto;min-width:0;max-width:50%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:.66rem;font-variant-numeric:tabular-nums}.excluded .file-path{color:var(--muted);text-decoration:line-through}.file-foot{display:flex;justify-content:space-between;gap:.6rem;padding:.6rem .8rem;color:var(--muted);font-size:.7rem}.options{display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:1rem;position:relative;z-index:2;overflow:visible;padding:.85rem .9rem 1rem}.options-grid{display:grid;grid-column:1/-1;gap:.7rem;min-width:0}.checks{position:relative;display:grid;grid-column:2;grid-row:3;align-content:center;justify-items:end;margin-top:1rem}.offline-help{position:absolute;top:calc(50% + .75rem);right:0;color:var(--muted);font-size:.66rem;line-height:1.4;white-space:nowrap}.check{display:inline-flex;align-items:center;gap:.4rem;color:var(--text);font-size:.75rem}.check input{width:.85rem;height:.85rem;accent-color:var(--accent)}.switch{display:inline-flex;align-items:center;gap:.45rem;color:var(--text);font-size:.74rem;cursor:default}.switch input{position:absolute;width:1px;height:1px;opacity:0}.switch-track{position:relative;width:2rem;height:1.1rem;border-radius:999px;background:var(--surface-active);transition:background .12s}.switch-track::after{content:'';position:absolute;top:.15rem;left:.15rem;width:.8rem;height:.8rem;border-radius:50%;background:var(--muted);transition:transform .12s,background .12s}.switch input:checked+.switch-track{background:rgb(from var(--accent) r g b / .4)}.switch input:checked+.switch-track::after{transform:translateX(.9rem);background:var(--accent)}.checks .switch input:checked+.switch-track{background:rgb(from var(--critical,#e5534b) r g b / .3)}.checks .switch input:checked+.switch-track::after{background:var(--critical,#e5534b)}.switch input:focus-visible+.switch-track{outline:2px solid var(--accent);outline-offset:2px}.options-footer{display:flex;flex-wrap:wrap;grid-column:1;grid-row:3;align-items:end;gap:.7rem;min-width:0;margin-top:1rem}.options-footer slot[name=before-run]{display:contents}.agentic-fields{display:grid;gap:.65rem;padding:.85rem .9rem 1rem}.agentic-panel .panel-head{align-items:center}.prompt-row{display:flex;align-items:start;gap:.4rem;min-width:0}.prompt-row textarea{flex:1;width:0}.prompt-action{display:grid;place-items:center;flex:0 0 auto;width:1.5rem;height:1.5rem;padding:.25rem;border:0;border-radius:4px;color:var(--muted);background:0 0}.prompt-action:hover{color:var(--text);background:var(--surface-active)}.prompt-action svg{width:1rem;height:1rem;fill:none;stroke:currentColor;stroke-width:1.4}textarea{min-width:0;resize:vertical;padding:.4rem .5rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.76rem}.run{padding:.48rem .8rem;border:0;border-radius:6px;color:var(--bg);background:var(--accent);font-size:.8rem;font-weight:600}.run:disabled{opacity:.45}.summary{align-self:end;padding-block:.48rem;color:var(--muted);font-size:.74rem}.history{display:grid;gap:.6rem}.scan-row{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:1rem;padding:.85rem .9rem}.scan-row+.scan-row{border-top:1px solid var(--border)}.scan-main{min-width:0}.scan-title{display:flex;align-items:center;gap:.45rem;min-width:0}.scan-title strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.82rem}.scan-meta{display:block;margin-top:.25rem;color:var(--muted);font-size:.7rem}.status{display:inline-flex;align-items:center;gap:.3rem;padding:.15rem .4rem;border-radius:999px;font-size:.66rem;font-weight:600;text-transform:capitalize}.status::before{content:'';width:.4rem;height:.4rem;border-radius:50%;background:currentColor}.status.running{color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.status.completed{color:#48b878;background:rgb(72 184 120 / .1)}.status.stopped{color:var(--muted);background:var(--surface-active)}.scan-actions{display:flex;align-items:center;gap:.45rem}.action{padding:.35rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font-size:.72rem;white-space:nowrap}.action:hover{border-color:var(--muted);background:var(--surface-active)}.empty{margin:0;padding:1.2rem;color:var(--muted);font-size:.8rem}@container scan-page (max-width: 48rem){gap:.7rem}.scope-grid{grid-template-columns:1fr}.scope-pane+.scope-pane{border-top:1px solid var(--border);border-left:0}.checks{margin-top:.8rem}.offline-help{max-width:100%;white-space:normal}.options-footer{margin-top:.8rem}.bundle-stats{grid-template-columns:repeat(2,minmax(0,1fr));gap:.45rem .65rem}.scope-head{flex-wrap:wrap}.scope-head p{flex-basis:100%;justify-content:start;margin-left:1.4rem;text-align:left}.scope-head p span{white-space:normal}.scope-head p span+span{padding-left:0;border-left:0}.scan-row{grid-template-columns:1fr;gap:.55rem}.scan-actions{justify-content:flex-start}.head-tabs{margin-left:0}`;var Xr=[{key:"metro",label:"metro",subtitle:"Metro bundle contents"},{key:"run",label:"run",subtitle:"Node.js CLI"},{key:"add",label:"add",subtitle:"Manually added files"}];function Qr(r){let e=r.filter(i=>i.id!=="all");if(e.length===0)return null;let t=new Map(e.map(i=>[String(i.id).replace(/^reason:/u,""),i]));return t.size!==e.length||[...t.keys()].some(i=>!Xr.some(s=>s.key===i))?null:[{id:"",label:"All files",subtitle:"Everything"},...Xr.filter(i=>t.has(i.key)).map(({key:i,...s})=>({...s,id:t.get(i).id,subtitle:i==="run"&&t.has("metro")?"Bundler and Node.js CLI":s.subtitle}))]}var zt={dependencies:l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="4" cy="8" r="2"/><circle cx="12" cy="4" r="2"/><circle cx="12" cy="12" r="2"/><path d="M6 8h2M10.2 5.3 6 7.3M10.2 10.7 6 8.7"/></svg>`,code:l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5.5 3-3 5 3 5M10.5 3l3 5-3 5M9 2.5 7 13.5"/></svg>`,agentic:l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m8 1.8.8 4.4L12.5 8l-3.7 1.8L8 14.2l-.8-4.4L3.5 8l3.7-1.8Z"/><path d="m13 2 .25 1.25L14.5 3.5 13.25 3.25 13 2ZM3 11.5l.2 1 .95.2-.95.2-.2 1-.2-1-.95-.2.95-.2Z"/></svg>`,report:l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 1.8h5l3 3V14H4zM9 1.8V5h3M6 8h4M6 10.5h4"/></svg>`},Tt=class extends w{static properties={source:{attribute:!1},loadBundle:{attribute:!1},loadModels:{attribute:!1},loadReportSources:{attribute:!1},canRun:{attribute:!1},_loadingBundle:{state:!0},_bundleError:{state:!0},_tab:{state:!0},_mode:{state:!0},_bundles:{state:!0},_repositories:{state:!0},_reportMode:{state:!0},_reportInput:{state:!0},_reportRestore:{state:!0},_scans:{state:!0},_selectedRepoId:{state:!0},_selectedBundleId:{state:!0},_reason:{state:!0},_excluded:{state:!0},_excludedModules:{state:!0},_prompts:{state:!0},_options:{state:!0},_regimes:{state:!0},_regimesReady:{state:!0},_notice:{state:!0}};static styles=Jr;constructor(){super(),this.loadModels=ae,this.canRun=!0,this._tab="new",this._mode="code",this.source=null,this.loadBundle=null,this._loadingBundle=!1,this._bundleError=null,this._bundles=[],this._repositories=[],this._reportMode="link",this._reportInput=null,this._reportRestore=null,this._scans=[],this._selectedRepoId=this._bundles[0]?.repoId??"unattached",this._selectedBundleId=this._bundles[0]?.id??null,this._reason=this._bundles[0]?.reasons[0]?.id??"",this._excluded=new Set,this._excludedModules=new Set,this._nextPromptId=1,this._prompts=[{id:1,text:""}],this._options={analyzer:"generic",model:null,effort:null,cached:!1,isolate:!1},this._regimes=[],this._regimesReady=!1,this._notice=null,this._timers=new Set}willUpdate(e){if(e.has("source")){this._bundles=this.source?.bundles??[],this._repositories=this.source?.repositories??[],this._scans=this.source?.scans??[],this._excluded=new Set,this._excludedModules=new Set;let t=this._bundles.find(i=>i.id===this._selectedBundleId)??this._bundles[0];this._selectedRepoId=t?.repoId??"unattached",this._selectedBundleId=t?.id??null,this._reason=t?.reasons?.[0]?.id??""}}updated(e){(e.has("source")||e.has("loadBundle"))&&this._loadSelectedBundle()}async _loadSelectedBundle(){this._bundleController?.abort(),this._loadingBundle=!1,this._bundleError=null;let e=this._bundle;if(!this.loadBundle||!e||Array.isArray(e.files))return;let t=this._bundleController=new AbortController;this._loadingBundle=!0;try{let i=await this.loadBundle(e,t.signal);if(t.signal.aborted)return;this._bundles=this._bundles.map(s=>s.id===e.id?i:s),this._reason=i.reasons?.[0]?.id??""}catch(i){t.signal.aborted||(this._bundleError=String(i?.message??i))}finally{t.signal.aborted||(this._loadingBundle=!1)}}disconnectedCallback(){super.disconnectedCallback(),this._bundleController?.abort();for(let e of this._timers)clearTimeout(e);this._timers.clear()}get _repoBundles(){return this._bundles.filter(e=>e.repoId===this._selectedRepoId)}get _bundle(){return this._repoBundles.find(e=>e.id===this._selectedBundleId)}get _reasonData(){return this._bundle?.reasons.find(e=>e.id===this._reason)??this._bundle?.reasons[0]}_packageLabel(e){return e==="__own__"?"Own code":e}get _files(){let e=this._reasonData,t=e?.fileModules,i=e?.filePaths?new Set(e.filePaths):null;return kt(this._bundle?.files).filter(s=>(t==null||t.includes(s.module))&&(i==null||i.has(s.path))).toSorted((s,o)=>o.bytes-s.bytes)}render(){return l`<div class="wrap"><div class="head"><div class="head-title"><slot name="navigation"></slot><h1>Scans</h1></div><div class="head-tabs" role="tablist" aria-label="Scan views"><button class="${this._tab==="new"?"active":""}" role="tab" aria-selected="${this._tab==="new"}" @click="${()=>{this._tab="new"}}">New scan</button> <button class="${this._tab==="history"?"active":""}" role="tab" aria-selected="${this._tab==="history"}" @click="${()=>{this._tab="history"}}">Scan history</button></div></div><p class="intro">${this._mode==="report"?"Choose inputs and start a scan. Save the report when it finishes.":"Choose a bundle and start a scan. Save the report when it finishes."}</p>${this._notice?l`<p class="notice" role="status">${this._notice}</p>`:u} ${this._bundleError?l`<p class="notice" role="alert">Couldn’t load bundle: ${this._bundleError}<button @click="${()=>{this._loadSelectedBundle()}}">Retry</button></p>`:u} ${this._tab==="new"?this._newScan():this._history()}</div>`}_newScan(){let e=this._mode,t=this._bundle,i=e==="code"?this._files:t?.files??[],s=this._excluded,o=this._excludedModules,n=i.filter(h=>!s.has(h.path)&&!o.has(h.module)),a=xe(t?.files?n:null),c=new Map;for(let h of i){let g=c.get(h.module)??{bytes:0,count:0,included:0};g.bytes+=h.bytes,g.count++,s.has(h.path)||g.included++,c.set(h.module,g)}let d=[...c.keys()].toSorted((h,g)=>c.get(g).bytes-c.get(h).bytes||this._packageLabel(h).localeCompare(this._packageLabel(g))),f=i.slice(0,80),p=d.filter(h=>!o.has(h)).length,b=this._reportInput?.mode===this._reportMode?this._reportInput.inputs:[];return l`<div class="setup"><section class="panel mode-panel" aria-labelledby="scan-mode-heading"><div class="panel-head"><h2 id="scan-mode-heading">Scan mode</h2><p>Choose what the server should analyze</p></div><div class="mode-grid" role="tablist" aria-label="Scan mode">${[["dependencies","Dependency alerts","Revalidate incoming alerts against actual code"],["code","Code","Run a full scan of the codebase"],["agentic","Agentic","Free-form analysis with your instructions"],["report","Reports","Link saved reports or merge scan results"]].map(([h,g,m])=>l`<button type="button" role="tab" aria-selected="${e===h}" class="${`mode-option ${e===h?"active":""}`}" @click="${()=>this._changeMode(h)}"><span class="mode-title">${zt[h]}<strong>${g}</strong></span><span>${m}</span></button>`)}</div>${e==="code"?l`<div class="subtype-wrap"><div class="subtype-options" role="radiogroup" aria-label="Code subtype">${[["security","Security","Security findings only"],["generic","Generic","Free-form code scan: wide-scoped, most results"],["correctness","Correctness","Guided correctness scan"],["advanced","Advanced","Merge multiple regimes"]].map(([h,g,m])=>l`<button type="button" role="radio" aria-checked="${this._options.analyzer===h}" class="${`subtype-option ${this._options.analyzer===h?"active":""}`}" @click="${()=>this._setOption("analyzer",h)}"><strong>${g}</strong><span>${m}</span></button>`)}</div><p class="subtype-help">Focusing controls how effort is spent: while Generic can also find security issues, a focused Security scan is likely to find more.</p></div>`:u} ${e==="report"?l`<div class="subtype-wrap"><div class="subtype-options report-subtypes" role="radiogroup" aria-label="Reports submode">${[["link","Link","Link findings across saved reports"],["merge","Merge","Combine scan results for one bundle"]].map(([h,g,m])=>l`<button type="button" role="radio" aria-checked="${this._reportMode===h}" class="${`subtype-option ${this._reportMode===h?"active":""}`}" @click="${()=>{this._reportMode=h,this._reportRestore=null}}"><strong>${g}</strong><span>${m}</span></button>`)}</div></div>`:u}</section>${e==="report"?l`<scan-report-inputs .mode="${this._reportMode}" .loadSources="${this.loadReportSources}" .restore="${this._reportRestore}" @report-inputs-change="${h=>{this._reportInput=h.detail}}"></scan-report-inputs>`:this._sourcePanel(t,i)} ${e==="code"?l`<details class="panel scope-panel"><summary class="scope-head"><svg class="scope-chevron" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 3 5 5-5 5"/></svg><h2>Source filter</h2><p><span>${n.length} of ${i.length} files · ${p} of ${d.length} packages</span> <span>${W(a.bytes)} · ${a.lines==null?"\u2014":a.lines.toLocaleString()} LoC</span></p></summary><div class="scope-grid"><section class="scope-pane package-pane" aria-label="Packages in bundle"><div class="pane-head"><strong>Packages</strong><span>${d.length} total · sorted by size</span></div><div class="package-list">${d.map(h=>{let{bytes:g,count:m,included:v}=c.get(h),$=!o.has(h);return l`<label class="${`package-row ${$?"":"excluded"}`}"><input type="checkbox" .checked="${$}" @change="${_=>this._toggleModule(h)}"><span class="package-name">${this._packageLabel(h)}</span><span class="package-size">${W(g)} · ${v}/${m}</span></label>`})}</div></section><section class="scope-pane file-panel" aria-label="Largest files in bundle"><div class="pane-head"><strong>Largest files</strong><span>showing ${f.length} of ${i.length}</span></div>${i.length===0?l`<p class="empty">No files in this selection.</p>`:l`<div class="file-list">${f.map(h=>{let g=!s.has(h.path)&&!o.has(h.module);return l`<label class="${`file ${g?"":"excluded"}`}"><input type="checkbox" .checked="${g}" @change="${m=>this._toggleFile(h,m.target.checked)}"><span class="file-copy"><span class="file-path" title="${h.path}">${h.path}</span><span class="file-meta">${h.size} · ${this._packageLabel(h.module)}</span></span></label>`})}</div>`}</section></div></details>`:u} ${e==="agentic"?this._agenticPanel():u}<slot name="access"></slot>${this._optionsPanel(e,t,e==="report"?b.length:n.length)}</div>`}_sourcePanel(e,t){let i=this._mode==="code"?this._repoBundles.map(d=>d.files?{...d,files:kt(d.files)}:d):this._repoBundles,{lines:s}=xe(e?.files?t:null),o=new Map;for(let d of this._bundles)o.set(d.repoId,(o.get(d.repoId)??0)+1);let n=o.size>1,a=["code","agentic"].includes(this._mode)&&e!=null&&(!e.filename.toLowerCase().endsWith(".map")||e.reasons?.some(d=>d.id!=="all")),c=this._repositories.map(d=>{let f=o.get(d.id)??0;return{value:d.id,label:d.label,detail:`${f} ${f===1?"bundle":"bundles"}`,special:d.id==="unattached"}});return l`<section class="panel source-panel" aria-busy="${this._loadingBundle}"><div class="panel-head"><h2>Source</h2></div><div class="${`source-choice ${n?"":"single-repository"}`}">${n?l`<div class="field"><span>Repository</span><repository-selector .options="${c}" .value="${this._selectedRepoId}" @repository-change="${d=>this._selectRepoById(d.detail.value)}"></repository-selector></div>`:u}<div class="field">${n?l`<span>Bundle</span>`:u}${i.length>0?l`<bundle-selector .bundles="${i}" .value="${e?.id??null}" @bundle-change="${d=>this._selectBundleById(d.detail.value)}"></bundle-selector>`:l`<div class="choice-empty">${this._bundles.length===0?"No stored bundles.":"No stored bundles for this repository."}</div>`}</div><div class="source-footer"><div class="bundle-stats" aria-label="Bundle statistics"><div class="metric"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><ellipse cx="8" cy="4" rx="5" ry="2"/><path d="M3 4v8c0 1.1 2.2 2 5 2s5-.9 5-2V4M3 8c0 1.1 2.2 2 5 2s5-.9 5-2"/></svg><strong>${e?.size??"\u2014"}</strong><span>bundle size</span></div><div class="metric">${zt.report}<strong>${t.length}</strong><span>files</span></div><div class="metric">${zt.code}<strong>${s==null?"\u2014":s.toLocaleString()}</strong><span>LoC</span></div><div class="metric">${L(oe)}<strong>${new Set(t.map(d=>d.module)).size}</strong><span>packages</span></div></div>${a?l`<div class="scope-slot">${this._scopeField(e)}</div>`:u}</div></div></section>`}_scopeField(e){if(!["code","agentic"].includes(this._mode))return u;let t=(e?.reasons??[]).filter(o=>o.id!=="all");if(t.length===0)return u;let i=this._mode==="agentic",s=Qr(t);if(s){let o=s.find(n=>n.id===this._reason)??s[0];return l`<div class="scope-toggle"><div class="scope-options" role="radiogroup" aria-label="${i?"Choose agentic scope":"Choose scan scope"}" aria-describedby="scan-scope-description">${s.map(n=>l`<label class="scope-option"><input type="radio" name="scan-scope" value="${n.id}" .checked="${o.id===n.id}" @change="${()=>this._changeReason(n.id)}"><span>${n.label}</span></label>`)}</div><span class="scope-description" id="scan-scope-description">${o.subtitle}</span></div>`}return l`<label class="scope-field"><span>Scope</span><select id="${i?"scan-agentic-scope":"scan-reason"}" aria-label="${i?"Choose agentic scope":"Choose scan scope"}" @change="${o=>this._changeReason(o.target.value)}"><option value="" .selected="${I(!this._reason||this._reason==="all")}">All files</option>${t.map(o=>l`<option value="${o.id}" .selected="${I(o.id===this._reason)}">${o.label??o.id}</option>`)}</select></label>`}_optionsPanel(e,t,i){let s=e==="report"?`${i} ${this._reportMode==="merge"?"scan results":"reports"} selected`:`${t?.filename??"No bundle selected"} \xB7 ${i} files will be analyzed`,o=e==="code"&&this._options.analyzer==="advanced",n=!this.canRun||(e==="report"?i===0:t==null||i===0||o&&(!this._regimesReady||this._regimes.length===0));return l`<section class="panel options"><div class="options-grid">${o?l`<scan-regime-editor .loadModels="${this.loadModels}" .value="${this._regimes}" @regimes-change="${a=>{this._regimesReady=a.detail.ready,this._regimes=a.detail.value}}"></scan-regime-editor>`:l`<scan-model-picker .loadModels="${this.loadModels}" ?has-extra="${e==="code"}" .value="${this._options.model}" .effort="${this._options.effort}" @model-change="${a=>{this._options={...this._options,model:a.detail.model,effort:a.detail.effort}}}">${e==="code"?l`<scan-depth-toggle slot="effort-extra" .isolate="${this._options.isolate}" @depth-change="${a=>this._setOption("isolate",a.detail.isolate)}"></scan-depth-toggle>`:u}</scan-model-picker>`}</div><div class="options-footer"><slot name="before-run"></slot><button type="button" class="run" ?disabled="${n}" @click="${()=>this._runScan()}">${e==="report"?this._reportMode==="merge"?"Merge results":"Link reports":"Run scan"}</button><span class="summary">${s}</span></div><div class="checks"><label class="switch"><input type="checkbox" aria-describedby="${this._options.cached?"offline-help":u}" .checked="${this._options.cached}" @change="${a=>this._setOption("cached",a.target.checked)}"><span class="switch-track" aria-hidden="true"></span><span>Offline</span></label>${this._options.cached?l`<small class="offline-help" id="offline-help">Cache only, no new model requests</small>`:u}</div></section>`}_history(){return l`<section class="panel history"><div class="panel-head"><h2>Scan history</h2><p>${this._scans.length} scans</p></div>${this._scans.length===0?l`<p class="empty">No scans yet.</p>`:this._scans.map(e=>this._scanRow(e))}</section>`}_scanRow(e){let t=e.status==="completed"?e.reportSaved?l`<button type="button" class="action" @click="${()=>this._deleteSavedReport(e)}">Delete saved report</button>`:l`<button type="button" class="action" @click="${()=>this._saveReport(e)}">Save report</button>`:u;return l`<div class="scan-row"><div class="scan-main"><div class="scan-title"><strong>${e.bundleName}</strong><span class="${`status ${e.status}`}">${e.status}</span></div><span class="scan-meta">${e.reason} · ${e.files} ${e.mode==="report"?e.reportMode==="merge"?"results":"reports":"files"} · ${e.createdAt}${e.duration?` \xB7 ${e.duration}`:""}${e.reportSaved?" \xB7 Report saved":e.status==="completed"?" \xB7 Report available":""}</span></div><span class="scan-actions">${t}${e.status==="running"?l`<button type="button" class="action" @click="${()=>this._stopScan(e)}">Stop</button>`:u}${e.status==="stopped"?l`<button type="button" class="action" @click="${()=>this._restartScan(e)}">Restart as new scan</button>`:u}</span><span aria-hidden="true"></span></div>`}_selectBundle(e){this._selectedRepoId=e.repoId,this._selectedBundleId=e.id,this._reason=e.reasons?.[0]?.id??"",this._excluded=new Set,this._excludedModules=new Set,this._notice=null,this._loadSelectedBundle()}_selectBundleById(e){let t=this._repoBundles.find(i=>i.id===e);t!=null&&this._selectBundle(t)}_selectRepoById(e){if(e===this._selectedRepoId||!this._repositories.some(i=>i.id===e))return;this._selectedRepoId=e;let t=this._bundles.find(i=>i.repoId===e);this._selectedBundleId=t?.id??null,this._reason=t?.reasons[0]?.id??"",this._excluded=new Set,this._excludedModules=new Set,this._notice=null,this._loadSelectedBundle()}_changeMode(e){!["dependencies","code","agentic","report"].includes(e)||e===this._mode||(this._mode=e,this._reportInput=null,this._reportRestore=null,this._excluded=new Set,this._excludedModules=new Set,this._notice=null)}_changeReason(e){this._reason=e,this._excluded=new Set,this._excludedModules=new Set}_toggleFile(e,t){let i=new Set(this._excluded);t?i.delete(e.path):i.add(e.path),this._excluded=i}_toggleModule(e){let t=new Set(this._excludedModules);t.has(e)?t.delete(e):t.add(e),this._excludedModules=t}_setOption(e,t){this._options[e]!==t&&(e==="analyzer"&&t==="advanced"&&(this._regimesReady=!1,this._regimes.length===0&&(this._regimes=[{mode:this._options.analyzer,model:this._options.model,effort:this._options.effort,isolate:this._options.isolate}])),this._options={...this._options,[e]:t})}_agenticPanel(){return l`<section class="panel agentic-panel"><div class="panel-head"><h2>Agentic instructions</h2><button type="button" class="prompt-action" aria-label="Add prompt" @click="${()=>this._addPrompt()}"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3v10M3 8h10"/></svg></button></div><div class="agentic-fields">${Ve(this._prompts,e=>e.id,(e,t)=>l`<div class="prompt-row"><textarea aria-label="${`Prompt ${t+1}`}" rows="3" placeholder="${this._promptPlaceholder(t)}" .value="${I(e.text)}" @input="${i=>{this._prompts=this._prompts.map(s=>s.id===e.id?{...s,text:i.target.value}:s)}}"></textarea>${this._prompts.length>1?l`<button type="button" class="prompt-action" aria-label="${`Remove prompt ${t+1}`}" @click="${()=>this._removePrompt(e.id)}"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="m4 4 8 8M12 4l-8 8"/></svg></button>`:u}</div>`)}</div></section>`}_promptPlaceholder(e){let t=["","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth"][e];return t!=null?`What should the ${t?`${t} `:""}agent focus on?`:`What should agent ${e+1} focus on?`}async _addPrompt(){this._prompts=[...this._prompts,{id:++this._nextPromptId,text:""}],await this.updateComplete,this.renderRoot?.querySelector(".prompt-row:last-child textarea")?.focus()}_removePrompt(e){this._prompts.length>1&&(this._prompts=this._prompts.filter(t=>t.id!==e))}_runScan(){if(!this.canRun)return;let e=this._mode,t=e==="code"&&this._options.analyzer==="advanced";if(t&&(!this._regimesReady||this._regimes.length===0))return;let i=this._bundle,s=this._reportInput?.mode===this._reportMode?this._reportInput:null,o=s?.inputs??[],n=e==="code"?this._files.filter(d=>!this._excluded.has(d.path)&&!this._excludedModules.has(d.module)):i?.files??[];if(e==="report"&&(!s?.source||o.length===0)||e!=="report"&&(!i||n.length===0))return;let a={id:`scan-${Date.now()}`,mode:e,bundleId:e==="report"?this._reportMode==="merge"?s.source.id:null:i?.id??null,bundleName:e==="report"?s.source.label:i.filename,reason:e==="agentic"?this._reasonData?.label??"All files":e==="report"?this._reportMode==="merge"?"Merge scan results":"Link saved reports":e==="code"?this._reasonData?.label??"All files":"Dependencies",status:"running",createdAt:"Just now",duration:"",files:e==="report"?o.length:n.length,reportSaved:!1,cached:this._options.cached,isolate:e==="code"&&this._options.isolate,model:this._options.model,effort:this._options.effort};e==="code"&&(a.analyzer=this._options.analyzer),t&&(a.regimes=this._regimes.map(d=>({...d})),a.reason=`Advanced \xB7 ${a.regimes.length} regimes \xB7 ${a.reason}`,a.scopeId=this._reason,a.model=null,a.effort=null,a.isolate=!1),e==="agentic"&&(a.prompts=this._prompts.map(d=>d.text)),e==="report"&&(a.reportMode=this._reportMode,a.reportSource={...s.source},a.inputIds=o.map(d=>d.id)),this._scans=[a,...this._scans],this._tab="history",this._notice="Scan started. The server will update its status as work progresses.";let c=setTimeout(()=>{this._timers.delete(c),a.status==="running"&&(a.status="completed",a.duration="2m 14s",this._notice="Scan completed. Its report is ready to save.",this.requestUpdate())},2200);this._timers.add(c)}_stopScan(e){e.status==="running"&&(e.status="stopped",e.duration=e.duration||"stopped by user",this._notice="Scan stopped. It cannot continue, but you can restart it as a new scan.",this.requestUpdate())}_restartScan(e){if(this._options={...this._options,model:e.model??this._options.model,effort:e.effort??this._options.effort,cached:e.cached??!1,isolate:e.isolate??!1,analyzer:e.analyzer??"generic"},e.mode==="report"){this._mode="report",this._reportMode=e.reportMode==="link"?"link":"merge",this._reportInput=null,this._reportRestore={mode:this._reportMode,source:e.reportSource,inputIds:e.inputIds??[]},this._tab="new",this._notice="New report scan settings restored from the stopped run.";return}let t=this._bundles.find(i=>i.id===e.bundleId);t&&(this._selectBundle(t),this._mode=e.mode??"dependencies",e.mode==="agentic"&&(this._prompts=(e.prompts?.length>0?e.prompts:[""]).map(i=>({id:++this._nextPromptId,text:i}))),e.regimes?.length>0&&(this._options={...this._options,analyzer:"advanced"},this._regimes=e.regimes.map(i=>({...i})),this._regimesReady=!1),this._reason=t.reasons.find(i=>i.label===e.reason)?.id??t.reasons[0]?.id??"",e.regimes?.length>0&&(this._reason=e.scopeId??this._reason),this._tab="new",this._notice="New scan settings restored from the stopped run.")}_saveReport(e){e.reportSaved=!0,this._notice="Report saved. You can delete it from Reports and save this completed scan again.",this.requestUpdate()}_deleteSavedReport(e){e.reportSaved=!1,this._notice="Saved report deleted. The completed scan can be saved again.",this.requestUpdate()}};customElements.get("deepview-scan-page")||customElements.define("deepview-scan-page",Tt);var Nt=["@acme/auth","@acme/billing","@acme/catalog","@acme/checkout","@acme/config","@acme/crypto","@acme/data","@acme/identity","@acme/notifications","@acme/payments","@acme/search","@acme/storage","@acme/telemetry","@acme/ui","@acme/users","@acme/webhooks"],xs=Array.from({length:128},(r,e)=>{let t=Nt[e%Nt.length],i=9e3+e*7300%48e3;return{path:`packages/${t.slice(6)}/src/file-${String(e+1).padStart(3,"0")}.ts`,bytes:i,lines:180+e*137%960,module:t}}),ei=[{id:"repo-checkout",label:"acme/checkout"},{id:"repo-worker",label:"acme/worker-service"},{id:"unattached",label:"Unattached"}],$s=[{id:"bundle-checkout",filename:"checkout.stasis",repoId:"repo-checkout",repo:"acme/checkout",size:"48.2 MiB",files:[{path:"src/auth/session.ts",bytes:82e3,lines:1640,module:"@acme/auth"},{path:"src/payments/checkout.ts",bytes:74e3,lines:1480,module:"@acme/payments"},{path:"src/api/routes.ts",bytes:61e3,lines:1220,module:"@acme/api"},{path:"src/users/permissions.ts",bytes:42e3,lines:840,module:"@acme/users"},{path:"src/crypto/tokens.ts",bytes:36e3,lines:720,module:"@acme/crypto"},{path:"src/db/queries.ts",bytes:29e3,lines:580,module:"@acme/database"},{path:"src/webhooks/stripe.ts",bytes:22e3,lines:440,module:"@acme/payments"},{path:"src/config/env.ts",bytes:13e3,lines:260,module:"@acme/config"},...xs],reasons:[{id:"all",label:"All",fileModules:null},{id:"run",label:"run",fileModules:null},{id:"app",label:"app",fileModules:["@acme/auth","@acme/payments","@acme/api","@acme/users","@acme/crypto","@acme/config",...Nt]}]},{id:"bundle-worker",filename:"worker.stasis",repoId:"repo-worker",repo:"acme/worker-service",size:"16.7 MiB",files:[{path:"worker/queue.ts",bytes:54e3,lines:1080,module:"queue"},{path:"worker/handlers/process.ts",bytes:48e3,lines:960,module:"handlers"},{path:"worker/handlers/retry.ts",bytes:31e3,lines:620,module:"handlers"},{path:"worker/secrets.ts",bytes:19e3,lines:380,module:"secrets"},{path:"worker/metrics.ts",bytes:12e3,lines:240,module:"metrics"}],reasons:[{id:"all",label:"All",fileModules:null},{id:"run",label:"run",fileModules:["queue","handlers","secrets","metrics"]},{id:"app",label:"app",fileModules:["queue","handlers","metrics"]}]},{id:"bundle-unattached",filename:"detached-preview.stasis",repoId:"unattached",repo:"Unattached",size:"6.4 MiB",files:[{path:"src/index.ts",bytes:31e3,lines:620,module:"preview"},{path:"src/loader.ts",bytes:24e3,lines:480,module:"preview"},{path:"src/manifest.ts",bytes:18e3,lines:360,module:"preview"},{path:"src/worker.ts",bytes:15e3,lines:300,module:"worker"}],reasons:[{id:"all",label:"All",fileModules:null},{id:"run",label:"run",fileModules:["preview","worker"]}]}],ti=[{id:"scan-104",bundleId:"bundle-checkout",bundleName:"checkout.stasis",reason:"app",status:"completed",createdAt:"Today, 09:42",duration:"4m 18s",files:5,reportSaved:!0},{id:"scan-103",bundleId:"bundle-worker",bundleName:"worker.stasis",reason:"All",status:"running",createdAt:"Today, 09:51",duration:"1m 06s",files:5,reportSaved:!1},{id:"scan-102",bundleId:"bundle-checkout",bundleName:"checkout.stasis",reason:"run",status:"stopped",createdAt:"Yesterday, 17:20",duration:"38s",files:4,reportSaved:!1}];function ri(){return $s.map(r=>({...r,files:r.files.map(e=>({...e,size:W(e.bytes)})),reasons:r.reasons.map(e=>({...e,fileModules:e.fileModules?[...e.fileModules]:null}))}))}var ks=/^( *)(```|~~~)/u,le=/^( *)(?:[-*+]|\d{1,9}[.)]) +(?=\S)/u;function K(r){let e=[],t=-1,i="",s=0,o=0,n=0;for(let a of r.split(`
4
+ `)){let c=n;n+=a.length+1;let d=ks.exec(a);if(t!==-1){d&&d[2]===i&&d[1].length<=s+3&&(e.push([t,c+a.length]),t=-1);continue}if(d&&d[1].length<=o+3){t=c,i=d[2],s=d[1].length;continue}if(!a.trim())continue;let f=le.exec(a),p=/^ */u.exec(a)[0].length;f&&f[1].length<=o+3?o=f[0].length:p<o&&(o=0)}return t!==-1&&e.push([t,r.length]),e}function Z(r,e){return r.some(([t,i])=>e>=t&&e<i)}function z(r){return String(r??"").replaceAll(/\r\n?/gu,`
5
+ `)}var ke=/^## +(.*)$/gmu,Se=/^### +(.*)$/gmu,Y=/^#### +(.*)$/gmu,Ot=/^(.+):(\d+(?:-\d+)?)$/u;function qe(r){return/^[0-9a-f]{7,64}$/iu.test(r)}function T(r,e){let t=K(r),i=[...r.matchAll(e)].filter(s=>!Z(t,s.index));return i.map((s,o)=>({heading:s[1],body:r.slice(s.index+s[0].length+1,i[o+1]?.index)}))}function J(r,e){let t=K(r),i=[...r.matchAll(e)].find(s=>!Z(t,s.index));return i?{head:r.slice(0,i.index),subs:T(r,e)}:{head:r,subs:[]}}function Ee(r){let e=r.indexOf(`
6
+ `);return e===-1?{title:r.trim(),body:""}:{title:r.slice(0,e).trim(),body:r.slice(e+1)}}function Ss(r){let e=[];for(let t of r.split(`
7
+ `)){let i=t.trim();if(!i.startsWith("|")||/^[\s:|-]+$/u.test(i)&&i.includes("-"))continue;let s=i.replace(/^\|/u,"").replace(/\|$/u,"").split("|").map(o=>o.trim());e.push(s)}return e}function Ae(r){let e=Ss(r);if(e.length<2)return[];let t=e[0].map(s=>s.toLowerCase()),i=[];for(let s of e.slice(1)){if(s.length===t.length&&s.every((n,a)=>n.toLowerCase()===t[a]))continue;let o={};t.forEach((n,a)=>{n&&(o[n]=s[a]??"")}),i.push(o)}return i}function ii(r){let e=Object.create(null),t=Object.create(null),i=[],s=null,o="",n=[],a="",c=(p,b,h)=>{!p||p in e||(e[p]=h.trim(),t[p]=b)},d=()=>{s&&c(s,o,n.join(`
8
+ `)),s=null,o="",n=[]},f=p=>{(s?n:i).push(p)};for(let p of r.split(`
9
+ `)){let b=/^ {0,3}(```|~~~)/u.exec(p),h=b!==null&&(!a||b[1]===a);if(h&&(a=a?"":b[1]),h||a){f(p);continue}if(!p.trim()){s?d():i.push(p);continue}let g=/^\s*(?:[-*] +)?\*\*([^:*]+):\*\*\s*(.*)$/u.exec(p);if(g){d();let m=g[1].trim(),v=g[2],$;for(;($=/\s+[·•]\s+\*\*([^:*]+):\*\*\s*/u.exec(v))!==null;)c(m.toLowerCase(),m,v.slice(0,$.index)),m=$[1].trim(),v=v.slice($.index+$[0].length);s=m.toLowerCase(),o=m,n=[v];continue}if(/^\s*(?:#{1,6} |\||[-=*_]{3,}\s*$)/u.test(p)){d();continue}f(p)}return d(),{fields:e,labels:t,prose:i.join(`
10
+ `).trim()}}function Ge(r){let e=(r||"").trim(),t="",i=ce(e);i&&(e=i.label.trim(),t=i.url.trim());let s="",o=/#L(\d+)/u.exec(t);o&&(s=o[1]);let c=[...e.matchAll(/`([^`]+)`/gu)].map(p=>p[1].trim()).find(p=>!p.includes("(")&&(p.includes("/")||/\.\w/u.test(p)))??(e.replaceAll("`","").trim().split(/[\s,]+/u).find(Boolean)||""),d=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(c);d&&(c=d[1],s||(s=d[2]));let f=Ot.exec(c);return f?(s||(s=f[2]),{file:f[1],line:s,locationLink:t}):{file:c,line:s||"?",locationLink:t}}function Bt(r){return r.replaceAll("**","")}function ce(r){let e=String(r??""),t=Es(e,As(e)),i=Cs(e),s=e.indexOf("]");for(let o=e.indexOf("[");o!==-1;o=e.indexOf("[",o+1)){for(;s!==-1&&s<=o;)s=e.indexOf("]",s+1);for(let n of[s,t.get(o)??-1]){if(n===-1||n===o+1||e[n+1]!=="(")continue;let a=Rs(e,n+1,i);if(a!==null)return{label:e.slice(o+1,n),url:a,index:o}}}return null}function Es(r,e){let t=new Map,i=[];for(let s=0;s<r.length;s++){let o=r[s];si(r,s)?s++:o==="`"?s=e.get(s)??s:o==="["?i.push(s):o==="]"&&i.length>0&&t.set(i.pop(),s)}return t}function As(r){let e=[];for(let s=r.indexOf("`");s!==-1;s=r.indexOf("`",s)){let o=1;for(;r[s+o]==="`";)o++;e.push([s,o]),s+=o}let t=new Map,i=new Map;for(let s=e.length-1;s>=0;s--){let[o,n]=e[s],a=i.get(n);a!==void 0&&t.set(o,a+n-1),i.set(n,o)}return t}function Cs(r){let e=r.length,t=new Int32Array(e+1).fill(-1),i=new Int32Array(e+1).fill(-1),s=new Int32Array(e+1).fill(-1),o=new Int32Array(e+1).fill(-1);for(let c=e-1;c>=0;c--)t[c]=r[c]===")"?c:t[c+1],i[c]=/\s/u.test(r[c])?c:i[c+1],s[c]=r[c]===">"?c:s[c+1],o[c]=r[c]===`
11
+ `?c:o[c+1];let n=new Map,a=[];for(let c=0;c<e;c++){let d=r[c];si(r,c)?c++:i[c]===c?a.length=0:d==="("?a.push(c):d===")"&&a.length>0&&n.set(a.pop(),c)}return{balanced:n,nextClose:t,nextSpace:i,nextAngle:s,nextLine:o}}function Rs(r,e,t){let i=Ms(r,e,t);if(i)return i;let s=t.balanced.get(e);if(s!==void 0)return s>e+1?r.slice(e+1,s):null;let o=t.nextClose[e+1],n=t.nextSpace[e+1];return o===-1||o===e+1||n!==-1&&n<o?null:r.slice(e+1,o)}function Ms(r,e,t){if(r[e+1]!=="<")return"";let i=t.nextAngle[e+2],s=t.nextLine[e+2];return i===-1||s!==-1&&s<i||r[i+1]!==")"?"":r.slice(e+2,i)}var Ls=/\\([!-/:-@[-`{-~])/gu,Is=/[!-/:-@[-`{-~]/u;function si(r,e){return r[e]==="\\"&&Is.test(r[e+1]??"")}function oi(r){return typeof r=="string"?r.replace(Ls,"$1"):r}function ni(r){let e=/^\[(.+)\]$/u.exec(r.trim());return e?e[1].trim():r.trim()}function X(r){let e=(r||"").trim();return/^[-–—]+$/u.test(e)?"":e}var zs=/^## ([A-Z][A-Z_]*)\s*\(\d+\)\s*\n/mu;function Ts(r){switch(r.toUpperCase()){case"CRITICAL":return"critical";case"HIGH":return"high";case"MEDIUM":return"medium";case"LOW":return"low";case"HIGH_BUG":return"high_bug";case"BUG":return"bug";case"INFO":case"INFORMATIONAL":return"informational";default:return"medium"}}var li=r=>String(r??"").toLowerCase().replaceAll(/[^a-z]+/gu,""),ai=new Map([["high",8],["medium",6],["low",4]]);function Ns(r){if(r!==void 0)return ai.get(li(r))??ai.get("medium")}var Os=new Map([["confirmed","confirmed"],["falsepositive","refuted"],["uncertain","unknown"]]);function ci(r){let t=z(r).trim().split(zs);if(t.length===1)return null;let i=[];for(let s=1;s<t.length;s+=2){let o=Ts(t[s]);for(let n of t[s+1].split(/^### /mu).slice(1)){let a=Bs(n,o);a&&i.push(a)}}return i.length===0?null:{type:"security",source:"deepsec",findings:i}}function Bs(r,e){let{title:t,body:i}=Ee(r);if(!t)return null;let s=i.replace(/\n---\s*$/u,"").trim(),o={};for(let v of s.matchAll(/^- \*\*([^:*]+):\*\*\s*(.+)$/gmu))o[v[1].trim().toLowerCase()]=v[2].trim();let n=/^\*\*Recommendation:\*\*\s*/mu.exec(s),a=s,c="";n&&(a=s.slice(0,n.index),c=s.slice(n.index+n[0].length).trim());let d=a.split(`
12
+ `).filter(v=>!/^\s*- \*\*/u.test(v)).join(`
13
+ `).replaceAll("**","").trim(),f=[t,d].filter(Boolean).join(`
14
+
15
+ `),p=(o.file||"unknown").replace(/^`(.*)`$/u,"$1"),b=(o.lines||"").split(",").map(v=>v.trim()).find(Boolean)||"?",h={file:p,line:b,severity:e,description:f};c&&(h.recommendation=c.replaceAll("**",""));let g=Ns(o.confidence);g!==void 0&&(h.confidence=g);let m=Os.get(li(o.revalidation));return m&&(h.revalidate=m,h.revalidateSource="deepsec",o.reasoning&&(h.revalidateVerdict=o.reasoning.replaceAll("**",""))),o.slug&&(h.slug=o.slug),h}var di={critical:"Critical",high:"High",medium:"Medium",low:"Low",high_bug:"High bug",bug:"Bug",informational:"Informational"};var We={"claude-security":"Claude Security","codex-security":"Codex Security",deepsec:"DeepSec",piolium:"Piolium"};var Ke=["revalidation","refuted","unreachable","confirmed","partial","unknown"],Ps=new Set(Ke);function pi(r){return Ps.has(r?.revalidate)?r.revalidate:""}function Pt(r,e=r?.source){return Object.hasOwn(We,e)||pi(r)==="revalidation"}function Dt(r){if(!r)return"";for(let e of r.split(`
16
+ `))if(e.trim())return e.trim();return""}function Ht(r){return Number.isFinite(parseInt(r?.line,10))?`${r.file}:${r.line}`:r?.file??""}function Ut(r){if(typeof r!="string"||r.length===0)return!1;try{let e=new URL(r);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}function Ds(r,e){let t=K(r),i=0;return r.split(`
17
+ `).map(s=>{let o=i;return i+=s.length+1,Z(t,o)?s:e(s)}).join(`
18
+ `)}function ui(r){return Ds(String(r??""),e=>e.replace(/^( {0,3})\\(\\*#)/u,"$1$2"))}var Hs=new Map(Object.entries(di).map(([r,e])=>[e.toLowerCase(),r])),mi=new Map(Object.entries(We).map(([r,e])=>[e.toLowerCase(),r])),Us=new Set(Ke);function C(r){let e=/(`+)(.+?)\1(?!`)/u.exec(String(r??""));if(!e)return null;let t=e[2];if(t.length>2&&t.startsWith(" ")&&t.endsWith(" ")){let i=t.slice(1,-1);if(i.startsWith("`")||i.endsWith("`"))return i}return t}function Ze(r){let e=ce(String(r??""));return e?.index===0?{label:e.label,url:e.url}:null}function fi(r){let e=/^<(https?:[^>\s]*)>$/u.exec(r.trim());return e?e[1]:null}function gi(r){let e=Ot.exec(r);return e?{file:e[1],line:e[2]}:{file:r,line:"?"}}function js(r){let e=r.indexOf(".");return e>0?{exportName:r.slice(0,e),methodName:r.slice(e+1)}:{exportName:r}}function Q(r){let e=String(r??"").trim();return Hs.get(e.toLowerCase())??e}function Fs(r){let e={},t=r.trim(),i=/ · (`+)(.+?)\1$/u.exec(t);i&&(Object.assign(e,js(C(i[0]))),t=t.slice(0,i.index));let s=Ze(t),o=C(s?s.label:t);return o!==null&&Object.assign(e,gi(o)),s&&Ut(s.url)&&(e.location=s.url),e}var hi=" \xB7 flagged critical by the analyzer",Vs=" (varies across reports \u2014 ";function qs(r){let e={},t=r.trim();t.endsWith(hi)&&(e.critical=!0,t=t.slice(0,-hi.length));let i=t.indexOf(Vs);i!==-1&&(t=t.slice(0,i));let s=/^(.*?) — corrected (from|to) (.*)$/u.exec(t);return s?s[2]==="from"?(e.severity=Q(s[3]),e.correctedSeverity=Q(s[1])):(e.severity=Q(s[1]),e.correctedSeverity=Q(s[3])):e.severity=Q(t),e}var Gs=new Set(["max","xhigh","high","medium","low","minimal"]),Ws=new Set(["list","isolate"]);function Ks(r){return/\d/u.test(r)||/^(?:opus|sonnet|haiku|gpt|gemini|fable|mythos|llama|mistral)\b/iu.test(r)}function Ye(r){let e=r.trim(),t=mi.get(e.toLowerCase());if(t)return{source:t};let i={},s=[];for(let o of e.split(" \xB7 ").map(n=>n.trim()).filter(Boolean))o==="revalidate"&&!i.revalidate?i.revalidate="revalidation":Ws.has(o)&&!i.exportsMode?i.exportsMode=o:Gs.has(o)&&!i.effort?i.effort=o:s.push(o);return s.length>1?[i.type,i.model]=s:s.length===1&&(i[Ks(s[0])?"model":"type"]=s[0]),{run:i}}function jt(r){let e=r.trim(),t=Ze(e);return t?t.label.trim():fi(e)??e}function Zs(r){let e=Ze(r.trim());if(e){let t=e.url.split("/").at(-1)??"";return qe(t)?t:C(e.label)??t}return C(r)??r.trim()}function Ys(r){let e=C(r)??r.trim(),t=e.lastIndexOf("@");return{npm:t>0?{name:e.slice(0,t),version:e.slice(t+1)}:{name:e}}}function Js(r){let e=r.trim().toLowerCase();return e==="the revalidation pass itself"?"revalidation":Us.has(e)?e:void 0}var Xs=new Map([["location",(r,e)=>Object.assign(r,Fs(e))],["severity",(r,e)=>Object.assign(r,qs(e))],["confidence",(r,e)=>{let t=/^(\d+(?:\.\d+)?)\/10$/u.exec(e);t&&(r.confidence=Number(t[1]))}],["revalidation",(r,e)=>{let t=Js(e);t&&(r.revalidate=t)}],["revalidated by",(r,e)=>{let t=e.trim();t&&(r.revalidateSource=mi.get(t.toLowerCase())??t)}],["repository",(r,e)=>{r.repo={github:jt(e)}}],["introduced in",(r,e)=>{r.commitHash=Zs(e)}],["package",(r,e)=>{r.package=Ys(e)}],["priority",(r,e)=>{r.priority=/^-?\d+(?:\.\d+)?$/u.test(e)?Number(e):e}],["found while analyzing",(r,e)=>{r.discoveredIn=C(e)??e}],["detailed report",(r,e)=>{r.reportPath=C(e)??e}],["commit audited",(r,e)=>{r.auditedCommit=C(e)??e}],["id",(r,e)=>{r.id=C(e)??e}],...[["category","category"],["status","status"],["branch","branch"],["date created","dateCreated"],["detected at","detectedAt"],["committed at","committedAt"],["poc status","pocStatus"],["variant of","parent"],["slug","slug"]].map(([r,e])=>[r,(t,i)=>{t[e]=i}])]);function bi(r,e,t){let i=Xs.get(e.trim().toLowerCase());i&&i(r,t.trim())}var Qs=/^- \*\*([^*\n]+?):\*\* ?(.*)$/u;function vi(r){let e=r.split(`
19
+ `),t=0,i=()=>{for(;t<e.length&&!e[t].trim();)t++},s=()=>{let a=[];for(;t<e.length;){let c=Qs.exec(e[t]);if(!c)break;a.push([c[1].trim(),c[2].trim()]),t++}return a};i();let o=s();if(o.length>0)return{title:"",facts:o,rest:e.slice(t).join(`
20
+ `)};let n=[];for(;t<e.length&&e[t].trim();)n.push(e[t++]);return i(),o=s(),o.length===0?{title:"",facts:o,rest:r}:{title:de(n.join(`
21
+ `).trim()),facts:o,rest:e.slice(t).join(`
22
+ `)}}function de(r){return ui(r)}function _i(r,e){let t=new RegExp(`^#{${e}} +(.*)$`,"gmu"),i=K(r),s=[...r.matchAll(t)].filter(a=>!Z(i,a.index)),o=r.slice(0,s[0]?.index??r.length).trim(),n=s.map((a,c)=>({label:a[1].trim(),body:r.slice(a.index+a[0].length,s[c+1]?.index).trim()}));return{lead:o,sections:n}}var eo=/^(\d+)\. (.*)$/u;function yi(r){let e=[],t=K(r),i=0;for(let s of r.split(`
23
+ `)){let o=Z(t,i)?null:eo.exec(s);i+=s.length+1,o?e.push({ref:o[2].trim(),indent:o[1].length+2,note:[]}):e.length>0&&e.at(-1).note.push(s)}return e.map(s=>to(s))}function to({ref:r,indent:e,note:t}){let i={},s=Ze(r),o=fi(r),n=o===null?C(s?s.label:r):null;n!==null&&Object.assign(i,gi(n));let a=s?s.url:o;Ut(a)&&(i.url=a);let c=de(t.map(d=>d.slice(Math.min(e,/^ */u.exec(d)[0].length))).join(`
24
+ `).trim());return c&&(i.text=c),i}var wi=new Map([["impact","impact"],["reproduction","reproduction"],["recommendation","recommendation"],["confidence reasoning","confidenceReason"],["revalidation verdict","revalidateVerdict"],["revalidation recommendation","revalidateRecommendation"]]),ro=[...wi.keys()];function xi(r){let e=r.length,t=1/0;for(let i=r.length-1;i>=0;i--){let s=ro.indexOf(r[i].label.toLowerCase());if(s===-1||s>=t)break;t=s,e=i}return{paragraphs:r.slice(0,e),fields:r.slice(e).map(i=>[wi.get(i.label.toLowerCase()),i.body])}}function $i(r,e,t){let i=[],s=Dt(e),o=r.endsWith("\u2026")?r.slice(0,-1).trimEnd():"";!r||s===r||o&&s.startsWith(o)?i.push(e):i.push(r,e);for(let{label:n,body:a}of t)i.push(a?`**${n}:** ${a}`:`**${n}:**`);return i.filter(Boolean).join(`
25
+
26
+ `)}var io=/^<!--\s*DeepView findings export\b[^>]*-->/u,so=/^Case \d+ of \d+(?:\s|$)/u,oo=/^- \*\*([^*\n]+?):\*\* ?(.*)$/gmu,no=new Set(["evidence","severity correction","comment"]);function Si(r){let e=z(r).trim();if(!io.test(e))return null;let{head:t,subs:i}=J(e,ke),s=[];for(let{heading:o,body:n}of i){if(o.trim().toLowerCase()==="summary")continue;let a=ao(o);for(let c of T(n,Se))s.push(co(c,a))}return uo(lo(t),s)}function ao(r){let e=/^(.*?)\s*\(\d+\)\s*$/u.exec(r.trim());return Q(e?e[1]:r)}function lo(r){let e=new Map;for(let t of r.matchAll(oo)){let i=t[1].trim().toLowerCase();e.has(i)||e.set(i,t[2].trim())}return{sources:(e.get("source")??"").split(",").map(t=>Ye(t).source).filter(Boolean),analyzers:(e.get("analyzer")??e.get("analyzers")??"").split(";").map(t=>t.trim()).filter(Boolean),repo:e.has("repository")?jt(e.get("repository")):""}}function co({heading:r,body:e},t){let i=r.trim().replace(/^\d+\.\s+/u,""),s=J(e,Y).subs.filter(o=>so.test(o.heading.trim()));return s.length===0?[ki(e,4,i,t)]:s.map(o=>ki(o.body,5,i,t))}function ki(r,e,t,i){let{title:s,facts:o,rest:n}=vi(r),{lead:a,sections:c}=_i(n,e),d={file:"unknown",line:"?"},f=null;for(let[_,A]of o)_.trim().toLowerCase()==="analyzer"?f=Ye(A):bi(d,_,A);d.severity||(d.severity=i||"medium");let p=s||t,b=p!=="Untitled finding"&&p!==Ht(d),h=c.filter(_=>!no.has(_.label.toLowerCase())).map(_=>({label:_.label,body:de(_.body)})),{paragraphs:g,fields:m}=xi(h);d.description=$i(b?p:"",de(a),g);let v=c.filter(_=>_.label.toLowerCase()==="evidence").flatMap(_=>yi(_.body));v.length>0&&(d.evidence=v);for(let[_,A]of m)d[_]=A;let $=c.find(_=>_.label.toLowerCase()==="severity correction");return $?.body&&(d.correctedSeverityReason=de($.body)),{finding:d,analyzer:f}}function po(r,e){let t={source:null,run:{}};if(e.some(s=>s.analyzer!==null)){let s=new Set(e.map(o=>o.analyzer?.source??null));s.size===1&&!s.has(null)&&([t.source]=s);for(let o of e)o.analyzer?.run?Object.assign(o.finding,o.analyzer.run):o.analyzer?.source&&!t.source&&(o.finding.source=o.analyzer.source);return t}let i=r.analyzers.length===1?Ye(r.analyzers[0]):null;return i?.source?t.source=i.source:i?.run?t.run=i.run:r.analyzers.length===0&&r.sources.length===1&&([t.source]=r.sources),t}function uo(r,e){let t=e.flat(),{source:i,run:s}=po(r,t),o={},n=new Set(t.map(d=>d.finding.type).filter(Boolean)),a=s.type??(n.size===1?[...n][0]:null)??(i?"security":null);a&&(o.type=a),i&&(o.source=i);for(let d of["model","effort","exportsMode"])s[d]&&(o[d]=s[d]);r.repo&&(o.repo={github:r.repo});let c=e.map(d=>d.map(f=>f.finding));return c.every(d=>d.length===1)?o.findings=c.flat():o.groups=c,o}var ho=new Set(["critical","high","medium","low","high_bug","bug","informational"]);function Ei(r){let e=mo(r);if(!e)return null;let{severity:t,description:i,location:s,file:o,line:n}=e;return s?{severity:t,description:i,location:s}:{severity:t,description:i,file:o,line:n}}function mo(r){let e=r.indexOf(`
27
+ `),t=(e===-1?r:r.slice(0,e)).trim();if(!t)return null;let i=e===-1?"":r.slice(e+1),{sectionsText:s,metaText:o}=fo(i),n=go(s),a=bo(o),{file:c,line:d,locationLink:f}=vo(n.location||""),p=(a.severity||"").toLowerCase();return{severity:ho.has(p)?p:"medium",description:_o(t,n),location:f,file:c||"unknown",line:d}}function fo(r){let e=/^---\s*$/mu,t=e.exec(r);if(!t)return{sectionsText:r,metaText:""};let i=r.slice(0,t.index).trim(),s=r.slice(t.index+t[0].length).replace(/^\n/u,""),o=e.exec(s),n=o?s.slice(0,o.index):s;return{sectionsText:i,metaText:n}}function go(r){let e={},t=r.split(/^## /mu);for(let i=1;i<t.length;i++){let s=t[i],o=s.indexOf(`
28
+ `),n=(o===-1?s:s.slice(0,o)).trim().toLowerCase(),a=(o===-1?"":s.slice(o+1)).trim();n&&(e[n]=a)}return e}function bo(r){let e={};for(let t of r.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu))e[t[1].trim().toLowerCase()]=t[2].trim();return e}function vo(r){let e="",t="?",i="",s=r.match(/\[([^\]]+)\]\(([^)]+)\)/u);if(s){e=s[1].trim(),i=s[2];let n=s[2].match(/#L(\d+)/u);n&&(t=n[1])}else e=r.trim(),i=r.trim();let o=e.match(/^(.+):(\d+)$/u);return o&&(e=o[1],t==="?"&&(t=o[2])),{file:e,line:t,locationLink:i}}function _o(r,e){let t=[r];return e.details&&t.push(e.details),e.impact&&t.push(`Impact: ${e.impact}`),e["reproduction steps"]&&t.push(`Reproduction: ${e["reproduction steps"]}`),yo(t.join(`
29
+
30
+ `))}function yo(r){return r.replaceAll("**","")}var wo=new Set(["critical","high","medium","low","high_bug","bug","informational"]);function Ri(r){let e=z(r).trim();if(!e.startsWith("# "))return null;let t=e.split(/^# /mu).filter(s=>s.trim().length>0),i=[];for(let s of t){let o=xo(s);o&&i.push(o)}return i.length===0?null:{type:"security",source:"claude-security",findings:i}}function xo(r){let{title:e,body:t}=Ee(r);if(!e)return null;let{sectionsText:i,metaText:s}=$o(t),o=ko(i),n=So(s),a=Ro(o.evidence||""),{file:c,line:d,locationLink:f}=Mi(o.location||a[0]?.ref||""),p=(n.severity||"").toLowerCase(),b=wo.has(p)?p:"medium",h=Lo(e,o,a.length>0),g={file:c||"unknown",line:d,severity:b,description:h};f&&(g.location=f),a.length>0&&(g.evidence=a.map(Mo)),o["reproduction steps"]&&(g.reproduction=Eo(o["reproduction steps"])),o["recommended fix"]&&(g.recommendation=o["recommended fix"]),n.repository&&(g.repo={github:n.repository}),n.branch&&(g.branch=n.branch),n["date created"]&&(g.dateCreated=n["date created"]),n.status&&(g.status=n.status),n.category&&(g.category=n.category);let m=Ei(r);return m&&(g._idBasis=m),g}function $o(r){let e=/^---\s*$/mu,t=e.exec(r);if(!t)return{sectionsText:r,metaText:""};let i=r.slice(0,t.index).trim(),s=r.slice(t.index+t[0].length).replace(/^\n/u,""),o=e.exec(s),n=o?s.slice(0,o.index):s;return{sectionsText:i,metaText:n}}function ko(r){let e={};for(let t of r.split(/^## /mu).slice(1)){let{title:i,body:s}=Ee(t),o=i.toLowerCase();o&&(e[o]=s.trim())}return e}function So(r){let e={};for(let t of r.matchAll(/\*\*([^:]+):\*\*\s*(.+)/gu))e[t[1].trim().toLowerCase()]=t[2].trim();return e}function Mi(r){let e="",t="?",i="",s=ce(r);if(s){e=s.label.trim(),i=s.url.trim();let n=i.match(/#L(\d+)(?:-L?(\d+))?/u);n&&(t=n[2]?`${n[1]}-${n[2]}`:n[1])}else e=r.trim(),i=r.trim();e=oi(e.replaceAll("`","")).trim();let o=e.match(/^(.+):(\d+)(?:\s*[-–—]\s*L?(\d+))?$/u);return o&&(e=o[1],t==="?"&&(t=o[3]?`${o[2]}-${o[3]}`:o[2])),{file:e,line:t,locationLink:i,linked:s!==null}}function Eo(r){let e=r.split(`
31
+ `),t=e.findIndex(a=>a.trim());if(t===-1||!le.test(e[t])||e.some((a,c)=>c!==t&&le.test(a)))return r;let i=e[t].replace(/^ */u,""),s=i.replace(le,"");if(!s.trim())return r;let o=Ai(s)??Ai(i);if(o===null&&(le.test(s)||Co.test(i)))return r;let n=o===null?[s]:o.length===1?[o[0].step]:o.map(({number:a,step:c})=>`${a}. ${c}`);return e.splice(t,1,...n),e.join(`
32
+ `)}var Ao=/(?:^|[ \t])(\d{1,9})\)(?=[ \t]|$)/gu,Co=/^\d{1,9}\)(?=[ \t]|$)/u;function Ai(r){let e=[...r.matchAll(Ao)];if(e.length===0||e[0].index!==0)return null;let t=[];for(let[i,s]of e.entries()){let o=Number(s[1]);if(i>0&&o<=t[i-1].number)return null;let n=r.slice(s.index+s[0].length,e[i+1]?.index).trim();if(!n)return null;t.push({number:o,step:n})}return t}var Ci=/^[ \t]*(?:\d+[.)]|[-*+])\s+/u;function Ro(r){let e=[];for(let t of r.split(`
33
+ `))Ci.test(t)?e.push({ref:t.replace(Ci,"").trim(),note:[]}):e.length>0&&t.trim()&&e.at(-1).note.push(t.trim());if(e.length===0){let t=r.split(`
34
+ `).map(o=>o.trim()).filter(Boolean),i=t.findIndex(o=>ce(o)!==null);if(i===-1&&t.length!==1)return[];let s=i===-1?0:i;e.push({ref:t[s],note:t.filter((o,n)=>n!==s)})}return e.filter(t=>t.ref)}function Mo({ref:r,note:e}){let{file:t,line:i,locationLink:s,linked:o}=Mi(r),n={file:t||"unknown",line:i};s&&o&&(n.url=s);let a=e.join(`
35
+ `);return a&&(n.text=a),n}function Lo(r,e,t){let i=[r];return e.details&&i.push(e.details),e.evidence&&!t&&i.push(`**Evidence:**
36
+ ${e.evidence}`),e.impact&&i.push(`**Impact:** ${e.impact}`),i.join(`
37
+
38
+ `)}function Io(r){let e=(r||"").trim(),t="",i=/\[([^\]]+)\]\(([^)]+)\)/u.exec(e);i&&(e=i[1].trim(),t=i[2].trim());let s="",o=/#L(\d+)/u.exec(t);o&&(s=o[1]);let c=[...e.matchAll(/`([^`]+)`/gu)].map(p=>p[1].trim()).find(p=>!p.includes("(")&&(p.includes("/")||/\.\w/u.test(p)))??(e.replaceAll("`","").trim().split(/[\s,]+/u).find(Boolean)||""),d=/^(.*?)#L(\d+)(?:-L?\d+)?$/u.exec(c);d&&(c=d[1],s||(s=d[2]));let f=/^(.+):(\d+(?:-\d+)?)$/u.exec(c);return f?(s||(s=f[2]),{file:f[1],line:s,locationLink:t}):{file:c,line:s||"?",locationLink:t}}function Je({severity:r,description:e,ref:t,lineBullet:i="",id:s=""}){let o=Io(t),n=o.file||"unknown",a=o.line==="?"&&i?i:o.line,c=o.locationLink||(n==="unknown"&&s?`piolium:${s}`:"");return c?{severity:r,description:e,location:c}:{severity:r,description:e,file:n,line:a}}var zo=/^[\w.-]+\/[\w.-]+$/u;function Li(r){return zo.test(r)}function D(r){switch(((r||"").trim().split(/\s+/u)[0]||"").replaceAll(/[`*]+/gu,"").toUpperCase()){case"CRITICAL":return"critical";case"HIGH":return"high";case"MEDIUM":return"medium";case"LOW":return"low";case"INFO":case"INFORMATIONAL":return"informational";default:return""}}function Ce(r){let e=/^([CHML])-?\d+$/iu.exec((r||"").trim());return e?{C:"critical",H:"high",M:"medium",L:"low"}[e[1].toUpperCase()]:""}function Ft(r){let e=/^(critical|high|medium|low|informational|info)(?:[ -](?:severity|risk))?(?:[ -]findings?)?(?:\s*\(\d+\))?$/iu.exec((r||"").trim());return e?D(e[1]):""}function Ii(r){let e=/^(critical|high|medium|low|informational|info)\b/iu.exec((r||"").trim());return e?D(e[1]):""}function Qe(r){return/^variants?\s*(?:\(\d+\))?\s*:?$/iu.test((r||"").trim())}function et(r){let e=/^([CHML]-?\d{1,4}|(?:p|q|b|r|m|l|x|diff)\d{0,4}-\d{2,4})(?:-([A-Za-z0-9][\w-]*))?$/iu.exec(r||"");return e?{id:e[1].toUpperCase(),slug:e[2]||""}:null}function Xe(r){return(r||"").replaceAll("-"," ")}function Re(r){let e=(r||"").trim(),t=/^\[([^\]]+)\]\([^)]*\)$/u.exec(e);return ni(t?t[1]:e).toUpperCase()}function Vt(r){let e=/^\[([^\]]+)\]\(([^)]+)\)\s*[:—–-]*\s*(.*)$/u.exec(r);return e?{text:e[3]?`${e[1].trim()} ${e[3].trim()}`:e[1].trim(),link:e[2].trim()}:null}function qt(r){let e=r.search(/\s/u),t=(e===-1?r:r.slice(0,e)).replace(/[:.,—–-]+$/u,""),i=et(t);if(!i)return null;let s=(e===-1?"":r.slice(e+1)).replace(/^[:—–-]+\s*/u,"").trim();return{id:i.id,slug:i.slug,rest:s}}function Gt(r){let{text:e,link:t}=Vt(r)??{text:r,link:""},i=/^\[([^\]]+)\] *(.*)$/u.exec(e);if(i){let o=et(i[1].trim());return o?{id:o.id,title:i[2].trim()||Xe(o.slug)||o.id,link:t}:{id:i[1].trim().toUpperCase(),title:i[2].trim(),link:t}}let s=qt(e);return s?{id:s.id,title:s.rest||Xe(s.slug)||s.id,link:t}:{id:"",title:e.trim(),link:t}}function zi(r){let e={},t=o=>(/`([^`]+)`/u.exec(o)?.[1]??o.split(/\s+/u)[0]??"").trim(),i=/^\s*(?:[-*] +)?\*\*Target:?\*\*\s*(.*)$/imu.exec(r||"");if(i){let o=t(i[1]);Li(o)&&(e.repo=o)}let s=/^\s*(?:[-*] +)?\*\*Commit[^:*]*:?\*\*\s*(.*)$/imu.exec(r||"");if(s){let o=t(s[1]);qe(o)&&(e.commitHash=o)}return e}var Wt=["key code reference","key code","code reference","location","affected file","file","path"];function Kt(r){for(let e of Wt)if(r[e])return r[e];return""}function tt(r){return{id:Re(r.id||""),title:X(r.title),severity:X(r.severity),pocStatus:X(r["poc status"]||r.poc),status:X(r.status),parent:Re(X(r.parent||"")),location:X(r.location)}}function rt(r,e=""){let t=D(r.severity)||e||Ce(r.id)||"medium",{file:i,line:s,locationLink:o}=Ge(r.location||""),n={file:i||"unknown",line:s,severity:t,description:Bt(r.title||r.id)};return o?n.location=o:n.file==="unknown"&&r.id&&(n.location=`piolium:${r.id}`),n._idBasis=Je({severity:t,description:n.description,ref:r.location||"",id:r.id}),r.pocStatus&&(n.pocStatus=r.pocStatus),r.status&&(n.status=r.status),r.parent&&(n.parent=r.parent),n}function Zt(r,e,t){let i=[];for(let s of r.split(`
39
+ `)){let o=/^\s{0,3}(?:[-*+]|\d{1,3}[.)])\s+(.+)$/u.exec(s);if(!o)continue;let n=o[1].trim();if(/^\*\*[^:*]+:\*\*/u.test(n))continue;let a=Vt(n),c=a?.link??"";if(a)n=a.text;else{let m=/^\*\*([^*]+)\*\*\s*[:—–-]*\s*(.*)$/u.exec(n);m&&(n=m[2]?`${m[1].trim()} ${m[2].trim()}`:m[1].trim())}if(/^(?:none\b|no |n\/a\b)/iu.test(n))continue;let d=qt(n),f=d?.id??"",p=n;if(d){let m=Xe(d.slug);p=m&&d.rest?`${m}
40
+
41
+ ${d.rest}`:d.rest||m||d.id}let b=t.get(f),g={file:"unknown",line:"?",severity:D(b?.severity)||e||Ce(f)||"medium",description:Bt(p)};f?g.location=`piolium:${f}`:c&&(g.location=c),c.endsWith("report.md")&&(g.reportPath=c),b?.pocStatus&&(g.pocStatus=b.pocStatus),b?.status&&(g.status=b.status),b?.parent&&(g.parent=b.parent),i.push({id:f,finding:g})}return i}function Yt(r,e,t,i=""){let s=[];for(let n of Ae(r)){let a=tt(n);!a.id&&!a.title||(!a.parent&&t&&(a.parent=t),a.id&&!e.has(a.id)&&e.set(a.id,a),s.push({id:a.id,finding:rt(a,i)}))}if(s.length>0)return s;let o=Zt(r,i,e);for(let n of o)t&&!n.finding.parent&&(n.finding.parent=t);return o}var To=new Set(["technical findings detail","technical findings","detailed findings","findings detail","findings"]);function No(r){return To.has(r)||r.startsWith("findings by severity")}var Oo=/^(?:summary of findings|deferred|methodolog|executive|conclusion|attack surface|coverage|discoveries|scope|table of contents|contents|appendix|recommendation|remediation)/u;function Bo(r){return Oo.test(r)}function Ti(r){let{id:e}=Gt(r);return!!(e&&et(e))}function Po(r){let e=T(r,Se);return(e.length>0?e:T(r,Y)).some(({heading:i})=>Ti(i))}function Ni(r){let e=z(r).trim();if(!/^# +Security Audit Report\b/mu.test(e)&&!/^## +Technical Findings Detail\s*$/imu.test(e)&&!/^## +Findings by Severity\b/imu.test(e))return null;let t=jo(e),i=Fo(t["summary of findings"]||""),s=zi(J(e,ke).head),o=[],n=new Set,a=[],c=({id:f,finding:p})=>{o.push(p),f&&n.add(f)},d=f=>{for(let p of f)c(p)};for(let[f,p]of Object.entries(t)){let b=Ft(f);b||No(f)?d(Jt(p,b,i,a)):!Bo(f)&&Po(p)&&d(Jt(p,Ii(f),i,a))}for(let f of a)(!f.id||!n.has(f.id))&&c(f);for(let f of i.values())n.has(f.id)||c({id:f.id,finding:rt(f)});if(o.length===0)return null;for(let f of o)s.repo&&(f.repo={github:s.repo}),s.commitHash&&!f.auditedCommit&&(f.auditedCommit=s.commitHash);return{type:"security",source:"piolium",findings:o}}function Do(r,e,t,i){let s=[],o="";for(let{heading:n,body:a}of r){let c=Ft(n);if(c)s.push(...Jt(a,c,e,t)),o="";else if(Qe(n))s.push(...Uo(a,e,o,t,i));else{let d=Ho(n,a,e,t,i);s.push(...d),o=d[0]?.id||o}}return s}function Ho(r,e,t,i,s){let{head:o,subs:n}=J(e,Y),a=Oi(r,o,t,s),c=a!==null&&!a.id&&n.some(f=>!Qe(f.heading)&&Ti(f.heading)),d=a&&!c?[a]:[];return d.push(...Xt(n,t,i,s,a?.id||"")),d}function Uo(r,e,t,i,s){let{head:o,subs:n}=J(r,Y);return i.push(...Yt(o,e,t,s)),Xt(n,e,i,s,"")}function Xt(r,e,t,i,s){let o=[],n="";for(let{heading:a,body:c}of r){if(Qe(a)){t.push(...Yt(c,e,s??n,i));continue}let d=Oi(a,c,e,i);d&&(o.push(d),n=d.id||n)}return o}function Jt(r,e,t,i){let s=T(r,Se);if(s.length>0)return Do(s,t,i,e);let o=Xt(T(r,Y),t,i,e,null);if(o.length>0)return o;let n=Ae(r).map(tt).filter(a=>a.id||a.title);if(n.length>0){for(let a of n)!a.severity&&e&&(a.severity=e),a.id&&!t.has(a.id)?t.set(a.id,a):a.id||i.push({id:"",finding:rt(a,e)});return[]}return i.push(...Zt(r,e,t)),[]}function Oi(r,e,t,i=""){let s=r.trim();if(!s)return null;let{id:o,title:n,link:a}=Gt(s),c=t.get(o);!o&&n&&(c=[...t.values()].find(N=>N.title.toLowerCase()===n.toLowerCase()),o=c?.id??"");let{fields:d,labels:f,prose:p}=ii(e),b=D(d.severity)||D(c?.severity)||i||Ce(o)||"medium",h=Ge(Kt(d)),g=/\d+/u.exec(d.line||d.lines||"")?.[0]??"",m=h.line==="?"&&g?g:h.line,v=/\*\*Variant of:?\*\*\s*\[?([^\]\s)]+)/iu.exec(e),$=p.split(`
42
+ `).filter(N=>!/^\s*<a\s[^>]*>\s*<\/a>\s*$/iu.test(N)&&!/\*\*Variant of:?\*\*/iu.test(N)).join(`
43
+ `).trim(),_={file:h.file||"unknown",line:m,severity:b,description:qo(n||o,d,f,$)};h.locationLink?_.location=h.locationLink:_.file==="unknown"&&o&&(_.location=`piolium:${o}`),_._idBasis=Je({severity:b,description:_.description,ref:Kt(d),lineBullet:g,id:o});let A=d["poc status"]||d.poc||c?.pocStatus;A&&(_.pocStatus=A);let Me=d["detailed report"]||(a.endsWith("report.md")?a:"");Me&&(_.reportPath=Me),c?.status&&(_.status=c.status);let Le=c?.parent||(v?Re(v[1]):"");return Le&&(_.parent=Le),{id:o,finding:_}}function jo(r){let e=Object.create(null);for(let{heading:t,body:i}of T(r,ke)){let s=t.trim().toLowerCase();s&&(e[s]=s in e?`${e[s]}
44
+ ${i}`:i)}return e}function Fo(r){let e=new Map;for(let t of Ae(r)){let i=tt(t);i.id&&e.set(i.id,i)}return e}var Vo=new Set([...Wt,"severity","summary","files","poc","poc status","line","lines","detailed report","proof of concept","evidence","variant of","pattern","status","id","title"]);function qo(r,e,t,i){let s=[r];e.summary&&s.push(e.summary),i&&s.push(i);for(let[o,n]of Object.entries(e))!n||Vo.has(o)||s.push(`**${t[o]||o}:** ${n}`);return s.filter(Boolean).join(`
45
+
46
+ `)}var Go=[["deepview-md",Si],["deepsec",ci],["piolium",Ni],["claude-security",Ri]];function Qt(r){return Array.isArray(r?.findings)?r.findings:Array.isArray(r?.groups)?r.groups:null}function Bi(r){let e;try{let t=JSON.parse(r);return Qt(t)?{data:t,format:"json",reason:null}:{data:null,format:null,reason:"JSON, but not a report: no findings array"}}catch(t){e=t}for(let[t,i]of Go){let s=i(r);if(s)return{data:s,format:t,reason:null}}return{data:null,format:null,reason:`Not JSON, and not a recognized markdown format. (JSON error: ${e.message})`}}function Wo(r){let{data:e}=Bi(r);return e&&Pi(e)>0?e:null}function Pi(r){return(Qt(r)??[]).filter(e=>(Array.isArray(e)?e:[e]).some(t=>t&&typeof t=="object"&&Pt(t,t.source??r.source))).length}function Di(r,e){let t=(r.reports??[]).filter(n=>n.visible&&n.repoId!=null).flatMap(n=>{let a=Wo(n.content??"");return a?[{id:n.id,filename:n.filename,repoIds:[n.repoId],repo:n.repoFullName,directory:n.repoDirectory,analyzer:n.analyzer,appFindings:Pi(a)}]:[]}),i=new Map((r.repos??[]).map(n=>[n.repoId,{id:n.repoId,label:n.fullName}]));for(let n of t)i.has(n.repoIds[0])||i.set(n.repoIds[0],{id:n.repoIds[0],label:n.repo??String(n.repoIds[0])});let s=e.results??[],o=new Set(s.map(n=>n.bundleId));return{merge:{bundles:(e.bundles??[]).filter(n=>o.has(n.id)).map(n=>({...n,size:W(n.byteSize)})),results:s},link:{repositories:[...i.values()].filter(n=>t.some(a=>a.repoIds.includes(n.id))),reports:t}}}function Hi(r){return r.map(e=>{let t=e.login||String(e.id),i=e.name?.trim()||`@${t}`,s=i===`@${t}`?"":`@${t}`,o=i.replace(/^@/u,"").split(/\s+/u).filter(Boolean).slice(0,2).map(n=>n[0]).join("").toUpperCase();return{value:e.id,label:s?`${i} ${s}`:i,displayLabel:i,secondary:s,initials:o,disabled:e.disabled,detail:e.detail}})}function Ui(r,e){let t=e.normalize("NFKC").toLocaleLowerCase().trim().split(/\s+/u).filter(Boolean),i=r.filter(s=>t.every(o=>s.label.normalize("NFKC").toLocaleLowerCase().includes(o))).toSorted((s,o)=>s.label.localeCompare(o.label,void 0,{sensitivity:"base",numeric:!0}));return{pinned:[],sections:[{label:null,options:i}],facets:[],showFacets:!1,count:i.length,total:r.length}}var er=class extends E{static properties={users:{attribute:!1}};constructor(){super(),this.users=[],this.label="Choose user",this.placeholder="Choose user"}get searchLabel(){return"Search users"}get optionsLabel(){return"Users"}get noMatchesLabel(){return"No matching users"}get emptyLabel(){return"No users available"}get changeEvent(){return"user-change"}willUpdate(e){e.has("users")&&(this.options=Hi(this.users))}choices(){return Ui(this.options,this._query)}};customElements.get("user-selector")||customElements.define("user-selector",er);async function ee(){let r=await y("/api/auth/session",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)return null;let e=await r.json();return{id:e?.user?.id??null,role:typeof e?.user?.role=="string"?e.user.role:"none",csrfToken:typeof e?.csrfToken=="string"?e.csrfToken:null}}var te=x`.head{display:flex;align-items:center;gap:.6rem;min-height:2.1rem;margin-bottom:.55rem}.breadcrumb{display:inline-flex;align-items:center;gap:.35rem;flex:0 0 auto}.breadcrumb-manage{padding:.22rem .35rem;border:1px solid transparent;border-radius:5px;color:var(--muted);background:0 0;font:inherit;font-size:.82rem;cursor:pointer}.breadcrumb-manage:hover{color:var(--text);background:var(--surface-active);border-color:var(--border)}.breadcrumb-manage:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.breadcrumb-separator{color:var(--muted);font-size:1rem}.head h1{margin:0;font-size:1.65rem;font-weight:600;letter-spacing:-.035em}`;function re(){return l`<span class="breadcrumb"><button type="button" class="breadcrumb-manage" @click="${()=>{document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:"manage"},bubbles:!0,composed:!0}))}}">Manage</button><span class="breadcrumb-separator" aria-hidden="true">›</span></span>`}function Ko(r){document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:r},bubbles:!0,composed:!0}))}var ur=x`:host{display:block;padding:clamp(1.5rem,4vw,2.5rem) clamp(1rem,4vw,2.5rem);color:var(--text);container-type:inline-size}*{box-sizing:border-box}.wrap{max-width:68rem;margin:0 auto}.head{gap:.65rem;margin-bottom:.45rem}h1{font-size:1.65rem;font-weight:600;letter-spacing:-.035em}.intro{margin:0 0 1.6rem;color:var(--muted);font-size:.85rem;line-height:1.5}.count{display:inline-grid;place-items:center;min-width:1.45rem;height:1.45rem;padding:0 .4rem;border-radius:5px;background:var(--surface-active);color:var(--muted);font-size:.72rem;font-weight:500;font-variant-numeric:tabular-nums}button,input,select{font:inherit}button,input[type=checkbox],select{cursor:default}button:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:2px}input:not([type=checkbox]),select{min-width:0;height:2rem;padding:.3rem .55rem;border:1px solid var(--border);border-radius:6px;background:var(--bg);color:var(--text);font-size:.8rem}input::placeholder{color:var(--muted)}input[type=checkbox]{margin:0;width:.85rem;height:.85rem;accent-color:var(--accent)}.btn{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;height:2rem;padding:0 .7rem;border:1px solid var(--border);border-radius:6px;background:var(--bg);color:var(--text);font-size:.78rem;font-weight:500;white-space:nowrap}.btn:hover:not(:disabled){background:var(--surface-active);border-color:var(--muted)}.btn.primary{background:var(--accent);color:var(--bg);border-color:var(--accent)}.btn.primary:hover:not(:disabled){filter:brightness(1.1)}button:disabled,select:disabled{opacity:.5}.icon-btn{display:inline-grid;place-items:center;flex:0 0 auto;width:1.8rem;height:1.8rem;padding:0;border:1px solid transparent;border-radius:5px;color:var(--muted);background:0 0}.icon-btn:hover:not(:disabled){color:var(--text);background:var(--surface-active)}.icon-btn.danger:hover:not(:disabled){color:var(--critical,#e5534b);background:rgb(from var(--critical,#e5534b) r g b / .1)}.btn svg,.icon-btn svg{width:.9rem;height:.9rem}.avatar{position:relative;display:inline-grid;place-items:center;flex:0 0 auto;width:2rem;height:2rem;border-radius:50%;overflow:hidden;background:var(--surface-active);color:var(--muted);font-family:system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-size:.8rem;font-weight:600;user-select:none}.avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.avatar img.broken{display:none}.msg{margin:1rem 0;color:var(--muted);font-size:.85rem;line-height:1.5}.msg.error{color:var(--critical,#e5534b)}`;function qi(r,e){return l`<span class="avatar" aria-hidden="true"><span>${(e?.[0]??"?").toUpperCase()}</span> ${ot()?u:l`<img alt="" src="${`/api/avatar/${encodeURIComponent(r)}`}" @error="${t=>t.currentTarget.classList.add("broken")}">`}</span>`}var Zo=l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m10 2 4 4-8 8H2v-4l8-8Zm-1 1 4 4"/></svg>`,Yo=l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 4h12M6 4V2h4v2M4 4l.6 10h6.8L12 4M6.5 7v4m3-4v4"/></svg>`,rr=l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><path d="m4 4 8 8m0-8-8 8"/></svg>`,tr=l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><path d="M8 3v10M3 8h10"/></svg>`,Jo={admin:"Admin",manage:"Manager",triage:"Triage",view:"Viewer",none:"No access"},Xo={admin:"Manage workspace access and teams",manage:"Manage content and scans",triage:"Review and triage findings",view:"Read-only access",none:"No workspace access"},ir=class extends w{static properties={_role:{state:!0}};static styles=x`:host{display:block;padding:clamp(1.5rem,5vw,3rem) clamp(1rem,4vw,2.5rem);color:var(--text)}.wrap{max-width:68rem;margin:0 auto}h1{margin:0;font-size:clamp(1.7rem,4vw,2.35rem);font-weight:600;letter-spacing:-.04em}.intro{max-width:38rem;margin:.55rem 0 1.7rem;color:var(--muted);line-height:1.5}.pages{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.55rem;margin:0;padding:0;list-style:none}.pages li:last-child{grid-column:1/-1}.page{display:flex;align-items:center;gap:.8rem;width:100%;padding:.85rem 1rem;color:var(--text);background:var(--surface);border:1px solid var(--border);border-radius:9px;text-align:left;font:inherit;cursor:default;transition:background .12s,border-color .12s}.page:hover{background:var(--surface-active);border-color:var(--muted)}.page:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.page-icon{display:grid;place-items:center;width:2rem;height:2rem;flex:0 0 auto;color:var(--accent);background:rgb(from var(--accent) r g b / .1);border-radius:6px}.page-icon svg{width:1.05rem;height:1.05rem}.page-icon .file-icon{width:1.15rem;height:1.15rem}.page-icon .brand-deepview{--brand-bg:#2563eb;--brand-fg:#fff}.page-icon .brand-claude{--brand-bg:#d97757;--brand-fg:#fff}.page-icon .brand-codex{--brand-bg:#fff;--brand-fg:#000}.page-icon .brand-vercel{--brand-bg:#000;--brand-fg:#fff}.page-icon .brand-piolium{--brand-bg:#fbb829;--brand-fg:#1c1b19}.page-icon .file-icon .bg{fill:var(--brand-bg)}.page-icon .file-icon .fg{fill:var(--brand-fg)}.page-icon .file-icon:is(.brand-codex,.brand-vercel) .bg{stroke:var(--brand-fg);stroke-width:.5}.page-copy{display:flex;min-width:0;flex-direction:column;gap:.15rem}.page-copy strong{font-size:.9rem;font-weight:600}.page-copy span{color:var(--muted);font-size:.76rem}.arrow{width:1rem;height:1rem;margin-left:auto;color:var(--muted);flex:0 0 auto}@media (max-width:42rem){.pages{grid-template-columns:1fr}.pages li:last-child{grid-column:auto}}`;constructor(){super(),this._role=null}connectedCallback(){super.connectedCallback(),ee().then(e=>(this._role=e?.role??"none",e))}render(){let e=(s,o,n,a)=>({view:s,title:o,text:n,icon:a}),t=[[this._role==="admin"?e("admin-users","Users","Review accounts and assign roles.","users"):null,this._role==="admin"?e("manage-teams","Teams","Organize repositories, members, and access.","team"):null],[this._role==="admin"?e("manage-repos","Repositories","Connect and select source repositories.","repo"):null,e("manage-bundles","Bundles","Manage source bundles and sourcemaps.","bundle")],[["admin","manage"].includes(this._role)?e("manage-scans","Scans","Run and monitor scans from stored bundles.","scan"):null,e("manage-reports","Reports","Review reports stored for your teams.","report")],[e("manage-history","History","Review workspace activity and triage changes.","history")]];return l`<div class="wrap"><h1>Manage</h1><p class="intro">${"Choose a page."}</p><nav aria-label="Management pages"><ul class="pages">${t.flat().filter(Boolean).map(s=>l`<li><button type="button" class="page" @click="${()=>Ko(s.view)}"><span class="page-icon" aria-hidden="true">${this._icon(s.icon)}</span> <span class="page-copy"><strong>${s.title}</strong><span>${s.text}</span></span> <svg class="arrow" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 4 4 4-4 4"/></svg></button></li>`)}</ul></nav></div>`}_icon(e){if(e==="bundle")return L(oe);let t={users:"M3.25 7.25a2.25 2.25 0 1 0 0-4.5 2.25 2.25 0 0 0 0 4.5Zm9.5 0a2.25 2.25 0 1 0 0-4.5 2.25 2.25 0 0 0 0 4.5ZM1 13.25c0-1.8 1.1-3 2.75-3s2.75 1.2 2.75 3M9.5 13.25c0-1.8 1.1-3 2.75-3S15 11.45 15 13.25M8 8.5a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm-3 5c0-2 1.2-3.5 3-3.5s3 1.5 3 3.5",repo:"M2 3.5A1.5 1.5 0 0 1 3.5 2h9A1.5 1.5 0 0 1 14 3.5v9a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 2 12.5v-9Zm3 2h6m-6 3h6m-6 3h3",report:"M4 1.5h5l3 3v10H4v-13Zm5 0v3h3m-6 3h4m-4 2h4m-4 2h3",bundle:"m8 1 5 2.8v8.4L8 15l-5-2.8V3.8L8 1Zm-5 2.8 5 2.8 5-2.8M8 6.6V15",history:"M8 2a6 6 0 1 0 6 6M8 4.5V8l2.25 1.5M10.5 2H14v3.5",team:"M8 8a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm-4 5c0-2 1.7-3 4-3s4 1 4 3M2 7h2m8 0h2M8 1v2m0 9v2",scan:"M3 3.5h10v9H3zM5.5 6h5M5.5 8h5M5.5 10h3"};return l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"><path d="${t[e]??t.report}/"></path></svg>`}};customElements.define("managed-admin-home",ir);async function Qo(){let r=await y("/api/admin/history",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)throw new Error(`HTTP ${r.status}`);let e=await r.json();if(!Array.isArray(e?.history))throw new Error("No history returned");return e.history}async function en(){try{let r=await y("/api/teams",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)return new Set;let e=await r.json();return new Set((Array.isArray(e?.teams)?e.teams:[]).flatMap(t=>Array.isArray(t.reports)?t.reports.map(i=>i.id):[]))}catch{return new Set}}var sr=class extends w{static properties={_history:{state:!0},_role:{state:!0},_allowedReports:{state:!0},_error:{state:!0},_filter:{state:!0},_query:{state:!0}};static styles=[te,x`:host{display:block;min-height:100%;padding:clamp(1.5rem,4vw,2.5rem) clamp(1rem,4vw,2.5rem);color:var(--text)}*{box-sizing:border-box}.wrap{max-width:68rem;margin:0 auto}.intro{margin:0 0 1rem;color:var(--muted);font-size:.82rem;line-height:1.5}.toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.55rem;margin:0 0 .8rem}.toolbar input,.toolbar select{height:2rem;padding:.28rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.74rem}.toolbar input{flex:1 1 20rem;min-width:12rem}.toolbar select{flex:0 1 10rem;min-width:9rem}.history{overflow:hidden;border:1px solid var(--border);border-radius:9px;background:var(--surface)}.row{display:grid;grid-template-columns:4.75rem minmax(8rem,10rem) minmax(0,1fr) auto;align-items:center;gap:.7rem;padding:.52rem .8rem;min-height:2.45rem}.row+.row{border-top:1px solid var(--border)}.kind{width:fit-content;padding:.14rem .38rem;border:1px solid var(--border);border-radius:999px;color:var(--muted);font-size:.62rem;font-weight:600;text-transform:capitalize}.kind.triage{color:var(--accent);border-color:rgb(from var(--accent) r g b / .35);background:rgb(from var(--accent) r g b / .08)}.actor{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:.72rem}.copy{display:grid;grid-template-columns:minmax(9rem,auto) minmax(0,1fr);min-width:0;align-items:baseline;gap:.45rem}.action{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.76rem}.detail{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:.67rem}time{color:var(--muted);font-size:.68rem;white-space:nowrap}.empty,.msg{margin:0;padding:1.2rem;color:var(--muted);font-size:.8rem;line-height:1.5}.msg.error{color:var(--critical,#c00)}@media (max-width:46rem){.row{grid-template-columns:4.5rem 8rem minmax(0,1fr) auto}.copy{grid-template-columns:minmax(8rem,auto) minmax(0,1fr)}}@media (max-width:38rem){.row{grid-template-columns:auto minmax(0,1fr) auto}.row .actor{grid-column:2;grid-row:2}.row .copy{grid-column:2;grid-row:1}time{grid-column:3;grid-row:1/3}}`];constructor(){super(),this._history=null,this._role=null,this._allowedReports=null,this._error=null,this._filter="all",this._query="",this._onActorFilter=e=>{let t=e.detail?.actor;typeof t!="string"||t.length===0||(this._query=t,this._filter="all")}}connectedCallback(){super.connectedCallback(),document.addEventListener("managed-history-filter",this._onActorFilter),this._load()}disconnectedCallback(){document.removeEventListener("managed-history-filter",this._onActorFilter),super.disconnectedCallback()}async _load(){try{let e=await ee();this._role=e?.role??"none",this._history=await Qo(),this._allowedReports=this._role==="manage"?await en():null}catch(e){this._error=String(e?.message??e)}}render(){let e=Array.isArray(this._history)?this._history:[],t=this._role==="manage"?e.filter(n=>n.kind==="triage"&&(this._allowedReports==null||this._allowedReports.has(n.reportId))):e,i=this._query.trim().toLocaleLowerCase(),s=i.length===0?t:t.filter(n=>tn(n).includes(i)),o=this._filter==="all"?s:s.filter(n=>n.kind===this._filter);return l`<div class="wrap"><div class="head">${re()}<h1>History</h1>${this._history?l`<span class="count">${o.length}</span>`:u}</div><p class="intro">${this._role==="admin"?"All workspace actions, including uploads, access changes, scans, and triage.":"Triage history for reports you can access."}</p>${this._history==null?u:l`<div class="toolbar" role="search"><input type="search" aria-label="Search history" placeholder="Search actions, users, repositories, reports…" .value="${this._query}" @input="${n=>{this._query=n.target.value}}"><select aria-label="Filter history by type" .value="${this._filter}" @change="${n=>{this._filter=n.target.value}}"><option value="all">All activity</option><option value="triage">Triage</option><option value="visibility">Visibility</option><option value="upload">Uploads</option><option value="scan">Scans</option></select></div>`} ${this._error?l`<p class="msg error">Couldn’t load history: ${this._error}</p>`:this._history==null?l`<p class="msg">Loading…</p>`:o.length===0?l`<div class="history"><p class="empty">No history available yet.</p></div>`:l`<div class="history" aria-label="Workspace history">${o.map(n=>this._row(n))}</div>`}</div>`}_row(e){let t=[e.repo??e.repository,e.report,e.finding].filter(Boolean).join(" \xB7 ");return l`<div class="row"><span class="${`kind ${e.kind??""}`}">${e.kind??"activity"}</span><span class="actor">${e.actor??e.user??"Unknown user"}</span><span class="copy"><span class="action">${e.action??"updated workspace data"}</span>${t?l`<span class="detail">${t}</span>`:u}</span><time>${e.when??""}</time></div>`}};customElements.define("managed-admin-history",sr);function tn(r){return Object.entries(r??{}).flatMap(([e,t])=>t==null?[]:typeof t=="object"?[e,JSON.stringify(t)]:[e,String(t)]).join(" ").toLocaleLowerCase()}async function rn(){let r=await y("/api/admin/users",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)throw new Error(`HTTP ${r.status}`);let e=await r.json();return Array.isArray(e?.users)?e.users:[]}function ji(r){if(r==null||r==="")return l`<span>Unknown</span>`;let e=typeof r=="number"?r:Number(r);if(!Number.isFinite(e))return l`<span>Unknown</span>`;let t=new Date(e);return Number.isNaN(t.getTime())?l`<span>Unknown</span>`:l`<time datetime="${t.toISOString()}">${t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}</time><span>${t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}</span>`}function Fi(r){if(r==null||r==="")return"Unknown";let e=typeof r=="number"?r:Number(r);return Number.isFinite(e)&&!Number.isNaN(new Date(e).getTime())?`Last seen ${new Date(e).toLocaleString()}`:"Unknown"}function Vi(r){return r?.lastActivityAt??r?.lastActivity??r?.lastWriteAt??r?.lastActiveAt}async function sn(r,e,t){let i={"content-type":"application/json"};t&&(i["x-csrf-token"]=t);let s=await y("/api/admin/set-role",{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify({userId:r,role:e})});if(!s.ok)throw new Error(`HTTP ${s.status}`)}var or=class extends w{static properties={_users:{state:!0},_teams:{state:!0},_error:{state:!0}};static styles=[te,ur,x`.wrap{max-width:68rem;margin:0 auto}.intro{margin-bottom:1rem;font-size:.78rem}.directory{border:1px solid var(--border);border-radius:9px;overflow:hidden;background:var(--surface)}.list-head,.users li{display:grid;grid-template-columns:minmax(12rem,1fr) minmax(15rem,1.15fr) 6.4rem 6.8rem 7rem;gap:.75rem;padding:.45rem .7rem;align-items:center}.list-head{color:var(--muted);font-size:.62rem;font-weight:500;border-bottom:1px solid var(--border)}.users{list-style:none;margin:0;padding:0}.users li+li{border-top:1px solid var(--border)}.person{display:flex;align-items:center;gap:.5rem;min-width:0}.avatar{width:1.65rem;height:1.65rem;font-size:.65rem}.who{display:grid;gap:.05rem;min-width:0}.name{display:flex;align-items:center;gap:.35rem;font-size:.78rem;font-weight:500}.login,.name-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.login{color:var(--muted);font-size:.65rem}.last-activity,.last-seen{display:grid;gap:.08rem;color:var(--muted);font-size:.61rem;font-variant-numeric:tabular-nums}.last-activity time,.last-seen time{color:var(--text)}.activity-link{display:block;min-width:0;padding:.15rem .2rem;border:0;border-radius:4px;color:inherit;background:0 0;text-align:left}.activity-link:hover{color:var(--accent);background:rgb(from var(--accent) r g b / .08)}.you{padding:.05rem .35rem;border-radius:4px;color:var(--accent);background:rgb(from var(--accent) r g b / .1);font-size:.65rem;font-weight:500}.memberships{display:grid;gap:.18rem;min-width:0}.team-access{display:flex;align-items:center;justify-content:flex-start;gap:.5rem;min-width:0;color:var(--muted);font-size:.64rem;line-height:1.35}.team-access strong{color:var(--text);font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.team-perms{display:inline-flex;gap:.3rem;white-space:nowrap}.permission-granted{color:var(--accent)}.permission-denied{color:var(--critical,#e5534b)}.no-team{color:var(--muted);font-size:.67rem}.access{display:flex;align-items:center;min-width:0}.role{width:100%;height:1.7rem;font-size:.72rem}.self-note{margin:.7rem 0;color:var(--muted);font-size:.73rem}@container (max-width: 46rem){gap:.45rem;padding-left:.55rem;padding-right:.55rem}.last-activity,.last-seen{font-size:.57rem}.users li{grid-template-columns:minmax(0,1fr) 6.2rem;gap:.3rem .6rem}.memberships{grid-column:1/-1;grid-row:3;padding-left:2.15rem}.last-seen{grid-column:1;grid-row:2;padding-left:2.15rem;display:flex;flex-wrap:wrap;gap:.3rem}.last-activity{grid-column:1;grid-row:4;padding-left:2.15rem;display:flex;flex-wrap:wrap;gap:.3rem}.activity-link{grid-column:1;grid-row:4;padding-left:2rem}.access{grid-column:2;grid-row:1/3}`];constructor(){super(),this._users=null,this._teams=null,this._error=null,this._me=null,this._csrf=null}connectedCallback(){super.connectedCallback(),this._load()}async _load(){this._error=null,this._users=null;try{let[e,t,i]=await Promise.all([ee(),rn(),Zi()]);this._me=e?.id??null,this._csrf=e?.csrfToken??null,this._users=t,this._teams=Array.isArray(i?.teams)?i.teams:[]}catch(e){this._error=String(e?.message??e)}}render(){return l`<div class="wrap"><div class="head">${re()}<h1>Users</h1>${this._users?l`<span class="count">${this._users.length}</span>`:u}</div><p class="intro">Manage workspace access and roles.</p>${this._error==null?this._users==null?l`<p class="msg">Loading…</p>`:this._list():l`<p class="msg error">Couldn't load users: ${this._error}</p>`}</div>`}_list(){return this._users.length===0?l`<p class="msg">No users yet.</p>`:l`<div class="directory"><div class="list-head" aria-hidden="true"><span>Account</span><span>Team access</span><span>Last seen</span><span>Last activity</span><span>Role</span></div><ul class="users">${this._users.map(e=>this._row(e))}</ul></div>${this._users.some(e=>e.id===this._me)?l`<p class="self-note">Your own role can only be changed by another admin.</p>`:u}`}_row(e){let t=e.id===this._me,i=(this._teams??[]).flatMap(s=>{let o=s.members?.find(n=>n.userId===e.id);return o==null?[]:[{team:s,member:o}]});return l`<li><span class="person">${qi(e.id,e.login)} <span class="who"><span class="name"><span class="name-text">${e.name||e.login}</span>${t?l`<span class="you">You</span>`:u}</span> <span class="login">@${e.login}</span> </span></span><span class="memberships">${i.length===0?l`<span class="no-team">No team access</span>`:i.map(({team:s,member:o})=>l`<span class="team-access"><strong>${s.name}</strong><span class="team-perms">${["dependencies","security"].map(n=>l`<span class="${o[n]===!0?"permission-granted":"permission-denied"}">${o[n]===!0?"+":"\u2212"} ${n==="dependencies"?"Deps":"Security"}</span>`)}</span></span>`)} </span><span class="last-seen" aria-label="${Fi(e.lastSeenAt)}">${ji(e.lastSeenAt)}</span> <button type="button" class="activity-link" aria-label="${`Show activity by ${e.login}`}" @click="${()=>this._showActivity(e.login)}"><span class="last-activity" aria-label="${`Last activity ${Fi(Vi(e)).replace(/^Last seen /u,"")}`}">${ji(Vi(e))}</span></button> <span class="access"><select class="role" ?disabled="${t}" aria-label="${`Change ${e.login}\u2019s role`}" aria-description="${Xo[e.role]??""}" @change="${s=>this._changeRole(e,s.target.value,s.target)}">${U.map(s=>l`<option value="${s}" ?selected="${s===e.role}">${Jo[s]}</option>`)}</select></span></li>`}async _changeRole(e,t,i){let s=e.role;if(t!==s){try{await sn(e.id,t,this._csrf),e.role=t}catch(o){console.warn("admin: set role failed:",o),i.value=s}this.requestUpdate()}}_showActivity(e){document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:"manage-history",actor:e},bubbles:!0,composed:!0}))}};customElements.define("managed-admin-users",or);async function on(r,e,t,i){let s=new URLSearchParams({scope:r,q:e,page:String(t),limit:"20"}),o=await y(`/api/admin/repositories?${s}`,{credentials:"same-origin",headers:{accept:"application/json"},signal:i});if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}async function nn(r,e,t){let i={"content-type":"application/json"};t&&(i["x-csrf-token"]=t);let s=await y("/api/admin/repositories/select",{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify({repoId:r,selected:e})});if(!s.ok)throw new Error(`HTTP ${s.status}`)}async function an(r,e){let t=await y(`/api/admin/repositories/impact?repoId=${encodeURIComponent(r)}`,{credentials:"same-origin",headers:{accept:"application/json"},signal:e});if(!t.ok)throw new Error(`HTTP ${t.status}`);let i=await t.json();if(i?.repoId!==r||!Array.isArray(i.reports)||!Array.isArray(i.bundles)||!Number.isSafeInteger(i.triageCount)||i.triageCount<0)throw new Error("Invalid repository data");return i}async function ln(r,e,t,i){let s={"content-type":"application/json"};i&&(s["x-csrf-token"]=i);let o=await y("/api/admin/repositories/remove",{method:"POST",credentials:"same-origin",headers:s,body:JSON.stringify({repoId:r,fullName:e,acknowledge:!0,deleteTriage:t})});if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.json()}var Gi=l`<svg class="repo-icon" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M2 2.75A2.75 2.75 0 0 1 4.75 0h7.5a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75H4.5a1 1 0 0 0 0 2h8a.75.75 0 0 1 0 1.5h-8A2.5 2.5 0 0 1 2 13V2.75Zm2.75-.25a1.25 1.25 0 0 0-1.25 1.25v7.32c.317-.114.66-.07 1 .18V2.5h-.5a.25.25 0 0 0 .75 0Zm6.75 0H5.5v8.5h6V2.5Z"/></svg>`,nr=class extends w{static properties={_data:{state:!0},_error:{state:!0},_actionError:{state:!0},_scope:{state:!0},_query:{state:!0},_page:{state:!0},_loading:{state:!0},_busy:{state:!0},_detail:{state:!0},_impact:{state:!0},_impactLoading:{state:!0},_removeOpen:{state:!0},_acknowledge:{state:!0},_deleteTriage:{state:!0},_confirmName:{state:!0}};static styles=[te,ur,x`.wrap{max-width:68rem;margin:0 auto}.head{flex-wrap:wrap}.head h1{overflow-wrap:anywhere}.toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;margin:1.25rem 0 .85rem}.search{flex:1 1 14rem;max-width:25rem;margin-right:auto}.search input{width:100%}.owners{display:grid;gap:1rem}.owner-head{display:flex;align-items:center;gap:.5rem;margin:0 0 .35rem;padding-left:.7rem;color:var(--muted);font-size:.72rem;font-weight:500}.owner-icon{display:grid;place-items:center;width:1.3rem;height:1.3rem;border-radius:4px;background:var(--surface-active);text-transform:uppercase;font-size:.65rem}.repos{margin:0;padding:0;list-style:none;border:1px solid var(--border);border-radius:8px;overflow:hidden;background:var(--surface)}.repos li+li{border-top:1px solid var(--border)}.repo-row{display:flex;align-items:center;gap:.65rem;width:100%;min-height:2.65rem;padding:.38rem .7rem;text-align:left}button.repo-row{border:0;background:0 0;color:var(--text);cursor:default}button.repo-row:hover{background:var(--surface-active)}button.repo-row:focus-visible{outline-offset:-2px}.repo-icon{width:1rem;height:1rem;flex:0 0 auto;color:var(--muted)}.repo-copy{display:flex;align-items:baseline;gap:.55rem;flex:1;min-width:0}.repo-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.8rem;font-weight:500}.repo-meta{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:.68rem}.repo-meta::before{content:'·';margin-right:.55rem;color:var(--border-strong,var(--muted))}.arrow{width:1rem;height:1rem;flex:0 0 auto;color:var(--muted)}.connected{display:inline-flex;align-items:center;gap:.25rem;flex:0 0 auto;color:var(--muted);font-size:.68rem;white-space:nowrap}.connected svg{width:.85rem;height:.85rem}.access-note{display:flex;align-items:center;gap:.85rem;padding:.85rem 1rem;background:var(--surface);border:1px solid var(--border);border-radius:8px}.access-note p{flex:1;margin:0;color:var(--muted);font-size:.78rem;line-height:1.5}a.btn{color:var(--text);text-decoration:none;cursor:default}.empty{padding:2.5rem 1rem;border:1px solid var(--border);border-radius:8px;text-align:center}.empty strong{display:block;margin-bottom:.4rem;font-size:.9rem;font-weight:500}.empty p{margin:0;color:var(--muted);font-size:.8rem}.loading{min-height:8rem;display:grid;place-items:center;color:var(--muted);font-size:.8rem}.pagination{display:flex;align-items:center;gap:.5rem;margin-top:.85rem}.pagination span{margin-right:auto;color:var(--muted);font-size:.72rem;font-variant-numeric:tabular-nums}.section{margin-top:1.5rem;border:1px solid var(--border);border-radius:8px;overflow:hidden;background:var(--surface)}.section h2{margin:0;padding:.8rem 1rem;border-bottom:1px solid var(--border);font-size:.85rem;font-weight:500}.settings-row{display:flex;align-items:center;gap:1rem;padding:1rem}.settings-copy{flex:1;min-width:0}.settings-copy strong{font-size:.83rem;font-weight:500}.settings-copy p{margin:.25rem 0 0;color:var(--muted);font-size:.76rem;line-height:1.5}.settings-row+.settings-row{border-top:1px solid var(--border)}.btn.danger{color:var(--critical,#e5534b)}.error{color:var(--critical,#e5534b)}.status-line{display:inline-flex;align-items:center;gap:.35rem;color:var(--muted);font-size:.72rem}.status-line.inactive{color:var(--warning,#d19a24)}.data-section{margin-top:1.5rem}.data-section h2{margin:0 0 .5rem;font-size:.85rem;font-weight:500}.data-list{margin:0;padding:0;list-style:none;border:1px solid var(--border);border-radius:8px;overflow:hidden}.data-list li{display:flex;align-items:baseline;gap:.5rem;padding:.5rem .75rem;font-size:.75rem}.data-list li+li{border-top:1px solid var(--border)}.data-list strong{min-width:0;overflow-wrap:anywhere;font-weight:500}.data-list span{margin-left:auto;color:var(--muted);font-size:.68rem;white-space:nowrap}.data-empty{margin:0;color:var(--muted);font-size:.75rem}.dialog-backdrop{position:fixed;inset:0;z-index:20;display:grid;place-items:center;padding:1rem;background:rgb(0 0 0 / .65)}.dialog{width:min(40rem,100%);max-height:min(42rem,calc(100vh - 2rem));overflow:auto;padding:1.25rem;border:1px solid var(--border);border-radius:10px;background:var(--surface);box-shadow:0 1rem 3rem rgb(0 0 0 / .35)}.dialog.small{width:min(28rem,100%)}.dialog h2{margin:0;font-size:1.05rem;font-weight:600}.dialog-copy{margin:.55rem 0 1rem;color:var(--muted);font-size:.78rem;line-height:1.5}.dialog-data{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem;margin:0 0 1rem}.dialog-data section{min-width:0;padding:.65rem;border:1px solid var(--border);border-radius:7px}.dialog-data h3{margin:0 0 .4rem;font-size:.72rem;font-weight:600}.dialog-data ul{max-height:9rem;overflow:auto;margin:0;padding-left:1rem;color:var(--muted);font-size:.7rem}.dialog-data li{margin:.2rem 0;overflow-wrap:anywhere}.confirm-line{display:flex;align-items:flex-start;gap:.5rem;margin:.7rem 0;color:var(--text);font-size:.76rem;line-height:1.4}.confirm-line input{flex:0 0 auto;margin-top:.15rem;accent-color:var(--accent)}.confirm-name{width:100%;margin-top:.15rem;padding:.45rem .55rem;border:1px solid var(--border);border-radius:5px;background:var(--bg);color:var(--text);font:inherit;font-size:.78rem}.dialog-actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:1rem}.dialog-actions .danger{color:var(--critical,#e5534b);border-color:rgb(from var(--critical,#e5534b) r g b / .4)}.search{flex-basis:100%;max-width:none}.access-note,.settings-row{flex-wrap:wrap}.access-note p,.settings-copy{flex-basis:100%}.head h1{font-size:1.35rem}.repo-copy{gap:.35rem}.repo-meta{max-width:45%}.dialog-data{grid-template-columns:1fr}`];constructor(){super(),this._data=null,this._error=null,this._actionError=null,this._csrf=null,this._scope="connected",this._query="",this._page=1,this._loading=!0,this._busy=null,this._detail=null,this._impact=null,this._impactLoading=!1,this._removeOpen=!1,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName="",this._request=null,this._impactRequest=null,this._searchTimer=null}connectedCallback(){super.connectedCallback(),this._load()}disconnectedCallback(){super.disconnectedCallback(),this._request?.abort(),this._impactRequest?.abort(),clearTimeout(this._searchTimer)}async _load(){this._request?.abort();let e=new AbortController;this._request=e,this._loading=!0,this._error=null;try{let[t,i]=await Promise.all([this._csrf?null:ee(),on(this._scope,this._query,this._page,e.signal)]);if(e.signal.aborted)return;t&&(this._csrf=t.csrfToken),this._data=i;let s=Math.max(1,Math.ceil(i.total/20));this._page>s&&(this._page=s,this._load())}catch(t){e.signal.aborted||(this._error=String(t?.message??t))}finally{this._request===e&&(this._loading=!1)}}_open(e){clearTimeout(this._searchTimer),this._scope=e,this._query="",this._page=1,this._detail=null,this._impact=null,this._removeOpen=!1,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName="",this._data=null,this._actionError=null,this._load()}_search(e){this._query=e,this._page=1,this._request?.abort(),clearTimeout(this._searchTimer),this._loading=!0,this._searchTimer=setTimeout(()=>{this._load()},200)}_back(){return l`<span class="breadcrumb"><button type="button" class="breadcrumb-manage" @click="${()=>{document.dispatchEvent(new CustomEvent("managed-admin-navigate",{detail:{view:"manage"},bubbles:!0,composed:!0}))}}">Manage</button> <span class="breadcrumb-separator" aria-hidden="true">›</span> <button type="button" class="breadcrumb-manage" aria-label="Back to repositories" @click="${()=>{this._detail?(this._detail=null,this._actionError=null):this._open("connected")}}">Repositories</button> <span class="breadcrumb-separator" aria-hidden="true">›</span></span>`}_openDetail(e){this._detail=e,this._actionError=null,this._impact=null,this._removeOpen=!1,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName="",this._impactLoading=!0,this._impactRequest?.abort();let t=new AbortController;this._impactRequest=t,an(e.id,t.signal).then(i=>(!t.signal.aborted&&this._impactRequest===t&&(this._impact=i),i)).catch(i=>{t.signal.aborted||(this._actionError=`Couldn't load repository data: ${i?.message??i}`)}).finally(()=>{this._impactRequest===t&&(this._impactLoading=!1)})}render(){if(this._detail)return this._detailPage(this._detail);let e=this._scope==="connected",t=e?"Repositories":`Add ${this._scope} repository`;return l`<div class="wrap"><div class="head">${e?re():this._back()}<h1>${t}</h1>${e&&this._data?l`<span class="count">${this._data.connectedCount} connected</span>`:u}</div><p class="intro">${e?"Manage connected repositories and their settings.":this._scope==="installed"?"Choose a repository the GitHub App can read. Installed repositories can be public or private.":"Choose a public repository your GitHub account is involved with. Random public repositories are not listed."}</p>${!e&&this._scope==="installed"?l`<div class="access-note"><p>Installed repositories are readable through the GitHub App. Install it on a repository or organization to make it available here.</p>${this._data?.installUrl?l`<a class="btn" href="${this._data.installUrl}" target="_blank" rel="noopener noreferrer">Configure GitHub access</a>`:u}</div>`:u}<div class="toolbar"><label class="search"><input type="search" aria-label="${e?"Search connected repositories":`Search ${this._scope} repositories`}" placeholder="Search by repository or owner…" .value="${this._query}" @input="${i=>this._search(i.target.value)}"></label> ${e?l`<button type="button" class="btn" @click="${()=>this._open("installed")}">${this._accessIcon("private")} Add installed repository</button> <button type="button" class="btn" @click="${()=>this._open("public")}">${this._accessIcon("public")} Add your public repository</button>`:l`<button type="button" class="btn" ?disabled="${this._loading}" @click="${()=>{this._load()}}">Refresh</button>`}</div>${this._actionError?l`<p class="msg error" role="alert">${this._actionError}</p>`:u}<div aria-busy="${this._loading}">${this._body()}</div></div>`}_body(){if(this._error)return l`<p class="msg error" role="alert">Couldn't load repositories: ${this._error}</p><button type="button" class="btn" @click="${()=>{this._load()}}">Try again</button>`;if(this._loading||!this._data)return l`<div class="loading" role="status">Loading repositories…</div>`;let e=this._data.repositories??[];return l`${this._data.tokenMissing&&this._scope==="public"?l`<p class="msg">Log out and back in to refresh your GitHub membership access.</p>`:u} ${e.length>0?l`<div class="owners">${this._groupRepos(e).map(([t,i])=>l`<section aria-label="${t}"><h2 class="owner-head"><span class="owner-icon" aria-hidden="true">${t[0]??"?"}</span>${t}</h2><ul class="repos">${i.map(s=>this._row(s))}</ul></section>`)}</div>`:l`<div class="empty"><strong>${this._query?"No matching repositories":this._scope==="connected"?"No connected repositories yet":`No ${this._scope} repositories available`}</strong><p>${this._query?"Try a different repository or owner name.":this._scope==="connected"?"Add an installed or public repository to get started.":this._scope==="installed"?"Install the GitHub App, then refresh this list.":"Public repositories associated with your GitHub account will appear here."}</p></div>`} ${this._data.total>20?l`<nav class="pagination" aria-label="Repository pages"><span>${(this._page-1)*20+1}–${Math.min(this._page*20,this._data.total)} of ${this._data.total}</span> <button type="button" class="btn" ?disabled="${this._page===1}" @click="${()=>{this._page--,this._load()}}">Previous</button> <button type="button" class="btn" ?disabled="${this._page*20>=this._data.total}" @click="${()=>{this._page++,this._load()}}">Next</button></nav>`:u}`}_groupRepos(e){let t=new Map;for(let i of e){let s=i.fullName.split("/")[0];t.has(s)||t.set(s,[]),t.get(s).push(i)}return[...t]}_row(e){let t=e.fullName.slice(e.fullName.indexOf("/")+1),i=`${this._accessLabel(e)}${this._scope==="connected"&&e.active===!1?" \xB7 Deactivated":""}`,s=l`${Gi}<span class="repo-copy"><span class="repo-name">${t}</span><span class="repo-meta">${i}</span></span>`;return this._scope==="connected"?l`<li><button type="button" class="repo-row" aria-label="${`Manage ${e.fullName}`}" @click="${()=>this._openDetail(e)}">${s}<svg class="arrow" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><path d="m6 4 4 4-4 4"/></svg></button></li>`:l`<li class="repo-row">${s} ${e.selected?l`<span class="connected"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m3 8 3 3 7-7"/></svg>Connected</span>`:e.private&&!e.installed?l`<span class="repo-meta">Needs App access</span>`:l`<button type="button" class="btn" aria-label="${`Add ${e.fullName}`}" ?disabled="${this._busy!=null}" @click="${()=>{this._setActive(e,!0)}}">${this._busy===e.id?"Adding\u2026":"Add"}</button>`}</li>`}_accessLabel(e){return e.installed?e.private?"Private \xB7 GitHub App":"Public \xB7 GitHub App":"Public \xB7 GitHub membership"}_detailPage(e){let t=e.active!==!1,i=this._impact?.reports??[],s=this._impact?.bundles??[];return l`<div class="wrap"><div class="head">${this._back()}<h1>${e.fullName}</h1></div><p class="intro">Repository settings and stored data.</p>${this._actionError?l`<p class="msg error" role="alert">${this._actionError}</p>`:u}<section class="section" aria-label="Repository connection"><h2>Connection</h2><div class="settings-row"><div class="settings-copy"><strong>${this._accessLabel(e)}</strong><p>${t?"Active for new scans and uploads.":"Deactivated. Stored reports and bundles are retained."}</p></div><span class="${`status-line ${t?"":"inactive"}`}">${t?"Active":"Deactivated"}</span> ${e.htmlUrl?l`<a class="btn" href="${e.htmlUrl}" target="_blank" rel="noopener noreferrer">View on GitHub</a>`:u}</div><div class="settings-row"><div class="settings-copy"><strong>${t?"Deactivate repository":"Reactivate repository"}</strong><p>${t?"Pause new scans while preserving all stored data and attachments.":"Make this repository available for new scans and bundle attachments again."}</p></div><button type="button" class="btn" ?disabled="${this._busy!=null}" @click="${()=>{this._setActive(e,!t)}}">${this._busy===e.id?t?"Deactivating\u2026":"Reactivating\u2026":t?"Deactivate":"Reactivate"}</button></div></section><section class="data-section" aria-label="Stored repository data"><h2>Stored data</h2>${this._impactLoading?l`<p class="data-empty">Loading attached reports and bundles…</p>`:this._impact==null?l`<p class="data-empty">Attached data could not be loaded.</p><button type="button" class="btn" @click="${()=>this._openDetail(e)}">Try again</button>`:l`<div class="dialog-data"><section><h3>Reports (${i.length})</h3>${i.length>0?l`<ul>${i.map(o=>l`<li>${o.filename}${o.repoDirectory?` \xB7 ${o.repoDirectory}`:u}</li>`)}</ul>`:l`<p class="data-empty">No reports attached.</p>`}</section><section><h3>Bundles (${s.length})</h3>${s.length>0?l`<ul>${s.map(o=>l`<li>${o.filename}</li>`)}</ul>`:l`<p class="data-empty">No bundles attached.</p>`}</section></div>`}</section><section class="section" aria-label="Permanent repository removal"><h2>Permanent removal</h2><div class="settings-row"><div class="settings-copy"><strong>Delete repository and stored data</strong><p>Deactivation is reversible. Permanent removal deletes this repository’s attached reports and bundles; it cannot be undone.</p></div><button type="button" class="btn danger" ?disabled="${this._busy!=null||this._impactLoading||this._impact==null}" @click="${()=>{this._removeOpen=!0,this._acknowledge=!1,this._deleteTriage=!1,this._confirmName=""}}">Remove permanently</button></div></section>${this._removeOpen&&this._impact!=null&&!this._impactLoading?this._removeDialog(e,i,s):u}</div>`}_removeDialog(e,t,i){let s=t.length>0||i.length>0,o=this._canRemove(e);return l`<div class="dialog-backdrop" role="presentation" @click="${n=>{n.target===n.currentTarget&&(this._removeOpen=!1)}}"><section class="${`dialog ${s?"":"small"}`}" role="dialog" aria-modal="true" aria-labelledby="remove-repo-title"><h2 id="remove-repo-title">Remove ${e.fullName} permanently?</h2><p class="dialog-copy">${s?"This destructive action will remove the repository and the stored data listed below. Deactivation keeps all of it.":"This repository has no attached reports or bundles. Permanent removal deletes its connection record."}</p>${s?l`<div class="dialog-data"><section><h3>Reports to delete (${t.length})</h3><ul>${t.map(n=>l`<li>${n.filename}${n.repoDirectory?` \xB7 ${n.repoDirectory}`:u}</li>`)}</ul></section><section><h3>Bundles to delete (${i.length})</h3><ul>${i.map(n=>l`<li>${n.filename}</li>`)}</ul></section></div>`:u} <label class="confirm-line"><input type="checkbox" .checked="${this._acknowledge}" @change="${n=>{this._acknowledge=n.target.checked}}">I understand this permanently deletes the repository connection${s?", reports, and bundles":""}.</label> ${(this._impact?.triageCount??0)>0?l`<label class="confirm-line"><input type="checkbox" .checked="${this._deleteTriage}" @change="${n=>{this._deleteTriage=n.target.checked}}">Also delete ${this._impact.triageCount} triage entr${this._impact.triageCount===1?"y":"ies"} belonging only to this repository.</label>`:u} ${s?l`<label class="confirm-line">Type <strong>${e.fullName}</strong> to confirm.<input class="confirm-name" type="text" autocomplete="off" .value="${this._confirmName}" @input="${n=>{this._confirmName=n.target.value}}"></label>`:u}<div class="dialog-actions"><button type="button" class="btn" @click="${()=>{this._removeOpen=!1}}">Cancel</button><button type="button" class="btn danger" ?disabled="${!o}" @click="${()=>{this._remove(e)}}">${this._busy===e.id?"Removing\u2026":"Remove permanently"}</button></div></section></div>`}_accessIcon(e){return e==="private"?l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="7" width="10" height="7" rx="1"/><path d="M5 7V5a3 3 0 0 1 6 0v2"/></svg>`:l`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="8" cy="8" r="6"/><path d="M2.5 8h11M8 2c1.5 1.7 2.2 3.7 2.2 6S9.5 12.3 8 14c-1.5-1.7-2.2-3.7-2.2-6S6.5 3.7 8 2Z"/></svg>`}async _setActive(e,t){if(this._busy==null){this._busy=e.id,this._actionError=null;try{if(await nn(e.id,t,this._csrf),!this.isConnected)return;this._detail?.id===e.id&&(this._detail={...this._detail,active:t}),this._data&&(this._data={...this._data,repositories:this._data.repositories.map(i=>i.id===e.id?{...i,active:t}:i)}),this._scope!=="connected"&&await this._load()}catch(i){let s=t?e.active===!1?"reactivate":"add":"deactivate";this._actionError=`Couldn't ${s} ${e.fullName}: ${i?.message??i}`}finally{this._busy=null}}}_canRemove(e){return this._busy!=null||this._impactLoading||this._impact?.repoId!==e.id||!this._acknowledge?!1:!(this._impact.reports.length>0||this._impact.bundles.length>0)||this._confirmName===e.fullName}async _remove(e){if(this._canRemove(e)){this._busy=e.id,this._actionError=null;try{await ln(e.id,e.fullName,this._deleteTriage,this._csrf),this._removeOpen=!1,this._detail=null,this._impact=null,await this._load()}catch(t){this._actionError=`Couldn't remove ${e.fullName}: ${t?.message??t}`}finally{this._busy=null}}}};customElements.define("managed-admin-repos",nr);async function cn(){let r=await y("/api/admin/reports",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async function dn(r,e,t=null,i=""){let s={"content-type":r.type||"application/json","x-report-filename":encodeURIComponent(r.name)};e&&(s["x-csrf-token"]=e),t!=null&&(s["x-repo-id"]=String(t)),i!==""&&(s["x-repo-directory"]=encodeURIComponent(i));let o=await y("/api/admin/reports",{method:"POST",credentials:"same-origin",headers:s,body:r});if(!o.ok){if(o.status===413)throw new Error("too large");let n="";try{let a=await o.json();a?.error==="repo-not-connected"&&typeof a.repo=="string"&&(n=`: ${a.repo} is not connected`)}catch{}throw new Error(`HTTP ${o.status}${n}`)}return o.json()}async function pn(r,e,t){let i={"content-type":"application/json"};t&&(i["x-csrf-token"]=t);let s=await y("/api/admin/reports/set-visible",{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify({reportId:r,visible:e})});if(!s.ok)throw new Error(`HTTP ${s.status}`)}async function un(r,e,t,i){let s={"content-type":"application/json"};i&&(s["x-csrf-token"]=i);let o=await y("/api/admin/reports/set-repo",{method:"POST",credentials:"same-origin",headers:s,body:JSON.stringify({reportId:r,repoId:e,directory:t})});if(!o.ok)throw o.status===409?new Error("this report already defines its repository"):new Error(o.status===400?"invalid repository or directory":`HTTP ${o.status}`);return o.json()}async function hn(r,e){let t=e?{"x-csrf-token":e}:{},i=await y(`/api/admin/reports/${encodeURIComponent(r)}`,{method:"DELETE",credentials:"same-origin",headers:t});if(!i.ok)throw new Error(`HTTP ${i.status}`)}function ar(r){return typeof r!="number"||!Number.isFinite(r)?"":r<1024?`${r} B`:r<1048576?`${(r/1024).toFixed(1)} KB`:`${(r/1048576).toFixed(1)} MB`}function hr(r){return[{value:null,label:"No repository",special:!0},...r.map(e=>({value:e.repoId,label:e.fullName}))]}function mn(r,e,t,i="Repository for new bundles"){return!Array.isArray(r)||r.length===0?u:l`<div class="repo-picker"><span class="repo-picker-label">${i}</span><repository-selector class="repo-select" .options="${hr(r)}" .value="${e}" label="${i}" @repository-change="${s=>t(s.detail.value)}"></repository-selector></div>`}function fn(r,e,t){return!Array.isArray(r)||r.length===0?u:l`<repository-selector class="repo-attach" label="Attach to a repository" .options="${hr(r)}" .value="${e??null}" @repository-change="${i=>t(i.detail.value)}"></repository-selector>`}function Wi(r,e=!0){let t=document.createElement("input");t.type="file",t.multiple=e,t.addEventListener("change",()=>{r([...t.files])},{once:!0}),t.click()}function Ki(r,e,t){let i=0,s=d=>Array.from(d.dataTransfer?.types??[]).includes("Files"),o=d=>{s(d)&&(d.preventDefault(),i+=1,t(!0))},n=d=>{s(d)&&d.preventDefault()},a=d=>{s(d)&&(i=Math.max(0,i-1),i===0&&t(!1))},c=d=>{s(d)&&(d.preventDefault(),d.stopPropagation(),i=0,t(!1),e([...d.dataTransfer.files]))};return r.addEventListener("dragenter",o),r.addEventListener("dragover",n),r.addEventListener("dragleave",a),r.addEventListener("drop",c),()=>{r.removeEventListener("dragenter",o),r.removeEventListener("dragover",n),r.removeEventListener("dragleave",a),r.removeEventListener("drop",c)}}var lr=class extends w{static properties={_data:{state:!0},_error:{state:!0},_busy:{state:!0},_dragOver:{state:!0},_preview:{state:!0},_previewLoading:{state:!0},_locationReport:{state:!0},_locationRepo:{state:!0},_locationDirectory:{state:!0},_locationBusy:{state:!0},_repoId:{state:!0},_repoDirectory:{state:!0}};static styles=[te,x`:host{display:block;position:relative;flex:1 1 auto;padding:clamp(1.5rem,4vw,2.5rem) clamp(1rem,4vw,2.5rem);color:var(--text);container-type:inline-size}*{box-sizing:border-box}.wrap{max-width:68rem;margin:0 auto}.dropzone{position:absolute;inset:.6rem;z-index:5;display:grid;place-items:center;border:2px dashed var(--accent);border-radius:10px;background:rgb(from var(--bg) r g b / .9);color:var(--accent);font-size:1rem;font-weight:600;pointer-events:none}.drop-card{display:flex;align-items:center;flex-wrap:wrap;gap:.7rem;margin:0 0 1.2rem;padding:.7rem .8rem;border:1px dashed var(--border);border-radius:8px;background:rgb(from var(--surface) r g b / .55)}.drop-card strong{display:block;font-size:.78rem;font-weight:600}.drop-card .drop-copy>span{display:block;margin-top:.12rem;color:var(--muted);font-size:.7rem}.drop-icon{display:grid;place-items:center;width:1.8rem;height:1.8rem;flex:0 0 auto;border-radius:5px;color:var(--accent);background:rgb(from var(--accent) r g b / .1)}.drop-icon svg{width:1rem;height:1rem}.drop-copy{min-width:0}.drop-browse{margin-left:auto;flex:0 0 auto;padding:.3rem .55rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.72rem}.head{display:flex;align-items:center;gap:.65rem;margin:0 0 .45rem}h1{margin:0;font-size:1.65rem;font-weight:600;letter-spacing:-.035em}.head-actions{display:flex;align-items:center;gap:.5rem;margin-left:auto}.action,.upload{display:inline-flex;align-items:center;justify-content:center;min-height:2rem;padding:.3rem .65rem;border:1px solid var(--border);border-radius:6px;background:var(--surface);color:var(--text);font:inherit;font-size:.78rem;font-weight:500;white-space:nowrap;cursor:default}.upload{border-color:var(--accent);background:var(--accent);color:var(--bg);font-weight:600}.action:disabled,.upload:disabled{opacity:.5}.action:hover:not(:disabled),.upload:hover:not(:disabled){background:var(--surface-active)}.upload:hover:not(:disabled){filter:brightness(1.08)}.intro{max-width:44rem;margin:0 0 1.4rem;color:var(--muted);font-size:.85rem;line-height:1.5}.hint{margin:0 0 .7rem;color:var(--muted);font-size:.75rem}.reports{display:grid;gap:.5rem;margin:0;padding:0;list-style:none}.report{overflow:hidden;border:1px solid var(--border);border-radius:9px;background:var(--surface)}.report-main{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:.55rem;padding:.42rem .6rem}.report-logo{display:grid;place-items:center;flex:0 0 auto;width:1.5rem;height:1.5rem;border-radius:5px;overflow:hidden}.report-logo svg{width:1.2rem;height:1.2rem}.report-logo.brand-deepview{--brand-bg:#2563eb;--brand-fg:#fff;background:var(--brand-bg)}.report-logo.brand-claude{--brand-bg:#d97757;--brand-fg:#fff;background:var(--brand-bg)}.report-logo.brand-codex{--brand-bg:#fff;--brand-fg:#000;background:var(--brand-bg)}.report-logo.brand-vercel{--brand-bg:#000;--brand-fg:#fff;background:var(--brand-bg)}.report-logo.brand-piolium{--brand-bg:#fbb829;--brand-fg:#1c1b19;background:var(--brand-bg)}.report-logo.generic{color:var(--muted);background:var(--surface-active);border:1px solid var(--border)}.report-logo .fg{fill:var(--brand-fg)}.report-logo .bg{fill:var(--brand-bg)}.report-logo.brand-codex .bg,.report-logo.brand-vercel .bg{stroke:var(--brand-fg);stroke-width:.5}.report-copy{display:grid;flex:1;min-width:0;gap:.08rem}.report-name{font-size:.78rem;font-weight:600;overflow-wrap:anywhere}.report-location{color:var(--muted);font-size:.66rem;overflow-wrap:anywhere}.report-meta{display:flex;flex-wrap:nowrap;align-items:center;gap:.22rem .4rem;min-width:0;overflow:hidden;color:var(--muted);font-size:.62rem;line-height:1.25}.report-meta>span{min-width:0}.report-meta>span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.report-meta .report-location{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.status{display:inline-flex;align-items:center;width:fit-content;padding:.1rem .35rem;border:1px solid var(--border);border-radius:4px;font-size:.65rem;font-weight:500}.status.hidden{color:var(--muted)}.status.visible{color:var(--accent);border-color:rgb(from var(--accent) r g b / .35);background:rgb(from var(--accent) r g b / .08)}.report-actions{display:flex;align-items:center;flex-wrap:wrap;justify-content:flex-end;gap:.25rem;margin-left:auto}.report-actions .action{min-height:1.7rem;padding:.2rem .44rem;font-size:.68rem}.report-actions a{color:var(--accent);text-decoration:none}.report-actions a:hover{text-decoration:underline}.preview{border-top:1px solid var(--border);padding:.7rem .85rem .8rem 3.35rem}.preview pre{max-height:16rem;overflow:auto;margin:0;padding:.65rem;border:1px solid var(--border);border-radius:6px;background:var(--bg);color:var(--muted);font:.7rem/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;white-space:pre-wrap;overflow-wrap:anywhere}.preview-loading{color:var(--muted);font-size:.75rem}.location-editor{display:grid;grid-template-columns:minmax(0,1fr) minmax(10rem,.7fr) auto;align-items:end;gap:.5rem;padding:.7rem .85rem .8rem 3.35rem;border-top:1px solid var(--border);background:rgb(from var(--bg) r g b / .35)}.location-field{display:grid;gap:.25rem;min-width:0}.location-field label{color:var(--muted);font-size:.68rem}.location-field input,.location-field select{width:100%;min-width:0;height:2rem;padding:.3rem .45rem;border:1px solid var(--border);border-radius:5px;color:var(--text);background:var(--bg);font:inherit;font-size:.74rem}.location-actions{display:flex;gap:.35rem}.empty{padding:2.5rem 1rem;border:1px solid var(--border);border-radius:8px;text-align:center}.empty strong{display:block;margin-bottom:.4rem;font-size:.9rem;font-weight:500}.empty p,.msg{margin:0;color:var(--muted);font-size:.8rem;line-height:1.5}.msg.error{color:var(--critical,#c00)}.head-actions{width:100%;margin-left:0}.report-main{grid-template-columns:auto minmax(0,1fr)}.report-actions{grid-column:2;width:auto;margin-left:0;justify-content:flex-start}.report-meta{flex-wrap:wrap}.location-editor,.preview{padding-left:.85rem}.location-editor{grid-template-columns:1fr;align-items:stretch}`];constructor(){super(),this._data=null,this._error=null,this._csrf=null,this._busy=!1,this._dragOver=!1,this._preview=null,this._previewLoading=null,this._previewRequest=null,this._locationReport=null,this._locationRepo=null,this._locationDirectory="",this._locationBusy=!1,this._repoId=null,this._repoDirectory="",this._teardownDrop=null,this._queue=[]}connectedCallback(){super.connectedCallback(),this._load(),this._teardownDrop=Ki(this,e=>{this._upload(e)},e=>{this._dragOver=e})}disconnectedCallback(){super.disconnectedCallback(),this._teardownDrop?.(),this._cancelPreview()}async _load(){this._cancelPreview(),this._error=null,this._data=null;try{let[e,t]=await Promise.all([ee(),cn()]);this._csrf=e?.csrfToken??null,this._data=t}catch(e){this._error=String(e?.message??e)}}render(){return l`${this._dragOver?l`<div class="dropzone">Drop reports to upload</div>`:u}<div class="wrap"><div class="head">${re()}<h1>Reports</h1></div><p class="intro">Upload reports. New reports stay hidden until you make them visible.</p><div class="drop-card"><span class="drop-icon" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M8 10V2m0 0L5 5m3-3 3 3M3 9v3.5A1.5 1.5 0 0 0 4.5 14h7a1.5 1.5 0 0 0 1.5-1.5V9"/></svg></span><span class="drop-copy"><strong>Drop reports here</strong><span>Reports can be dropped anywhere on this page, or selected from your computer.</span></span><button type="button" class="drop-browse" ?disabled="${this._busy}" @click="${()=>Wi(e=>{this._upload(e)})}">${this._busy?"Uploading\u2026":"Browse files"}</button></div>${this._body()}</div>`}_body(){if(this._error!=null)return l`<p class="msg error">Couldn't load reports: ${this._error}</p>`;if(this._data==null)return l`<p class="msg">Loading…</p>`;let e=Array.isArray(this._data.reports)?this._data.reports:[];return e.length===0?l`<div class="empty"><strong>No reports uploaded yet</strong><p>Drop a report here or browse files above.</p></div>`:l`<p class="hint">${e.length} stored ${e.length===1?"report":"reports"}</p><ul class="reports">${e.map(t=>this._row(t))}</ul>`}_row(e){let t=e.analyzer??e.source??e.producer??"default",i=bt[t]??bt.default,s=e.repoEmbedded!==!0,o=e.repoEmbedded===!0||e.repoId!=null,n=e.repoFullName?`${e.repoFullName}${e.repoDirectory?`/${e.repoDirectory}`:""}`:"No repository assigned",a=Number.isFinite(e.uploadedAt)?new Date(e.uploadedAt).toLocaleString():"",c=[e.uploadedByLogin?`by ${e.uploadedByLogin}`:"uploader removed",a,ar(e.byteSize)].filter(Boolean).join(" \xB7 ");return l`<li class="report"><div class="report-main">${L(i)} <span class="report-copy"><span class="report-name">${e.filename}</span><span class="report-meta"><span class="${`status ${e.visible?"visible":"hidden"}`}">${e.visible?"Visible":"Hidden"}</span><span class="report-location">${n}</span><span>${c}</span></span></span> <span class="report-actions">${s?l`<button type="button" class="action" @click="${()=>this._openLocation(e)}">${e.repoId==null?"Set location":"Change location"}</button>`:u}<button type="button" class="action" @click="${()=>{this._togglePreview(e)}}">${this._preview===e.id?"Hide preview":"Preview"}</button>${e.visible?l`<button type="button" class="action" @click="${()=>{this._setVisible(e,!1)}}">Hide</button>`:l`<button type="button" class="action" ?disabled="${!o}" @click="${()=>{this._setVisible(e,!0)}}">Make visible</button>`}<a class="action" href="${`/api/admin/reports/${encodeURIComponent(e.id)}`}">Download</a><button type="button" class="action" @click="${()=>this._delete(e)}">Delete</button></span></div>${this._preview===e.id?l`<div class="preview">${this._previewLoading===e.id?l`<span class="preview-loading">Loading preview…</span>`:l`<pre>${this._previewText??""}</pre>`}</div>`:u} ${this._locationReport===e.id?this._locationEditor(e):u}</li>`}_openLocation(e){this._locationReport=e.id,this._locationRepo=e.repoId??null,this._locationDirectory=e.repoDirectory??"",this._error=null}_locationEditor(e){let t=Array.isArray(this._data?.repos)?this._data.repos:[];return l`<div class="location-editor"><div class="location-field"><span>Repository</span><repository-selector label="Repository for report" .options="${hr(t)}" .value="${this._locationRepo}" ?disabled="${this._locationBusy}" @repository-change="${i=>{this._locationRepo=i.detail.value}}"></repository-selector></div><div class="location-field"><label for="${`report-dir-${e.id}`}">Directory (optional)</label><input id="${`report-dir-${e.id}`}" type="text" placeholder="Repository root" .value="${this._locationDirectory}" @input="${i=>{this._locationDirectory=i.target.value}}"></div><div class="location-actions"><button type="button" class="action" @click="${()=>{this._locationReport=null}}">Cancel</button><button type="button" class="action" ?disabled="${this._locationBusy||this._locationRepo==null}" @click="${()=>{this._saveLocation(e)}}">Save</button></div></div>`}async _saveLocation(e){if(!(this._locationRepo==null||this._locationBusy)){this._locationBusy=!0;try{await un(e.id,this._locationRepo,this._locationDirectory.trim(),this._csrf),this._locationReport=null,await this._load()}catch(t){this._error=`Couldn't set report location: ${String(t?.message??t)}`}finally{this._locationBusy=!1}}}_cancelPreview(){this._previewRequest?.abort(),this._previewRequest=null,this._preview=null,this._previewLoading=null,this._previewText=""}async _togglePreview(e){let t=this._preview===e.id;if(this._cancelPreview(),t)return;let i=new AbortController;this._previewRequest=i;let s=()=>this._previewRequest===i&&!i.signal.aborted;this._preview=e.id,this._previewLoading=e.id;try{let o=await y(`/api/admin/reports/${encodeURIComponent(e.id)}`,{credentials:"same-origin",signal:i.signal});if(!o.ok)throw new Error(`HTTP ${o.status}`);let n=await o.text();s()&&(this._previewText=n.slice(0,4e3)+(n.length>4e3?`
47
+ \u2026`:""))}catch(o){s()&&(this._previewText=`Preview unavailable: ${o?.message??o}`)}finally{s()&&(this._previewLoading=null)}}async _setVisible(e,t){try{await pn(e.id,t,this._csrf),e.visible=t,this.requestUpdate()}catch(i){this._error=`Couldn't change report visibility: ${String(i?.message??i)}`}}async _upload(e){if(e.length!==0&&(this._queue.push(...e),!this._busy)){this._busy=!0,this._error=null;try{for(;this._queue.length>0;)await dn(this._queue.shift(),this._csrf,this._repoId,this._repoDirectory.trim())}catch(t){this._queue=[],this._error=`Upload failed: ${String(t?.message??t)}`}finally{this._busy=!1,await this._load()}}}async _delete(e){if(globalThis.confirm?.(`Delete \u201C${e.filename}\u201D? This can't be undone.`)){try{await hn(e.id,this._csrf)}catch(t){this._error=`Delete failed: ${String(t?.message??t)}`}await this._load()}}};customElements.define("managed-admin-reports",lr);async function gn(){let r=await y("/api/admin/bundles",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async function bn(r,e,t){let i={"content-type":"application/octet-stream","x-bundle-filename":encodeURIComponent(r.name)};e&&(i["x-csrf-token"]=e),t!=null&&(i["x-repo-id"]=String(t));let s=await y("/api/admin/bundles",{method:"POST",credentials:"same-origin",headers:i,body:r});if(!s.ok)throw new Error(s.status===413?"too large":`HTTP ${s.status}`);return s.json()}async function vn(r,e){let t=e?{"x-csrf-token":e}:{},i=await y(`/api/admin/bundles/${encodeURIComponent(r)}`,{method:"DELETE",credentials:"same-origin",headers:t});if(!i.ok)throw new Error(`HTTP ${i.status}`)}async function _n(r,e,t){let i={"content-type":"application/json"};t&&(i["x-csrf-token"]=t);let s=await y("/api/admin/bundles/set-repo",{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify({bundleId:r,repoId:e})});if(!s.ok)throw new Error(`HTTP ${s.status}`)}var yn=l`<svg class="report-icon" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M8.878.392a1.75 1.75 0 0 0-1.756 0l-5.25 3.045A1.75 1.75 0 0 0 1 4.951v6.098c0 .624.332 1.2.872 1.514l5.25 3.045a1.75 1.75 0 0 0 1.756 0l5.25-3.045c.54-.313.872-.89.872-1.514V4.951c0-.624-.332-1.2-.872-1.514ZM7.875 1.69a.25.25 0 0 1 .25 0l4.63 2.685L8 7.133 3.245 4.375Zm-5.125 4.4 4.5 2.61v5.317l-4.375-2.537a.25.25 0 0 1-.125-.216Zm6 7.927V8.7l4.5-2.61v3.96a.25.25 0 0 1-.125.216Z"/></svg>`,cr=class extends w{static properties={_data:{state:!0},_repoId:{state:!0},_error:{state:!0},_busy:{state:!0},_dragOver:{state:!0}};static styles=[te,x`:host{display:block;position:relative;padding:clamp(1.5rem,4vw,2.5rem) clamp(1rem,4vw,2.5rem);color:var(--text);container-type:inline-size}*{box-sizing:border-box}.wrap{max-width:68rem;margin:0 auto}.head{margin-bottom:.4rem}h1{font-size:1.65rem;letter-spacing:-.035em}button,select{font:inherit;cursor:default}a:focus-visible,button:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:3px}.intro{margin:0 0 1rem;color:var(--muted);font-size:.8rem;line-height:1.45}.dropzone{position:absolute;inset:.6rem;z-index:5;display:grid;place-items:center;border:2px dashed var(--accent);border-radius:10px;background:rgb(from var(--bg) r g b / .94);color:var(--accent);font-size:1rem;font-weight:600;pointer-events:none}.upload-panel{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:.55rem 1rem;padding:.7rem .8rem;margin-bottom:1rem;border:1px dashed color-mix(in srgb,var(--border) 70%,var(--muted));border-radius:8px;background:var(--surface)}.upload-copy{display:grid;gap:.25rem}.upload-copy strong{font-size:.87rem;font-weight:600}.upload-copy>span{color:var(--muted);font-size:.72rem}.upload-controls{display:flex;align-items:end;gap:.65rem}.repo-picker{display:grid;gap:.3rem;min-width:0}.repo-picker-label{color:var(--muted);font-size:.67rem}.repo-attach,.repo-select{min-width:0;width:100%}.repo-select{max-width:18rem}.drop-browse{height:2rem;flex-shrink:0;padding:.3rem .75rem;border:1px solid var(--accent);border-radius:5px;color:var(--bg);background:var(--accent);font-size:.74rem;font-weight:600}.drop-browse:hover:not(:disabled){filter:brightness(1.08)}.drop-browse:disabled{opacity:.5}.section-head{display:flex;align-items:baseline;justify-content:space-between;flex-wrap:wrap;gap:.5rem;margin-bottom:.6rem}.section-head h2{margin:0;font-size:.85rem;font-weight:600}.summary{display:flex;flex-wrap:wrap;align-items:center;gap:.75rem;color:var(--muted);font-size:.7rem;font-variant-numeric:tabular-nums}.unassigned{color:var(--high,#d97732)}.bundles{margin:0;padding:0;list-style:none}.bundle-groups{display:grid;gap:.65rem}.bundle-group{overflow:hidden;border:1px solid var(--border);border-radius:8px;background:var(--surface)}.bundle-group-head{display:flex;align-items:center;justify-content:space-between;gap:.6rem;padding:.45rem .7rem;border-bottom:1px solid var(--border)}.bundle-group-head strong{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.74rem;font-weight:600}.bundle-group-head span{color:var(--muted);font-size:.67rem}.bundle-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(10rem,15rem) auto;align-items:center;gap:.75rem;padding:.42rem .65rem}.bundle-row+.bundle-row{border-top:1px solid var(--border)}.identity{display:flex;align-items:flex-start;min-width:0;gap:.5rem}.bundle-icon{display:grid;place-items:center;width:1.45rem;height:1.45rem;flex-shrink:0;color:var(--muted)}.bundle-icon svg{width:1rem;height:1rem}.who{display:grid;min-width:0;gap:.12rem}.filename{font-size:.82rem;font-weight:600;overflow-wrap:anywhere}.meta{display:flex;flex-wrap:wrap;gap:.2rem .5rem;color:var(--muted);font-size:.62rem;line-height:1.35}.kind{color:var(--text)}.bundle-location{display:grid;gap:.18rem;min-width:0}.bundle-location-label{color:var(--muted);font-size:.6rem}.actions{display:flex;gap:.2rem}.action{display:grid;place-items:center;width:1.65rem;height:1.65rem;padding:.35rem;border:1px solid transparent;border-radius:5px;background:0 0;color:var(--muted);text-decoration:none}.action svg{width:1rem;height:1rem}.action:hover{color:var(--text);border-color:var(--border);background:var(--surface)}.action.danger:hover{color:var(--critical,#e5534b)}.msg{padding:1rem 0;margin:0;color:var(--muted);font-size:.8rem}.msg.error{color:var(--critical,#e5534b)}.upload-controls{justify-content:space-between}.repo-picker{flex:1}.repo-select{max-width:none}.bundle-row{grid-template-columns:minmax(0,1fr) auto;gap:.5rem}.bundle-location{grid-column:1;padding-left:2.4rem}.actions{grid-column:2;grid-row:1/3}.repo-picker{flex-basis:100%}`];constructor(){super(),this._data=null,this._error=null,this._csrf=null,this._busy=!1,this._repoId=null,this._dragOver=!1,this._teardownDrop=null,this._queue=[]}connectedCallback(){super.connectedCallback(),this._load(),this._teardownDrop=Ki(this,e=>{this._upload(e)},e=>{this._dragOver=e})}disconnectedCallback(){super.disconnectedCallback(),this._teardownDrop?.()}async _load(){this._error=null,this._data=null;try{let[e,t]=await Promise.all([ee(),gn()]);this._csrf=e?.csrfToken??null,this._data=t}catch(e){this._error=String(e?.message??e)}}render(){return l`${this._dragOver?l`<div class="dropzone">Drop bundles to upload</div>`:u}<div class="wrap"><div class="head">${re()}<h1>Bundles</h1></div><p class="intro">Source bundles and sourcemaps for your repositories.</p><section class="upload-panel" aria-label="Upload bundles"><div class="upload-copy"><strong>Drop bundles here</strong><span>Choose a repository for your uploads.</span></div><div class="upload-controls">${mn(this._data?.repos,this._repoId,e=>{this._repoId=e},"Repository")}<button type="button" class="drop-browse" ?disabled="${this._busy}" @click="${()=>Wi(e=>{this._upload(e)})}">${this._busy?"Uploading\u2026":"Browse files"}</button></div></section>${this._body()}</div>`}_body(){if(this._error!=null)return l`<p class="msg error">Couldn't load bundles: ${this._error}</p>`;if(this._data==null)return l`<p class="msg">Loading…</p>`;let e=Array.isArray(this._data.bundles)?this._data.bundles:[],t=e.filter(o=>o.repoId==null).length,i=e.reduce((o,n)=>o+(Number.isFinite(n.byteSize)?n.byteSize:0),0),s=Map.groupBy(e,o=>o.repoFullName||"Unattached");return l`<div class="section-head"><h2>Stored bundles</h2><span class="summary"><span>${e.length} ${e.length===1?"bundle":"bundles"}</span><span>${ar(i)}</span>${t?l`<span class="unassigned">${t} unattached</span>`:u}</span></div>${e.length>0?l`<div class="bundle-groups">${[...s].toSorted(([o],[n])=>o==="Unattached"?1:n==="Unattached"?-1:o.localeCompare(n)).map(([o,n])=>l`<section class="bundle-group"><div class="bundle-group-head"><strong>${o}</strong><span>${n.length} ${n.length===1?"bundle":"bundles"}</span></div><ul class="bundles">${n.map(a=>this._row(a))}</ul></section>`)}</div>`:l`<p class="msg">No bundles uploaded yet.</p>`}`}_row(e){let t=Number.isFinite(e.uploadedAt)?new Date(e.uploadedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):"";return l`<li class="bundle-row"><span class="identity"><span class="bundle-icon" aria-hidden="true">${yn}</span><span class="who"> <span class="filename">${e.filename}</span> <span class="meta"><span class="kind">${e.kind==="stasis"?"Stasis":"Sourcemaps"}</span><span>${ar(e.byteSize)}</span><span>${t}</span>${e.uploadedByLogin?l`<span>@${e.uploadedByLogin}</span>`:u}</span> </span></span><span class="bundle-location">${fn(this._data?.repos,e.repoId,i=>this._setRepo(e,i))}</span> <span class="actions"><a class="action" aria-label="${`Download ${e.filename}`}" href="${`/api/admin/bundles/${encodeURIComponent(e.id)}`}"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2v8m-3-3 3 3 3-3M3 11v3h10v-3"/></svg></a><button type="button" class="action danger" aria-label="${`Delete ${e.filename}`}" @click="${()=>this._delete(e)}">${rr}</button></span></li>`}async _setRepo(e,t){try{await _n(e.id,t,this._csrf)}catch(i){this._error=`Couldn't change repo: ${String(i?.message??i)}`}await this._load()}async _upload(e){if(e.length!==0&&(this._queue.push(...e),!this._busy)){this._busy=!0,this._error=null;try{for(;this._queue.length>0;){let t=this._queue.shift();await bn(t,this._csrf,this._repoId)}}catch(t){this._queue=[],this._error=`Upload failed: ${String(t?.message??t)}`}finally{this._busy=!1,await this._load()}}}async _delete(e){if(globalThis.confirm?.(`Delete \u201C${e.filename}\u201D? Linked reports will keep their pending link.`)){try{await vn(e.id,this._csrf)}catch(t){this._error=`Delete failed: ${String(t?.message??t)}`}await this._load()}}};customElements.define("managed-admin-bundles",cr);var dr=class extends w{static styles=[te,x`:host{display:block}`];constructor(){super(),this._loadModels=e=>ae(e,y),this._source={bundles:ri(),repositories:ei,scans:ti.map(e=>({...e}))},this._loadReportSources=async e=>{let[t,i]=await Promise.all([y("/api/admin/reports",{signal:e,credentials:"same-origin"}),y("/api/admin/scan-results",{signal:e,credentials:"same-origin"})]);if(!t.ok)throw new Error(`Reports: HTTP ${t.status}`);if(!i.ok&&i.status!==404)throw new Error(`Scan results: HTTP ${i.status}`);let s=await t.json();return s.reports=await Promise.all((s.reports??[]).filter(o=>o.visible&&o.repoId!=null).map(async o=>{let n=await y(`/api/admin/reports/${encodeURIComponent(o.id)}`,{signal:e,credentials:"same-origin"});if(!n.ok)throw new Error(`Report ${o.filename}: HTTP ${n.status}`);return{...o,content:await n.text()}})),Di(s,i.ok?await i.json():{bundles:[],results:[]})}}render(){return l`<deepview-scan-page .source="${this._source}" .loadModels="${this._loadModels}" .loadReportSources="${this._loadReportSources}"><span slot="navigation">${re()}</span></deepview-scan-page>`}};customElements.define("managed-admin-scans",dr);async function Zi(){let r=await y("/api/admin/teams",{credentials:"same-origin",headers:{accept:"application/json"}});if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}async function H(r,e,t){let i={"content-type":"application/json"};e&&(i["x-csrf-token"]=e);let s=await y(r,{method:"POST",credentials:"same-origin",headers:i,body:JSON.stringify(t)});if(!s.ok)throw new Error(s.status===409?"name already taken":`HTTP ${s.status}`)}var pr=class extends w{static properties={_data:{state:!0},_error:{state:!0},_busy:{state:!0},_renamingId:{state:!0},_repoChoices:{state:!0},_memberChoices:{state:!0}};static styles=[te,ur,x`.create-team{display:flex;align-items:center;gap:.5rem;margin-bottom:1.2rem}.create-team label{color:var(--muted);font-size:.78rem;margin-right:.25rem}.new-name{width:15rem}.team{border:1px solid var(--border);border-radius:9px;margin-bottom:1rem;background:var(--surface);overflow:hidden}.team-head{display:flex;align-items:center;gap:.65rem;min-height:3.6rem;padding:.8rem 1rem;border-bottom:1px solid var(--border)}.team-icon{display:grid;place-items:center;flex:0 0 auto;width:1.9rem;height:1.9rem;border-radius:6px;background:rgb(from var(--accent) r g b / .1);color:var(--accent)}.team-icon svg{width:1.05rem;height:1.05rem}.team-name{margin:0;min-width:0;font-size:1rem;font-weight:600;letter-spacing:-.015em;overflow-wrap:anywhere}.team-actions{display:flex;gap:.25rem;margin-left:auto}.rename-input{flex:1;max-width:22rem;width:0}.team-body{display:grid;grid-template-columns:minmax(0,.85fr) minmax(0,1.15fr)}.sub{min-width:0;padding:1rem}.sub+.sub{border-left:1px solid var(--border)}.sub-title{display:flex;align-items:center;gap:.45rem;margin:0;font-size:.82rem;font-weight:600}.sub-title .count{height:1.1rem;min-width:1.1rem;font-size:.65rem;padding:0 .3rem}.sub-description{display:flex;flex-direction:column;gap:.12rem;margin:.35rem 0 .65rem;color:var(--muted);font-size:.72rem;line-height:1.4}.links{list-style:none;margin:0 0 .5rem;padding:0}.links li{display:flex;align-items:center;gap:.5rem;min-height:2.9rem;padding:.5rem 0}.links li+li{border-top:1px solid var(--border)}.repo-icon{flex:0 0 auto;color:var(--muted);width:.95rem;height:.95rem}.repo-copy{display:flex;min-width:0;flex-direction:column;gap:.2rem}.ln{min-width:0;font-size:.8rem;font-weight:500;overflow-wrap:anywhere}.path{color:var(--muted);font-family:var(--mono);font-size:.7rem;overflow-wrap:anywhere}.repo-row .icon-btn{margin-left:auto}.links .member-row{display:grid;grid-template-columns:minmax(0,1fr) auto 1.8rem;gap:.45rem}.member{display:flex;align-items:center;gap:.45rem;min-width:0}.member .avatar{width:1.6rem;height:1.6rem;font-size:.65rem}.perms{display:flex;flex-wrap:wrap;gap:.3rem}.perm{display:inline-flex;align-items:center;gap:.3rem;padding:.3rem .4rem;border:1px solid var(--border);border-radius:5px;font-size:.67rem;color:var(--muted);user-select:none}.perm:has(:checked){color:var(--text);background:rgb(from var(--accent) r g b / .07);border-color:rgb(from var(--accent) r g b / .2)}.perm:has(:disabled){opacity:.5}.add-row{display:flex;align-items:center;gap:.4rem;padding-top:.55rem}.add-row repository-selector,.add-row select,.add-row user-selector{flex:1;width:0}.add-repo-path{flex:.75;width:0}.add-row .btn{flex:0 0 auto}.muted{color:var(--muted);font-size:.78rem;margin:.75rem 0}.sub+.sub{border-left:0;border-top:1px solid var(--border)}.add-row{max-width:36rem}.create-team label{flex-basis:100%}.new-name{flex:1;width:0}.sub,.team-head{padding-left:.75rem;padding-right:.75rem}.links .member-row{grid-template-columns:minmax(0,1fr) 1.8rem}.perms{grid-row:2;padding-left:2.05rem}.member-row>.icon-btn{grid-column:2;grid-row:1}.add-row{flex-wrap:wrap}.add-repo-sel{flex-basis:calc(100% - 4rem)!important}.add-repo-path{order:1;flex-basis:100%}`];constructor(){super(),this._data=null,this._error=null,this._csrf=null,this._busy=!1,this._renamingId=null,this._repoChoices=new Map,this._memberChoices=new Map}connectedCallback(){super.connectedCallback(),this._load()}async _load(){this._error=null;try{let[e,t]=await Promise.all([ee(),Zi()]);this._csrf=e?.csrfToken??null,this._data=t}catch(e){this._error=String(e?.message??e)}}async _do(e){if(!this._busy){this._busy=!0,this._error=null;try{await e()}catch(t){this._error=String(t?.message??t)}finally{this._busy=!1,await this._load()}}}render(){return l`<div class="wrap"><div class="head">${re()}<h1>Teams</h1>${this._data?.teams?l`<span class="count">${this._data.teams.length}</span>`:u}</div><p class="intro">Group repositories and give members access to the findings they need.</p><div class="create-team"><label for="new-team-name">New team</label> <input id="new-team-name" class="new-name" type="text" placeholder="Team name" maxlength="100" ?disabled="${this._busy}" @keydown="${e=>{e.key==="Enter"&&this._create()}}"> <button class="btn primary" ?disabled="${this._busy}" @click="${()=>this._create()}">${tr} Create team</button></div>${this._body()}</div>`}_body(){if(this._error!=null&&this._data==null)return l`<p class="msg error">Couldn't load teams: ${this._error}</p>`;if(this._data==null)return l`<p class="msg">Loading…</p>`;let e=Array.isArray(this._data.teams)?this._data.teams:[];return l`${this._error==null?u:l`<p class="msg error">${this._error}</p>`} ${e.length===0?l`<p class="msg">No teams yet. Create one above.</p>`:e.map(t=>this._team(t))}`}_team(e){return l`<section class="team" aria-label="${e.name}"><div class="team-head"><span class="team-icon" aria-hidden="true"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="5" r="2.5"/><path d="M1.5 13v-1c0-2 1.8-3.5 4.5-3.5s4.5 1.5 4.5 3.5v1M11 2.5a2.5 2.5 0 0 1 0 5M12 9c1.7.5 2.5 1.5 2.5 3v1"/></svg></span>${this._renamingId===e.id?l`<input class="rename-input" type="text" .value="${e.name}" maxlength="100" aria-label="Team name" @keydown="${t=>this._renameKey(t,e)}"> <button class="btn" ?disabled="${this._busy}" @click="${t=>this._saveRename(e,t)}">Save</button> <button class="btn" @click="${()=>{this._renamingId=null}}">Cancel</button>`:l`<h2 class="team-name">${e.name}</h2><span class="team-actions"><button class="icon-btn" aria-label="${`Rename ${e.name}`}" ?disabled="${this._busy}" @click="${()=>{this._renamingId=e.id}}">${Zo}</button> <button class="icon-btn danger" aria-label="${`Delete ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._deleteTeam(e)}">${Yo}</button></span>`}</div><div class="team-body"><div class="sub"><h3 class="sub-title">Repositories <span class="count">${e.repos.length}</span></h3><p class="sub-description">Source repositories included in this team.</p>${e.repos.length===0?l`<p class="muted">No repositories linked.</p>`:l`<ul class="links">${e.repos.map(t=>this._repoRow(e,t))}</ul>`} ${this._addRepoRow(e)}</div><div class="sub"><h3 class="sub-title">Members <span class="count">${e.members.length}</span></h3><p class="sub-description"><span>Membership includes the scan’s standard non-security findings.</span><span>Add underlying dependency or security findings per member.</span></p>${e.members.length===0?l`<p class="muted">No members.</p>`:l`<ul class="links">${e.members.map(t=>this._memberRow(e,t))}</ul>`} ${this._addMemberRow(e)}</div></div></section>`}_repoRow(e,t){return l`<li class="repo-row">${Gi} <span class="repo-copy"><span class="ln">${t.fullName}</span>${t.path?l`<span class="path">/${t.path.replace(/^\/+/u,"")}</span>`:u}</span> <button class="icon-btn danger" aria-label="${`Remove ${t.fullName}${t.path?`/${t.path}`:""} from ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._do(()=>H("/api/admin/teams/remove-repo",this._csrf,{teamId:e.id,repoId:t.repoId,path:t.path??null}))}">${rr}</button></li>`}_addRepoRow(e){let t=Array.isArray(this._data.repos)?this._data.repos:[];return t.length===0?l`<p class="muted">No selected repositories to link — pick some on “Manage repositories”.</p>`:l`<div class="add-row"><repository-selector class="add-repo-sel" label="${`Repository to add to ${e.name}`}" placeholder="Add repository…" ?disabled="${this._busy}" .options="${t.map(i=>({value:i.repoId,label:i.fullName}))}" .value="${this._repoChoices.get(e.id)??null}" @repository-change="${i=>{this._repoChoices=new Map(this._repoChoices).set(e.id,i.detail.value)}}"></repository-selector><input class="add-repo-path" type="text" placeholder="Path (optional)" aria-label="${`Repository path in ${e.name} (optional)`}" maxlength="500" ?disabled="${this._busy}"> <button class="btn" aria-label="${`Add repository to ${e.name}`}" ?disabled="${this._busy||!this._repoChoices.has(e.id)}" @click="${i=>this._addRepo(e,i)}">${tr} Add</button></div>`}_memberRow(e,t){let i=Array.isArray(this._data.permissions)?this._data.permissions:[];return l`<li class="member-row"><span class="member">${qi(t.userId,t.login)}<span class="ln">${t.login}</span></span> <span class="perms">${i.map(s=>l`<label class="perm"><input type="checkbox" .checked="${t[s]===!0}" ?disabled="${this._busy}" aria-label="${`${it[s]??s} access for ${t.login} in ${e.name}`}" @change="${o=>this._togglePerm(e,t,s,o.target.checked)}"> ${it[s]??s}</label>`)} </span><button class="icon-btn danger" aria-label="${`Remove ${t.login} from ${e.name}`}" ?disabled="${this._busy}" @click="${()=>this._do(()=>H("/api/admin/teams/remove-member",this._csrf,{teamId:e.id,userId:t.userId}))}">${rr}</button></li>`}_addMemberRow(e){let t=Array.isArray(this._data.users)?this._data.users:[],i=new Set(e.members.map(s=>s.userId));return l`<div class="add-row"><user-selector class="add-member-sel" label="${`Member to add to ${e.name}`}" placeholder="Add member…" ?disabled="${this._busy}" .users="${t.map(s=>({...s,disabled:i.has(s.id),detail:i.has(s.id)?"Member":""}))}" .value="${this._memberChoices.get(e.id)??null}" @user-change="${s=>{this._memberChoices=new Map(this._memberChoices).set(e.id,s.detail.value)}}"></user-selector><button class="btn" aria-label="${`Add member to ${e.name}`}" ?disabled="${this._busy||!this._memberChoices.has(e.id)||i.has(this._memberChoices.get(e.id))}" @click="${()=>this._addMember(e)}">${tr} Add</button></div>`}_create(){let e=this.renderRoot.querySelector(".new-name"),t=e?.value.trim();t&&this._do(async()=>{await H("/api/admin/teams",this._csrf,{name:t}),e&&(e.value="")})}_deleteTeam(e){globalThis.confirm?.(`Delete team \u201C${e.name}\u201D? Its repo + member links are removed.`)&&this._do(()=>H("/api/admin/teams/delete",this._csrf,{teamId:e.id}))}_renameKey(e,t){e.key==="Enter"?this._saveRename(t,e):e.key==="Escape"&&(this._renamingId=null)}_saveRename(e,t){if(this._busy)return;let i=t.target.closest(".team-head")?.querySelector(".rename-input")?.value.trim()??"";this._renamingId=null,!(i===""||i===e.name)&&this._do(()=>H("/api/admin/teams/rename",this._csrf,{teamId:e.id,name:i}))}_addRepo(e,t){let i=t.target.closest(".add-row"),s=this._repoChoices.get(e.id);if(!Number.isSafeInteger(s)||s<=0)return;let o=i?.querySelector(".add-repo-path")?.value??"";this._do(async()=>{await H("/api/admin/teams/set-repo",this._csrf,{teamId:e.id,repoId:s,path:o});let n=new Map(this._repoChoices);n.delete(e.id),this._repoChoices=n;let a=i?.querySelector(".add-repo-path");a&&(a.value="")})}_addMember(e){let t=this._memberChoices.get(e.id);!t||e.members.some(i=>i.userId===t)||this._do(async()=>{await H("/api/admin/teams/set-member",this._csrf,{teamId:e.id,userId:t});let i=new Map(this._memberChoices);i.delete(e.id),this._memberChoices=i})}_togglePerm(e,t,i,s){let o={};for(let n of this._data.permissions??[])o[n]=t[n]===!0;o[i]=s,this._do(()=>H("/api/admin/teams/set-member",this._csrf,{teamId:e.id,userId:t.userId,...o}))}};customElements.define("managed-admin-teams",pr);async function mr(r){let e;try{e=await y(r,{credentials:"same-origin",headers:{accept:"application/json"}})}catch{return null}if(!e.ok)return null;try{return await e.json()}catch{return null}}async function Wc(){let r=await mr("/api/auth/session"),e=r?.user;return e==null||typeof e.login!="string"?null:{id:e.id,login:e.login,name:typeof e.name=="string"?e.name:null,avatarUrl:typeof e.avatarUrl=="string"?e.avatarUrl:null,role:typeof e.role=="string"?e.role:"none",csrfToken:typeof r.csrfToken=="string"?r.csrfToken:null}}async function Kc(){let e=(await mr("/api/teams"))?.teams;return Array.isArray(e)?e.filter(t=>t!=null&&typeof t.id=="string"&&typeof t.name=="string").map(t=>({id:t.id,name:t.name,reports:Array.isArray(t.reports)?t.reports.filter(i=>i!=null&&typeof i.id=="string"&&typeof i.filename=="string").map(i=>({id:i.id,filename:i.filename})):[],bundles:Array.isArray(t.bundles)?t.bundles.filter(i=>i!=null&&typeof i.id=="string"&&typeof i.filename=="string").map(i=>({id:i.id,filename:i.filename,repoFullName:typeof i.repoFullName=="string"?i.repoFullName:""})):[]})):[]}async function Zc(r){let e;try{e=await y(`/api/reports/${encodeURIComponent(r)}`,{credentials:"same-origin"})}catch{return null}if(!e.ok)return null;try{return await e.text()}catch{return null}}async function Yc(r){let t=(await mr(`/api/reports/${encodeURIComponent(r)}/triage`))?.entries;return t!=null&&typeof t=="object"&&!Array.isArray(t)?t:null}async function Jc(r,e,t){try{return(await y(`/api/reports/${encodeURIComponent(r)}/triage`,{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json",...t?{"x-csrf-token":t}:{}},body:JSON.stringify({entries:e})})).status}catch{return 0}}function Xc(r){r&&(location.href=r)}async function Qc(r){try{await y("/api/auth/logout",{method:"POST",credentials:"same-origin",headers:r?{"x-csrf-token":r}:{}})}catch{}location.reload()}export{Zc as fetchReport,Yc as fetchReportTriage,ot as getPreviewRole,Xc as login,Qc as logout,Wc as probeSession,Kc as probeTeams,Jc as pushReportTriage,Yi as setPreviewRole};
48
+ /*! Bundled license information:
49
+
50
+ @lit/reactive-element/css-tag.js:
51
+ (**
52
+ * @license
53
+ * Copyright 2019 Google LLC
54
+ * SPDX-License-Identifier: BSD-3-Clause
55
+ *)
56
+
57
+ @lit/reactive-element/reactive-element.js:
58
+ lit-html/lit-html.js:
59
+ lit-element/lit-element.js:
60
+ lit-html/directive.js:
61
+ lit-html/directives/unsafe-html.js:
62
+ lit-html/directives/repeat.js:
63
+ (**
64
+ * @license
65
+ * Copyright 2017 Google LLC
66
+ * SPDX-License-Identifier: BSD-3-Clause
67
+ *)
68
+
69
+ lit-html/is-server.js:
70
+ (**
71
+ * @license
72
+ * Copyright 2022 Google LLC
73
+ * SPDX-License-Identifier: BSD-3-Clause
74
+ *)
75
+
76
+ lit-html/directive-helpers.js:
77
+ lit-html/directives/live.js:
78
+ (**
79
+ * @license
80
+ * Copyright 2020 Google LLC
81
+ * SPDX-License-Identifier: BSD-3-Clause
82
+ *)
83
+ */