// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: Unused imports
import { Create as $Create } from "@wailsio/runtime";

/**
 * APIEndpoint declares an API endpoint the module provides.
 */
export class APIEndpoint {
    /**
     * GET, POST, etc.
     */
    "method": string;

    /**
     * Relative to /api/{namespace}/{code}
     */
    "path": string;
    "description"?: string;

    /** Creates a new APIEndpoint instance. */
    constructor($$source: Partial<APIEndpoint> = {}) {
        if (!("method" in $$source)) {
            this["method"] = "";
        }
        if (!("path" in $$source)) {
            this["path"] = "";
        }

        Object.assign(this, $$source);
    }

    /**
     * Creates a new APIEndpoint instance from a string or object.
     */
    static createFrom($$source: any = {}): APIEndpoint {
        let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
        return new APIEndpoint($$parsedSource as Partial<APIEndpoint>);
    }
}

/**
 * AppConfig defines web app specific configuration.
 */
export class AppConfig {
    "url"?: string;

    /**
     * spa, iframe, etc.
     */
    "type"?: string;
    "hooks"?: AppHook[];

    /** Creates a new AppConfig instance. */
    constructor($$source: Partial<AppConfig> = {}) {

        Object.assign(this, $$source);
    }

    /**
     * Creates a new AppConfig instance from a string or object.
     */
    static createFrom($$source: any = {}): AppConfig {
        const $$createField2_0 = $$createType1;
        let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
        if ("hooks" in $$parsedSource) {
            $$parsedSource["hooks"] = $$createField2_0($$parsedSource["hooks"]);
        }
        return new AppConfig($$parsedSource as Partial<AppConfig>);
    }
}

/**
 * AppHook defines app lifecycle hooks.
 */
export class AppHook {
    /**
     * rename, copy, etc.
     */
    "type": string;
    "from"?: string;
    "to"?: string;
    "data"?: { [_: string]: any };

    /** Creates a new AppHook instance. */
    constructor($$source: Partial<AppHook> = {}) {
        if (!("type" in $$source)) {
            this["type"] = "";
        }

        Object.assign(this, $$source);
    }

    /**
     * Creates a new AppHook instance from a string or object.
     */
    static createFrom($$source: any = {}): AppHook {
        const $$createField3_0 = $$createType2;
        let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
        if ("data" in $$parsedSource) {
            $$parsedSource["data"] = $$createField3_0($$parsedSource["data"]);
        }
        return new AppHook($$parsedSource as Partial<AppHook>);
    }
}

/**
 * BinaryInfo contains download info for a binary.
 */
export class BinaryInfo {
    "url": string;
    "checksum"?: string;

    /** Creates a new BinaryInfo instance. */
    constructor($$source: Partial<BinaryInfo> = {}) {
        if (!("url" in $$source)) {
            this["url"] = "";
        }

        Object.assign(this, $$source);
    }

    /**
     * Creates a new BinaryInfo instance from a string or object.
     */
    static createFrom($$source: any = {}): BinaryInfo {
        let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
        return new BinaryInfo($$parsedSource as Partial<BinaryInfo>);
    }
}

/**
 * Config is the .itw3.json format for module registration.
 * This is the boundary format between Core and external modules.
 */
export class Config {
    /**
     * Unique identifier
     */
    "code": string;

    /**
     * core, app, bin
     */
    "type": ModuleType;

    /**
     * Display name
     */
    "name": string;

    /**
     * Semantic version
     */
    "version": string;

    /**
     * API/config namespace
     */
    "namespace": string;

    /**
     * Human description
     */
    "description"?: string;
    "author"?: string;

    /**
     * UI menu contributions
     */
    "menu"?: MenuItem[];

    /**
     * UI route contributions
     */
    "routes"?: Route[];

    /**
     * Which contexts this module supports
     */
    "contexts"?: Context[];

    /**
     * Platform binaries
     */
    "downloads"?: Downloads | null;

    /**
     * Web app config
     */
    "app"?: AppConfig | null;

    /**
     * Module dependencies
     */
    "depends"?: string[];

    /**
     * API endpoint declarations
     */
    "api"?: APIEndpoint[];

    /**
     * Default configuration
     */
    "config"?: { [_: string]: any };

    /** Creates a new Config instance. */
    constructor($$source: Partial<Config> = {}) {
        if (!("code" in $$source)) {
            this["code"] = "";
        }
        if (!("type" in $$source)) {
            this["type"] = ModuleType.$zero;
        }
        if (!("name" in $$source)) {
            this["name"] = "";
        }
        if (!("version" in $$source)) {
            this["version"] = "";
        }
        if (!("namespace" in $$source)) {
            this["namespace"] = "";
        }

        Object.assign(this, $$source);
    }

