/**
 * IAMAR world API 0.3 for standard TypeScript worlds (profile iamar-typescript-sync-v2).
 *
 * GENERATED by tools/typescript-world/gen_bindings.mjs from api/world_api.json
 * (sha256 c052828d0285e168d84fd9062fff171a412df3a48d058f3e570a8b9826ccd9ee). Do not edit; re-run the generator.
 *
 * The build supplies this file; world sources are global scripts with no imports.
 * Every method is a thin, validated call into the matching "iamar" Wasm import:
 * numbers must be finite f32 values, handles/player ids positive i32 integers,
 * other integers i32, flags booleans, strings at most 512 UTF-8 bytes and byte
 * payloads at most 4096 bytes. A malformed argument throws (TypeError/RangeError)
 * before reaching the host; host failures come back as negative status codes.
 */
declare namespace IamarWorld {
  /** Metres, +Y up; yaw is radians about +Y and zero faces -Z. */
  type Position = readonly [x: number, y: number, z: number, yaw: number];
  type Vector3 = readonly [x: number, y: number, z: number];
  /** A raycast hit: entity handle (0 = world geometry), point and surface normal. */
  interface RaycastHit { readonly hit: EntityHandle; readonly x: number; readonly y: number; readonly z: number;
    readonly nx: number; readonly ny: number; readonly nz: number; }
  type EntityKind = "chicken" | "box" | "sphere" | "marker" | "cylinder" | "capsule" | "cone" | "plane"
    | "light" | "spot" | "particles" | "label" | `mesh:${number}` | `asset:${string}.glb`;
  type ParticlePreset = "smoke" | "fire" | "sparks" | "dust" | "magic" | "rain" | "snow" | "bubbles";
  type SoundName = "cluck" | "squawk" | "bell" | "click" | "door" | "jump" | "land" | "select" | "gear"
    | `asset:${string}.ogg`;
  /** Byte payloads: a Uint8Array, an ArrayBuffer, or a string (sent as UTF-8). */
  type Bytes = Uint8Array | ArrayBuffer | string;
  /**
   * A handle returned by this script's entity_spawn (> 0), or a negative error. Scoped to this
   * instance: Host lookup, not this numeric alias, enforces entity ownership. Do not guess IDs,
   * persist handles, or share them across script instances/world runs.
   */
  type EntityHandle = number;
  /** A player id (> 0), local to this copy of the script; the local player is 1. */
  type PlayerId = number;
  /** 0 succeeds; -1 bad handle, -2 bad argument, -3 limit, -4 not found. */
  type Status = number;

