// SPDX-License-Identifier: Apache-2.0
import { AccountId } from "@hiero-ledger/sdk";
import { InvalidIdFormat } from "./error/InvalidIdFormat";
export const HEDERA_FORMAT_ID_REGEX = /^(0|(?:[1-9]\d*))\.(0|(?:[1-9]\d*))\.(0|(?:[1-9]\d*))(?:-([a-z]{5}))?$/;
export class HederaId {
    static NULL = new HederaId("0.0.0");
    value;
    constructor(value) {
        if (!HEDERA_FORMAT_ID_REGEX.exec(value)) {
            throw new InvalidIdFormat(value);
        }
        this.value = value;
    }
    static from(value) {
        return new HederaId(value ?? "");
    }
    toHederaAddress() {
        return AccountId.fromString(this.value);
    }
    toString() {
        return this.value;
    }
    isNull() {
        return this.value == "0.0.0";
    }
}
