// THE aggregation point. Every public global the SDK provides is re-exported here under the exact
// name user code uses it as. The bundler passes this file to esbuild's `inject:` option, so user
// code references `Scene`, `Sprite`, `toast`, … with no imports; esbuild tree-shakes away whatever
// a given project does not use (so a pure-2D project drops all 3D classes, and vice versa).
//
// Rule: this is the ONLY file that `export`s public names. Everything else is internal and imported
// by it. Host-provided globals (setLoop, console, setTimeout, DEG2RAD, asset, …) are NOT here —
// they live in src/host.d.ts as declarations and stay as free references at runtime.

// ---- math ----
export { Mathf } from "./math/Mathf"
export { Vec2, Vec3 } from "./math/vec"
export { Quat } from "./math/quat"
export { Mat4 } from "./math/mat4"
export { Color } from "./core/color"

// ---- aspects (attachable node capabilities) ----
export { Aspect, System, type With, type SystemHost } from "./core/Aspect"
export { type EventMap } from "./core/events"
export { Time } from "./core/time"
export { StateMachine, defineStates, type StateDef, type StatesDef, type StateGuard, type StateHandler, type StateMachineEvents } from "./core/StateMachine"
export { InspectorUI } from "./core/InspectorUI"

// ---- reactivity (signals; UI text/style props also accept `() => value` bindings) ----
export { signal, computed, effect, type Signal, type Computed } from "./core/signals"
export { __compWrite, __compOp, type CompAxis, type CompWriter } from "./core/compWrite"

// ---- canvas (core 2D drawing that bakes to a texture; shared by 2D/3D/UI) ----
export { Canvas, Bitmap } from "./canvas/Canvas"

// ---- platform runtime (injected globals; the host provides the lower-level _creator* bridges) ----
export { toast, openURL, SvgSource } from "./runtime/misc"
export { app, type AppState, type OrientationLock } from "./runtime/app"
export { clipboard } from "./runtime/clipboard"
export { date, type DateValue, type DateInput, type Unit, type Locale } from "./runtime/datetime"
export { fetch, fetchLocal, FormData, File, type FetchResponse } from "./runtime/fetch"
export { localStorage } from "./runtime/storage"
export { device, type HapticStyle, type MotionOptions } from "./runtime/device"
export { Input, InputChannel, type InputKeyEvent, type InputGamepadEvent, type InputEventName, type GamepadState, type GamepadAxisName } from "./runtime/input"
export { WebSocket } from "./runtime/net"
// Multiplayer (docs/multiplayer-plan.md): roles, players, JSON messages over the _creatorNet transport.
export { Net, NetPlayer, Replicated, NetEntity, type NetMessage, type NetRole, type NetStatus, type NetEvents, type NetLaunch, type NetInput, type NetKind, type NetTransform } from "./net"
// App-backend transport: the compiler-generated stubs of `*.server.ts` modules call these; user code
// only ever imports its server functions (docs/backend-plan.md §4).
export { __rpc, __channel, __serverOnly, RpcError, type ClientChannel } from "./runtime/rpc"
export { AudioPlayer, VideoPlayer } from "./runtime/media"
export { openFilePicker } from "./runtime/files"
export { share } from "./runtime/share"
export { ClickEvent, TouchStartEvent, LongPressEvent } from "./runtime/touch"

