// Generated by bynkc — do not edit by hand.
// context fx.clockwork

import { Ok, Err, Some, None, type Result, type Option, type ValidationError } from "../runtime.js";

export async function run(f: (a0: number) => Promise<number>, x: number): Promise<number> {
  const y = await f(x);
  return y;
}

export interface Clock {
  now(): Promise<number>;
}

export const ClockToken: unique symbol = Symbol("Clock");

export class FixedClock implements Clock {
  async now(): Promise<number> {
    return 42;
  }
}

export const FixedClockProvider = { token: ClockToken, factory: () => new FixedClock() };

export const stamper = {
  async call(offset: number, deps: { Clock: Clock }): Promise<number> {
    const stamped = await run(async (n) => {
    const t = await deps.Clock.now();
    return t + n;
  }, offset);
    return stamped;
  },
};

export interface FxClockworkDeps {
  readonly Clock: Clock;
}

export function makeSurface(deps: FxClockworkDeps) {
  return {
    async stamper(offset: number): Promise<number> {
      return stamper.call(offset, deps);
    },
  };
}

