import { clone, hash } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
import { GIB } from "@ibgib/ts-gib/dist/V1/constants.mjs";
import { getGib } from "@ibgib/ts-gib/dist/V1/transforms/transform-helper.mjs";
import { ANONYMOUS_FN_ATOM, DEFAULT_ANONYMOUS_FN_DATA_V1 } from "./anonymous-fn-constants.mjs";
import { getAnonymousFnIb } from "./anonymous-fn-helper.mjs";
/**
 * Helper class that wraps a witness function.
 *
 * @see {@link AnonymousFnWitnessData_V1}
 * @see {@link AnonymousFnWitnessRel8ns_V1}
 * @see {@link WitnessFn}
 */
export class AnonymousFnWitness_V1 {
    fn;
    ib = ANONYMOUS_FN_ATOM.concat();
    gib = GIB;
    data = clone(DEFAULT_ANONYMOUS_FN_DATA_V1);
    rel8ns;
    constructor(fn) {
        this.fn = fn;
        if (!fn) {
            throw new Error(`fn required (E: b1e1478f466a2a347b75e7c336f8d323)`);
        }
    }
    async witness(arg) {
        this.data.fnHash = await hash({ s: this.fn.toString() });
        this.ib = getAnonymousFnIb({ data: this.data });
        this.gib = await getGib({ ibGib: this });
        return this.fn(arg);
    }
}
//# sourceMappingURL=anonymous-fn-v1.mjs.map