// ---- 2D engine (creator-2d) ----
export { Scene2D } from "./g2/Scene2D"
export { Node2D } from "./g2/Node2D"
export { Camera2D } from "./g2/Camera2D"
export { Sprite } from "./g2/Sprite"
export { SpriteAnimation } from "./g2/SpriteAnimation"
export { Shape2D } from "./g2/Shape2D"
export { Physics2D } from "./g2/Physics2D"
export { Trigger2D } from "./g2/Trigger2D"
export { CharacterController2D } from "./g2/CharacterController2D"
export { OneWay2D } from "./g2/OneWay2D"
export { PhysicsGroup2D } from "./g2/groups2d"
export { Tilemap } from "./g2/Tilemap"
export { Texture2D } from "./g2/Texture2D"
// sprite sheets as data (.sprite.ts files — see src/g2/SpriteSheet.ts)
export { SpriteSheet, defineSpriteSheet } from "./g2/SpriteSheet"
export type { SpriteSheetDef, SheetSprite, SpriteMakeOptions } from "./g2/SpriteSheet"
// tilesets as data (.tiles.ts files — autotile materials, see src/g2/Tileset.ts + autotile.ts)
export { Tileset, defineTileset, Autotile2D } from "./g2/Tileset"
export { rawCell, isRawCell, rawIndex } from "./g2/autotile"
export { rot90, rot180, rot270, flipX, packTile, tileIndex, tileTurns, tileFlip, tileOriented } from "./g2/autotile"
export type {
  TilesetDef, TileMaterial, PatchMaterial, PathMaterial, PatchSlots, EdgeSlot, FillBlock, BlockEntry,
  TileBlock, TilePart,
} from "./g2/autotile"
// 2D scenes as data (.scene2d.ts files — see src/g2/defineScene2d.ts) + the cells('…') payload
export { defineScene2d, Scene2dHandle } from "./g2/defineScene2d"
export type { Scene2dDef, Scene2dNodeDef, Scene2dEnv, SpriteSourceDef, TilemapSourceDef, Camera2dNodeDef, LoadedScene2d } from "./g2/defineScene2d"
export { cells, encodeCells, type CellsData } from "./g2/cells"
// no-code 2D scenario aspects (attachable in scene files — see src/g2/scenarios2d.ts)
export { CameraFollow } from "./g2/scenarios2d"

// ---- UI (creator-ui) ----
export {
  UIScreen, type UIScreenStyle,
  UIRow, UIColumn, UIBox, type UIContainerStyle,
  UIText, type UITextStyle,
  UIButton, type UIButtonStyle,
  UIImage, type UIImageStyle,
  UIVideo, type UIVideoStyle,
  UIInput, UITextArea, type UIInputStyle,
  UIScrollable, type UIScrollableStyle,
  UIPager, type UIPagerStyle,
  UITabs, type UITabDef,
  defineTabs, type TabDef, type TabsHandle,
  UIWidget, type UIWidgetStyle,
  UIModal, type UIModalStyle,
  UIBottomSheet, type UIBottomSheetStyle,
  UIPopover, type UIPopoverStyle,
  UISpacer, type UISpacerStyle,
  UIVirtualizedList,
  Router,
  NativeView, type UINativeViewStyle,
  registerFont,
  __uiMap,
  __UIColumn, __UIRow, __UIBox, __UIButton, __UIScreen, __UIScrollable, __UIWidget,
} from "./ui/UI"
// The Presentable navigation contract (docs/navigation-presentable-plan.md). `Presentable` is
// interface + runtime companion (declaration merging): `Presentable.current` = what's on screen.
export { Presentable } from "./ui/UI"
export type { PresentOptions, Transition, TransitionName, TransitionSpec, TransitionTransform } from "./ui/UI"
// The base node type + the union a container accepts as children — documented as the signature of
// UIColumn/UIRow/append/etc., so they must be global (type-only; erased at runtime).
export type { UINode, UINodeChild } from "./ui/UINode"
// App theme variables (docs/ui-theme-plan.md): theme({...}) merges + returns typed var()
// accessors; system vars are static props (theme.primaryColor, theme["comfort-top"], …).
export { theme, type ThemeValues, type ThemeAccessors } from "./ui/theme"

// ---- animate ----
export { animate, animateMat4, stopAnimation, pauseAnimation, resumeAnimation } from "./animate/animate"
export { cubicBezier } from "./animate/bezier"
export { easeIn, easeOut, easeInOut } from "./animate/easings"

// ---- plugins (optional, host-provided capabilities — typed NativeView/service wrappers, see src/plugins/) ----
export { QRScanner } from "./plugins/qr"
export { CameraView, type CameraFacing } from "./plugins/camera"
export { Geolocation, type GeoPosition, type GeoOptions, type GeoWatch } from "./plugins/geolocation"
export { Push, type PushPayload, type PushStatus, type PushRegisterOptions, type PushEvent } from "./plugins/push"
export { OAuth, type OAuthCredential, type OAuthProviderName } from "./plugins/oauth"
export { Service } from "./plugins/service"

