import*as i18n from"../i18n/i18n.js";import{AffectedResourcesView}from"./AffectedResourcesView.js";const UIStrings={item:"item",items:"items",warning:"warning",blocked:"blocked",status:"Status",request:"Request",resourceAddressSpace:"Resource Address",initiatorAddressSpace:"Initiator Address",secure:"secure",insecure:"insecure",initiatorContext:"Initiator Context"},str_=i18n.i18n.registerUIStrings("issues/CorsIssueDetailsView.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class CorsIssueDetailsView extends AffectedResourcesView{constructor(e,t){super(e,{singular:i18nString(UIStrings.item),plural:i18nString(UIStrings.items)}),this.issue=t}appendStatus(e,t){const s=document.createElement("td");t?(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)),e.appendChild(s)}appendDetails(e){const t=document.createElement("tr");this.appendColumnTitle(t,i18nString(UIStrings.request)),this.appendColumnTitle(t,i18nString(UIStrings.status)),this.appendColumnTitle(t,i18nString(UIStrings.resourceAddressSpace)),this.appendColumnTitle(t,i18nString(UIStrings.initiatorAddressSpace)),this.appendColumnTitle(t,i18nString(UIStrings.initiatorContext)),this.affectedResources.appendChild(t);let s=0;for(const i of e)s++,this.appendDetail(i);this.updateAffectedResourceCount(s)}appendSecureContextCell(e,t){void 0!==t?this.appendIssueDetailCell(e,i18nString(t?UIStrings.secure:UIStrings.insecure)):this.appendIssueDetailCell(e,"")}appendDetail(e){const t=document.createElement("tr");t.classList.add("affected-resource-directive");const s=e.details();t.appendChild(this.createRequestCell(s.request)),this.appendStatus(t,s.isWarning),this.appendIssueDetailCell(t,s.resourceIPAddressSpace??""),this.appendIssueDetailCell(t,s.clientSecurityState?.initiatorIPAddressSpace??""),this.appendSecureContextCell(t,s.clientSecurityState?.initiatorIsSecureContext),this.affectedResources.appendChild(t)}update(){this.clear(),this.appendDetails(this.issue.getCorsIssues())}}