#!/usr/bin/env bash
set -euo pipefail

FILE="assets/js/modules/coproducer.inline-main.js"
STAMP="$(date +%Y%m%d_%H%M%S)"
BACKUP="${FILE}.bak_remove_master_lines_${STAMP}"
TMP="${FILE}.tmp_${STAMP}"

cp -p "$FILE" "$BACKUP"

# Remove from the first master patch marker to just before the next non-master code block.
# Based on your current file:
# first marker starts at 5009
# last master-related block starts at 6023
# remove through end of file, since these patches were appended at the tail.
awk 'NR < 5009 { print }' "$FILE" > "$TMP"

mv "$TMP" "$FILE"

echo "Backup created:"
echo "  $BACKUP"
echo
echo "Remaining master markers:"
grep -n '__masterMixer' "$FILE" || true
echo
echo "Tail preview:"
tail -n 40 "$FILE"
