<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<installer-gui-script minSpecVersion="2">
    <title>Lumen 1.0.1</title>
    <organization>com.wildconstruct</organization>
    <options customize="never" require-scripts="false" hostArchitectures="arm64"/>
    <background file="background.png" mime-type="image/png" alignment="bottomleft" scaling="proportional"/>
    <background-darkAqua file="background-dark.png" mime-type="image/png" alignment="bottomleft" scaling="proportional"/>
    <welcome file="welcome.html" mime-type="text/html"/>
    <license file="license.html" mime-type="text/html"/>
    <conclusion file="conclusion.html" mime-type="text/html"/>
    <installation-check script="lumenCheckInstall()"/>
    <script><![CDATA[
    function lumenCheckInstall() {
      if (system.sysctl('hw.optional.arm64') != 1) {
        my.result.title = 'Apple silicon required';
        my.result.message = 'Lumen 1.0.1 runs only on Macs with Apple silicon (M1 or later).';
        my.result.type = 'Fatal';
        return false;
      }
      return lumenCheckHosts();
    }
    // Installer JavaScript cannot list a folder, hence the year probes.
    function lumenCheckHosts() {
      var apps = ['Adobe After Effects ', 'Adobe Premiere Pro '];
      var supported = false, old = '';
      for (var a = 0; a < apps.length; a++) {
        for (var y = 2025; y <= 2035; y++) {
          if (system.files.fileExistsAtPath('/Applications/' + apps[a] + y)) supported = true;
        }
        for (var o = 2013; o < 2025; o++) {
          if (system.files.fileExistsAtPath('/Applications/' + apps[a] + o)) old = apps[a].replace('Adobe ', '') + o;
        }
      }
      if (old == '') return true;
      if (!supported) {
        my.result.title = 'After Effects or Premiere Pro 2025 or later required';
        my.result.message = 'Lumen needs After Effects or Premiere Pro 2025 or later. '
                          + 'The newest on this Mac is ' + old + ', which may fail to launch with Lumen installed.';
        my.result.type = 'Fatal';
        return false;
      }
      my.result.title = 'Older Adobe app detected';
      my.result.message = 'This Mac also has ' + old + ', which Lumen does not support. '
                        + 'It shares the plug-in folder, so it may fail to launch while Lumen is installed.';
      my.result.type = 'Warning';
      return false;
    }
  ]]></script>
    <volume-check>
        <allowed-os-versions>
            <os-version min="26.0"/>
        </allowed-os-versions>
    </volume-check>
    <choices-outline>
        <line choice="default"/>
    </choices-outline>
    <choice id="default" title="Lumen">
        <pkg-ref id="com.wildconstruct.lumen.plugins"/>
        <pkg-ref id="com.wildconstruct.lumen.photoshop"/>
        <pkg-ref id="com.wildconstruct.lumen.notices"/>
    </choice>
    <pkg-ref id="com.wildconstruct.lumen.plugins" version="1.0.1" onConclusion="none" installKBytes="20150" updateKBytes="0">#lumen-plugins.pkg</pkg-ref>
    <pkg-ref id="com.wildconstruct.lumen.photoshop" version="1.0.1" onConclusion="none" installKBytes="10598" updateKBytes="0">#lumen-photoshop.pkg</pkg-ref>
    <pkg-ref id="com.wildconstruct.lumen.notices" version="1.0.1" onConclusion="none" installKBytes="16" updateKBytes="0">#lumen-notices.pkg</pkg-ref>
    <pkg-ref id="com.wildconstruct.lumen.plugins">
        <bundle-version>
            <bundle CFBundleShortVersionString="1.0.1" CFBundleVersion="1.0.1" id="com.wildconstruct.LumenGlow" path="LumenGlow.plugin"/>
            <bundle CFBundleShortVersionString="1.0.1" CFBundleVersion="1.0.1" id="com.wildconstruct.LumenTransition" path="LumenTransition.plugin"/>
        </bundle-version>
    </pkg-ref>
    <pkg-ref id="com.wildconstruct.lumen.photoshop">
        <bundle-version>
            <bundle CFBundleShortVersionString="1.0.1" CFBundleVersion="1.0.1" id="com.wildconstruct.lumen.photoshop" path="LumenGlowPhotoshop.plugin"/>
        </bundle-version>
    </pkg-ref>
    <pkg-ref id="com.wildconstruct.lumen.notices">
        <bundle-version/>
    </pkg-ref>
</installer-gui-script>