    /**
     * Creates a new Config instance from a string or object.
     */
    static createFrom($$source: any = {}): Config {
        const $$createField7_0 = $$createType4;
        const $$createField8_0 = $$createType6;
        const $$createField9_0 = $$createType7;
        const $$createField10_0 = $$createType9;
        const $$createField11_0 = $$createType11;
        const $$createField12_0 = $$createType12;
        const $$createField13_0 = $$createType14;
        const $$createField14_0 = $$createType2;
        let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
        if ("menu" in $$parsedSource) {
            $$parsedSource["menu"] = $$createField7_0($$parsedSource["menu"]);
        }
        if ("routes" in $$parsedSource) {
            $$parsedSource["routes"] = $$createField8_0($$parsedSource["routes"]);
        }
        if ("contexts" in $$parsedSource) {
            $$parsedSource["contexts"] = $$createField9_0($$parsedSource["contexts"]);
        }
        if ("downloads" in $$parsedSource) {
            $$parsedSource["downloads"] = $$createField10_0($$parsedSource["downloads"]);
        }
        if ("app" in $$parsedSource) {
            $$parsedSource["app"] = $$createField11_0($$parsedSource["app"]);
        }
        if ("depends" in $$parsedSource) {
            $$parsedSource["depends"] = $$createField12_0($$parsedSource["depends"]);
        }
        if ("api" in $$parsedSource) {
            $$parsedSource["api"] = $$createField13_0($$parsedSource["api"]);
        }
        if ("config" in $$parsedSource) {
            $$parsedSource["config"] = $$createField14_0($$parsedSource["config"]);
        }
        return new Config($$parsedSource as Partial<Config>);
    }
}

/**
 * Context represents the UI context (developer, retail, miner, etc.)
 */
export enum Context {
    /**
     * The Go zero value for the underlying type of the enum.
     */
    $zero = "",

    ContextDefault = "default",
    ContextDeveloper = "developer",
    ContextRetail = "retail",
    ContextMiner = "miner",
};

/**
 * Downloads defines platform-specific binary downloads.
 */
export class Downloads {
    /**
     * Web app archive
     */
    "app"?: string;
    "x86_64"?: PlatformBinaries | null;
    "aarch64"?: PlatformBinaries | null;

    /** Creates a new Downloads instance. */
    constructor($$source: Partial<Downloads> = {}) {

        Object.assign(this, $$source);
    }

    /**
     * Creates a new Downloads instance from a string or object.
     */
    static createFrom($$source: any = {}): Downloads {
        const $$createField1_0 = $$createType16;
        const $$createField2_0 = $$createType16;
        let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
        if ("x86_64" in $$parsedSource) {
            $$parsedSource["x86_64"] = $$createField1_0($$parsedSource["x86_64"]);
        }
        if ("aarch64" in $$parsedSource) {
            $$parsedSource["aarch64"] = $$createField2_0($$parsedSource["aarch64"]);
        }
        return new Downloads($$parsedSource as Partial<Downloads>);
    }
}

/**
 * MenuItem represents a menu item contribution.
 */
export class MenuItem {
    "id": string;
    "label": string;
    "icon"?: string;

    /**
     * Event name to emit
     */
    "action"?: string;

    /**
     * Frontend route
     */
    "route"?: string;

    /**
     * Keyboard shortcut
     */
    "accelerator"?: string;

    /**
     * Show in these contexts
     */
    "contexts"?: Context[];

    /**
     * Submenu items
     */
    "children"?: MenuItem[];

    /**
     * Sort order
     */
    "order"?: number;
    "separator"?: boolean;

    /** Creates a new MenuItem instance. */
    constructor($$source: Partial<MenuItem> = {}) {
        if (!("id" in $$source)) {
            this["id"] = "";
        }
        if (!("label" in $$source)) {
            this["label"] = "";
        }

        Object.assign(this, $$source);
    }

    /**
     * Creates a new MenuItem instance from a string or object.
     */
    static createFrom($$source: any = {}): MenuItem {
        const $$createField6_0 = $$createType7;
        const $$createField7_0 = $$createType4;
        let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
        if ("contexts" in $$parsedSource) {
            $$parsedSource["contexts"] = $$createField6_0($$parsedSource["contexts"]);
        }
        if ("children" in $$parsedSource) {
            $$parsedSource["children"] = $$createField7_0($$parsedSource["children"]);
        }
        return new MenuItem($$parsedSource as Partial<MenuItem>);
    }
}

/**
 * ModuleType defines the type of module.
 */
export enum ModuleType {
    /**
     * The Go zero value for the underlying type of the enum.
     */
    $zero = "",

    /**
     * Built-in core module
     */
    TypeCore = "core",

    /**
     * External application
     */
    TypeApp = "app",

    /**
     * Binary/daemon wrapper
     */
    TypeBin = "bin",
};

/**
 * PlatformBinaries defines OS-specific binary URLs.
 */
export class PlatformBinaries {
    "darwin"?: BinaryInfo | null;
    "linux"?: BinaryInfo | null;
    "windows"?: BinaryInfo | null;

