import { Address, Hex } from "viem";

//#region src/consts.d.ts

/**
 * The longest an entity may live, in blocks, counted from the block its create or extension lands
 * in: 7,884,000 blocks, about 182.5 days at {@link BLOCK_TIME}. The chain reverts anything longer
 * with `ExpiryBeyondMaxLifetime`, so the SDK refuses it before sending.
 */
declare const MAX_LIFETIME = 7884000n;
//#endregion
//#region src/entity/errors.d.ts
/** An expiry could not be expressed, or would be rejected by the engine. */
declare class InvalidExpiryError extends Error {
  constructor(reason: string);
}
/** A `creationFlags` byte could not be built or read. */
declare class InvalidCreationFlagsError extends Error {
  constructor(reason: string);
}
/** A key salt was outside the `uint128` the wire carries. */
declare class InvalidSaltError extends Error {
  constructor(salt: unknown);
}
/** No cryptographic randomness was available to generate a salt. */
declare class NoRandomSourceError extends Error {
  constructor();
}
//#endregion
//#region src/entity/events.d.ts
/**
 * The events the engine emits: one per applied operation, in application order, so an off-chain
 * replica can replay a transaction operation by operation.
 */
declare const ENTITY_EVENTS_ABI: readonly [{
  readonly name: "EntityCreated";
  readonly type: "event";
  readonly inputs: readonly [{
    readonly type: "bytes32";
    readonly name: "entityKey";
    readonly indexed: true;
  }, {
    readonly type: "address";
    readonly name: "owner";
    readonly indexed: true;
  }, {
    readonly type: "uint64";
    readonly name: "expiresAt";
  }, {
    readonly type: "uint8";
    readonly name: "creationFlags";
  }];
}, {
  readonly name: "EntityPatched";
  readonly type: "event";
  readonly inputs: readonly [{
    readonly type: "bytes32";
    readonly name: "entityKey";
    readonly indexed: true;
  }, {
    readonly type: "address";
    readonly name: "owner";
    readonly indexed: true;
  }];
}, {
  readonly name: "ExpiryExtended";
  readonly type: "event";
  readonly inputs: readonly [{
    readonly type: "bytes32";
    readonly name: "entityKey";
    readonly indexed: true;
  }, {
    readonly type: "address";
    readonly name: "owner";
    readonly indexed: true;
  }, {
    readonly type: "uint64";
    readonly name: "expiresAt";
  }];
}, {
  readonly name: "OwnershipTransferred";
  readonly type: "event";
  readonly inputs: readonly [{
    readonly type: "bytes32";
    readonly name: "entityKey";
    readonly indexed: true;
  }, {
    readonly type: "address";
    readonly name: "previousOwner";
    readonly indexed: true;
  }, {
    readonly type: "address";
    readonly name: "newOwner";
    readonly indexed: true;
  }];
}, {
  readonly name: "EntityDeleted";
  readonly type: "event";
  readonly inputs: readonly [{
    readonly type: "bytes32";
    readonly name: "entityKey";
    readonly indexed: true;
  }, {
    readonly type: "address";
    readonly name: "owner";
    readonly indexed: true;
  }];
}];
/** The name of each event in {@link ENTITY_EVENTS_ABI}. */
type EntityEventName = (typeof ENTITY_EVENTS_ABI)[number]["name"];
//#endregion
//#region src/entity/flags.d.ts
/**
 * The immutable properties an entity is created with. Both default to `false`.
 *
 * Creation flags are fixed at creation: there is no operation that changes them, so an entity is
 * whatever it was created as for its whole life.
 */
type CreationFlags = {
  /**
   * The entity's attributes can never be changed — only its expiry extended, its
   * ownership transferred, and the entity deleted.
   */
  readonly?: boolean;
  /**
   * Anyone, not just the owner, may extend the entity's expiry. Lets a third party keep something
   * alive without being able to change it.
   */
  permissionlessExtension?: boolean;
};
/** {@link CreationFlags} as read back, with every flag resolved and the raw byte alongside. */
type ResolvedCreationFlags = {
  readonly: boolean;
  permissionlessExtension: boolean;
  raw: number;
};
//#endregion
//#region src/entity/key.d.ts
/** The widest salt the `uint128` wire field carries. */
declare const MAX_SALT: bigint;
/**
 * Opts a create out of salting, as {@link CreateEntityOptions.salt}: the key is then derived
 * from the owner and its nonce alone, so anyone who knows both can work it out before the create
 * lands.
 */
declare const NO_SALT: unique symbol;
/**
 * A salt as a caller expresses it: an explicit `uint128`, or {@link NO_SALT} to opt out of salting.
 */
type SaltInput = bigint | typeof NO_SALT;
/**
 * A cryptographically random 128-bit salt — what {@link CreateEntityOptions.salt} defaults to.
 *
 * The salt exists for unpredictability, not uniqueness: the per-owner nonce already guarantees
 * distinct keys. Random bits mean only the creator can predict the key of an entity they are about
 * to create, so nobody else can reference or squat it in advance.
 *
 * @throws {NoRandomSourceError} If the runtime has no `crypto.getRandomValues`.
 */
declare function randomSalt(): bigint;
/**
 * The key an entity will be created with, derived exactly as the engine derives it:
 * `keccak256(domain ++ owner ++ nonce ++ salt)`.
 *
 * Deriving it client-side is what lets a batch compose: predict the key of a create, then have a
 * later operation in the same transaction reference it, or store it as a `key` attribute on a
 * sibling entity.
 */
declare function predictEntityKey({
  owner,
  nonce,
  salt,
  chainId
}: {
  /** The account creating the entity. */
  owner: Address;
  /**
   * The owner's entity-nonce at creation time. Each create in a batch consumes one, so the *n*th
   * create in a batch uses `nonce + n`.
   */
  nonce: bigint;
  /** The salt the create will carry, or {@link NO_SALT} if it carries none. */
  salt: SaltInput;
  /** The chain the entity is being created on — half of the derivation domain. */
  chainId: number;
}): Hex;
//#endregion
//#region src/entity/params.d.ts
/**
 * Max uint64 value
 */
declare const MAX_EXPIRES_AT: bigint;
//#endregion
export { predictEntityKey as a, ResolvedCreationFlags as c, InvalidCreationFlagsError as d, InvalidExpiryError as f, MAX_LIFETIME as h, SaltInput as i, ENTITY_EVENTS_ABI as l, NoRandomSourceError as m, MAX_SALT as n, randomSalt as o, InvalidSaltError as p, NO_SALT as r, CreationFlags as s, MAX_EXPIRES_AT as t, EntityEventName as u };
//# sourceMappingURL=index-CL3rAR9T.d.ts.map