#!/bin/bash
# Shared Tape DSP macOS uninstall logic (system + user plugin folders).
set -u

tape_dsp_remove_system_plugins() {
  osascript <<'APPLESCRIPT' || return 1
do shell script "rm -rf \"/Library/Audio/Plug-Ins/VST3/Tape DSP Machine.vst3\" \"/Library/Audio/Plug-Ins/VST3/Tape DSP Echo.vst3\" \"/Library/Audio/Plug-Ins/VST3/Tape DSP Compressor.vst3\" \"/Library/Audio/Plug-Ins/Components/Tape DSP Machine.component\" \"/Library/Audio/Plug-Ins/Components/Tape DSP Echo.component\" \"/Library/Audio/Plug-Ins/Components/Tape DSP Compressor.component\"" with administrator privileges
APPLESCRIPT
}

tape_dsp_remove_user_plugins() {
  rm -rf \
    "$HOME/Library/Audio/Plug-Ins/VST3/Tape DSP Machine.vst3" \
    "$HOME/Library/Audio/Plug-Ins/VST3/Tape DSP Echo.vst3" \
    "$HOME/Library/Audio/Plug-Ins/VST3/Tape DSP Compressor.vst3" \
    "$HOME/Library/Audio/Plug-Ins/Components/Tape DSP Machine.component" \
    "$HOME/Library/Audio/Plug-Ins/Components/Tape DSP Echo.component" \
    "$HOME/Library/Audio/Plug-Ins/Components/Tape DSP Compressor.component" \
    2>/dev/null || true
}

tape_dsp_forget_pkg_receipts() {
  pkgutil --forget "com.tapedsp.bundle.plugins" >/dev/null 2>&1 || true
}

tape_dsp_remove_app_folder() {
  rm -rf "/Applications/Tape DSP" 2>/dev/null || true
}
