import*as i18n from"../i18n/i18n.js";import*as SDK from"../sdk/sdk.js";import{AffectedResourcesView}from"./AffectedResourcesView.js";const UIStrings={resource:"resource",resources:"resources",statusCode:"Status code",url:"Url",packageName:"Package name",packageSignature:"Package signature"},str_=i18n.i18n.registerUIStrings("issues/AffectedTrustedWebActivityIssueDetailsView.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class AffectedTrustedWebActivityIssueDetailsView extends AffectedResourcesView{constructor(e,t){super(e,{singular:i18nString(UIStrings.resource),plural:i18nString(UIStrings.resources)}),this.issue=t}appendDetail(e){const t=document.createElement("tr");t.classList.add("affected-resource-row");const s=e.details();this.issue.code()===SDK.TrustedWebActivityIssue.httpViolationCode&&s.httpStatusCode?(this.appendIssueDetailCell(t,s.httpStatusCode.toString()),this.appendIssueDetailCell(t,s.url)):this.issue.code()===SDK.TrustedWebActivityIssue.offlineViolationCode?this.appendIssueDetailCell(t,s.url):this.issue.code()===SDK.TrustedWebActivityIssue.assetlinkViolationCode&&(this.appendIssueDetailCell(t,s.packageName||""),this.appendIssueDetailCell(t,s.url),this.appendIssueDetailCell(t,s.signature||"")),this.affectedResources.appendChild(t)}appendDetails(e){const t=document.createElement("tr");this.issue.code()===SDK.TrustedWebActivityIssue.httpViolationCode?(this.appendColumnTitle(t,i18nString(UIStrings.statusCode)),this.appendColumnTitle(t,i18nString(UIStrings.url))):this.issue.code()===SDK.TrustedWebActivityIssue.offlineViolationCode?this.appendColumnTitle(t,i18nString(UIStrings.url)):this.issue.code()===SDK.TrustedWebActivityIssue.assetlinkViolationCode&&(this.appendColumnTitle(t,i18nString(UIStrings.packageName)),this.appendColumnTitle(t,i18nString(UIStrings.url)),this.appendColumnTitle(t,i18nString(UIStrings.packageSignature))),this.affectedResources.appendChild(t);let s=0;for(const i of e)this.appendDetail(i),s++;this.updateAffectedResourceCount(s)}update(){this.clear(),this.appendDetails(this.issue.getTrustedWebActivityIssues())}}