import type { AppConfigInput, CustomAppConfig } from 'nuxt/schema'
import type { Defu } from 'defu'
import cfg0 from "../../app/app.config"

declare global {
  const defineAppConfig: <C extends AppConfigInput>(config: C) => C
}

declare const inlineConfig = {
  nuxt: {},
  ui: {
    colors: {
      primary: "green",
      secondary: "blue",
      success: "green",
      info: "blue",
      warning: "yellow",
      error: "red",
      neutral: "slate"
    },
    icons: {
      arrowDown: "i-lucide-arrow-down",
      arrowLeft: "i-lucide-arrow-left",
      arrowRight: "i-lucide-arrow-right",
      arrowUp: "i-lucide-arrow-up",
      caution: "i-lucide-circle-alert",
      check: "i-lucide-check",
      chevronDoubleLeft: "i-lucide-chevrons-left",
      chevronDoubleRight: "i-lucide-chevrons-right",
      chevronDown: "i-lucide-chevron-down",
      chevronLeft: "i-lucide-chevron-left",
      chevronRight: "i-lucide-chevron-right",
      chevronUp: "i-lucide-chevron-up",
      close: "i-lucide-x",
      copy: "i-lucide-copy",
      copyCheck: "i-lucide-copy-check",
      dark: "i-lucide-moon",
      drag: "i-lucide-grip-vertical",
      ellipsis: "i-lucide-ellipsis",
      error: "i-lucide-circle-x",
      external: "i-lucide-arrow-up-right",
      eye: "i-lucide-eye",
      eyeOff: "i-lucide-eye-off",
      file: "i-lucide-file",
      folder: "i-lucide-folder",
      folderOpen: "i-lucide-folder-open",
      hash: "i-lucide-hash",
      info: "i-lucide-info",
      light: "i-lucide-sun",
      loading: "i-lucide-loader-circle",
      menu: "i-lucide-menu",
      minus: "i-lucide-minus",
      panelClose: "i-lucide-panel-left-close",
      panelOpen: "i-lucide-panel-left-open",
      plus: "i-lucide-plus",
      reload: "i-lucide-rotate-ccw",
      search: "i-lucide-search",
      stop: "i-lucide-square",
      success: "i-lucide-circle-check",
      system: "i-lucide-monitor",
      tip: "i-lucide-lightbulb",
      upload: "i-lucide-upload",
      warning: "i-lucide-triangle-alert"
    },
    tv: {
      twMergeConfig: {}
    }
  },
  icon: {
    provider: "iconify",
    class: "",
    aliases: {},
    iconifyApiEndpoint: "https://api.iconify.design",
    localApiEndpoint: "/api/_nuxt_icon",
    fallbackToApi: true,
    cssSelectorPrefix: "i-",
    cssWherePseudo: true,
    cssLayer: "components",
    mode: "css",
    attrs: {
      "aria-hidden": true
    },
    collections: [
      "academicons",
      "akar-icons",
      "ant-design",
      "arcticons",
      "basil",
      "bi",
      "bitcoin-icons",
      "bpmn",
      "brandico",
      "bx",
      "bxl",
      "bxs",
      "bytesize",
      "carbon",
      "catppuccin",
      "cbi",
      "charm",
      "ci",
      "cib",
      "cif",
      "cil",
      "circle-flags",
      "circum",
      "clarity",
      "codicon",
      "covid",
      "cryptocurrency",
      "cryptocurrency-color",
      "dashicons",
      "devicon",
      "devicon-plain",
      "ei",
      "el",
      "emojione",
      "emojione-monotone",
      "emojione-v1",
      "entypo",
      "entypo-social",
      "eos-icons",
      "ep",
      "et",
      "eva",
      "f7",
      "fa",
      "fa-brands",
      "fa-regular",
      "fa-solid",
      "fa6-brands",
      "fa6-regular",
      "fa6-solid",
      "fad",
      "fe",
      "feather",
      "file-icons",
      "flag",
      "flagpack",
      "flat-color-icons",
      "flat-ui",
      "flowbite",
      "fluent",
      "fluent-emoji",
      "fluent-emoji-flat",
      "fluent-emoji-high-contrast",
      "fluent-mdl2",
      "fontelico",
      "fontisto",
      "formkit",
      "foundation",
      "fxemoji",
      "gala",
      "game-icons",
      "geo",
      "gg",
      "gis",
      "gravity-ui",
      "gridicons",
      "grommet-icons",
      "guidance",
      "healthicons",
      "heroicons",
      "heroicons-outline",
      "heroicons-solid",
      "hugeicons",
      "humbleicons",
      "ic",
      "icomoon-free",
      "icon-park",
      "icon-park-outline",
      "icon-park-solid",
      "icon-park-twotone",
      "iconamoon",
      "iconoir",
      "icons8",
      "il",
      "ion",
      "iwwa",
      "jam",
      "la",
      "lets-icons",
      "line-md",
      "logos",
      "ls",
      "lucide",
      "lucide-lab",
      "mage",
      "majesticons",
      "maki",
      "map",
      "marketeq",
      "material-symbols",
      "material-symbols-light",
      "mdi",
      "mdi-light",
      "medical-icon",
      "memory",
      "meteocons",
      "mi",
      "mingcute",
      "mono-icons",
      "mynaui",
      "nimbus",
      "nonicons",
      "noto",
      "noto-v1",
      "octicon",
      "oi",
      "ooui",
      "openmoji",
      "oui",
      "pajamas",
      "pepicons",
      "pepicons-pencil",
      "pepicons-pop",
      "pepicons-print",
      "ph",
      "pixelarticons",
      "prime",
      "ps",
      "quill",
      "radix-icons",
      "raphael",
      "ri",
      "rivet-icons",
      "si-glyph",
      "simple-icons",
      "simple-line-icons",
      "skill-icons",
      "solar",
      "streamline",
      "streamline-emojis",
      "subway",
      "svg-spinners",
      "system-uicons",
      "tabler",
      "tdesign",
      "teenyicons",
      "token",
      "token-branded",
      "topcoat",
      "twemoji",
      "typcn",
      "uil",
      "uim",
      "uis",
      "uit",
      "uiw",
      "unjs",
      "vaadin",
      "vs",
      "vscode-icons",
      "websymbol",
      "weui",
      "whh",
      "wi",
      "wpf",
      "zmdi",
      "zondicons"
    ],
    fetchTimeout: 1500
  }
}

type ResolvedAppConfig = Defu<typeof inlineConfig, [typeof cfg0]>

type IsAny<T> = 0 extends 1 & T ? true : false

type MergedAppConfig<
  Resolved extends Record<string, unknown>,
  Custom extends Record<string, unknown>
> = {
  [K in keyof (Resolved & Custom)]: K extends keyof Custom
    ? unknown extends Custom[K]
      ? Resolved[K]
      : IsAny<Custom[K]> extends true
        ? Resolved[K]
        : Custom[K] extends Record<string, any>
          ? Resolved[K] extends Record<string, any>
            ? MergedAppConfig<Resolved[K], Custom[K]>
            : Exclude<Custom[K], undefined>
          : Exclude<Custom[K], undefined>
    : Resolved[K]
}

declare module 'nuxt/schema' {
  interface AppConfig extends MergedAppConfig<ResolvedAppConfig, CustomAppConfig> {}
}

declare module '@nuxt/schema' {
  interface AppConfig extends MergedAppConfig<ResolvedAppConfig, CustomAppConfig> {}
}