  interface Api {
    // ---- core ----
    /**
     * (major << 16) | minor of the browser's API: 3 for 0.3. (since 0.1)
     */
    api_version(): number;
    /**
     * A line in the world's log (the author's console). <= 512 bytes, 50/s. (since 0.1)
     */
    log(text: string): void;
    // ---- ui ----
    /**
     * A short note on the player's screen, marked as the world's. <= 512 bytes, 4/s.
     * (since 0.1)
     */
    ui_note(text: string): void;
    // ---- core ----
    /**
     * Uniform in [0, 1). Seeded per world, so every visitor's copy draws the same
     * sequence. (since 0.1)
     */
    rand(): number;
    /**
     * Seconds since the script started (game time; pauses with the game). (since 0.1)
     */
    time(): number;
    // ---- entity ----
    /**
     * A new entity; returns its handle (> 0). Kinds: chicken, box, sphere, marker,
     * cylinder, capsule, cone, plane, light, spot, particles, label, mesh:<id> (from
     * mesh_create), or asset:<path>.glb from the world's own package. <= 256 entities
     * (manifest budget up to 1024). (since 0.1)
     */
    entity_spawn(kind: EntityKind, x: number, y: number, z: number, yaw: number): EntityHandle;
    /**
     * Remove one of this script's entities. (since 0.1)
     */
    entity_remove(h: EntityHandle): Status;
    /**
     * Jump there; stops any move_to. (since 0.1)
     */
    entity_set_pos(h: EntityHandle, x: number, y: number, z: number, yaw: number): Status;
    /**
     * Walk there in a straight line at speed m/s (<= 50), turning to face the way it
     * goes. (since 0.1)
     */
    entity_move_to(h: EntityHandle, x: number, y: number, z: number, speed: number): Status;
    /**
     * Writes x, y, z, yaw. Returns a copied tuple, or null when the call fails. (since
     * 0.1)
     */
    entity_pos(h: EntityHandle): Position | null;
    /**
     * chicken: idle, walk, run, peck, flap; glTF assets: any animation in the file.
     * (since 0.1)
     */
    entity_play_anim(h: EntityHandle, name: string): Status;
    /**
     * Wash the entity in a colour (0-1); a = 0 removes it. (since 0.1)
     */
    entity_set_tint(h: EntityHandle, r: number, g: number, b: number, a: number): Status;
    /**
     * A grounded entity stays on the terrain while it moves. (since 0.1)
     */
    entity_set_grounded(h: EntityHandle, on: boolean): Status;
    /**
     * Each axis clamped to 0.01-100. (since 0.2)
     */
    entity_set_scale(h: EntityHandle, sx: number, sy: number, sz: number): Status;
    /**
     * Show or hide. (since 0.2)
     */
    entity_set_visible(h: EntityHandle, on: boolean): Status;
    /**
     * Radians; pitch about +X, yaw about +Y, roll about +Z. (since 0.2)
     */
    entity_set_rot(h: EntityHandle, pitch: number, yaw: number, roll: number): Status;
    /**
     * Stop the current animation. (since 0.2)
     */
    entity_stop_anim(h: EntityHandle): Status;
    // ---- render ----
    /**
     * Base colour of a primitive or label, or the colour of a light / particles. a < 1
     * makes primitives see-through. Components clamped to 0-1. (since 0.3)
     */
    entity_set_color(h: EntityHandle, r: number, g: number, b: number, a: number): Status;
    /**
     * Surface of a primitive or mesh entity: metallic 0-1, roughness 0-1, emission
     * energy 0-16 (glows in its own colour), unshaded >= 0.5 ignores lighting. (since
     * 0.3)
     */
    entity_set_material(h: EntityHandle, metallic: number, roughness: number, emission: number, unshaded: number): Status;
    /**
     * For light and spot entities: energy 0-16, range 0.1-60 m, spot cone angle 1-89
     * degrees (ignored for light). Colour comes from entity_set_color. <= 16 lights per
     * world; no shadows. (since 0.3)
     */
    entity_set_light(h: EntityHandle, energy: number, range: number, angle: number): Status;
    /**
     * For particles entities: preset smoke, fire, sparks, dust, magic, rain, snow,
     * bubbles; rate 0-200 particles/s (0 stops it). <= 8 emitters per world. (since 0.3)
     */
    entity_set_particles(h: EntityHandle, preset: ParticlePreset, rate: number): Status;
    /**
     * For label entities: text floating in the world, always facing the camera. <= 128
     * bytes; size 0.05-4 m per line. (since 0.3)
     */
    entity_set_text(h: EntityHandle, text: string, size: number): Status;
    /**
     * A custom triangle mesh; returns a mesh id (> 0) to spawn as kind mesh:<id>.
     * vertices: vertex_count x 8 f32 (x, y, z, nx, ny, nz, u, v); indices: index_count
     * u32 (triangles, so a multiple of 3). <= 4096 vertices and 12288 indices per mesh
     * (bigger models belong in a .glb asset), 64 meshes, 1,000,000 vertices and
     * 3,000,000 indices per world, 4 calls per second. vertices: 8 numbers per vertex
     * (x, y, z, nx, ny, nz, u, v); indices: vertex indices, 3 per triangle. (since 0.3)
     */
    mesh_create(vertices: Float32Array | readonly number[], indices: Uint32Array | readonly number[]): number;
    // ---- world ----
    /**
     * Terrain height at (x, z). (since 0.1)
     */
    ground_y(x: number, z: number): number;
    // ---- physics ----
    /**
     * Read-only ray query (<= 10 km): writes hit x, y, z and normal x, y, z; returns the
     * hit entity's handle, 0 for world geometry, -4 on a miss. Returns null on a miss or
     * error. (since 0.2)
     */
    raycast(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number): RaycastHit | null;
    // ---- audio ----
    /**
     * A sound at a point: cluck, squawk, bell, click, door, jump, land, select, gear, or
     * asset:<path>.ogg from the world's package (<= 2 MiB each, 32 files). 10/s. (since
     * 0.2)
     */
    sound_play(name: SoundName, x: number, y: number, z: number): Status;
    // ---- physics ----
    /**
     * Give an entity a solid shape players bump into and raycasts hit: shape 0 none, 1
     * box (sx, sy, sz = full size), 2 sphere (sx = radius), 3 capsule (sx = radius, sy =
     * height). Sizes 0.01-100. (since 0.3)
     */
    entity_set_collider(h: EntityHandle, shape: number, sx: number, sy: number, sz: number): Status;
    /**
     * mode 0 scripted (the default: only the script moves it), 1 dynamic (falls, bounces
     * and is pushed; needs a collider), 2 static. mass 0.01-10000 kg. <= 128 dynamic
     * bodies per world. (since 0.3)
     */
    entity_set_physics(h: EntityHandle, mode: number, mass: number): Status;
    /**
     * Push a dynamic entity (N*s). Its velocity afterwards is capped at 200 m/s however
     * many impulses a callback gives, and a dynamic entity never moves faster than 200
     * m/s. (since 0.3)
     */
    entity_apply_impulse(h: EntityHandle, x: number, y: number, z: number): Status;
    /**
     * Set a dynamic entity's velocity (m/s, each component clamped to +/-200). (since
     * 0.3)
     */
    entity_set_velocity(h: EntityHandle, x: number, y: number, z: number): Status;
    /**
     * Writes the entity's velocity x, y, z (0 for scripted entities that are not
     * moving). Returns a copied tuple, or null when the call fails. (since 0.3)
     */
    entity_velocity(h: EntityHandle): Vector3 | null;
    /**
     * Make the entity a trigger zone of this radius (0.1-50 m; 0 turns it off):
     * on_trigger_enter / on_trigger_exit fire as players come and go. (since 0.3)
     */
    entity_set_trigger(h: EntityHandle, radius: number): Status;
    // ---- time ----
    /**
     * Calls on_timer(tag) after ms (0-86,400,000). <= 64 pending. (since 0.2)
     */
    timer_after(ms: number, tag: number): Status;
    /**
     * Cancels every pending timer with this tag; returns how many. (since 0.2)
     */
    timer_cancel(tag: number): number;
    /**
     * Calls on_timer(tag) every ms (1-86,400,000) until cancelled. (since 0.2)
     */
    timer_repeat(ms: number, tag: number): Status;
    // ---- players ----
    /**
     * Players in the world now, including remote visitors. (since 0.2)
     */
    players_count(): number;
    /**
     * Id of the index-th player (0 <= index < count), ascending. (since 0.2)
     */
    player_id(index: number): number;
    /**
     * Writes x, y, z, yaw. Returns a copied tuple, or null when the call fails. (since
     * 0.1)
     */
    player_pos(id: PlayerId): Position | null;
    /**
     * Teleport the local player (portals, respawns, checkpoints). A remote player's own
     * copy of the script moves them; here it returns -1. (since 0.2)
     */
    player_set_pos(id: PlayerId, x: number, y: number, z: number, yaw: number): Status;
    /**
     * 1 for the player at this keyboard, 0 for a remote visitor, -1 for an unknown id.
     * (since 0.3)
     */
    player_is_local(id: PlayerId): number;
    /**
     * Copies up to cap bytes of the player's display name (UTF-8); returns its full
     * length. Returns the whole text, or null when the call fails. (since 0.3)
     */
    player_name(id: PlayerId): string | null;
    /**
     * A stable key for the player that is the same in every visitor's copy of the script
     * (player ids are local to each copy). ASCII, <= 64 bytes; returns its full length.
     * Returns the whole text, or null when the call fails. (since 0.3)
     */
    player_key(id: PlayerId): string | null;
    // ---- storage ----
    /**
     * Copies up to cap bytes of the value; returns its full length, or -4. Returns the
     * whole value, or null when the call fails. (since 0.1)
     */
    kv_get(key: string): Uint8Array | null;
    /**
     * A value of 0 bytes deletes the key. Keys <= 128 bytes, values <= 4 KiB, 64 KiB per
     * world. Stored on this visitor's machine. (since 0.1)
     */
    kv_set(key: string, value: Bytes): Status;
    // ---- network ----
    /**
     * Send bytes (<= 1 KiB, 20/s) to every other visitor's copy of this script; they
     * arrive in on_message_from (or on_message). Peer-to-peer over the room's encrypted
     * links. (since 0.1)
     */
    world_message(data: Bytes): Status;
    /**
     * Send bytes to one remote player's copy of this script (same limits as
     * world_message, sharing its rate). (since 0.3)
     */
    message_to(id: PlayerId, data: Bytes): Status;
    /**
     * 1 if this copy is the world's authority, else 0: the copy whose visitor has the
     * smallest player key among everyone in the room, so normally exactly one copy is.
     * Use it to coordinate (who spawns, who keeps score), never as security: a hostile
     * visitor can arrange to be the authority, so check what other copies send you.
     * (since 0.3)
     */
    is_authority(): number;
    // ---- camera ----
    /**
     * mode 0 gives the camera back to the player; mode 1 looks from (x, y, z) at (tx,
     * ty, tz) (cutscenes, puzzles). Esc, the browser's menus and leaving the world
     * always give it back, and after Esc the script cannot take it again for 10 seconds
     * (-3). (since 0.3)
     */
    camera_set(mode: number, x: number, y: number, z: number, tx: number, ty: number, tz: number): Status;
    // ---- input ----
    /**
     * Ask for on_input events for a key: Godot key codes for A-Z (65-90), 0-9 (48-57),
     * Space (32) and the arrows (4194319-4194322). Esc, Enter, Tab and the F keys are
     * the browser's and are refused. The key keeps its normal game meaning too. <= 32
     * keys. (since 0.3)
     */
    input_bind(key: number, on: boolean): Status;
    // ---- ui ----
    /**
     * Create or update text on the world's screen layer at (x, y) in 0-1 of the window,
     * size 8-64 px. <= 256 bytes. The layer sits under the browser's own UI and is
     * framed as the world's. (since 0.3)
     */
    ui_text(id: number, text: string, x: number, y: number, size: number): Status;
    /**
     * Create or update a clickable button (position and size in 0-1 of the window); a
     * click calls on_ui(id). (since 0.3)
     */
    ui_button(id: number, text: string, x: number, y: number, w: number, h: number): Status;
    /**
     * Create or update a progress bar filled to value (0-1); its colour follows
     * entity-style ui_color. (since 0.3)
     */
    ui_bar(id: number, value: number, x: number, y: number, w: number): Status;
    /**
     * Colour of a UI element's text or fill (0-1). (since 0.3)
     */
    ui_color(id: number, r: number, g: number, b: number, a: number): Status;
    /**
     * Remove a UI element. Ids are the script's own (1-2,147,483,647); <= 32 elements.
     * (since 0.3)
     */
    ui_remove(id: number): Status;
  }

