<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<installer-gui-script minSpecVersion="2">
    <title>Lickd for DaVinci Resolve</title>
    <organization>co.lickd</organization>
    <options customize="never" require-scripts="true" hostArchitectures="arm64,x86_64"/>
    <!--
      Resolve's manifest.xml has no MinVersion field and Resolve will happily add
      our menu item on any Studio build that scans the folder. Premiere refuses to
      install a panel below host.minVersion; here the refusal has to be ours, and
      this is the earliest place we can make it — before the payload lands, with a
      message the user can act on.
    -->
    <installation-check script="lickd_can_install()"/>
    <script><![CDATA[
        function lickd_can_install() {
            if (!system.files.fileExistsAtPath('/Applications/DaVinci Resolve.app')) {
                my.result.title = 'DaVinci Resolve is not installed';
                my.result.message = 'Install DaVinci Resolve Studio first, then run this installer again.';
                my.result.type = 'Fatal';
                return false;
            }
            // The Developer folder is where WorkflowIntegration.node lives, and
            // postinstall cannot proceed without it. Checking here turns a failed
            // install into an explanation.
            // Both locations postinstall will search. Checking only the first
            // would refuse an install that would in fact have succeeded.
            var bridges = [
                '/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Workflow Integrations/Examples/SamplePlugin/WorkflowIntegration.node',
                '/Applications/DaVinci Resolve.app/Contents/Resources/Developer/Workflow Integrations/Examples/SamplePlugin/WorkflowIntegration.node'
            ];
            var found = false;
            for (var i = 0; i < bridges.length; i++) {
                if (system.files.fileExistsAtPath(bridges[i])) { found = true; break; }
            }
            if (!found) {
                my.result.title = 'DaVinci Resolve Studio is required';
                my.result.message = 'This installer could not find the Workflow Integrations developer files that ship with DaVinci Resolve Studio. The free edition of DaVinci Resolve cannot run plugins.';
                my.result.type = 'Fatal';
                return false;
            }
            return true;
        }
    ]]></script>
    <welcome file="welcome.html" mime-type="text/html"/>
    <conclusion file="conclusion.html" mime-type="text/html"/>
    <pkg-ref id="co.lickd.resolve.plugin">
        <bundle-version/>
    </pkg-ref>
    <choices-outline>
        <line choice="default">
            <line choice="co.lickd.resolve.plugin"/>
        </line>
    </choices-outline>
    <choice id="default"/>
    <choice id="co.lickd.resolve.plugin" visible="false">
        <pkg-ref id="co.lickd.resolve.plugin"/>
    </choice>
    <pkg-ref id="co.lickd.resolve.plugin" version="1.3.0" onConclusion="none" installKBytes="3554" updateKBytes="0">#component.pkg</pkg-ref>
</installer-gui-script>