<?php











namespace Composer;

use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;






class InstalledVersions
{
private static $installed = array (
  'root' => 
  array (
    'pretty_version' => 'dev-master',
    'version' => 'dev-master',
    'aliases' => 
    array (
    ),
    'reference' => NULL,
    'name' => 'automattic/jetpack',
  ),
  'versions' => 
  array (
    'automattic/jetpack' => 
    array (
      'pretty_version' => 'dev-master',
      'version' => 'dev-master',
      'aliases' => 
      array (
      ),
      'reference' => NULL,
    ),
    'automattic/jetpack-a8c-mc-stats' => 
    array (
      'pretty_version' => 'v1.4.3',
      'version' => '1.4.3.0',
      'aliases' => 
      array (
      ),
      'reference' => 'fb7d2f80de987911853b5158423b58002bac7be3',
    ),
    'automattic/jetpack-abtest' => 
    array (
      'pretty_version' => '1.9.5',
      'version' => '1.9.5.0',
      'aliases' => 
      array (
      ),
      'reference' => '1d248925d21c8a6bae7e531c943f33b9d4acbaa3',
    ),
    'automattic/jetpack-assets' => 
    array (
      'pretty_version' => 'v1.11.4',
      'version' => '1.11.4.0',
      'aliases' => 
      array (
      ),
      'reference' => 'b07f8d9fac7cf57029872c2d443a8976118f2c78',
    ),
    'automattic/jetpack-autoloader' => 
    array (
      'pretty_version' => '2.10.1',
      'version' => '2.10.1.0',
      'aliases' => 
      array (
      ),
      'reference' => '20393c4677765c3e737dcb5aee7a3f7b90dce4b3',
    ),
    'automattic/jetpack-backup' => 
    array (
      'pretty_version' => '1.0.4',
      'version' => '1.0.4.0',
      'aliases' => 
      array (
      ),
      'reference' => '0f4484827b2176611a9880069fdcd6c2e2190894',
    ),
    'automattic/jetpack-blocks' => 
    array (
      'pretty_version' => 'v1.3.0',
      'version' => '1.3.0.0',
      'aliases' => 
      array (
      ),
      'reference' => 'e281aa8c75d7f287d1abdd03dafe2b57539f2178',
    ),
    'automattic/jetpack-compat' => 
    array (
      'pretty_version' => '1.6.3',
      'version' => '1.6.3.0',
      'aliases' => 
      array (
      ),
      'reference' => '3c180503515b7cc578e2045fa1d3ee4ebe6e9b3f',
    ),
    'automattic/jetpack-config' => 
    array (
      'pretty_version' => '1.4.4',
      'version' => '1.4.4.0',
      'aliases' => 
      array (
      ),
      'reference' => '3b052acd3e4990058f4f22de3dd9dd30d7b088b0',
    ),
    'automattic/jetpack-connection' => 
    array (
      'pretty_version' => 'v1.25.2',
      'version' => '1.25.2.0',
      'aliases' => 
      array (
      ),
      'reference' => '694ee277bceb238cd88622a7c8761622618f0904',
    ),
    'automattic/jetpack-connection-ui' => 
    array (
      'pretty_version' => '1.0.1',
      'version' => '1.0.1.0',
      'aliases' => 
      array (
      ),
      'reference' => '2bf49abc63c57e990958287de5fb3ed79594fef2',
    ),
    'automattic/jetpack-constants' => 
    array (
      'pretty_version' => 'v1.6.4',
      'version' => '1.6.4.0',
      'aliases' => 
      array (
      ),
      'reference' => 'cebd2c4760636595c7024e9381d5ee5a79825dbc',
    ),
    'automattic/jetpack-device-detection' => 
    array (
      'pretty_version' => '1.4.0',
      'version' => '1.4.0.0',
      'aliases' => 
      array (
      ),
      'reference' => '95a84035a27427cd110314964fdf6ad0463fe657',
    ),
    'automattic/jetpack-error' => 
    array (
      'pretty_version' => '1.3.3',
      'version' => '1.3.3.0',
      'aliases' => 
      array (
      ),
      'reference' => 'ed03067a151345e410334ba3e62a115e198a4c2f',
    ),
    'automattic/jetpack-heartbeat' => 
    array (
      'pretty_version' => 'v1.3.5',
      'version' => '1.3.5.0',
      'aliases' => 
      array (
      ),
      'reference' => 'caeecb4e65070fa1cc4e7005672d4df2a81371bf',
    ),
    'automattic/jetpack-jitm' => 
    array (
      'pretty_version' => '1.14.1',
      'version' => '1.14.1.0',
      'aliases' => 
      array (
      ),
      'reference' => 'f2372421b3b641e29bf231a55bcc36ec8d7c4851',
    ),
    'automattic/jetpack-lazy-images' => 
    array (
      'pretty_version' => '1.4.2',
      'version' => '1.4.2.0',
      'aliases' => 
      array (
      ),
      'reference' => 'd38189d9062268ccbb85e4eef807df518b829ead',
    ),
    'automattic/jetpack-licensing' => 
    array (
      'pretty_version' => '1.4.0',
      'version' => '1.4.0.0',
      'aliases' => 
      array (
      ),
      'reference' => '0ceadca9f21f3b810900c2de3418e03756e7adc6',
    ),
    'automattic/jetpack-logo' => 
    array (
      'pretty_version' => '1.5.3',
      'version' => '1.5.3.0',
      'aliases' => 
      array (
      ),
      'reference' => 'ae88ffbbc44775c73cf5022efbf76c66161c1c70',
    ),
    'automattic/jetpack-options' => 
    array (
      'pretty_version' => 'v1.11.4',
      'version' => '1.11.4.0',
      'aliases' => 
      array (
      ),
      'reference' => '0fa26d7d38d1938e570f17b6bae097e4ffb4a625',
    ),
    'automattic/jetpack-partner' => 
    array (
      'pretty_version' => '1.4.3',
      'version' => '1.4.3.0',
      'aliases' => 
      array (
      ),
      'reference' => '7d955c7363811e9550206f21d18beb85c59600f9',
    ),
    'automattic/jetpack-password-checker' => 
    array (
      'pretty_version' => '0.1.0',
      'version' => '0.1.0.0',
      'aliases' => 
      array (
      ),
      'reference' => '32ae71bbb32ec9d2f43bbc6459ec19188a25bff5',
    ),
    'automattic/jetpack-redirect' => 
    array (
      'pretty_version' => '1.5.4',
      'version' => '1.5.4.0',
      'aliases' => 
      array (
      ),
      'reference' => '3a466a83a0a55da6f56e8b1e4ec3f785603a4d7c',
    ),
    'automattic/jetpack-roles' => 
    array (
      'pretty_version' => 'v1.4.4',
      'version' => '1.4.4.0',
      'aliases' => 
      array (
      ),
      'reference' => '66fc99a92fb17352ca8b9eb7d990c95655acd491',
    ),
    'automattic/jetpack-status' => 
    array (
      'pretty_version' => 'v1.7.4',
      'version' => '1.7.4.0',
      'aliases' => 
      array (
      ),
      'reference' => '2620010589ae98848ac87f07ced9fd46ec501d1e',
    ),
    'automattic/jetpack-sync' => 
    array (
      'pretty_version' => '1.21.1',
      'version' => '1.21.1.0',
      'aliases' => 
      array (
      ),
      'reference' => 'b1336c2d478792f7586f0b875d17c0d7fadb9a37',
    ),
    'automattic/jetpack-terms-of-service' => 
    array (
      'pretty_version' => 'v1.9.5',
      'version' => '1.9.5.0',
      'aliases' => 
      array (
      ),
      'reference' => '107ab93984f161d1de6f0c07110f0b0b43f5723a',
    ),
    'automattic/jetpack-tracking' => 
    array (
      'pretty_version' => 'v1.13.4',
      'version' => '1.13.4.0',
      'aliases' => 
      array (
      ),
      'reference' => '55cb0e304a8a2b7575d8f87d3c1f5fb01b8a220a',
    ),
    'nojimage/twitter-text-php' => 
    array (
      'pretty_version' => 'v3.1.1',
      'version' => '3.1.1.0',
      'aliases' => 
      array (
      ),
      'reference' => '7f466b331cebfdd00e3568acaf45f2e90a39a320',
    ),
  ),
);
private static $canGetVendors;
private static $installedByVendor = array();







public static function getInstalledPackages()
{
$packages = array();
foreach (self::getInstalled() as $installed) {
$packages[] = array_keys($installed['versions']);
}


if (1 === \count($packages)) {
return $packages[0];
}

return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
}









public static function isInstalled($packageName)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return true;
}
}

return false;
}














public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));

return $provided->matches($constraint);
}










public static function getVersionRanges($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}

$ranges = array();
if (isset($installed['versions'][$packageName]['pretty_version'])) {
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
}
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
}
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
}
if (array_key_exists('provided', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
}

return implode(' || ', $ranges);
}

throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}





public static function getVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}

if (!isset($installed['versions'][$packageName]['version'])) {
return null;
}

return $installed['versions'][$packageName]['version'];
}

throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}





public static function getPrettyVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}

if (!isset($installed['versions'][$packageName]['pretty_version'])) {
return null;
}

return $installed['versions'][$packageName]['pretty_version'];
}

throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}





public static function getReference($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}

if (!isset($installed['versions'][$packageName]['reference'])) {
return null;
}

return $installed['versions'][$packageName]['reference'];
}

throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}





public static function getRootPackage()
{
$installed = self::getInstalled();

return $installed[0]['root'];
}







public static function getRawData()
{
return self::$installed;
}



















public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();
}




private static function getInstalled()
{
if (null === self::$canGetVendors) {
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
}

$installed = array();

if (self::$canGetVendors) {
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
}
}
}

$installed[] = self::$installed;

return $installed;
}
}
