// SwiftUI TypeScript declarations
// Re-exports IR types and adds SwiftUI base classes

import { Animation } from "./IREnums.generated";
import type { IRNodeChild } from "./IRSwiftUI";

/** Base class for SwiftUI View implemented in JavaScript */
export declare class SwiftUIView {
  /** Override this to return your view's IR representation */
  get body(): IRNodeChild;

  /** Call to trigger a re-render of the view */
  invalidate(): void;

  // Binding to a state variable
  $<T = any>(name: string): Binding<T>;
}

/** Base class for SwiftUI App implemented in JavaScript */
export declare class SwiftUIApp {
  /** Override this to return your app's root view */
  get body(): IRNodeChild;

  /** Start the application */
  static main(): void;
}

export { SwiftUIView as View, SwiftUIApp as App };

export declare class SwiftUIBinding<T> {
  constructor({ get, set }: { get: () => T; set: (newValue: T) => void });

  get: () => T;
  set: (newValue: T) => void;

  animated(animation?: Animation): this;
}

export { SwiftUIBinding as Binding };

export function withAnimation<T>(callback: () => T): T;
export function withAnimation<T>(animation: Animation, callback: () => T): T;

declare global {
  class App extends SwiftUIApp {}
  class View extends SwiftUIView {}
  const withAnimation: typeof import("./SwiftUI.d.ts").withAnimation;
  class Binding<T> extends SwiftUIBinding<T> {}

  class Console {
    log(...args: any[]): void;
    error(...args: any[]): void;
    warn(...args: any[]): void;
    info(...args: any[]): void;
  }

  const console: Console;
}
