"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCliAssetPath = getCliAssetPath;
exports.findPackageRoot = findPackageRoot;
const fs_1 = require("fs");
const path_1 = require("path");
/**
 * Returns the absolute path to a CLI-bundled asset file.
 * @param relativePath - Path relative to the assets folder (e.g., "mac-build/entitlements.mac.plist")
 */
function getCliAssetPath(relativePath) {
    return (0, path_1.join)(findPackageRoot(), "assets", relativePath);
}
function findPackageRoot() {
    let dir = __dirname;
    let found = false;
    while (!found) {
        if ((0, fs_1.existsSync)((0, path_1.join)(dir, "package.json"))) {
            found = true;
        }
        else {
            const parent = (0, path_1.dirname)(dir);
            if (parent === dir) {
                throw new Error("package.json not found");
            }
            dir = parent;
        }
    }
    return dir;
}
//# sourceMappingURL=find.package.dir.js.map