// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
// SPDX-License-Identifier: MPL-2.0
import { core } from "./wit.js";
export class PolicyPerEffectObject {
    constructor(value) {
        this.value = value;
    }
}
export default class Policy {
    constructor(_id, name) {
        this._id = _id;
        this.name = name;
    }
    static public() {
        const [id, name] = core.getPublicPolicy();
        return new Policy(id, name);
    }
    static context(key, check) {
        const [id, name] = core.registerContextPolicy(key, typeof check === "string"
            ? { tag: "value", val: check }
            : { tag: "pattern", val: check.source });
        return new Policy(id, name);
    }
    static internal() {
        const [id, name] = core.getInternalPolicy();
        return new Policy(id, name);
    }
    static create(name, materializerId) {
        return new Policy(core.registerPolicy({ name, materializer: materializerId }), name);
    }
    static on(effects) {
        return new PolicyPerEffectObject(effects);
    }
}
