import*as i18n from"../i18n/i18n.js";import*as UI from"../ui/ui.js";import{AffectedResourcesView}from"./AffectedResourcesView.js";const UIStrings={violation:"violation",violations:"violations",warning:"warning",blocked:"blocked",instantiation:"Instantiation",aSharedarraybufferWas:"A `SharedArrayBuffer` was instantiated in a context that is not cross-origin isolated",transfer:"Transfer",sharedarraybufferWasTransferedTo:"`SharedArrayBuffer` was transfered to a context that is not cross-origin isolated",sourceLocation:"Source Location",trigger:"Trigger",status:"Status"},str_=i18n.i18n.registerUIStrings("issues/AffectedSharedArrayBufferIssueDetailsView.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class AffectedSharedArrayBufferIssueDetailsView extends AffectedResourcesView{constructor(t,e){super(t,{singular:i18nString(UIStrings.violation),plural:i18nString(UIStrings.violations)}),this.issue=e}appendStatus(t,e){const s=document.createElement("td");e?(s.classList.add("affected-resource-report-only-status"),s.textContent=i18nString(UIStrings.warning)):(s.classList.add("affected-resource-blocked-status"),s.textContent=i18nString(UIStrings.blocked)),t.appendChild(s)}appendType(t,e){const s=document.createElement("td");switch(e){case Protocol.Audits.SharedArrayBufferIssueType.CreationIssue:s.textContent=i18nString(UIStrings.instantiation),UI.Tooltip.Tooltip.install(s,i18nString(UIStrings.aSharedarraybufferWas));break;case Protocol.Audits.SharedArrayBufferIssueType.TransferIssue:s.textContent=i18nString(UIStrings.transfer),UI.Tooltip.Tooltip.install(s,i18nString(UIStrings.sharedarraybufferWasTransferedTo))}t.appendChild(s)}appendDetails(t){const e=document.createElement("tr");this.appendColumnTitle(e,i18nString(UIStrings.sourceLocation)),this.appendColumnTitle(e,i18nString(UIStrings.trigger)),this.appendColumnTitle(e,i18nString(UIStrings.status)),this.affectedResources.appendChild(e);let s=0;for(const i of t)s++,this.appendDetail(i);this.updateAffectedResourceCount(s)}appendDetail(t){const e=document.createElement("tr");e.classList.add("affected-resource-directive");const s=t.details();this.appendSourceLocation(e,s.sourceCodeLocation,t.model()?.getTargetIfNotDisposed()),this.appendType(e,s.type),this.appendStatus(e,s.isWarning),this.affectedResources.appendChild(e)}update(){this.clear(),this.appendDetails(this.issue.getSharedArrayBufferIssues())}}