import { n as BaseComponent, t as publicDirURL } from "../../../public_dir-C5bujZKB.js"; import { n as htmlEscape } from "../../../helpers-B9BQYaS6.js"; import { dump, themes } from "@poppinss/dumper/html"; var ErrorMetadata = class extends BaseComponent { cssFile = new URL("./error_metadata/style.css", publicDirURL); #primitives = [ "string", "boolean", "number", "undefined" ]; #formatRowValue(value, dumpValue, cspNonce) { if (dumpValue === true) return dump(value, { styles: themes.cssVariables, cspNonce }); if (this.#primitives.includes(typeof value) || value === null) return typeof value === "string" ? htmlEscape(value) : value; return dump(value, { styles: themes.cssVariables, cspNonce }); } #renderRows(rows, cspNonce) { return ` ${rows.map((row) => { return ``; }).join("\n")}
${row.key} ${this.#formatRowValue(row.value, row.dump, cspNonce)}
`; } #renderSection(section, rows, cspNonce) { return `

${section}

${Array.isArray(rows) ? this.#renderRows(rows, cspNonce) : `${this.#formatRowValue(rows.value, rows.dump, cspNonce)}`}
`; } #renderGroup(group, sections, cspNonce) { return `

${group}

${Object.keys(sections).map((section) => this.#renderSection(section, sections[section], cspNonce)).join("\n")}
`; } async toHTML(props) { const groups = props.metadata.toJSON(); const groupsNames = Object.keys(groups); if (!groupsNames.length) return ""; return groupsNames.map((group) => this.#renderGroup(group, groups[group], props.cspNonce)).join("\n"); } async toANSI() { return ""; } }; export { ErrorMetadata };