    /** Creates a new PlatformBinaries instance. */
    constructor($$source: Partial<PlatformBinaries> = {}) {

        Object.assign(this, $$source);
    }

    /**
     * Creates a new PlatformBinaries instance from a string or object.
     */
    static createFrom($$source: any = {}): PlatformBinaries {
        const $$createField0_0 = $$createType18;
        const $$createField1_0 = $$createType18;
        const $$createField2_0 = $$createType18;
        let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
        if ("darwin" in $$parsedSource) {
            $$parsedSource["darwin"] = $$createField0_0($$parsedSource["darwin"]);
        }
        if ("linux" in $$parsedSource) {
            $$parsedSource["linux"] = $$createField1_0($$parsedSource["linux"]);
        }
        if ("windows" in $$parsedSource) {
            $$parsedSource["windows"] = $$createField2_0($$parsedSource["windows"]);
        }
        return new PlatformBinaries($$parsedSource as Partial<PlatformBinaries>);
    }
}

/**
 * Registry manages module registration and provides unified API routing + UI assembly.
 */
export class Registry {

    /** Creates a new Registry instance. */
    constructor($$source: Partial<Registry> = {}) {

        Object.assign(this, $$source);
    }

    /**
     * Creates a new Registry instance from a string or object.
     */
    static createFrom($$source: any = {}): Registry {
        let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
        return new Registry($$parsedSource as Partial<Registry>);
    }
}

/**
 * Route represents a UI route contribution.
 */
export class Route {
    "path": string;

    /**
     * Custom element or component
     */
    "component": string;
    "title"?: string;
    "icon"?: string;
    "contexts"?: Context[];

    /** Creates a new Route instance. */
    constructor($$source: Partial<Route> = {}) {
        if (!("path" in $$source)) {
            this["path"] = "";
        }
        if (!("component" in $$source)) {
            this["component"] = "";
        }

        Object.assign(this, $$source);
    }

    /**
     * Creates a new Route instance from a string or object.
     */
    static createFrom($$source: any = {}): Route {
        const $$createField4_0 = $$createType7;
        let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
        if ("contexts" in $$parsedSource) {
            $$parsedSource["contexts"] = $$createField4_0($$parsedSource["contexts"]);
        }
        return new Route($$parsedSource as Partial<Route>);
    }
}

/**
 * UIConfig is the complete UI configuration for frontends.
 */
export class UIConfig {
    "context": Context;
    "menus": MenuItem[];
    "routes": Route[];
    "modules": Config[];

    /** Creates a new UIConfig instance. */
    constructor($$source: Partial<UIConfig> = {}) {
        if (!("context" in $$source)) {
            this["context"] = Context.$zero;
        }
        if (!("menus" in $$source)) {
            this["menus"] = [];
        }
        if (!("routes" in $$source)) {
            this["routes"] = [];
        }
        if (!("modules" in $$source)) {
            this["modules"] = [];
        }

        Object.assign(this, $$source);
    }

    /**
     * Creates a new UIConfig instance from a string or object.
     */
    static createFrom($$source: any = {}): UIConfig {
        const $$createField1_0 = $$createType4;
        const $$createField2_0 = $$createType6;
        const $$createField3_0 = $$createType20;
        let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
        if ("menus" in $$parsedSource) {
            $$parsedSource["menus"] = $$createField1_0($$parsedSource["menus"]);
        }
        if ("routes" in $$parsedSource) {
            $$parsedSource["routes"] = $$createField2_0($$parsedSource["routes"]);
        }
        if ("modules" in $$parsedSource) {
            $$parsedSource["modules"] = $$createField3_0($$parsedSource["modules"]);
        }
        return new UIConfig($$parsedSource as Partial<UIConfig>);
    }
}

// Private type creation functions
const $$createType0 = AppHook.createFrom;
const $$createType1 = $Create.Array($$createType0);
const $$createType2 = $Create.Map($Create.Any, $Create.Any);
const $$createType3 = MenuItem.createFrom;
const $$createType4 = $Create.Array($$createType3);
const $$createType5 = Route.createFrom;
const $$createType6 = $Create.Array($$createType5);
const $$createType7 = $Create.Array($Create.Any);
const $$createType8 = Downloads.createFrom;
const $$createType9 = $Create.Nullable($$createType8);
const $$createType10 = AppConfig.createFrom;
const $$createType11 = $Create.Nullable($$createType10);
const $$createType12 = $Create.Array($Create.Any);
const $$createType13 = APIEndpoint.createFrom;
const $$createType14 = $Create.Array($$createType13);
const $$createType15 = PlatformBinaries.createFrom;
const $$createType16 = $Create.Nullable($$createType15);
const $$createType17 = BinaryInfo.createFrom;
const $$createType18 = $Create.Nullable($$createType17);
const $$createType19 = Config.createFrom;
const $$createType20 = $Create.Array($$createType19);
