<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- The uninstaller's distribution, rendered by scripts/release/build-pkg.sh (the version
     placeholder is replaced; docs/release.md "The uninstaller"). One payload-free package whose postinstall
     removes Chatty Chad. -->
<installer-gui-script minSpecVersion="2">
    <title>Uninstall Chatty Chad</title>
    <welcome file="welcome.html" mime-type="text/html"/>
    <conclusion file="conclusion.html" mime-type="text/html"/>
    <options customize="never" hostArchitectures="arm64" rootVolumeOnly="true"/>
    <domains enable_localSystem="true" enable_anywhere="false" enable_currentUserHome="false"/>
    <allowed-os-versions>
        <os-version min="13.0"/>
    </allowed-os-versions>
    <!-- A running Lightroom Classic keeps the plug-in loaded, and it writes the settings folder
         again after it is removed: refused here and again by the script. Installer's
         JavaScript: system.applications.fromIdentifier, from Apple's Installer JavaScript
         Reference (not on this Mac), unverified on a real run. It fails open: if the call is
         missing or throws, the check passes and the script's own pgrep refuses instead. -->
    <installation-check script="lightroomIsClosed()"/>
    <script><![CDATA[
function lightroomIsClosed() {
    var running = null;
    try {
        running = system.applications.fromIdentifier('com.adobe.LightroomClassicCC7');
    } catch (e) {
        return true;
    }
    if (running && running.length > 0) {
        my.result.type = 'Fatal';
        my.result.title = 'Quit Lightroom Classic first';
        my.result.message = 'Quit Lightroom Classic, then run Uninstall Chatty Chad again.';
        return false;
    }
    return true;
}
    ]]></script>
    <choices-outline>
        <line choice="com.remesch.lrcbuddy.uninstall.pkg"/>
    </choices-outline>
    <choice id="com.remesch.lrcbuddy.uninstall.pkg" visible="false" title="Uninstall Chatty Chad">
        <pkg-ref id="com.remesch.lrcbuddy.uninstall.pkg"/>
    </choice>
    <pkg-ref id="com.remesch.lrcbuddy.uninstall.pkg" version="0.9.2" onConclusion="none" installKBytes="0" updateKBytes="0">#uninstall.pkg</pkg-ref>
    <pkg-ref id="com.remesch.lrcbuddy.uninstall.pkg">
        <bundle-version/>
    </pkg-ref>
</installer-gui-script>