/* Ruska — Tweaks app: hero palette switcher.
   Mounts a React root only for the Tweaks panel; the page itself stays vanilla. */
(function () {
  function mount() {
    if (!window.React || !window.ReactDOM || !window.TweaksPanel || !window.RuskaPalettes) {
      return setTimeout(mount, 60);
    }
    var e = React.createElement;
    var PALS = window.RuskaPalettes.list;

    function App() {
      var init = window.RuskaPalettes.currentId || "brand";
      var ref = React.useState(init);
      var pal = ref[0], setPal = ref[1];

      function choose(id) {
        setPal(id);
        window.RuskaPalettes.apply(id);
      }

      return e(window.TweaksPanel, { title: "Tweaks" },
        e(window.TweakSection, { label: "メインビジュアル配色" }),
        e("div", { style: { display: "flex", flexDirection: "column", gap: "8px" } },
          PALS.map(function (p) {
            var on = p.id === pal;
            return e("button", {
              key: p.id,
              onClick: function () { choose(p.id); },
              style: {
                display: "flex", alignItems: "center", gap: "11px",
                padding: "10px 11px", borderRadius: "9px", cursor: "pointer",
                border: on ? "1.5px solid #242422" : "1px solid #e2e2e2",
                background: on ? "#faf9f8" : "#fff", textAlign: "left", width: "100%",
                transition: "border-color .2s, background .2s"
              }
            },
              e("span", {
                style: {
                  flex: "none", width: "46px", height: "26px", borderRadius: "6px",
                  background: "linear-gradient(90deg," + p.colors[0] + " 0%," + p.colors[1] + " 50%," + p.colors[2] + " 100%)",
                  boxShadow: "inset 0 0 0 1px rgba(0,0,0,.06)"
                }
              }),
              e("span", { style: { display: "flex", flexDirection: "column", gap: "1px", minWidth: 0 } },
                e("span", { style: { fontSize: "13px", fontWeight: 700, color: "#242422", letterSpacing: ".02em" } }, p.name),
                e("span", { style: { fontSize: "10.5px", color: "#9a9a9a", letterSpacing: ".01em", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, p.sub)
              ),
              on ? e("span", { style: { marginLeft: "auto", flex: "none", color: "#242422", fontSize: "13px" } }, "\u2713") : null
            );
          })
        )
      );
    }

    var host = document.createElement("div");
    host.id = "ruska-tweaks-root";
    document.body.appendChild(host);
    ReactDOM.createRoot(host).render(e(App));
  }
  mount();
})();
