"use strict";

const actionMeta = [
  {
    test: ".media.playpause",
    title: "Play / Pause",
    chip: "Static Media",
    deckVisual: "Static icon",
    settings: "No controls",
    note: "This Basic action is currently static-only."
  },
  {
    test: ".media.next",
    title: "Next Track",
    chip: "Static Media",
    deckVisual: "Static icon",
    settings: "No controls",
    note: "This Basic action is currently static-only."
  },
  {
    test: ".media.previous",
    title: "Previous Track",
    chip: "Static Media",
    deckVisual: "Static icon",
    settings: "No controls",
    note: "This Basic action is currently static-only."
  },
  {
    test: ".volume.up",
    title: "Volume Up",
    chip: "Volume",
    deckVisual: "Static icon",
    settings: "No controls",
    note: "Volume actions keep the Basic fixed deck visual."
  },
  {
    test: ".volume.down",
    title: "Volume Down",
    chip: "Volume",
    deckVisual: "Static icon",
    settings: "No controls",
    note: "Volume actions keep the Basic fixed deck visual."
  },
  {
    test: ".volume.mute",
    title: "Mute",
    chip: "Volume",
    deckVisual: "Static icon",
    settings: "No controls",
    note: "Volume actions keep the Basic fixed deck visual."
  },
  {
    test: ".cover.classic",
    title: "Rhythm Classic Cover",
    chip: "Classic Cover",
    deckVisual: "Live cover surface",
    settings: "Fixed layout",
    note: "Classic Cover uses its fixed Basic layout."
  }
];

function $(id) {
  return document.getElementById(id);
}

function text(id, value) {
  const node = $(id);
  if (node) node.textContent = value;
}

function actionId() {
  return String(window.$action || (typeof $action !== "undefined" ? $action : ""));
}

function currentMeta() {
  const action = actionId();
  return actionMeta.find((item) => action.includes(item.test)) || {
    title: "Rhythm Basic",
    chip: "Basic",
    deckVisual: "Static icon",
    settings: "No controls",
    note: "This Basic interface has no configurable controls."
  };
}

function apply() {
  const meta = currentMeta();
  text("actionTitle", meta.title);
  text("actionSummary", meta.note);
  text("actionChip", meta.chip);
  text("currentAction", meta.title);
  text("deckVisual", meta.deckVisual);
  text("settingsState", meta.settings);
  text("actionNote", meta.note);
  if ($("coverCard")) $("coverCard").hidden = meta.chip !== "Classic Cover";
}

window.onSettingsLoaded = apply;
document.addEventListener("DOMContentLoaded", apply);
