// SourceWeaver theme picker — wraps the Landing root and renders a TweaksPanel.

function ThemedLanding() {
  const [tweaks, setTweak] = useTweaks({ theme: 'terminal' });

  React.useEffect(() => {
    document.documentElement.dataset.theme = tweaks.theme;
    // Propagate theme to embedded app iframes (e.g. the hero AppShell mock).
    const frames = document.querySelectorAll('iframe[data-sw-app]');
    frames.forEach(f => {
      try { f.contentWindow.postMessage({ type: '__sw_set_theme', theme: tweaks.theme }, '*'); } catch {}
    });
  }, [tweaks.theme]);

  return (
    <>
      <Landing />
      <TweaksPanel title="Tweaks">
        <TweakSection title="Theme">
          <TweakRadio
            value={tweaks.theme}
            onChange={(v) => setTweak('theme', v)}
            options={[
              { value: 'terminal', label: 'Terminal' },
              { value: 'mid',      label: 'Mid' },
              { value: 'light',    label: 'Light' },
            ]}
          />
        </TweakSection>
      </TweaksPanel>
    </>
  );
}

Object.assign(window, { ThemedLanding });
