import {
colors,
htmlEscape
} from "./chunk-4L7RY2JA.js";
import {
publicDirURL
} from "./chunk-OSUFJZHZ.js";
import {
BaseComponent
} from "./chunk-4YEN7HVQ.js";
// src/templates/error_stack/main.ts
import { dump, themes } from "@poppinss/dumper/html";
import { dump as dumpCli } from "@poppinss/dumper/console";
var CHEVIRON = ``;
var EDITORS = {
textmate: "txmt://open?url=file://%f&line=%l",
macvim: "mvim://open?url=file://%f&line=%l",
emacs: "emacs://open?url=file://%f&line=%l",
sublime: "subl://open?url=file://%f&line=%l",
phpstorm: "phpstorm://open?file=%f&line=%l",
atom: "atom://core/open/file?filename=%f&line=%l",
vscode: "vscode://file/%f:%l"
};
var ErrorStack = class extends BaseComponent {
cssFile = new URL("./error_stack/style.css", publicDirURL);
scriptFile = new URL("./error_stack/script.js", publicDirURL);
/**
* Returns the file's relative name from the CWD
*/
#getRelativeFileName(filePath) {
return filePath.replace(`${process.cwd()}/`, "");
}
/**
* Returns the index of the frame that should be expanded by
* default
*/
#getFirstExpandedFrameIndex(frames) {
let expandAtIndex = frames.findIndex((frame) => frame.type === "app");
if (expandAtIndex === -1) {
expandAtIndex = frames.findIndex((frame) => frame.type === "module");
}
return expandAtIndex;
}
/**
* Returns the link to open the file within known code
* editors
*/
#getEditorLink(ide, frame) {
const editorURL = EDITORS[ide] || ide;
if (!editorURL || frame.type === "native") {
return {
text: this.#getRelativeFileName(frame.fileName)
};
}
return {
href: editorURL.replace("%f", frame.fileName).replace("%l", String(frame.lineNumber)),
text: this.#getRelativeFileName(frame.fileName)
};
}
/**
* Returns the HTML fragment for the frame location
*/
#renderFrameLocation(frame, ide) {
const { text, href } = this.#getEditorLink(ide, frame);
const fileName = `
${htmlEscape(text)}
`;
const functionName = frame.functionName ? `in
${htmlEscape(frame.functionName)}
` : "";
const loc = `at line ${frame.lineNumber}:${frame.columnNumber}`;
if (frame.type !== "native" && frame.source) {
return ``;
}
return `