// Tracker interface + factory.
//
// A Tracker encapsulates everything that varies between input modalities
// (head, eye, etc.). Everything *after* pose detection — velocity smoothing,
// cursor integration, CURSOR_UPDATE dispatch — lives in pipeline.js and is
// shared across all trackers.
//
// Contract:
//   const tracker = await createTracker(source, { video });
//   tracker.onPose(({ yaw, pitch }) => { ... });   // subscribe
//   await tracker.init();                           // load model
//   tracker.start();                                // begin emitting
//   tracker.stop();                                 // halt emission
//
// Pose units: { yaw, pitch } as normalized horizontal/vertical offsets
// relative to inter-eye distance (matches the original head-tracking math
// from offscreen.js). A real eye tracker should convert its native gaze
// output into the same units before emitting.

import { createHeadTracker } from "./head-tracker.js";
import { createEyeTracker } from "./eye-tracker.js";

export async function createTracker(source, ctx) {
  switch (source) {
    case "eye":
      return createEyeTracker(ctx);
    case "head":
    default:
      return createHeadTracker(ctx);
  }
}
