#!/bin/bash
SRC=~/sudx-ai/sudx-ai.sh
DEST=~/sudx-ai/.sudx-ai/services/sudx-dashboard

# Extract DASH_APP heredoc (between the cat line and DASH_APP marker)
awk '/cat >.*dashboard_app.py.*DASH_APP/{flag=1;next} /^DASH_APP$/{flag=0} flag' "$SRC" > "$DEST/dashboard_app.py"
echo "APP lines: $(wc -l < "$DEST/dashboard_app.py")"

# Extract DASH_HTML heredoc (between the cat line and DASH_HTML marker)
awk '/cat >.*index\.html.*DASH_HTML/{flag=1;next} /^DASH_HTML$/{flag=0} flag' "$SRC" > "$DEST/static/index.html"
echo "HTML lines: $(wc -l < "$DEST/static/index.html")"

# Verify music is present
echo "---"
grep -c proxy_music "$DEST/dashboard_app.py" && echo "proxy_music in app.py: OK" || echo "proxy_music in app.py: MISSING"
grep -c loadMusic "$DEST/static/index.html" && echo "loadMusic in HTML: OK" || echo "loadMusic in HTML: MISSING"
grep -c 'data-page="music"' "$DEST/static/index.html" && echo "music nav in HTML: OK" || echo "music nav in HTML: MISSING"
