<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!--
  Sonic Cascade — macOS productbuild Distribution Descriptor (Template)

  Placeholders replaced by build-installer.sh at build time. (XML comments
  must not contain double-hyphens, so option names are written with one dash.)
    DREAM DECAY  — User-visible display name (e.g., "DREAM DECAY");
                       filled from the -display-name option (falls back to
                       the -plugin-name slug)
    1.0.0      — Version string (e.g., "1.0.0")
    com.soniccascade.dreamdecay    — Bundle identifier (e.g., "com.soniccascade.dreamdecay")
-->
<installer-gui-script minSpecVersion="2">
    <title>Sonic Cascade DREAM DECAY</title>
    <!-- Background art shown behind every step of Installer.app. Both files
         are alpha-only PNGs (SC logo bottom-left, no field color) so they sit
         on the window chrome in either appearance; darkAqua gets the white
         logo, light gets Piano Black. 144 dpi metadata = 620x418pt at Retina
         resolution. Generated by shared/installer/scripts/generate-branding.py;
         overridable per plugin via build-installer.sh -background /
         -background-dark. -->
    <background file="background.png" mime-type="image/png" alignment="bottomleft" scaling="none"/>
    <background-darkAqua file="background-dark.png" mime-type="image/png" alignment="bottomleft" scaling="none"/>
    <!-- Welcome, license, and conclusion pages -->
    <welcome file="welcome.html" mime-type="text/html"/>
    <license file="license.html" mime-type="text/html"/>
    <conclusion file="conclusion.html" mime-type="text/html"/>
    <!-- Require macOS 10.13 or later (JUCE 8 minimum) -->
    <os-version min="10.13"/>
    <!-- Require 64-bit Intel or Apple Silicon -->
    <allowed-os-versions>
        <os-version min="10.13"/>
    </allowed-os-versions>
    <!-- Options -->
    <options customize="allow" require-scripts="false" rootVolumeOnly="true"/>
    <!-- Domain — install to the local system volume -->
    <domains enable_localSystem="true"/>
    <!-- ================================================================= -->
    <!-- Choice logic                                                       -->
    <!-- ================================================================= -->
    <!--
      At least one plugin format must stay selected, matching the Windows
      components page (installer.iss NextButtonClick, which refuses to leave
      the page when WizardSelectedComponents is empty).

      Installer.app offers no hook to block Continue on the Installation Type
      pane, so the invariant is enforced one step earlier: the LAST remaining
      format cannot be unticked. The user deselects formats freely until one is
      left, and that one's checkbox goes grey. Same guarantee as Windows, and
      it says so up front rather than erroring after the fact.

      The enabled= attributes below are BARE JavaScript expressions. Installer
      wraps the attribute value in "return ...;" and evaluates it as-is, so a
      "js:" prefix (or any other prefix) is a SyntaxError that Installer.app
      surfaces as "There was an error reading the package. JavaScriptError"
      before the welcome pane, which is exactly how DREAM DECAY 1.0.0 shipped
      on 2026-09-12 (#460 wrote enabled="js:scCanToggle(...)", untested on a
      Mac). build-installer.sh now opens every built .pkg headlessly with
      Apple's `installer -showChoicesXML`, which evaluates this same script and
      fails the build on any JS error.

      ['vst3','au','aax'] is substituted by build-installer.sh with the formats
      actually in this payload. It must not name a format that isn't here: the
      AAX choice block is deleted from this file outright when no .aaxplugin
      was passed, and a guard counting a missing choice would be wrong.
    -->
    <script><![CDATA[
        var SC_FORMAT_IDS = ['vst3','au','aax'];

        function scFormatsSelected()
        {
            var n = 0;
            for (var i = 0; i < SC_FORMAT_IDS.length; i++)
            {
                var c = choices[SC_FORMAT_IDS[i]];
                if (c != null && c.selected)
                    n++;
            }
            return n;
        }

        // A format's checkbox is live unless it is the only one still ticked.
        function scCanToggle (id)
        {
            var c = choices[id];
            if (c == null)
                return true;
            return !(c.selected && scFormatsSelected() <= 1);
        }
    ]]></script>
    <!-- ================================================================= -->
    <!-- Component choices                                                  -->
    <!-- ================================================================= -->
    <choices-outline>
        <line choice="vst3"/>
        <line choice="au"/>
        <line choice="aax"/>
        <line choice="manual"/>
        <line choice="notices"/>
        <line choice="system"/>
    </choices-outline>
    <!-- VST3 — visible, on by default, freely toggleable. Can only be
         unticked while another format is still ticked (see scCanToggle). -->
    <choice id="vst3" title="VST3 Plugin" description="Installs DREAM DECAY.vst3 to /Library/Audio/Plug-Ins/VST3/" visible="true" enabled="scCanToggle('vst3')" selected="true">
        <pkg-ref id="com.soniccascade.dreamdecay.vst3"/>
    </choice>
    <!-- Audio Unit — visible, on by default, freely toggleable. Same
         last-one-standing rule as VST3. -->
    <choice id="au" title="Audio Unit Plugin" description="Installs DREAM DECAY.component to /Library/Audio/Plug-Ins/Components/" visible="true" enabled="scCanToggle('au')" selected="true">
        <pkg-ref id="com.soniccascade.dreamdecay.component"/>
    </choice>
    <!-- AAX — visible, on by default, freely toggleable. Same last-one-standing
         rule. This block is removed by build-installer.sh if no AAX is
         provided, which is why the guard's format list is generated there. -->
    <choice id="aax" title="AAX Plugin (Pro Tools)" description="Installs DREAM DECAY.aaxplugin to /Library/Application Support/Avid/Audio/Plug-Ins/" visible="true" enabled="scCanToggle('aax')" selected="true">
        <pkg-ref id="com.soniccascade.dreamdecay.aaxplugin"/>
    </choice>
    <!-- User manual — visible, on by default, freely toggleable, and
         deliberately NOT part of the at-least-one-format rule: unticking it is
         always allowed, because a plugin with no manual still installs. This
         block is removed by build-installer.sh if no manual is provided. -->
    <choice id="manual" title="User Manual (PDF)" description="Installs DREAM DECAY Manual.pdf to /Library/Application Support/Sonic Cascade/DREAM DECAY/" visible="true" enabled="true" selected="true">
        <pkg-ref id="com.soniccascade.dreamdecay.manual"/>
    </choice>
    <!-- Third-party licence notices — hidden + force-selected, NOT a user
         choice. The MIT/ISC licences on the bundled code oblige us to ship
         these notices with the binary, so the user must not be able to
         deselect them. Removed by build-installer.sh only if no -notices file
         was supplied (which is itself a compliance gap the script warns about). -->
    <choice id="notices" title="Third-Party Notices" description="Installs NOTICES.txt to /Library/Application Support/Sonic Cascade/DREAM DECAY/" visible="false" enabled="false" selected="true">
        <pkg-ref id="com.soniccascade.dreamdecay.notices"/>
    </choice>
    <!-- Post-install — ALWAYS present (never stripped). Hidden + force-selected
         so it always runs: sets up ~/Documents/Sonic Cascade/ (user-facing
         manual copy + installed-plugins log). Payload-free; the work is in its
         postinstall script. -->
    <choice id="system" title="Sonic Cascade" description="Sets up your Documents/Sonic Cascade folder (user manual copy and installed-plugins log)." visible="false" enabled="false" selected="true">
        <pkg-ref id="com.soniccascade.dreamdecay.postinstall"/>
    </choice>
    <!-- ================================================================= -->
    <!-- Package references                                                 -->
    <!-- ================================================================= -->
    <pkg-ref id="com.soniccascade.dreamdecay.vst3" version="1.0.0" onConclusion="none" installKBytes="19214" updateKBytes="0">#vst3.pkg</pkg-ref>
    <pkg-ref id="com.soniccascade.dreamdecay.component" version="1.0.0" onConclusion="none" installKBytes="19154" updateKBytes="0">#au.pkg</pkg-ref>
    <pkg-ref id="com.soniccascade.dreamdecay.aaxplugin" version="1.0.0" onConclusion="none" installKBytes="19268" updateKBytes="0">#aax.pkg</pkg-ref>
    <pkg-ref id="com.soniccascade.dreamdecay.manual" version="1.0.0" onConclusion="none" installKBytes="956" updateKBytes="0">#manual.pkg</pkg-ref>
    <pkg-ref id="com.soniccascade.dreamdecay.notices" version="1.0.0" onConclusion="none" installKBytes="9" updateKBytes="0">#notices.pkg</pkg-ref>
    <pkg-ref id="com.soniccascade.dreamdecay.postinstall" version="1.0.0" onConclusion="none" installKBytes="0" updateKBytes="0">#postinstall.pkg</pkg-ref>
    <pkg-ref id="com.soniccascade.dreamdecay.vst3">
        <bundle-version>
            <bundle CFBundleShortVersionString="1.0.0" CFBundleVersion="1.0.0" id="com.soniccascade.dreamdecay" path="DREAM DECAY.vst3"/>
        </bundle-version>
    </pkg-ref>
    <pkg-ref id="com.soniccascade.dreamdecay.component">
        <bundle-version>
            <bundle CFBundleShortVersionString="1.0.0" CFBundleVersion="1.0.0" id="com.soniccascade.dreamdecay" path="DREAM DECAY.component"/>
        </bundle-version>
    </pkg-ref>
    <pkg-ref id="com.soniccascade.dreamdecay.aaxplugin">
        <bundle-version>
            <bundle CFBundleShortVersionString="1.0.0" CFBundleVersion="1.0.0" id="com.soniccascade.dreamdecay" path="DREAM DECAY.aaxplugin"/>
        </bundle-version>
    </pkg-ref>
    <pkg-ref id="com.soniccascade.dreamdecay.manual">
        <bundle-version/>
    </pkg-ref>
    <pkg-ref id="com.soniccascade.dreamdecay.notices">
        <bundle-version/>
    </pkg-ref>
    <pkg-ref id="com.soniccascade.dreamdecay.postinstall">
        <bundle-version/>
    </pkg-ref>
</installer-gui-script>