  /**
   * Callbacks: define any of these as top-level global functions in world.ts
   * (on_init is required). No registration; the build checks each declaration.
   * All run synchronously and must return void, never a Promise.
   */
  interface Callbacks {
    /** Once, after instantiation. */
    on_init(): void;
    /** About 10 times a second (tick_hz); dt is seconds since the last tick (<= 0.5). */
    on_tick?(dt: number): void;
    /** A player arrives (after on_init for everyone already there). The local player is id 1. */
    on_enter?(player: PlayerId): void;
    /** A player leaves. */
    on_leave?(player: PlayerId): void;
    /** A player uses an entity (the interact key within 2.5 m). */
    on_interact?(player: PlayerId, entity: EntityHandle): void;
    /** A timer_after / timer_repeat fired. */
    on_timer?(tag: number): void;
    /** Bytes from another copy of the script (used when on_message_from is not exported). */
    on_message?(data: Uint8Array): void;
    /** Bytes from the copy of the script running for this player. */
    on_message_from?(player: PlayerId, data: Uint8Array): void;
    /** A player walked into a trigger zone. */
    on_trigger_enter?(player: PlayerId, entity: EntityHandle): void;
    /** A player left a trigger zone. */
    on_trigger_exit?(player: PlayerId, entity: EntityHandle): void;
    /** Two of the script's dynamic entities, or a dynamic entity and the world (b = 0), started touching. */
    on_contact?(a: EntityHandle, b: EntityHandle): void;
    /** The local player clicked an entity with the mouse (needs a collider). */
    on_click?(player: PlayerId, entity: EntityHandle): void;
    /** A key asked for with input_bind went down (1) or up (0). */
    on_input?(key: number, pressed: boolean): void;
    /** A ui_button was clicked. */
    on_ui?(id: number): void;
  }
}

/** Frozen guest-local capability object backed only by the "iamar" Wasm imports. */
declare const iamar: Readonly<IamarWorld.Api>;
