<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<installer-gui-script minSpecVersion="2">
    <title>AudioFuse Control Center</title>
    <welcome file="Welcome.rtf"/>
    <license file="License.rtf"/>
    <options allow-external-scripts="true" customize="always" rootVolumeOnly="true" hostArchitectures="x86_64,arm64"/>
    <installation-check script="installation_check()"/>
    <volume-check>
        <allowed-os-versions>
            <os-version min="10.10.0"/>
        </allowed-os-versions>
    </volume-check>
    <background file="bg.png" mime-type="image/png" scaling="none" alignment="bottomleft"/>
    <choices-outline>
        <line choice="UnspecifiedChoice"/>
        <line choice="documentationChoice"/>
        <line choice="resourcesChoice"/>
    </choices-outline>
    <choice id="UnspecifiedChoice" title="Unspecified" start_selected="true" start_enabled="false" start_visible="false">
        <pkg-ref id="com.Arturia.AudioFuseControlCenter.Unspecified"/>
    </choice>
    <pkg-ref id="com.Arturia.AudioFuseControlCenter.Unspecified" version="2.4.0" installKBytes="20874" auth="Admin" onConclusion="None" updateKBytes="0">#AudioFuse%20Control%20Center-2.4.0-Darwin-Unspecified.pkg</pkg-ref>
    <choice id="documentationChoice" title="AudioFuse Control Center Documentation" start_selected="true" start_enabled="false" start_visible="false" description="Documentation for AudioFuse Control Center">
        <pkg-ref id="com.Arturia.AudioFuseControlCenter.documentation"/>
    </choice>
    <pkg-ref id="com.Arturia.AudioFuseControlCenter.documentation" version="2.4.0" installKBytes="184" auth="Admin" onConclusion="None" updateKBytes="0">#AudioFuse%20Control%20Center-2.4.0-Darwin-documentation.pkg</pkg-ref>
    <choice id="resourcesChoice" title="AudioFuse Control Center" start_selected="true" start_enabled="false" start_visible="true" description="Mandatory resources for AudioFuse Control Center">
        <pkg-ref id="com.Arturia.AudioFuseControlCenter.resources"/>
    </choice>
    <pkg-ref id="com.Arturia.AudioFuseControlCenter.resources" version="2.4.0" installKBytes="200020" auth="Admin" onConclusion="None" updateKBytes="0">#AudioFuse%20Control%20Center-2.4.0-Darwin-resources.pkg</pkg-ref>
    <script>
	/* This is the script of the mac installer distribution file. It has to be added after generating the distribution with CPack */

	const __IC_FLAT_DISTRIBUTION__=true;
	const IC_CPU_ARCHITECTURE_ANY=0;
	const IC_CPU_ARCHITECTURE_POWERPC=18;
	const IC_CPU_ARCHITECTURE_INTEL=7;
	const IC_CPU_ARCHITECTURE_ARM=16777228;
	const IC_CPU_ARCHITECTURE_TYPE_ANY=0;
	const IC_CPU_ARCHITECTURE_TYPE_32=1;
	const IC_CPU_ARCHITECTURE_TYPE_64=2;

	const IC_DISK_TYPE_DESTINATION=0;
	const IC_DISK_TYPE_STARTUP_DISK=1;
	const IC_OS_DISTRIBUTION_TYPE_ANY=0;
	const IC_OS_DISTRIBUTION_TYPE_CLIENT=1;
	const IC_OS_DISTRIBUTION_TYPE_SERVER=2;

	const IC_COMPARATOR_IS_LESS=-1;
	const IC_COMPARATOR_IS_EQUAL=0;
	const IC_COMPARATOR_IS_GREATER=1;
	const IC_COMPARATOR_IS_NOT_EQUAL=2;

	function IC_CheckCPU(inMinimumCoresCount,inSupportedArchitecture,inSupportedIntelArchitectureType,inMinimumFrequency)
	{
		/* Check Minimum Core Count */

		if (system.sysctl('hw.ncpu')&gt;=inMinimumCoresCount)
		{
			var tArchitecture;
			var t64BitSupport;

			tArchitecture=system.sysctl('hw.cputype');

			/* Check Architecture */

			if (tArchitecture==IC_CPU_ARCHITECTURE_POWERPC)
			{
				/* We don't support PowerPC anymore */

				return false;
			}
			else if (inSupportedArchitecture!=IC_CPU_ARCHITECTURE_ANY)
			{
				if (inSupportedArchitecture!=tArchitecture)
				{
					return false;
				}
			}

			/* Check Architecture Type */

			t64BitSupport=system.sysctl('hw.cpu64bit_capable');

			if (tArchitecture==IC_CPU_ARCHITECTURE_ARM &amp;&amp; t64BitSupport==0)
			{
				/* We only support 64bits on ARM */

				return false;
			}
			else if (tArchitecture==IC_CPU_ARCHITECTURE_INTEL)
			{
				if ((inSupportedIntelArchitectureType==IC_CPU_ARCHITECTURE_TYPE_32 &amp;&amp; t64BitSupport==1) ||
					(inSupportedIntelArchitectureType==IC_CPU_ARCHITECTURE_TYPE_64 &amp;&amp; t64BitSupport==0))
				{
					return false;
				}
			}

			/* Check Minimum CPU Frequency */

			if(tArchitecture==IC_CPU_ARCHITECTURE_ARM)
			{
				/* Always return true when on arm, as hw.cpufrequency_max is  ot defined on silicon platforms */

				return true;
			}
			else if (system.sysctl('hw.cpufrequency_max')&gt;=inMinimumFrequency)
			{
				return true;
			}
		}

		return false;
	}

	function IC_CheckOS(inDiskType,inMustBeInstalled,inMinimumVersion,inDistributionType)
	{
		var tOSVersion=undefined;

		/* Check Minimum Version */

		if (inDiskType==IC_DISK_TYPE_DESTINATION)
		{
			if (my.target.systemVersion!=undefined)
			{
				tOSVersion=my.target.systemVersion.ProductVersion;
			}

			/* Check if no OS is installed on the potential target */

			if (tOSVersion==undefined)
			{
				return (inMustBeInstalled==false);
			}
		}
		else
		{
			tOSVersion=system.version.ProductVersion;
		}

		if (system.compareVersions(tOSVersion,inMinimumVersion)==-1)
		{
			return false;
		}

		/* Check Distribution Type */

		if (inDistributionType!=IC_OS_DISTRIBUTION_TYPE_ANY)
		{
			var tIsServer;

			if (system.compareVersions(tOSVersion,'10.8.0')==-1)
			{
				if (inDiskType==IC_DISK_TYPE_DESTINATION)
				{
					tIsServer=system.files.fileExistsAtPath(my.target.mountpoint+'/System/Library/CoreServices/ServerVersion.plist');
				}
				else
				{
					tIsServer=system.files.fileExistsAtPath('/System/Library/CoreServices/ServerVersion.plist');
				}
			}
			else
			{
				if (inDiskType==IC_DISK_TYPE_DESTINATION)
				{
					tIsServer=system.files.fileExistsAtPath(my.target.mountpoint+'/Applications/Server.app');
				}
				else
				{
					tIsServer=system.files.fileExistsAtPath('/Applications/Server.app');
				}
			}

			if (inDistributionType==IC_OS_DISTRIBUTION_TYPE_CLIENT &amp;&amp; tIsServer==true)
			{
				return false;
			}

			if (inDistributionType==IC_OS_DISTRIBUTION_TYPE_SERVER &amp;&amp; tIsServer==false)
			{
				return false;
			}
		}

		return true;
	}

	function IC_CheckScriptReturnValue(inScriptPath,inArguments,inComparator,inReturnValue)
	{
		var tReturnValue;

		if (inScriptPath.charAt(0)=='/')
		{
			/* Check Absolute Path Existence */

			if (system.files.fileExistsAtPath(inScriptPath)==false)
			{
				return false;
			}
		}
		else
		{
			if (__IC_FLAT_DISTRIBUTION__==true &amp;&amp; system.compareVersions(system.version.ProductVersion, '10.6.0')&lt;0)
			{
				system.log("[WARNING] Embedded scripts are not supported in Flat distribution format on Mac OS X 10.5");

				return true;
			}
		}

		if (inArguments.length&gt;0)
		{
			var tMethodCall;
			var tStringArguments=[];

			for(var i=0;i&lt;inArguments.length;i++)
			{
				tStringArguments[i]='inArguments['+i+']';
			}

			tMethodCall='system.run(inScriptPath,'+tStringArguments.join(',')+');';

			tReturnValue=eval(tMethodCall);
		}
		else
		{
			tReturnValue=system.run(inScriptPath);
		}

		if (tReturnValue==undefined)
		{
			return false;
		}

		if (inComparator==IC_COMPARATOR_IS_EQUAL)
		{
			return (tReturnValue==inReturnValue);
		}
		else if (inComparator==IC_COMPARATOR_IS_GREATER)
		{
			return (tReturnValue&gt;inReturnValue);
		}
		else if (inComparator==IC_COMPARATOR_IS_LESS)
		{
			return (tReturnValue&lt;inReturnValue);
		}
		else if (inComparator==IC_COMPARATOR_IS_NOT_EQUAL)
		{
			return (tReturnValue!=inReturnValue);
		}

		return false;
	}

	function installation_check()
	{
		var tResult;

		tResult=IC_CheckCPU(1,IC_CPU_ARCHITECTURE_ANY,IC_CPU_ARCHITECTURE_TYPE_ANY,866666);

		if (tResult==false)
		{
			my.result.title = system.localizedString('Processor');
			my.result.message = system.localizedString('The program cannot be installed on this computer, because the system architecture PPC is not supported. Intel architecture is required!');
			my.result.type = 'Fatal';
		}

		return tResult;
	}

	function volume_check()
	{
		var tResult;

		tResult=IC_CheckOS(IC_DISK_TYPE_DESTINATION,true,'10.10',IC_OS_DISTRIBUTION_TYPE_ANY);

		if (tResult==false)
		{
			my.result.message = system.localizedString('The program cannot be installed on this computer, because the installed operating system version is too old. System version Mac 0S X 10.10 ("Yosemite") or later is required!');
			my.result.type = 'Fatal';
		}

		return tResult;
	}

    </script>
    <pkg-ref id="com.Arturia.AudioFuseControlCenter.Unspecified">
        <bundle-version/>
    </pkg-ref>
    <pkg-ref id="com.Arturia.AudioFuseControlCenter.documentation">
        <bundle-version/>
    </pkg-ref>
    <pkg-ref id="com.Arturia.AudioFuseControlCenter.resources">
        <bundle-version>
            <bundle id="com.Arturia.updater" path="Applications/Arturia/AudioFuse Control Center.app/Contents/Resources/updater.app"/>
            <bundle CFBundleShortVersionString="2.4.0" CFBundleVersion="2.4.0.347" id="com.Arturia.AudioFuseControlCenterAgent" path="Applications/Arturia/AudioFuse Control Center.app/Contents/Resources/AudioFuseControlCenterAgent.app"/>
            <bundle CFBundleShortVersionString="2.4.0" CFBundleVersion="2.4.0.347" id="com.Arturia.AudioFuseControlCenter" path="Applications/Arturia/AudioFuse Control Center.app"/>
        </bundle-version>
    </pkg-ref>
    <product id="com.Arturia.AudioFuseControlCenter" version="2.4.0"/>
</installer-gui-script>