// ---- scenes as data (.scene.ts files — see src/scene/defineScene.ts) ----
export { defineScene, use, ref, make, SceneHandle, applyEditorPose as __applyEditorPose } from "./scene/defineScene"
export {
  defineMaterial, MaterialHandle,
  // editor-harness helpers (the scene editor's live material paths — not app API)
  assignMaterialDef as __assignMaterialDef, applyMaterialParam as __applyMaterialParam,
} from "./scene/material"
export type { MaterialData, MaterialParamValue, ShaderMaterialDef, LitMaterialDef, UnlitMaterialDef } from "./scene/material"
export type { SceneDef, SceneNodeDef, MeshDef, LightDef, MaterialDef, CameraNodeDef, AspectEntry, MakeEntry, LoadedScene, SceneInstance } from "./scene/defineScene"
export { CameraPlace } from "./gl/CameraPlace"
export type { FieldMeta } from "./core/fields"
// Editor-only line drawing from generator rebuild() / make() factories / tool hooks — drawn by the
// scene editor's viewport overlay, a no-op everywhere else (see src/scene/gizmos.ts).
export { Gizmos, GizmoBuffer as __GizmoBuffer, withGizmoScope as __withGizmoScope } from "./scene/gizmos"
export type { GizmoStyle, GizmoAnchor } from "./scene/gizmos"

// ---- no-code scenario aspects (attachable in the scene editor — see src/gl/scenarios.ts) ----
export { MoveTo, FollowPath, Spin, LookAt, PlayAnimation } from "./gl/scenarios"

// ---- editor plugins (called from `*.editor.ts` files — editor bundles only; DCE'd from apps) ----
export { registerEditorWindow, registerEditorTool, __editorPlugins } from "./scene/editorPlugins"
export type { EditorApi, EditorRayHit, EditorToolHooks, EditorWindowFn } from "./scene/editorPlugins"

// ---- 3D engine (creator-gl) ----
export { Scene, ARScene, VRScene } from "./gl/Scene"
export { Node } from "./gl/Node"
export { Mesh } from "./gl/Mesh"
export { Model } from "./gl/Model"
export { Shape } from "./gl/Shape"
export { Physics } from "./gl/Physics"
export { Trigger } from "./gl/Trigger"
export { CharacterController } from "./gl/CharacterController"
export { Vehicle } from "./gl/Vehicle"
export type { DriveLayout, DifferentialMode, EngineConfig, SteeringConfig, AeroConfig } from "./gl/Vehicle"
export { Wheel } from "./gl/Wheel"
export { Ragdoll } from "./gl/Ragdoll"
export type { RagdollPart, RagdollHinge } from "./gl/Ragdoll"
export type { TireCurve, WheelSuspension, WheelTire, WheelVisual } from "./gl/Wheel"
export { Gearbox } from "./gl/Gearbox"
export { AnimationClip } from "./gl/animation/AnimationClip"
export type { ClipDef, ClipTrackDef, ClipKey } from "./gl/animation/AnimationClip"
export { Animator } from "./gl/animation/Animator"
export { Playback } from "./gl/animation/Playback"
export { Loop } from "./gl/animation/Loop"
export { Layer } from "./gl/animation/Layer"
export type { PlayOptions, StopOptions, LayerOptions, LoopOptions, LoopDef, BlendPosition, ActiveClip } from "./gl/animation/core"
export { IK } from "./gl/IK"
export type { IKTwoBone, IKLookAt } from "./gl/IK"
export { Light } from "./gl/Light"
export { Lightmap } from "./gl/Lightmap"
export { Terrain } from "./gl/Terrain"
export type { TerrainOptions, TerrainLayer, TerrainRegion, ConformOptions, RibbonOptions, AutoPaintRules, SculptOptions, TerrainHit, TerrainSnapshot } from "./gl/Terrain"
export { NavMesh, NavCrowd } from "./gl/NavMesh"
export type { NavMeshLoadOptions, NavMeshInfo, NavPath, NavQueryOptions, NavRaycastHit, NavAgentSize } from "./gl/NavMesh"
export { NavAgent } from "./gl/NavAgent"
export type { NavAgentState, NavAgentAvoidance, NavAgentDrive, NavAgentEvents } from "./gl/NavAgent"
export { Material } from "./gl/Material"
export { Geometry } from "./gl/Geometry"
export { InstancedMesh } from "./gl/InstancedMesh"
export type { InstanceTransform } from "./gl/InstancedMesh"
export { Texture } from "./gl/Texture"
export { Camera } from "./gl/Camera"
export { Ray } from "./gl/Ray"
export { Plane } from "./gl/Plane"
export { Noise } from "./gl/Noise"
export { Particles, Trail, curve, colorCurve } from "./gl/Particles"
