<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<installer-gui-script minSpecVersion="1">
    <title>MIDI Control Center</title>
    <welcome file="Welcome.rtf"/>
    <license file="License.rtf"/>
    <options allow-external-scripts="no" customize="allow" rootVolumeOnly="false"/>
    <choices-outline>
        <line choice="resourcesChoice"/>
        <line choice="templatesChoice"/>
    </choices-outline>
    <choice id="resourcesChoice" title="MIDI Control Center" start_selected="true" start_enabled="false" start_visible="true" description="Mandatory resources for MIDI Control Center">
        <pkg-ref id="com.Arturia.MIDIControlCenter.resources"/>
    </choice>
    <pkg-ref id="com.Arturia.MIDIControlCenter.resources" version="1.23.0" installKBytes="117595" auth="Admin" onConclusion="None" updateKBytes="0">#MIDI%20Control%20Center-1.23.0-Darwin-resources.pkg</pkg-ref>
    <choice id="templatesChoice" title="MIDI Control Center Templates" start_selected="true" start_enabled="false" start_visible="false" description="Mandatory templates for MIDI Control Center">
        <pkg-ref id="com.Arturia.MIDIControlCenter.templates"/>
    </choice>
    <pkg-ref id="com.Arturia.MIDIControlCenter.templates" version="1.23.0" installKBytes="71995" auth="Admin" onConclusion="None" updateKBytes="0">#MIDI%20Control%20Center-1.23.0-Darwin-templates.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.MIDIControlCenter.resources">
        <bundle-version>
            <bundle id="com.Arturia.updater" path="Library/Arturia/MIDI Control Center/Resources/updater.app"/>
            <bundle CFBundleShortVersionString="1.23.0.134" CFBundleVersion="1.23.0.134" id="com.arturia.midicontrolcenter" path="Applications/Arturia/MIDI Control Center.app"/>
        </bundle-version>
    </pkg-ref>
    <pkg-ref id="com.Arturia.MIDIControlCenter.templates">
        <bundle-version/>
    </pkg-ref>
    <product id="com.Arturia.MIDIControlCenter" version="1.23.0"/>
</installer-gui-script>