diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d2604a9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# Top-most EditorConfig file +root = true + +# All files +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +# PHP files +[{*.php,*.json}] +indent_style = space +indent_size = 4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9dad553..5a78e0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,13 +1,15 @@ name: Codeception on: + workflow_dispatch: push: branches: - - master + - main - develop + - craft4 pull_request: branches: - - master + - main jobs: test: @@ -17,7 +19,7 @@ jobs: strategy: matrix: operating-system: [ubuntu-latest] - php-versions: ["7.1", "7.2", "7.3", "7.4"] + php-versions: ["8.0", "8.1"] db: ["mysql", "pgsql"] env: DEFAULT_COMPOSER_FLAGS: "--no-interaction --no-ansi --no-progress --no-suggest" @@ -50,7 +52,7 @@ jobs: - uses: actions/checkout@v2 - name: Setup PHP Action - uses: shivammathur/setup-php@2.5.0 + uses: shivammathur/setup-php@2.25.5 with: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl, gd, imagick, zip, dom, pdo_mysql, pdo_pgsql, fileinfo diff --git a/changelog.md b/changelog.md index c947680..fe704b9 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,14 @@ # Snipcart Changelog +## 2.0 - 2023-09-11 + +- Update plugin to work with Craft 4 +- Move to using native Craft content table instead of custom `product_details` table +- Add migration to move product data from the custom `product_details` table to Craft native content tables +- Add convenience console command to remove legacy `product_details` table when required + - Command is `snipcart/cleanup` +- Removes legacy class alias for field type + ## 1.6.0 - 2023-06-20 ### Added @@ -108,7 +117,7 @@ ### Fixed - Fixed custom email notifications. - Order notification email subjects are now translatable. -- Admin order email notifications will only display a ShipStation ID when it’s not empty. +- Admin order email notifications will only display a ShipStation ID when it’s not empty. ### Changed - The Recent Orders summary now uses relative timestamps rather than `m/d` format. @@ -324,7 +333,7 @@ ## 1.0.3 - 2019-03-05 ### Fixed -- Fixed a bug where passing a `null` value for Product Details `customOptions` would throw a warning in PHP 7.2. +- Fixed a bug where passing a `null` value for Product Details `customOptions` would throw a warning in PHP 7.2. ## 1.0.2 - 2019-03-04 ### Fixed diff --git a/composer.json b/composer.json index 045f55a..0b7c65c 100644 --- a/composer.json +++ b/composer.json @@ -2,13 +2,13 @@ "name": "fostercommerce/craft-snipcart", "description": "Craft CMS e-commerce in a day.", "type": "craft-plugin", - "version": "1.6.0", + "version": "2.0.0", "keywords": [ "craft", "cms", "craftcms", "craft-plugin", - "craft3", + "craft4", "snipcart" ], "support": { @@ -24,14 +24,17 @@ ], "require": { "php": "^8.0", - "craftcms/cms": "^3.3.0", + "craftcms/cms": "^4.0.0", "pelago/emogrifier": "*" }, "require-dev": { - "roave/security-advisories": "dev-master", + "craftcms/ecs": "dev-main", + "craftcms/phpstan": "dev-main", + "craftcms/rector": "dev-main", + "roave/security-advisories": "dev-latest", + "fakerphp/faker": "^1.23", "vlucas/phpdotenv": "^3.4", "codeception/codeception": "^4.0.0", - "fzaninotto/faker": "^1.8", "codeception/module-phpbrowser": "^1.0.0", "codeception/module-asserts": "^1.0.0", "codeception/module-rest": "^1.0.0", @@ -44,7 +47,11 @@ } }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "yiisoft/yii2-composer": true, + "craftcms/plugin-installer": true + } }, "extra": { "name": "Snipcart", @@ -53,5 +60,14 @@ "hasCpSection": true, "changelogUrl": "https://github.com/FosterCommerce/snipcart-craft-plugin/changelog.md", "class": "fostercommerce\\snipcart\\Snipcart" + }, + "prefer-stable": true, + "minimum-stability": "dev", + "scripts": { + "phpstan": "phpstan --memory-limit=1G", + "ecs-check": "ecs check --ansi --memory-limit=1G", + "ecs-fix": "ecs check --ansi --fix --memory-limit=1G", + "rector": "rector process", + "rector-dry-run": "rector process --dry-run" } } diff --git a/ecs.php b/ecs.php new file mode 100644 index 0000000..558e42f --- /dev/null +++ b/ecs.php @@ -0,0 +1,32 @@ +parallel(); + $ecsConfig->paths([ + __DIR__ . '/src', + __FILE__, + ]); + + $ecsConfig->sets([ + SetList::ARRAY, + SetList::COMMENTS, + // SetList::CONTROL_STRUCTURES, + SetList::DOCBLOCK, + SetList::NAMESPACES, + SetList::PHPUNIT, + SetList::SPACES, + SetList::STRICT, + SetList::CLEAN_CODE, + SetList::PSR_12, + CraftSetList::CRAFT_CMS_4, + ]); + + $ecsConfig->services()->remove(DeclareStrictTypesFixer::class); +}; diff --git a/package.json b/package.json index 6e02506..1e31b7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "snipcart-craft-plugin", - "version": "1.5.1.1", + "version": "2.1.1", "description": "![Snipcart](resources/hero.svg)", "directories": { "doc": "docs", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..f9f81af --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,7 @@ +includes: + - vendor/craftcms/phpstan/phpstan.neon + +parameters: + level: 0 + paths: + - src diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..dcbab64 --- /dev/null +++ b/rector.php @@ -0,0 +1,41 @@ +paths([ + __DIR__ . '/src', + __FILE__, + ]); + + $rectorConfig->importNames(true, false); + $rectorConfig->importShortClasses(false); + + $rectorConfig->sets([ + SetList::PHP_80, + SetList::PHP_74, + SetList::PHP_73, + SetList::PHP_72, + SetList::PHP_71, + SetList::PHP_70, + SetList::PHP_56, + SetList::PHP_55, + SetList::PHP_54, + SetList::PHP_53, + SetList::PHP_52, + SetList::CODE_QUALITY, + SetList::CODING_STYLE, +// SetList::DEAD_CODE, + SetList::STRICT_BOOLEANS, + SetList::NAMING, + SetList::TYPE_DECLARATION, + SetList::EARLY_RETURN, +// SetList::INSTANCEOF, + CraftSetList::CRAFT_CMS_40, + CraftSetList::CRAFT_COMMERCE_40, + ]); + +}; diff --git a/src/Snipcart.php b/src/Snipcart.php index 8c6f76b..3bb113a 100755 --- a/src/Snipcart.php +++ b/src/Snipcart.php @@ -1,14 +1,32 @@ getRequest()->getIsConsoleRequest()) { + $this->controllerNamespace = 'fostercommerce\\snipcart\\console\\controllers'; + } + parent::init(); self::$plugin = $this; $this->setComponents([ - 'api' => Api::class, - 'carts' => Carts::class, - 'customers' => Customers::class, - 'data' => Data::class, - 'digitalGoods' => DigitalGoods::class, - 'discounts' => Discounts::class, - 'fields' => SnipcartFields::class, - 'orders' => Orders::class, + 'api' => Api::class, + 'carts' => Carts::class, + 'customers' => Customers::class, + 'data' => Data::class, + 'digitalGoods' => DigitalGoods::class, + 'discounts' => Discounts::class, + 'fields' => SnipcartFields::class, + 'orders' => Orders::class, 'notifications' => Notifications::class, - 'products' => Products::class, - 'shipments' => Shipments::class, + 'products' => Products::class, + 'shipments' => Shipments::class, 'subscriptions' => Subscriptions::class, - 'webhooks' => Webhooks::class, + 'webhooks' => Webhooks::class, ]); Event::on( CraftVariable::class, CraftVariable::EVENT_INIT, - static function (Event $event) { + static function(Event $event): void { $variable = $event->sender; $variable->set('snipcart', SnipcartVariable::class); } @@ -117,36 +116,37 @@ static function (Event $event) { Event::on( Dashboard::class, Dashboard::EVENT_REGISTER_WIDGET_TYPES, - static function (RegisterComponentTypesEvent $event) { - $event->types[] = OrdersWidget::class; + static function(RegisterComponentTypesEvent $registerComponentTypesEvent): void { + $registerComponentTypesEvent->types[] = OrdersWidget::class; } ); Event::on( Fields::class, Fields::EVENT_REGISTER_FIELD_TYPES, - static function (RegisterComponentTypesEvent $event) { - $event->types[] = ProductDetails::class; + static function(RegisterComponentTypesEvent $registerComponentTypesEvent): void { + $registerComponentTypesEvent->types[] = ProductDetails::class; } ); Event::on( ClearCaches::class, ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, - static function (RegisterCacheOptionsEvent $event) { - $event->options = array_merge( - $event->options, + static function(RegisterCacheOptionsEvent $registerCacheOptionsEvent): void { + $registerCacheOptionsEvent->options = array_merge( + $registerCacheOptionsEvent->options, [ [ - 'key' => Api::CACHE_TAG, - 'action' => [Snipcart::$plugin->api, 'invalidateCache'], - 'label' => Craft::t('snipcart', 'Snipcart API cache'), + 'key' => Api::CACHE_TAG, + 'action' => static fn() => self::$plugin->api::invalidateCache(), + 'label' => Craft::t('snipcart', 'Snipcart API cache'), ], ] ); } ); + // TODO: Remove CraftQL, replace with Crafts native graphql. /** * Tell CraftQL how to grab Snipcart Product Details field data. */ @@ -154,7 +154,7 @@ static function (RegisterCacheOptionsEvent $event) { Event::on( ProductDetails::class, 'craftQlGetFieldSchema', - static function ($event) { + static function($event): void { $event->handled = true; $outputSchema = CraftQlHelper::addFieldTypeToSchema( @@ -175,9 +175,9 @@ static function ($event) { Event::on( UrlManager::class, UrlManager::EVENT_REGISTER_CP_URL_RULES, - static function (RegisterUrlRulesEvent $event) { - $event->rules = array_merge( - $event->rules, + static function(RegisterUrlRulesEvent $registerUrlRulesEvent): void { + $registerUrlRulesEvent->rules = array_merge( + $registerUrlRulesEvent->rules, RouteHelper::getCpRoutes() ); } @@ -191,18 +191,7 @@ static function (RegisterUrlRulesEvent $event) { $this->registerShippingProviders(); } - /** - * @inheritdoc - */ - protected function createSettingsModel() - { - return new Settings(); - } - - /** - * @inheritdoc - */ - public function getSettingsResponse() + public function getSettingsResponse(): mixed { Craft::$app->getView()->registerAssetBundle( PluginSettingsAsset::class @@ -217,9 +206,11 @@ public function getSettingsResponse() ); } - /** - * @inheritdoc - */ + protected function createSettingsModel(): ?Model + { + return new Settings(); + } + protected function settingsHtml(): string { return Craft::$app->view->renderTemplate( @@ -234,28 +225,27 @@ protected function settingsHtml(): string /** * Instantiate Shipping providers and make each available in an indexed array. */ - private function registerShippingProviders() + private function registerShippingProviders(): void { // just one for now! - $shippingProviders = [ ShipStation::class ]; + $shippingProviders = [ShipStation::class]; if ($this->hasEventHandlers(self::EVENT_REGISTER_SHIPPING_PROVIDERS)) { - $event = new RegisterShippingProvidersEvent([ + $registerShippingProvidersEvent = new RegisterShippingProvidersEvent([ 'shippingProviders' => $shippingProviders, ]); - $this->trigger(self::EVENT_REGISTER_SHIPPING_PROVIDERS, $event); + $this->trigger(self::EVENT_REGISTER_SHIPPING_PROVIDERS, $registerShippingProvidersEvent); - $shippingProviders = $event->shippingProviders; + $shippingProviders = $registerShippingProvidersEvent->shippingProviders; } $pluginSettings = $this->getSettings(); - foreach ($shippingProviders as $shippingProviderClass) { - $instance = new $shippingProviderClass(); + foreach ($shippingProviders as $shippingProvider) { + $instance = new $shippingProvider(); $pluginSettings->addProvider($instance->refHandle(), $instance); } } - } diff --git a/src/assetbundles/ChartAsset.php b/src/assetbundles/ChartAsset.php index cfcfc15..45725b0 100644 --- a/src/assetbundles/ChartAsset.php +++ b/src/assetbundles/ChartAsset.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -18,10 +18,7 @@ */ class ChartAsset extends AssetBundle { - /** - * @inheritdoc - */ - public function init() + public function init(): void { $this->sourcePath = '@fostercommerce/snipcart/assetbundles/dist'; $this->depends = [CpAsset::class]; diff --git a/src/assetbundles/DiscountFieldAsset.php b/src/assetbundles/DiscountFieldAsset.php index e10da64..e5fe48c 100644 --- a/src/assetbundles/DiscountFieldAsset.php +++ b/src/assetbundles/DiscountFieldAsset.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -17,10 +17,7 @@ */ class DiscountFieldAsset extends AssetBundle { - /** - * @inheritdoc - */ - public function init() + public function init(): void { $this->sourcePath = '@fostercommerce/snipcart/assetbundles/dist'; $this->depends = [SnipcartAsset::class]; diff --git a/src/assetbundles/OrdersWidgetAsset.php b/src/assetbundles/OrdersWidgetAsset.php index ab417ae..8adca25 100644 --- a/src/assetbundles/OrdersWidgetAsset.php +++ b/src/assetbundles/OrdersWidgetAsset.php @@ -2,33 +2,31 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\assetbundles; -use yii\web\JqueryAsset; +use craft\web\AssetBundle; use craft\web\assets\cp\CpAsset; +use yii\web\JqueryAsset; /** * @author Working Concept * @package Snipcart * @since 1.0.0 */ -class OrdersWidgetAsset extends \craft\web\AssetBundle +class OrdersWidgetAsset extends AssetBundle { - /** - * @inheritdoc - */ - public function init() + public function init(): void { $this->sourcePath = '@fostercommerce/snipcart/assetbundles/dist'; $this->depends = [ SnipcartAsset::class, ChartAsset::class, CpAsset::class, - JqueryAsset::class + JqueryAsset::class, ]; $this->js = ['js/OrdersWidget.js']; $this->css = []; diff --git a/src/assetbundles/OverviewAsset.php b/src/assetbundles/OverviewAsset.php index 6e93c52..999bf27 100644 --- a/src/assetbundles/OverviewAsset.php +++ b/src/assetbundles/OverviewAsset.php @@ -2,15 +2,15 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\assetbundles; use craft\web\AssetBundle; -use yii\web\JqueryAsset; use craft\web\assets\cp\CpAsset; +use yii\web\JqueryAsset; /** * @author Working Concept @@ -19,17 +19,14 @@ */ class OverviewAsset extends AssetBundle { - /** - * @inheritdoc - */ - public function init() + public function init(): void { $this->sourcePath = '@fostercommerce/snipcart/assetbundles/dist'; $this->depends = [ SnipcartAsset::class, ChartAsset::class, CpAsset::class, - JqueryAsset::class + JqueryAsset::class, ]; $this->js = ['js/overview.js']; $this->css = ['css/snipcart.css']; diff --git a/src/assetbundles/PluginSettingsAsset.php b/src/assetbundles/PluginSettingsAsset.php index cabef95..be87e92 100644 --- a/src/assetbundles/PluginSettingsAsset.php +++ b/src/assetbundles/PluginSettingsAsset.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -17,10 +17,7 @@ */ class PluginSettingsAsset extends AssetBundle { - /** - * @inheritdoc - */ - public function init() + public function init(): void { $this->sourcePath = '@fostercommerce/snipcart/assetbundles/dist'; $this->depends = [SnipcartAsset::class]; diff --git a/src/assetbundles/ProductDetailsFieldAsset.php b/src/assetbundles/ProductDetailsFieldAsset.php index ec86a3c..e3e2948 100644 --- a/src/assetbundles/ProductDetailsFieldAsset.php +++ b/src/assetbundles/ProductDetailsFieldAsset.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -17,10 +17,7 @@ */ class ProductDetailsFieldAsset extends AssetBundle { - /** - * @inheritdoc - */ - public function init() + public function init(): void { $this->sourcePath = '@fostercommerce/snipcart/assetbundles/dist'; $this->depends = [SnipcartAsset::class]; diff --git a/src/assetbundles/SnipcartAsset.php b/src/assetbundles/SnipcartAsset.php index 0dce127..7a0c5f6 100644 --- a/src/assetbundles/SnipcartAsset.php +++ b/src/assetbundles/SnipcartAsset.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -18,10 +18,7 @@ */ class SnipcartAsset extends AssetBundle { - /** - * @inheritdoc - */ - public function init() + public function init(): void { $this->sourcePath = '@fostercommerce/snipcart/assetbundles/dist'; $this->depends = [CpAsset::class]; diff --git a/src/assetbundles/dist/js/vendors.js b/src/assetbundles/dist/js/vendors.js index 4572375..c26a8b6 100644 --- a/src/assetbundles/dist/js/vendors.js +++ b/src/assetbundles/dist/js/vendors.js @@ -1,21 +1,21 @@ (window.webpackJsonp=window.webpackJsonp||[]).push([[0],[function(t,e,i){"use strict";var a; /*! - * ApexCharts v3.36.2 - * (c) 2018-2022 ApexCharts + * ApexCharts v3.42.0 + * (c) 2018-2023 ApexCharts * Released under the MIT License. - */function s(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,a)}return i}function r(t){for(var e=1;et.length)&&(e=t.length);for(var i=0,a=new Array(e);i>16,o=i>>8&255,n=255&i;return"#"+(16777216+65536*(Math.round((a-r)*s)+r)+256*(Math.round((a-o)*s)+o)+(Math.round((a-n)*s)+n)).toString(16).slice(1)}},{key:"shadeColor",value:function(e,i){return t.isColorHex(i)?this.shadeHexColor(e,i):this.shadeRGBColor(e,i)}}],[{key:"bind",value:function(t,e){return function(){return t.apply(e,arguments)}}},{key:"isObject",value:function(t){return t&&"object"===o(t)&&!Array.isArray(t)&&null!=t}},{key:"is",value:function(t,e){return Object.prototype.toString.call(e)==="[object "+t+"]"}},{key:"listToArray",value:function(t){var e,i=[];for(e=0;ee.length?t:e}))),t.length>e.length?t:e}),0)}},{key:"hexToRgba",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"#999999",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.6;"#"!==t.substring(0,1)&&(t="#999999");var i=t.replace("#","");i=i.match(new RegExp("(.{"+i.length/3+"})","g"));for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:"x",i=t.toString().slice();return i.replace(/[` ~!@#$%^&*()|+\=?;:'",.<>{}[\]\\/]/gi,e)}},{key:"negToZero",value:function(t){return t<0?0:t}},{key:"moveIndexInArray",value:function(t,e,i){if(i>=t.length)for(var a=i-t.length+1;a--;)t.push(void 0);return t.splice(i,0,t.splice(e,1)[0]),t}},{key:"extractNumber",value:function(t){return parseFloat(t.replace(/[^\d.]*/g,""))}},{key:"findAncestor",value:function(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t}},{key:"setELstyles",value:function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t.style.key=e[i])}},{key:"isNumber",value:function(t){return!isNaN(t)&&parseFloat(Number(t))===t&&!isNaN(parseInt(t,10))}},{key:"isFloat",value:function(t){return Number(t)===t&&t%1!=0}},{key:"isSafari",value:function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}},{key:"isFirefox",value:function(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1}},{key:"isIE11",value:function(){if(-1!==window.navigator.userAgent.indexOf("MSIE")||window.navigator.appVersion.indexOf("Trident/")>-1)return!0}},{key:"isIE",value:function(){var t=window.navigator.userAgent,e=t.indexOf("MSIE ");if(e>0)return parseInt(t.substring(e+5,t.indexOf(".",e)),10);if(t.indexOf("Trident/")>0){var i=t.indexOf("rv:");return parseInt(t.substring(i+3,t.indexOf(".",i)),10)}var a=t.indexOf("Edge/");return a>0&&parseInt(t.substring(a+5,t.indexOf(".",a)),10)}}]),t}(),y=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.setEasingFunctions()}return h(t,[{key:"setEasingFunctions",value:function(){var t;if(!this.w.globals.easing){switch(this.w.config.chart.animations.easing){case"linear":t="-";break;case"easein":t="<";break;case"easeout":t=">";break;case"easeinout":default:t="<>";break;case"swing":t=function(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1};break;case"bounce":t=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375};break;case"elastic":t=function(t){return t===!!t?t:Math.pow(2,-10*t)*Math.sin((t-.075)*(2*Math.PI)/.3)+1}}this.w.globals.easing=t}}},{key:"animateLine",value:function(t,e,i,a){t.attr(e).animate(a).attr(i)}},{key:"animateMarker",value:function(t,e,i,a,s,r){e||(e=0),t.attr({r:e,width:e,height:e}).animate(a,s).attr({r:i,width:i.width,height:i.height}).afterAll((function(){r()}))}},{key:"animateCircle",value:function(t,e,i,a,s){t.attr({r:e.r,cx:e.cx,cy:e.cy}).animate(a,s).attr({r:i.r,cx:i.cx,cy:i.cy})}},{key:"animateRect",value:function(t,e,i,a,s){t.attr(e).animate(a).attr(i).afterAll((function(){return s()}))}},{key:"animatePathsGradually",value:function(t){var e=t.el,i=t.realIndex,a=t.j,s=t.fill,r=t.pathFrom,o=t.pathTo,n=t.speed,l=t.delay,h=this.w,c=0;h.config.chart.animations.animateGradually.enabled&&(c=h.config.chart.animations.animateGradually.delay),h.config.chart.animations.dynamicAnimation.enabled&&h.globals.dataChanged&&"bar"!==h.config.chart.type&&(c=0),this.morphSVG(e,i,a,"line"!==h.config.chart.type||h.globals.comboCharts?s:"stroke",r,o,n,l*c)}},{key:"showDelayedElements",value:function(){this.w.globals.delayedElements.forEach((function(t){t.el.classList.remove("apexcharts-element-hidden")}))}},{key:"animationCompleted",value:function(t){var e=this.w;e.globals.animationEnded||(e.globals.animationEnded=!0,this.showDelayedElements(),"function"==typeof e.config.chart.events.animationEnd&&e.config.chart.events.animationEnd(this.ctx,{el:t,w:e}))}},{key:"morphSVG",value:function(t,e,i,a,s,r,o,n){var l=this,h=this.w;s||(s=t.attr("pathFrom")),r||(r=t.attr("pathTo"));var c=function(t){return"radar"===h.config.chart.type&&(o=1),"M 0 ".concat(h.globals.gridHeight)};(!s||s.indexOf("undefined")>-1||s.indexOf("NaN")>-1)&&(s=c()),(!r||r.indexOf("undefined")>-1||r.indexOf("NaN")>-1)&&(r=c()),h.globals.shouldAnimate||(o=1),t.plot(s).animate(1,h.globals.easing,n).plot(s).animate(o,h.globals.easing,n).plot(r).afterAll((function(){m.isNumber(i)?i===h.globals.series[h.globals.maxValsInArrayIndex].length-2&&h.globals.shouldAnimate&&l.animationCompleted(t):"none"!==a&&h.globals.shouldAnimate&&(!h.globals.comboCharts&&e===h.globals.series.length-1||h.globals.comboCharts)&&l.animationCompleted(t),l.showDelayedElements()}))}}]),t}(),w=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"getDefaultFilter",value:function(t,e){var i=this.w;t.unfilter(!0),(new window.SVG.Filter).size("120%","180%","-5%","-40%"),"none"!==i.config.states.normal.filter?this.applyFilter(t,e,i.config.states.normal.filter.type,i.config.states.normal.filter.value):i.config.chart.dropShadow.enabled&&this.dropShadow(t,i.config.chart.dropShadow,e)}},{key:"addNormalFilter",value:function(t,e){var i=this.w;i.config.chart.dropShadow.enabled&&!t.node.classList.contains("apexcharts-marker")&&this.dropShadow(t,i.config.chart.dropShadow,e)}},{key:"addLightenFilter",value:function(t,e,i){var a=this,s=this.w,r=i.intensity;t.unfilter(!0),new window.SVG.Filter,t.filter((function(t){var i=s.config.chart.dropShadow;(i.enabled?a.addShadow(t,e,i):t).componentTransfer({rgb:{type:"linear",slope:1.5,intercept:r}})})),t.filterer.node.setAttribute("filterUnits","userSpaceOnUse"),this._scaleFilterSize(t.filterer.node)}},{key:"addDarkenFilter",value:function(t,e,i){var a=this,s=this.w,r=i.intensity;t.unfilter(!0),new window.SVG.Filter,t.filter((function(t){var i=s.config.chart.dropShadow;(i.enabled?a.addShadow(t,e,i):t).componentTransfer({rgb:{type:"linear",slope:r}})})),t.filterer.node.setAttribute("filterUnits","userSpaceOnUse"),this._scaleFilterSize(t.filterer.node)}},{key:"applyFilter",value:function(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5;switch(i){case"none":this.addNormalFilter(t,e);break;case"lighten":this.addLightenFilter(t,e,{intensity:a});break;case"darken":this.addDarkenFilter(t,e,{intensity:a})}}},{key:"addShadow",value:function(t,e,i){var a=i.blur,s=i.top,r=i.left,o=i.color,n=i.opacity,l=t.flood(Array.isArray(o)?o[e]:o,n).composite(t.sourceAlpha,"in").offset(r,s).gaussianBlur(a).merge(t.source);return t.blend(t.source,l)}},{key:"dropShadow",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=e.top,s=e.left,r=e.blur,o=e.color,n=e.opacity,l=e.noUserSpaceOnUse,h=this.w;return t.unfilter(!0),m.isIE()&&"radialBar"===h.config.chart.type||(o=Array.isArray(o)?o[i]:o,t.filter((function(t){var e;e=m.isSafari()||m.isFirefox()||m.isIE()?t.flood(o,n).composite(t.sourceAlpha,"in").offset(s,a).gaussianBlur(r):t.flood(o,n).composite(t.sourceAlpha,"in").offset(s,a).gaussianBlur(r).merge(t.source),t.blend(t.source,e)})),l||t.filterer.node.setAttribute("filterUnits","userSpaceOnUse"),this._scaleFilterSize(t.filterer.node)),t}},{key:"setSelectionFilter",value:function(t,e,i){var a=this.w;if(void 0!==a.globals.selectedDataPoints[e]&&a.globals.selectedDataPoints[e].indexOf(i)>-1){t.node.setAttribute("selected",!0);var s=a.config.states.active.filter;"none"!==s&&this.applyFilter(t,e,s.type,s.value)}}},{key:"_scaleFilterSize",value:function(t){!function(e){for(var i in e)e.hasOwnProperty(i)&&t.setAttribute(i,e[i])}({width:"200%",height:"200%",x:"-50%",y:"-50%"})}}]),t}(),k=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"roundPathCorners",value:function(t,e){function i(t,e,i){var s=e.x-t.x,r=e.y-t.y,o=Math.sqrt(s*s+r*r);return a(t,e,Math.min(1,i/o))}function a(t,e,i){return{x:t.x+(e.x-t.x)*i,y:t.y+(e.y-t.y)*i}}function s(t,e){t.length>2&&(t[t.length-2]=e.x,t[t.length-1]=e.y)}function r(t){return{x:parseFloat(t[t.length-2]),y:parseFloat(t[t.length-1])}}var o=t.split(/[,\s]/).reduce((function(t,e){var i=e.match("([a-zA-Z])(.+)");return i?(t.push(i[1]),t.push(i[2])):t.push(e),t}),[]).reduce((function(t,e){return parseFloat(e)==e&&t.length?t[t.length-1].push(e):t.push([e]),t}),[]),n=[];if(o.length>1){var l=r(o[0]),h=null;"Z"==o[o.length-1][0]&&o[0].length>2&&(h=["L",l.x,l.y],o[o.length-1]=h),n.push(o[0]);for(var c=1;c2&&"L"==g[0]&&u.length>2&&"L"==u[0]){var f,p,x=r(d),b=r(g),v=r(u);f=i(b,x,e),p=i(b,v,e),s(g,f),g.origPoint=b,n.push(g);var m=a(f,b,.5),y=a(b,p,.5),w=["C",m.x,m.y,y.x,y.y,p.x,p.y];w.origPoint=b,n.push(w)}else n.push(g)}if(h){var k=r(n[n.length-1]);n.push(["Z"]),s(n[0],k)}}else n=o;return n.reduce((function(t,e){return t+e.join(" ")+" "}),"")}},{key:"drawLine",value:function(t,e,i,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"#a8a8a8",r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,n=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"butt",l=this.w,h=l.globals.dom.Paper.line().attr({x1:t,y1:e,x2:i,y2:a,stroke:s,"stroke-dasharray":r,"stroke-width":o,"stroke-linecap":n});return h}},{key:"drawRect",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"#fefefe",o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1,n=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null,l=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,h=arguments.length>9&&void 0!==arguments[9]?arguments[9]:0,c=this.w,d=c.globals.dom.Paper.rect();return d.attr({x:t,y:e,width:i>0?i:0,height:a>0?a:0,rx:s,ry:s,opacity:o,"stroke-width":null!==n?n:0,stroke:null!==l?l:"none","stroke-dasharray":h}),d.node.setAttribute("fill",r),d}},{key:"drawPolygon",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#e1e1e1",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"none",s=this.w,r=s.globals.dom.Paper.polygon(t).attr({fill:a,stroke:e,"stroke-width":i});return r}},{key:"drawCircle",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=this.w;t<0&&(t=0);var a=i.globals.dom.Paper.circle(2*t);return null!==e&&a.attr(e),a}},{key:"drawPath",value:function(t){var e=t.d,i=void 0===e?"":e,a=t.stroke,s=void 0===a?"#a8a8a8":a,r=t.strokeWidth,o=void 0===r?1:r,n=t.fill,l=t.fillOpacity,h=void 0===l?1:l,c=t.strokeOpacity,d=void 0===c?1:c,g=t.classes,u=t.strokeLinecap,f=void 0===u?null:u,p=t.strokeDashArray,x=void 0===p?0:p,b=this.w;return null===f&&(f=b.config.stroke.lineCap),(i.indexOf("undefined")>-1||i.indexOf("NaN")>-1)&&(i="M 0 ".concat(b.globals.gridHeight)),b.globals.dom.Paper.path(i).attr({fill:n,"fill-opacity":h,stroke:s,"stroke-opacity":d,"stroke-linecap":f,"stroke-width":o,"stroke-dasharray":x,class:g})}},{key:"group",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=this.w,i=e.globals.dom.Paper.group();return null!==t&&i.attr(t),i}},{key:"move",value:function(t,e){return["M",t,e].join(" ")}},{key:"line",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=null;return null===i?a=[" L",t,e].join(" "):"H"===i?a=[" H",t].join(" "):"V"===i&&(a=[" V",e].join(" ")),a}},{key:"curve",value:function(t,e,i,a,s,r){return["C",t,e,i,a,s,r].join(" ")}},{key:"quadraticCurve",value:function(t,e,i,a){return["Q",t,e,i,a].join(" ")}},{key:"arc",value:function(t,e,i,a,s,r,o){var n=arguments.length>7&&void 0!==arguments[7]&&arguments[7],l="A";n&&(l="a");var h=[l,t,e,i,a,s,r,o].join(" ");return h}},{key:"renderPaths",value:function(t){var e,i=t.j,a=t.realIndex,s=t.pathFrom,o=t.pathTo,n=t.stroke,l=t.strokeWidth,h=t.strokeLinecap,c=t.fill,d=t.animationDelay,g=t.initialSpeed,u=t.dataChangeSpeed,f=t.className,p=t.shouldClipToGrid,x=void 0===p||p,b=t.bindEventsOnPaths,v=void 0===b||b,m=t.drawShadow,k=void 0===m||m,A=this.w,S=new w(this.ctx),C=new y(this.ctx),L=this.w.config.chart.animations.enabled,P=L&&this.w.config.chart.animations.dynamicAnimation.enabled,T=!!(L&&!A.globals.resized||P&&A.globals.dataChanged&&A.globals.shouldAnimate);T?e=s:(e=o,A.globals.animationEnded=!0);var M,I=A.config.stroke.dashArray;M=Array.isArray(I)?I[a]:A.config.stroke.dashArray;var z=this.drawPath({d:e,stroke:n,strokeWidth:l,fill:c,fillOpacity:1,classes:f,strokeLinecap:h,strokeDashArray:M});if(z.attr("index",a),x&&z.attr({"clip-path":"url(#gridRectMask".concat(A.globals.cuid,")")}),"none"!==A.config.states.normal.filter.type)S.getDefaultFilter(z,a);else if(A.config.chart.dropShadow.enabled&&k&&(!A.config.chart.dropShadow.enabledOnSeries||A.config.chart.dropShadow.enabledOnSeries&&-1!==A.config.chart.dropShadow.enabledOnSeries.indexOf(a))){var E=A.config.chart.dropShadow;S.dropShadow(z,E,a)}v&&(z.node.addEventListener("mouseenter",this.pathMouseEnter.bind(this,z)),z.node.addEventListener("mouseleave",this.pathMouseLeave.bind(this,z)),z.node.addEventListener("mousedown",this.pathMouseDown.bind(this,z))),z.attr({pathTo:o,pathFrom:s});var X={el:z,j:i,realIndex:a,pathFrom:s,pathTo:o,fill:c,strokeWidth:l,delay:d};return!L||A.globals.resized||A.globals.dataChanged?!A.globals.resized&&A.globals.dataChanged||C.showDelayedElements():C.animatePathsGradually(r(r({},X),{},{speed:g})),A.globals.dataChanged&&P&&T&&C.animatePathsGradually(r(r({},X),{},{speed:u})),z}},{key:"drawPattern",value:function(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"#a8a8a8",s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=this.w,o=r.globals.dom.Paper.pattern(e,i,(function(r){"horizontalLines"===t?r.line(0,0,i,0).stroke({color:a,width:s+1}):"verticalLines"===t?r.line(0,0,0,e).stroke({color:a,width:s+1}):"slantedLines"===t?r.line(0,0,e,i).stroke({color:a,width:s}):"squares"===t?r.rect(e,i).fill("none").stroke({color:a,width:s}):"circles"===t&&r.circle(e).fill("none").stroke({color:a,width:s})}));return o}},{key:"drawGradient",value:function(t,e,i,a,s){var r,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,n=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,l=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null,h=arguments.length>8&&void 0!==arguments[8]?arguments[8]:0,c=this.w;e.length<9&&0===e.indexOf("#")&&(e=m.hexToRgba(e,a)),i.length<9&&0===i.indexOf("#")&&(i=m.hexToRgba(i,s));var d=0,g=1,u=1,f=null;null!==n&&(d=void 0!==n[0]?n[0]/100:0,g=void 0!==n[1]?n[1]/100:1,u=void 0!==n[2]?n[2]/100:1,f=void 0!==n[3]?n[3]/100:null);var p=!("donut"!==c.config.chart.type&&"pie"!==c.config.chart.type&&"polarArea"!==c.config.chart.type&&"bubble"!==c.config.chart.type);if(r=null===l||0===l.length?c.globals.dom.Paper.gradient(p?"radial":"linear",(function(t){t.at(d,e,a),t.at(g,i,s),t.at(u,i,s),null!==f&&t.at(f,e,a)})):c.globals.dom.Paper.gradient(p?"radial":"linear",(function(t){(Array.isArray(l[h])?l[h]:l).forEach((function(e){t.at(e.offset/100,e.color,e.opacity)}))})),p){var x=c.globals.gridWidth/2,b=c.globals.gridHeight/2;"bubble"!==c.config.chart.type?r.attr({gradientUnits:"userSpaceOnUse",cx:x,cy:b,r:o}):r.attr({cx:.5,cy:.5,r:.8,fx:.2,fy:.2})}else"vertical"===t?r.from(0,0).to(0,1):"diagonal"===t?r.from(0,0).to(1,1):"horizontal"===t?r.from(0,1).to(1,1):"diagonal2"===t&&r.from(1,0).to(0,1);return r}},{key:"getTextBasedOnMaxWidth",value:function(t){var e=t.text,i=t.maxWidth,a=t.fontSize,s=t.fontFamily,r=this.getTextRects(e,a,s),o=r.width/e.length,n=Math.floor(i/o);return i-1){var n=i.globals.selectedDataPoints[s].indexOf(r);i.globals.selectedDataPoints[s].splice(n,1)}}else{if(!i.config.states.active.allowMultipleDataPointsSelection&&i.globals.selectedDataPoints.length>0){i.globals.selectedDataPoints=[];var l=i.globals.dom.Paper.select(".apexcharts-series path").members,h=i.globals.dom.Paper.select(".apexcharts-series circle, .apexcharts-series rect").members,c=function(t){Array.prototype.forEach.call(t,(function(t){t.node.setAttribute("selected","false"),a.getDefaultFilter(t,s)}))};c(l),c(h)}t.node.setAttribute("selected","true"),o="true",void 0===i.globals.selectedDataPoints[s]&&(i.globals.selectedDataPoints[s]=[]),i.globals.selectedDataPoints[s].push(r)}if("true"===o){var d=i.config.states.active.filter;if("none"!==d)a.applyFilter(t,s,d.type,d.value);else if("none"!==i.config.states.hover.filter&&!i.globals.isTouchDevice){var g=i.config.states.hover.filter;a.applyFilter(t,s,g.type,g.value)}}else"none"!==i.config.states.active.filter.type&&("none"===i.config.states.hover.filter.type||i.globals.isTouchDevice?a.getDefaultFilter(t,s):(g=i.config.states.hover.filter,a.applyFilter(t,s,g.type,g.value)));"function"==typeof i.config.chart.events.dataPointSelection&&i.config.chart.events.dataPointSelection(e,this.ctx,{selectedDataPoints:i.globals.selectedDataPoints,seriesIndex:s,dataPointIndex:r,w:i}),e&&this.ctx.events.fireEvent("dataPointSelection",[e,this.ctx,{selectedDataPoints:i.globals.selectedDataPoints,seriesIndex:s,dataPointIndex:r,w:i}])}},{key:"rotateAroundCenter",value:function(t){var e={};return t&&"function"==typeof t.getBBox&&(e=t.getBBox()),{x:e.x+e.width/2,y:e.y+e.height/2}}},{key:"getTextRects",value:function(t,e,i,a){var s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],r=this.w,o=this.drawText({x:-200,y:-200,text:t,textAnchor:"start",fontSize:e,fontFamily:i,foreColor:"#fff",opacity:0});a&&o.attr("transform",a),r.globals.dom.Paper.add(o);var n=o.bbox();return s||(n=o.node.getBoundingClientRect()),o.remove(),{width:n.width,height:n.height}}},{key:"placeTextWithEllipsis",value:function(t,e,i){if("function"==typeof t.getComputedTextLength&&(t.textContent=e,e.length>0&&t.getComputedTextLength()>=i/1.1)){for(var a=e.length-3;a>0;a-=3)if(t.getSubStringLength(0,a)<=i/1.1)return void(t.textContent=e.substring(0,a)+"...");t.textContent="."}}}],[{key:"setAttrs",value:function(t,e){for(var i in e)e.hasOwnProperty(i)&&t.setAttribute(i,e[i])}}]),t}(),A=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"getStackedSeriesTotals",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=this.w,i=[];if(0===e.globals.series.length)return i;for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:null;return null===t?this.w.config.series.reduce((function(t,e){return t+e}),0):this.w.globals.series[t].reduce((function(t,e){return t+e}),0)}},{key:"isSeriesNull",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return 0===(null===t?this.w.config.series.filter((function(t){return null!==t})):this.w.config.series[t].data.filter((function(t){return null!==t}))).length}},{key:"seriesHaveSameValues",value:function(t){return this.w.globals.series[t].every((function(t,e,i){return t===i[0]}))}},{key:"getCategoryLabels",value:function(t){var e=this.w,i=t.slice();return e.config.xaxis.convertedCatToNumeric&&(i=t.map((function(t,i){return e.config.xaxis.labels.formatter(t-e.globals.minX+1)}))),i}},{key:"getLargestSeries",value:function(){var t=this.w;t.globals.maxValsInArrayIndex=t.globals.series.map((function(t){return t.length})).indexOf(Math.max.apply(Math,t.globals.series.map((function(t){return t.length}))))}},{key:"getLargestMarkerSize",value:function(){var t=this.w,e=0;return t.globals.markers.size.forEach((function(t){e=Math.max(e,t)})),t.config.markers.discrete&&t.config.markers.discrete.length&&t.config.markers.discrete.forEach((function(t){e=Math.max(e,t.size)})),e>0&&(e+=t.config.markers.hover.sizeOffset+1),t.globals.markers.largestSize=e,e}},{key:"getSeriesTotals",value:function(){var t=this.w;t.globals.seriesTotals=t.globals.series.map((function(t,e){var i=0;if(Array.isArray(t))for(var a=0;at&&i.globals.seriesX[s][o]0&&(e=!0),{comboBarCount:i,comboCharts:e}}},{key:"extendArrayProps",value:function(t,e,i){return e.yaxis&&(e=t.extendYAxis(e,i)),e.annotations&&(e.annotations.yaxis&&(e=t.extendYAxisAnnotations(e)),e.annotations.xaxis&&(e=t.extendXAxisAnnotations(e)),e.annotations.points&&(e=t.extendPointAnnotations(e))),e}}]),t}(),S=function(){function t(e){n(this,t),this.w=e.w,this.annoCtx=e}return h(t,[{key:"setOrientations",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=this.w;if("vertical"===t.label.orientation){var a=null!==e?e:0,s=i.globals.dom.baseEl.querySelector(".apexcharts-xaxis-annotations .apexcharts-xaxis-annotation-label[rel='".concat(a,"']"));if(null!==s){var r=s.getBoundingClientRect();s.setAttribute("x",parseFloat(s.getAttribute("x"))-r.height+4),"top"===t.label.position?s.setAttribute("y",parseFloat(s.getAttribute("y"))+r.width):s.setAttribute("y",parseFloat(s.getAttribute("y"))-r.width);var o=this.annoCtx.graphics.rotateAroundCenter(s),n=o.x,l=o.y;s.setAttribute("transform","rotate(-90 ".concat(n," ").concat(l,")"))}}}},{key:"addBackgroundToAnno",value:function(t,e){var i=this.w;if(!t||void 0===e.label.text||void 0!==e.label.text&&!String(e.label.text).trim())return null;var a=i.globals.dom.baseEl.querySelector(".apexcharts-grid").getBoundingClientRect(),s=t.getBoundingClientRect(),r=e.label.style.padding.left,o=e.label.style.padding.right,n=e.label.style.padding.top,l=e.label.style.padding.bottom;"vertical"===e.label.orientation&&(n=e.label.style.padding.left,l=e.label.style.padding.right,r=e.label.style.padding.top,o=e.label.style.padding.bottom);var h=s.left-a.left-r,c=s.top-a.top-n,d=this.annoCtx.graphics.drawRect(h-i.globals.barPadForNumericAxis,c,s.width+r+o,s.height+n+l,e.label.borderRadius,e.label.style.background,1,e.label.borderWidth,e.label.borderColor,0);return e.id&&d.node.classList.add(e.id),d}},{key:"annotationsBackground",value:function(){var t=this,e=this.w,i=function(i,a,s){var r=e.globals.dom.baseEl.querySelector(".apexcharts-".concat(s,"-annotations .apexcharts-").concat(s,"-annotation-label[rel='").concat(a,"']"));if(r){var o=r.parentNode,n=t.addBackgroundToAnno(r,i);n&&(o.insertBefore(n.node,r),i.label.mouseEnter&&n.node.addEventListener("mouseenter",i.label.mouseEnter.bind(t,i)),i.label.mouseLeave&&n.node.addEventListener("mouseleave",i.label.mouseLeave.bind(t,i)),i.label.click&&n.node.addEventListener("click",i.label.click.bind(t,i)))}};e.config.annotations.xaxis.map((function(t,e){i(t,e,"xaxis")})),e.config.annotations.yaxis.map((function(t,e){i(t,e,"yaxis")})),e.config.annotations.points.map((function(t,e){i(t,e,"point")}))}},{key:"getY1Y2",value:function(t,e){var i,a="y1"===t?e.y:e.y2,s=this.w;if(this.annoCtx.invertAxis){var r=s.globals.labels.indexOf(a);s.config.xaxis.convertedCatToNumeric&&(r=s.globals.categoryLabels.indexOf(a));var o=s.globals.dom.baseEl.querySelector(".apexcharts-yaxis-texts-g text:nth-child("+(r+1)+")");o&&(i=parseFloat(o.getAttribute("y")))}else{var n;n=s.config.yaxis[e.yAxisIndex].logarithmic?(a=new A(this.annoCtx.ctx).getLogVal(a,e.yAxisIndex))/s.globals.yLogRatio[e.yAxisIndex]:(a-s.globals.minYArr[e.yAxisIndex])/(s.globals.yRange[e.yAxisIndex]/s.globals.gridHeight),i=s.globals.gridHeight-n,!e.marker||void 0!==e.y&&null!==e.y||(i=0),s.config.yaxis[e.yAxisIndex]&&s.config.yaxis[e.yAxisIndex].reversed&&(i=n)}return"string"==typeof a&&a.indexOf("px")>-1&&(i=parseFloat(a)),i}},{key:"getX1X2",value:function(t,e){var i=this.w,a=this.annoCtx.invertAxis?i.globals.minY:i.globals.minX,s=this.annoCtx.invertAxis?i.globals.maxY:i.globals.maxX,r=this.annoCtx.invertAxis?i.globals.yRange[0]:i.globals.xRange,o=(e.x-a)/(r/i.globals.gridWidth);this.annoCtx.inversedReversedAxis&&(o=(s-e.x)/(r/i.globals.gridWidth)),"category"!==i.config.xaxis.type&&!i.config.xaxis.convertedCatToNumeric||this.annoCtx.invertAxis||i.globals.dataFormatXNumeric||(o=this.getStringX(e.x));var n=(e.x2-a)/(r/i.globals.gridWidth);return this.annoCtx.inversedReversedAxis&&(n=(s-e.x2)/(r/i.globals.gridWidth)),"category"!==i.config.xaxis.type&&!i.config.xaxis.convertedCatToNumeric||this.annoCtx.invertAxis||i.globals.dataFormatXNumeric||(n=this.getStringX(e.x2)),void 0!==e.x&&null!==e.x||!e.marker||(o=i.globals.gridWidth),"x1"===t&&"string"==typeof e.x&&e.x.indexOf("px")>-1&&(o=parseFloat(e.x)),"x2"===t&&"string"==typeof e.x2&&e.x2.indexOf("px")>-1&&(n=parseFloat(e.x2)),"x1"===t?o:n}},{key:"getStringX",value:function(t){var e=this.w,i=t;e.config.xaxis.convertedCatToNumeric&&e.globals.categoryLabels.length&&(t=e.globals.categoryLabels.indexOf(t)+1);var a=e.globals.labels.indexOf(t),s=e.globals.dom.baseEl.querySelector(".apexcharts-xaxis-texts-g text:nth-child("+(a+1)+")");return s&&(i=parseFloat(s.getAttribute("x"))),i}}]),t}(),C=function(){function t(e){n(this,t),this.w=e.w,this.annoCtx=e,this.invertAxis=this.annoCtx.invertAxis,this.helpers=new S(this.annoCtx)}return h(t,[{key:"addXaxisAnnotation",value:function(t,e,i){var a,s=this.w,r=this.helpers.getX1X2("x1",t),o=t.label.text,n=t.strokeDashArray;if(m.isNumber(r)){if(null===t.x2||void 0===t.x2){var l=this.annoCtx.graphics.drawLine(r+t.offsetX,0+t.offsetY,r+t.offsetX,s.globals.gridHeight+t.offsetY,t.borderColor,n,t.borderWidth);e.appendChild(l.node),t.id&&l.node.classList.add(t.id)}else{if((a=this.helpers.getX1X2("x2",t))o){var h=o;o=a,a=h}var c=this.annoCtx.graphics.drawRect(0+t.offsetX,a+t.offsetY,this._getYAxisAnnotationWidth(t),o-a,0,t.fillColor,t.opacity,1,t.borderColor,r);c.node.classList.add("apexcharts-annotation-rect"),c.attr("clip-path","url(#gridRectMask".concat(s.globals.cuid,")")),e.appendChild(c.node),t.id&&c.node.classList.add(t.id)}var d="right"===t.label.position?s.globals.gridWidth:"center"===t.label.position?s.globals.gridWidth/2:0,g=this.annoCtx.graphics.drawText({x:d+t.label.offsetX,y:(null!=a?a:o)+t.label.offsetY-3,text:n,textAnchor:t.label.textAnchor,fontSize:t.label.style.fontSize,fontFamily:t.label.style.fontFamily,fontWeight:t.label.style.fontWeight,foreColor:t.label.style.color,cssClass:"apexcharts-yaxis-annotation-label ".concat(t.label.style.cssClass," ").concat(t.id?t.id:"")});g.attr({rel:i}),e.appendChild(g.node)}},{key:"_getYAxisAnnotationWidth",value:function(t){var e=this.w;return e.globals.gridWidth,(t.width.indexOf("%")>-1?e.globals.gridWidth*parseInt(t.width,10)/100:parseInt(t.width,10))+t.offsetX}},{key:"drawYAxisAnnotations",value:function(){var t=this,e=this.w,i=this.annoCtx.graphics.group({class:"apexcharts-yaxis-annotations"});return e.config.annotations.yaxis.map((function(e,a){t.addYaxisAnnotation(e,i.node,a)})),i}}]),t}(),P=function(){function t(e){n(this,t),this.w=e.w,this.annoCtx=e,this.helpers=new S(this.annoCtx)}return h(t,[{key:"addPointAnnotation",value:function(t,e,i){this.w;var a=this.helpers.getX1X2("x1",t),s=this.helpers.getY1Y2("y1",t);if(m.isNumber(a)){var r={pSize:t.marker.size,pointStrokeWidth:t.marker.strokeWidth,pointFillColor:t.marker.fillColor,pointStrokeColor:t.marker.strokeColor,shape:t.marker.shape,pRadius:t.marker.radius,class:"apexcharts-point-annotation-marker ".concat(t.marker.cssClass," ").concat(t.id?t.id:"")},o=this.annoCtx.graphics.drawMarker(a+t.marker.offsetX,s+t.marker.offsetY,r);e.appendChild(o.node);var n=t.label.text?t.label.text:"",l=this.annoCtx.graphics.drawText({x:a+t.label.offsetX,y:s+t.label.offsetY-t.marker.size-parseFloat(t.label.style.fontSize)/1.6,text:n,textAnchor:t.label.textAnchor,fontSize:t.label.style.fontSize,fontFamily:t.label.style.fontFamily,fontWeight:t.label.style.fontWeight,foreColor:t.label.style.color,cssClass:"apexcharts-point-annotation-label ".concat(t.label.style.cssClass," ").concat(t.id?t.id:"")});if(l.attr({rel:i}),e.appendChild(l.node),t.customSVG.SVG){var h=this.annoCtx.graphics.group({class:"apexcharts-point-annotations-custom-svg "+t.customSVG.cssClass});h.attr({transform:"translate(".concat(a+t.customSVG.offsetX,", ").concat(s+t.customSVG.offsetY,")")}),h.node.innerHTML=t.customSVG.SVG,e.appendChild(h.node)}if(t.image.path){var c=t.image.width?t.image.width:20,d=t.image.height?t.image.height:20;o=this.annoCtx.addImage({x:a+t.image.offsetX-c/2,y:s+t.image.offsetY-d/2,width:c,height:d,path:t.image.path,appendTo:".apexcharts-point-annotations"})}t.mouseEnter&&o.node.addEventListener("mouseenter",t.mouseEnter.bind(this,t)),t.mouseLeave&&o.node.addEventListener("mouseleave",t.mouseLeave.bind(this,t)),t.click&&o.node.addEventListener("click",t.click.bind(this,t))}}},{key:"drawPointAnnotations",value:function(){var t=this,e=this.w,i=this.annoCtx.graphics.group({class:"apexcharts-point-annotations"});return e.config.annotations.points.map((function(e,a){t.addPointAnnotation(e,i.node,a)})),i}}]),t}(),T={name:"en",options:{months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],toolbar:{exportToSVG:"Download SVG",exportToPNG:"Download PNG",exportToCSV:"Download CSV",menu:"Menu",selection:"Selection",selectionZoom:"Selection Zoom",zoomIn:"Zoom In",zoomOut:"Zoom Out",pan:"Panning",reset:"Reset Zoom"}}},M=function(){function t(){n(this,t),this.yAxis={show:!0,showAlways:!1,showForNullSeries:!0,seriesName:void 0,opposite:!1,reversed:!1,logarithmic:!1,logBase:10,tickAmount:void 0,forceNiceScale:!1,max:void 0,min:void 0,floating:!1,decimalsInFloat:void 0,labels:{show:!0,minWidth:0,maxWidth:160,offsetX:0,offsetY:0,align:void 0,rotate:0,padding:20,style:{colors:[],fontSize:"11px",fontWeight:400,fontFamily:void 0,cssClass:""},formatter:void 0},axisBorder:{show:!1,color:"#e0e0e0",width:1,offsetX:0,offsetY:0},axisTicks:{show:!1,color:"#e0e0e0",width:6,offsetX:0,offsetY:0},title:{text:void 0,rotate:-90,offsetY:0,offsetX:0,style:{color:void 0,fontSize:"11px",fontWeight:900,fontFamily:void 0,cssClass:""}},tooltip:{enabled:!1,offsetX:0},crosshairs:{show:!0,position:"front",stroke:{color:"#b6b6b6",width:1,dashArray:0}}},this.pointAnnotation={id:void 0,x:0,y:null,yAxisIndex:0,seriesIndex:0,mouseEnter:void 0,mouseLeave:void 0,click:void 0,marker:{size:4,fillColor:"#fff",strokeWidth:2,strokeColor:"#333",shape:"circle",offsetX:0,offsetY:0,radius:2,cssClass:""},label:{borderColor:"#c2c2c2",borderWidth:1,borderRadius:2,text:void 0,textAnchor:"middle",offsetX:0,offsetY:0,mouseEnter:void 0,mouseLeave:void 0,click:void 0,style:{background:"#fff",color:void 0,fontSize:"11px",fontFamily:void 0,fontWeight:400,cssClass:"",padding:{left:5,right:5,top:2,bottom:2}}},customSVG:{SVG:void 0,cssClass:void 0,offsetX:0,offsetY:0},image:{path:void 0,width:20,height:20,offsetX:0,offsetY:0}},this.yAxisAnnotation={id:void 0,y:0,y2:null,strokeDashArray:1,fillColor:"#c2c2c2",borderColor:"#c2c2c2",borderWidth:1,opacity:.3,offsetX:0,offsetY:0,width:"100%",yAxisIndex:0,label:{borderColor:"#c2c2c2",borderWidth:1,borderRadius:2,text:void 0,textAnchor:"end",position:"right",offsetX:0,offsetY:-3,mouseEnter:void 0,mouseLeave:void 0,click:void 0,style:{background:"#fff",color:void 0,fontSize:"11px",fontFamily:void 0,fontWeight:400,cssClass:"",padding:{left:5,right:5,top:2,bottom:2}}}},this.xAxisAnnotation={id:void 0,x:0,x2:null,strokeDashArray:1,fillColor:"#c2c2c2",borderColor:"#c2c2c2",borderWidth:1,opacity:.3,offsetX:0,offsetY:0,label:{borderColor:"#c2c2c2",borderWidth:1,borderRadius:2,text:void 0,textAnchor:"middle",orientation:"vertical",position:"top",offsetX:0,offsetY:0,mouseEnter:void 0,mouseLeave:void 0,click:void 0,style:{background:"#fff",color:void 0,fontSize:"11px",fontFamily:void 0,fontWeight:400,cssClass:"",padding:{left:5,right:5,top:2,bottom:2}}}},this.text={x:0,y:0,text:"",textAnchor:"start",foreColor:void 0,fontSize:"13px",fontFamily:void 0,fontWeight:400,appendTo:".apexcharts-annotations",backgroundColor:"transparent",borderColor:"#c2c2c2",borderRadius:0,borderWidth:0,paddingLeft:4,paddingRight:4,paddingTop:2,paddingBottom:2}}return h(t,[{key:"init",value:function(){return{annotations:{position:"front",yaxis:[this.yAxisAnnotation],xaxis:[this.xAxisAnnotation],points:[this.pointAnnotation],texts:[],images:[],shapes:[]},chart:{animations:{enabled:!0,easing:"easeinout",speed:800,animateGradually:{delay:150,enabled:!0},dynamicAnimation:{enabled:!0,speed:350}},background:"transparent",locales:[T],defaultLocale:"en",dropShadow:{enabled:!1,enabledOnSeries:void 0,top:2,left:2,blur:4,color:"#000",opacity:.35},events:{animationEnd:void 0,beforeMount:void 0,mounted:void 0,updated:void 0,click:void 0,mouseMove:void 0,mouseLeave:void 0,xAxisLabelClick:void 0,legendClick:void 0,markerClick:void 0,selection:void 0,dataPointSelection:void 0,dataPointMouseEnter:void 0,dataPointMouseLeave:void 0,beforeZoom:void 0,beforeResetZoom:void 0,zoomed:void 0,scrolled:void 0,brushScrolled:void 0},foreColor:"#373d3f",fontFamily:"Helvetica, Arial, sans-serif",height:"auto",parentHeightOffset:15,redrawOnParentResize:!0,redrawOnWindowResize:!0,id:void 0,group:void 0,offsetX:0,offsetY:0,selection:{enabled:!1,type:"x",fill:{color:"#24292e",opacity:.1},stroke:{width:1,color:"#24292e",opacity:.4,dashArray:3},xaxis:{min:void 0,max:void 0},yaxis:{min:void 0,max:void 0}},sparkline:{enabled:!1},brush:{enabled:!1,autoScaleYaxis:!0,target:void 0},stacked:!1,stackType:"normal",toolbar:{show:!0,offsetX:0,offsetY:0,tools:{download:!0,selection:!0,zoom:!0,zoomin:!0,zoomout:!0,pan:!0,reset:!0,customIcons:[]},export:{csv:{filename:void 0,columnDelimiter:",",headerCategory:"category",headerValue:"value",dateFormatter:function(t){return new Date(t).toDateString()}},png:{filename:void 0},svg:{filename:void 0}},autoSelected:"zoom"},type:"line",width:"100%",zoom:{enabled:!0,type:"x",autoScaleYaxis:!1,zoomedArea:{fill:{color:"#90CAF9",opacity:.4},stroke:{color:"#0D47A1",opacity:.4,width:1}}}},plotOptions:{area:{fillTo:"origin"},bar:{horizontal:!1,columnWidth:"70%",barHeight:"70%",distributed:!1,borderRadius:0,borderRadiusApplication:"around",borderRadiusWhenStacked:"last",rangeBarOverlap:!0,rangeBarGroupRows:!1,colors:{ranges:[],backgroundBarColors:[],backgroundBarOpacity:1,backgroundBarRadius:0},dataLabels:{position:"top",maxItems:100,hideOverflowingLabels:!0,orientation:"horizontal",total:{enabled:!1,formatter:void 0,offsetX:0,offsetY:0,style:{color:"#373d3f",fontSize:"12px",fontFamily:void 0,fontWeight:600}}}},bubble:{zScaling:!0,minBubbleRadius:void 0,maxBubbleRadius:void 0},candlestick:{colors:{upward:"#00B746",downward:"#EF403C"},wick:{useFillColor:!0}},boxPlot:{colors:{upper:"#00E396",lower:"#008FFB"}},heatmap:{radius:2,enableShades:!0,shadeIntensity:.5,reverseNegativeShade:!1,distributed:!1,useFillColorAsStroke:!1,colorScale:{inverse:!1,ranges:[],min:void 0,max:void 0}},treemap:{enableShades:!0,shadeIntensity:.5,distributed:!1,reverseNegativeShade:!1,useFillColorAsStroke:!1,colorScale:{inverse:!1,ranges:[],min:void 0,max:void 0}},radialBar:{inverseOrder:!1,startAngle:0,endAngle:360,offsetX:0,offsetY:0,hollow:{margin:5,size:"50%",background:"transparent",image:void 0,imageWidth:150,imageHeight:150,imageOffsetX:0,imageOffsetY:0,imageClipped:!0,position:"front",dropShadow:{enabled:!1,top:0,left:0,blur:3,color:"#000",opacity:.5}},track:{show:!0,startAngle:void 0,endAngle:void 0,background:"#f2f2f2",strokeWidth:"97%",opacity:1,margin:5,dropShadow:{enabled:!1,top:0,left:0,blur:3,color:"#000",opacity:.5}},dataLabels:{show:!0,name:{show:!0,fontSize:"16px",fontFamily:void 0,fontWeight:600,color:void 0,offsetY:0,formatter:function(t){return t}},value:{show:!0,fontSize:"14px",fontFamily:void 0,fontWeight:400,color:void 0,offsetY:16,formatter:function(t){return t+"%"}},total:{show:!1,label:"Total",fontSize:"16px",fontWeight:600,fontFamily:void 0,color:void 0,formatter:function(t){return t.globals.seriesTotals.reduce((function(t,e){return t+e}),0)/t.globals.series.length+"%"}}}},pie:{customScale:1,offsetX:0,offsetY:0,startAngle:0,endAngle:360,expandOnClick:!0,dataLabels:{offset:0,minAngleToShowLabel:10},donut:{size:"65%",background:"transparent",labels:{show:!1,name:{show:!0,fontSize:"16px",fontFamily:void 0,fontWeight:600,color:void 0,offsetY:-10,formatter:function(t){return t}},value:{show:!0,fontSize:"20px",fontFamily:void 0,fontWeight:400,color:void 0,offsetY:10,formatter:function(t){return t}},total:{show:!1,showAlways:!1,label:"Total",fontSize:"16px",fontWeight:400,fontFamily:void 0,color:void 0,formatter:function(t){return t.globals.seriesTotals.reduce((function(t,e){return t+e}),0)}}}}},polarArea:{rings:{strokeWidth:1,strokeColor:"#e8e8e8"},spokes:{strokeWidth:1,connectorColors:"#e8e8e8"}},radar:{size:void 0,offsetX:0,offsetY:0,polygons:{strokeWidth:1,strokeColors:"#e8e8e8",connectorColors:"#e8e8e8",fill:{colors:void 0}}}},colors:void 0,dataLabels:{enabled:!0,enabledOnSeries:void 0,formatter:function(t){return null!==t?t:""},textAnchor:"middle",distributed:!1,offsetX:0,offsetY:0,style:{fontSize:"12px",fontFamily:void 0,fontWeight:600,colors:void 0},background:{enabled:!0,foreColor:"#fff",borderRadius:2,padding:4,opacity:.9,borderWidth:1,borderColor:"#fff",dropShadow:{enabled:!1,top:1,left:1,blur:1,color:"#000",opacity:.45}},dropShadow:{enabled:!1,top:1,left:1,blur:1,color:"#000",opacity:.45}},fill:{type:"solid",colors:void 0,opacity:.85,gradient:{shade:"dark",type:"horizontal",shadeIntensity:.5,gradientToColors:void 0,inverseColors:!0,opacityFrom:1,opacityTo:1,stops:[0,50,100],colorStops:[]},image:{src:[],width:void 0,height:void 0},pattern:{style:"squares",width:6,height:6,strokeWidth:2}},forecastDataPoints:{count:0,fillOpacity:.5,strokeWidth:void 0,dashArray:4},grid:{show:!0,borderColor:"#e0e0e0",strokeDashArray:0,position:"back",xaxis:{lines:{show:!1}},yaxis:{lines:{show:!0}},row:{colors:void 0,opacity:.5},column:{colors:void 0,opacity:.5},padding:{top:0,right:10,bottom:0,left:12}},labels:[],legend:{show:!0,showForSingleSeries:!1,showForNullSeries:!0,showForZeroSeries:!0,floating:!1,position:"bottom",horizontalAlign:"center",inverseOrder:!1,fontSize:"12px",fontFamily:void 0,fontWeight:400,width:void 0,height:void 0,formatter:void 0,tooltipHoverFormatter:void 0,offsetX:-20,offsetY:4,customLegendItems:[],labels:{colors:void 0,useSeriesColors:!1},markers:{width:12,height:12,strokeWidth:0,fillColors:void 0,strokeColor:"#fff",radius:12,customHTML:void 0,offsetX:0,offsetY:0,onClick:void 0},itemMargin:{horizontal:5,vertical:2},onItemClick:{toggleDataSeries:!0},onItemHover:{highlightDataSeries:!0}},markers:{discrete:[],size:0,colors:void 0,strokeColors:"#fff",strokeWidth:2,strokeOpacity:.9,strokeDashArray:0,fillOpacity:1,shape:"circle",width:8,height:8,radius:2,offsetX:0,offsetY:0,onClick:void 0,onDblClick:void 0,showNullDataPoints:!0,hover:{size:void 0,sizeOffset:3}},noData:{text:void 0,align:"center",verticalAlign:"middle",offsetX:0,offsetY:0,style:{color:void 0,fontSize:"14px",fontFamily:void 0}},responsive:[],series:void 0,states:{normal:{filter:{type:"none",value:0}},hover:{filter:{type:"lighten",value:.1}},active:{allowMultipleDataPointsSelection:!1,filter:{type:"darken",value:.5}}},title:{text:void 0,align:"left",margin:5,offsetX:0,offsetY:0,floating:!1,style:{fontSize:"14px",fontWeight:900,fontFamily:void 0,color:void 0}},subtitle:{text:void 0,align:"left",margin:5,offsetX:0,offsetY:30,floating:!1,style:{fontSize:"12px",fontWeight:400,fontFamily:void 0,color:void 0}},stroke:{show:!0,curve:"smooth",lineCap:"butt",width:2,colors:void 0,dashArray:0,fill:{type:"solid",colors:void 0,opacity:.85,gradient:{shade:"dark",type:"horizontal",shadeIntensity:.5,gradientToColors:void 0,inverseColors:!0,opacityFrom:1,opacityTo:1,stops:[0,50,100],colorStops:[]}}},tooltip:{enabled:!0,enabledOnSeries:void 0,shared:!0,followCursor:!1,intersect:!1,inverseOrder:!1,custom:void 0,fillSeriesColor:!1,theme:"light",cssClass:"",style:{fontSize:"12px",fontFamily:void 0},onDatasetHover:{highlightDataSeries:!1},x:{show:!0,format:"dd MMM",formatter:void 0},y:{formatter:void 0,title:{formatter:function(t){return t?t+": ":""}}},z:{formatter:void 0,title:"Size: "},marker:{show:!0,fillColors:void 0},items:{display:"flex"},fixed:{enabled:!1,position:"topRight",offsetX:0,offsetY:0}},xaxis:{type:"category",categories:[],convertedCatToNumeric:!1,offsetX:0,offsetY:0,overwriteCategories:void 0,labels:{show:!0,rotate:-45,rotateAlways:!1,hideOverlappingLabels:!0,trim:!1,minHeight:void 0,maxHeight:120,showDuplicates:!0,style:{colors:[],fontSize:"12px",fontWeight:400,fontFamily:void 0,cssClass:""},offsetX:0,offsetY:0,format:void 0,formatter:void 0,datetimeUTC:!0,datetimeFormatter:{year:"yyyy",month:"MMM 'yy",day:"dd MMM",hour:"HH:mm",minute:"HH:mm:ss",second:"HH:mm:ss"}},group:{groups:[],style:{colors:[],fontSize:"12px",fontWeight:400,fontFamily:void 0,cssClass:""}},axisBorder:{show:!0,color:"#e0e0e0",width:"100%",height:1,offsetX:0,offsetY:0},axisTicks:{show:!0,color:"#e0e0e0",height:6,offsetX:0,offsetY:0},tickAmount:void 0,tickPlacement:"on",min:void 0,max:void 0,range:void 0,floating:!1,decimalsInFloat:void 0,position:"bottom",title:{text:void 0,offsetX:0,offsetY:0,style:{color:void 0,fontSize:"12px",fontWeight:900,fontFamily:void 0,cssClass:""}},crosshairs:{show:!0,width:1,position:"back",opacity:.9,stroke:{color:"#b6b6b6",width:1,dashArray:3},fill:{type:"solid",color:"#B1B9C4",gradient:{colorFrom:"#D8E3F0",colorTo:"#BED1E6",stops:[0,100],opacityFrom:.4,opacityTo:.5}},dropShadow:{enabled:!1,left:0,top:0,blur:1,opacity:.4}},tooltip:{enabled:!0,offsetY:0,formatter:void 0,style:{fontSize:"12px",fontFamily:void 0}}},yaxis:this.yAxis,theme:{mode:"light",palette:"palette1",monochrome:{enabled:!1,color:"#008FFB",shadeTo:"light",shadeIntensity:.65}}}}}]),t}(),I=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.graphics=new k(this.ctx),this.w.globals.isBarHorizontal&&(this.invertAxis=!0),this.helpers=new S(this),this.xAxisAnnotations=new C(this),this.yAxisAnnotations=new L(this),this.pointsAnnotations=new P(this),this.w.globals.isBarHorizontal&&this.w.config.yaxis[0].reversed&&(this.inversedReversedAxis=!0),this.xDivision=this.w.globals.gridWidth/this.w.globals.dataPoints}return h(t,[{key:"drawAxesAnnotations",value:function(){var t=this.w;if(t.globals.axisCharts){for(var e=this.yAxisAnnotations.drawYAxisAnnotations(),i=this.xAxisAnnotations.drawXAxisAnnotations(),a=this.pointsAnnotations.drawPointAnnotations(),s=t.config.chart.animations.enabled,r=[e,i,a],o=[i.node,e.node,a.node],n=0;n<3;n++)t.globals.dom.elGraphical.add(r[n]),!s||t.globals.resized||t.globals.dataChanged||"scatter"!==t.config.chart.type&&"bubble"!==t.config.chart.type&&t.globals.dataPoints>1&&o[n].classList.add("apexcharts-element-hidden"),t.globals.delayedElements.push({el:o[n],index:0});this.helpers.annotationsBackground()}}},{key:"drawImageAnnos",value:function(){var t=this;this.w.config.annotations.images.map((function(e,i){t.addImage(e,i)}))}},{key:"drawTextAnnos",value:function(){var t=this;this.w.config.annotations.texts.map((function(e,i){t.addText(e,i)}))}},{key:"addXaxisAnnotation",value:function(t,e,i){this.xAxisAnnotations.addXaxisAnnotation(t,e,i)}},{key:"addYaxisAnnotation",value:function(t,e,i){this.yAxisAnnotations.addYaxisAnnotation(t,e,i)}},{key:"addPointAnnotation",value:function(t,e,i){this.pointsAnnotations.addPointAnnotation(t,e,i)}},{key:"addText",value:function(t,e){var i=t.x,a=t.y,s=t.text,r=t.textAnchor,o=t.foreColor,n=t.fontSize,l=t.fontFamily,h=t.fontWeight,c=t.cssClass,d=t.backgroundColor,g=t.borderWidth,u=t.strokeDashArray,f=t.borderRadius,p=t.borderColor,x=t.appendTo,b=void 0===x?".apexcharts-annotations":x,v=t.paddingLeft,m=void 0===v?4:v,y=t.paddingRight,w=void 0===y?4:y,k=t.paddingBottom,A=void 0===k?2:k,S=t.paddingTop,C=void 0===S?2:S,L=this.w,P=this.graphics.drawText({x:i,y:a,text:s,textAnchor:r||"start",fontSize:n||"12px",fontWeight:h||"regular",fontFamily:l||L.config.chart.fontFamily,foreColor:o||L.config.chart.foreColor,cssClass:c}),T=L.globals.dom.baseEl.querySelector(b);T&&T.appendChild(P.node);var M=P.bbox();if(s){var I=this.graphics.drawRect(M.x-m,M.y-C,M.width+m+w,M.height+A+C,f,d||"transparent",1,g,p,u);T.insertBefore(I.node,P.node)}}},{key:"addImage",value:function(t,e){var i=this.w,a=t.path,s=t.x,r=void 0===s?0:s,o=t.y,n=void 0===o?0:o,l=t.width,h=void 0===l?20:l,c=t.height,d=void 0===c?20:c,g=t.appendTo,u=void 0===g?".apexcharts-annotations":g,f=i.globals.dom.Paper.image(a);f.size(h,d).move(r,n);var p=i.globals.dom.baseEl.querySelector(u);return p&&p.appendChild(f.node),f}},{key:"addXaxisAnnotationExternal",value:function(t,e,i){return this.addAnnotationExternal({params:t,pushToMemory:e,context:i,type:"xaxis",contextMethod:i.addXaxisAnnotation}),i}},{key:"addYaxisAnnotationExternal",value:function(t,e,i){return this.addAnnotationExternal({params:t,pushToMemory:e,context:i,type:"yaxis",contextMethod:i.addYaxisAnnotation}),i}},{key:"addPointAnnotationExternal",value:function(t,e,i){return void 0===this.invertAxis&&(this.invertAxis=i.w.globals.isBarHorizontal),this.addAnnotationExternal({params:t,pushToMemory:e,context:i,type:"point",contextMethod:i.addPointAnnotation}),i}},{key:"addAnnotationExternal",value:function(t){var e=t.params,i=t.pushToMemory,a=t.context,s=t.type,r=t.contextMethod,o=a,n=o.w,l=n.globals.dom.baseEl.querySelector(".apexcharts-".concat(s,"-annotations")),h=l.childNodes.length+1,c=new M,d=Object.assign({},"xaxis"===s?c.xAxisAnnotation:"yaxis"===s?c.yAxisAnnotation:c.pointAnnotation),g=m.extend(d,e);switch(s){case"xaxis":this.addXaxisAnnotation(g,l,h);break;case"yaxis":this.addYaxisAnnotation(g,l,h);break;case"point":this.addPointAnnotation(g,l,h)}var u=n.globals.dom.baseEl.querySelector(".apexcharts-".concat(s,"-annotations .apexcharts-").concat(s,"-annotation-label[rel='").concat(h,"']")),f=this.helpers.addBackgroundToAnno(u,g);return f&&l.insertBefore(f.node,u),i&&n.globals.memory.methodsToExec.push({context:o,id:g.id?g.id:m.randomId(),method:r,label:"addAnnotation",params:e}),a}},{key:"clearAnnotations",value:function(t){var e=t.w,i=e.globals.dom.baseEl.querySelectorAll(".apexcharts-yaxis-annotations, .apexcharts-xaxis-annotations, .apexcharts-point-annotations");e.globals.memory.methodsToExec.map((function(t,i){"addText"!==t.label&&"addAnnotation"!==t.label||e.globals.memory.methodsToExec.splice(i,1)})),i=m.listToArray(i),Array.prototype.forEach.call(i,(function(t){for(;t.firstChild;)t.removeChild(t.firstChild)}))}},{key:"removeAnnotation",value:function(t,e){var i=t.w,a=i.globals.dom.baseEl.querySelectorAll(".".concat(e));a&&(i.globals.memory.methodsToExec.map((function(t,a){t.id===e&&i.globals.memory.methodsToExec.splice(a,1)})),Array.prototype.forEach.call(a,(function(t){t.parentElement.removeChild(t)})))}}]),t}(),z=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.months31=[1,3,5,7,8,10,12],this.months30=[2,4,6,9,11],this.daysCntOfYear=[0,31,59,90,120,151,181,212,243,273,304,334]}return h(t,[{key:"isValidDate",value:function(t){return!isNaN(this.parseDate(t))}},{key:"getTimeStamp",value:function(t){return Date.parse(t)?this.w.config.xaxis.labels.datetimeUTC?new Date(new Date(t).toISOString().substr(0,25)).getTime():new Date(t).getTime():t}},{key:"getDate",value:function(t){return this.w.config.xaxis.labels.datetimeUTC?new Date(new Date(t).toUTCString()):new Date(t)}},{key:"parseDate",value:function(t){var e=Date.parse(t);if(!isNaN(e))return this.getTimeStamp(t);var i=Date.parse(t.replace(/-/g,"/").replace(/[a-z]+/gi," "));return this.getTimeStamp(i)}},{key:"parseDateWithTimezone",value:function(t){return Date.parse(t.replace(/-/g,"/").replace(/[a-z]+/gi," "))}},{key:"formatDate",value:function(t,e){var i=this.w.globals.locale,a=this.w.config.xaxis.labels.datetimeUTC,s=["\0"].concat(x(i.months)),r=[""].concat(x(i.shortMonths)),o=[""].concat(x(i.days)),n=[""].concat(x(i.shortDays));function l(t,e){var i=t+"";for(e=e||2;i.length12?g-12:0===g?12:g;e=(e=(e=(e=e.replace(/(^|[^\\])HH+/g,"$1"+l(g))).replace(/(^|[^\\])H/g,"$1"+g)).replace(/(^|[^\\])hh+/g,"$1"+l(u))).replace(/(^|[^\\])h/g,"$1"+u);var f=a?t.getUTCMinutes():t.getMinutes();e=(e=e.replace(/(^|[^\\])mm+/g,"$1"+l(f))).replace(/(^|[^\\])m/g,"$1"+f);var p=a?t.getUTCSeconds():t.getSeconds();e=(e=e.replace(/(^|[^\\])ss+/g,"$1"+l(p))).replace(/(^|[^\\])s/g,"$1"+p);var b=a?t.getUTCMilliseconds():t.getMilliseconds();e=e.replace(/(^|[^\\])fff+/g,"$1"+l(b,3)),b=Math.round(b/10),e=e.replace(/(^|[^\\])ff/g,"$1"+l(b)),b=Math.round(b/10);var v=g<12?"AM":"PM";e=(e=(e=e.replace(/(^|[^\\])f/g,"$1"+b)).replace(/(^|[^\\])TT+/g,"$1"+v)).replace(/(^|[^\\])T/g,"$1"+v.charAt(0));var m=v.toLowerCase();e=(e=e.replace(/(^|[^\\])tt+/g,"$1"+m)).replace(/(^|[^\\])t/g,"$1"+m.charAt(0));var y=-t.getTimezoneOffset(),w=a||!y?"Z":y>0?"+":"-";if(!a){var k=(y=Math.abs(y))%60;w+=l(Math.floor(y/60))+":"+l(k)}e=e.replace(/(^|[^\\])K/g,"$1"+w);var A=(a?t.getUTCDay():t.getDay())+1;return(e=(e=(e=(e=e.replace(new RegExp(o[0],"g"),o[A])).replace(new RegExp(n[0],"g"),n[A])).replace(new RegExp(s[0],"g"),s[c])).replace(new RegExp(r[0],"g"),r[c])).replace(/\\(.)/g,"$1")}},{key:"getTimeUnitsfromTimestamp",value:function(t,e,i){var a=this.w;void 0!==a.config.xaxis.min&&(t=a.config.xaxis.min),void 0!==a.config.xaxis.max&&(e=a.config.xaxis.max);var s=this.getDate(t),r=this.getDate(e),o=this.formatDate(s,"yyyy MM dd HH mm ss fff").split(" "),n=this.formatDate(r,"yyyy MM dd HH mm ss fff").split(" ");return{minMillisecond:parseInt(o[6],10),maxMillisecond:parseInt(n[6],10),minSecond:parseInt(o[5],10),maxSecond:parseInt(n[5],10),minMinute:parseInt(o[4],10),maxMinute:parseInt(n[4],10),minHour:parseInt(o[3],10),maxHour:parseInt(n[3],10),minDate:parseInt(o[2],10),maxDate:parseInt(n[2],10),minMonth:parseInt(o[1],10)-1,maxMonth:parseInt(n[1],10)-1,minYear:parseInt(o[0],10),maxYear:parseInt(n[0],10)}}},{key:"isLeapYear",value:function(t){return t%4==0&&t%100!=0||t%400==0}},{key:"calculcateLastDaysOfMonth",value:function(t,e,i){return this.determineDaysOfMonths(t,e)-i}},{key:"determineDaysOfYear",value:function(t){var e=365;return this.isLeapYear(t)&&(e=366),e}},{key:"determineRemainingDaysOfYear",value:function(t,e,i){var a=this.daysCntOfYear[e]+i;return e>1&&this.isLeapYear()&&a++,a}},{key:"determineDaysOfMonths",value:function(t,e){var i=30;switch(t=m.monthMod(t),!0){case this.months30.indexOf(t)>-1:2===t&&(i=this.isLeapYear(e)?29:28);break;case this.months31.indexOf(t)>-1:default:i=31}return i}}]),t}(),E=function(t){var e,i=t.ctx,a=t.seriesIndex,s=t.dataPointIndex,r=t.y1,o=t.y2,n=t.w,l=n.globals.seriesRangeStart[a][s],h=n.globals.seriesRangeEnd[a][s],c=n.globals.labels[s],d=n.config.series[a].name?n.config.series[a].name:"",g=n.config.tooltip.y.formatter,u=n.config.tooltip.y.title.formatter,f={w:n,seriesIndex:a,dataPointIndex:s,start:l,end:h};"function"==typeof u&&(d=u(d,f)),null!==(e=n.config.series[a].data[s])&&void 0!==e&&e.x&&(c=n.config.series[a].data[s].x+":"),"function"==typeof g&&(c=g(c,f)),Number.isFinite(r)&&Number.isFinite(o)&&(l=r,h=o);var p="",x="",b=n.globals.colors[a];if(void 0===n.config.tooltip.x.formatter)if("datetime"===n.config.xaxis.type){var v=new z(i);p=v.formatDate(v.getDate(l),n.config.tooltip.x.format),x=v.formatDate(v.getDate(h),n.config.tooltip.x.format)}else p=l,x=h;else p=n.config.tooltip.x.formatter(l),x=n.config.tooltip.x.formatter(h);return{start:l,end:h,startVal:p,endVal:x,ylabel:c,color:b,seriesName:d}},X=function(t){var e=t.color,i=t.seriesName,a=t.ylabel,s=t.start,r=t.end,o=t.seriesIndex,n=t.dataPointIndex,l=t.ctx.tooltip.tooltipLabels.getFormatters(o);s=l.yLbFormatter(s),r=l.yLbFormatter(r);var h=l.yLbFormatter(t.w.globals.series[o][n]),c='\n '.concat(s,'\n - \n ').concat(r,"\n ");return'
'+(i||"")+'
'+a+" "+(t.w.globals.comboCharts?"rangeArea"===t.w.config.series[o].type||"rangeBar"===t.w.config.series[o].type?c:"".concat(h,""):c)+"
"},Y=function(){function t(e){n(this,t),this.opts=e}return h(t,[{key:"line",value:function(){return{chart:{animations:{easing:"swing"}},dataLabels:{enabled:!1},stroke:{width:5,curve:"straight"},markers:{size:0,hover:{sizeOffset:6}},xaxis:{crosshairs:{width:1}}}}},{key:"sparkline",value:function(t){return this.opts.yaxis[0].show=!1,this.opts.yaxis[0].title.text="",this.opts.yaxis[0].axisBorder.show=!1,this.opts.yaxis[0].axisTicks.show=!1,this.opts.yaxis[0].floating=!0,m.extend(t,{grid:{show:!1,padding:{left:0,right:0,top:0,bottom:0}},legend:{show:!1},xaxis:{labels:{show:!1},tooltip:{enabled:!1},axisBorder:{show:!1},axisTicks:{show:!1}},chart:{toolbar:{show:!1},zoom:{enabled:!1}},dataLabels:{enabled:!1}})}},{key:"bar",value:function(){return{chart:{stacked:!1,animations:{easing:"swing"}},plotOptions:{bar:{dataLabels:{position:"center"}}},dataLabels:{style:{colors:["#fff"]},background:{enabled:!1}},stroke:{width:0,lineCap:"round"},fill:{opacity:.85},legend:{markers:{shape:"square",radius:2,size:8}},tooltip:{shared:!1,intersect:!0},xaxis:{tooltip:{enabled:!1},tickPlacement:"between",crosshairs:{width:"barWidth",position:"back",fill:{type:"gradient"},dropShadow:{enabled:!1},stroke:{width:0}}}}}},{key:"candlestick",value:function(){var t=this;return{stroke:{width:1,colors:["#333"]},fill:{opacity:1},dataLabels:{enabled:!1},tooltip:{shared:!0,custom:function(e){var i=e.seriesIndex,a=e.dataPointIndex,s=e.w;return t._getBoxTooltip(s,i,a,["Open","High","","Low","Close"],"candlestick")}},states:{active:{filter:{type:"none"}}},xaxis:{crosshairs:{width:1}}}}},{key:"boxPlot",value:function(){var t=this;return{chart:{animations:{dynamicAnimation:{enabled:!1}}},stroke:{width:1,colors:["#24292e"]},dataLabels:{enabled:!1},tooltip:{shared:!0,custom:function(e){var i=e.seriesIndex,a=e.dataPointIndex,s=e.w;return t._getBoxTooltip(s,i,a,["Minimum","Q1","Median","Q3","Maximum"],"boxPlot")}},markers:{size:5,strokeWidth:1,strokeColors:"#111"},xaxis:{crosshairs:{width:1}}}}},{key:"rangeBar",value:function(){return{stroke:{width:0,lineCap:"square"},plotOptions:{bar:{borderRadius:0,dataLabels:{position:"center"}}},dataLabels:{enabled:!1,formatter:function(t,e){e.ctx;var i=e.seriesIndex,a=e.dataPointIndex,s=e.w,r=function(){var t=s.globals.seriesRangeStart[i][a];return s.globals.seriesRangeEnd[i][a]-t};return s.globals.comboCharts?"rangeBar"===s.config.series[i].type||"rangeArea"===s.config.series[i].type?r():t:r()},background:{enabled:!1},style:{colors:["#fff"]}},tooltip:{shared:!1,followCursor:!0,custom:function(t){return t.w.config.plotOptions&&t.w.config.plotOptions.bar&&t.w.config.plotOptions.bar.horizontal?function(t){var e=E(t),i=e.color,a=e.seriesName,s=e.ylabel,o=e.startVal,n=e.endVal;return X(r(r({},t),{},{color:i,seriesName:a,ylabel:s,start:o,end:n}))}(t):function(t){var e=E(t),i=e.color,a=e.seriesName,s=e.ylabel,o=e.start,n=e.end;return X(r(r({},t),{},{color:i,seriesName:a,ylabel:s,start:o,end:n}))}(t)}},xaxis:{tickPlacement:"between",tooltip:{enabled:!1},crosshairs:{stroke:{width:0}}}}}},{key:"area",value:function(){return{stroke:{width:4,fill:{type:"solid",gradient:{inverseColors:!1,shade:"light",type:"vertical",opacityFrom:.65,opacityTo:.5,stops:[0,100,100]}}},fill:{type:"gradient",gradient:{inverseColors:!1,shade:"light",type:"vertical",opacityFrom:.65,opacityTo:.5,stops:[0,100,100]}},markers:{size:0,hover:{sizeOffset:6}},tooltip:{followCursor:!1}}}},{key:"rangeArea",value:function(){return{stroke:{curve:"straight",width:0},fill:{type:"solid",opacity:.6},markers:{size:0},states:{hover:{filter:{type:"none"}},active:{filter:{type:"none"}}},tooltip:{intersect:!1,shared:!0,followCursor:!0,custom:function(t){return function(t){var e=E(t),i=e.color,a=e.seriesName,s=e.ylabel,o=e.start,n=e.end;return X(r(r({},t),{},{color:i,seriesName:a,ylabel:s,start:o,end:n}))}(t)}}}}},{key:"brush",value:function(t){return m.extend(t,{chart:{toolbar:{autoSelected:"selection",show:!1},zoom:{enabled:!1}},dataLabels:{enabled:!1},stroke:{width:1},tooltip:{enabled:!1},xaxis:{tooltip:{enabled:!1}}})}},{key:"stacked100",value:function(t){t.dataLabels=t.dataLabels||{},t.dataLabels.formatter=t.dataLabels.formatter||void 0;var e=t.dataLabels.formatter;return t.yaxis.forEach((function(e,i){t.yaxis[i].min=0,t.yaxis[i].max=100})),"bar"===t.chart.type&&(t.dataLabels.formatter=e||function(t){return"number"==typeof t&&t?t.toFixed(0)+"%":t}),t}},{key:"convertCatToNumeric",value:function(t){return t.xaxis.convertedCatToNumeric=!0,t}},{key:"convertCatToNumericXaxis",value:function(t,e,i){t.xaxis.type="numeric",t.xaxis.labels=t.xaxis.labels||{},t.xaxis.labels.formatter=t.xaxis.labels.formatter||function(t){return m.isNumber(t)?Math.floor(t):t};var a=t.xaxis.labels.formatter,s=t.xaxis.categories&&t.xaxis.categories.length?t.xaxis.categories:t.labels;return i&&i.length&&(s=i.map((function(t){return Array.isArray(t)?t:String(t)}))),s&&s.length&&(t.xaxis.labels.formatter=function(t){return m.isNumber(t)?a(s[Math.floor(t)-1]):a(t)}),t.xaxis.categories=[],t.labels=[],t.xaxis.tickAmount=t.xaxis.tickAmount||"dataPoints",t}},{key:"bubble",value:function(){return{dataLabels:{style:{colors:["#fff"]}},tooltip:{shared:!1,intersect:!0},xaxis:{crosshairs:{width:0}},fill:{type:"solid",gradient:{shade:"light",inverse:!0,shadeIntensity:.55,opacityFrom:.4,opacityTo:.8}}}}},{key:"scatter",value:function(){return{dataLabels:{enabled:!1},tooltip:{shared:!1,intersect:!0},markers:{size:6,strokeWidth:1,hover:{sizeOffset:2}}}}},{key:"heatmap",value:function(){return{chart:{stacked:!1},fill:{opacity:1},dataLabels:{style:{colors:["#fff"]}},stroke:{colors:["#fff"]},tooltip:{followCursor:!0,marker:{show:!1},x:{show:!1}},legend:{position:"top",markers:{shape:"square",size:10,offsetY:2}},grid:{padding:{right:20}}}}},{key:"treemap",value:function(){return{chart:{zoom:{enabled:!1}},dataLabels:{style:{fontSize:14,fontWeight:600,colors:["#fff"]}},stroke:{show:!0,width:2,colors:["#fff"]},legend:{show:!1},fill:{gradient:{stops:[0,100]}},tooltip:{followCursor:!0,x:{show:!1}},grid:{padding:{left:0,right:0}},xaxis:{crosshairs:{show:!1},tooltip:{enabled:!1}}}}},{key:"pie",value:function(){return{chart:{toolbar:{show:!1}},plotOptions:{pie:{donut:{labels:{show:!1}}}},dataLabels:{formatter:function(t){return t.toFixed(1)+"%"},style:{colors:["#fff"]},background:{enabled:!1},dropShadow:{enabled:!0}},stroke:{colors:["#fff"]},fill:{opacity:1,gradient:{shade:"light",stops:[0,100]}},tooltip:{theme:"dark",fillSeriesColor:!0},legend:{position:"right"}}}},{key:"donut",value:function(){return{chart:{toolbar:{show:!1}},dataLabels:{formatter:function(t){return t.toFixed(1)+"%"},style:{colors:["#fff"]},background:{enabled:!1},dropShadow:{enabled:!0}},stroke:{colors:["#fff"]},fill:{opacity:1,gradient:{shade:"light",shadeIntensity:.35,stops:[80,100],opacityFrom:1,opacityTo:1}},tooltip:{theme:"dark",fillSeriesColor:!0},legend:{position:"right"}}}},{key:"polarArea",value:function(){return this.opts.yaxis[0].tickAmount=this.opts.yaxis[0].tickAmount?this.opts.yaxis[0].tickAmount:6,{chart:{toolbar:{show:!1}},dataLabels:{formatter:function(t){return t.toFixed(1)+"%"},enabled:!1},stroke:{show:!0,width:2},fill:{opacity:.7},tooltip:{theme:"dark",fillSeriesColor:!0},legend:{position:"right"}}}},{key:"radar",value:function(){return this.opts.yaxis[0].labels.offsetY=this.opts.yaxis[0].labels.offsetY?this.opts.yaxis[0].labels.offsetY:6,{dataLabels:{enabled:!1,style:{fontSize:"11px"}},stroke:{width:2},markers:{size:3,strokeWidth:1,strokeOpacity:1},fill:{opacity:.2},tooltip:{shared:!1,intersect:!0,followCursor:!0},grid:{show:!1},xaxis:{labels:{formatter:function(t){return t},style:{colors:["#a8a8a8"],fontSize:"11px"}},tooltip:{enabled:!1},crosshairs:{show:!1}}}}},{key:"radialBar",value:function(){return{chart:{animations:{dynamicAnimation:{enabled:!0,speed:800}},toolbar:{show:!1}},fill:{gradient:{shade:"dark",shadeIntensity:.4,inverseColors:!1,type:"diagonal2",opacityFrom:1,opacityTo:1,stops:[70,98,100]}},legend:{show:!1,position:"right"},tooltip:{enabled:!1,fillSeriesColor:!0}}}},{key:"_getBoxTooltip",value:function(t,e,i,a,s){var r=t.globals.seriesCandleO[e][i],o=t.globals.seriesCandleH[e][i],n=t.globals.seriesCandleM[e][i],l=t.globals.seriesCandleL[e][i],h=t.globals.seriesCandleC[e][i];return t.config.series[e].type&&t.config.series[e].type!==s?'
\n '.concat(t.config.series[e].name?t.config.series[e].name:"series-"+(e+1),": ").concat(t.globals.series[e][i],"\n
"):'
')+"
".concat(a[0],': ')+r+"
"+"
".concat(a[1],': ')+o+"
"+(n?"
".concat(a[2],': ')+n+"
":"")+"
".concat(a[3],': ')+l+"
"+"
".concat(a[4],': ')+h+"
"}}]),t}(),F=function(){function t(e){n(this,t),this.opts=e}return h(t,[{key:"init",value:function(t){var e=t.responsiveOverride,i=this.opts,a=new M,s=new Y(i);this.chartType=i.chart.type,"histogram"===this.chartType&&(i.chart.type="bar",i=m.extend({plotOptions:{bar:{columnWidth:"99.99%"}}},i)),i=this.extendYAxis(i),i=this.extendAnnotations(i);var r=a.init(),n={};if(i&&"object"===o(i)){var l={};l=-1!==["line","area","bar","candlestick","boxPlot","rangeBar","rangeArea","histogram","bubble","scatter","heatmap","treemap","pie","polarArea","donut","radar","radialBar"].indexOf(i.chart.type)?s[i.chart.type]():s.line(),i.chart.brush&&i.chart.brush.enabled&&(l=s.brush(l)),i.chart.stacked&&"100%"===i.chart.stackType&&(i=s.stacked100(i)),this.checkForDarkTheme(window.Apex),this.checkForDarkTheme(i),i.xaxis=i.xaxis||window.Apex.xaxis||{},e||(i.xaxis.convertedCatToNumeric=!1),((i=this.checkForCatToNumericXAxis(this.chartType,l,i)).chart.sparkline&&i.chart.sparkline.enabled||window.Apex.chart&&window.Apex.chart.sparkline&&window.Apex.chart.sparkline.enabled)&&(l=s.sparkline(l)),n=m.extend(r,l)}var h=m.extend(n,window.Apex);return r=m.extend(h,i),this.handleUserInputErrors(r)}},{key:"checkForCatToNumericXAxis",value:function(t,e,i){var a=new Y(i),s=("bar"===t||"boxPlot"===t)&&i.plotOptions&&i.plotOptions.bar&&i.plotOptions.bar.horizontal,r="pie"===t||"polarArea"===t||"donut"===t||"radar"===t||"radialBar"===t||"heatmap"===t,o="datetime"!==i.xaxis.type&&"numeric"!==i.xaxis.type,n=i.xaxis.tickPlacement?i.xaxis.tickPlacement:e.xaxis&&e.xaxis.tickPlacement;return s||r||!o||"between"===n||(i=a.convertCatToNumeric(i)),i}},{key:"extendYAxis",value:function(t,e){var i=new M;(void 0===t.yaxis||!t.yaxis||Array.isArray(t.yaxis)&&0===t.yaxis.length)&&(t.yaxis={}),t.yaxis.constructor!==Array&&window.Apex.yaxis&&window.Apex.yaxis.constructor!==Array&&(t.yaxis=m.extend(t.yaxis,window.Apex.yaxis)),t.yaxis.constructor!==Array?t.yaxis=[m.extend(i.yAxis,t.yaxis)]:t.yaxis=m.extendArray(t.yaxis,i.yAxis);var a=!1;t.yaxis.forEach((function(t){t.logarithmic&&(a=!0)}));var s=t.series;return e&&!s&&(s=e.config.series),a&&s.length!==t.yaxis.length&&s.length&&(t.yaxis=s.map((function(e,a){if(e.name||(s[a].name="series-".concat(a+1)),t.yaxis[a])return t.yaxis[a].seriesName=s[a].name,t.yaxis[a];var r=m.extend(i.yAxis,t.yaxis[0]);return r.show=!1,r}))),a&&s.length>1&&s.length!==t.yaxis.length&&console.warn("A multi-series logarithmic chart should have equal number of series and y-axes. Please make sure to equalize both."),t}},{key:"extendAnnotations",value:function(t){return void 0===t.annotations&&(t.annotations={},t.annotations.yaxis=[],t.annotations.xaxis=[],t.annotations.points=[]),t=this.extendYAxisAnnotations(t),t=this.extendXAxisAnnotations(t),this.extendPointAnnotations(t)}},{key:"extendYAxisAnnotations",value:function(t){var e=new M;return t.annotations.yaxis=m.extendArray(void 0!==t.annotations.yaxis?t.annotations.yaxis:[],e.yAxisAnnotation),t}},{key:"extendXAxisAnnotations",value:function(t){var e=new M;return t.annotations.xaxis=m.extendArray(void 0!==t.annotations.xaxis?t.annotations.xaxis:[],e.xAxisAnnotation),t}},{key:"extendPointAnnotations",value:function(t){var e=new M;return t.annotations.points=m.extendArray(void 0!==t.annotations.points?t.annotations.points:[],e.pointAnnotation),t}},{key:"checkForDarkTheme",value:function(t){t.theme&&"dark"===t.theme.mode&&(t.tooltip||(t.tooltip={}),"light"!==t.tooltip.theme&&(t.tooltip.theme="dark"),t.chart.foreColor||(t.chart.foreColor="#f6f7f8"),t.chart.background||(t.chart.background="#424242"),t.theme.palette||(t.theme.palette="palette4"))}},{key:"handleUserInputErrors",value:function(t){var e=t;if(e.tooltip.shared&&e.tooltip.intersect)throw new Error("tooltip.shared cannot be enabled when tooltip.intersect is true. Turn off any other option by setting it to false.");if("bar"===e.chart.type&&e.plotOptions.bar.horizontal){if(e.yaxis.length>1)throw new Error("Multiple Y Axis for bars are not supported. Switch to column chart by setting plotOptions.bar.horizontal=false");e.yaxis[0].reversed&&(e.yaxis[0].opposite=!0),e.xaxis.tooltip.enabled=!1,e.yaxis[0].tooltip.enabled=!1,e.chart.zoom.enabled=!1}return"bar"!==e.chart.type&&"rangeBar"!==e.chart.type||e.tooltip.shared&&"barWidth"===e.xaxis.crosshairs.width&&e.series.length>1&&(e.xaxis.crosshairs.width="tickWidth"),"candlestick"!==e.chart.type&&"boxPlot"!==e.chart.type||e.yaxis[0].reversed&&(console.warn("Reversed y-axis in ".concat(e.chart.type," chart is not supported.")),e.yaxis[0].reversed=!1),e}}]),t}(),R=function(){function t(){n(this,t)}return h(t,[{key:"initGlobalVars",value:function(t){t.series=[],t.seriesCandleO=[],t.seriesCandleH=[],t.seriesCandleM=[],t.seriesCandleL=[],t.seriesCandleC=[],t.seriesRangeStart=[],t.seriesRangeEnd=[],t.seriesRange=[],t.seriesPercent=[],t.seriesGoals=[],t.seriesX=[],t.seriesZ=[],t.seriesNames=[],t.seriesTotals=[],t.seriesLog=[],t.seriesColors=[],t.stackedSeriesTotals=[],t.seriesXvalues=[],t.seriesYvalues=[],t.labels=[],t.hasGroups=!1,t.groups=[],t.categoryLabels=[],t.timescaleLabels=[],t.noLabelsProvided=!1,t.resizeTimer=null,t.selectionResizeTimer=null,t.delayedElements=[],t.pointsArray=[],t.dataLabelsRects=[],t.isXNumeric=!1,t.xaxisLabelsCount=0,t.skipLastTimelinelabel=!1,t.skipFirstTimelinelabel=!1,t.isDataXYZ=!1,t.isMultiLineX=!1,t.isMultipleYAxis=!1,t.maxY=-Number.MAX_VALUE,t.minY=Number.MIN_VALUE,t.minYArr=[],t.maxYArr=[],t.maxX=-Number.MAX_VALUE,t.minX=Number.MAX_VALUE,t.initialMaxX=-Number.MAX_VALUE,t.initialMinX=Number.MAX_VALUE,t.maxDate=0,t.minDate=Number.MAX_VALUE,t.minZ=Number.MAX_VALUE,t.maxZ=-Number.MAX_VALUE,t.minXDiff=Number.MAX_VALUE,t.yAxisScale=[],t.xAxisScale=null,t.xAxisTicksPositions=[],t.yLabelsCoords=[],t.yTitleCoords=[],t.barPadForNumericAxis=0,t.padHorizontal=0,t.xRange=0,t.yRange=[],t.zRange=0,t.dataPoints=0,t.xTickAmount=0}},{key:"globalVars",value:function(t){return{chartID:null,cuid:null,events:{beforeMount:[],mounted:[],updated:[],clicked:[],selection:[],dataPointSelection:[],zoomed:[],scrolled:[]},colors:[],clientX:null,clientY:null,fill:{colors:[]},stroke:{colors:[]},dataLabels:{style:{colors:[]}},radarPolygons:{fill:{colors:[]}},markers:{colors:[],size:t.markers.size,largestSize:0},animationEnded:!1,isTouchDevice:"ontouchstart"in window||navigator.msMaxTouchPoints,isDirty:!1,isExecCalled:!1,initialConfig:null,initialSeries:[],lastXAxis:[],lastYAxis:[],columnSeries:null,labels:[],timescaleLabels:[],noLabelsProvided:!1,allSeriesCollapsed:!1,collapsedSeries:[],collapsedSeriesIndices:[],ancillaryCollapsedSeries:[],ancillaryCollapsedSeriesIndices:[],risingSeries:[],dataFormatXNumeric:!1,capturedSeriesIndex:-1,capturedDataPointIndex:-1,selectedDataPoints:[],goldenPadding:35,invalidLogScale:!1,ignoreYAxisIndexes:[],yAxisSameScaleIndices:[],maxValsInArrayIndex:0,radialSize:0,selection:void 0,zoomEnabled:"zoom"===t.chart.toolbar.autoSelected&&t.chart.toolbar.tools.zoom&&t.chart.zoom.enabled,panEnabled:"pan"===t.chart.toolbar.autoSelected&&t.chart.toolbar.tools.pan,selectionEnabled:"selection"===t.chart.toolbar.autoSelected&&t.chart.toolbar.tools.selection,yaxis:null,mousedown:!1,lastClientPosition:{},visibleXRange:void 0,yValueDecimal:0,total:0,SVGNS:"http://www.w3.org/2000/svg",svgWidth:0,svgHeight:0,noData:!1,locale:{},dom:{},memory:{methodsToExec:[]},shouldAnimate:!0,skipLastTimelinelabel:!1,skipFirstTimelinelabel:!1,delayedElements:[],axisCharts:!0,isDataXYZ:!1,resized:!1,resizeTimer:null,comboCharts:!1,dataChanged:!1,previousPaths:[],allSeriesHasEqualX:!0,pointsArray:[],dataLabelsRects:[],lastDrawnDataLabelsIndexes:[],hasNullValues:!1,easing:null,zoomed:!1,gridWidth:0,gridHeight:0,rotateXLabels:!1,defaultLabels:!1,xLabelFormatter:void 0,yLabelFormatters:[],xaxisTooltipFormatter:void 0,ttKeyFormatter:void 0,ttVal:void 0,ttZFormatter:void 0,LINE_HEIGHT_RATIO:1.618,xAxisLabelsHeight:0,xAxisGroupLabelsHeight:0,xAxisLabelsWidth:0,yAxisLabelsWidth:0,scaleX:1,scaleY:1,translateX:0,translateY:0,translateYAxisX:[],yAxisWidths:[],translateXAxisY:0,translateXAxisX:0,tooltip:null}}},{key:"init",value:function(t){var e=this.globalVars(t);return this.initGlobalVars(e),e.initialConfig=m.extend({},t),e.initialSeries=m.clone(t.series),e.lastXAxis=m.clone(e.initialConfig.xaxis),e.lastYAxis=m.clone(e.initialConfig.yaxis),e}}]),t}(),D=function(){function t(e){n(this,t),this.opts=e}return h(t,[{key:"init",value:function(){var t=new F(this.opts).init({responsiveOverride:!1});return{config:t,globals:(new R).init(t)}}}]),t}(),H=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.opts=null,this.seriesIndex=0}return h(t,[{key:"clippedImgArea",value:function(t){var e=this.w,i=e.config,a=parseInt(e.globals.gridWidth,10),s=parseInt(e.globals.gridHeight,10),r=a>s?a:s,o=t.image,n=0,l=0;void 0===t.width&&void 0===t.height?void 0!==i.fill.image.width&&void 0!==i.fill.image.height?(n=i.fill.image.width+1,l=i.fill.image.height):(n=r+1,l=r):(n=t.width,l=t.height);var h=document.createElementNS(e.globals.SVGNS,"pattern");k.setAttrs(h,{id:t.patternID,patternUnits:t.patternUnits?t.patternUnits:"userSpaceOnUse",width:n+"px",height:l+"px"});var c=document.createElementNS(e.globals.SVGNS,"image");h.appendChild(c),c.setAttributeNS(window.SVG.xlink,"href",o),k.setAttrs(c,{x:0,y:0,preserveAspectRatio:"none",width:n+"px",height:l+"px"}),c.style.opacity=t.opacity,e.globals.dom.elDefs.node.appendChild(h)}},{key:"getSeriesIndex",value:function(t){var e=this.w;return("bar"===e.config.chart.type||"rangeBar"===e.config.chart.type)&&e.config.plotOptions.bar.distributed||"heatmap"===e.config.chart.type||"treemap"===e.config.chart.type?this.seriesIndex=t.seriesNumber:this.seriesIndex=t.seriesNumber%e.globals.series.length,this.seriesIndex}},{key:"fillPath",value:function(t){var e=this.w;this.opts=t;var i,a,s,r=this.w.config;this.seriesIndex=this.getSeriesIndex(t);var o=this.getFillColors()[this.seriesIndex];void 0!==e.globals.seriesColors[this.seriesIndex]&&(o=e.globals.seriesColors[this.seriesIndex]),"function"==typeof o&&(o=o({seriesIndex:this.seriesIndex,dataPointIndex:t.dataPointIndex,value:t.value,w:e}));var n=t.fillType?t.fillType:this.getFillType(this.seriesIndex),l=Array.isArray(r.fill.opacity)?r.fill.opacity[this.seriesIndex]:r.fill.opacity;t.color&&(o=t.color);var h=o;if(-1===o.indexOf("rgb")?o.length<9&&(h=m.hexToRgba(o,l)):o.indexOf("rgba")>-1&&(l=m.getOpacityFromRGBA(o)),t.opacity&&(l=t.opacity),"pattern"===n&&(a=this.handlePatternFill({fillConfig:t.fillConfig,patternFill:a,fillColor:o,fillOpacity:l,defaultColor:h})),"gradient"===n&&(s=this.handleGradientFill({fillConfig:t.fillConfig,fillColor:o,fillOpacity:l,i:this.seriesIndex})),"image"===n){var c=r.fill.image.src,d=t.patternID?t.patternID:"";this.clippedImgArea({opacity:l,image:Array.isArray(c)?t.seriesNumber-1&&(u=m.getOpacityFromRGBA(g));var f=void 0===o.gradient.opacityTo?i:Array.isArray(o.gradient.opacityTo)?o.gradient.opacityTo[s]:o.gradient.opacityTo;if(void 0===o.gradient.gradientToColors||0===o.gradient.gradientToColors.length)n="dark"===o.gradient.shade?c.shadeColor(-1*parseFloat(o.gradient.shadeIntensity),e.indexOf("rgb")>-1?m.rgb2hex(e):e):c.shadeColor(parseFloat(o.gradient.shadeIntensity),e.indexOf("rgb")>-1?m.rgb2hex(e):e);else if(o.gradient.gradientToColors[l.seriesNumber]){var p=o.gradient.gradientToColors[l.seriesNumber];n=p,p.indexOf("rgba")>-1&&(f=m.getOpacityFromRGBA(p))}else n=e;if(o.gradient.gradientFrom&&(g=o.gradient.gradientFrom),o.gradient.gradientTo&&(n=o.gradient.gradientTo),o.gradient.inverseColors){var x=g;g=n,n=x}return g.indexOf("rgb")>-1&&(g=m.rgb2hex(g)),n.indexOf("rgb")>-1&&(n=m.rgb2hex(n)),h.drawGradient(d,g,n,u,f,l.size,o.gradient.stops,o.gradient.colorStops,s)}}]),t}(),O=function(){function t(e,i){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"setGlobalMarkerSize",value:function(){var t=this.w;if(t.globals.markers.size=Array.isArray(t.config.markers.size)?t.config.markers.size:[t.config.markers.size],t.globals.markers.size.length>0){if(t.globals.markers.size.length4&&void 0!==arguments[4]&&arguments[4],o=this.w,n=e,l=t,h=null,c=new k(this.ctx),d=o.config.markers.discrete&&o.config.markers.discrete.length;if((o.globals.markers.size[e]>0||r||d)&&(h=c.group({class:r||d?"":"apexcharts-series-markers"})).attr("clip-path","url(#gridRectMarkerMask".concat(o.globals.cuid,")")),Array.isArray(l.x))for(var g=0;g0:o.config.markers.size>0;if(p||r||d){m.isNumber(l.y[g])?f+=" w".concat(m.randomId()):f="apexcharts-nullpoint";var x=this.getMarkerConfig({cssClass:f,seriesIndex:e,dataPointIndex:u});o.config.series[n].data[u]&&(o.config.series[n].data[u].fillColor&&(x.pointFillColor=o.config.series[n].data[u].fillColor),o.config.series[n].data[u].strokeColor&&(x.pointStrokeColor=o.config.series[n].data[u].strokeColor)),a&&(x.pSize=a),(s=c.drawMarker(l.x[g],l.y[g],x)).attr("rel",u),s.attr("j",u),s.attr("index",e),s.node.setAttribute("default-marker-size",x.pSize);var b=new w(this.ctx);b.setSelectionFilter(s,e,u),this.addEvents(s),h&&h.add(s)}else void 0===o.globals.pointsArray[e]&&(o.globals.pointsArray[e]=[]),o.globals.pointsArray[e].push([l.x[g],l.y[g]])}return h}},{key:"getMarkerConfig",value:function(t){var e=t.cssClass,i=t.seriesIndex,a=t.dataPointIndex,s=void 0===a?null:a,r=t.finishRadius,o=void 0===r?null:r,n=this.w,l=this.getMarkerStyle(i),h=n.globals.markers.size[i],c=n.config.markers;return null!==s&&c.discrete.length&&c.discrete.map((function(t){t.seriesIndex===i&&t.dataPointIndex===s&&(l.pointStrokeColor=t.strokeColor,l.pointFillColor=t.fillColor,h=t.size,l.pointShape=t.shape)})),{pSize:null===o?h:o,pRadius:c.radius,width:Array.isArray(c.width)?c.width[i]:c.width,height:Array.isArray(c.height)?c.height[i]:c.height,pointStrokeWidth:Array.isArray(c.strokeWidth)?c.strokeWidth[i]:c.strokeWidth,pointStrokeColor:l.pointStrokeColor,pointFillColor:l.pointFillColor,shape:l.pointShape||(Array.isArray(c.shape)?c.shape[i]:c.shape),class:e,pointStrokeOpacity:Array.isArray(c.strokeOpacity)?c.strokeOpacity[i]:c.strokeOpacity,pointStrokeDashArray:Array.isArray(c.strokeDashArray)?c.strokeDashArray[i]:c.strokeDashArray,pointFillOpacity:Array.isArray(c.fillOpacity)?c.fillOpacity[i]:c.fillOpacity,seriesIndex:i}}},{key:"addEvents",value:function(t){var e=this.w,i=new k(this.ctx);t.node.addEventListener("mouseenter",i.pathMouseEnter.bind(this.ctx,t)),t.node.addEventListener("mouseleave",i.pathMouseLeave.bind(this.ctx,t)),t.node.addEventListener("mousedown",i.pathMouseDown.bind(this.ctx,t)),t.node.addEventListener("click",e.config.markers.onClick),t.node.addEventListener("dblclick",e.config.markers.onDblClick),t.node.addEventListener("touchstart",i.pathMouseDown.bind(this.ctx,t),{passive:!0})}},{key:"getMarkerStyle",value:function(t){var e=this.w,i=e.globals.markers.colors,a=e.config.markers.strokeColor||e.config.markers.strokeColors;return{pointStrokeColor:Array.isArray(a)?a[t]:a,pointFillColor:Array.isArray(i)?i[t]:i}}}]),t}(),N=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.initialAnim=this.w.config.chart.animations.enabled,this.dynamicAnim=this.initialAnim&&this.w.config.chart.animations.dynamicAnimation.enabled}return h(t,[{key:"draw",value:function(t,e,i){var a=this.w,s=new k(this.ctx),r=i.realIndex,o=i.pointsPos,n=i.zRatio,l=i.elParent,h=s.group({class:"apexcharts-series-markers apexcharts-series-".concat(a.config.chart.type)});if(h.attr("clip-path","url(#gridRectMarkerMask".concat(a.globals.cuid,")")),Array.isArray(o.x))for(var c=0;cp.maxBubbleRadius&&(f=p.maxBubbleRadius)}a.config.chart.animations.enabled||(u=f);var x=o.x[c],b=o.y[c];if(u=u||0,null!==b&&void 0!==a.globals.series[r][d]||(g=!1),g){var v=this.drawPoint(x,b,u,f,r,d,e);h.add(v)}l.add(h)}}},{key:"drawPoint",value:function(t,e,i,a,s,r,o){var n=this.w,l=s,h=new y(this.ctx),c=new w(this.ctx),d=new H(this.ctx),g=new O(this.ctx),u=new k(this.ctx),f=g.getMarkerConfig({cssClass:"apexcharts-marker",seriesIndex:l,dataPointIndex:r,finishRadius:"bubble"===n.config.chart.type||n.globals.comboCharts&&n.config.series[s]&&"bubble"===n.config.series[s].type?a:null});a=f.pSize;var p,x=d.fillPath({seriesNumber:s,dataPointIndex:r,color:f.pointFillColor,patternUnits:"objectBoundingBox",value:n.globals.series[s][o]});if("circle"===f.shape?p=u.drawCircle(i):"square"!==f.shape&&"rect"!==f.shape||(p=u.drawRect(0,0,f.width-f.pointStrokeWidth/2,f.height-f.pointStrokeWidth/2,f.pRadius)),n.config.series[l].data[r]&&n.config.series[l].data[r].fillColor&&(x=n.config.series[l].data[r].fillColor),p.attr({x:t-f.width/2-f.pointStrokeWidth/2,y:e-f.height/2-f.pointStrokeWidth/2,cx:t,cy:e,fill:x,"fill-opacity":f.pointFillOpacity,stroke:f.pointStrokeColor,r:a,"stroke-width":f.pointStrokeWidth,"stroke-dasharray":f.pointStrokeDashArray,"stroke-opacity":f.pointStrokeOpacity}),n.config.chart.dropShadow.enabled){var b=n.config.chart.dropShadow;c.dropShadow(p,b,s)}if(!this.initialAnim||n.globals.dataChanged||n.globals.resized)n.globals.animationEnded=!0;else{var v=n.config.chart.animations.speed;h.animateMarker(p,0,"circle"===f.shape?a:{width:f.width,height:f.height},v,n.globals.easing,(function(){window.setTimeout((function(){h.animationCompleted(p)}),100)}))}if(n.globals.dataChanged&&"circle"===f.shape)if(this.dynamicAnim){var m,A,S,C,L=n.config.chart.animations.dynamicAnimation.speed;null!=(C=n.globals.previousPaths[s]&&n.globals.previousPaths[s][o])&&(m=C.x,A=C.y,S=void 0!==C.r?C.r:a);for(var P=0;Pn.globals.gridHeight+d&&(e=n.globals.gridHeight+d/2),void 0===n.globals.dataLabelsRects[a]&&(n.globals.dataLabelsRects[a]=[]),n.globals.dataLabelsRects[a].push({x:t,y:e,width:c,height:d});var g=n.globals.dataLabelsRects[a].length-2,u=void 0!==n.globals.lastDrawnDataLabelsIndexes[a]?n.globals.lastDrawnDataLabelsIndexes[a][n.globals.lastDrawnDataLabelsIndexes[a].length-1]:0;if(void 0!==n.globals.dataLabelsRects[a][g]){var f=n.globals.dataLabelsRects[a][u];(t>f.x+f.width+2||e>f.y+f.height+2||t+ce.globals.gridWidth+p.textRects.width+10)&&(n="");var x=e.globals.dataLabels.style.colors[r];(("bar"===e.config.chart.type||"rangeBar"===e.config.chart.type)&&e.config.plotOptions.bar.distributed||e.config.dataLabels.distributed)&&(x=e.globals.dataLabels.style.colors[o]),"function"==typeof x&&(x=x({series:e.globals.series,seriesIndex:r,dataPointIndex:o,w:e})),g&&(x=g);var b=d.offsetX,v=d.offsetY;if("bar"!==e.config.chart.type&&"rangeBar"!==e.config.chart.type||(b=0,v=0),p.drawnextLabel){var m=i.drawText({width:100,height:parseInt(d.style.fontSize,10),x:a+b,y:s+v,foreColor:x,textAnchor:l||d.textAnchor,text:n,fontSize:h||d.style.fontSize,fontFamily:d.style.fontFamily,fontWeight:d.style.fontWeight||"normal"});if(m.attr({class:"apexcharts-datalabel",cx:a,cy:s}),d.dropShadow.enabled){var y=d.dropShadow;new w(this.ctx).dropShadow(m,y)}c.add(m),void 0===e.globals.lastDrawnDataLabelsIndexes[r]&&(e.globals.lastDrawnDataLabelsIndexes[r]=[]),e.globals.lastDrawnDataLabelsIndexes[r].push(o)}}}},{key:"addBackgroundToDataLabel",value:function(t,e){var i=this.w,a=i.config.dataLabels.background,s=a.padding,r=a.padding/2,o=e.width,n=e.height,l=new k(this.ctx).drawRect(e.x-s,e.y-r/2,o+2*s,n+r,a.borderRadius,"transparent"===i.config.chart.background?"#fff":i.config.chart.background,a.opacity,a.borderWidth,a.borderColor);return a.dropShadow.enabled&&new w(this.ctx).dropShadow(l,a.dropShadow),l}},{key:"dataLabelsBackground",value:function(){var t=this.w;if("bubble"!==t.config.chart.type)for(var e=t.globals.dom.baseEl.querySelectorAll(".apexcharts-datalabels text"),i=0;i0&&void 0!==arguments[0])||arguments[0],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=this.w,s=m.clone(a.globals.initialSeries);a.globals.previousPaths=[],i?(a.globals.collapsedSeries=[],a.globals.ancillaryCollapsedSeries=[],a.globals.collapsedSeriesIndices=[],a.globals.ancillaryCollapsedSeriesIndices=[]):s=this.emptyCollapsedSeries(s),a.config.series=s,t&&(e&&(a.globals.zoomed=!1,this.ctx.updateHelpers.revertDefaultAxisMinMax()),this.ctx.updateHelpers._updateSeries(s,a.config.chart.animations.dynamicAnimation.enabled))}},{key:"emptyCollapsedSeries",value:function(t){for(var e=this.w,i=0;i-1&&(t[i].data=[]);return t}},{key:"toggleSeriesOnHover",value:function(t,e){var i=this.w;e||(e=t.target);var a=i.globals.dom.baseEl.querySelectorAll(".apexcharts-series, .apexcharts-datalabels");if("mousemove"===t.type){var s=parseInt(e.getAttribute("rel"),10)-1,r=null,o=null;i.globals.axisCharts||"radialBar"===i.config.chart.type?i.globals.axisCharts?(r=i.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(s,"']")),o=i.globals.dom.baseEl.querySelector(".apexcharts-datalabels[data\\:realIndex='".concat(s,"']"))):r=i.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(s+1,"']")):r=i.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(s+1,"'] path"));for(var n=0;n=t.from&&a<=t.to&&s[e].classList.remove(i.legendInactiveClass)}}(a.config.plotOptions.heatmap.colorScale.ranges[o])}else"mouseout"===t.type&&r("remove")}},{key:"getActiveConfigSeriesIndex",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"asc",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=this.w,a=0;if(i.config.series.length>1)for(var s=i.config.series.map((function(t,a){return t.data&&t.data.length>0&&-1===i.globals.collapsedSeriesIndices.indexOf(a)&&(!i.globals.comboCharts||0===e.length||e.length&&e.indexOf(i.config.series[a].type)>-1)?a:-1})),r="asc"===t?0:s.length-1;"asc"===t?r=0;"asc"===t?r++:r--)if(-1!==s[r]){a=s[r];break}return a}},{key:"getBarSeriesIndices",value:function(){return this.w.globals.comboCharts?this.w.config.series.map((function(t,e){return"bar"===t.type||"column"===t.type?e:-1})).filter((function(t){return-1!==t})):this.w.config.series.map((function(t,e){return e}))}},{key:"getPreviousPaths",value:function(){var t=this.w;function e(e,i,a){for(var s=e[i].childNodes,r={type:a,paths:[],realIndex:e[i].getAttribute("data:realIndex")},o=0;o0)for(var a=function(e){for(var i=t.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(t.config.chart.type," .apexcharts-series[data\\:realIndex='").concat(e,"'] rect")),a=[],s=function(t){var e=function(e){return i[t].getAttribute(e)},s={x:parseFloat(e("x")),y:parseFloat(e("y")),width:parseFloat(e("width")),height:parseFloat(e("height"))};a.push({rect:s,color:i[t].getAttribute("color")})},r=0;r0)for(var a=0;a0?t:[]}))}}]),t}(),G=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.twoDSeries=[],this.threeDSeries=[],this.twoDSeriesX=[],this.seriesGoals=[],this.coreUtils=new A(this.ctx)}return h(t,[{key:"isMultiFormat",value:function(){return this.isFormatXY()||this.isFormat2DArray()}},{key:"isFormatXY",value:function(){var t=this.w.config.series.slice(),e=new B(this.ctx);if(this.activeSeriesIndex=e.getActiveConfigSeriesIndex(),void 0!==t[this.activeSeriesIndex].data&&t[this.activeSeriesIndex].data.length>0&&null!==t[this.activeSeriesIndex].data[0]&&void 0!==t[this.activeSeriesIndex].data[0].x&&null!==t[this.activeSeriesIndex].data[0])return!0}},{key:"isFormat2DArray",value:function(){var t=this.w.config.series.slice(),e=new B(this.ctx);if(this.activeSeriesIndex=e.getActiveConfigSeriesIndex(),void 0!==t[this.activeSeriesIndex].data&&t[this.activeSeriesIndex].data.length>0&&void 0!==t[this.activeSeriesIndex].data[0]&&null!==t[this.activeSeriesIndex].data[0]&&t[this.activeSeriesIndex].data[0].constructor===Array)return!0}},{key:"handleFormat2DArray",value:function(t,e){for(var i=this.w.config,a=this.w.globals,s="boxPlot"===i.chart.type||"boxPlot"===i.series[e].type,r=0;r=5?this.twoDSeries.push(m.parseNumber(t[e].data[r][4])):this.twoDSeries.push(m.parseNumber(t[e].data[r][1])),a.dataFormatXNumeric=!0),"datetime"===i.xaxis.type){var o=new Date(t[e].data[r][0]);o=new Date(o).getTime(),this.twoDSeriesX.push(o)}else this.twoDSeriesX.push(t[e].data[r][0]);for(var n=0;n-1&&(r=this.activeSeriesIndex);for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:this.ctx,a=this.w.config,s=this.w.globals,r=new z(i),o=a.labels.length>0?a.labels.slice():a.xaxis.categories.slice();s.isRangeBar="rangeBar"===a.chart.type&&s.isBarHorizontal,s.hasGroups="category"===a.xaxis.type&&a.xaxis.group.groups.length>0,s.hasGroups&&(s.groups=a.xaxis.group.groups);for(var n=function(){for(var t=0;t0&&(this.twoDSeriesX=o,s.seriesX.push(this.twoDSeriesX))),s.labels.push(this.twoDSeriesX);var h=t[l].data.map((function(t){return m.parseNumber(t)}));s.series.push(h)}s.seriesZ.push(this.threeDSeries),void 0!==t[l].name?s.seriesNames.push(t[l].name):s.seriesNames.push("series-"+parseInt(l+1,10)),void 0!==t[l].color?s.seriesColors.push(t[l].color):s.seriesColors.push(void 0)}return this.w}},{key:"parseDataNonAxisCharts",value:function(t){var e=this.w.globals,i=this.w.config;e.series=t.slice(),e.seriesNames=i.labels.slice();for(var a=0;a0?i.labels=e.xaxis.categories:e.labels.length>0?i.labels=e.labels.slice():this.fallbackToCategory?(i.labels=i.labels[0],i.seriesRange.length&&(i.seriesRange.map((function(t){t.forEach((function(t){i.labels.indexOf(t.x)<0&&t.x&&i.labels.push(t.x)}))})),i.labels=i.labels.filter((function(t,e,i){return i.indexOf(t)===e}))),e.xaxis.convertedCatToNumeric&&(new Y(e).convertCatToNumericXaxis(e,this.ctx,i.seriesX[0]),this._generateExternalLabels(t))):this._generateExternalLabels(t)}},{key:"_generateExternalLabels",value:function(t){var e=this.w.globals,i=this.w.config,a=[];if(e.axisCharts){if(e.series.length>0)if(this.isFormatXY())for(var s=i.series.map((function(t,e){return t.data.filter((function(t,e,i){return i.findIndex((function(e){return e.x===t.x}))===e}))})),r=s.reduce((function(t,e,i,a){return a[t].length>e.length?t:i}),0),o=0;o0&&i<100?t.toFixed(1):t.toFixed(0)}return e.globals.isBarHorizontal&&e.globals.maxY-e.globals.minYArr<4?t.toFixed(1):t.toFixed(0)}return t},"function"==typeof e.config.tooltip.x.formatter?e.globals.ttKeyFormatter=e.config.tooltip.x.formatter:e.globals.ttKeyFormatter=e.globals.xLabelFormatter,"function"==typeof e.config.xaxis.tooltip.formatter&&(e.globals.xaxisTooltipFormatter=e.config.xaxis.tooltip.formatter),(Array.isArray(e.config.tooltip.y)||void 0!==e.config.tooltip.y.formatter)&&(e.globals.ttVal=e.config.tooltip.y),void 0!==e.config.tooltip.z.formatter&&(e.globals.ttZFormatter=e.config.tooltip.z.formatter),void 0!==e.config.legend.formatter&&(e.globals.legendFormatter=e.config.legend.formatter),e.config.yaxis.forEach((function(i,a){void 0!==i.labels.formatter?e.globals.yLabelFormatters[a]=i.labels.formatter:e.globals.yLabelFormatters[a]=function(s){return e.globals.xyCharts?Array.isArray(s)?s.map((function(e){return t.defaultYFormatter(e,i,a)})):t.defaultYFormatter(s,i,a):s}})),e.globals}},{key:"heatmapLabelFormatters",value:function(){var t=this.w;if("heatmap"===t.config.chart.type){t.globals.yAxisScale[0].result=t.globals.seriesNames.slice();var e=t.globals.seriesNames.reduce((function(t,e){return t.length>e.length?t:e}),0);t.globals.yAxisScale[0].niceMax=e,t.globals.yAxisScale[0].niceMin=e}}}]),t}(),j=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"getLabel",value:function(t,e,i,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"12px",o=!(arguments.length>6&&void 0!==arguments[6])||arguments[6],n=this.w,l=void 0===t[a]?"":t[a],h=l,c=n.globals.xLabelFormatter,d=n.config.xaxis.labels.formatter,g=!1,u=new V(this.ctx),f=l;o&&(h=u.xLabelFormat(c,l,f,{i:a,dateFormatter:new z(this.ctx).formatDate,w:n}),void 0!==d&&(h=d(l,t[a],{i:a,dateFormatter:new z(this.ctx).formatDate,w:n})));var p=function(t){var i=null;return e.forEach((function(t){"month"===t.unit?i="year":"day"===t.unit?i="month":"hour"===t.unit?i="day":"minute"===t.unit&&(i="hour")})),i===t};e.length>0?(g=p(e[a].unit),i=e[a].position,h=e[a].value):"datetime"===n.config.xaxis.type&&void 0===d&&(h=""),void 0===h&&(h=""),h=Array.isArray(h)?h:h.toString();var x=new k(this.ctx),b={};b=n.globals.rotateXLabels&&o?x.getTextRects(h,parseInt(r,10),null,"rotate(".concat(n.config.xaxis.labels.rotate," 0 0)"),!1):x.getTextRects(h,parseInt(r,10));var v=!n.config.xaxis.labels.showDuplicates&&this.ctx.timeScale;return!Array.isArray(h)&&(0===h.indexOf("NaN")||0===h.toLowerCase().indexOf("invalid")||h.toLowerCase().indexOf("infinity")>=0||s.indexOf(h)>=0&&v)&&(h=""),{x:i,text:h,textRect:b,isBold:g}}},{key:"checkLabelBasedOnTickamount",value:function(t,e,i){var a=this.w,s=a.config.xaxis.tickAmount;return"dataPoints"===s&&(s=Math.round(a.globals.gridWidth/120)),s>i||t%Math.round(i/(s+1))==0||(e.text=""),e}},{key:"checkForOverflowingLabels",value:function(t,e,i,a,s){var r=this.w;if(0===t&&r.globals.skipFirstTimelinelabel&&(e.text=""),t===i-1&&r.globals.skipLastTimelinelabel&&(e.text=""),r.config.xaxis.labels.hideOverlappingLabels&&a.length>0){var o=s[s.length-1];e.x0){!0===n.config.yaxis[s].opposite&&(t+=a.width);for(var c=e;c>=0;c--){var d=h+e/10+n.config.yaxis[s].labels.offsetY-1;n.globals.isBarHorizontal&&(d=r*c),"heatmap"===n.config.chart.type&&(d+=r/2);var g=l.drawLine(t+i.offsetX-a.width+a.offsetX,d+a.offsetY,t+i.offsetX+a.offsetX,d+a.offsetY,a.color);o.add(g),h+=r}}}}]),t}(),_=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"scaleSvgNode",value:function(t,e){var i=parseFloat(t.getAttributeNS(null,"width")),a=parseFloat(t.getAttributeNS(null,"height"));t.setAttributeNS(null,"width",i*e),t.setAttributeNS(null,"height",a*e),t.setAttributeNS(null,"viewBox","0 0 "+i+" "+a)}},{key:"fixSvgStringForIe11",value:function(t){if(!m.isIE11())return t.replace(/ /g," ");var e=0,i=t.replace(/xmlns="http:\/\/www.w3.org\/2000\/svg"/g,(function(t){return 2==++e?'xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev"':t}));return(i=i.replace(/xmlns:NS\d+=""/g,"")).replace(/NS\d+:(\w+:\w+=")/g,"$1")}},{key:"getSvgString",value:function(t){null==t&&(t=1);var e=this.w.globals.dom.Paper.svg();if(1!==t){var i=this.w.globals.dom.Paper.node.cloneNode(!0);this.scaleSvgNode(i,t),e=(new XMLSerializer).serializeToString(i)}return this.fixSvgStringForIe11(e)}},{key:"cleanup",value:function(){var t=this.w,e=t.globals.dom.baseEl.getElementsByClassName("apexcharts-xcrosshairs"),i=t.globals.dom.baseEl.getElementsByClassName("apexcharts-ycrosshairs"),a=t.globals.dom.baseEl.querySelectorAll(".apexcharts-zoom-rect, .apexcharts-selection-rect");Array.prototype.forEach.call(a,(function(t){t.setAttribute("width",0)})),e&&e[0]&&(e[0].setAttribute("x",-500),e[0].setAttribute("x1",-500),e[0].setAttribute("x2",-500)),i&&i[0]&&(i[0].setAttribute("y",-100),i[0].setAttribute("y1",-100),i[0].setAttribute("y2",-100))}},{key:"svgUrl",value:function(){this.cleanup();var t=this.getSvgString(),e=new Blob([t],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(e)}},{key:"dataURI",value:function(t){var e=this;return new Promise((function(i){var a=e.w,s=t?t.scale||t.width/a.globals.svgWidth:1;e.cleanup();var r=document.createElement("canvas");r.width=a.globals.svgWidth*s,r.height=parseInt(a.globals.dom.elWrap.style.height,10)*s;var o="transparent"===a.config.chart.background?"#fff":a.config.chart.background,n=r.getContext("2d");n.fillStyle=o,n.fillRect(0,0,r.width*s,r.height*s);var l=e.getSvgString(s);if(window.canvg&&m.isIE11()){var h=window.canvg.Canvg.fromString(n,l,{ignoreClear:!0,ignoreDimensions:!0});h.start();var c=r.msToBlob();h.stop(),i({blob:c})}else{var d="data:image/svg+xml,"+encodeURIComponent(l),g=new Image;g.crossOrigin="anonymous",g.onload=function(){if(n.drawImage(g,0,0),r.msToBlob){var t=r.msToBlob();i({blob:t})}else{var e=r.toDataURL("image/png");i({imgURI:e})}},g.src=d}}))}},{key:"exportToSVG",value:function(){this.triggerDownload(this.svgUrl(),this.w.config.chart.toolbar.export.svg.filename,".svg")}},{key:"exportToPng",value:function(){var t=this;this.dataURI().then((function(e){var i=e.imgURI,a=e.blob;a?navigator.msSaveOrOpenBlob(a,t.w.globals.chartID+".png"):t.triggerDownload(i,t.w.config.chart.toolbar.export.png.filename,".png")}))}},{key:"exportToCSV",value:function(t){var e=this,i=t.series,a=t.fileName,s=t.columnDelimiter,r=void 0===s?",":s,o=t.lineDelimiter,n=void 0===o?"\n":o,l=this.w;i||(i=l.config.series);var h=[],c=[],d="",g=l.globals.series.map((function(t,e){return-1===l.globals.collapsedSeriesIndices.indexOf(e)?t:[]})),u=Math.max.apply(Math,x(i.map((function(t){return t.data?t.data.length:0})))),f=new G(this.ctx),p=new j(this.ctx),b=function(t){var i="";if(l.globals.axisCharts){if("category"===l.config.xaxis.type||l.config.xaxis.convertedCatToNumeric)if(l.globals.isBarHorizontal){var a=l.globals.yLabelFormatters[0],s=new B(e.ctx).getActiveConfigSeriesIndex();i=a(l.globals.labels[t],{seriesIndex:s,dataPointIndex:t,w:l})}else i=p.getLabel(l.globals.labels,l.globals.timescaleLabels,0,t).text;"datetime"===l.config.xaxis.type&&(l.config.xaxis.categories.length?i=l.config.xaxis.categories[t]:l.config.labels.length&&(i=l.config.labels[t]))}else i=l.config.labels[t];return Array.isArray(i)&&(i=i.join(" ")),m.isNumber(i)?i:i.split(r).join("")};h.push(l.config.chart.toolbar.export.csv.headerCategory),"boxPlot"===l.config.chart.type?(h.push("minimum"),h.push("q1"),h.push("median"),h.push("q3"),h.push("maximum")):"candlestick"===l.config.chart.type?(h.push("open"),h.push("high"),h.push("low"),h.push("close")):"rangeBar"===l.config.chart.type?(h.push("minimum"),h.push("maximum")):i.map((function(t,e){var i=t.name?t.name:"series-".concat(e);l.globals.axisCharts&&h.push(i.split(r).join("")?i.split(r).join(""):"series-".concat(e))})),l.globals.axisCharts||(h.push(l.config.chart.toolbar.export.csv.headerValue),c.push(h.join(r))),i.map((function(t,e){l.globals.axisCharts?function(t,e){if(h.length&&0===e&&c.push(h.join(r)),t.data){t.data=t.data.length&&t.data||x(Array(u)).map((function(){return""}));for(var a=0;a=10?l.config.chart.toolbar.export.csv.dateFormatter(s):m.isNumber(s)?s:s.split(r).join("")));for(var o=0;o0&&!a.globals.isBarHorizontal&&(this.xaxisLabels=a.globals.timescaleLabels.slice()),a.config.xaxis.overwriteCategories&&(this.xaxisLabels=a.config.xaxis.overwriteCategories),this.drawnLabels=[],this.drawnLabelsRects=[],"top"===a.config.xaxis.position?this.offY=0:this.offY=a.globals.gridHeight+1,this.offY=this.offY+a.config.xaxis.axisBorder.offsetY,this.isCategoryBarHorizontal="bar"===a.config.chart.type&&a.config.plotOptions.bar.horizontal,this.xaxisFontSize=a.config.xaxis.labels.style.fontSize,this.xaxisFontFamily=a.config.xaxis.labels.style.fontFamily,this.xaxisForeColors=a.config.xaxis.labels.style.colors,this.xaxisBorderWidth=a.config.xaxis.axisBorder.width,this.isCategoryBarHorizontal&&(this.xaxisBorderWidth=a.config.yaxis[0].axisBorder.width.toString()),this.xaxisBorderWidth.indexOf("%")>-1?this.xaxisBorderWidth=a.globals.gridWidth*parseInt(this.xaxisBorderWidth,10)/100:this.xaxisBorderWidth=parseInt(this.xaxisBorderWidth,10),this.xaxisBorderHeight=a.config.xaxis.axisBorder.height,this.yaxis=a.config.yaxis[0]}return h(t,[{key:"drawXaxis",value:function(){var t=this.w,e=new k(this.ctx),i=e.group({class:"apexcharts-xaxis",transform:"translate(".concat(t.config.xaxis.offsetX,", ").concat(t.config.xaxis.offsetY,")")}),a=e.group({class:"apexcharts-xaxis-texts-g",transform:"translate(".concat(t.globals.translateXAxisX,", ").concat(t.globals.translateXAxisY,")")});i.add(a);for(var s=[],r=0;r6&&void 0!==arguments[6]?arguments[6]:{},h=[],c=[],d=this.w,g=l.xaxisFontSize||this.xaxisFontSize,u=l.xaxisFontFamily||this.xaxisFontFamily,f=l.xaxisForeColors||this.xaxisForeColors,p=l.fontWeight||d.config.xaxis.labels.style.fontWeight,x=l.cssClass||d.config.xaxis.labels.style.cssClass,b=d.globals.padHorizontal,v=a.length,m="category"===d.config.xaxis.type?d.globals.dataPoints:v;if(0===m&&v>m&&(m=v),s){var y=m>1?m-1:m;o=d.globals.gridWidth/y,b=b+r(0,o)/2+d.config.xaxis.labels.offsetX}else o=d.globals.gridWidth/m,b=b+r(0,o)+d.config.xaxis.labels.offsetX;for(var w=function(s){var l=b-r(s,o)/2+d.config.xaxis.labels.offsetX;0===s&&1===v&&o/2===b&&1===m&&(l=d.globals.gridWidth/2);var y=n.axesUtils.getLabel(a,d.globals.timescaleLabels,l,s,h,g,t),w=28;if(d.globals.rotateXLabels&&t&&(w=22),d.config.xaxis.title.text&&"top"===d.config.xaxis.position&&(w+=parseFloat(d.config.xaxis.title.style.fontSize)+2),t||(w=w+parseFloat(g)+(d.globals.xAxisLabelsHeight-d.globals.xAxisGroupLabelsHeight)+(d.globals.rotateXLabels?10:0)),y=void 0!==d.config.xaxis.tickAmount&&"dataPoints"!==d.config.xaxis.tickAmount&&"datetime"!==d.config.xaxis.type?n.axesUtils.checkLabelBasedOnTickamount(s,y,v):n.axesUtils.checkForOverflowingLabels(s,y,v,h,c),t&&y.text&&d.globals.xaxisLabelsCount++,d.config.xaxis.labels.show){var k=e.drawText({x:y.x,y:n.offY+d.config.xaxis.labels.offsetY+w-("top"===d.config.xaxis.position?d.globals.xAxisHeight+d.config.xaxis.axisTicks.height-2:0),text:y.text,textAnchor:"middle",fontWeight:y.isBold?600:p,fontSize:g,fontFamily:u,foreColor:Array.isArray(f)?t&&d.config.xaxis.convertedCatToNumeric?f[d.globals.minX+s-1]:f[s]:f,isPlainText:!1,cssClass:(t?"apexcharts-xaxis-label ":"apexcharts-xaxis-group-label ")+x});if(i.add(k),k.on("click",(function(t){if("function"==typeof d.config.chart.events.xAxisLabelClick){var e=Object.assign({},d,{labelIndex:s});d.config.chart.events.xAxisLabelClick(t,n.ctx,e)}})),t){var A=document.createElementNS(d.globals.SVGNS,"title");A.textContent=Array.isArray(y.text)?y.text.join(" "):y.text,k.node.appendChild(A),""!==y.text&&(h.push(y.text),c.push(y))}}sa.globals.gridWidth)){var r=this.offY+a.config.xaxis.axisTicks.offsetY;if(e=e+r+a.config.xaxis.axisTicks.height,"top"===a.config.xaxis.position&&(e=r-a.config.xaxis.axisTicks.height),a.config.xaxis.axisTicks.show){var o=new k(this.ctx).drawLine(t+a.config.xaxis.axisTicks.offsetX,r+a.config.xaxis.offsetY,s+a.config.xaxis.axisTicks.offsetX,e+a.config.xaxis.offsetY,a.config.xaxis.axisTicks.color);i.add(o),o.node.classList.add("apexcharts-xaxis-tick")}}}},{key:"getXAxisTicksPositions",value:function(){var t=this.w,e=[],i=this.xaxisLabels.length,a=t.globals.padHorizontal;if(t.globals.timescaleLabels.length>0)for(var s=0;s0){var h=s[s.length-1].getBBox(),c=s[0].getBBox();h.x<-20&&s[s.length-1].parentNode.removeChild(s[s.length-1]),c.x+c.width>t.globals.gridWidth&&!t.globals.isBarHorizontal&&s[0].parentNode.removeChild(s[0]);for(var d=0;d0&&(this.xaxisLabels=i.globals.timescaleLabels.slice())}return h(t,[{key:"drawGridArea",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=this.w,i=new k(this.ctx);null===t&&(t=i.group({class:"apexcharts-grid"}));var a=i.drawLine(e.globals.padHorizontal,1,e.globals.padHorizontal,e.globals.gridHeight,"transparent"),s=i.drawLine(e.globals.padHorizontal,e.globals.gridHeight,e.globals.gridWidth,e.globals.gridHeight,"transparent");return t.add(s),t.add(a),t}},{key:"drawGrid",value:function(){var t=null;return this.w.globals.axisCharts&&(t=this.renderGrid(),this.drawGridArea(t.el)),t}},{key:"createGridMask",value:function(){var t=this.w,e=t.globals,i=new k(this.ctx),a=Array.isArray(t.config.stroke.width)?0:t.config.stroke.width;if(Array.isArray(t.config.stroke.width)){var s=0;t.config.stroke.width.forEach((function(t){s=Math.max(s,t)})),a=s}e.dom.elGridRectMask=document.createElementNS(e.SVGNS,"clipPath"),e.dom.elGridRectMask.setAttribute("id","gridRectMask".concat(e.cuid)),e.dom.elGridRectMarkerMask=document.createElementNS(e.SVGNS,"clipPath"),e.dom.elGridRectMarkerMask.setAttribute("id","gridRectMarkerMask".concat(e.cuid)),e.dom.elForecastMask=document.createElementNS(e.SVGNS,"clipPath"),e.dom.elForecastMask.setAttribute("id","forecastMask".concat(e.cuid)),e.dom.elNonForecastMask=document.createElementNS(e.SVGNS,"clipPath"),e.dom.elNonForecastMask.setAttribute("id","nonForecastMask".concat(e.cuid));var r=t.config.chart.type,o=0,n=0;("bar"===r||"rangeBar"===r||"candlestick"===r||"boxPlot"===r||t.globals.comboBarCount>0)&&t.globals.isXNumeric&&!t.globals.isBarHorizontal&&(o=t.config.grid.padding.left,n=t.config.grid.padding.right,e.barPadForNumericAxis>o&&(o=e.barPadForNumericAxis,n=e.barPadForNumericAxis)),e.dom.elGridRect=i.drawRect(-a/2-o-2,-a/2,e.gridWidth+a+n+o+4,e.gridHeight+a,0,"#fff");var l=t.globals.markers.largestSize+1;e.dom.elGridRectMarker=i.drawRect(2*-l,2*-l,e.gridWidth+4*l,e.gridHeight+4*l,0,"#fff"),e.dom.elGridRectMask.appendChild(e.dom.elGridRect.node),e.dom.elGridRectMarkerMask.appendChild(e.dom.elGridRectMarker.node);var h=e.dom.baseEl.querySelector("defs");h.appendChild(e.dom.elGridRectMask),h.appendChild(e.dom.elForecastMask),h.appendChild(e.dom.elNonForecastMask),h.appendChild(e.dom.elGridRectMarkerMask)}},{key:"_drawGridLines",value:function(t){var e=t.i,i=t.x1,a=t.y1,s=t.x2,r=t.y2,o=t.xCount,n=t.parent,l=this.w;if(!(0===e&&l.globals.skipFirstTimelinelabel||e===o-1&&l.globals.skipLastTimelinelabel&&!l.config.xaxis.labels.formatter||"radar"===l.config.chart.type)){l.config.grid.xaxis.lines.show&&this._drawGridLine({i:e,x1:i,y1:a,x2:s,y2:r,xCount:o,parent:n});var h=0;if(l.globals.hasGroups&&"between"===l.config.xaxis.tickPlacement){var c=l.globals.groups;if(c){for(var d=0,g=0;d2));s++);return!t.globals.isBarHorizontal||this.isRangeBar?(i=this.xaxisLabels.length,this.isRangeBar&&(a=t.globals.labels.length,t.config.xaxis.tickAmount&&t.config.xaxis.labels.formatter&&(i=t.config.xaxis.tickAmount)),this._drawXYLines({xCount:i,tickAmount:a})):(i=a,a=t.globals.xTickAmount,this._drawInvertedXYLines({xCount:i,tickAmount:a})),this.drawGridBands(i,a),{el:this.elg,elGridBorders:this.elGridBorders,xAxisTickWidth:t.globals.gridWidth/i}}},{key:"drawGridBands",value:function(t,e){var i=this.w;if(void 0!==i.config.grid.row.colors&&i.config.grid.row.colors.length>0)for(var a=0,s=i.globals.gridHeight/e,r=i.globals.gridWidth,o=0,n=0;o=i.config.grid.row.colors.length&&(n=0),this._drawGridBandRect({c:n,x1:0,y1:a,x2:r,y2:s,type:"row"}),a+=i.globals.gridHeight/e;if(void 0!==i.config.grid.column.colors&&i.config.grid.column.colors.length>0)for(var l=i.globals.isBarHorizontal||"category"!==i.config.xaxis.type&&!i.config.xaxis.convertedCatToNumeric?t:t-1,h=i.globals.padHorizontal,c=i.globals.padHorizontal+i.globals.gridWidth/l,d=i.globals.gridHeight,g=0,u=0;g=i.config.grid.column.colors.length&&(u=0),this._drawGridBandRect({c:u,x1:h,y1:0,x2:c,y2:d,type:"column"}),h+=i.globals.gridWidth/l}}]),t}(),Z=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"niceScale",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4?arguments[4]:void 0,r=this.w,o=Math.abs(e-t);if("dataPoints"===(i=this._adjustTicksForSmallRange(i,a,o))&&(i=r.globals.dataPoints-1),t===Number.MIN_VALUE&&0===e||!m.isNumber(t)&&!m.isNumber(e)||t===Number.MIN_VALUE&&e===-Number.MAX_VALUE){t=0,e=i;var n=this.linearScale(t,e,i);return n}t>e?(console.warn("axis.min cannot be greater than axis.max"),e=t+.1):t===e&&(t=0===t?0:t-.5,e=0===e?2:e+.5);var l=[];o<1&&s&&("candlestick"===r.config.chart.type||"candlestick"===r.config.series[a].type||"boxPlot"===r.config.chart.type||"boxPlot"===r.config.series[a].type||r.globals.isRangeData)&&(e*=1.01);var h=i+1;h<2?h=2:h>2&&(h-=2);var c=o/h,d=Math.floor(m.log10(c)),g=Math.pow(10,d),u=Math.round(c/g);u<1&&(u=1);var f=u*g,p=f*Math.floor(t/f),x=f*Math.ceil(e/f),b=p;if(s&&o>2){for(;l.push(b),!((b+=f)>x););return{result:l,niceMin:l[0],niceMax:l[l.length-1]}}var v=t;(l=[]).push(v);for(var y=Math.abs(e-t)/i,w=0;w<=i;w++)v+=y,l.push(v);return l[l.length-2]>=e&&l.pop(),{result:l,niceMin:l[0],niceMax:l[l.length-1]}}},{key:"linearScale",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,a=arguments.length>3?arguments[3]:void 0,s=Math.abs(e-t);"dataPoints"===(i=this._adjustTicksForSmallRange(i,a,s))&&(i=this.w.globals.dataPoints-1);var r=s/i;i===Number.MAX_VALUE&&(i=10,r=1);for(var o=[],n=t;i>=0;)o.push(n),n+=r,i-=1;return{result:o,niceMin:o[0],niceMax:o[o.length-1]}}},{key:"logarithmicScaleNice",value:function(t,e,i){e<=0&&(e=Math.max(t,i)),t<=0&&(t=Math.min(e,i));for(var a=[],s=Math.ceil(Math.log(e)/Math.log(i)+1),r=Math.floor(Math.log(t)/Math.log(i));r5)a.allSeriesCollapsed=!1,a.yAxisScale[t]=this.logarithmicScale(e,i,r.logBase),a.yAxisScale[t]=r.forceNiceScale?this.logarithmicScaleNice(e,i,r.logBase):this.logarithmicScale(e,i,r.logBase);else if(i!==-Number.MAX_VALUE&&m.isNumber(i))if(a.allSeriesCollapsed=!1,void 0===r.min&&void 0===r.max||r.forceNiceScale){var n=void 0===s.yaxis[t].max&&void 0===s.yaxis[t].min||s.yaxis[t].forceNiceScale;a.yAxisScale[t]=this.niceScale(e,i,r.tickAmount?r.tickAmount:o<5&&o>1?o+1:5,t,n)}else a.yAxisScale[t]=this.linearScale(e,i,r.tickAmount,t);else a.yAxisScale[t]=this.linearScale(0,5,5)}},{key:"setXScale",value:function(t,e){var i=this.w,a=i.globals,s=i.config.xaxis,r=Math.abs(e-t);return e!==-Number.MAX_VALUE&&m.isNumber(e)?a.xAxisScale=this.linearScale(t,e,s.tickAmount?s.tickAmount:r<5&&r>1?r+1:5,0):a.xAxisScale=this.linearScale(0,5,5),a.xAxisScale}},{key:"setMultipleYScales",value:function(){var t=this,e=this.w.globals,i=this.w.config,a=e.minYArr.concat([]),s=e.maxYArr.concat([]),r=[];i.yaxis.forEach((function(e,o){var n=o;i.series.forEach((function(t,i){t.name===e.seriesName&&(n=i,o!==i?r.push({index:i,similarIndex:o,alreadyExists:!0}):r.push({index:i}))}));var l=a[n],h=s[n];t.setYScaleForIndex(o,l,h)})),this.sameScaleInMultipleAxes(a,s,r)}},{key:"sameScaleInMultipleAxes",value:function(t,e,i){var a=this,s=this.w.config,r=this.w.globals,o=[];i.forEach((function(t){t.alreadyExists&&(void 0===o[t.index]&&(o[t.index]=[]),o[t.index].push(t.index),o[t.index].push(t.similarIndex))})),r.yAxisSameScaleIndices=o,o.forEach((function(t,e){o.forEach((function(i,a){var s,r;e!==a&&(s=t,r=i,s.filter((function(t){return-1!==r.indexOf(t)}))).length>0&&(o[e]=o[e].concat(o[a]))}))}));var n=o.map((function(t){return t.filter((function(e,i){return t.indexOf(e)===i}))})).map((function(t){return t.sort()}));o=o.filter((function(t){return!!t}));var l=n.slice(),h=l.map((function(t){return JSON.stringify(t)}));l=l.filter((function(t,e){return h.indexOf(JSON.stringify(t))===e}));var c=[],d=[];t.forEach((function(t,i){l.forEach((function(a,s){a.indexOf(i)>-1&&(void 0===c[s]&&(c[s]=[],d[s]=[]),c[s].push({key:i,value:t}),d[s].push({key:i,value:e[i]}))}))}));var g=Array.apply(null,Array(l.length)).map(Number.prototype.valueOf,Number.MIN_VALUE),u=Array.apply(null,Array(l.length)).map(Number.prototype.valueOf,-Number.MAX_VALUE);c.forEach((function(t,e){t.forEach((function(t,i){g[e]=Math.min(t.value,g[e])}))})),d.forEach((function(t,e){t.forEach((function(t,i){u[e]=Math.max(t.value,u[e])}))})),t.forEach((function(t,e){d.forEach((function(t,i){var o=g[i],n=u[i];s.chart.stacked&&(n=0,t.forEach((function(t,e){t.value!==-Number.MAX_VALUE&&(n+=t.value),o!==Number.MIN_VALUE&&(o+=c[i][e].value)}))),t.forEach((function(i,l){t[l].key===e&&(void 0!==s.yaxis[e].min&&(o="function"==typeof s.yaxis[e].min?s.yaxis[e].min(r.minY):s.yaxis[e].min),void 0!==s.yaxis[e].max&&(n="function"==typeof s.yaxis[e].max?s.yaxis[e].max(r.maxY):s.yaxis[e].max),a.setYScaleForIndex(e,o,n))}))}))}))}},{key:"autoScaleY",value:function(t,e,i){t||(t=this);var a=t.w;if(a.globals.isMultipleYAxis||a.globals.collapsedSeries.length)return console.warn("autoScaleYaxis is not supported in a multi-yaxis chart."),e;var s=a.globals.seriesX[0],r=a.config.chart.stacked;return e.forEach((function(t,o){for(var n=0,l=0;l=i.xaxis.min){n=l;break}var h,c,d=a.globals.minYArr[o],g=a.globals.maxYArr[o],u=a.globals.stackedSeriesTotals;a.globals.series.forEach((function(o,l){var f=o[n];r?(f=u[n],h=c=f,u.forEach((function(t,e){s[e]<=i.xaxis.max&&s[e]>=i.xaxis.min&&(t>c&&null!==t&&(c=t),o[e]=i.xaxis.min){var r=t,o=t;a.globals.series.forEach((function(i,a){null!==t&&(r=Math.min(i[e],r),o=Math.max(i[e],o))})),o>c&&null!==o&&(c=o),rd&&(h=d),e.length>1?(e[l].min=void 0===t.min?h:t.min,e[l].max=void 0===t.max?c:t.max):(e[0].min=void 0===t.min?h:t.min,e[0].max=void 0===t.max?c:t.max)}))})),e}}]),t}(),$=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.scales=new Z(e)}return h(t,[{key:"init",value:function(){this.setYRange(),this.setXRange(),this.setZRange()}},{key:"getMinYMaxY",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.MAX_VALUE,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-Number.MAX_VALUE,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=this.w.config,r=this.w.globals,o=-Number.MAX_VALUE,n=Number.MIN_VALUE;null===a&&(a=t+1);var l=r.series,h=l,c=l;"candlestick"===s.chart.type?(h=r.seriesCandleL,c=r.seriesCandleH):"boxPlot"===s.chart.type?(h=r.seriesCandleO,c=r.seriesCandleC):r.isRangeData&&(h=r.seriesRangeStart,c=r.seriesRangeEnd);for(var d=t;dh[d][g]&&h[d][g]<0&&(n=h[d][g])):r.hasNullValues=!0}}return"rangeBar"===s.chart.type&&r.seriesRangeStart.length&&r.isBarHorizontal&&(n=e),"bar"===s.chart.type&&(n<0&&o<0&&(o=0),n===Number.MIN_VALUE&&(n=0)),{minY:n,maxY:o,lowestY:e,highestY:i}}},{key:"setYRange",value:function(){var t=this.w.globals,e=this.w.config;t.maxY=-Number.MAX_VALUE,t.minY=Number.MIN_VALUE;var i=Number.MAX_VALUE;if(t.isMultipleYAxis)for(var a=0;a=0&&i<=10||void 0!==e.yaxis[0].min||void 0!==e.yaxis[0].max)&&(o=0),t.minY=i-5*o/100,i>0&&t.minY<0&&(t.minY=0),t.maxY=t.maxY+5*o/100}return e.yaxis.forEach((function(e,i){void 0!==e.max&&("number"==typeof e.max?t.maxYArr[i]=e.max:"function"==typeof e.max&&(t.maxYArr[i]=e.max(t.isMultipleYAxis?t.maxYArr[i]:t.maxY)),t.maxY=t.maxYArr[i]),void 0!==e.min&&("number"==typeof e.min?t.minYArr[i]=e.min:"function"==typeof e.min&&(t.minYArr[i]=e.min(t.isMultipleYAxis?t.minYArr[i]===Number.MIN_VALUE?0:t.minYArr[i]:t.minY)),t.minY=t.minYArr[i])})),t.isBarHorizontal&&["min","max"].forEach((function(i){void 0!==e.xaxis[i]&&"number"==typeof e.xaxis[i]&&("min"===i?t.minY=e.xaxis[i]:t.maxY=e.xaxis[i])})),t.isMultipleYAxis?(this.scales.setMultipleYScales(),t.minY=i,t.yAxisScale.forEach((function(e,i){t.minYArr[i]=e.niceMin,t.maxYArr[i]=e.niceMax}))):(this.scales.setYScaleForIndex(0,t.minY,t.maxY),t.minY=t.yAxisScale[0].niceMin,t.maxY=t.yAxisScale[0].niceMax,t.minYArr[0]=t.yAxisScale[0].niceMin,t.maxYArr[0]=t.yAxisScale[0].niceMax),{minY:t.minY,maxY:t.maxY,minYArr:t.minYArr,maxYArr:t.maxYArr,yAxisScale:t.yAxisScale}}},{key:"setXRange",value:function(){var t=this.w.globals,e=this.w.config,i="numeric"===e.xaxis.type||"datetime"===e.xaxis.type||"category"===e.xaxis.type&&!t.noLabelsProvided||t.noLabelsProvided||t.isXNumeric;if(t.isXNumeric&&function(){for(var e=0;et.dataPoints&&0!==t.dataPoints&&(a=t.dataPoints-1)):"dataPoints"===e.xaxis.tickAmount?(t.series.length>1&&(a=t.series[t.maxValsInArrayIndex].length-1),t.isXNumeric&&(a=t.maxX-t.minX-1)):a=e.xaxis.tickAmount,t.xTickAmount=a,void 0!==e.xaxis.max&&"number"==typeof e.xaxis.max&&(t.maxX=e.xaxis.max),void 0!==e.xaxis.min&&"number"==typeof e.xaxis.min&&(t.minX=e.xaxis.min),void 0!==e.xaxis.range&&(t.minX=t.maxX-e.xaxis.range),t.minX!==Number.MAX_VALUE&&t.maxX!==-Number.MAX_VALUE)if(e.xaxis.convertedCatToNumeric&&!t.dataFormatXNumeric){for(var s=[],r=t.minX-1;r0&&(t.xAxisScale=this.scales.linearScale(1,t.labels.length,a-1),t.seriesX=t.labels.slice());i&&(t.labels=t.xAxisScale.result.slice())}return t.isBarHorizontal&&t.labels.length&&(t.xTickAmount=t.labels.length),this._handleSingleDataPoint(),this._getMinXDiff(),{minX:t.minX,maxX:t.maxX}}},{key:"setZRange",value:function(){var t=this.w.globals;if(t.isDataXYZ)for(var e=0;e0){var s=e-a[i-1];s>0&&(t.minXDiff=Math.min(s,t.minXDiff))}})),1!==t.dataPoints&&t.minXDiff!==Number.MAX_VALUE||(t.minXDiff=.5)}))}},{key:"_setStackedMinMax",value:function(){var t=this.w.globals,e=[],i=[];if(t.series.length)for(var a=0;a0?s=s+parseFloat(t.series[o][a])+1e-4:r+=parseFloat(t.series[o][a])),o===t.series.length-1&&(e.push(s),i.push(r));for(var n=0;n=0;b--)x(b);if(void 0!==i.config.yaxis[t].title.text){var v=a.group({class:"apexcharts-yaxis-title"}),m=0;i.config.yaxis[t].opposite&&(m=i.globals.translateYAxisX[t]);var y=a.drawText({x:m,y:i.globals.gridHeight/2+i.globals.translateY+i.config.yaxis[t].title.offsetY,text:i.config.yaxis[t].title.text,textAnchor:"end",foreColor:i.config.yaxis[t].title.style.color,fontSize:i.config.yaxis[t].title.style.fontSize,fontWeight:i.config.yaxis[t].title.style.fontWeight,fontFamily:i.config.yaxis[t].title.style.fontFamily,cssClass:"apexcharts-yaxis-title-text "+i.config.yaxis[t].title.style.cssClass});v.add(y),l.add(v)}var w=i.config.yaxis[t].axisBorder,A=31+w.offsetX;if(i.config.yaxis[t].opposite&&(A=-31-w.offsetX),w.show){var S=a.drawLine(A,i.globals.translateY+w.offsetY-2,A,i.globals.gridHeight+i.globals.translateY+w.offsetY+2,w.color,0,w.width);l.add(S)}return i.config.yaxis[t].axisTicks.show&&this.axesUtils.drawYAxisTicks(A,c,w,i.config.yaxis[t].axisTicks,t,d,l),l}},{key:"drawYaxisInversed",value:function(t){var e=this.w,i=new k(this.ctx),a=i.group({class:"apexcharts-xaxis apexcharts-yaxis-inversed"}),s=i.group({class:"apexcharts-xaxis-texts-g",transform:"translate(".concat(e.globals.translateXAxisX,", ").concat(e.globals.translateXAxisY,")")});a.add(s);var r=e.globals.yAxisScale[t].result.length-1,o=e.globals.gridWidth/r+.1,n=o+e.config.xaxis.labels.offsetX,l=e.globals.xLabelFormatter,h=e.globals.yAxisScale[t].result.slice(),c=e.globals.timescaleLabels;c.length>0&&(this.xaxisLabels=c.slice(),r=(h=c.slice()).length),h=this.axesUtils.checkForReversedLabels(t,h);var d=c.length;if(e.config.xaxis.labels.show)for(var g=d?0:r;d?g=0;d?g++:g--){var u=h[g];u=l(u,g,e);var f=e.globals.gridWidth+e.globals.padHorizontal-(n-o+e.config.xaxis.labels.offsetX);if(c.length){var p=this.axesUtils.getLabel(h,c,f,g,this.drawnLabels,this.xaxisFontSize);f=p.x,u=p.text,this.drawnLabels.push(p.text),0===g&&e.globals.skipFirstTimelinelabel&&(u=""),g===h.length-1&&e.globals.skipLastTimelinelabel&&(u="")}var x=i.drawText({x:f,y:this.xAxisoffX+e.config.xaxis.labels.offsetY+30-("top"===e.config.xaxis.position?e.globals.xAxisHeight+e.config.xaxis.axisTicks.height-2:0),text:u,textAnchor:"middle",foreColor:Array.isArray(this.xaxisForeColors)?this.xaxisForeColors[t]:this.xaxisForeColors,fontSize:this.xaxisFontSize,fontFamily:this.xaxisFontFamily,fontWeight:e.config.xaxis.labels.style.fontWeight,isPlainText:!1,cssClass:"apexcharts-xaxis-label "+e.config.xaxis.labels.style.cssClass});s.add(x),x.tspan(u);var b=document.createElementNS(e.globals.SVGNS,"title");b.textContent=u,x.node.appendChild(b),n+=o}return this.inversedYAxisTitleText(a),this.inversedYAxisBorder(a),a}},{key:"inversedYAxisBorder",value:function(t){var e=this.w,i=new k(this.ctx),a=e.config.xaxis.axisBorder;if(a.show){var s=0;"bar"===e.config.chart.type&&e.globals.isXNumeric&&(s-=15);var r=i.drawLine(e.globals.padHorizontal+s+a.offsetX,this.xAxisoffX,e.globals.gridWidth,this.xAxisoffX,a.color,0,a.height);this.elgrid&&this.elgrid.elGridBorders?this.elgrid.elGridBorders.add(r):t.add(r)}}},{key:"inversedYAxisTitleText",value:function(t){var e=this.w,i=new k(this.ctx);if(void 0!==e.config.xaxis.title.text){var a=i.group({class:"apexcharts-xaxis-title apexcharts-yaxis-title-inversed"}),s=i.drawText({x:e.globals.gridWidth/2+e.config.xaxis.title.offsetX,y:this.xAxisoffX+parseFloat(this.xaxisFontSize)+parseFloat(e.config.xaxis.title.style.fontSize)+e.config.xaxis.title.offsetY+20,text:e.config.xaxis.title.text,textAnchor:"middle",fontSize:e.config.xaxis.title.style.fontSize,fontFamily:e.config.xaxis.title.style.fontFamily,fontWeight:e.config.xaxis.title.style.fontWeight,foreColor:e.config.xaxis.title.style.color,cssClass:"apexcharts-xaxis-title-text "+e.config.xaxis.title.style.cssClass});a.add(s),t.add(a)}}},{key:"yAxisTitleRotate",value:function(t,e){var i=this.w,a=new k(this.ctx),s={width:0,height:0},r={width:0,height:0},o=i.globals.dom.baseEl.querySelector(" .apexcharts-yaxis[rel='".concat(t,"'] .apexcharts-yaxis-texts-g"));null!==o&&(s=o.getBoundingClientRect());var n=i.globals.dom.baseEl.querySelector(".apexcharts-yaxis[rel='".concat(t,"'] .apexcharts-yaxis-title text"));if(null!==n&&(r=n.getBoundingClientRect()),null!==n){var l=this.xPaddingForYAxisTitle(t,s,r,e);n.setAttribute("x",l.xPos-(e?10:0))}if(null!==n){var h=a.rotateAroundCenter(n);n.setAttribute("transform","rotate(".concat(e?-1*i.config.yaxis[t].title.rotate:i.config.yaxis[t].title.rotate," ").concat(h.x," ").concat(h.y,")"))}}},{key:"xPaddingForYAxisTitle",value:function(t,e,i,a){var s=this.w,r=0,o=0,n=10;return void 0===s.config.yaxis[t].title.text||t<0?{xPos:o,padd:0}:(a?(o=e.width+s.config.yaxis[t].title.offsetX+i.width/2+n/2,0===(r+=1)&&(o-=n/2)):(o=-1*e.width+s.config.yaxis[t].title.offsetX+n/2+i.width/2,s.globals.isBarHorizontal&&(n=25,o=-1*e.width-s.config.yaxis[t].title.offsetX-n)),{xPos:o,padd:n})}},{key:"setYAxisXPosition",value:function(t,e){var i=this.w,a=0,s=0,r=18,o=1;i.config.yaxis.length>1&&(this.multipleYs=!0),i.config.yaxis.map((function(n,l){var h=i.globals.ignoreYAxisIndexes.indexOf(l)>-1||!n.show||n.floating||0===t[l].width,c=t[l].width+e[l].width;n.opposite?i.globals.isBarHorizontal?(s=i.globals.gridWidth+i.globals.translateX-1,i.globals.translateYAxisX[l]=s-n.labels.offsetX):(s=i.globals.gridWidth+i.globals.translateX+o,h||(o=o+c+20),i.globals.translateYAxisX[l]=s-n.labels.offsetX+20):(a=i.globals.translateX-r,h||(r=r+c+20),i.globals.translateYAxisX[l]=a+n.labels.offsetX)}))}},{key:"setYAxisTextAlignments",value:function(){var t=this.w,e=t.globals.dom.baseEl.getElementsByClassName("apexcharts-yaxis");(e=m.listToArray(e)).forEach((function(e,i){var a=t.config.yaxis[i];if(a&&void 0!==a.labels.align){var s=t.globals.dom.baseEl.querySelector(".apexcharts-yaxis[rel='".concat(i,"'] .apexcharts-yaxis-texts-g")),r=t.globals.dom.baseEl.querySelectorAll(".apexcharts-yaxis[rel='".concat(i,"'] .apexcharts-yaxis-label"));r=m.listToArray(r);var o=s.getBoundingClientRect();"left"===a.labels.align?(r.forEach((function(t,e){t.setAttribute("text-anchor","start")})),a.opposite||s.setAttribute("transform","translate(-".concat(o.width,", 0)"))):"center"===a.labels.align?(r.forEach((function(t,e){t.setAttribute("text-anchor","middle")})),s.setAttribute("transform","translate(".concat(o.width/2*(a.opposite?1:-1),", 0)"))):"right"===a.labels.align&&(r.forEach((function(t,e){t.setAttribute("text-anchor","end")})),a.opposite&&s.setAttribute("transform","translate(".concat(o.width,", 0)")))}}))}}]),t}(),Q=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.documentEvent=m.bind(this.documentEvent,this)}return h(t,[{key:"addEventListener",value:function(t,e){var i=this.w;i.globals.events.hasOwnProperty(t)?i.globals.events[t].push(e):i.globals.events[t]=[e]}},{key:"removeEventListener",value:function(t,e){var i=this.w;if(i.globals.events.hasOwnProperty(t)){var a=i.globals.events[t].indexOf(e);-1!==a&&i.globals.events[t].splice(a,1)}}},{key:"fireEvent",value:function(t,e){var i=this.w;if(i.globals.events.hasOwnProperty(t)){e&&e.length||(e=[]);for(var a=i.globals.events[t],s=a.length,r=0;r0&&(e=this.w.config.chart.locales.concat(window.Apex.chart.locales));var i=e.filter((function(e){return e.name===t}))[0];if(!i)throw new Error("Wrong locale name provided. Please make sure you set the correct locale name in options");var a=m.extend(T,i);this.w.globals.locale=a.options}}]),t}(),tt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"drawAxis",value:function(t,e){var i,a,s=this.w.globals,r=this.w.config,o=new U(this.ctx,e),n=new J(this.ctx,e);s.axisCharts&&"radar"!==t&&(s.isBarHorizontal?(a=n.drawYaxisInversed(0),i=o.drawXaxisInversed(0),s.dom.elGraphical.add(i),s.dom.elGraphical.add(a)):(i=o.drawXaxis(),s.dom.elGraphical.add(i),r.yaxis.map((function(t,e){-1===s.ignoreYAxisIndexes.indexOf(e)&&(a=n.drawYaxis(e),s.dom.Paper.add(a))}))))}}]),t}(),et=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"drawXCrosshairs",value:function(){var t=this.w,e=new k(this.ctx),i=new w(this.ctx),a=t.config.xaxis.crosshairs.fill.gradient,s=t.config.xaxis.crosshairs.dropShadow,r=t.config.xaxis.crosshairs.fill.type,o=a.colorFrom,n=a.colorTo,l=a.opacityFrom,h=a.opacityTo,c=a.stops,d=s.enabled,g=s.left,u=s.top,f=s.blur,p=s.color,x=s.opacity,b=t.config.xaxis.crosshairs.fill.color;if(t.config.xaxis.crosshairs.show){"gradient"===r&&(b=e.drawGradient("vertical",o,n,l,h,null,c,null));var v=e.drawRect();1===t.config.xaxis.crosshairs.width&&(v=e.drawLine());var y=t.globals.gridHeight;(!m.isNumber(y)||y<0)&&(y=0);var A=t.config.xaxis.crosshairs.width;(!m.isNumber(A)||A<0)&&(A=0),v.attr({class:"apexcharts-xcrosshairs",x:0,y:0,y2:y,width:A,height:y,fill:b,filter:"none","fill-opacity":t.config.xaxis.crosshairs.opacity,stroke:t.config.xaxis.crosshairs.stroke.color,"stroke-width":t.config.xaxis.crosshairs.stroke.width,"stroke-dasharray":t.config.xaxis.crosshairs.stroke.dashArray}),d&&(v=i.dropShadow(v,{left:g,top:u,blur:f,color:p,opacity:x})),t.globals.dom.elGraphical.add(v)}}},{key:"drawYCrosshairs",value:function(){var t=this.w,e=new k(this.ctx),i=t.config.yaxis[0].crosshairs,a=t.globals.barPadForNumericAxis;if(t.config.yaxis[0].crosshairs.show){var s=e.drawLine(-a,0,t.globals.gridWidth+a,0,i.stroke.color,i.stroke.dashArray,i.stroke.width);s.attr({class:"apexcharts-ycrosshairs"}),t.globals.dom.elGraphical.add(s)}var r=e.drawLine(-a,0,t.globals.gridWidth+a,0,i.stroke.color,0,0);r.attr({class:"apexcharts-ycrosshairs-hidden"}),t.globals.dom.elGraphical.add(r)}}]),t}(),it=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"checkResponsiveConfig",value:function(t){var e=this,i=this.w,a=i.config;if(0!==a.responsive.length){var s=a.responsive.slice();s.sort((function(t,e){return t.breakpoint>e.breakpoint?1:e.breakpoint>t.breakpoint?-1:0})).reverse();var r=new F({}),o=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=s[0].breakpoint,o=window.innerWidth>0?window.innerWidth:screen.width;if(o>a){var n=A.extendArrayProps(r,i.globals.initialConfig,i);t=m.extend(n,t),t=m.extend(i.config,t),e.overrideResponsiveOptions(t)}else for(var l=0;l0&&"function"==typeof e.config.colors[0]&&(e.globals.colors=e.config.series.map((function(i,a){var s=e.config.colors[a];return s||(s=e.config.colors[0]),"function"==typeof s?(t.isColorFn=!0,s({value:e.globals.axisCharts?e.globals.series[a][0]?e.globals.series[a][0]:0:e.globals.series[a],seriesIndex:a,dataPointIndex:a,w:e})):s})))),e.globals.seriesColors.map((function(t,i){t&&(e.globals.colors[i]=t)})),e.config.theme.monochrome.enabled){var a=[],s=e.globals.series.length;(this.isBarDistributed||this.isHeatmapDistributed)&&(s=e.globals.series[0].length*e.globals.series.length);for(var r=e.config.theme.monochrome.color,o=1/(s/e.config.theme.monochrome.shadeIntensity),n=e.config.theme.monochrome.shadeTo,l=0,h=0;h2&&void 0!==arguments[2]?arguments[2]:null,a=this.w,s=e||a.globals.series.length;if(null===i&&(i=this.isBarDistributed||this.isHeatmapDistributed||"heatmap"===a.config.chart.type&&a.config.plotOptions.heatmap.colorScale.inverse),i&&a.globals.series.length&&(s=a.globals.series[a.globals.maxValsInArrayIndex].length*a.globals.series.length),t.lengtht.globals.svgWidth&&(this.dCtx.lgRect.width=t.globals.svgWidth/1.5),this.dCtx.lgRect}},{key:"getLargestStringFromMultiArr",value:function(t,e){var i=t;if(this.w.globals.isMultiLineX){var a=e.map((function(t,e){return Array.isArray(t)?t.length:1})),s=Math.max.apply(Math,x(a));i=e[a.indexOf(s)]}return i}}]),t}(),ot=function(){function t(e){n(this,t),this.w=e.w,this.dCtx=e}return h(t,[{key:"getxAxisLabelsCoords",value:function(){var t,e=this.w,i=e.globals.labels.slice();if(e.config.xaxis.convertedCatToNumeric&&0===i.length&&(i=e.globals.categoryLabels),e.globals.timescaleLabels.length>0){var a=this.getxAxisTimeScaleLabelsCoords();t={width:a.width,height:a.height},e.globals.rotateXLabels=!1}else{this.dCtx.lgWidthForSideLegends="left"!==e.config.legend.position&&"right"!==e.config.legend.position||e.config.legend.floating?0:this.dCtx.lgRect.width;var s=e.globals.xLabelFormatter,r=m.getLargestStringFromArr(i),o=this.dCtx.dimHelpers.getLargestStringFromMultiArr(r,i);e.globals.isBarHorizontal&&(o=r=e.globals.yAxisScale[0].result.reduce((function(t,e){return t.length>e.length?t:e}),0));var n=new V(this.dCtx.ctx),l=r;r=n.xLabelFormat(s,r,l,{i:void 0,dateFormatter:new z(this.dCtx.ctx).formatDate,w:e}),o=n.xLabelFormat(s,o,l,{i:void 0,dateFormatter:new z(this.dCtx.ctx).formatDate,w:e}),(e.config.xaxis.convertedCatToNumeric&&void 0===r||""===String(r).trim())&&(o=r="1");var h=new k(this.dCtx.ctx),c=h.getTextRects(r,e.config.xaxis.labels.style.fontSize),d=c;if(r!==o&&(d=h.getTextRects(o,e.config.xaxis.labels.style.fontSize)),(t={width:c.width>=d.width?c.width:d.width,height:c.height>=d.height?c.height:d.height}).width*i.length>e.globals.svgWidth-this.dCtx.lgWidthForSideLegends-this.dCtx.yAxisWidth-this.dCtx.gridPad.left-this.dCtx.gridPad.right&&0!==e.config.xaxis.labels.rotate||e.config.xaxis.labels.rotateAlways){if(!e.globals.isBarHorizontal){e.globals.rotateXLabels=!0;var g=function(t){return h.getTextRects(t,e.config.xaxis.labels.style.fontSize,e.config.xaxis.labels.style.fontFamily,"rotate(".concat(e.config.xaxis.labels.rotate," 0 0)"),!1)};c=g(r),r!==o&&(d=g(o)),t.height=(c.height>d.height?c.height:d.height)/1.5,t.width=c.width>d.width?c.width:d.width}}else e.globals.rotateXLabels=!1}return e.config.xaxis.labels.show||(t={width:0,height:0}),{width:t.width,height:t.height}}},{key:"getxAxisGroupLabelsCoords",value:function(){var t,e=this.w;if(!e.globals.hasGroups)return{width:0,height:0};var i,a=(null===(t=e.config.xaxis.group.style)||void 0===t?void 0:t.fontSize)||e.config.xaxis.labels.style.fontSize,s=e.globals.groups.map((function(t){return t.title})),r=m.getLargestStringFromArr(s),o=this.dCtx.dimHelpers.getLargestStringFromMultiArr(r,s),n=new k(this.dCtx.ctx),l=n.getTextRects(r,a),h=l;return r!==o&&(h=n.getTextRects(o,a)),i={width:l.width>=h.width?l.width:h.width,height:l.height>=h.height?l.height:h.height},e.config.xaxis.labels.show||(i={width:0,height:0}),{width:i.width,height:i.height}}},{key:"getxAxisTitleCoords",value:function(){var t=this.w,e=0,i=0;if(void 0!==t.config.xaxis.title.text){var a=new k(this.dCtx.ctx).getTextRects(t.config.xaxis.title.text,t.config.xaxis.title.style.fontSize);e=a.width,i=a.height}return{width:e,height:i}}},{key:"getxAxisTimeScaleLabelsCoords",value:function(){var t,e=this.w;this.dCtx.timescaleLabels=e.globals.timescaleLabels.slice();var i=this.dCtx.timescaleLabels.map((function(t){return t.value})),a=i.reduce((function(t,e){return void 0===t?(console.error("You have possibly supplied invalid Date format. Please supply a valid JavaScript Date"),0):t.length>e.length?t:e}),0);return 1.05*(t=new k(this.dCtx.ctx).getTextRects(a,e.config.xaxis.labels.style.fontSize)).width*i.length>e.globals.gridWidth&&0!==e.config.xaxis.labels.rotate&&(e.globals.overlappingXLabels=!0),t}},{key:"additionalPaddingXLabels",value:function(t){var e=this,i=this.w,a=i.globals,s=i.config,r=s.xaxis.type,o=t.width;a.skipLastTimelinelabel=!1,a.skipFirstTimelinelabel=!1;var n=i.config.yaxis[0].opposite&&i.globals.isBarHorizontal,l=function(t,n){(function(t){return-1!==a.collapsedSeriesIndices.indexOf(t)})(n)||function(t){if(e.dCtx.timescaleLabels&&e.dCtx.timescaleLabels.length){var n=e.dCtx.timescaleLabels[0],l=e.dCtx.timescaleLabels[e.dCtx.timescaleLabels.length-1].position+o/1.75-e.dCtx.yAxisWidthRight,h=n.position-o/1.75+e.dCtx.yAxisWidthLeft,c="right"===i.config.legend.position&&e.dCtx.lgRect.width>0?e.dCtx.lgRect.width:0;l>a.svgWidth-a.translateX-c&&(a.skipLastTimelinelabel=!0),h<-(t.show&&!t.floating||"bar"!==s.chart.type&&"candlestick"!==s.chart.type&&"rangeBar"!==s.chart.type&&"boxPlot"!==s.chart.type?10:o/1.75)&&(a.skipFirstTimelinelabel=!0)}else"datetime"===r?e.dCtx.gridPad.rightString(n.niceMax).length?c:n.niceMax,g=h(d,{seriesIndex:o,dataPointIndex:-1,w:e}),u=g;if(void 0!==g&&0!==g.length||(g=d),e.globals.isBarHorizontal){a=0;var f=e.globals.labels.slice();g=h(g=m.getLargestStringFromArr(f),{seriesIndex:o,dataPointIndex:-1,w:e}),u=t.dCtx.dimHelpers.getLargestStringFromMultiArr(g,f)}var p=new k(t.dCtx.ctx),x="rotate(".concat(r.labels.rotate," 0 0)"),b=p.getTextRects(g,r.labels.style.fontSize,r.labels.style.fontFamily,x,!1),v=b;g!==u&&(v=p.getTextRects(u,r.labels.style.fontSize,r.labels.style.fontFamily,x,!1)),i.push({width:(l>v.width||l>b.width?l:v.width>b.width?v.width:b.width)+a,height:v.height>b.height?v.height:b.height})}else i.push({width:0,height:0})})),i}},{key:"getyAxisTitleCoords",value:function(){var t=this,e=this.w,i=[];return e.config.yaxis.map((function(e,a){if(e.show&&void 0!==e.title.text){var s=new k(t.dCtx.ctx),r="rotate(".concat(e.title.rotate," 0 0)"),o=s.getTextRects(e.title.text,e.title.style.fontSize,e.title.style.fontFamily,r,!1);i.push({width:o.width,height:o.height})}else i.push({width:0,height:0})})),i}},{key:"getTotalYAxisWidth",value:function(){var t=this.w,e=0,i=0,a=0,s=t.globals.yAxisScale.length>1?10:0,r=new j(this.dCtx.ctx),o=function(o,n){var l=t.config.yaxis[n].floating,h=0;o.width>0&&!l?(h=o.width+s,function(e){return t.globals.ignoreYAxisIndexes.indexOf(e)>-1}(n)&&(h=h-o.width-s)):h=l||r.isYAxisHidden(n)?0:5,t.config.yaxis[n].opposite?a+=h:i+=h,e+=h};return t.globals.yLabelsCoords.map((function(t,e){o(t,e)})),t.globals.yTitleCoords.map((function(t,e){o(t,e)})),t.globals.isBarHorizontal&&!t.config.yaxis[0].floating&&(e=t.globals.yLabelsCoords[0].width+t.globals.yTitleCoords[0].width+15),this.dCtx.yAxisWidthLeft=i,this.dCtx.yAxisWidthRight=a,e}}]),t}(),lt=function(){function t(e){n(this,t),this.w=e.w,this.dCtx=e}return h(t,[{key:"gridPadForColumnsInNumericAxis",value:function(t){var e=this.w;if(e.globals.noData||e.globals.allSeriesCollapsed)return 0;var i=function(t){return"bar"===t||"rangeBar"===t||"candlestick"===t||"boxPlot"===t},a=e.config.chart.type,s=0,r=i(a)?e.config.series.length:1;if(e.globals.comboBarCount>0&&(r=e.globals.comboBarCount),e.globals.collapsedSeries.forEach((function(t){i(t.type)&&(r-=1)})),e.config.chart.stacked&&(r=1),(i(a)||e.globals.comboBarCount>0)&&e.globals.isXNumeric&&!e.globals.isBarHorizontal&&r>0){var o,n,l=Math.abs(e.globals.initialMaxX-e.globals.initialMinX);l<=3&&(l=e.globals.dataPoints),o=l/t,e.globals.minXDiff&&e.globals.minXDiff/o>0&&(n=e.globals.minXDiff/o),n>t/2&&(n/=2),(s=n/r*parseInt(e.config.plotOptions.bar.columnWidth,10)/100)<1&&(s=1),s=s/(r>1?1:1.5)+5,e.globals.barPadForNumericAxis=s}return s}},{key:"gridPadFortitleSubtitle",value:function(){var t=this,e=this.w,i=e.globals,a=this.dCtx.isSparkline||!e.globals.axisCharts?0:10;["title","subtitle"].forEach((function(i){void 0!==e.config[i].text?a+=e.config[i].margin:a+=t.dCtx.isSparkline||!e.globals.axisCharts?0:5})),!e.config.legend.show||"bottom"!==e.config.legend.position||e.config.legend.floating||e.globals.axisCharts||(a+=10);var s=this.dCtx.dimHelpers.getTitleSubtitleCoords("title"),r=this.dCtx.dimHelpers.getTitleSubtitleCoords("subtitle");i.gridHeight=i.gridHeight-s.height-r.height-a,i.translateY=i.translateY+s.height+r.height+a}},{key:"setGridXPosForDualYAxis",value:function(t,e){var i=this.w,a=new j(this.dCtx.ctx);i.config.yaxis.map((function(s,r){-1!==i.globals.ignoreYAxisIndexes.indexOf(r)||s.floating||a.isYAxisHidden(r)||(s.opposite&&(i.globals.translateX=i.globals.translateX-(e[r].width+t[r].width)-parseInt(i.config.yaxis[r].labels.style.fontSize,10)/1.2-12),i.globals.translateX<2&&(i.globals.translateX=2))}))}}]),t}(),ht=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.lgRect={},this.yAxisWidth=0,this.yAxisWidthLeft=0,this.yAxisWidthRight=0,this.xAxisHeight=0,this.isSparkline=this.w.config.chart.sparkline.enabled,this.dimHelpers=new rt(this),this.dimYAxis=new nt(this),this.dimXAxis=new ot(this),this.dimGrid=new lt(this),this.lgWidthForSideLegends=0,this.gridPad=this.w.config.grid.padding,this.xPadRight=0,this.xPadLeft=0}return h(t,[{key:"plotCoords",value:function(){var t=this,e=this.w,i=e.globals;this.lgRect=this.dimHelpers.getLegendsRect(),this.isSparkline&&(e.config.markers.discrete.length>0||e.config.markers.size>0)&&Object.entries(this.gridPad).forEach((function(e){var i=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var a,s,r=[],o=!0,n=!1;try{for(i=i.call(t);!(o=(a=i.next()).done)&&(r.push(a.value),!e||r.length!==e);o=!0);}catch(t){n=!0,s=t}finally{try{o||null==i.return||i.return()}finally{if(n)throw s}}return r}}(t,e)||b(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(e,2),a=i[0],s=i[1];t.gridPad[a]=Math.max(s,t.w.globals.markers.largestSize/1.5)})),i.axisCharts?this.setDimensionsForAxisCharts():this.setDimensionsForNonAxisCharts(),this.dimGrid.gridPadFortitleSubtitle(),i.gridHeight=i.gridHeight-this.gridPad.top-this.gridPad.bottom,i.gridWidth=i.gridWidth-this.gridPad.left-this.gridPad.right-this.xPadRight-this.xPadLeft;var a=this.dimGrid.gridPadForColumnsInNumericAxis(i.gridWidth);i.gridWidth=i.gridWidth-2*a,i.translateX=i.translateX+this.gridPad.left+this.xPadLeft+(a>0?a+4:0),i.translateY=i.translateY+this.gridPad.top}},{key:"setDimensionsForAxisCharts",value:function(){var t=this,e=this.w,i=e.globals,a=this.dimYAxis.getyAxisLabelsCoords(),s=this.dimYAxis.getyAxisTitleCoords();e.globals.yLabelsCoords=[],e.globals.yTitleCoords=[],e.config.yaxis.map((function(t,i){e.globals.yLabelsCoords.push({width:a[i].width,index:i}),e.globals.yTitleCoords.push({width:s[i].width,index:i})})),this.yAxisWidth=this.dimYAxis.getTotalYAxisWidth();var r=this.dimXAxis.getxAxisLabelsCoords(),o=this.dimXAxis.getxAxisGroupLabelsCoords(),n=this.dimXAxis.getxAxisTitleCoords();this.conditionalChecksForAxisCoords(r,n,o),i.translateXAxisY=e.globals.rotateXLabels?this.xAxisHeight/8:-4,i.translateXAxisX=e.globals.rotateXLabels&&e.globals.isXNumeric&&e.config.xaxis.labels.rotate<=-45?-this.xAxisWidth/4:0,e.globals.isBarHorizontal&&(i.rotateXLabels=!1,i.translateXAxisY=parseInt(e.config.xaxis.labels.style.fontSize,10)/1.5*-1),i.translateXAxisY=i.translateXAxisY+e.config.xaxis.labels.offsetY,i.translateXAxisX=i.translateXAxisX+e.config.xaxis.labels.offsetX;var l=this.yAxisWidth,h=this.xAxisHeight;i.xAxisLabelsHeight=this.xAxisHeight-n.height,i.xAxisGroupLabelsHeight=i.xAxisLabelsHeight-r.height,i.xAxisLabelsWidth=this.xAxisWidth,i.xAxisHeight=this.xAxisHeight;var c=10;("radar"===e.config.chart.type||this.isSparkline)&&(l=0,h=i.goldenPadding),this.isSparkline&&(this.lgRect={height:0,width:0}),(this.isSparkline||"treemap"===e.config.chart.type)&&(l=0,h=0,c=0),this.isSparkline||this.dimXAxis.additionalPaddingXLabels(r);var d=function(){i.translateX=l,i.gridHeight=i.svgHeight-t.lgRect.height-h-(t.isSparkline||"treemap"===e.config.chart.type?0:e.globals.rotateXLabels?10:15),i.gridWidth=i.svgWidth-l};switch("top"===e.config.xaxis.position&&(c=i.xAxisHeight-e.config.xaxis.axisTicks.height-5),e.config.legend.position){case"bottom":i.translateY=c,d();break;case"top":i.translateY=this.lgRect.height+c,d();break;case"left":i.translateY=c,i.translateX=this.lgRect.width+l,i.gridHeight=i.svgHeight-h-12,i.gridWidth=i.svgWidth-this.lgRect.width-l;break;case"right":i.translateY=c,i.translateX=l,i.gridHeight=i.svgHeight-h-12,i.gridWidth=i.svgWidth-this.lgRect.width-l-5;break;default:throw new Error("Legend position not supported")}this.dimGrid.setGridXPosForDualYAxis(s,a),new J(this.ctx).setYAxisXPosition(a,s)}},{key:"setDimensionsForNonAxisCharts",value:function(){var t=this.w,e=t.globals,i=t.config,a=0;t.config.legend.show&&!t.config.legend.floating&&(a=20);var s="pie"===i.chart.type||"polarArea"===i.chart.type||"donut"===i.chart.type?"pie":"radialBar",r=i.plotOptions[s].offsetY,o=i.plotOptions[s].offsetX;if(!i.legend.show||i.legend.floating)return e.gridHeight=e.svgHeight-i.grid.padding.left+i.grid.padding.right,e.gridWidth=e.gridHeight,e.translateY=r,void(e.translateX=o+(e.svgWidth-e.gridWidth)/2);switch(i.legend.position){case"bottom":e.gridHeight=e.svgHeight-this.lgRect.height-e.goldenPadding,e.gridWidth=e.svgWidth,e.translateY=r-10,e.translateX=o+(e.svgWidth-e.gridWidth)/2;break;case"top":e.gridHeight=e.svgHeight-this.lgRect.height-e.goldenPadding,e.gridWidth=e.svgWidth,e.translateY=this.lgRect.height+r+10,e.translateX=o+(e.svgWidth-e.gridWidth)/2;break;case"left":e.gridWidth=e.svgWidth-this.lgRect.width-a,e.gridHeight="auto"!==i.chart.height?e.svgHeight:e.gridWidth,e.translateY=r,e.translateX=o+this.lgRect.width+a;break;case"right":e.gridWidth=e.svgWidth-this.lgRect.width-a-5,e.gridHeight="auto"!==i.chart.height?e.svgHeight:e.gridWidth,e.translateY=r,e.translateX=o+10;break;default:throw new Error("Legend position not supported")}}},{key:"conditionalChecksForAxisCoords",value:function(t,e,i){var a=this.w,s=a.globals.hasGroups?2:1,r=i.height+t.height+e.height,o=a.globals.isMultiLineX?1.2:a.globals.LINE_HEIGHT_RATIO,n=a.globals.rotateXLabels?22:10,l=a.globals.rotateXLabels&&"bottom"===a.config.legend.position?10:0;this.xAxisHeight=r*o+s*n+l,this.xAxisWidth=t.width,this.xAxisHeight-e.height>a.config.xaxis.labels.maxHeight&&(this.xAxisHeight=a.config.xaxis.labels.maxHeight),a.config.xaxis.labels.minHeight&&this.xAxisHeightc&&(this.yAxisWidth=c)}}]),t}(),ct=function(){function t(e){n(this,t),this.w=e.w,this.lgCtx=e}return h(t,[{key:"getLegendStyles",value:function(){var t=document.createElement("style");t.setAttribute("type","text/css");var e=document.createTextNode("\t\n \t\n .apexcharts-legend {\t\n display: flex;\t\n overflow: auto;\t\n padding: 0 10px;\t\n }\t\n .apexcharts-legend.apx-legend-position-bottom, .apexcharts-legend.apx-legend-position-top {\t\n flex-wrap: wrap\t\n }\t\n .apexcharts-legend.apx-legend-position-right, .apexcharts-legend.apx-legend-position-left {\t\n flex-direction: column;\t\n bottom: 0;\t\n }\t\n .apexcharts-legend.apx-legend-position-bottom.apexcharts-align-left, .apexcharts-legend.apx-legend-position-top.apexcharts-align-left, .apexcharts-legend.apx-legend-position-right, .apexcharts-legend.apx-legend-position-left {\t\n justify-content: flex-start;\t\n }\t\n .apexcharts-legend.apx-legend-position-bottom.apexcharts-align-center, .apexcharts-legend.apx-legend-position-top.apexcharts-align-center {\t\n justify-content: center; \t\n }\t\n .apexcharts-legend.apx-legend-position-bottom.apexcharts-align-right, .apexcharts-legend.apx-legend-position-top.apexcharts-align-right {\t\n justify-content: flex-end;\t\n }\t\n .apexcharts-legend-series {\t\n cursor: pointer;\t\n line-height: normal;\t\n }\t\n .apexcharts-legend.apx-legend-position-bottom .apexcharts-legend-series, .apexcharts-legend.apx-legend-position-top .apexcharts-legend-series{\t\n display: flex;\t\n align-items: center;\t\n }\t\n .apexcharts-legend-text {\t\n position: relative;\t\n font-size: 14px;\t\n }\t\n .apexcharts-legend-text *, .apexcharts-legend-marker * {\t\n pointer-events: none;\t\n }\t\n .apexcharts-legend-marker {\t\n position: relative;\t\n display: inline-block;\t\n cursor: pointer;\t\n margin-right: 3px;\t\n border-style: solid;\n }\t\n \t\n .apexcharts-legend.apexcharts-align-right .apexcharts-legend-series, .apexcharts-legend.apexcharts-align-left .apexcharts-legend-series{\t\n display: inline-block;\t\n }\t\n .apexcharts-legend-series.apexcharts-no-click {\t\n cursor: auto;\t\n }\t\n .apexcharts-legend .apexcharts-hidden-zero-series, .apexcharts-legend .apexcharts-hidden-null-series {\t\n display: none !important;\t\n }\t\n .apexcharts-inactive-legend {\t\n opacity: 0.45;\t\n }");return t.appendChild(e),t}},{key:"getLegendBBox",value:function(){var t=this.w.globals.dom.baseEl.querySelector(".apexcharts-legend").getBoundingClientRect(),e=t.width;return{clwh:t.height,clww:e}}},{key:"appendToForeignObject",value:function(){var t=this.w.globals;t.dom.elLegendForeign=document.createElementNS(t.SVGNS,"foreignObject");var e=t.dom.elLegendForeign;e.setAttribute("x",0),e.setAttribute("y",0),e.setAttribute("width",t.svgWidth),e.setAttribute("height",t.svgHeight),t.dom.elLegendWrap.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),e.appendChild(t.dom.elLegendWrap),e.appendChild(this.getLegendStyles()),t.dom.Paper.node.insertBefore(e,t.dom.elGraphical.node)}},{key:"toggleDataSeries",value:function(t,e){var i=this,a=this.w;if(a.globals.axisCharts||"radialBar"===a.config.chart.type){a.globals.resized=!0;var s=null,r=null;a.globals.risingSeries=[],a.globals.axisCharts?(s=a.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(t,"']")),r=parseInt(s.getAttribute("data:realIndex"),10)):(s=a.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(t+1,"']")),r=parseInt(s.getAttribute("rel"),10)-1),e?[{cs:a.globals.collapsedSeries,csi:a.globals.collapsedSeriesIndices},{cs:a.globals.ancillaryCollapsedSeries,csi:a.globals.ancillaryCollapsedSeriesIndices}].forEach((function(t){i.riseCollapsedSeries(t.cs,t.csi,r)})):this.hideSeries({seriesEl:s,realIndex:r})}else{var o=a.globals.dom.Paper.select(" .apexcharts-series[rel='".concat(t+1,"'] path")),n=a.config.chart.type;if("pie"===n||"polarArea"===n||"donut"===n){var l=a.config.plotOptions.pie.donut.labels;new k(this.lgCtx.ctx).pathMouseDown(o.members[0],null),this.lgCtx.ctx.pie.printDataLabelsInner(o.members[0].node,l)}o.fire("click")}}},{key:"hideSeries",value:function(t){var e=t.seriesEl,i=t.realIndex,a=this.w,s=m.clone(a.config.series);if(a.globals.axisCharts){var r=!1;if(a.config.yaxis[i]&&a.config.yaxis[i].show&&a.config.yaxis[i].showAlways&&(r=!0,a.globals.ancillaryCollapsedSeriesIndices.indexOf(i)<0&&(a.globals.ancillaryCollapsedSeries.push({index:i,data:s[i].data.slice(),type:e.parentNode.className.baseVal.split("-")[1]}),a.globals.ancillaryCollapsedSeriesIndices.push(i))),!r){a.globals.collapsedSeries.push({index:i,data:s[i].data.slice(),type:e.parentNode.className.baseVal.split("-")[1]}),a.globals.collapsedSeriesIndices.push(i);var o=a.globals.risingSeries.indexOf(i);a.globals.risingSeries.splice(o,1)}}else a.globals.collapsedSeries.push({index:i,data:s[i]}),a.globals.collapsedSeriesIndices.push(i);for(var n=e.childNodes,l=0;l0){for(var r=0;r-1&&(t[a].data=[])})):t.forEach((function(i,a){e.globals.collapsedSeriesIndices.indexOf(a)>-1&&(t[a]=0)})),t}}]),t}(),dt=function(){function t(e,i){n(this,t),this.ctx=e,this.w=e.w,this.onLegendClick=this.onLegendClick.bind(this),this.onLegendHovered=this.onLegendHovered.bind(this),this.isBarsDistributed="bar"===this.w.config.chart.type&&this.w.config.plotOptions.bar.distributed&&1===this.w.config.series.length,this.legendHelpers=new ct(this)}return h(t,[{key:"init",value:function(){var t=this.w,e=t.globals,i=t.config;if((i.legend.showForSingleSeries&&1===e.series.length||this.isBarsDistributed||e.series.length>1||!e.axisCharts)&&i.legend.show){for(;e.dom.elLegendWrap.firstChild;)e.dom.elLegendWrap.removeChild(e.dom.elLegendWrap.firstChild);this.drawLegends(),m.isIE11()?document.getElementsByTagName("head")[0].appendChild(this.legendHelpers.getLegendStyles()):this.legendHelpers.appendToForeignObject(),"bottom"===i.legend.position||"top"===i.legend.position?this.legendAlignHorizontal():"right"!==i.legend.position&&"left"!==i.legend.position||this.legendAlignVertical()}}},{key:"drawLegends",value:function(){var t=this,e=this.w,i=e.config.legend.fontFamily,a=e.globals.seriesNames,s=e.globals.colors.slice();if("heatmap"===e.config.chart.type){var r=e.config.plotOptions.heatmap.colorScale.ranges;a=r.map((function(t){return t.name?t.name:t.from+" - "+t.to})),s=r.map((function(t){return t.color}))}else this.isBarsDistributed&&(a=e.globals.labels.slice());e.config.legend.customLegendItems.length&&(a=e.config.legend.customLegendItems);for(var o=e.globals.legendFormatter,n=e.config.legend.inverseOrder,l=n?a.length-1:0;n?l>=0:l<=a.length-1;n?l--:l++){var h=o(a[l],{seriesIndex:l,w:e}),c=!1,d=!1;if(e.globals.collapsedSeries.length>0)for(var g=0;g0)for(var u=0;u0?l-10:0)+(h>0?h-10:0)}a.style.position="absolute",r=r+t+i.config.legend.offsetX,o=o+e+i.config.legend.offsetY,a.style.left=r+"px",a.style.top=o+"px","bottom"===i.config.legend.position?(a.style.top="auto",a.style.bottom=5-i.config.legend.offsetY+"px"):"right"===i.config.legend.position&&(a.style.left="auto",a.style.right=25+i.config.legend.offsetX+"px"),["width","height"].forEach((function(t){a.style[t]&&(a.style[t]=parseInt(i.config.legend[t],10)+"px")}))}},{key:"legendAlignHorizontal",value:function(){var t=this.w;t.globals.dom.baseEl.querySelector(".apexcharts-legend").style.right=0;var e=this.legendHelpers.getLegendBBox(),i=new ht(this.ctx),a=i.dimHelpers.getTitleSubtitleCoords("title"),s=i.dimHelpers.getTitleSubtitleCoords("subtitle"),r=0;"bottom"===t.config.legend.position?r=-e.clwh/1.8:"top"===t.config.legend.position&&(r=a.height+s.height+t.config.title.margin+t.config.subtitle.margin-10),this.setLegendWrapXY(20,r)}},{key:"legendAlignVertical",value:function(){var t=this.w,e=this.legendHelpers.getLegendBBox(),i=0;"left"===t.config.legend.position&&(i=20),"right"===t.config.legend.position&&(i=t.globals.svgWidth-e.clww-10),this.setLegendWrapXY(i,20)}},{key:"onLegendHovered",value:function(t){var e=this.w,i=t.target.classList.contains("apexcharts-legend-text")||t.target.classList.contains("apexcharts-legend-marker");if("heatmap"===e.config.chart.type||this.isBarsDistributed){if(i){var a=parseInt(t.target.getAttribute("rel"),10)-1;this.ctx.events.fireEvent("legendHover",[this.ctx,a,this.w]),new B(this.ctx).highlightRangeInSeries(t,t.target)}}else!t.target.classList.contains("apexcharts-inactive-legend")&&i&&new B(this.ctx).toggleSeriesOnHover(t,t.target)}},{key:"onLegendClick",value:function(t){var e=this.w;if(!e.config.legend.customLegendItems.length&&(t.target.classList.contains("apexcharts-legend-text")||t.target.classList.contains("apexcharts-legend-marker"))){var i=parseInt(t.target.getAttribute("rel"),10)-1,a="true"===t.target.getAttribute("data:collapsed"),s=this.w.config.chart.events.legendClick;"function"==typeof s&&s(this.ctx,i,this.w),this.ctx.events.fireEvent("legendClick",[this.ctx,i,this.w]);var r=this.w.config.legend.markers.onClick;"function"==typeof r&&t.target.classList.contains("apexcharts-legend-marker")&&(r(this.ctx,i,this.w),this.ctx.events.fireEvent("legendMarkerClick",[this.ctx,i,this.w])),"treemap"!==e.config.chart.type&&"heatmap"!==e.config.chart.type&&!this.isBarsDistributed&&e.config.legend.onItemClick.toggleDataSeries&&this.legendHelpers.toggleDataSeries(i,a)}}}]),t}(),gt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w;var i=this.w;this.ev=this.w.config.chart.events,this.selectedClass="apexcharts-selected",this.localeValues=this.w.globals.locale.toolbar,this.minX=i.globals.minX,this.maxX=i.globals.maxX}return h(t,[{key:"createToolbar",value:function(){var t=this,e=this.w,i=function(){return document.createElement("div")},a=i();if(a.setAttribute("class","apexcharts-toolbar"),a.style.top=e.config.chart.toolbar.offsetY+"px",a.style.right=3-e.config.chart.toolbar.offsetX+"px",e.globals.dom.elWrap.appendChild(a),this.elZoom=i(),this.elZoomIn=i(),this.elZoomOut=i(),this.elPan=i(),this.elSelection=i(),this.elZoomReset=i(),this.elMenuIcon=i(),this.elMenu=i(),this.elCustomIcons=[],this.t=e.config.chart.toolbar.tools,Array.isArray(this.t.customIcons))for(var s=0;s\n \n \n\n'),o("zoomOut",this.elZoomOut,'\n \n \n\n');var n=function(i){t.t[i]&&e.config.chart[i].enabled&&r.push({el:"zoom"===i?t.elZoom:t.elSelection,icon:"string"==typeof t.t[i]?t.t[i]:"zoom"===i?'\n \n \n \n':'\n \n \n',title:t.localeValues["zoom"===i?"selectionZoom":"selection"],class:e.globals.isTouchDevice?"apexcharts-element-hidden":"apexcharts-".concat(i,"-icon")})};n("zoom"),n("selection"),this.t.pan&&e.config.chart.zoom.enabled&&r.push({el:this.elPan,icon:"string"==typeof this.t.pan?this.t.pan:'\n \n \n \n \n \n \n \n',title:this.localeValues.pan,class:e.globals.isTouchDevice?"apexcharts-element-hidden":"apexcharts-pan-icon"}),o("reset",this.elZoomReset,'\n \n \n'),this.t.download&&r.push({el:this.elMenuIcon,icon:"string"==typeof this.t.download?this.t.download:'',title:this.localeValues.menu,class:"apexcharts-menu-icon"});for(var l=0;l0&&e.height>0&&this.slDraggableRect.selectize({points:"l, r",pointSize:8,pointType:"rect"}).resize({constraint:{minX:0,minY:0,maxX:t.globals.gridWidth,maxY:t.globals.gridHeight}}).on("resizing",this.selectionDragging.bind(this,"resizing"))}}},{key:"preselectedSelection",value:function(){var t=this.w,e=this.xyRatios;if(!t.globals.zoomEnabled)if(void 0!==t.globals.selection&&null!==t.globals.selection)this.drawSelectionRect(t.globals.selection);else if(void 0!==t.config.chart.selection.xaxis.min&&void 0!==t.config.chart.selection.xaxis.max){var i=(t.config.chart.selection.xaxis.min-t.globals.minX)/e.xRatio,a={x:i,y:0,width:t.globals.gridWidth-(t.globals.maxX-t.config.chart.selection.xaxis.max)/e.xRatio-i,height:t.globals.gridHeight,translateX:0,translateY:0,selectionEnabled:!0};this.drawSelectionRect(a),this.makeSelectionRectDraggable(),"function"==typeof t.config.chart.events.selection&&t.config.chart.events.selection(this.ctx,{xaxis:{min:t.config.chart.selection.xaxis.min,max:t.config.chart.selection.xaxis.max},yaxis:{}})}}},{key:"drawSelectionRect",value:function(t){var e=t.x,i=t.y,a=t.width,s=t.height,r=t.translateX,o=void 0===r?0:r,n=t.translateY,l=void 0===n?0:n,h=this.w,c=this.zoomRect,d=this.selectionRect;if(this.dragged||null!==h.globals.selection){var g={transform:"translate("+o+", "+l+")"};h.globals.zoomEnabled&&this.dragged&&(a<0&&(a=1),c.attr({x:e,y:i,width:a,height:s,fill:h.config.chart.zoom.zoomedArea.fill.color,"fill-opacity":h.config.chart.zoom.zoomedArea.fill.opacity,stroke:h.config.chart.zoom.zoomedArea.stroke.color,"stroke-width":h.config.chart.zoom.zoomedArea.stroke.width,"stroke-opacity":h.config.chart.zoom.zoomedArea.stroke.opacity}),k.setAttrs(c.node,g)),h.globals.selectionEnabled&&(d.attr({x:e,y:i,width:a>0?a:0,height:s>0?s:0,fill:h.config.chart.selection.fill.color,"fill-opacity":h.config.chart.selection.fill.opacity,stroke:h.config.chart.selection.stroke.color,"stroke-width":h.config.chart.selection.stroke.width,"stroke-dasharray":h.config.chart.selection.stroke.dashArray,"stroke-opacity":h.config.chart.selection.stroke.opacity}),k.setAttrs(d.node,g))}}},{key:"hideSelectionRect",value:function(t){t&&t.attr({x:0,y:0,width:0,height:0})}},{key:"selectionDrawing",value:function(t){var e,i=t.context,a=t.zoomtype,s=this.w,r=i,o=this.gridRect.getBoundingClientRect(),n=r.startX-1,l=r.startY,h=!1,c=!1,d=r.clientX-o.left-n,g=r.clientY-o.top-l;return Math.abs(d+n)>s.globals.gridWidth?d=s.globals.gridWidth-n:r.clientX-o.left<0&&(d=n),n>r.clientX-o.left&&(h=!0,d=Math.abs(d)),l>r.clientY-o.top&&(c=!0,g=Math.abs(g)),e="x"===a?{x:h?n-d:n,y:0,width:d,height:s.globals.gridHeight}:"y"===a?{x:0,y:c?l-g:l,width:s.globals.gridWidth,height:g}:{x:h?n-d:n,y:c?l-g:l,width:d,height:g},r.drawSelectionRect(e),r.selectionDragging("resizing"),e}},{key:"selectionDragging",value:function(t,e){var i=this,a=this.w,s=this.xyRatios,r=this.selectionRect,o=0;"resizing"===t&&(o=30);var n=function(t){return parseFloat(r.node.getAttribute(t))},l={x:n("x"),y:n("y"),width:n("width"),height:n("height")};a.globals.selection=l,"function"==typeof a.config.chart.events.selection&&a.globals.selectionEnabled&&(clearTimeout(this.w.globals.selectionResizeTimer),this.w.globals.selectionResizeTimer=window.setTimeout((function(){var t=i.gridRect.getBoundingClientRect(),e=r.node.getBoundingClientRect(),o={xaxis:{min:a.globals.xAxisScale.niceMin+(e.left-t.left)*s.xRatio,max:a.globals.xAxisScale.niceMin+(e.right-t.left)*s.xRatio},yaxis:{min:a.globals.yAxisScale[0].niceMin+(t.bottom-e.bottom)*s.yRatio[0],max:a.globals.yAxisScale[0].niceMax-(e.top-t.top)*s.yRatio[0]}};a.config.chart.events.selection(i.ctx,o),a.config.chart.brush.enabled&&void 0!==a.config.chart.events.brushScrolled&&a.config.chart.events.brushScrolled(i.ctx,o)}),o))}},{key:"selectionDrawn",value:function(t){var e=t.context,i=t.zoomtype,a=this.w,s=e,r=this.xyRatios,o=this.ctx.toolbar;if(s.startX>s.endX){var n=s.startX;s.startX=s.endX,s.endX=n}if(s.startY>s.endY){var l=s.startY;s.startY=s.endY,s.endY=l}var h=void 0,c=void 0;a.globals.isRangeBar?(h=a.globals.yAxisScale[0].niceMin+s.startX*r.invertedYRatio,c=a.globals.yAxisScale[0].niceMin+s.endX*r.invertedYRatio):(h=a.globals.xAxisScale.niceMin+s.startX*r.xRatio,c=a.globals.xAxisScale.niceMin+s.endX*r.xRatio);var d=[],g=[];if(a.config.yaxis.forEach((function(t,e){d.push(a.globals.yAxisScale[e].niceMax-r.yRatio[e]*s.startY),g.push(a.globals.yAxisScale[e].niceMax-r.yRatio[e]*s.endY)})),s.dragged&&(s.dragX>10||s.dragY>10)&&h!==c)if(a.globals.zoomEnabled){var u=m.clone(a.globals.initialConfig.yaxis),f=m.clone(a.globals.initialConfig.xaxis);if(a.globals.zoomed=!0,a.config.xaxis.convertedCatToNumeric&&(h=Math.floor(h),c=Math.floor(c),h<1&&(h=1,c=a.globals.dataPoints),c-h<2&&(c=h+1)),"xy"!==i&&"x"!==i||(f={min:h,max:c}),"xy"!==i&&"y"!==i||u.forEach((function(t,e){u[e].min=g[e],u[e].max=d[e]})),a.config.chart.zoom.autoScaleYaxis){var p=new Z(s.ctx);u=p.autoScaleY(s.ctx,u,{xaxis:f})}if(o){var x=o.getBeforeZoomRange(f,u);x&&(f=x.xaxis?x.xaxis:f,u=x.yaxis?x.yaxis:u)}var b={xaxis:f};a.config.chart.group||(b.yaxis=u),s.ctx.updateHelpers._updateOptions(b,!1,s.w.config.chart.animations.dynamicAnimation.enabled),"function"==typeof a.config.chart.events.zoomed&&o.zoomCallback(f,u)}else if(a.globals.selectionEnabled){var v,y=null;v={min:h,max:c},"xy"!==i&&"y"!==i||(y=m.clone(a.config.yaxis)).forEach((function(t,e){y[e].min=g[e],y[e].max=d[e]})),a.globals.selection=s.selection,"function"==typeof a.config.chart.events.selection&&a.config.chart.events.selection(s.ctx,{xaxis:v,yaxis:y})}}},{key:"panDragging",value:function(t){var e=t.context,i=this.w,a=e;if(void 0!==i.globals.lastClientPosition.x){var s=i.globals.lastClientPosition.x-a.clientX,r=i.globals.lastClientPosition.y-a.clientY;Math.abs(s)>Math.abs(r)&&s>0?this.moveDirection="left":Math.abs(s)>Math.abs(r)&&s<0?this.moveDirection="right":Math.abs(r)>Math.abs(s)&&r>0?this.moveDirection="up":Math.abs(r)>Math.abs(s)&&r<0&&(this.moveDirection="down")}i.globals.lastClientPosition={x:a.clientX,y:a.clientY};var o=i.globals.isRangeBar?i.globals.minY:i.globals.minX,n=i.globals.isRangeBar?i.globals.maxY:i.globals.maxX;i.config.xaxis.convertedCatToNumeric||a.panScrolled(o,n)}},{key:"delayedPanScrolled",value:function(){var t=this.w,e=t.globals.minX,i=t.globals.maxX,a=(t.globals.maxX-t.globals.minX)/2;"left"===this.moveDirection?(e=t.globals.minX+a,i=t.globals.maxX+a):"right"===this.moveDirection&&(e=t.globals.minX-a,i=t.globals.maxX-a),e=Math.floor(e),i=Math.floor(i),this.updateScrolledChart({xaxis:{min:e,max:i}},e,i)}},{key:"panScrolled",value:function(t,e){var i=this.w,a=this.xyRatios,s=m.clone(i.globals.initialConfig.yaxis),r=a.xRatio,o=i.globals.minX,n=i.globals.maxX;i.globals.isRangeBar&&(r=a.invertedYRatio,o=i.globals.minY,n=i.globals.maxY),"left"===this.moveDirection?(t=o+i.globals.gridWidth/15*r,e=n+i.globals.gridWidth/15*r):"right"===this.moveDirection&&(t=o-i.globals.gridWidth/15*r,e=n-i.globals.gridWidth/15*r),i.globals.isRangeBar||(ti.globals.initialMaxX)&&(t=o,e=n);var l={min:t,max:e};i.config.chart.zoom.autoScaleYaxis&&(s=new Z(this.ctx).autoScaleY(this.ctx,s,{xaxis:l}));var h={xaxis:{min:t,max:e}};i.config.chart.group||(h.yaxis=s),this.updateScrolledChart(h,t,e)}},{key:"updateScrolledChart",value:function(t,e,i){var a=this.w;this.ctx.updateHelpers._updateOptions(t,!1,!1),"function"==typeof a.config.chart.events.scrolled&&a.config.chart.events.scrolled(this.ctx,{xaxis:{min:e,max:i}})}}]),i}(),ft=function(){function t(e){n(this,t),this.w=e.w,this.ttCtx=e,this.ctx=e.ctx}return h(t,[{key:"getNearestValues",value:function(t){var e=t.hoverArea,i=t.elGrid,a=t.clientX,s=t.clientY,r=this.w,o=i.getBoundingClientRect(),n=o.width,l=o.height,h=n/(r.globals.dataPoints-1),c=l/r.globals.dataPoints,d=this.hasBars();!r.globals.comboCharts&&!d||r.config.xaxis.convertedCatToNumeric||(h=n/r.globals.dataPoints);var g=a-o.left-r.globals.barPadForNumericAxis,u=s-o.top;g<0||u<0||g>n||u>l?(e.classList.remove("hovering-zoom"),e.classList.remove("hovering-pan")):r.globals.zoomEnabled?(e.classList.remove("hovering-pan"),e.classList.add("hovering-zoom")):r.globals.panEnabled&&(e.classList.remove("hovering-zoom"),e.classList.add("hovering-pan"));var f=Math.round(g/h),p=Math.floor(u/c);d&&!r.config.xaxis.convertedCatToNumeric&&(f=Math.ceil(g/h),f-=1);var x=null,b=null,v=[],y=[];if(r.globals.seriesXvalues.forEach((function(t){v.push([t[0]+1e-6].concat(t))})),r.globals.seriesYvalues.forEach((function(t){y.push([t[0]+1e-6].concat(t))})),v=v.map((function(t){return t.filter((function(t){return m.isNumber(t)}))})),y=y.map((function(t){return t.filter((function(t){return m.isNumber(t)}))})),r.globals.isXNumeric){var w=this.ttCtx.getElGrid().getBoundingClientRect(),k=g*(w.width/n),A=u*(w.height/l);x=(b=this.closestInMultiArray(k,A,v,y)).index,f=b.j,null!==x&&(v=r.globals.seriesXvalues[x],f=(b=this.closestInArray(k,v)).index)}return r.globals.capturedSeriesIndex=null===x?-1:x,(!f||f<1)&&(f=0),r.globals.isBarHorizontal?r.globals.capturedDataPointIndex=p:r.globals.capturedDataPointIndex=f,{capturedSeries:x,j:r.globals.isBarHorizontal?p:f,hoverX:g,hoverY:u}}},{key:"closestInMultiArray",value:function(t,e,i,a){var s=this.w,r=0,o=null,n=-1;s.globals.series.length>1?r=this.getFirstActiveXArray(i):o=0;var l=i[r][0],h=Math.abs(t-l);if(i.forEach((function(e){e.forEach((function(e,i){var a=Math.abs(t-e);a0?e:-1})),s=0;s0)for(var a=0;ai?-1:0}));var e=[];return t.forEach((function(t){e.push(t.querySelector(".apexcharts-marker"))})),e}},{key:"hasMarkers",value:function(){return this.getElMarkers().length>0}},{key:"getElBars",value:function(){return this.w.globals.dom.baseEl.querySelectorAll(".apexcharts-bar-series, .apexcharts-candlestick-series, .apexcharts-boxPlot-series, .apexcharts-rangebar-series")}},{key:"hasBars",value:function(){return this.getElBars().length>0}},{key:"getHoverMarkerSize",value:function(t){var e=this.w,i=e.config.markers.hover.size;return void 0===i&&(i=e.globals.markers.size[t]+e.config.markers.hover.sizeOffset),i}},{key:"toggleAllTooltipSeriesGroups",value:function(t){var e=this.w,i=this.ttCtx;0===i.allTooltipSeriesGroups.length&&(i.allTooltipSeriesGroups=e.globals.dom.baseEl.querySelectorAll(".apexcharts-tooltip-series-group"));for(var a=i.allTooltipSeriesGroups,s=0;s ').concat(i.attrs.name,""),e+="
".concat(i.val,"
")})),v.innerHTML=t+"",m.innerHTML=e+""};o?l.globals.seriesGoals[e][i]&&Array.isArray(l.globals.seriesGoals[e][i])?y():(v.innerHTML="",m.innerHTML=""):y()}else v.innerHTML="",m.innerHTML="";null!==f&&(a[e].querySelector(".apexcharts-tooltip-text-z-label").innerHTML=l.config.tooltip.z.title,a[e].querySelector(".apexcharts-tooltip-text-z-value").innerHTML=void 0!==f?f:""),o&&p[0]&&(null==c||l.globals.ancillaryCollapsedSeriesIndices.indexOf(e)>-1||l.globals.collapsedSeriesIndices.indexOf(e)>-1?p[0].parentNode.style.display="none":p[0].parentNode.style.display=l.config.tooltip.items.display)}},{key:"toggleActiveInactiveSeries",value:function(t){var e=this.w;if(t)this.tooltipUtil.toggleAllTooltipSeriesGroups("enable");else{this.tooltipUtil.toggleAllTooltipSeriesGroups("disable");var i=e.globals.dom.baseEl.querySelector(".apexcharts-tooltip-series-group");i&&(i.classList.add("apexcharts-active"),i.style.display=e.config.tooltip.items.display)}}},{key:"getValuesToPrint",value:function(t){var e=t.i,i=t.j,a=this.w,s=this.ctx.series.filteredSeriesX(),r="",o="",n=null,l=null,h={series:a.globals.series,seriesIndex:e,dataPointIndex:i,w:a},c=a.globals.ttZFormatter;null===i?l=a.globals.series[e]:a.globals.isXNumeric&&"treemap"!==a.config.chart.type?(r=s[e][i],0===s[e].length&&(r=s[this.tooltipUtil.getFirstActiveXArray(s)][i])):r=void 0!==a.globals.labels[i]?a.globals.labels[i]:"";var d=r;return r=a.globals.isXNumeric&&"datetime"===a.config.xaxis.type?new V(this.ctx).xLabelFormat(a.globals.ttKeyFormatter,d,d,{i:void 0,dateFormatter:new z(this.ctx).formatDate,w:this.w}):a.globals.isBarHorizontal?a.globals.yLabelFormatters[0](d,h):a.globals.xLabelFormatter(d,h),void 0!==a.config.tooltip.x.formatter&&(r=a.globals.ttKeyFormatter(d,h)),a.globals.seriesZ.length>0&&a.globals.seriesZ[e].length>0&&(n=c(a.globals.seriesZ[e][i],a)),o="function"==typeof a.config.xaxis.tooltip.formatter?a.globals.xaxisTooltipFormatter(d,h):r,{val:Array.isArray(l)?l.join(" "):l,xVal:Array.isArray(r)?r.join(" "):r,xAxisTTVal:Array.isArray(o)?o.join(" "):o,zVal:n}}},{key:"handleCustomTooltip",value:function(t){var e=t.i,i=t.j,a=t.y1,s=t.y2,r=t.w,o=this.ttCtx.getElTooltip(),n=r.config.tooltip.custom;Array.isArray(n)&&n[e]&&(n=n[e]),o.innerHTML=n({ctx:this.ctx,series:r.globals.series,seriesIndex:e,dataPointIndex:i,y1:a,y2:s,w:r})}}]),t}(),xt=function(){function t(e){n(this,t),this.ttCtx=e,this.ctx=e.ctx,this.w=e.w}return h(t,[{key:"moveXCrosshairs",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=this.ttCtx,a=this.w,s=i.getElXCrosshairs(),r=t-i.xcrosshairsWidth/2,o=a.globals.labels.slice().length;if(null!==e&&(r=a.globals.gridWidth/o*e),null===s||a.globals.isBarHorizontal||(s.setAttribute("x",r),s.setAttribute("x1",r),s.setAttribute("x2",r),s.setAttribute("y2",a.globals.gridHeight),s.classList.add("apexcharts-active")),r<0&&(r=0),r>a.globals.gridWidth&&(r=a.globals.gridWidth),i.isXAxisTooltipEnabled){var n=r;"tickWidth"!==a.config.xaxis.crosshairs.width&&"barWidth"!==a.config.xaxis.crosshairs.width||(n=r+i.xcrosshairsWidth/2),this.moveXAxisTooltip(n)}}},{key:"moveYCrosshairs",value:function(t){var e=this.ttCtx;null!==e.ycrosshairs&&k.setAttrs(e.ycrosshairs,{y1:t,y2:t}),null!==e.ycrosshairsHidden&&k.setAttrs(e.ycrosshairsHidden,{y1:t,y2:t})}},{key:"moveXAxisTooltip",value:function(t){var e=this.w,i=this.ttCtx;if(null!==i.xaxisTooltip&&0!==i.xcrosshairsWidth){i.xaxisTooltip.classList.add("apexcharts-active");var a,s=i.xaxisOffY+e.config.xaxis.tooltip.offsetY+e.globals.translateY+1+e.config.xaxis.offsetY;if(t-=i.xaxisTooltip.getBoundingClientRect().width/2,!isNaN(t))t+=e.globals.translateX,a=new k(this.ctx).getTextRects(i.xaxisTooltipText.innerHTML),i.xaxisTooltipText.style.minWidth=a.width+"px",i.xaxisTooltip.style.left=t+"px",i.xaxisTooltip.style.top=s+"px"}}},{key:"moveYAxisTooltip",value:function(t){var e=this.w,i=this.ttCtx;null===i.yaxisTTEls&&(i.yaxisTTEls=e.globals.dom.baseEl.querySelectorAll(".apexcharts-yaxistooltip"));var a=parseInt(i.ycrosshairsHidden.getAttribute("y1"),10),s=e.globals.translateY+a,r=i.yaxisTTEls[t].getBoundingClientRect().height,o=e.globals.translateYAxisX[t]-2;e.config.yaxis[t].opposite&&(o-=26),s-=r/2,-1===e.globals.ignoreYAxisIndexes.indexOf(t)?(i.yaxisTTEls[t].classList.add("apexcharts-active"),i.yaxisTTEls[t].style.top=s+"px",i.yaxisTTEls[t].style.left=o+e.config.yaxis[t].tooltip.offsetX+"px"):i.yaxisTTEls[t].classList.remove("apexcharts-active")}},{key:"moveTooltip",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=this.w,s=this.ttCtx,r=s.getElTooltip(),o=s.tooltipRect,n=null!==i?parseFloat(i):1,l=parseFloat(t)+n+5,h=parseFloat(e)+n/2;if(l>a.globals.gridWidth/2&&(l=l-o.ttWidth-n-10),l>a.globals.gridWidth-o.ttWidth-10&&(l=a.globals.gridWidth-o.ttWidth),l<-20&&(l=-20),a.config.tooltip.followCursor){var c=s.getElGrid(),d=c.getBoundingClientRect();h=s.e.clientY+a.globals.translateY-d.top-o.ttHeight/2}else a.globals.isBarHorizontal||(o.ttHeight/2+h>a.globals.gridHeight&&(h=a.globals.gridHeight-o.ttHeight+a.globals.translateY),h<0&&(h=0));isNaN(l)||(l+=a.globals.translateX,r.style.left=l+"px",r.style.top=h+"px")}},{key:"moveMarkers",value:function(t,e){var i=this.w,a=this.ttCtx;if(i.globals.markers.size[t]>0)for(var s=i.globals.dom.baseEl.querySelectorAll(" .apexcharts-series[data\\:realIndex='".concat(t,"'] .apexcharts-marker")),r=0;r0&&(h.setAttribute("r",n),h.setAttribute("cx",i),h.setAttribute("cy",a)),this.moveXCrosshairs(i),r.fixedTooltip||this.moveTooltip(i,a,n)}}},{key:"moveDynamicPointsOnHover",value:function(t){var e,i=this.ttCtx,a=i.w,s=0,r=0,o=a.globals.pointsArray;e=new B(this.ctx).getActiveConfigSeriesIndex("asc",["line","area","scatter","bubble"]);var n=i.tooltipUtil.getHoverMarkerSize(e);o[e]&&(s=o[e][t][0],r=o[e][t][1]);var l=i.tooltipUtil.getAllMarkers();if(null!==l)for(var h=0;h0?(l[h]&&l[h].setAttribute("r",n),l[h]&&l[h].setAttribute("cy",d)):l[h]&&l[h].setAttribute("r",0)}}if(this.moveXCrosshairs(s),!i.fixedTooltip){var f=r||a.globals.gridHeight;this.moveTooltip(s,f,n)}}},{key:"moveStickyTooltipOverBars",value:function(t){var e=this.w,i=this.ttCtx,a=e.globals.columnSeries?e.globals.columnSeries.length:e.globals.series.length,s=a>=2&&a%2==0?Math.floor(a/2):Math.floor(a/2)+1;e.globals.isBarHorizontal&&(s=new B(this.ctx).getActiveConfigSeriesIndex("desc")+1);var r=e.globals.dom.baseEl.querySelector(".apexcharts-bar-series .apexcharts-series[rel='".concat(s,"'] path[j='").concat(t,"'], .apexcharts-candlestick-series .apexcharts-series[rel='").concat(s,"'] path[j='").concat(t,"'], .apexcharts-boxPlot-series .apexcharts-series[rel='").concat(s,"'] path[j='").concat(t,"'], .apexcharts-rangebar-series .apexcharts-series[rel='").concat(s,"'] path[j='").concat(t,"']")),o=r?parseFloat(r.getAttribute("cx")):0,n=r?parseFloat(r.getAttribute("cy")):0,l=r?parseFloat(r.getAttribute("barWidth")):0,h=r?parseFloat(r.getAttribute("barHeight")):0,c=i.getElGrid().getBoundingClientRect(),d=r.classList.contains("apexcharts-candlestick-area")||r.classList.contains("apexcharts-boxPlot-area");if(e.globals.isXNumeric?(r&&!d&&(o-=a%2!=0?l/2:0),r&&d&&e.globals.comboCharts&&(o-=l/2)):e.globals.isBarHorizontal||(o=i.xAxisTicksPositions[t-1]+i.dataPointsDividedWidth/2,isNaN(o)&&(o=i.xAxisTicksPositions[t]-i.dataPointsDividedWidth/2)),e.globals.isBarHorizontal?(n>e.globals.gridHeight/2&&(n-=i.tooltipRect.ttHeight),(n=n+e.config.grid.padding.top+h/3)+h>e.globals.gridHeight&&(n=e.globals.gridHeight-h)):e.config.tooltip.followCursor?n=i.e.clientY-c.top-i.tooltipRect.ttHeight/2:n+i.tooltipRect.ttHeight+15>e.globals.gridHeight&&(n=e.globals.gridHeight),n<-10&&(n=-10),e.globals.isBarHorizontal||this.moveXCrosshairs(o),!i.fixedTooltip){var g=n||e.globals.gridHeight;this.moveTooltip(o,g)}}}]),t}(),bt=function(){function t(e){n(this,t),this.w=e.w,this.ttCtx=e,this.ctx=e.ctx,this.tooltipPosition=new xt(e)}return h(t,[{key:"drawDynamicPoints",value:function(){var t=this.w,e=new k(this.ctx),i=new O(this.ctx),a=t.globals.dom.baseEl.querySelectorAll(".apexcharts-series");a=x(a),t.config.chart.stacked&&a.sort((function(t,e){return parseFloat(t.getAttribute("data:realIndex"))-parseFloat(e.getAttribute("data:realIndex"))}));for(var s=0;s2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=this.w;"bubble"!==s.config.chart.type&&this.newPointSize(t,e);var r=e.getAttribute("cx"),o=e.getAttribute("cy");if(null!==i&&null!==a&&(r=i,o=a),this.tooltipPosition.moveXCrosshairs(r),!this.fixedTooltip){if("radar"===s.config.chart.type){var n=this.ttCtx.getElGrid(),l=n.getBoundingClientRect();r=this.ttCtx.e.clientX-l.left}this.tooltipPosition.moveTooltip(r,o,s.config.markers.hover.size)}}},{key:"enlargePoints",value:function(t){for(var e=this.w,i=this,a=this.ttCtx,s=t,r=e.globals.dom.baseEl.querySelectorAll(".apexcharts-series:not(.apexcharts-series-collapsed) .apexcharts-marker"),o=e.config.markers.hover.size,n=0;n=0?t[e].setAttribute("r",i):t[e].setAttribute("r",0)}}}]),t}(),vt=function(){function t(e){n(this,t),this.w=e.w,this.ttCtx=e}return h(t,[{key:"getAttr",value:function(t,e){return parseFloat(t.target.getAttribute(e))}},{key:"handleHeatTreeTooltip",value:function(t){var e=t.e,i=t.opt,a=t.x,s=t.y,r=t.type,o=this.ttCtx,n=this.w;if(e.target.classList.contains("apexcharts-".concat(r,"-rect"))){var l=this.getAttr(e,"i"),h=this.getAttr(e,"j"),c=this.getAttr(e,"cx"),d=this.getAttr(e,"cy"),g=this.getAttr(e,"width"),u=this.getAttr(e,"height");if(o.tooltipLabels.drawSeriesTexts({ttItems:i.ttItems,i:l,j:h,shared:!1,e:e}),n.globals.capturedSeriesIndex=l,n.globals.capturedDataPointIndex=h,a=c+o.tooltipRect.ttWidth/2+g,s=d+o.tooltipRect.ttHeight/2-u/2,o.tooltipPosition.moveXCrosshairs(c+g/2),a>n.globals.gridWidth/2&&(a=c-o.tooltipRect.ttWidth/2+g),o.w.config.tooltip.followCursor){var f=n.globals.dom.elWrap.getBoundingClientRect();a=n.globals.clientX-f.left-(a>n.globals.gridWidth/2?o.tooltipRect.ttWidth:0),s=n.globals.clientY-f.top-(s>n.globals.gridHeight/2?o.tooltipRect.ttHeight:0)}}return{x:a,y:s}}},{key:"handleMarkerTooltip",value:function(t){var e,i,a=t.e,s=t.opt,r=t.x,o=t.y,n=this.w,l=this.ttCtx;if(a.target.classList.contains("apexcharts-marker")){var h=parseInt(s.paths.getAttribute("cx"),10),c=parseInt(s.paths.getAttribute("cy"),10),d=parseFloat(s.paths.getAttribute("val"));if(i=parseInt(s.paths.getAttribute("rel"),10),e=parseInt(s.paths.parentNode.parentNode.parentNode.getAttribute("rel"),10)-1,l.intersect){var g=m.findAncestor(s.paths,"apexcharts-series");g&&(e=parseInt(g.getAttribute("data:realIndex"),10))}if(l.tooltipLabels.drawSeriesTexts({ttItems:s.ttItems,i:e,j:i,shared:!l.showOnIntersect&&n.config.tooltip.shared,e:a}),"mouseup"===a.type&&l.markerClick(a,e,i),n.globals.capturedSeriesIndex=e,n.globals.capturedDataPointIndex=i,r=h,o=c+n.globals.translateY-1.4*l.tooltipRect.ttHeight,l.w.config.tooltip.followCursor){var u=l.getElGrid().getBoundingClientRect();o=l.e.clientY+n.globals.translateY-u.top}d<0&&(o=c),l.marker.enlargeCurrentPoint(i,s.paths,r,o)}return{x:r,y:o}}},{key:"handleBarTooltip",value:function(t){var e,i,a=t.e,s=t.opt,r=this.w,o=this.ttCtx,n=o.getElTooltip(),l=0,h=0,c=0,d=this.getBarTooltipXY({e:a,opt:s});e=d.i;var g=d.barHeight,u=d.j;r.globals.capturedSeriesIndex=e,r.globals.capturedDataPointIndex=u,r.globals.isBarHorizontal&&o.tooltipUtil.hasBars()||!r.config.tooltip.shared?(h=d.x,c=d.y,i=Array.isArray(r.config.stroke.width)?r.config.stroke.width[e]:r.config.stroke.width,l=h):r.globals.comboCharts||r.config.tooltip.shared||(l/=2),isNaN(c)?c=r.globals.svgHeight-o.tooltipRect.ttHeight:c<0&&(c=0);var f=parseInt(s.paths.parentNode.getAttribute("data:realIndex"),10),p=r.globals.isMultipleYAxis?r.config.yaxis[f]&&r.config.yaxis[f].reversed:r.config.yaxis[0].reversed;if(h+o.tooltipRect.ttWidth>r.globals.gridWidth&&!p?h-=o.tooltipRect.ttWidth:h<0&&(h=0),o.w.config.tooltip.followCursor){var x=o.getElGrid().getBoundingClientRect();c=o.e.clientY-x.top}null===o.tooltip&&(o.tooltip=r.globals.dom.baseEl.querySelector(".apexcharts-tooltip")),r.config.tooltip.shared||(r.globals.comboBarCount>0?o.tooltipPosition.moveXCrosshairs(l+i/2):o.tooltipPosition.moveXCrosshairs(l)),!o.fixedTooltip&&(!r.config.tooltip.shared||r.globals.isBarHorizontal&&o.tooltipUtil.hasBars())&&(p&&(h-=o.tooltipRect.ttWidth)<0&&(h=0),!p||r.globals.isBarHorizontal&&o.tooltipUtil.hasBars()||(c=c+g-2*(r.globals.series[e][u]<0?g:0)),o.tooltipRect.ttHeight+c>r.globals.gridHeight?c=r.globals.gridHeight-o.tooltipRect.ttHeight+r.globals.translateY:(c=c+r.globals.translateY-o.tooltipRect.ttHeight/2)<0&&(c=0),n.style.left=h+r.globals.translateX+"px",n.style.top=c+"px")}},{key:"getBarTooltipXY",value:function(t){var e=t.e,i=t.opt,a=this.w,s=null,r=this.ttCtx,o=0,n=0,l=0,h=0,c=0,d=e.target.classList;if(d.contains("apexcharts-bar-area")||d.contains("apexcharts-candlestick-area")||d.contains("apexcharts-boxPlot-area")||d.contains("apexcharts-rangebar-area")){var g=e.target,u=g.getBoundingClientRect(),f=i.elGrid.getBoundingClientRect(),p=u.height;c=u.height;var x=u.width,b=parseInt(g.getAttribute("cx"),10),v=parseInt(g.getAttribute("cy"),10);h=parseFloat(g.getAttribute("barWidth"));var m="touchmove"===e.type?e.touches[0].clientX:e.clientX;s=parseInt(g.getAttribute("j"),10),o=parseInt(g.parentNode.getAttribute("rel"),10)-1;var y=g.getAttribute("data-range-y1"),w=g.getAttribute("data-range-y2");a.globals.comboCharts&&(o=parseInt(g.parentNode.getAttribute("data:realIndex"),10)),r.tooltipLabels.drawSeriesTexts({ttItems:i.ttItems,i:o,j:s,y1:y?parseInt(y,10):null,y2:w?parseInt(w,10):null,shared:!r.showOnIntersect&&a.config.tooltip.shared,e:e}),a.config.tooltip.followCursor?a.globals.isBarHorizontal?(n=m-f.left+15,l=v-r.dataPointsDividedHeight+p/2-r.tooltipRect.ttHeight/2):(n=a.globals.isXNumeric?b-x/2:b-r.dataPointsDividedWidth+x/2,l=e.clientY-f.top-r.tooltipRect.ttHeight/2-15):a.globals.isBarHorizontal?((n=b)0&&i.setAttribute("width",e.xcrosshairsWidth)}},{key:"handleYCrosshair",value:function(){var t=this.w,e=this.ttCtx;e.ycrosshairs=t.globals.dom.baseEl.querySelector(".apexcharts-ycrosshairs"),e.ycrosshairsHidden=t.globals.dom.baseEl.querySelector(".apexcharts-ycrosshairs-hidden")}},{key:"drawYaxisTooltipText",value:function(t,e,i){var a=this.ttCtx,s=this.w,r=s.globals.yLabelFormatters[t];if(a.yaxisTooltips[t]){var o=a.getElGrid().getBoundingClientRect(),n=(e-o.top)*i.yRatio[t],l=s.globals.maxYArr[t]-s.globals.minYArr[t],h=s.globals.minYArr[t]+(l-n);a.tooltipPosition.moveYCrosshairs(e-o.top),a.yaxisTooltipText[t].innerHTML=r(h),a.tooltipPosition.moveYAxisTooltip(t)}}}]),t}(),yt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w;var i=this.w;this.tConfig=i.config.tooltip,this.tooltipUtil=new ft(this),this.tooltipLabels=new pt(this),this.tooltipPosition=new xt(this),this.marker=new bt(this),this.intersect=new vt(this),this.axesTooltip=new mt(this),this.showOnIntersect=this.tConfig.intersect,this.showTooltipTitle=this.tConfig.x.show,this.fixedTooltip=this.tConfig.fixed.enabled,this.xaxisTooltip=null,this.yaxisTTEls=null,this.isBarShared=!i.globals.isBarHorizontal&&this.tConfig.shared,this.lastHoverTime=Date.now()}return h(t,[{key:"getElTooltip",value:function(t){return t||(t=this),t.w.globals.dom.baseEl?t.w.globals.dom.baseEl.querySelector(".apexcharts-tooltip"):null}},{key:"getElXCrosshairs",value:function(){return this.w.globals.dom.baseEl.querySelector(".apexcharts-xcrosshairs")}},{key:"getElGrid",value:function(){return this.w.globals.dom.baseEl.querySelector(".apexcharts-grid")}},{key:"drawTooltip",value:function(t){var e=this.w;this.xyRatios=t,this.isXAxisTooltipEnabled=e.config.xaxis.tooltip.enabled&&e.globals.axisCharts,this.yaxisTooltips=e.config.yaxis.map((function(t,i){return!!(t.show&&t.tooltip.enabled&&e.globals.axisCharts)})),this.allTooltipSeriesGroups=[],e.globals.axisCharts||(this.showTooltipTitle=!1);var i=document.createElement("div");if(i.classList.add("apexcharts-tooltip"),e.config.tooltip.cssClass&&i.classList.add(e.config.tooltip.cssClass),i.classList.add("apexcharts-theme-".concat(this.tConfig.theme)),e.globals.dom.elWrap.appendChild(i),e.globals.axisCharts){this.axesTooltip.drawXaxisTooltip(),this.axesTooltip.drawYaxisTooltip(),this.axesTooltip.setXCrosshairWidth(),this.axesTooltip.handleYCrosshair();var a=new U(this.ctx);this.xAxisTicksPositions=a.getXAxisTicksPositions()}if(!e.globals.comboCharts&&!this.tConfig.intersect&&"rangeBar"!==e.config.chart.type||this.tConfig.shared||(this.showOnIntersect=!0),0!==e.config.markers.size&&0!==e.globals.markers.largestSize||this.marker.drawDynamicPoints(this),e.globals.collapsedSeries.length!==e.globals.series.length){this.dataPointsDividedHeight=e.globals.gridHeight/e.globals.dataPoints,this.dataPointsDividedWidth=e.globals.gridWidth/e.globals.dataPoints,this.showTooltipTitle&&(this.tooltipTitle=document.createElement("div"),this.tooltipTitle.classList.add("apexcharts-tooltip-title"),this.tooltipTitle.style.fontFamily=this.tConfig.style.fontFamily||e.config.chart.fontFamily,this.tooltipTitle.style.fontSize=this.tConfig.style.fontSize,i.appendChild(this.tooltipTitle));var s=e.globals.series.length;(e.globals.xyCharts||e.globals.comboCharts)&&this.tConfig.shared&&(s=this.showOnIntersect?1:e.globals.series.length),this.legendLabels=e.globals.dom.baseEl.querySelectorAll(".apexcharts-legend-text"),this.ttItems=this.createTTElements(s),this.addSVGEvents()}}},{key:"createTTElements",value:function(t){for(var e=this,i=this.w,a=[],s=this.getElTooltip(),r=function(r){var o=document.createElement("div");o.classList.add("apexcharts-tooltip-series-group"),o.style.order=i.config.tooltip.inverseOrder?t-r:r+1,e.tConfig.shared&&e.tConfig.enabledOnSeries&&Array.isArray(e.tConfig.enabledOnSeries)&&e.tConfig.enabledOnSeries.indexOf(r)<0&&o.classList.add("apexcharts-tooltip-series-group-hidden");var n=document.createElement("span");n.classList.add("apexcharts-tooltip-marker"),n.style.backgroundColor=i.globals.colors[r],o.appendChild(n);var l=document.createElement("div");l.classList.add("apexcharts-tooltip-text"),l.style.fontFamily=e.tConfig.style.fontFamily||i.config.chart.fontFamily,l.style.fontSize=e.tConfig.style.fontSize,["y","goals","z"].forEach((function(t){var e=document.createElement("div");e.classList.add("apexcharts-tooltip-".concat(t,"-group"));var i=document.createElement("span");i.classList.add("apexcharts-tooltip-text-".concat(t,"-label")),e.appendChild(i);var a=document.createElement("span");a.classList.add("apexcharts-tooltip-text-".concat(t,"-value")),e.appendChild(a),l.appendChild(e)})),o.appendChild(l),s.appendChild(o),a.push(o)},o=0;o0&&this.addPathsEventListeners(u,c),this.tooltipUtil.hasBars()&&!this.tConfig.shared&&this.addDatapointEventsListeners(c)}}},{key:"drawFixedTooltipRect",value:function(){var t=this.w,e=this.getElTooltip(),i=e.getBoundingClientRect(),a=i.width+10,s=i.height+10,r=this.tConfig.fixed.offsetX,o=this.tConfig.fixed.offsetY,n=this.tConfig.fixed.position.toLowerCase();return n.indexOf("right")>-1&&(r=r+t.globals.svgWidth-a+10),n.indexOf("bottom")>-1&&(o=o+t.globals.svgHeight-s-10),e.style.left=r+"px",e.style.top=o+"px",{x:r,y:o,ttWidth:a,ttHeight:s}}},{key:"addDatapointEventsListeners",value:function(t){var e=this.w.globals.dom.baseEl.querySelectorAll(".apexcharts-series-markers .apexcharts-marker, .apexcharts-bar-area, .apexcharts-candlestick-area, .apexcharts-boxPlot-area, .apexcharts-rangebar-area");this.addPathsEventListeners(e,t)}},{key:"addPathsEventListeners",value:function(t,e){for(var i=this,a=function(a){var s={paths:t[a],tooltipEl:e.tooltipEl,tooltipY:e.tooltipY,tooltipX:e.tooltipX,elGrid:e.elGrid,hoverArea:e.hoverArea,ttItems:e.ttItems};["mousemove","mouseup","touchmove","mouseout","touchend"].map((function(e){return t[a].addEventListener(e,i.onSeriesHover.bind(i,s),{capture:!1,passive:!0})}))},s=0;s=100?this.seriesHover(t,e):(clearTimeout(this.seriesHoverTimeout),this.seriesHoverTimeout=setTimeout((function(){i.seriesHover(t,e)}),100-a))}},{key:"seriesHover",value:function(t,e){var i=this;this.lastHoverTime=Date.now();var a=[],s=this.w;s.config.chart.group&&(a=this.ctx.getGroupedCharts()),s.globals.axisCharts&&(s.globals.minX===-1/0&&s.globals.maxX===1/0||0===s.globals.dataPoints)||(a.length?a.forEach((function(a){var s=i.getElTooltip(a),r={paths:t.paths,tooltipEl:s,tooltipY:t.tooltipY,tooltipX:t.tooltipX,elGrid:t.elGrid,hoverArea:t.hoverArea,ttItems:a.w.globals.tooltip.ttItems};a.w.globals.minX===i.w.globals.minX&&a.w.globals.maxX===i.w.globals.maxX&&a.w.globals.tooltip.seriesHoverByContext({chartCtx:a,ttCtx:a.w.globals.tooltip,opt:r,e:e})})):this.seriesHoverByContext({chartCtx:this.ctx,ttCtx:this.w.globals.tooltip,opt:t,e:e}))}},{key:"seriesHoverByContext",value:function(t){var e=t.chartCtx,i=t.ttCtx,a=t.opt,s=t.e,r=e.w,o=this.getElTooltip();o&&(i.tooltipRect={x:0,y:0,ttWidth:o.getBoundingClientRect().width,ttHeight:o.getBoundingClientRect().height},i.e=s,!i.tooltipUtil.hasBars()||r.globals.comboCharts||i.isBarShared||this.tConfig.onDatasetHover.highlightDataSeries&&new B(e).toggleSeriesOnHover(s,s.target.parentNode),i.fixedTooltip&&i.drawFixedTooltipRect(),r.globals.axisCharts?i.axisChartsTooltips({e:s,opt:a,tooltipRect:i.tooltipRect}):i.nonAxisChartsTooltips({e:s,opt:a,tooltipRect:i.tooltipRect}))}},{key:"axisChartsTooltips",value:function(t){var e,i,a=t.e,s=t.opt,r=this.w,o=s.elGrid.getBoundingClientRect(),n="touchmove"===a.type?a.touches[0].clientX:a.clientX,l="touchmove"===a.type?a.touches[0].clientY:a.clientY;if(this.clientY=l,this.clientX=n,r.globals.capturedSeriesIndex=-1,r.globals.capturedDataPointIndex=-1,lo.top+o.height)this.handleMouseOut(s);else{if(Array.isArray(this.tConfig.enabledOnSeries)&&!r.config.tooltip.shared){var h=parseInt(s.paths.getAttribute("index"),10);if(this.tConfig.enabledOnSeries.indexOf(h)<0)return void this.handleMouseOut(s)}var c=this.getElTooltip(),d=this.getElXCrosshairs(),g=r.globals.xyCharts||"bar"===r.config.chart.type&&!r.globals.isBarHorizontal&&this.tooltipUtil.hasBars()&&this.tConfig.shared||r.globals.comboCharts&&this.tooltipUtil.hasBars();if("mousemove"===a.type||"touchmove"===a.type||"mouseup"===a.type){if(r.globals.collapsedSeries.length+r.globals.ancillaryCollapsedSeries.length===r.globals.series.length)return;null!==d&&d.classList.add("apexcharts-active");var u=this.yaxisTooltips.filter((function(t){return!0===t}));if(null!==this.ycrosshairs&&u.length&&this.ycrosshairs.classList.add("apexcharts-active"),g&&!this.showOnIntersect)this.handleStickyTooltip(a,n,l,s);else if("heatmap"===r.config.chart.type||"treemap"===r.config.chart.type){var f=this.intersect.handleHeatTreeTooltip({e:a,opt:s,x:e,y:i,type:r.config.chart.type});e=f.x,i=f.y,c.style.left=e+"px",c.style.top=i+"px"}else this.tooltipUtil.hasBars()&&this.intersect.handleBarTooltip({e:a,opt:s}),this.tooltipUtil.hasMarkers()&&this.intersect.handleMarkerTooltip({e:a,opt:s,x:e,y:i});if(this.yaxisTooltips.length)for(var p=0;pl.width?this.handleMouseOut(a):null!==n?this.handleStickyCapturedSeries(t,n,a,o):(this.tooltipUtil.isXoverlap(o)||s.globals.isBarHorizontal)&&this.create(t,this,0,o,a.ttItems)}},{key:"handleStickyCapturedSeries",value:function(t,e,i,a){var s=this.w;this.tConfig.shared||null!==s.globals.series[e][a]?void 0!==s.globals.series[e][a]?this.tConfig.shared&&this.tooltipUtil.isXoverlap(a)&&this.tooltipUtil.isInitialSeriesSameLen()?this.create(t,this,e,a,i.ttItems):this.create(t,this,e,a,i.ttItems,!1):this.tooltipUtil.isXoverlap(a)&&this.create(t,this,0,a,i.ttItems):this.handleMouseOut(i)}},{key:"deactivateHoverFilter",value:function(){for(var t=this.w,e=new k(this.ctx),i=t.globals.dom.Paper.select(".apexcharts-bar-area"),a=0;a5&&void 0!==arguments[5]?arguments[5]:null,o=this.w,n=e;"mouseup"===t.type&&this.markerClick(t,i,a),null===r&&(r=this.tConfig.shared);var l=this.tooltipUtil.hasMarkers(),h=this.tooltipUtil.getElBars();if(o.config.legend.tooltipHoverFormatter){var c=o.config.legend.tooltipHoverFormatter,d=Array.from(this.legendLabels);d.forEach((function(t){var e=t.getAttribute("data:default-text");t.innerHTML=decodeURIComponent(e)}));for(var g=0;g0?n.marker.enlargePoints(a):n.tooltipPosition.moveDynamicPointsOnHover(a)),this.tooltipUtil.hasBars()&&(this.barSeriesHeight=this.tooltipUtil.getBarsHeight(h),this.barSeriesHeight>0)){var b=new k(this.ctx),v=o.globals.dom.Paper.select(".apexcharts-bar-area[j='".concat(a,"']"));this.deactivateHoverFilter(),this.tooltipPosition.moveStickyTooltipOverBars(a);for(var m=0;ms.globals.gridHeight&&(u=s.globals.gridHeight-b)),{bcx:h,bcy:l,dataLabelsX:e,dataLabelsY:u,totalDataLabelsX:a,totalDataLabelsY:i,totalDataLabelsAnchor:"middle"}}},{key:"calculateBarsDataLabelsPosition",value:function(t){var e=this.w,i=t.x,a=t.i,s=t.j,r=t.realIndex,o=t.bcy,n=t.barHeight,l=t.barWidth,h=t.textRects,c=t.dataLabelsX,d=t.strokeWidth,g=t.dataLabelsConfig,u=t.barDataLabelsConfig,f=t.barTotalDataLabelsConfig,p=t.offX,x=t.offY,b=e.globals.gridHeight/e.globals.dataPoints;l=Math.abs(l);var v,m,y=o-(this.barCtx.isRangeBar?0:b)+n/2+h.height/2+x-3,w="start",A=this.barCtx.series[a][s]<0,S=i;switch(this.barCtx.isReversed&&(S=i+l-(A?2*l:0),i=e.globals.gridWidth-l),u.position){case"center":c=A?S+l/2-p:Math.max(h.width/2,S-l/2)+p;break;case"bottom":c=A?S+l-d-Math.round(h.width/2)-p:S-l+d+Math.round(h.width/2)+p;break;case"top":c=A?S-d+Math.round(h.width/2)-p:S-d-Math.round(h.width/2)+p}if(this.barCtx.lastActiveBarSerieIndex===r&&f.enabled){var C=new k(this.barCtx.ctx).getTextRects(this.getStackedTotalDataLabel({realIndex:r,j:s}),g.fontSize);A?(v=S-d+Math.round(C.width/2)-p-f.offsetX-15,w="end"):v=S-d-Math.round(C.width/2)+p+f.offsetX+15,m=y+f.offsetY}return e.config.chart.stacked||(c<0?c=c+h.width+d:c+h.width/2>e.globals.gridWidth&&(c=e.globals.gridWidth-h.width-d)),{bcx:i,bcy:o,dataLabelsX:c,dataLabelsY:y,totalDataLabelsX:v,totalDataLabelsY:m,totalDataLabelsAnchor:w}}},{key:"drawCalculatedDataLabels",value:function(t){var e=t.x,i=t.y,a=t.val,s=t.i,o=t.j,n=t.textRects,l=t.barHeight,h=t.barWidth,c=t.dataLabelsConfig,d=this.w,g="rotate(0)";"vertical"===d.config.plotOptions.bar.dataLabels.orientation&&(g="rotate(-90, ".concat(e,", ").concat(i,")"));var u=new W(this.barCtx.ctx),f=new k(this.barCtx.ctx),p=c.formatter,x=null,b=d.globals.collapsedSeriesIndices.indexOf(s)>-1;if(c.enabled&&!b){x=f.group({class:"apexcharts-data-labels",transform:g});var v="";void 0!==a&&(v=p(a,r(r({},d),{},{seriesIndex:s,dataPointIndex:o,w:d})));var m=d.globals.series[s][o]<0,y=d.config.plotOptions.bar.dataLabels.position;"vertical"===d.config.plotOptions.bar.dataLabels.orientation&&("top"===y&&(c.textAnchor=m?"end":"start"),"center"===y&&(c.textAnchor="middle"),"bottom"===y&&(c.textAnchor=m?"end":"start")),this.barCtx.isRangeBar&&this.barCtx.barOptions.dataLabels.hideOverflowingLabels&&hMath.abs(h)&&(v=""):n.height/1.6>Math.abs(l)&&(v=""));var w=r({},c);this.barCtx.isHorizontal&&a<0&&("start"===c.textAnchor?w.textAnchor="end":"end"===c.textAnchor&&(w.textAnchor="start")),u.plotDataLabelsText({x:e,y:i,text:v,i:s,j:o,parent:x,dataLabelsConfig:w,alwaysDrawDataLabel:!0,offsetCorrection:!0})}return x}},{key:"drawTotalDataLabels",value:function(t){var e,i=t.x,a=t.y,s=t.val,r=t.realIndex,o=t.textAnchor,n=t.barTotalDataLabelsConfig,l=new k(this.barCtx.ctx);return n.enabled&&void 0!==i&&void 0!==a&&this.barCtx.lastActiveBarSerieIndex===r&&(e=l.drawText({x:i,y:a,foreColor:n.style.color,text:s,textAnchor:o,fontFamily:n.style.fontFamily,fontSize:n.style.fontSize,fontWeight:n.style.fontWeight})),e}}]),t}(),kt=function(){function t(e){n(this,t),this.w=e.w,this.barCtx=e}return h(t,[{key:"initVariables",value:function(t){var e=this.w;this.barCtx.series=t,this.barCtx.totalItems=0,this.barCtx.seriesLen=0,this.barCtx.visibleI=-1,this.barCtx.visibleItems=1;for(var i=0;i0&&(this.barCtx.seriesLen=this.barCtx.seriesLen+1,this.barCtx.totalItems+=t[i].length),e.globals.isXNumeric)for(var a=0;ae.globals.minX&&e.globals.seriesX[i][a]0&&(a=l.globals.minXDiff/d),(r=a/this.barCtx.seriesLen*parseInt(this.barCtx.barOptions.columnWidth,10)/100)<1&&(r=1)}o=l.globals.gridHeight-this.barCtx.baseLineY[this.barCtx.yaxisIndex]-(this.barCtx.isReversed?l.globals.gridHeight:0)+(this.barCtx.isReversed?2*this.barCtx.baseLineY[this.barCtx.yaxisIndex]:0),t=l.globals.padHorizontal+(a-r*this.barCtx.seriesLen)/2}return{x:t,y:e,yDivision:i,xDivision:a,barHeight:s,barWidth:r,zeroH:o,zeroW:n}}},{key:"getPathFillColor",value:function(t,e,i,a){var s,r,o,n,l=this.w,h=new H(this.barCtx.ctx),c=null,d=this.barCtx.barOptions.distributed?i:e;return this.barCtx.barOptions.colors.ranges.length>0&&this.barCtx.barOptions.colors.ranges.map((function(a){t[e][i]>=a.from&&t[e][i]<=a.to&&(c=a.color)})),l.config.series[e].data[i]&&l.config.series[e].data[i].fillColor&&(c=l.config.series[e].data[i].fillColor),h.fillPath({seriesNumber:this.barCtx.barOptions.distributed?d:a,dataPointIndex:i,color:c,value:t[e][i],fillConfig:null===(s=l.config.series[e].data[i])||void 0===s?void 0:s.fill,fillType:null!==(r=l.config.series[e].data[i])&&void 0!==r&&null!==(o=r.fill)&&void 0!==o&&o.type?null===(n=l.config.series[e].data[i])||void 0===n?void 0:n.fill.type:l.config.fill.type})}},{key:"getStrokeWidth",value:function(t,e,i){var a=0,s=this.w;return void 0===this.barCtx.series[t][e]||null===this.barCtx.series[t][e]?this.barCtx.isNullValue=!0:this.barCtx.isNullValue=!1,s.config.stroke.show&&(this.barCtx.isNullValue||(a=Array.isArray(this.barCtx.strokeWidth)?this.barCtx.strokeWidth[i]:this.barCtx.strokeWidth)),a}},{key:"shouldApplyRadius",value:function(t){var e=this.w,i=!1;return e.config.plotOptions.bar.borderRadius>0&&(e.config.chart.stacked&&"last"===e.config.plotOptions.bar.borderRadiusWhenStacked?this.barCtx.lastActiveBarSerieIndex===t&&(i=!0):i=!0),i}},{key:"barBackground",value:function(t){var e=t.j,i=t.i,a=t.x1,s=t.x2,r=t.y1,o=t.y2,n=t.elSeries,l=this.w,h=new k(this.barCtx.ctx),c=new B(this.barCtx.ctx).getActiveConfigSeriesIndex();if(this.barCtx.barOptions.colors.backgroundBarColors.length>0&&c===i){e>=this.barCtx.barOptions.colors.backgroundBarColors.length&&(e%=this.barCtx.barOptions.colors.backgroundBarColors.length);var d=this.barCtx.barOptions.colors.backgroundBarColors[e],g=h.drawRect(void 0!==a?a:0,void 0!==r?r:0,void 0!==s?s:l.globals.gridWidth,void 0!==o?o:l.globals.gridHeight,this.barCtx.barOptions.colors.backgroundBarRadius,d,this.barCtx.barOptions.colors.backgroundBarOpacity);n.add(g),g.node.classList.add("apexcharts-backgroundBar")}}},{key:"getColumnPaths",value:function(t){var e,i=t.barWidth,a=t.barXPosition,s=t.y1,r=t.y2,o=t.strokeWidth,n=t.realIndex,l=t.i,h=t.j,c=t.w,d=new k(this.barCtx.ctx);(o=Array.isArray(o)?o[n]:o)||(o=0);var g=i,u=a;null!==(e=c.config.series[n].data[h])&&void 0!==e&&e.columnWidthOffset&&(u=a-c.config.series[n].data[h].columnWidthOffset/2,g=i+c.config.series[n].data[h].columnWidthOffset);var f=u,p=u+g;s+=.001,r+=.001;var x=d.move(f,s),b=d.move(f,s),v=d.line(p-o,s);return c.globals.previousPaths.length>0&&(b=this.barCtx.getPreviousPath(n,h,!1)),x=x+d.line(f,r)+d.line(p-o,r)+d.line(p-o,s)+("around"===c.config.plotOptions.bar.borderRadiusApplication?" Z":" z"),b=b+d.line(f,s)+v+v+v+v+v+d.line(f,s)+("around"===c.config.plotOptions.bar.borderRadiusApplication?" Z":" z"),this.shouldApplyRadius(n)&&(x=d.roundPathCorners(x,c.config.plotOptions.bar.borderRadius)),c.config.chart.stacked&&(this.barCtx.yArrj.push(r),this.barCtx.yArrjF.push(Math.abs(s-r)),this.barCtx.yArrjVal.push(this.barCtx.series[l][h])),{pathTo:x,pathFrom:b}}},{key:"getBarpaths",value:function(t){var e,i=t.barYPosition,a=t.barHeight,s=t.x1,r=t.x2,o=t.strokeWidth,n=t.realIndex,l=t.i,h=t.j,c=t.w,d=new k(this.barCtx.ctx);(o=Array.isArray(o)?o[n]:o)||(o=0);var g=i,u=a;null!==(e=c.config.series[n].data[h])&&void 0!==e&&e.barHeightOffset&&(g=i-c.config.series[n].data[h].barHeightOffset/2,u=a+c.config.series[n].data[h].barHeightOffset);var f=g,p=g+u;s+=.001,r+=.001;var x=d.move(s,f),b=d.move(s,f);c.globals.previousPaths.length>0&&(b=this.barCtx.getPreviousPath(n,h,!1));var v=d.line(s,p-o);return x=x+d.line(r,f)+d.line(r,p-o)+v+("around"===c.config.plotOptions.bar.borderRadiusApplication?" Z":" z"),b=b+d.line(s,f)+v+v+v+v+v+d.line(s,f)+("around"===c.config.plotOptions.bar.borderRadiusApplication?" Z":" z"),this.shouldApplyRadius(n)&&(x=d.roundPathCorners(x,c.config.plotOptions.bar.borderRadius)),c.config.chart.stacked&&(this.barCtx.xArrj.push(r),this.barCtx.xArrjF.push(Math.abs(s-r)),this.barCtx.xArrjVal.push(this.barCtx.series[l][h])),{pathTo:x,pathFrom:b}}},{key:"checkZeroSeries",value:function(t){for(var e=t.series,i=this.w,a=0;a=0;o--)this.barCtx.zeroSerieses.indexOf(o)>-1&&o===this.radiusOnSeriesNumber&&(this.barCtx.radiusOnSeriesNumber-=1);for(var n=e.length-1;n>=0;n--)i.globals.collapsedSeriesIndices.indexOf(this.barCtx.radiusOnSeriesNumber)>-1&&(this.barCtx.radiusOnSeriesNumber-=1)}},{key:"getXForValue",value:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=i?e:null;return null!=t&&(a=e+t/this.barCtx.invertedYRatio-2*(this.barCtx.isReversed?t/this.barCtx.invertedYRatio:0)),a}},{key:"getYForValue",value:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=i?e:null;return null!=t&&(a=e-t/this.barCtx.yRatio[this.barCtx.yaxisIndex]+2*(this.barCtx.isReversed?t/this.barCtx.yRatio[this.barCtx.yaxisIndex]:0)),a}},{key:"getGoalValues",value:function(t,e,i,a,s){var r=this,o=this.w,n=[];return o.globals.seriesGoals[a]&&o.globals.seriesGoals[a][s]&&Array.isArray(o.globals.seriesGoals[a][s])&&o.globals.seriesGoals[a][s].forEach((function(a){var s;n.push((c(s={},t,"x"===t?r.getXForValue(a.value,e,!1):r.getYForValue(a.value,i,!1)),c(s,"attrs",a),s))})),n}},{key:"drawGoalLine",value:function(t){var e=t.barXPosition,i=t.barYPosition,a=t.goalX,s=t.goalY,r=t.barWidth,o=t.barHeight,n=new k(this.barCtx.ctx),l=n.group({className:"apexcharts-bar-goals-groups"}),h=null;return this.barCtx.isHorizontal?Array.isArray(a)&&a.forEach((function(t){var e=void 0!==t.attrs.strokeHeight?t.attrs.strokeHeight:o/2,a=i+e+o/2;h=n.drawLine(t.x,a-2*e,t.x,a,t.attrs.strokeColor?t.attrs.strokeColor:void 0,t.attrs.strokeDashArray,t.attrs.strokeWidth?t.attrs.strokeWidth:2,t.attrs.strokeLineCap),l.add(h)})):Array.isArray(s)&&s.forEach((function(t){var i=void 0!==t.attrs.strokeWidth?t.attrs.strokeWidth:r/2,a=e+i+r/2;h=n.drawLine(a-2*i,t.y,a,t.y,t.attrs.strokeColor?t.attrs.strokeColor:void 0,t.attrs.strokeDashArray,t.attrs.strokeHeight?t.attrs.strokeHeight:2,t.attrs.strokeLineCap),l.add(h)})),l}}]),t}(),At=function(){function t(e,i){n(this,t),this.ctx=e,this.w=e.w;var a=this.w;this.barOptions=a.config.plotOptions.bar,this.isHorizontal=this.barOptions.horizontal,this.strokeWidth=a.config.stroke.width,this.isNullValue=!1,this.isRangeBar=a.globals.seriesRange.length&&this.isHorizontal,this.xyRatios=i,null!==this.xyRatios&&(this.xRatio=i.xRatio,this.initialXRatio=i.initialXRatio,this.yRatio=i.yRatio,this.invertedXRatio=i.invertedXRatio,this.invertedYRatio=i.invertedYRatio,this.baseLineY=i.baseLineY,this.baseLineInvertedY=i.baseLineInvertedY),this.yaxisIndex=0,this.seriesLen=0;var s=new B(this.ctx);this.lastActiveBarSerieIndex=s.getActiveConfigSeriesIndex("desc",["bar","column"]);var r=s.getBarSeriesIndices(),o=new A(this.ctx);this.stackedSeriesTotals=o.getStackedSeriesTotals(this.w.config.series.map((function(t,e){return-1===r.indexOf(e)?e:-1})).filter((function(t){return-1!==t}))),this.barHelpers=new kt(this)}return h(t,[{key:"draw",value:function(t,e){var i=this.w,a=new k(this.ctx),s=new A(this.ctx,i);t=s.getLogSeries(t),this.series=t,this.yRatio=s.getLogYRatios(this.yRatio),this.barHelpers.initVariables(t);var o=a.group({class:"apexcharts-bar-series apexcharts-plot-series"});i.config.dataLabels.enabled&&this.totalItems>this.barOptions.dataLabels.maxItems&&console.warn("WARNING: DataLabels are enabled but there are too many to display. This may cause performance issue when rendering.");for(var n=0,l=0;n0&&(this.visibleI=this.visibleI+1);var y=0,w=0;this.yRatio.length>1&&(this.yaxisIndex=b),this.isReversed=i.config.yaxis[this.yaxisIndex]&&i.config.yaxis[this.yaxisIndex].reversed;var S=this.barHelpers.initialPositions();f=S.y,y=S.barHeight,c=S.yDivision,g=S.zeroW,u=S.x,w=S.barWidth,h=S.xDivision,d=S.zeroH,this.horizontal||x.push(u+w/2);for(var C=a.group({class:"apexcharts-datalabels","data:realIndex":b}),L=a.group({class:"apexcharts-bar-goals-markers",style:"pointer-events: none"}),P=0;P0&&x.push(u+w/2),p.push(f);var E=this.barHelpers.getPathFillColor(t,n,P,b);this.renderSeries({realIndex:b,pathFill:E,j:P,i:n,pathFrom:M.pathFrom,pathTo:M.pathTo,strokeWidth:T,elSeries:v,x:u,y:f,series:t,barHeight:y,barWidth:w,elDataLabelsWrap:C,elGoalsMarkers:L,visibleSeries:this.visibleI,type:"bar"})}i.globals.seriesXvalues[b]=x,i.globals.seriesYvalues[b]=p,o.add(v)}return o}},{key:"renderSeries",value:function(t){var e=t.realIndex,i=t.pathFill,a=t.lineFill,s=t.j,r=t.i,o=t.pathFrom,n=t.pathTo,l=t.strokeWidth,h=t.elSeries,c=t.x,d=t.y,g=t.y1,u=t.y2,f=t.series,p=t.barHeight,x=t.barWidth,b=t.barYPosition,v=t.elDataLabelsWrap,m=t.elGoalsMarkers,y=t.visibleSeries,A=t.type,S=this.w,C=new k(this.ctx);a||(a=this.barOptions.distributed?S.globals.stroke.colors[s]:S.globals.stroke.colors[e]),S.config.series[r].data[s]&&S.config.series[r].data[s].strokeColor&&(a=S.config.series[r].data[s].strokeColor),this.isNullValue&&(i="none");var L=s/S.config.chart.animations.animateGradually.delay*(S.config.chart.animations.speed/S.globals.dataPoints)/2.4,P=C.renderPaths({i:r,j:s,realIndex:e,pathFrom:o,pathTo:n,stroke:a,strokeWidth:l,strokeLineCap:S.config.stroke.lineCap,fill:i,animationDelay:L,initialSpeed:S.config.chart.animations.speed,dataChangeSpeed:S.config.chart.animations.dynamicAnimation.speed,className:"apexcharts-".concat(A,"-area")});P.attr("clip-path","url(#gridRectMask".concat(S.globals.cuid,")"));var T=S.config.forecastDataPoints;T.count>0&&s>=S.globals.dataPoints-T.count&&(P.node.setAttribute("stroke-dasharray",T.dashArray),P.node.setAttribute("stroke-width",T.strokeWidth),P.node.setAttribute("fill-opacity",T.fillOpacity)),void 0!==g&&void 0!==u&&(P.attr("data-range-y1",g),P.attr("data-range-y2",u)),new w(this.ctx).setSelectionFilter(P,e,s),h.add(P);var M=new wt(this).handleBarDataLabels({x:c,y:d,y1:g,y2:u,i:r,j:s,series:f,realIndex:e,barHeight:p,barWidth:x,barYPosition:b,renderedPath:P,visibleSeries:y});return null!==M.dataLabels&&v.add(M.dataLabels),M.totalDataLabels&&v.add(M.totalDataLabels),h.add(v),m&&h.add(m),h}},{key:"drawBarPaths",value:function(t){var e=t.indexes,i=t.barHeight,a=t.strokeWidth,s=t.zeroW,r=t.x,o=t.y,n=t.yDivision,l=t.elSeries,h=this.w,c=e.i,d=e.j;h.globals.isXNumeric&&(o=(h.globals.seriesX[c][d]-h.globals.minX)/this.invertedXRatio-i);var g=o+i*this.visibleI;r=this.barHelpers.getXForValue(this.series[c][d],s);var u=this.barHelpers.getBarpaths({barYPosition:g,barHeight:i,x1:s,x2:r,strokeWidth:a,series:this.series,realIndex:e.realIndex,i:c,j:d,w:h});return h.globals.isXNumeric||(o+=n),this.barHelpers.barBackground({j:d,i:c,y1:g-i*this.visibleI,y2:i*this.seriesLen,elSeries:l}),{pathTo:u.pathTo,pathFrom:u.pathFrom,x:r,y:o,goalX:this.barHelpers.getGoalValues("x",s,null,c,d),barYPosition:g}}},{key:"drawColumnPaths",value:function(t){var e=t.indexes,i=t.x,a=t.y,s=t.xDivision,r=t.barWidth,o=t.zeroH,n=t.strokeWidth,l=t.elSeries,h=this.w,c=e.realIndex,d=e.i,g=e.j,u=e.bc;if(h.globals.isXNumeric){var f=c;h.globals.seriesX[c].length||(f=h.globals.maxValsInArrayIndex),i=(h.globals.seriesX[f][g]-h.globals.minX)/this.xRatio-r*this.seriesLen/2}var p=i+r*this.visibleI;a=this.barHelpers.getYForValue(this.series[d][g],o);var x=this.barHelpers.getColumnPaths({barXPosition:p,barWidth:r,y1:o,y2:a,strokeWidth:n,series:this.series,realIndex:e.realIndex,i:d,j:g,w:h});return h.globals.isXNumeric||(i+=s),this.barHelpers.barBackground({bc:u,j:g,i:d,x1:p-n/2-r*this.visibleI,x2:r*this.seriesLen+n/2,elSeries:l}),{pathTo:x.pathTo,pathFrom:x.pathFrom,x:i,y:a,goalY:this.barHelpers.getGoalValues("y",null,o,d,g),barXPosition:p}}},{key:"getPreviousPath",value:function(t,e){for(var i,a=this.w,s=0;s0&&parseInt(r.realIndex,10)===parseInt(t,10)&&void 0!==a.globals.previousPaths[s].paths[e]&&(i=a.globals.previousPaths[s].paths[e].d)}return i}}]),t}(),St=function(t){d(i,At);var e=p(i);function i(){return n(this,i),e.apply(this,arguments)}return h(i,[{key:"draw",value:function(t,e){var i=this,a=this.w;this.graphics=new k(this.ctx),this.bar=new At(this.ctx,this.xyRatios);var s=new A(this.ctx,a);t=s.getLogSeries(t),this.yRatio=s.getLogYRatios(this.yRatio),this.barHelpers.initVariables(t),"100%"===a.config.chart.stackType&&(t=a.globals.seriesPercent.slice()),this.series=t,this.totalItems=0,this.prevY=[],this.prevX=[],this.prevYF=[],this.prevXF=[],this.prevYVal=[],this.prevXVal=[],this.xArrj=[],this.xArrjF=[],this.xArrjVal=[],this.yArrj=[],this.yArrjF=[],this.yArrjVal=[];for(var o=0;o0&&(this.totalItems+=t[o].length);for(var n=this.graphics.group({class:"apexcharts-bar-series apexcharts-plot-series"}),l=0,h=0,c=function(s,o){var c=void 0,d=void 0,g=void 0,u=void 0,f=[],p=[],x=a.globals.comboCharts?e[s]:s;i.yRatio.length>1&&(i.yaxisIndex=x),i.isReversed=a.config.yaxis[i.yaxisIndex]&&a.config.yaxis[i.yaxisIndex].reversed;var b=i.graphics.group({class:"apexcharts-series",seriesName:m.escapeString(a.globals.seriesNames[x]),rel:s+1,"data:realIndex":x});i.ctx.series.addCollapsedClassToSeries(b,x);var v=i.graphics.group({class:"apexcharts-datalabels","data:realIndex":x}),y=i.graphics.group({class:"apexcharts-bar-goals-markers",style:"pointer-events: none"}),w=0,k=0,A=i.initialPositions(l,h,c,d,g,u);h=A.y,w=A.barHeight,d=A.yDivision,u=A.zeroW,l=A.x,k=A.barWidth,c=A.xDivision,g=A.zeroH,i.yArrj=[],i.yArrjF=[],i.yArrjVal=[],i.xArrj=[],i.xArrjF=[],i.xArrjVal=[],1===i.prevY.length&&i.prevY[0].every((function(t){return isNaN(t)}))&&(i.prevY[0]=i.prevY[0].map((function(t){return g})),i.prevYF[0]=i.prevYF[0].map((function(t){return 0})));for(var S=0;S1?(i=l.globals.minXDiff/this.xRatio)*parseInt(this.barOptions.columnWidth,10)/100:n*parseInt(l.config.plotOptions.bar.columnWidth,10)/100,s=l.globals.gridHeight-this.baseLineY[this.yaxisIndex]-(this.isReversed?l.globals.gridHeight:0)+(this.isReversed?2*this.baseLineY[this.yaxisIndex]:0),t=l.globals.padHorizontal+(i-n)/2),{x:t,y:e,yDivision:a,xDivision:i,barHeight:o,barWidth:n,zeroH:s,zeroW:r}}},{key:"drawStackedBarPaths",value:function(t){for(var e,i=t.indexes,a=t.barHeight,s=t.strokeWidth,r=t.zeroW,o=t.x,n=t.y,l=t.yDivision,h=t.elSeries,c=this.w,d=n,g=i.i,u=i.j,f=0,p=0;p0){var x=r;this.prevXVal[g-1][u]<0?x=this.series[g][u]>=0?this.prevX[g-1][u]+f-2*(this.isReversed?f:0):this.prevX[g-1][u]:this.prevXVal[g-1][u]>=0&&(x=this.series[g][u]>=0?this.prevX[g-1][u]:this.prevX[g-1][u]-f+2*(this.isReversed?f:0)),e=x}else e=r;o=null===this.series[g][u]?e:e+this.series[g][u]/this.invertedYRatio-2*(this.isReversed?this.series[g][u]/this.invertedYRatio:0);var b=this.barHelpers.getBarpaths({barYPosition:d,barHeight:a,x1:e,x2:o,strokeWidth:s,series:this.series,realIndex:i.realIndex,i:g,j:u,w:c});return this.barHelpers.barBackground({j:u,i:g,y1:d,y2:a,elSeries:h}),n+=l,{pathTo:b.pathTo,pathFrom:b.pathFrom,goalX:this.barHelpers.getGoalValues("x",r,null,g,u),barYPosition:d,x:o,y:n}}},{key:"drawStackedColumnPaths",value:function(t){var e=t.indexes,i=t.x,a=t.y,s=t.xDivision,r=t.barWidth,o=t.zeroH;t.strokeWidth;var n=t.elSeries,l=this.w,h=e.i,c=e.j,d=e.bc;if(l.globals.isXNumeric){var g=l.globals.seriesX[h][c];g||(g=0),i=(g-l.globals.minX)/this.xRatio-r/2}for(var u,f=i,p=0,x=0;x0&&!l.globals.isXNumeric||h>0&&l.globals.isXNumeric&&l.globals.seriesX[h-1][c]===l.globals.seriesX[h][c]){var b,v,m=Math.min(this.yRatio.length+1,h+1);if(void 0!==this.prevY[h-1])for(var y=1;y=0?v-p+2*(this.isReversed?p:0):v;break}if(this.prevYVal[h-w][c]>=0){b=this.series[h][c]>=0?v:v+p-2*(this.isReversed?p:0);break}}void 0===b&&(b=l.globals.gridHeight),u=this.prevYF[0].every((function(t){return 0===t}))&&this.prevYF.slice(1,h).every((function(t){return t.every((function(t){return isNaN(t)}))}))?o:b}else u=o;a=u-this.series[h][c]/this.yRatio[this.yaxisIndex]+2*(this.isReversed?this.series[h][c]/this.yRatio[this.yaxisIndex]:0);var k=this.barHelpers.getColumnPaths({barXPosition:f,barWidth:r,y1:u,y2:a,yRatio:this.yRatio[this.yaxisIndex],strokeWidth:this.strokeWidth,series:this.series,realIndex:e.realIndex,i:h,j:c,w:l});return this.barHelpers.barBackground({bc:d,j:c,i:h,x1:f,x2:r,elSeries:n}),i+=s,{pathTo:k.pathTo,pathFrom:k.pathFrom,goalY:this.barHelpers.getGoalValues("y",null,o,h,c),barXPosition:f,x:l.globals.isXNumeric?i-s:i,y:a}}}]),i}(),Ct=function(t){d(i,At);var e=p(i);function i(){return n(this,i),e.apply(this,arguments)}return h(i,[{key:"draw",value:function(t,e){var i=this,a=this.w,s=new k(this.ctx),o=new H(this.ctx);this.candlestickOptions=this.w.config.plotOptions.candlestick,this.boxOptions=this.w.config.plotOptions.boxPlot,this.isHorizontal=a.config.plotOptions.bar.horizontal;var n=new A(this.ctx,a);t=n.getLogSeries(t),this.series=t,this.yRatio=n.getLogYRatios(this.yRatio),this.barHelpers.initVariables(t);for(var l=s.group({class:"apexcharts-".concat(a.config.chart.type,"-series apexcharts-plot-series")}),h=function(n){i.isBoxPlot="boxPlot"===a.config.chart.type||"boxPlot"===a.config.series[n].type;var h,c,d,g,u,f,p=void 0,x=void 0,b=[],v=[],y=a.globals.comboCharts?e[n]:n,w=s.group({class:"apexcharts-series",seriesName:m.escapeString(a.globals.seriesNames[y]),rel:n+1,"data:realIndex":y});i.ctx.series.addCollapsedClassToSeries(w,y),t[n].length>0&&(i.visibleI=i.visibleI+1),i.yRatio.length>1&&(i.yaxisIndex=y);var k=i.barHelpers.initialPositions();x=k.y,u=k.barHeight,c=k.yDivision,g=k.zeroW,p=k.x,f=k.barWidth,h=k.xDivision,d=k.zeroH,v.push(p+f/2);for(var A=s.group({class:"apexcharts-datalabels","data:realIndex":y}),S=function(e){var s=i.barHelpers.getStrokeWidth(n,e,y),l=null,m={indexes:{i:n,j:e,realIndex:y},x:p,y:x,strokeWidth:s,elSeries:w};l=i.isHorizontal?i.drawHorizontalBoxPaths(r(r({},m),{},{yDivision:c,barHeight:u,zeroW:g})):i.drawVerticalBoxPaths(r(r({},m),{},{xDivision:h,barWidth:f,zeroH:d})),x=l.y,p=l.x,e>0&&v.push(p+f/2),b.push(x),l.pathTo.forEach((function(r,h){var c=!i.isBoxPlot&&i.candlestickOptions.wick.useFillColor?l.color[h]:a.globals.stroke.colors[n],d=o.fillPath({seriesNumber:y,dataPointIndex:e,color:l.color[h],value:t[n][e]});i.renderSeries({realIndex:y,pathFill:d,lineFill:c,j:e,i:n,pathFrom:l.pathFrom,pathTo:r,strokeWidth:s,elSeries:w,x:p,y:x,series:t,barHeight:u,barWidth:f,elDataLabelsWrap:A,visibleSeries:i.visibleI,type:a.config.chart.type})}))},C=0;Cb.c&&(d=!1);var y=Math.min(b.o,b.c),w=Math.max(b.o,b.c),A=b.m;n.globals.isXNumeric&&(i=(n.globals.seriesX[x][c]-n.globals.minX)/this.xRatio-s/2);var S=i+s*this.visibleI;void 0===this.series[h][c]||null===this.series[h][c]?(y=r,w=r):(y=r-y/p,w=r-w/p,v=r-b.h/p,m=r-b.l/p,A=r-b.m/p);var C=l.move(S,r),L=l.move(S+s/2,y);return n.globals.previousPaths.length>0&&(L=this.getPreviousPath(x,c,!0)),C=this.isBoxPlot?[l.move(S,y)+l.line(S+s/2,y)+l.line(S+s/2,v)+l.line(S+s/4,v)+l.line(S+s-s/4,v)+l.line(S+s/2,v)+l.line(S+s/2,y)+l.line(S+s,y)+l.line(S+s,A)+l.line(S,A)+l.line(S,y+o/2),l.move(S,A)+l.line(S+s,A)+l.line(S+s,w)+l.line(S+s/2,w)+l.line(S+s/2,m)+l.line(S+s-s/4,m)+l.line(S+s/4,m)+l.line(S+s/2,m)+l.line(S+s/2,w)+l.line(S,w)+l.line(S,A)+"z"]:[l.move(S,w)+l.line(S+s/2,w)+l.line(S+s/2,v)+l.line(S+s/2,w)+l.line(S+s,w)+l.line(S+s,y)+l.line(S+s/2,y)+l.line(S+s/2,m)+l.line(S+s/2,y)+l.line(S,y)+l.line(S,w-o/2)],L+=l.move(S,y),n.globals.isXNumeric||(i+=a),{pathTo:C,pathFrom:L,x:i,y:w,barXPosition:S,color:this.isBoxPlot?f:d?[g]:[u]}}},{key:"drawHorizontalBoxPaths",value:function(t){var e=t.indexes;t.x;var i=t.y,a=t.yDivision,s=t.barHeight,r=t.zeroW,o=t.strokeWidth,n=this.w,l=new k(this.ctx),h=e.i,c=e.j,d=this.boxOptions.colors.lower;this.isBoxPlot&&(d=[this.boxOptions.colors.lower,this.boxOptions.colors.upper]);var g=this.invertedYRatio,u=e.realIndex,f=this.getOHLCValue(u,c),p=r,x=r,b=Math.min(f.o,f.c),v=Math.max(f.o,f.c),m=f.m;n.globals.isXNumeric&&(i=(n.globals.seriesX[u][c]-n.globals.minX)/this.invertedXRatio-s/2);var y=i+s*this.visibleI;void 0===this.series[h][c]||null===this.series[h][c]?(b=r,v=r):(b=r+b/g,v=r+v/g,p=r+f.h/g,x=r+f.l/g,m=r+f.m/g);var w=l.move(r,y),A=l.move(b,y+s/2);return n.globals.previousPaths.length>0&&(A=this.getPreviousPath(u,c,!0)),w=[l.move(b,y)+l.line(b,y+s/2)+l.line(p,y+s/2)+l.line(p,y+s/2-s/4)+l.line(p,y+s/2+s/4)+l.line(p,y+s/2)+l.line(b,y+s/2)+l.line(b,y+s)+l.line(m,y+s)+l.line(m,y)+l.line(b+o/2,y),l.move(m,y)+l.line(m,y+s)+l.line(v,y+s)+l.line(v,y+s/2)+l.line(x,y+s/2)+l.line(x,y+s-s/4)+l.line(x,y+s/4)+l.line(x,y+s/2)+l.line(v,y+s/2)+l.line(v,y)+l.line(m,y)+"z"],A+=l.move(b,y),n.globals.isXNumeric||(i+=a),{pathTo:w,pathFrom:A,x:v,y:i,barYPosition:y,color:d}}},{key:"getOHLCValue",value:function(t,e){var i=this.w;return{o:this.isBoxPlot?i.globals.seriesCandleH[t][e]:i.globals.seriesCandleO[t][e],h:this.isBoxPlot?i.globals.seriesCandleO[t][e]:i.globals.seriesCandleH[t][e],m:i.globals.seriesCandleM[t][e],l:this.isBoxPlot?i.globals.seriesCandleC[t][e]:i.globals.seriesCandleL[t][e],c:this.isBoxPlot?i.globals.seriesCandleL[t][e]:i.globals.seriesCandleC[t][e]}}}]),i}(),Lt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"checkColorRange",value:function(){var t=this.w,e=!1,i=t.config.plotOptions[t.config.chart.type];return i.colorScale.ranges.length>0&&i.colorScale.ranges.map((function(t,i){t.from<=0&&(e=!0)})),e}},{key:"getShadeColor",value:function(t,e,i,a){var s=this.w,r=1,o=s.config.plotOptions[t].shadeIntensity,n=this.determineColor(t,e,i);s.globals.hasNegs||a?r=s.config.plotOptions[t].reverseNegativeShade?n.percent<0?n.percent/100*(1.25*o):(1-n.percent/100)*(1.25*o):n.percent<=0?1-(1+n.percent/100)*o:(1-n.percent/100)*o:(r=1-n.percent/100,"treemap"===t&&(r=(1-n.percent/100)*(1.25*o)));var l=n.color,h=new m;return s.config.plotOptions[t].enableShades&&(l="dark"===this.w.config.theme.mode?m.hexToRgba(h.shadeColor(-1*r,n.color),s.config.fill.opacity):m.hexToRgba(h.shadeColor(r,n.color),s.config.fill.opacity)),{color:l,colorProps:n}}},{key:"determineColor",value:function(t,e,i){var a=this.w,s=a.globals.series[e][i],r=a.config.plotOptions[t],o=r.colorScale.inverse?i:e;r.distributed&&"treemap"===a.config.chart.type&&(o=i);var n=a.globals.colors[o],l=null,h=Math.min.apply(Math,x(a.globals.series[e])),c=Math.max.apply(Math,x(a.globals.series[e]));r.distributed||"heatmap"!==t||(h=a.globals.minY,c=a.globals.maxY),void 0!==r.colorScale.min&&(h=r.colorScale.mina.globals.maxY?r.colorScale.max:a.globals.maxY);var d=Math.abs(c)+Math.abs(h),g=100*s/(0===d?d-1e-6:d);return r.colorScale.ranges.length>0&&r.colorScale.ranges.map((function(t,e){if(s>=t.from&&s<=t.to){n=t.color,l=t.foreColor?t.foreColor:null,h=t.from,c=t.to;var i=Math.abs(c)+Math.abs(h);g=100*s/(0===i?i-1e-6:i)}})),{color:n,foreColor:l,percent:g}}},{key:"calculateDataLabels",value:function(t){var e=t.text,i=t.x,a=t.y,s=t.i,r=t.j,o=t.colorProps,n=t.fontSize,l=this.w.config.dataLabels,h=new k(this.ctx),c=new W(this.ctx),d=null;if(l.enabled){d=h.group({class:"apexcharts-data-labels"});var g=l.offsetX,u=l.offsetY,f=i+g,p=a+parseFloat(l.style.fontSize)/3+u;c.plotDataLabelsText({x:f,y:p,text:e,i:s,j:r,color:o.foreColor,parent:d,fontSize:n,dataLabelsConfig:l})}return d}},{key:"addListeners",value:function(t){var e=new k(this.ctx);t.node.addEventListener("mouseenter",e.pathMouseEnter.bind(this,t)),t.node.addEventListener("mouseleave",e.pathMouseLeave.bind(this,t)),t.node.addEventListener("mousedown",e.pathMouseDown.bind(this,t))}}]),t}(),Pt=function(){function t(e,i){n(this,t),this.ctx=e,this.w=e.w,this.xRatio=i.xRatio,this.yRatio=i.yRatio,this.dynamicAnim=this.w.config.chart.animations.dynamicAnimation,this.helpers=new Lt(e),this.rectRadius=this.w.config.plotOptions.heatmap.radius,this.strokeWidth=this.w.config.stroke.show?this.w.config.stroke.width:0}return h(t,[{key:"draw",value:function(t){var e=this.w,i=new k(this.ctx),a=i.group({class:"apexcharts-heatmap"});a.attr("clip-path","url(#gridRectMask".concat(e.globals.cuid,")"));var s=e.globals.gridWidth/e.globals.dataPoints,r=e.globals.gridHeight/e.globals.series.length,o=0,n=!1;this.negRange=this.helpers.checkColorRange();var l=t.slice();e.config.yaxis[0].reversed&&(n=!0,l.reverse());for(var h=n?0:l.length-1;n?h=0;n?h++:h--){var c=i.group({class:"apexcharts-series apexcharts-heatmap-series",seriesName:m.escapeString(e.globals.seriesNames[h]),rel:h+1,"data:realIndex":h});if(this.ctx.series.addCollapsedClassToSeries(c,h),e.config.chart.dropShadow.enabled){var d=e.config.chart.dropShadow;new w(this.ctx).dropShadow(c,d,h)}for(var g=0,u=e.config.plotOptions.heatmap.shadeIntensity,f=0;f-1&&this.pieClicked(d),i.config.dataLabels.enabled){var A=v.x,S=v.y,C=100*u/this.fullAngle+"%";if(0!==u&&i.config.plotOptions.pie.dataLabels.minAngleToShowLabelthis.fullAngle?e.endAngle=e.endAngle-(a+o):a+o=this.fullAngle+this.w.config.plotOptions.pie.startAngle%this.fullAngle&&(n=this.fullAngle+this.w.config.plotOptions.pie.startAngle%this.fullAngle-.01),Math.ceil(n)>this.fullAngle&&(n-=this.fullAngle);var l=Math.PI*(n-90)/180,h=e.centerX+s*Math.cos(o),c=e.centerY+s*Math.sin(o),d=e.centerX+s*Math.cos(l),g=e.centerY+s*Math.sin(l),u=m.polarToCartesian(e.centerX,e.centerY,e.donutSize,n),f=m.polarToCartesian(e.centerX,e.centerY,e.donutSize,r),p=a>180?1:0,x=["M",h,c,"A",s,s,0,p,1,d,g];return"donut"===e.chartType?[].concat(x,["L",u.x,u.y,"A",e.donutSize,e.donutSize,0,p,0,f.x,f.y,"L",h,c,"z"]).join(" "):"pie"===e.chartType||"polarArea"===e.chartType?[].concat(x,["L",e.centerX,e.centerY,"L",h,c]).join(" "):[].concat(x).join(" ")}},{key:"drawPolarElements",value:function(t){var e=this.w,i=new Z(this.ctx),a=new k(this.ctx),s=new Tt(this.ctx),r=a.group(),o=a.group(),n=i.niceScale(0,Math.ceil(this.maxY),e.config.yaxis[0].tickAmount,0,!0),l=n.result.reverse(),h=n.result.length;this.maxY=n.niceMax;for(var c=e.globals.radialSize,d=c/(h-1),g=0;g1&&t.total.show&&(s=t.total.color);var o=r.globals.dom.baseEl.querySelector(".apexcharts-datalabel-label"),n=r.globals.dom.baseEl.querySelector(".apexcharts-datalabel-value");i=(0,t.value.formatter)(i,r),a||"function"!=typeof t.total.formatter||(i=t.total.formatter(r));var l=e===t.total.label;e=t.name.formatter(e,l,r),null!==o&&(o.textContent=e),null!==n&&(n.textContent=i),null!==o&&(o.style.fill=s)}},{key:"printDataLabelsInner",value:function(t,e){var i=this.w,a=t.getAttribute("data:value"),s=i.globals.seriesNames[parseInt(t.parentNode.getAttribute("rel"),10)-1];i.globals.series.length>1&&this.printInnerLabels(e,s,a,t);var r=i.globals.dom.baseEl.querySelector(".apexcharts-datalabels-group");null!==r&&(r.style.opacity=1)}},{key:"drawSpokes",value:function(t){var e=this,i=this.w,a=new k(this.ctx),s=i.config.plotOptions.polarArea.spokes;if(0!==s.strokeWidth){for(var r=[],o=360/i.globals.series.length,n=0;n1)o&&!e.total.showAlways?l({makeSliceOut:!1,printLabel:!0}):this.printInnerLabels(e,e.total.label,e.total.formatter(s));else if(l({makeSliceOut:!1,printLabel:!0}),!o)if(s.globals.selectedDataPoints.length&&s.globals.series.length>1)if(s.globals.selectedDataPoints[0].length>0){var h=s.globals.selectedDataPoints[0],c=s.globals.dom.baseEl.querySelector(".apexcharts-".concat(this.chartType.toLowerCase(),"-slice-").concat(h));this.printDataLabelsInner(c,e)}else r&&s.globals.selectedDataPoints.length&&0===s.globals.selectedDataPoints[0].length&&(r.style.opacity=0);else r&&s.globals.series.length>1&&(r.style.opacity=0)}}]),t}(),It=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.chartType=this.w.config.chart.type,this.initialAnim=this.w.config.chart.animations.enabled,this.dynamicAnim=this.initialAnim&&this.w.config.chart.animations.dynamicAnimation.enabled,this.animDur=0;var i=this.w;this.graphics=new k(this.ctx),this.lineColorArr=void 0!==i.globals.stroke.colors?i.globals.stroke.colors:i.globals.colors,this.defaultSize=i.globals.svgHeight0&&(p=e.getPreviousPath(n));for(var x=0;x=10?t.x>0?(i="start",a+=10):t.x<0&&(i="end",a-=10):i="middle",Math.abs(t.y)>=e-10&&(t.y<0?s-=10:t.y>0&&(s+=10)),{textAnchor:i,newX:a,newY:s}}},{key:"getPreviousPath",value:function(t){for(var e=this.w,i=null,a=0;a0&&parseInt(s.realIndex,10)===parseInt(t,10)&&void 0!==e.globals.previousPaths[a].paths[0]&&(i=e.globals.previousPaths[a].paths[0].d)}return i}},{key:"getDataPointsPos",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.dataPointsLen;t=t||[],e=e||[];for(var a=[],s=0;s=360&&(g=360-Math.abs(this.startAngle)-.1);var u=i.drawPath({d:"",stroke:c,strokeWidth:o*parseInt(h.strokeWidth,10)/100,fill:"none",strokeOpacity:h.opacity,classes:"apexcharts-radialbar-area"});if(h.dropShadow.enabled){var f=h.dropShadow;s.dropShadow(u,f)}l.add(u),u.attr("id","apexcharts-radialbarTrack-"+n),this.animatePaths(u,{centerX:t.centerX,centerY:t.centerY,endAngle:g,startAngle:d,size:t.size,i:n,totalItems:2,animBeginArr:0,dur:0,isTrack:!0,easing:e.globals.easing})}return a}},{key:"drawArcs",value:function(t){var e=this.w,i=new k(this.ctx),a=new H(this.ctx),s=new w(this.ctx),r=i.group(),o=this.getStrokeWidth(t);t.size=t.size-o/2;var n=e.config.plotOptions.radialBar.hollow.background,l=t.size-o*t.series.length-this.margin*t.series.length-o*parseInt(e.config.plotOptions.radialBar.track.strokeWidth,10)/100/2,h=l-e.config.plotOptions.radialBar.hollow.margin;void 0!==e.config.plotOptions.radialBar.hollow.image&&(n=this.drawHollowImage(t,r,l,n));var c=this.drawHollow({size:h,centerX:t.centerX,centerY:t.centerY,fill:n||"transparent"});if(e.config.plotOptions.radialBar.hollow.dropShadow.enabled){var d=e.config.plotOptions.radialBar.hollow.dropShadow;s.dropShadow(c,d)}var g=1;!this.radialDataLabels.total.show&&e.globals.series.length>1&&(g=0);var u=null;this.radialDataLabels.show&&(u=this.renderInnerDataLabels(this.radialDataLabels,{hollowSize:l,centerX:t.centerX,centerY:t.centerY,opacity:g})),"back"===e.config.plotOptions.radialBar.hollow.position&&(r.add(c),u&&r.add(u));var f=!1;e.config.plotOptions.radialBar.inverseOrder&&(f=!0);for(var p=f?t.series.length-1:0;f?p>=0:p100?100:t.series[p])/100,S=Math.round(this.totalAngle*A)+this.startAngle,C=void 0;e.globals.dataChanged&&(y=this.startAngle,C=Math.round(this.totalAngle*m.negToZero(e.globals.previousPaths[p])/100)+y),Math.abs(S)+Math.abs(v)>=360&&(S-=.01),Math.abs(C)+Math.abs(y)>=360&&(C-=.01);var L=S-v,P=Array.isArray(e.config.stroke.dashArray)?e.config.stroke.dashArray[p]:e.config.stroke.dashArray,T=i.drawPath({d:"",stroke:b,strokeWidth:o,fill:"none",fillOpacity:e.config.fill.opacity,classes:"apexcharts-radialbar-area apexcharts-radialbar-slice-"+p,strokeDashArray:P});if(k.setAttrs(T.node,{"data:angle":L,"data:value":t.series[p]}),e.config.chart.dropShadow.enabled){var M=e.config.chart.dropShadow;s.dropShadow(T,M,p)}s.setSelectionFilter(T,0,p),this.addListeners(T,this.radialDataLabels),x.add(T),T.attr({index:0,j:p});var I=0;!this.initialAnim||e.globals.resized||e.globals.dataChanged||(I=e.config.chart.animations.speed),e.globals.dataChanged&&(I=e.config.chart.animations.dynamicAnimation.speed),this.animDur=I/(1.2*t.series.length)+this.animDur,this.animBeginArr.push(this.animDur),this.animatePaths(T,{centerX:t.centerX,centerY:t.centerY,endAngle:S,startAngle:v,prevEndAngle:C,prevStartAngle:y,size:t.size,i:p,totalItems:2,animBeginArr:this.animBeginArr,dur:I,shouldSetPrevPaths:!0,easing:e.globals.easing})}return{g:r,elHollow:c,dataLabels:u}}},{key:"drawHollow",value:function(t){var e=new k(this.ctx).drawCircle(2*t.size);return e.attr({class:"apexcharts-radialbar-hollow",cx:t.centerX,cy:t.centerY,r:t.size,fill:t.fill}),e}},{key:"drawHollowImage",value:function(t,e,i,a){var s=this.w,r=new H(this.ctx),o=m.randomId(),n=s.config.plotOptions.radialBar.hollow.image;if(s.config.plotOptions.radialBar.hollow.imageClipped)r.clippedImgArea({width:i,height:i,image:n,patternID:"pattern".concat(s.globals.cuid).concat(o)}),a="url(#pattern".concat(s.globals.cuid).concat(o,")");else{var l=s.config.plotOptions.radialBar.hollow.imageWidth,h=s.config.plotOptions.radialBar.hollow.imageHeight;if(void 0===l&&void 0===h){var c=s.globals.dom.Paper.image(n).loaded((function(e){this.move(t.centerX-e.width/2+s.config.plotOptions.radialBar.hollow.imageOffsetX,t.centerY-e.height/2+s.config.plotOptions.radialBar.hollow.imageOffsetY)}));e.add(c)}else{var d=s.globals.dom.Paper.image(n).loaded((function(e){this.move(t.centerX-l/2+s.config.plotOptions.radialBar.hollow.imageOffsetX,t.centerY-h/2+s.config.plotOptions.radialBar.hollow.imageOffsetY),this.size(l,h)}));e.add(d)}}return a}},{key:"getStrokeWidth",value:function(t){var e=this.w;return t.size*(100-parseInt(e.config.plotOptions.radialBar.hollow.size,10))/100/(t.series.length+1)-this.margin}}]),i}(),Et=function(t){d(i,At);var e=p(i);function i(){return n(this,i),e.apply(this,arguments)}return h(i,[{key:"draw",value:function(t,e){var i=this.w,a=new k(this.ctx);this.rangeBarOptions=this.w.config.plotOptions.rangeBar,this.series=t,this.seriesRangeStart=i.globals.seriesRangeStart,this.seriesRangeEnd=i.globals.seriesRangeEnd,this.barHelpers.initVariables(t);for(var s=a.group({class:"apexcharts-rangebar-series apexcharts-plot-series"}),o=0;o0&&(this.visibleI=this.visibleI+1);var p=0,x=0;this.yRatio.length>1&&(this.yaxisIndex=u);var b=this.barHelpers.initialPositions();d=b.y,h=b.zeroW,c=b.x,x=b.barWidth,n=b.xDivision,l=b.zeroH;for(var v=a.group({class:"apexcharts-datalabels","data:realIndex":u}),y=a.group({class:"apexcharts-rangebar-goals-markers",style:"pointer-events: none"}),w=0;w0}));return a=l.config.plotOptions.bar.rangeBarGroupRows?s+o*g:s+r*this.visibleI+o*g,u>-1&&!l.config.plotOptions.bar.rangeBarOverlap&&(h=l.globals.seriesRange[e][u].overlaps).indexOf(c)>-1&&(a=(r=n.barHeight/h.length)*this.visibleI+o*(100-parseInt(this.barOptions.barHeight,10))/100/2+r*(this.visibleI+h.indexOf(c))+o*g),{barYPosition:a,barHeight:r}}},{key:"drawRangeColumnPaths",value:function(t){var e=t.indexes,i=t.x;t.strokeWidth;var a=t.xDivision,s=t.barWidth,r=t.zeroH,o=this.w,n=e.i,l=e.j,h=this.yRatio[this.yaxisIndex],c=e.realIndex,d=this.getRangeValue(c,l),g=Math.min(d.start,d.end),u=Math.max(d.start,d.end);o.globals.isXNumeric&&(i=(o.globals.seriesX[n][l]-o.globals.minX)/this.xRatio-s/2);var f=i+s*this.visibleI;void 0===this.series[n][l]||null===this.series[n][l]?g=r:(g=r-g/h,u=r-u/h);var p=Math.abs(u-g),x=this.barHelpers.getColumnPaths({barXPosition:f,barWidth:s,y1:g,y2:u,strokeWidth:this.strokeWidth,series:this.seriesRangeEnd,realIndex:e.realIndex,i:c,j:l,w:o});return o.globals.isXNumeric||(i+=a),{pathTo:x.pathTo,pathFrom:x.pathFrom,barHeight:p,x:i,y:u,goalY:this.barHelpers.getGoalValues("y",null,r,n,l),barXPosition:f}}},{key:"drawRangeBarPaths",value:function(t){var e=t.indexes,i=t.y,a=t.y1,s=t.y2,r=t.yDivision,o=t.barHeight,n=t.barYPosition,l=t.zeroW,h=this.w,c=l+a/this.invertedYRatio,d=l+s/this.invertedYRatio,g=Math.abs(d-c),u=this.barHelpers.getBarpaths({barYPosition:n,barHeight:o,x1:c,x2:d,strokeWidth:this.strokeWidth,series:this.seriesRangeEnd,i:e.realIndex,realIndex:e.realIndex,j:e.j,w:h});return h.globals.isXNumeric||(i+=r),{pathTo:u.pathTo,pathFrom:u.pathFrom,barWidth:g,x:d,goalX:this.barHelpers.getGoalValues("x",l,null,e.realIndex,e.j),y:i}}},{key:"getRangeValue",value:function(t,e){var i=this.w;return{start:i.globals.seriesRangeStart[t][e],end:i.globals.seriesRangeEnd[t][e]}}}]),i}(),Xt=function(){function t(e){n(this,t),this.w=e.w,this.lineCtx=e}return h(t,[{key:"sameValueSeriesFix",value:function(t,e){var i=this.w;if(("gradient"===i.config.fill.type||"gradient"===i.config.fill.type[t])&&new A(this.lineCtx.ctx,i).seriesHaveSameValues(t)){var a=e[t].slice();a[a.length-1]=a[a.length-1]+1e-6,e[t]=a}return e}},{key:"calculatePoints",value:function(t){var e=t.series,i=t.realIndex,a=t.x,s=t.y,r=t.i,o=t.j,n=t.prevY,l=this.w,h=[],c=[];if(0===o){var d=this.lineCtx.categoryAxisCorrection+l.config.markers.offsetX;l.globals.isXNumeric&&(d=(l.globals.seriesX[i][0]-l.globals.minX)/this.lineCtx.xRatio+l.config.markers.offsetX),h.push(d),c.push(m.isNumber(e[r][0])?n+l.config.markers.offsetY:null),h.push(a+l.config.markers.offsetX),c.push(m.isNumber(e[r][o+1])?s+l.config.markers.offsetY:null)}else h.push(a+l.config.markers.offsetX),c.push(m.isNumber(e[r][o+1])?s+l.config.markers.offsetY:null);return{x:h,y:c}}},{key:"checkPreviousPaths",value:function(t){for(var e=t.pathFromLine,i=t.pathFromArea,a=t.realIndex,s=this.w,r=0;r0&&parseInt(o.realIndex,10)===parseInt(a,10)&&("line"===o.type?(this.lineCtx.appendPathFrom=!1,e=s.globals.previousPaths[r].paths[0].d):"area"===o.type&&(this.lineCtx.appendPathFrom=!1,i=s.globals.previousPaths[r].paths[0].d,s.config.stroke.show&&s.globals.previousPaths[r].paths[1]&&(e=s.globals.previousPaths[r].paths[1].d)))}return{pathFromLine:e,pathFromArea:i}}},{key:"determineFirstPrevY",value:function(t){var e,i=t.i,a=t.series,s=t.prevY,r=t.lineYPosition,o=this.w;if(void 0!==(null===(e=a[i])||void 0===e?void 0:e[0]))s=(r=o.config.chart.stacked&&i>0?this.lineCtx.prevSeriesY[i-1][0]:this.lineCtx.zeroY)-a[i][0]/this.lineCtx.yRatio[this.lineCtx.yaxisIndex]+2*(this.lineCtx.isReversed?a[i][0]/this.lineCtx.yRatio[this.lineCtx.yaxisIndex]:0);else if(o.config.chart.stacked&&i>0&&void 0===a[i][0])for(var n=i-1;n>=0;n--)if(null!==a[n][0]&&void 0!==a[n][0]){s=r=this.lineCtx.prevSeriesY[n][0];break}return{prevY:s,lineYPosition:r}}}]),t}(),Yt=function(){function t(e,i,a){n(this,t),this.ctx=e,this.w=e.w,this.xyRatios=i,this.pointsChart=!("bubble"!==this.w.config.chart.type&&"scatter"!==this.w.config.chart.type)||a,this.scatter=new N(this.ctx),this.noNegatives=this.w.globals.minX===Number.MAX_VALUE,this.lineHelpers=new Xt(this),this.markers=new O(this.ctx),this.prevSeriesY=[],this.categoryAxisCorrection=0,this.yaxisIndex=0}return h(t,[{key:"draw",value:function(t,e,i,a){var s=this.w,o=new k(this.ctx),n=s.globals.comboCharts?e:s.config.chart.type,l=o.group({class:"apexcharts-".concat(n,"-series apexcharts-plot-series")}),h=new A(this.ctx,s);this.yRatio=this.xyRatios.yRatio,this.zRatio=this.xyRatios.zRatio,this.xRatio=this.xyRatios.xRatio,this.baseLineY=this.xyRatios.baseLineY,t=h.getLogSeries(t),this.yRatio=h.getLogYRatios(this.yRatio);for(var c=[],d=0;d0&&(p=(s.globals.seriesX[g][0]-s.globals.minX)/this.xRatio),f.push(p);var x,b=p,v=void 0,m=b,y=this.zeroY,w=this.zeroY;y=this.lineHelpers.determineFirstPrevY({i:d,series:t,prevY:y,lineYPosition:0}).prevY,u.push(y),x=y,"rangeArea"===n&&(v=w=this.lineHelpers.determineFirstPrevY({i:d,series:a,prevY:w,lineYPosition:0}).prevY);var S={type:n,series:t,realIndex:g,i:d,x:p,y:1,pX:b,pY:x,pathsFrom:this._calculatePathsFrom({type:n,series:t,i:d,realIndex:g,prevX:m,prevY:y,prevY2:w}),linePaths:[],areaPaths:[],seriesIndex:i,lineYPosition:0,xArrj:f,yArrj:u,seriesRangeEnd:a},C=this._iterateOverDataPoints(r(r({},S),{},{iterations:"rangeArea"===n?t[d].length-1:void 0,isRangeStart:!0}));if("rangeArea"===n){var L=this._calculatePathsFrom({series:a,i:d,realIndex:g,prevX:m,prevY:w}),P=this._iterateOverDataPoints(r(r({},S),{},{series:a,pY:v,pathsFrom:L,iterations:a[d].length-1,isRangeStart:!1}));C.linePaths[0]=P.linePath+C.linePath,C.pathFromLine=P.pathFromLine+C.pathFromLine}this._handlePaths({type:n,realIndex:g,i:d,paths:C}),this.elSeries.add(this.elPointsMain),this.elSeries.add(this.elDataLabelsWrap),c.push(this.elSeries)}if(s.config.chart.stacked)for(var T=c.length;T>0;T--)l.add(c[T-1]);else for(var M=0;M1&&(this.yaxisIndex=i),this.isReversed=a.config.yaxis[this.yaxisIndex]&&a.config.yaxis[this.yaxisIndex].reversed,this.zeroY=a.globals.gridHeight-this.baseLineY[this.yaxisIndex]-(this.isReversed?a.globals.gridHeight:0)+(this.isReversed?2*this.baseLineY[this.yaxisIndex]:0),this.areaBottomY=this.zeroY,(this.zeroY>a.globals.gridHeight||"end"===a.config.plotOptions.area.fillTo)&&(this.areaBottomY=a.globals.gridHeight),this.categoryAxisCorrection=this.xDivision/2,this.elSeries=s.group({class:"apexcharts-series",seriesName:m.escapeString(a.globals.seriesNames[i])}),this.elPointsMain=s.group({class:"apexcharts-series-markers-wrap","data:realIndex":i}),this.elDataLabelsWrap=s.group({class:"apexcharts-datalabels","data:realIndex":i});var r=t[e].length===a.globals.dataPoints;this.elSeries.attr({"data:longestSeries":r,rel:e+1,"data:realIndex":i}),this.appendPathFrom=!0}},{key:"_calculatePathsFrom",value:function(t){var e,i,a,s,r=t.type,o=t.series,n=t.i,l=t.realIndex,h=t.prevX,c=t.prevY,d=t.prevY2,g=this.w,u=new k(this.ctx);if(null===o[n][0]){for(var f=0;f0){var p=this.lineHelpers.checkPreviousPaths({pathFromLine:a,pathFromArea:s,realIndex:l});a=p.pathFromLine,s=p.pathFromArea}return{prevX:h,prevY:c,linePath:e,areaPath:i,pathFromLine:a,pathFromArea:s}}},{key:"_handlePaths",value:function(t){var e=t.type,i=t.realIndex,a=t.i,s=t.paths,o=this.w,n=new k(this.ctx),l=new H(this.ctx);this.prevSeriesY.push(s.yArrj),o.globals.seriesXvalues[i]=s.xArrj,o.globals.seriesYvalues[i]=s.yArrj;var h=o.config.forecastDataPoints;if(h.count>0&&"rangeArea"!==e){var c=o.globals.seriesXvalues[i][o.globals.seriesXvalues[i].length-h.count-1],d=n.drawRect(c,0,o.globals.gridWidth,o.globals.gridHeight,0);o.globals.dom.elForecastMask.appendChild(d.node);var g=n.drawRect(0,0,c,o.globals.gridHeight,0);o.globals.dom.elNonForecastMask.appendChild(g.node)}this.pointsChart||o.globals.delayedElements.push({el:this.elPointsMain.node,index:i});var u={i:a,realIndex:i,animationDelay:a,initialSpeed:o.config.chart.animations.speed,dataChangeSpeed:o.config.chart.animations.dynamicAnimation.speed,className:"apexcharts-".concat(e)};if("area"===e)for(var f=l.fillPath({seriesNumber:i}),p=0;p0&&"rangeArea"!==e){var S=n.renderPaths(w);S.node.setAttribute("stroke-dasharray",h.dashArray),h.strokeWidth&&S.node.setAttribute("stroke-width",h.strokeWidth),this.elSeries.add(S),S.attr("clip-path","url(#forecastMask".concat(o.globals.cuid,")")),A.attr("clip-path","url(#nonForecastMask".concat(o.globals.cuid,")"))}}}}},{key:"_iterateOverDataPoints",value:function(t){var e=t.type,i=t.series,a=t.iterations,s=t.realIndex,r=t.i,o=t.x,n=t.y,l=t.pX,h=t.pY,c=t.pathsFrom,d=t.linePaths,g=t.areaPaths,u=t.seriesIndex,f=t.lineYPosition,p=t.xArrj,x=t.yArrj,b=t.isRangeStart,v=t.seriesRangeEnd,y=this.w,w=new k(this.ctx),A=this.yRatio,S=c.prevY,C=c.linePath,L=c.areaPath,P=c.pathFromLine,T=c.pathFromArea,M=m.isNumber(y.globals.minYArr[s])?y.globals.minYArr[s]:y.globals.minY;a||(a=y.globals.dataPoints>1?y.globals.dataPoints-1:y.globals.dataPoints);for(var I=n,z=0;z0&&y.globals.collapsedSeries.length-1){e--;break}return e>=0?e:0}(r-1)][z+1]:this.zeroY,E?n=f-M/A[this.yaxisIndex]+2*(this.isReversed?M/A[this.yaxisIndex]:0):(n=f-i[r][z+1]/A[this.yaxisIndex]+2*(this.isReversed?i[r][z+1]/A[this.yaxisIndex]:0),"rangeArea"===e&&(I=f-v[r][z+1]/A[this.yaxisIndex]+2*(this.isReversed?v[r][z+1]/A[this.yaxisIndex]:0))),p.push(o),x.push(n);var Y=this.lineHelpers.calculatePoints({series:i,x:o,y:n,realIndex:s,i:r,j:z,prevY:S}),F=this._createPaths({type:e,series:i,i:r,realIndex:s,j:z,x:o,y:n,y2:I,pX:l,pY:h,linePath:C,areaPath:L,linePaths:d,areaPaths:g,seriesIndex:u,isRangeStart:b});g=F.areaPaths,d=F.linePaths,l=F.pX,h=F.pY,L=F.areaPath,C=F.linePath,this.appendPathFrom&&(P+=w.line(o,this.zeroY),T+=w.line(o,this.zeroY)),this.handleNullDataPoints(i,Y,r,z,s),this._handleMarkersAndLabels({type:e,pointsPos:Y,i:r,j:z,realIndex:s,isRangeStart:b})}return{yArrj:x,xArrj:p,pathFromArea:T,areaPaths:g,pathFromLine:P,linePaths:d,linePath:C,areaPath:L}}},{key:"_handleMarkersAndLabels",value:function(t){var e=t.type,i=t.pointsPos,a=t.isRangeStart,s=t.i,r=t.j,o=t.realIndex,n=this.w,l=new W(this.ctx);if(this.pointsChart)this.scatter.draw(this.elSeries,r,{realIndex:o,pointsPos:i,zRatio:this.zRatio,elParent:this.elPointsMain});else{n.globals.series[s].length>1&&this.elPointsMain.node.classList.add("apexcharts-element-hidden");var h=this.markers.plotChartMarkers(i,o,r+1);null!==h&&this.elPointsMain.add(h)}var c=l.drawDataLabel({type:e,isRangeStart:a,pos:i,i:o,j:r+1});null!==c&&this.elDataLabelsWrap.add(c)}},{key:"_createPaths",value:function(t){var e=t.type,i=t.series,a=t.i,s=t.realIndex,r=t.j,o=t.x,n=t.y,l=t.y2,h=t.pX,c=t.pY,d=t.linePath,g=t.areaPath,u=t.linePaths,f=t.areaPaths,p=t.seriesIndex,x=t.isRangeStart,b=this.w,v=new k(this.ctx),m=b.config.stroke.curve,y=this.areaBottomY;if(Array.isArray(b.config.stroke.curve)&&(m=Array.isArray(p)?b.config.stroke.curve[p[a]]:b.config.stroke.curve[a]),"smooth"===m){var w=.35*(o-h);b.globals.hasNullValues?(null!==i[a][r]&&(null!==i[a][r+1]?(d=v.move(h,c)+v.curve(h+w,c,o-w,n,o+1,n),g=v.move(h+1,c)+v.curve(h+w,c,o-w,n,o+1,n)+v.line(o,y)+v.line(h,y)+"z"):(d=v.move(h,c),g=v.move(h,c)+"z")),u.push(d),f.push(g)):(d+=v.curve(h+w,c,o-w,n,o,n),g+=v.curve(h+w,c,o-w,n,o,n)),h=o,c=n,r===i[a].length-2&&(g=g+v.curve(h,c,o,n,o,y)+v.move(o,n)+"z","rangeArea"===e&&x?d=d+v.curve(h,c,o,n,o,l)+v.move(o,l)+"z":b.globals.hasNullValues||(u.push(d),f.push(g)))}else{if(null===i[a][r+1]){d+=v.move(o,n);var A=b.globals.isXNumeric?(b.globals.seriesX[s][r]-b.globals.minX)/this.xRatio:o-this.xDivision;g=g+v.line(A,y)+v.move(o,n)+"z"}null===i[a][r]&&(d+=v.move(o,n),g+=v.move(o,y)),"stepline"===m?(d=d+v.line(o,null,"H")+v.line(null,n,"V"),g=g+v.line(o,null,"H")+v.line(null,n,"V")):"straight"===m&&(d+=v.line(o,n),g+=v.line(o,n)),r===i[a].length-2&&(g=g+v.line(o,y)+v.move(o,n)+"z","rangeArea"===e&&x?d=d+v.line(o,l)+v.move(o,l)+"z":(u.push(d),f.push(g)))}return{linePaths:u,areaPaths:f,pX:h,pY:c,linePath:d,areaPath:g}}},{key:"handleNullDataPoints",value:function(t,e,i,a,s){var r=this.w;if(null===t[i][a]&&r.config.markers.showNullDataPoints||1===t[i].length){var o=this.markers.plotChartMarkers(e,s,a+1,this.strokeWidth-r.config.markers.strokeWidth/2,!0);null!==o&&this.elPointsMain.add(o)}}}]),t}();window.TreemapSquared={},window.TreemapSquared.generate=function(){function t(e,i,a,s){this.xoffset=e,this.yoffset=i,this.height=s,this.width=a,this.shortestEdge=function(){return Math.min(this.height,this.width)},this.getCoordinates=function(t){var e,i=[],a=this.xoffset,s=this.yoffset,o=r(t)/this.height,n=r(t)/this.width;if(this.width>=this.height)for(e=0;e=this.height){var a=e/this.height,s=this.width-a;i=new t(this.xoffset+a,this.yoffset,s,this.height)}else{var r=e/this.width,o=this.height-r;i=new t(this.xoffset,this.yoffset+r,this.width,o)}return i}}function e(e,a,s,o,n){return o=void 0===o?0:o,n=void 0===n?0:n,function(t){var e,i,a=[];for(e=0;e=a(s,i))}(e,l=t[0],n)?(e.push(l),i(t.slice(1),e,s,o)):(h=s.cutArea(r(e),o),o.push(s.getCoordinates(e)),i(t,[],h,o)),o;o.push(s.getCoordinates(e))}function a(t,e){var i=Math.min.apply(Math,t),a=Math.max.apply(Math,t),s=r(t);return Math.max(Math.pow(e,2)*a/Math.pow(s,2),Math.pow(s,2)/(Math.pow(e,2)*i))}function s(t){return t&&t.constructor===Array}function r(t){var e,i=0;for(e=0;er-a&&l.width<=o-s){var h=n.rotateAroundCenter(t.node);t.node.setAttribute("transform","rotate(-90 ".concat(h.x," ").concat(h.y,")"))}}},{key:"animateTreemap",value:function(t,e,i,a){var s=new y(this.ctx);s.animateRect(t,{x:e.x,y:e.y,width:e.width,height:e.height},{x:i.x,y:i.y,width:i.width,height:i.height},a,(function(){s.animationCompleted(t)}))}}]),t}(),Ht=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.timeScaleArray=[],this.utc=this.w.config.xaxis.labels.datetimeUTC}return h(t,[{key:"calculateTimeScaleTicks",value:function(t,e){var i=this,a=this.w;if(a.globals.allSeriesCollapsed)return a.globals.labels=[],a.globals.timescaleLabels=[],[];var s=new z(this.ctx),o=(e-t)/864e5;this.determineInterval(o),a.globals.disableZoomIn=!1,a.globals.disableZoomOut=!1,o<.00011574074074074075?a.globals.disableZoomIn=!0:o>5e4&&(a.globals.disableZoomOut=!0);var n=s.getTimeUnitsfromTimestamp(t,e,this.utc),l=a.globals.gridWidth/o,h=l/24,c=h/60,d=c/60,g=Math.floor(24*o),u=Math.floor(1440*o),f=Math.floor(86400*o),p=Math.floor(o),x=Math.floor(o/30),b=Math.floor(o/365),v={minMillisecond:n.minMillisecond,minSecond:n.minSecond,minMinute:n.minMinute,minHour:n.minHour,minDate:n.minDate,minMonth:n.minMonth,minYear:n.minYear},m={firstVal:v,currentMillisecond:v.minMillisecond,currentSecond:v.minSecond,currentMinute:v.minMinute,currentHour:v.minHour,currentMonthDate:v.minDate,currentDate:v.minDate,currentMonth:v.minMonth,currentYear:v.minYear,daysWidthOnXAxis:l,hoursWidthOnXAxis:h,minutesWidthOnXAxis:c,secondsWidthOnXAxis:d,numberOfSeconds:f,numberOfMinutes:u,numberOfHours:g,numberOfDays:p,numberOfMonths:x,numberOfYears:b};switch(this.tickInterval){case"years":this.generateYearScale(m);break;case"months":case"half_year":this.generateMonthScale(m);break;case"months_days":case"months_fortnight":case"days":case"week_days":this.generateDayScale(m);break;case"hours":this.generateHourScale(m);break;case"minutes_fives":case"minutes":this.generateMinuteScale(m);break;case"seconds_tens":case"seconds_fives":case"seconds":this.generateSecondScale(m)}var y=this.timeScaleArray.map((function(t){var e={position:t.position,unit:t.unit,year:t.year,day:t.day?t.day:1,hour:t.hour?t.hour:0,month:t.month+1};return"month"===t.unit?r(r({},e),{},{day:1,value:t.value+1}):"day"===t.unit||"hour"===t.unit?r(r({},e),{},{value:t.value}):"minute"===t.unit?r(r({},e),{},{value:t.value,minute:t.value}):"second"===t.unit?r(r({},e),{},{value:t.value,minute:t.minute,second:t.second}):t}));return y.filter((function(t){var e=1,s=Math.ceil(a.globals.gridWidth/120),r=t.value;void 0!==a.config.xaxis.tickAmount&&(s=a.config.xaxis.tickAmount),y.length>s&&(e=Math.floor(y.length/s));var o=!1,n=!1;switch(i.tickInterval){case"years":"year"===t.unit&&(o=!0);break;case"half_year":e=7,"year"===t.unit&&(o=!0);break;case"months":e=1,"year"===t.unit&&(o=!0);break;case"months_fortnight":e=15,"year"!==t.unit&&"month"!==t.unit||(o=!0),30===r&&(n=!0);break;case"months_days":e=10,"month"===t.unit&&(o=!0),30===r&&(n=!0);break;case"week_days":e=8,"month"===t.unit&&(o=!0);break;case"days":e=1,"month"===t.unit&&(o=!0);break;case"hours":"day"===t.unit&&(o=!0);break;case"minutes_fives":case"seconds_fives":r%5!=0&&(n=!0);break;case"seconds_tens":r%10!=0&&(n=!0)}if("hours"===i.tickInterval||"minutes_fives"===i.tickInterval||"seconds_tens"===i.tickInterval||"seconds_fives"===i.tickInterval){if(!n)return!0}else if((r%e==0||o)&&!n)return!0}))}},{key:"recalcDimensionsBasedOnFormat",value:function(t,e){var i=this.w,a=this.formatDates(t),s=this.removeOverlappingTS(a);i.globals.timescaleLabels=s.slice(),new ht(this.ctx).plotCoords()}},{key:"determineInterval",value:function(t){var e=24*t,i=60*e;switch(!0){case t/365>5:this.tickInterval="years";break;case t>800:this.tickInterval="half_year";break;case t>180:this.tickInterval="months";break;case t>90:this.tickInterval="months_fortnight";break;case t>60:this.tickInterval="months_days";break;case t>30:this.tickInterval="week_days";break;case t>2:this.tickInterval="days";break;case e>2.4:this.tickInterval="hours";break;case i>15:this.tickInterval="minutes_fives";break;case i>5:this.tickInterval="minutes";break;case i>1:this.tickInterval="seconds_tens";break;case 60*i>20:this.tickInterval="seconds_fives";break;default:this.tickInterval="seconds"}}},{key:"generateYearScale",value:function(t){var e=t.firstVal,i=t.currentMonth,a=t.currentYear,s=t.daysWidthOnXAxis,r=t.numberOfYears,o=e.minYear,n=0,l=new z(this.ctx),h="year";if(e.minDate>1||e.minMonth>0){var c=l.determineRemainingDaysOfYear(e.minYear,e.minMonth,e.minDate);n=(l.determineDaysOfYear(e.minYear)-c+1)*s,o=e.minYear+1,this.timeScaleArray.push({position:n,value:o,unit:h,year:o,month:m.monthMod(i+1)})}else 1===e.minDate&&0===e.minMonth&&this.timeScaleArray.push({position:n,value:o,unit:h,year:a,month:m.monthMod(i+1)});for(var d=o,g=n,u=0;u1){l=(h.determineDaysOfMonths(a+1,e.minYear)-i+1)*r,n=m.monthMod(a+1);var g=s+d,u=m.monthMod(n),f=n;0===n&&(c="year",f=g,u=1,g+=d+=1),this.timeScaleArray.push({position:l,value:f,unit:c,year:g,month:u})}else this.timeScaleArray.push({position:l,value:n,unit:c,year:s,month:m.monthMod(a)});for(var p=n+1,x=l,b=0,v=1;bo.determineDaysOfMonths(e+1,i)?(h=1,n="month",g=e+=1,e):e},d=(24-e.minHour)*s,g=l,u=c(h,i,a);0===e.minHour&&1===e.minDate?(d=0,g=m.monthMod(e.minMonth),n="month",h=e.minDate,r++):1!==e.minDate&&0===e.minHour&&0===e.minMinute&&(d=0,l=e.minDate,g=l,u=c(h=l,i,a)),this.timeScaleArray.push({position:d,value:g,unit:n,year:this._getYear(a,u,0),month:m.monthMod(u),day:h});for(var f=d,p=0;pn.determineDaysOfMonths(e+1,s)&&(p=1,e+=1),{month:e,date:p}},c=function(t,e){return t>n.determineDaysOfMonths(e+1,s)?e+=1:e},d=60-(e.minMinute+e.minSecond/60),g=d*r,u=e.minHour+1,f=u+1;60===d&&(g=0,f=(u=e.minHour)+1);var p=i,x=c(p,a);this.timeScaleArray.push({position:g,value:u,unit:l,day:p,hour:f,year:s,month:m.monthMod(x)});for(var b=g,v=0;v=24&&(f=0,l="day",x=h(p+=1,x).month,x=c(p,x));var y=this._getYear(s,x,0);b=0===f&&0===v?d*r:60*r+b;var w=0===f?p:f;this.timeScaleArray.push({position:b,value:w,unit:l,hour:f,day:p,year:y,month:m.monthMod(x)}),f++}}},{key:"generateMinuteScale",value:function(t){for(var e=t.currentMillisecond,i=t.currentSecond,a=t.currentMinute,s=t.currentHour,r=t.currentDate,o=t.currentMonth,n=t.currentYear,l=t.minutesWidthOnXAxis,h=t.secondsWidthOnXAxis,c=t.numberOfMinutes,d=a+1,g=r,u=o,f=n,p=s,x=(60-i-e/1e3)*h,b=0;b=60&&(d=0,24===(p+=1)&&(p=0)),this.timeScaleArray.push({position:x,value:d,unit:"minute",hour:p,minute:d,day:g,year:this._getYear(f,u,0),month:m.monthMod(u)}),x+=l,d++}},{key:"generateSecondScale",value:function(t){for(var e=t.currentMillisecond,i=t.currentSecond,a=t.currentMinute,s=t.currentHour,r=t.currentDate,o=t.currentMonth,n=t.currentYear,l=t.secondsWidthOnXAxis,h=t.numberOfSeconds,c=i+1,d=a,g=r,u=o,f=n,p=s,x=(1e3-e)/1e3*l,b=0;b=60&&(c=0,++d>=60&&(d=0,24==++p&&(p=0))),this.timeScaleArray.push({position:x,value:c,unit:"second",hour:p,minute:d,second:c,day:g,year:this._getYear(f,u,0),month:m.monthMod(u)}),x+=l,c++}},{key:"createRawDateString",value:function(t,e){var i=t.year;return 0===t.month&&(t.month=1),i+="-"+("0"+t.month.toString()).slice(-2),"day"===t.unit?i+="day"===t.unit?"-"+("0"+e).slice(-2):"-01":i+="-"+("0"+(t.day?t.day:"1")).slice(-2),"hour"===t.unit?i+="hour"===t.unit?"T"+("0"+e).slice(-2):"T00":i+="T"+("0"+(t.hour?t.hour:"0")).slice(-2),"minute"===t.unit?i+=":"+("0"+e).slice(-2):i+=":"+(t.minute?("0"+t.minute).slice(-2):"00"),"second"===t.unit?i+=":"+("0"+e).slice(-2):i+=":00",this.utc&&(i+=".000Z"),i}},{key:"formatDates",value:function(t){var e=this,i=this.w;return t.map((function(t){var a=t.value.toString(),s=new z(e.ctx),r=e.createRawDateString(t,a),o=s.getDate(s.parseDate(r));if(e.utc||(o=s.getDate(s.parseDateWithTimezone(r))),void 0===i.config.xaxis.labels.format){var n="dd MMM",l=i.config.xaxis.labels.datetimeFormatter;"year"===t.unit&&(n=l.year),"month"===t.unit&&(n=l.month),"day"===t.unit&&(n=l.day),"hour"===t.unit&&(n=l.hour),"minute"===t.unit&&(n=l.minute),"second"===t.unit&&(n=l.second),a=s.formatDate(o,n)}else a=s.formatDate(o,i.config.xaxis.labels.format);return{dateString:r,position:t.position,value:a,unit:t.unit,year:t.year,month:t.month}}))}},{key:"removeOverlappingTS",value:function(t){var e,i=this,a=new k(this.ctx),s=!1;t.length>0&&t[0].value&&t.every((function(e){return e.value.length===t[0].value.length}))&&(s=!0,e=a.getTextRects(t[0].value).width);var r=0,o=t.map((function(o,n){if(n>0&&i.w.config.xaxis.labels.hideOverlappingLabels){var l=s?e:a.getTextRects(t[r].value).width,h=t[r].position;return o.position>h+l+10?(r=n,o):null}return o}));return o.filter((function(t){return null!==t}))}},{key:"_getYear",value:function(t,e,i){return t+Math.floor(e/12)+i}}]),t}(),Ot=function(){function t(e,i){n(this,t),this.ctx=i,this.w=i.w,this.el=e}return h(t,[{key:"setupElements",value:function(){var t=this.w.globals,e=this.w.config,i=e.chart.type;t.axisCharts=["line","area","bar","rangeBar","rangeArea","candlestick","boxPlot","scatter","bubble","radar","heatmap","treemap"].indexOf(i)>-1,t.xyCharts=["line","area","bar","rangeBar","rangeArea","candlestick","boxPlot","scatter","bubble"].indexOf(i)>-1,t.isBarHorizontal=("bar"===e.chart.type||"rangeBar"===e.chart.type||"boxPlot"===e.chart.type)&&e.plotOptions.bar.horizontal,t.chartClass=".apexcharts"+t.chartID,t.dom.baseEl=this.el,t.dom.elWrap=document.createElement("div"),k.setAttrs(t.dom.elWrap,{id:t.chartClass.substring(1),class:"apexcharts-canvas "+t.chartClass.substring(1)}),this.el.appendChild(t.dom.elWrap),t.dom.Paper=new window.SVG.Doc(t.dom.elWrap),t.dom.Paper.attr({class:"apexcharts-svg","xmlns:data":"ApexChartsNS",transform:"translate(".concat(e.chart.offsetX,", ").concat(e.chart.offsetY,")")}),t.dom.Paper.node.style.background=e.chart.background,this.setSVGDimensions(),t.dom.elGraphical=t.dom.Paper.group().attr({class:"apexcharts-inner apexcharts-graphical"}),t.dom.elAnnotations=t.dom.Paper.group().attr({class:"apexcharts-annotations"}),t.dom.elDefs=t.dom.Paper.defs(),t.dom.elLegendWrap=document.createElement("div"),t.dom.elLegendWrap.classList.add("apexcharts-legend"),t.dom.elWrap.appendChild(t.dom.elLegendWrap),t.dom.Paper.add(t.dom.elGraphical),t.dom.elGraphical.add(t.dom.elDefs)}},{key:"plotChartType",value:function(t,e){var i=this.w,a=i.config,s=i.globals,r={series:[],i:[]},o={series:[],i:[]},n={series:[],i:[]},l={series:[],i:[]},h={series:[],i:[]},c={series:[],i:[]},d={series:[],i:[]},g={series:[],i:[]},u={series:[],seriesRangeEnd:[],i:[]};s.series.map((function(e,f){var p=0;void 0!==t[f].type?("column"===t[f].type||"bar"===t[f].type?(s.series.length>1&&a.plotOptions.bar.horizontal&&console.warn("Horizontal bars are not supported in a mixed/combo chart. Please turn off `plotOptions.bar.horizontal`"),h.series.push(e),h.i.push(f),p++,i.globals.columnSeries=h.series):"area"===t[f].type?(o.series.push(e),o.i.push(f),p++):"line"===t[f].type?(r.series.push(e),r.i.push(f),p++):"scatter"===t[f].type?(n.series.push(e),n.i.push(f)):"bubble"===t[f].type?(l.series.push(e),l.i.push(f),p++):"candlestick"===t[f].type?(c.series.push(e),c.i.push(f),p++):"boxPlot"===t[f].type?(d.series.push(e),d.i.push(f),p++):"rangeBar"===t[f].type?(g.series.push(e),g.i.push(f),p++):"rangeArea"===t[f].type?(u.series.push(s.seriesRangeStart[f]),u.seriesRangeEnd.push(s.seriesRangeEnd[f]),u.i.push(f),p++):console.warn("You have specified an unrecognized chart type. Available types for this property are line/area/column/bar/scatter/bubble"),p>1&&(s.comboCharts=!0)):(r.series.push(e),r.i.push(f))}));var f=new Yt(this.ctx,e),p=new Ct(this.ctx,e);this.ctx.pie=new Mt(this.ctx);var x=new zt(this.ctx);this.ctx.rangeBar=new Et(this.ctx,e);var b=new It(this.ctx),v=[];if(s.comboCharts){if(o.series.length>0&&v.push(f.draw(o.series,"area",o.i)),h.series.length>0)if(i.config.chart.stacked){var m=new St(this.ctx,e);v.push(m.draw(h.series,h.i))}else this.ctx.bar=new At(this.ctx,e),v.push(this.ctx.bar.draw(h.series,h.i));if(u.series.length>0&&v.push(f.draw(u.series,"rangeArea",u.i,u.seriesRangeEnd)),r.series.length>0&&v.push(f.draw(r.series,"line",r.i)),c.series.length>0&&v.push(p.draw(c.series,c.i)),d.series.length>0&&v.push(p.draw(d.series,d.i)),g.series.length>0&&v.push(this.ctx.rangeBar.draw(g.series,g.i)),n.series.length>0){var y=new Yt(this.ctx,e,!0);v.push(y.draw(n.series,"scatter",n.i))}if(l.series.length>0){var w=new Yt(this.ctx,e,!0);v.push(w.draw(l.series,"bubble",l.i))}}else switch(a.chart.type){case"line":v=f.draw(s.series,"line");break;case"area":v=f.draw(s.series,"area");break;case"bar":a.chart.stacked?v=new St(this.ctx,e).draw(s.series):(this.ctx.bar=new At(this.ctx,e),v=this.ctx.bar.draw(s.series));break;case"candlestick":case"boxPlot":v=new Ct(this.ctx,e).draw(s.series);break;case"rangeBar":v=this.ctx.rangeBar.draw(s.series);break;case"rangeArea":v=f.draw(s.seriesRangeStart,"rangeArea",void 0,s.seriesRangeEnd);break;case"heatmap":v=new Pt(this.ctx,e).draw(s.series);break;case"treemap":v=new Dt(this.ctx,e).draw(s.series);break;case"pie":case"donut":case"polarArea":v=this.ctx.pie.draw(s.series);break;case"radialBar":v=x.draw(s.series);break;case"radar":v=b.draw(s.series);break;default:v=f.draw(s.series)}return v}},{key:"setSVGDimensions",value:function(){var t=this.w.globals,e=this.w.config;t.svgWidth=e.chart.width,t.svgHeight=e.chart.height;var i=m.getDimensions(this.el),a=e.chart.width.toString().split(/[0-9]+/g).pop();"%"===a?m.isNumber(i[0])&&(0===i[0].width&&(i=m.getDimensions(this.el.parentNode)),t.svgWidth=i[0]*parseInt(e.chart.width,10)/100):"px"!==a&&""!==a||(t.svgWidth=parseInt(e.chart.width,10));var s=e.chart.height.toString().split(/[0-9]+/g).pop();if("auto"!==t.svgHeight&&""!==t.svgHeight)if("%"===s){var r=m.getDimensions(this.el.parentNode);t.svgHeight=r[1]*parseInt(e.chart.height,10)/100}else t.svgHeight=parseInt(e.chart.height,10);else t.axisCharts?t.svgHeight=t.svgWidth/1.61:t.svgHeight=t.svgWidth/1.2;if(t.svgWidth<0&&(t.svgWidth=0),t.svgHeight<0&&(t.svgHeight=0),k.setAttrs(t.dom.Paper.node,{width:t.svgWidth,height:t.svgHeight}),"%"!==s){var o=e.chart.sparkline.enabled?0:t.axisCharts?e.chart.parentHeightOffset:0;t.dom.Paper.node.parentNode.parentNode.style.minHeight=t.svgHeight+o+"px"}t.dom.elWrap.style.width=t.svgWidth+"px",t.dom.elWrap.style.height=t.svgHeight+"px"}},{key:"shiftGraphPosition",value:function(){var t=this.w.globals,e=t.translateY,i={transform:"translate("+t.translateX+", "+e+")"};k.setAttrs(t.dom.elGraphical.node,i)}},{key:"resizeNonAxisCharts",value:function(){var t=this.w,e=t.globals,i=0,a=t.config.chart.sparkline.enabled?1:15;a+=t.config.grid.padding.bottom,"top"!==t.config.legend.position&&"bottom"!==t.config.legend.position||!t.config.legend.show||t.config.legend.floating||(i=new dt(this.ctx).legendHelpers.getLegendBBox().clwh+10);var s=t.globals.dom.baseEl.querySelector(".apexcharts-radialbar, .apexcharts-pie"),r=2.05*t.globals.radialSize;if(s&&!t.config.chart.sparkline.enabled&&0!==t.config.plotOptions.radialBar.startAngle){var o=m.getBoundingClientRect(s);r=o.bottom;var n=o.bottom-o.top;r=Math.max(2.05*t.globals.radialSize,n)}var l=r+e.translateY+i+a;e.dom.elLegendForeign&&e.dom.elLegendForeign.setAttribute("height",l),t.config.chart.height&&String(t.config.chart.height).indexOf("%")>0||(e.dom.elWrap.style.height=l+"px",k.setAttrs(e.dom.Paper.node,{height:l}),e.dom.Paper.node.parentNode.parentNode.style.minHeight=l+"px")}},{key:"coreCalculations",value:function(){new $(this.ctx).init()}},{key:"resetGlobals",value:function(){var t=this,e=function(){return t.w.config.series.map((function(t){return[]}))},i=new R,a=this.w.globals;i.initGlobalVars(a),a.seriesXvalues=e(),a.seriesYvalues=e()}},{key:"isMultipleY",value:function(){if(this.w.config.yaxis.constructor===Array&&this.w.config.yaxis.length>1)return this.w.globals.isMultipleYAxis=!0,!0}},{key:"xySettings",value:function(){var t=null,e=this.w;if(e.globals.axisCharts){if("back"===e.config.xaxis.crosshairs.position&&new et(this.ctx).drawXCrosshairs(),"back"===e.config.yaxis[0].crosshairs.position&&new et(this.ctx).drawYCrosshairs(),"datetime"===e.config.xaxis.type&&void 0===e.config.xaxis.labels.formatter){this.ctx.timeScale=new Ht(this.ctx);var i=[];isFinite(e.globals.minX)&&isFinite(e.globals.maxX)&&!e.globals.isBarHorizontal?i=this.ctx.timeScale.calculateTimeScaleTicks(e.globals.minX,e.globals.maxX):e.globals.isBarHorizontal&&(i=this.ctx.timeScale.calculateTimeScaleTicks(e.globals.minY,e.globals.maxY)),this.ctx.timeScale.recalcDimensionsBasedOnFormat(i)}t=new A(this.ctx).getCalculatedRatios()}return t}},{key:"updateSourceChart",value:function(t){this.ctx.w.globals.selection=void 0,this.ctx.updateHelpers._updateOptions({chart:{selection:{xaxis:{min:t.w.globals.minX,max:t.w.globals.maxX}}}},!1,!1)}},{key:"setupBrushHandler",value:function(){var t=this,e=this.w;if(e.config.chart.brush.enabled&&"function"!=typeof e.config.chart.events.selection){var i=e.config.chart.brush.targets||[e.config.chart.brush.target];i.forEach((function(e){var i=ApexCharts.getChartByID(e);i.w.globals.brushSource=t.ctx,"function"!=typeof i.w.config.chart.events.zoomed&&(i.w.config.chart.events.zoomed=function(){t.updateSourceChart(i)}),"function"!=typeof i.w.config.chart.events.scrolled&&(i.w.config.chart.events.scrolled=function(){t.updateSourceChart(i)})})),e.config.chart.events.selection=function(t,a){i.forEach((function(t){var i=ApexCharts.getChartByID(t),s=m.clone(e.config.yaxis);if(e.config.chart.brush.autoScaleYaxis&&1===i.w.globals.series.length){var o=new Z(i);s=o.autoScaleY(i,s,a)}var n=i.w.config.yaxis.reduce((function(t,e,a){return[].concat(x(t),[r(r({},i.w.config.yaxis[a]),{},{min:s[0].min,max:s[0].max})])}),[]);i.ctx.updateHelpers._updateOptions({xaxis:{min:a.xaxis.min,max:a.xaxis.max},yaxis:n},!1,!1,!1,!1)}))}}}}]),t}(),Nt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"_updateOptions",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return new Promise((function(n){var l=[e.ctx];s&&(l=e.ctx.getSyncedCharts()),e.ctx.w.globals.isExecCalled&&(l=[e.ctx],e.ctx.w.globals.isExecCalled=!1),l.forEach((function(s,h){var c=s.w;if(c.globals.shouldAnimate=a,i||(c.globals.resized=!0,c.globals.dataChanged=!0,a&&s.series.getPreviousPaths()),t&&"object"===o(t)&&(s.config=new F(t),t=A.extendArrayProps(s.config,t,c),s.w.globals.chartID!==e.ctx.w.globals.chartID&&delete t.series,c.config=m.extend(c.config,t),r&&(c.globals.lastXAxis=t.xaxis?m.clone(t.xaxis):[],c.globals.lastYAxis=t.yaxis?m.clone(t.yaxis):[],c.globals.initialConfig=m.extend({},c.config),c.globals.initialSeries=m.clone(c.config.series),t.series))){for(var d=0;d2&&void 0!==arguments[2]&&arguments[2];return new Promise((function(s){var r,o=i.w;return o.globals.shouldAnimate=e,o.globals.dataChanged=!0,e&&i.ctx.series.getPreviousPaths(),o.globals.axisCharts?(0===(r=t.map((function(t,e){return i._extendSeries(t,e)}))).length&&(r=[{data:[]}]),o.config.series=r):o.config.series=t.slice(),a&&(o.globals.initialConfig.series=m.clone(o.config.series),o.globals.initialSeries=m.clone(o.config.series)),i.ctx.update().then((function(){s(i.ctx)}))}))}},{key:"_extendSeries",value:function(t,e){var i=this.w,a=i.config.series[e];return r(r({},i.config.series[e]),{},{name:t.name?t.name:a&&a.name,color:t.color?t.color:a&&a.color,type:t.type?t.type:a&&a.type,data:t.data?t.data:a&&a.data})}},{key:"toggleDataPointSelection",value:function(t,e){var i=this.w,a=null,s=".apexcharts-series[data\\:realIndex='".concat(t,"']");return i.globals.axisCharts?a=i.globals.dom.Paper.select("".concat(s," path[j='").concat(e,"'], ").concat(s," circle[j='").concat(e,"'], ").concat(s," rect[j='").concat(e,"']")).members[0]:void 0===e&&(a=i.globals.dom.Paper.select("".concat(s," path[j='").concat(t,"']")).members[0],"pie"!==i.config.chart.type&&"polarArea"!==i.config.chart.type&&"donut"!==i.config.chart.type||this.ctx.pie.pieClicked(t)),a?(new k(this.ctx).pathMouseDown(a,null),a.node?a.node:null):(console.warn("toggleDataPointSelection: Element not found"),null)}},{key:"forceXAxisUpdate",value:function(t){var e=this.w;if(["min","max"].forEach((function(i){void 0!==t.xaxis[i]&&(e.config.xaxis[i]=t.xaxis[i],e.globals.lastXAxis[i]=t.xaxis[i])})),t.xaxis.categories&&t.xaxis.categories.length&&(e.config.xaxis.categories=t.xaxis.categories),e.config.xaxis.convertedCatToNumeric){var i=new Y(t);t=i.convertCatToNumericXaxis(t,this.ctx)}return t}},{key:"forceYAxisUpdate",value:function(t){return t.chart&&t.chart.stacked&&"100%"===t.chart.stackType&&(Array.isArray(t.yaxis)?t.yaxis.forEach((function(e,i){t.yaxis[i].min=0,t.yaxis[i].max=100})):(t.yaxis.min=0,t.yaxis.max=100)),t}},{key:"revertDefaultAxisMinMax",value:function(t){var e=this,i=this.w,a=i.globals.lastXAxis,s=i.globals.lastYAxis;t&&t.xaxis&&(a=t.xaxis),t&&t.yaxis&&(s=t.yaxis),i.config.xaxis.min=a.min,i.config.xaxis.max=a.max;i.config.yaxis.map((function(t,a){i.globals.zoomed||void 0!==s[a]?function(t){void 0!==s[t]&&(i.config.yaxis[t].min=s[t].min,i.config.yaxis[t].max=s[t].max)}(a):void 0!==e.ctx.opts.yaxis[a]&&(t.min=e.ctx.opts.yaxis[a].min,t.max=e.ctx.opts.yaxis[a].max)}))}}]),t}();Ft="undefined"!=typeof window?window:void 0,Rt=function(t,e){var i=(void 0!==this?this:t).SVG=function(t){if(i.supported)return t=new i.Doc(t),i.parser.draw||i.prepare(),t};if(i.ns="http://www.w3.org/2000/svg",i.xmlns="http://www.w3.org/2000/xmlns/",i.xlink="http://www.w3.org/1999/xlink",i.svgjs="http://svgjs.dev",i.supported=!0,!i.supported)return!1;i.did=1e3,i.eid=function(t){return"Svgjs"+d(t)+i.did++},i.create=function(t){var i=e.createElementNS(this.ns,t);return i.setAttribute("id",this.eid(t)),i},i.extend=function(){var t,e;e=(t=[].slice.call(arguments)).pop();for(var a=t.length-1;a>=0;a--)if(t[a])for(var s in e)t[a].prototype[s]=e[s];i.Set&&i.Set.inherit&&i.Set.inherit()},i.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,i.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&i.extend(e,t.extend),t.construct&&i.extend(t.parent||i.Container,t.construct),e},i.adopt=function(e){return e?e.instance?e.instance:((a="svg"==e.nodeName?e.parentNode instanceof t.SVGElement?new i.Nested:new i.Doc:"linearGradient"==e.nodeName?new i.Gradient("linear"):"radialGradient"==e.nodeName?new i.Gradient("radial"):i[d(e.nodeName)]?new(i[d(e.nodeName)]):new i.Element(e)).type=e.nodeName,a.node=e,e.instance=a,a instanceof i.Doc&&a.namespace().defs(),a.setData(JSON.parse(e.getAttribute("svgjs:data"))||{}),a):null;var a},i.prepare=function(){var t=e.getElementsByTagName("body")[0],a=(t?new i.Doc(t):i.adopt(e.documentElement).nested()).size(2,0);i.parser={body:t||e.documentElement,draw:a.style("opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden").node,poly:a.polyline().node,path:a.path().node,native:i.create("svg")}},i.parser={native:i.create("svg")},e.addEventListener("DOMContentLoaded",(function(){i.parser.draw||i.prepare()}),!1),i.regex={numberAndUnit:/^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,hex:/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,rgb:/rgb\((\d+),(\d+),(\d+)\)/,reference:/#([a-z0-9\-_]+)/i,transforms:/\)\s*,?\s*/,whitespace:/\s/g,isHex:/^#[a-f0-9]{3,6}$/i,isRgb:/^rgb\(/,isCss:/[^:]+:[^;]+;?/,isBlank:/^(\s+)?$/,isNumber:/^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,isPercent:/^-?[\d\.]+%$/,isImage:/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,delimiter:/[\s,]+/,hyphen:/([^e])\-/gi,pathLetters:/[MLHVCSQTAZ]/gi,isPathLetter:/[MLHVCSQTAZ]/i,numbersWithDots:/((\d?\.\d+(?:e[+-]?\d+)?)((?:\.\d+(?:e[+-]?\d+)?)+))+/gi,dots:/\./g},i.utils={map:function(t,e){for(var i=t.length,a=[],s=0;s1?1:t,new i.Color({r:~~(this.r+(this.destination.r-this.r)*t),g:~~(this.g+(this.destination.g-this.g)*t),b:~~(this.b+(this.destination.b-this.b)*t)})):this}}),i.Color.test=function(t){return t+="",i.regex.isHex.test(t)||i.regex.isRgb.test(t)},i.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},i.Color.isColor=function(t){return i.Color.isRgb(t)||i.Color.test(t)},i.Array=function(t,e){0==(t=(t||[]).valueOf()).length&&e&&(t=e.valueOf()),this.value=this.parse(t)},i.extend(i.Array,{toString:function(){return this.value.join(" ")},valueOf:function(){return this.value},parse:function(t){return t=t.valueOf(),Array.isArray(t)?t:this.split(t)}}),i.PointArray=function(t,e){i.Array.call(this,t,e||[[0,0]])},i.PointArray.prototype=new i.Array,i.PointArray.prototype.constructor=i.PointArray;for(var a={M:function(t,e,i){return e.x=i.x=t[0],e.y=i.y=t[1],["M",e.x,e.y]},L:function(t,e){return e.x=t[0],e.y=t[1],["L",t[0],t[1]]},H:function(t,e){return e.x=t[0],["H",t[0]]},V:function(t,e){return e.y=t[0],["V",t[0]]},C:function(t,e){return e.x=t[4],e.y=t[5],["C",t[0],t[1],t[2],t[3],t[4],t[5]]},Q:function(t,e){return e.x=t[2],e.y=t[3],["Q",t[0],t[1],t[2],t[3]]},Z:function(t,e,i){return e.x=i.x,e.y=i.y,["Z"]}},s="mlhvqtcsaz".split(""),r=0,n=s.length;rl);return r},bbox:function(){return i.parser.draw||i.prepare(),i.parser.path.setAttribute("d",this.toString()),i.parser.path.getBBox()}}),i.Number=i.invent({create:function(t,e){this.value=0,this.unit=e||"","number"==typeof t?this.value=isNaN(t)?0:isFinite(t)?t:t<0?-34e37:34e37:"string"==typeof t?(e=t.match(i.regex.numberAndUnit))&&(this.value=parseFloat(e[1]),"%"==e[5]?this.value/=100:"s"==e[5]&&(this.value*=1e3),this.unit=e[5]):t instanceof i.Number&&(this.value=t.valueOf(),this.unit=t.unit)},extend:{toString:function(){return("%"==this.unit?~~(1e8*this.value)/1e6:"s"==this.unit?this.value/1e3:this.value)+this.unit},toJSON:function(){return this.toString()},valueOf:function(){return this.value},plus:function(t){return t=new i.Number(t),new i.Number(this+t,this.unit||t.unit)},minus:function(t){return t=new i.Number(t),new i.Number(this-t,this.unit||t.unit)},times:function(t){return t=new i.Number(t),new i.Number(this*t,this.unit||t.unit)},divide:function(t){return t=new i.Number(t),new i.Number(this/t,this.unit||t.unit)},to:function(t){var e=new i.Number(this);return"string"==typeof t&&(e.unit=t),e},morph:function(t){return this.destination=new i.Number(t),t.relative&&(this.destination.value+=this.value),this},at:function(t){return this.destination?new i.Number(this.destination).minus(this).times(t).plus(this):this}}}),i.Element=i.invent({create:function(t){this._stroke=i.defaults.attrs.stroke,this._event=null,this.dom={},(this.node=t)&&(this.type=t.nodeName,this.node.instance=this,this._stroke=t.getAttribute("stroke")||this._stroke)},extend:{x:function(t){return this.attr("x",t)},y:function(t){return this.attr("y",t)},cx:function(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)},cy:function(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},width:function(t){return this.attr("width",t)},height:function(t){return this.attr("height",t)},size:function(t,e){var a=u(this,t,e);return this.width(new i.Number(a.width)).height(new i.Number(a.height))},clone:function(t){this.writeDataToDom();var e=x(this.node.cloneNode(!0));return t?t.add(e):this.after(e),e},remove:function(){return this.parent()&&this.parent().removeElement(this),this},replace:function(t){return this.after(t).remove(),t},addTo:function(t){return t.put(this)},putIn:function(t){return t.add(this)},id:function(t){return this.attr("id",t)},show:function(){return this.style("display","")},hide:function(){return this.style("display","none")},visible:function(){return"none"!=this.style("display")},toString:function(){return this.attr("id")},classes:function(){var t=this.attr("class");return null==t?[]:t.trim().split(i.regex.delimiter)},hasClass:function(t){return-1!=this.classes().indexOf(t)},addClass:function(t){if(!this.hasClass(t)){var e=this.classes();e.push(t),this.attr("class",e.join(" "))}return this},removeClass:function(t){return this.hasClass(t)&&this.attr("class",this.classes().filter((function(e){return e!=t})).join(" ")),this},toggleClass:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t)},reference:function(t){return i.get(this.attr(t))},parent:function(e){var a=this;if(!a.node.parentNode)return null;if(a=i.adopt(a.node.parentNode),!e)return a;for(;a&&a.node instanceof t.SVGElement;){if("string"==typeof e?a.matches(e):a instanceof e)return a;if(!a.node.parentNode||"#document"==a.node.parentNode.nodeName)return null;a=i.adopt(a.node.parentNode)}},doc:function(){return this instanceof i.Doc?this:this.parent(i.Doc)},parents:function(t){var e=[],i=this;do{if(!(i=i.parent(t))||!i.node)break;e.push(i)}while(i.parent);return e},matches:function(t){return function(t,e){return(t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector).call(t,e)}(this.node,t)},native:function(){return this.node},svg:function(t){var a=e.createElement("svg");if(!(t&&this instanceof i.Parent))return a.appendChild(t=e.createElement("svg")),this.writeDataToDom(),t.appendChild(this.node.cloneNode(!0)),a.innerHTML.replace(/^/,"").replace(/<\/svg>$/,"");a.innerHTML=""+t.replace(/\n/,"").replace(/<([\w:-]+)([^<]+?)\/>/g,"<$1$2>")+"";for(var s=0,r=a.firstChild.childNodes.length;s":function(t){return-Math.cos(t*Math.PI)/2+.5},">":function(t){return Math.sin(t*Math.PI/2)},"<":function(t){return 1-Math.cos(t*Math.PI/2)}},i.morph=function(t){return function(e,a){return new i.MorphObj(e,a).at(t)}},i.Situation=i.invent({create:function(t){this.init=!1,this.reversed=!1,this.reversing=!1,this.duration=new i.Number(t.duration).valueOf(),this.delay=new i.Number(t.delay).valueOf(),this.start=+new Date+this.delay,this.finish=this.start+this.duration,this.ease=t.ease,this.loop=0,this.loops=!1,this.animations={},this.attrs={},this.styles={},this.transforms=[],this.once={}}}),i.FX=i.invent({create:function(t){this._target=t,this.situations=[],this.active=!1,this.situation=null,this.paused=!1,this.lastPos=0,this.pos=0,this.absPos=0,this._speed=1},extend:{animate:function(t,e,a){"object"===o(t)&&(e=t.ease,a=t.delay,t=t.duration);var s=new i.Situation({duration:t||1e3,delay:a||0,ease:i.easing[e||"-"]||e});return this.queue(s),this},target:function(t){return t&&t instanceof i.Element?(this._target=t,this):this._target},timeToAbsPos:function(t){return(t-this.situation.start)/(this.situation.duration/this._speed)},absPosToTime:function(t){return this.situation.duration/this._speed*t+this.situation.start},startAnimFrame:function(){this.stopAnimFrame(),this.animationFrame=t.requestAnimationFrame(function(){this.step()}.bind(this))},stopAnimFrame:function(){t.cancelAnimationFrame(this.animationFrame)},start:function(){return!this.active&&this.situation&&(this.active=!0,this.startCurrent()),this},startCurrent:function(){return this.situation.start=+new Date+this.situation.delay/this._speed,this.situation.finish=this.situation.start+this.situation.duration/this._speed,this.initAnimations().step()},queue:function(t){return("function"==typeof t||t instanceof i.Situation)&&this.situations.push(t),this.situation||(this.situation=this.situations.shift()),this},dequeue:function(){return this.stop(),this.situation=this.situations.shift(),this.situation&&(this.situation instanceof i.Situation?this.start():this.situation.call(this)),this},initAnimations:function(){var t,e=this.situation;if(e.init)return this;for(var a in e.animations){t=this.target()[a](),Array.isArray(t)||(t=[t]),Array.isArray(e.animations[a])||(e.animations[a]=[e.animations[a]]);for(var s=t.length;s--;)e.animations[a][s]instanceof i.Number&&(t[s]=new i.Number(t[s])),e.animations[a][s]=t[s].morph(e.animations[a][s])}for(var a in e.attrs)e.attrs[a]=new i.MorphObj(this.target().attr(a),e.attrs[a]);for(var a in e.styles)e.styles[a]=new i.MorphObj(this.target().style(a),e.styles[a]);return e.initialTransformation=this.target().matrixify(),e.init=!0,this},clearQueue:function(){return this.situations=[],this},clearCurrent:function(){return this.situation=null,this},stop:function(t,e){var i=this.active;return this.active=!1,e&&this.clearQueue(),t&&this.situation&&(!i&&this.startCurrent(),this.atEnd()),this.stopAnimFrame(),this.clearCurrent()},after:function(t){var e=this.last();return this.target().on("finished.fx",(function i(a){a.detail.situation==e&&(t.call(this,e),this.off("finished.fx",i))})),this._callStart()},during:function(t){var e=this.last(),a=function(a){a.detail.situation==e&&t.call(this,a.detail.pos,i.morph(a.detail.pos),a.detail.eased,e)};return this.target().off("during.fx",a).on("during.fx",a),this.after((function(){this.off("during.fx",a)})),this._callStart()},afterAll:function(t){var e=function e(i){t.call(this),this.off("allfinished.fx",e)};return this.target().off("allfinished.fx",e).on("allfinished.fx",e),this._callStart()},last:function(){return this.situations.length?this.situations[this.situations.length-1]:this.situation},add:function(t,e,i){return this.last()[i||"animations"][t]=e,this._callStart()},step:function(t){var e,i,a;t||(this.absPos=this.timeToAbsPos(+new Date)),!1!==this.situation.loops?(e=Math.max(this.absPos,0),i=Math.floor(e),!0===this.situation.loops||ithis.lastPos&&r<=s&&(this.situation.once[r].call(this.target(),this.pos,s),delete this.situation.once[r]);return this.active&&this.target().fire("during",{pos:this.pos,eased:s,fx:this,situation:this.situation}),this.situation?(this.eachAt(),1==this.pos&&!this.situation.reversed||this.situation.reversed&&0==this.pos?(this.stopAnimFrame(),this.target().fire("finished",{fx:this,situation:this.situation}),this.situations.length||(this.target().fire("allfinished"),this.situations.length||(this.target().off(".fx"),this.active=!1)),this.active?this.dequeue():this.clearCurrent()):!this.paused&&this.active&&this.startAnimFrame(),this.lastPos=s,this):this},eachAt:function(){var t,e=this,a=this.target(),s=this.situation;for(var r in s.animations)t=[].concat(s.animations[r]).map((function(t){return"string"!=typeof t&&t.at?t.at(s.ease(e.pos),e.pos):t})),a[r].apply(a,t);for(var r in s.attrs)t=[r].concat(s.attrs[r]).map((function(t){return"string"!=typeof t&&t.at?t.at(s.ease(e.pos),e.pos):t})),a.attr.apply(a,t);for(var r in s.styles)t=[r].concat(s.styles[r]).map((function(t){return"string"!=typeof t&&t.at?t.at(s.ease(e.pos),e.pos):t})),a.style.apply(a,t);if(s.transforms.length){t=s.initialTransformation,r=0;for(var o=s.transforms.length;r=0;--a)this[m[a]]=null!=t[m[a]]?t[m[a]]:e[m[a]]},extend:{extract:function(){var t=f(this,0,1);f(this,1,0);var e=180/Math.PI*Math.atan2(t.y,t.x)-90;return{x:this.e,y:this.f,transformedX:(this.e*Math.cos(e*Math.PI/180)+this.f*Math.sin(e*Math.PI/180))/Math.sqrt(this.a*this.a+this.b*this.b),transformedY:(this.f*Math.cos(e*Math.PI/180)+this.e*Math.sin(-e*Math.PI/180))/Math.sqrt(this.c*this.c+this.d*this.d),rotation:e,a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f,matrix:new i.Matrix(this)}},clone:function(){return new i.Matrix(this)},morph:function(t){return this.destination=new i.Matrix(t),this},multiply:function(t){return new i.Matrix(this.native().multiply(function(t){return t instanceof i.Matrix||(t=new i.Matrix(t)),t}(t).native()))},inverse:function(){return new i.Matrix(this.native().inverse())},translate:function(t,e){return new i.Matrix(this.native().translate(t||0,e||0))},native:function(){for(var t=i.parser.native.createSVGMatrix(),e=m.length-1;e>=0;e--)t[m[e]]=this[m[e]];return t},toString:function(){return"matrix("+v(this.a)+","+v(this.b)+","+v(this.c)+","+v(this.d)+","+v(this.e)+","+v(this.f)+")"}},parent:i.Element,construct:{ctm:function(){return new i.Matrix(this.node.getCTM())},screenCTM:function(){if(this instanceof i.Nested){var t=this.rect(1,1),e=t.node.getScreenCTM();return t.remove(),new i.Matrix(e)}return new i.Matrix(this.node.getScreenCTM())}}}),i.Point=i.invent({create:function(t,e){var i;i=Array.isArray(t)?{x:t[0],y:t[1]}:"object"===o(t)?{x:t.x,y:t.y}:null!=t?{x:t,y:null!=e?e:t}:{x:0,y:0},this.x=i.x,this.y=i.y},extend:{clone:function(){return new i.Point(this)},morph:function(t,e){return this.destination=new i.Point(t,e),this}}}),i.extend(i.Element,{point:function(t,e){return new i.Point(t,e).transform(this.screenCTM().inverse())}}),i.extend(i.Element,{attr:function(t,e,a){if(null==t){for(t={},a=(e=this.node.attributes).length-1;a>=0;a--)t[e[a].nodeName]=i.regex.isNumber.test(e[a].nodeValue)?parseFloat(e[a].nodeValue):e[a].nodeValue;return t}if("object"===o(t))for(var s in t)this.attr(s,t[s]);else if(null===e)this.node.removeAttribute(t);else{if(null==e)return null==(e=this.node.getAttribute(t))?i.defaults.attrs[t]:i.regex.isNumber.test(e)?parseFloat(e):e;"stroke-width"==t?this.attr("stroke",parseFloat(e)>0?this._stroke:null):"stroke"==t&&(this._stroke=e),"fill"!=t&&"stroke"!=t||(i.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof i.Image&&(e=this.doc().defs().pattern(0,0,(function(){this.add(e)})))),"number"==typeof e?e=new i.Number(e):i.Color.isColor(e)?e=new i.Color(e):Array.isArray(e)&&(e=new i.Array(e)),"leading"==t?this.leading&&this.leading(e):"string"==typeof a?this.node.setAttributeNS(a,t,e.toString()):this.node.setAttribute(t,e.toString()),!this.rebuild||"font-size"!=t&&"x"!=t||this.rebuild(t,e)}return this}}),i.extend(i.Element,{transform:function(t,e){var a;return"object"!==o(t)?(a=new i.Matrix(this).extract(),"string"==typeof t?a[t]:a):(a=new i.Matrix(this),e=!!e||!!t.relative,null!=t.a&&(a=e?a.multiply(new i.Matrix(t)):new i.Matrix(t)),this.attr("transform",a))}}),i.extend(i.Element,{untransform:function(){return this.attr("transform",null)},matrixify:function(){return(this.attr("transform")||"").split(i.regex.transforms).slice(0,-1).map((function(t){var e=t.trim().split("(");return[e[0],e[1].split(i.regex.delimiter).map((function(t){return parseFloat(t)}))]})).reduce((function(t,e){return"matrix"==e[0]?t.multiply(p(e[1])):t[e[0]].apply(t,e[1])}),new i.Matrix)},toParent:function(t){if(this==t)return this;var e=this.screenCTM(),i=t.screenCTM().inverse();return this.addTo(t).untransform().transform(i.multiply(e)),this},toDoc:function(){return this.toParent(this.doc())}}),i.Transformation=i.invent({create:function(t,e){if(arguments.length>1&&"boolean"!=typeof e)return this.constructor.call(this,[].slice.call(arguments));if(Array.isArray(t))for(var i=0,a=this.arguments.length;i=0},index:function(t){return[].slice.call(this.node.childNodes).indexOf(t.node)},get:function(t){return i.adopt(this.node.childNodes[t])},first:function(){return this.get(0)},last:function(){return this.get(this.node.childNodes.length-1)},each:function(t,e){for(var a=this.children(),s=0,r=a.length;s=0;a--)e.childNodes[a]instanceof t.SVGElement&&x(e.childNodes[a]);return i.adopt(e).id(i.eid(e.nodeName))}function b(t){return null==t.x&&(t.x=0,t.y=0,t.width=0,t.height=0),t.w=t.width,t.h=t.height,t.x2=t.x+t.width,t.y2=t.y+t.height,t.cx=t.x+t.width/2,t.cy=t.y+t.height/2,t}function v(t){return Math.abs(t)>1e-37?t:0}["fill","stroke"].forEach((function(t){var e={};e[t]=function(e){if(void 0===e)return this;if("string"==typeof e||i.Color.isRgb(e)||e&&"function"==typeof e.fill)this.attr(t,e);else for(var a=l[t].length-1;a>=0;a--)null!=e[l[t][a]]&&this.attr(l.prefix(t,l[t][a]),e[l[t][a]]);return this},i.extend(i.Element,i.FX,e)})),i.extend(i.Element,i.FX,{translate:function(t,e){return this.transform({x:t,y:e})},matrix:function(t){return this.attr("transform",new i.Matrix(6==arguments.length?[].slice.call(arguments):t))},opacity:function(t){return this.attr("opacity",t)},dx:function(t){return this.x(new i.Number(t).plus(this instanceof i.FX?0:this.x()),!0)},dy:function(t){return this.y(new i.Number(t).plus(this instanceof i.FX?0:this.y()),!0)}}),i.extend(i.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),i.Set=i.invent({create:function(t){Array.isArray(t)?this.members=t:this.clear()},extend:{add:function(){for(var t=[].slice.call(arguments),e=0,i=t.length;e-1&&this.members.splice(e,1),this},each:function(t){for(var e=0,i=this.members.length;e=0},index:function(t){return this.members.indexOf(t)},get:function(t){return this.members[t]},first:function(){return this.get(0)},last:function(){return this.get(this.members.length-1)},valueOf:function(){return this.members}},construct:{set:function(t){return new i.Set(t)}}}),i.FX.Set=i.invent({create:function(t){this.set=t}}),i.Set.inherit=function(){var t=[];for(var e in i.Shape.prototype)"function"==typeof i.Shape.prototype[e]&&"function"!=typeof i.Set.prototype[e]&&t.push(e);for(var e in t.forEach((function(t){i.Set.prototype[t]=function(){for(var e=0,a=this.members.length;e=0;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory||(this._memory={})}}),i.get=function(t){var a=e.getElementById(function(t){var e=(t||"").toString().match(i.regex.reference);if(e)return e[1]}(t)||t);return i.adopt(a)},i.select=function(t,a){return new i.Set(i.utils.map((a||e).querySelectorAll(t),(function(t){return i.adopt(t)})))},i.extend(i.Parent,{select:function(t){return i.select(t,this.node)}});var m="abcdef".split("");if("function"!=typeof t.CustomEvent){var y=function(t,i){i=i||{bubbles:!1,cancelable:!1,detail:void 0};var a=e.createEvent("CustomEvent");return a.initCustomEvent(t,i.bubbles,i.cancelable,i.detail),a};y.prototype=t.Event.prototype,i.CustomEvent=y}else i.CustomEvent=t.CustomEvent;return i},void 0!==(a=function(){return Rt(Ft,Ft.document)}.call(e,i,e,t))&&(t.exports=a), + */function s(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,a)}return i}function r(t){for(var e=1;et.length)&&(e=t.length);for(var i=0,a=new Array(e);i>16,o=i>>8&255,n=255&i;return"#"+(16777216+65536*(Math.round((a-r)*s)+r)+256*(Math.round((a-o)*s)+o)+(Math.round((a-n)*s)+n)).toString(16).slice(1)}},{key:"shadeColor",value:function(e,i){return t.isColorHex(i)?this.shadeHexColor(e,i):this.shadeRGBColor(e,i)}}],[{key:"bind",value:function(t,e){return function(){return t.apply(e,arguments)}}},{key:"isObject",value:function(t){return t&&"object"===o(t)&&!Array.isArray(t)&&null!=t}},{key:"is",value:function(t,e){return Object.prototype.toString.call(e)==="[object "+t+"]"}},{key:"listToArray",value:function(t){var e,i=[];for(e=0;e1&&void 0!==arguments[1]?arguments[1]:2;return parseFloat(t.toPrecision(e))}},{key:"randomId",value:function(){return(Math.random()+1).toString(36).substring(4)}},{key:"noExponents",value:function(t){var e=String(t).split(/[eE]/);if(1===e.length)return e[0];var i="",a=t<0?"-":"",s=e[0].replace(".",""),r=Number(e[1])+1;if(r<0){for(i=a+"0.";r++;)i+="0";return i+s.replace(/^-/,"")}for(r-=s.length;r--;)i+="0";return s+i}},{key:"getDimensions",value:function(t){var e=getComputedStyle(t,null),i=t.clientHeight,a=t.clientWidth;return i-=parseFloat(e.paddingTop)+parseFloat(e.paddingBottom),[a-=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight),i]}},{key:"getBoundingClientRect",value:function(t){var e=t.getBoundingClientRect();return{top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:t.clientWidth,height:t.clientHeight,x:e.left,y:e.top}}},{key:"getLargestStringFromArr",value:function(t){return t.reduce((function(t,e){return Array.isArray(e)&&(e=e.reduce((function(t,e){return t.length>e.length?t:e}))),t.length>e.length?t:e}),0)}},{key:"hexToRgba",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"#999999",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.6;"#"!==t.substring(0,1)&&(t="#999999");var i=t.replace("#","");i=i.match(new RegExp("(.{"+i.length/3+"})","g"));for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:"x",i=t.toString().slice();return i.replace(/[` ~!@#$%^&*()|+\=?;:'",.<>{}[\]\\/]/gi,e)}},{key:"negToZero",value:function(t){return t<0?0:t}},{key:"moveIndexInArray",value:function(t,e,i){if(i>=t.length)for(var a=i-t.length+1;a--;)t.push(void 0);return t.splice(i,0,t.splice(e,1)[0]),t}},{key:"extractNumber",value:function(t){return parseFloat(t.replace(/[^\d.]*/g,""))}},{key:"findAncestor",value:function(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t}},{key:"setELstyles",value:function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t.style.key=e[i])}},{key:"isNumber",value:function(t){return!isNaN(t)&&parseFloat(Number(t))===t&&!isNaN(parseInt(t,10))}},{key:"isFloat",value:function(t){return Number(t)===t&&t%1!=0}},{key:"isSafari",value:function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}},{key:"isFirefox",value:function(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1}},{key:"isIE11",value:function(){if(-1!==window.navigator.userAgent.indexOf("MSIE")||window.navigator.appVersion.indexOf("Trident/")>-1)return!0}},{key:"isIE",value:function(){var t=window.navigator.userAgent,e=t.indexOf("MSIE ");if(e>0)return parseInt(t.substring(e+5,t.indexOf(".",e)),10);if(t.indexOf("Trident/")>0){var i=t.indexOf("rv:");return parseInt(t.substring(i+3,t.indexOf(".",i)),10)}var a=t.indexOf("Edge/");return a>0&&parseInt(t.substring(a+5,t.indexOf(".",a)),10)}}]),t}(),w=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.setEasingFunctions()}return h(t,[{key:"setEasingFunctions",value:function(){var t;if(!this.w.globals.easing){switch(this.w.config.chart.animations.easing){case"linear":t="-";break;case"easein":t="<";break;case"easeout":t=">";break;case"easeinout":default:t="<>";break;case"swing":t=function(t){var e=1.70158;return(t-=1)*t*((e+1)*t+e)+1};break;case"bounce":t=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375};break;case"elastic":t=function(t){return t===!!t?t:Math.pow(2,-10*t)*Math.sin((t-.075)*(2*Math.PI)/.3)+1}}this.w.globals.easing=t}}},{key:"animateLine",value:function(t,e,i,a){t.attr(e).animate(a).attr(i)}},{key:"animateMarker",value:function(t,e,i,a,s,r){e||(e=0),t.attr({r:e,width:e,height:e}).animate(a,s).attr({r:i,width:i.width,height:i.height}).afterAll((function(){r()}))}},{key:"animateCircle",value:function(t,e,i,a,s){t.attr({r:e.r,cx:e.cx,cy:e.cy}).animate(a,s).attr({r:i.r,cx:i.cx,cy:i.cy})}},{key:"animateRect",value:function(t,e,i,a,s){t.attr(e).animate(a).attr(i).afterAll((function(){return s()}))}},{key:"animatePathsGradually",value:function(t){var e=t.el,i=t.realIndex,a=t.j,s=t.fill,r=t.pathFrom,o=t.pathTo,n=t.speed,l=t.delay,h=this.w,c=0;h.config.chart.animations.animateGradually.enabled&&(c=h.config.chart.animations.animateGradually.delay),h.config.chart.animations.dynamicAnimation.enabled&&h.globals.dataChanged&&"bar"!==h.config.chart.type&&(c=0),this.morphSVG(e,i,a,"line"!==h.config.chart.type||h.globals.comboCharts?s:"stroke",r,o,n,l*c)}},{key:"showDelayedElements",value:function(){this.w.globals.delayedElements.forEach((function(t){var e=t.el;e.classList.remove("apexcharts-element-hidden"),e.classList.add("apexcharts-hidden-element-shown")}))}},{key:"animationCompleted",value:function(t){var e=this.w;e.globals.animationEnded||(e.globals.animationEnded=!0,this.showDelayedElements(),"function"==typeof e.config.chart.events.animationEnd&&e.config.chart.events.animationEnd(this.ctx,{el:t,w:e}))}},{key:"morphSVG",value:function(t,e,i,a,s,r,o,n){var l=this,h=this.w;s||(s=t.attr("pathFrom")),r||(r=t.attr("pathTo"));var c=function(t){return"radar"===h.config.chart.type&&(o=1),"M 0 ".concat(h.globals.gridHeight)};(!s||s.indexOf("undefined")>-1||s.indexOf("NaN")>-1)&&(s=c()),(!r||r.indexOf("undefined")>-1||r.indexOf("NaN")>-1)&&(r=c()),h.globals.shouldAnimate||(o=1),t.plot(s).animate(1,h.globals.easing,n).plot(s).animate(o,h.globals.easing,n).plot(r).afterAll((function(){y.isNumber(i)?i===h.globals.series[h.globals.maxValsInArrayIndex].length-2&&h.globals.shouldAnimate&&l.animationCompleted(t):"none"!==a&&h.globals.shouldAnimate&&(!h.globals.comboCharts&&e===h.globals.series.length-1||h.globals.comboCharts)&&l.animationCompleted(t),l.showDelayedElements()}))}}]),t}(),k=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"getDefaultFilter",value:function(t,e){var i=this.w;t.unfilter(!0),(new window.SVG.Filter).size("120%","180%","-5%","-40%"),"none"!==i.config.states.normal.filter?this.applyFilter(t,e,i.config.states.normal.filter.type,i.config.states.normal.filter.value):i.config.chart.dropShadow.enabled&&this.dropShadow(t,i.config.chart.dropShadow,e)}},{key:"addNormalFilter",value:function(t,e){var i=this.w;i.config.chart.dropShadow.enabled&&!t.node.classList.contains("apexcharts-marker")&&this.dropShadow(t,i.config.chart.dropShadow,e)}},{key:"addLightenFilter",value:function(t,e,i){var a=this,s=this.w,r=i.intensity;t.unfilter(!0),new window.SVG.Filter,t.filter((function(t){var i=s.config.chart.dropShadow;(i.enabled?a.addShadow(t,e,i):t).componentTransfer({rgb:{type:"linear",slope:1.5,intercept:r}})})),t.filterer.node.setAttribute("filterUnits","userSpaceOnUse"),this._scaleFilterSize(t.filterer.node)}},{key:"addDarkenFilter",value:function(t,e,i){var a=this,s=this.w,r=i.intensity;t.unfilter(!0),new window.SVG.Filter,t.filter((function(t){var i=s.config.chart.dropShadow;(i.enabled?a.addShadow(t,e,i):t).componentTransfer({rgb:{type:"linear",slope:r}})})),t.filterer.node.setAttribute("filterUnits","userSpaceOnUse"),this._scaleFilterSize(t.filterer.node)}},{key:"applyFilter",value:function(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5;switch(i){case"none":this.addNormalFilter(t,e);break;case"lighten":this.addLightenFilter(t,e,{intensity:a});break;case"darken":this.addDarkenFilter(t,e,{intensity:a})}}},{key:"addShadow",value:function(t,e,i){var a=i.blur,s=i.top,r=i.left,o=i.color,n=i.opacity,l=t.flood(Array.isArray(o)?o[e]:o,n).composite(t.sourceAlpha,"in").offset(r,s).gaussianBlur(a).merge(t.source);return t.blend(t.source,l)}},{key:"dropShadow",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=e.top,s=e.left,r=e.blur,o=e.color,n=e.opacity,l=e.noUserSpaceOnUse,h=this.w;return t.unfilter(!0),y.isIE()&&"radialBar"===h.config.chart.type||(o=Array.isArray(o)?o[i]:o,t.filter((function(t){var e;e=y.isSafari()||y.isFirefox()||y.isIE()?t.flood(o,n).composite(t.sourceAlpha,"in").offset(s,a).gaussianBlur(r):t.flood(o,n).composite(t.sourceAlpha,"in").offset(s,a).gaussianBlur(r).merge(t.source),t.blend(t.source,e)})),l||t.filterer.node.setAttribute("filterUnits","userSpaceOnUse"),this._scaleFilterSize(t.filterer.node)),t}},{key:"setSelectionFilter",value:function(t,e,i){var a=this.w;if(void 0!==a.globals.selectedDataPoints[e]&&a.globals.selectedDataPoints[e].indexOf(i)>-1){t.node.setAttribute("selected",!0);var s=a.config.states.active.filter;"none"!==s&&this.applyFilter(t,e,s.type,s.value)}}},{key:"_scaleFilterSize",value:function(t){!function(e){for(var i in e)e.hasOwnProperty(i)&&t.setAttribute(i,e[i])}({width:"200%",height:"200%",x:"-50%",y:"-50%"})}}]),t}(),A=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"roundPathCorners",value:function(t,e){function i(t,e,i){var s=e.x-t.x,r=e.y-t.y,o=Math.sqrt(s*s+r*r);return a(t,e,Math.min(1,i/o))}function a(t,e,i){return{x:t.x+(e.x-t.x)*i,y:t.y+(e.y-t.y)*i}}function s(t,e){t.length>2&&(t[t.length-2]=e.x,t[t.length-1]=e.y)}function r(t){return{x:parseFloat(t[t.length-2]),y:parseFloat(t[t.length-1])}}t.indexOf("NaN")>-1&&(t="");var o=t.split(/[,\s]/).reduce((function(t,e){var i=e.match("([a-zA-Z])(.+)");return i?(t.push(i[1]),t.push(i[2])):t.push(e),t}),[]).reduce((function(t,e){return parseFloat(e)==e&&t.length?t[t.length-1].push(e):t.push([e]),t}),[]),n=[];if(o.length>1){var l=r(o[0]),h=null;"Z"==o[o.length-1][0]&&o[0].length>2&&(h=["L",l.x,l.y],o[o.length-1]=h),n.push(o[0]);for(var c=1;c2&&"L"==g[0]&&u.length>2&&"L"==u[0]){var p,f,x=r(d),b=r(g),v=r(u);p=i(b,x,e),f=i(b,v,e),s(g,p),g.origPoint=b,n.push(g);var m=a(p,b,.5),y=a(b,f,.5),w=["C",m.x,m.y,y.x,y.y,f.x,f.y];w.origPoint=b,n.push(w)}else n.push(g)}if(h){var k=r(n[n.length-1]);n.push(["Z"]),s(n[0],k)}}else n=o;return n.reduce((function(t,e){return t+e.join(" ")+" "}),"")}},{key:"drawLine",value:function(t,e,i,a){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"#a8a8a8",r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,n=arguments.length>7&&void 0!==arguments[7]?arguments[7]:"butt";return this.w.globals.dom.Paper.line().attr({x1:t,y1:e,x2:i,y2:a,stroke:s,"stroke-dasharray":r,"stroke-width":o,"stroke-linecap":n})}},{key:"drawRect",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"#fefefe",o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:1,n=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null,l=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null,h=arguments.length>9&&void 0!==arguments[9]?arguments[9]:0,c=this.w.globals.dom.Paper.rect();return c.attr({x:t,y:e,width:i>0?i:0,height:a>0?a:0,rx:s,ry:s,opacity:o,"stroke-width":null!==n?n:0,stroke:null!==l?l:"none","stroke-dasharray":h}),c.node.setAttribute("fill",r),c}},{key:"drawPolygon",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#e1e1e1",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"none";return this.w.globals.dom.Paper.polygon(t).attr({fill:a,stroke:e,"stroke-width":i})}},{key:"drawCircle",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t<0&&(t=0);var i=this.w.globals.dom.Paper.circle(2*t);return null!==e&&i.attr(e),i}},{key:"drawPath",value:function(t){var e=t.d,i=void 0===e?"":e,a=t.stroke,s=void 0===a?"#a8a8a8":a,r=t.strokeWidth,o=void 0===r?1:r,n=t.fill,l=t.fillOpacity,h=void 0===l?1:l,c=t.strokeOpacity,d=void 0===c?1:c,g=t.classes,u=t.strokeLinecap,p=void 0===u?null:u,f=t.strokeDashArray,x=void 0===f?0:f,b=this.w;return null===p&&(p=b.config.stroke.lineCap),(i.indexOf("undefined")>-1||i.indexOf("NaN")>-1)&&(i="M 0 ".concat(b.globals.gridHeight)),b.globals.dom.Paper.path(i).attr({fill:n,"fill-opacity":h,stroke:s,"stroke-opacity":d,"stroke-linecap":p,"stroke-width":o,"stroke-dasharray":x,class:g})}},{key:"group",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=this.w.globals.dom.Paper.group();return null!==t&&e.attr(t),e}},{key:"move",value:function(t,e){return["M",t,e].join(" ")}},{key:"line",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=null;return null===i?a=[" L",t,e].join(" "):"H"===i?a=[" H",t].join(" "):"V"===i&&(a=[" V",e].join(" ")),a}},{key:"curve",value:function(t,e,i,a,s,r){return["C",t,e,i,a,s,r].join(" ")}},{key:"quadraticCurve",value:function(t,e,i,a){return["Q",t,e,i,a].join(" ")}},{key:"arc",value:function(t,e,i,a,s,r,o){var n="A";arguments.length>7&&void 0!==arguments[7]&&arguments[7]&&(n="a");var l=[n,t,e,i,a,s,r,o].join(" ");return l}},{key:"renderPaths",value:function(t){var e,i=t.j,a=t.realIndex,s=t.pathFrom,o=t.pathTo,n=t.stroke,l=t.strokeWidth,h=t.strokeLinecap,c=t.fill,d=t.animationDelay,g=t.initialSpeed,u=t.dataChangeSpeed,p=t.className,f=t.shouldClipToGrid,x=void 0===f||f,b=t.bindEventsOnPaths,v=void 0===b||b,m=t.drawShadow,y=void 0===m||m,A=this.w,S=new k(this.ctx),C=new w(this.ctx),L=this.w.config.chart.animations.enabled,P=L&&this.w.config.chart.animations.dynamicAnimation.enabled,T=!!(L&&!A.globals.resized||P&&A.globals.dataChanged&&A.globals.shouldAnimate);T?e=s:(e=o,A.globals.animationEnded=!0);var I,M=A.config.stroke.dashArray;I=Array.isArray(M)?M[a]:A.config.stroke.dashArray;var X=this.drawPath({d:e,stroke:n,strokeWidth:l,fill:c,fillOpacity:1,classes:p,strokeLinecap:h,strokeDashArray:I});if(X.attr("index",a),x&&X.attr({"clip-path":"url(#gridRectMask".concat(A.globals.cuid,")")}),"none"!==A.config.states.normal.filter.type)S.getDefaultFilter(X,a);else if(A.config.chart.dropShadow.enabled&&y&&(!A.config.chart.dropShadow.enabledOnSeries||A.config.chart.dropShadow.enabledOnSeries&&-1!==A.config.chart.dropShadow.enabledOnSeries.indexOf(a))){var z=A.config.chart.dropShadow;S.dropShadow(X,z,a)}v&&(X.node.addEventListener("mouseenter",this.pathMouseEnter.bind(this,X)),X.node.addEventListener("mouseleave",this.pathMouseLeave.bind(this,X)),X.node.addEventListener("mousedown",this.pathMouseDown.bind(this,X))),X.attr({pathTo:o,pathFrom:s});var E={el:X,j:i,realIndex:a,pathFrom:s,pathTo:o,fill:c,strokeWidth:l,delay:d};return!L||A.globals.resized||A.globals.dataChanged?!A.globals.resized&&A.globals.dataChanged||C.showDelayedElements():C.animatePathsGradually(r(r({},E),{},{speed:g})),A.globals.dataChanged&&P&&T&&C.animatePathsGradually(r(r({},E),{},{speed:u})),X}},{key:"drawPattern",value:function(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"#a8a8a8",s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;return this.w.globals.dom.Paper.pattern(e,i,(function(r){"horizontalLines"===t?r.line(0,0,i,0).stroke({color:a,width:s+1}):"verticalLines"===t?r.line(0,0,0,e).stroke({color:a,width:s+1}):"slantedLines"===t?r.line(0,0,e,i).stroke({color:a,width:s}):"squares"===t?r.rect(e,i).fill("none").stroke({color:a,width:s}):"circles"===t&&r.circle(e).fill("none").stroke({color:a,width:s})}))}},{key:"drawGradient",value:function(t,e,i,a,s){var r,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,n=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,l=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null,h=arguments.length>8&&void 0!==arguments[8]?arguments[8]:0,c=this.w;e.length<9&&0===e.indexOf("#")&&(e=y.hexToRgba(e,a)),i.length<9&&0===i.indexOf("#")&&(i=y.hexToRgba(i,s));var d=0,g=1,u=1,p=null;null!==n&&(d=void 0!==n[0]?n[0]/100:0,g=void 0!==n[1]?n[1]/100:1,u=void 0!==n[2]?n[2]/100:1,p=void 0!==n[3]?n[3]/100:null);var f=!("donut"!==c.config.chart.type&&"pie"!==c.config.chart.type&&"polarArea"!==c.config.chart.type&&"bubble"!==c.config.chart.type);if(r=null===l||0===l.length?c.globals.dom.Paper.gradient(f?"radial":"linear",(function(t){t.at(d,e,a),t.at(g,i,s),t.at(u,i,s),null!==p&&t.at(p,e,a)})):c.globals.dom.Paper.gradient(f?"radial":"linear",(function(t){(Array.isArray(l[h])?l[h]:l).forEach((function(e){t.at(e.offset/100,e.color,e.opacity)}))})),f){var x=c.globals.gridWidth/2,b=c.globals.gridHeight/2;"bubble"!==c.config.chart.type?r.attr({gradientUnits:"userSpaceOnUse",cx:x,cy:b,r:o}):r.attr({cx:.5,cy:.5,r:.8,fx:.2,fy:.2})}else"vertical"===t?r.from(0,0).to(0,1):"diagonal"===t?r.from(0,0).to(1,1):"horizontal"===t?r.from(0,1).to(1,1):"diagonal2"===t&&r.from(1,0).to(0,1);return r}},{key:"getTextBasedOnMaxWidth",value:function(t){var e=t.text,i=t.maxWidth,a=t.fontSize,s=t.fontFamily,r=this.getTextRects(e,a,s),o=r.width/e.length,n=Math.floor(i/o);return i-1){var n=i.globals.selectedDataPoints[s].indexOf(r);i.globals.selectedDataPoints[s].splice(n,1)}}else{if(!i.config.states.active.allowMultipleDataPointsSelection&&i.globals.selectedDataPoints.length>0){i.globals.selectedDataPoints=[];var l=i.globals.dom.Paper.select(".apexcharts-series path").members,h=i.globals.dom.Paper.select(".apexcharts-series circle, .apexcharts-series rect").members,c=function(t){Array.prototype.forEach.call(t,(function(t){t.node.setAttribute("selected","false"),a.getDefaultFilter(t,s)}))};c(l),c(h)}t.node.setAttribute("selected","true"),o="true",void 0===i.globals.selectedDataPoints[s]&&(i.globals.selectedDataPoints[s]=[]),i.globals.selectedDataPoints[s].push(r)}if("true"===o){var d=i.config.states.active.filter;if("none"!==d)a.applyFilter(t,s,d.type,d.value);else if("none"!==i.config.states.hover.filter&&!i.globals.isTouchDevice){var g=i.config.states.hover.filter;a.applyFilter(t,s,g.type,g.value)}}else"none"!==i.config.states.active.filter.type&&("none"===i.config.states.hover.filter.type||i.globals.isTouchDevice?a.getDefaultFilter(t,s):(g=i.config.states.hover.filter,a.applyFilter(t,s,g.type,g.value)));"function"==typeof i.config.chart.events.dataPointSelection&&i.config.chart.events.dataPointSelection(e,this.ctx,{selectedDataPoints:i.globals.selectedDataPoints,seriesIndex:s,dataPointIndex:r,w:i}),e&&this.ctx.events.fireEvent("dataPointSelection",[e,this.ctx,{selectedDataPoints:i.globals.selectedDataPoints,seriesIndex:s,dataPointIndex:r,w:i}])}},{key:"rotateAroundCenter",value:function(t){var e={};return t&&"function"==typeof t.getBBox&&(e=t.getBBox()),{x:e.x+e.width/2,y:e.y+e.height/2}}},{key:"getTextRects",value:function(t,e,i,a){var s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],r=this.w,o=this.drawText({x:-200,y:-200,text:t,textAnchor:"start",fontSize:e,fontFamily:i,foreColor:"#fff",opacity:0});a&&o.attr("transform",a),r.globals.dom.Paper.add(o);var n=o.bbox();return s||(n=o.node.getBoundingClientRect()),o.remove(),{width:n.width,height:n.height}}},{key:"placeTextWithEllipsis",value:function(t,e,i){if("function"==typeof t.getComputedTextLength&&(t.textContent=e,e.length>0&&t.getComputedTextLength()>=i/1.1)){for(var a=e.length-3;a>0;a-=3)if(t.getSubStringLength(0,a)<=i/1.1)return void(t.textContent=e.substring(0,a)+"...");t.textContent="."}}}],[{key:"setAttrs",value:function(t,e){for(var i in e)e.hasOwnProperty(i)&&t.setAttribute(i,e[i])}}]),t}(),S=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"getStackedSeriesTotals",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=this.w,i=[];if(0===e.globals.series.length)return i;for(var a=0;a0&&void 0!==arguments[0]?arguments[0]:null;return null===t?this.w.config.series.reduce((function(t,e){return t+e}),0):this.w.globals.series[t].reduce((function(t,e){return t+e}),0)}},{key:"isSeriesNull",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return 0===(null===t?this.w.config.series.filter((function(t){return null!==t})):this.w.config.series[t].data.filter((function(t){return null!==t}))).length}},{key:"seriesHaveSameValues",value:function(t){return this.w.globals.series[t].every((function(t,e,i){return t===i[0]}))}},{key:"getCategoryLabels",value:function(t){var e=this.w,i=t.slice();return e.config.xaxis.convertedCatToNumeric&&(i=t.map((function(t,i){return e.config.xaxis.labels.formatter(t-e.globals.minX+1)}))),i}},{key:"getLargestSeries",value:function(){var t=this.w;t.globals.maxValsInArrayIndex=t.globals.series.map((function(t){return t.length})).indexOf(Math.max.apply(Math,t.globals.series.map((function(t){return t.length}))))}},{key:"getLargestMarkerSize",value:function(){var t=this.w,e=0;return t.globals.markers.size.forEach((function(t){e=Math.max(e,t)})),t.config.markers.discrete&&t.config.markers.discrete.length&&t.config.markers.discrete.forEach((function(t){e=Math.max(e,t.size)})),e>0&&(e+=t.config.markers.hover.sizeOffset+1),t.globals.markers.largestSize=e,e}},{key:"getSeriesTotals",value:function(){var t=this.w;t.globals.seriesTotals=t.globals.series.map((function(t,e){var i=0;if(Array.isArray(t))for(var a=0;at&&i.globals.seriesX[s][o]0&&(e=!0),{comboBarCount:i,comboCharts:e}}},{key:"extendArrayProps",value:function(t,e,i){return e.yaxis&&(e=t.extendYAxis(e,i)),e.annotations&&(e.annotations.yaxis&&(e=t.extendYAxisAnnotations(e)),e.annotations.xaxis&&(e=t.extendXAxisAnnotations(e)),e.annotations.points&&(e=t.extendPointAnnotations(e))),e}}]),t}(),C=function(){function t(e){n(this,t),this.w=e.w,this.annoCtx=e}return h(t,[{key:"setOrientations",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=this.w;if("vertical"===t.label.orientation){var a=null!==e?e:0,s=i.globals.dom.baseEl.querySelector(".apexcharts-xaxis-annotations .apexcharts-xaxis-annotation-label[rel='".concat(a,"']"));if(null!==s){var r=s.getBoundingClientRect();s.setAttribute("x",parseFloat(s.getAttribute("x"))-r.height+4),"top"===t.label.position?s.setAttribute("y",parseFloat(s.getAttribute("y"))+r.width):s.setAttribute("y",parseFloat(s.getAttribute("y"))-r.width);var o=this.annoCtx.graphics.rotateAroundCenter(s),n=o.x,l=o.y;s.setAttribute("transform","rotate(-90 ".concat(n," ").concat(l,")"))}}}},{key:"addBackgroundToAnno",value:function(t,e){var i=this.w;if(!t||void 0===e.label.text||void 0!==e.label.text&&!String(e.label.text).trim())return null;var a=i.globals.dom.baseEl.querySelector(".apexcharts-grid").getBoundingClientRect(),s=t.getBoundingClientRect(),r=e.label.style.padding.left,o=e.label.style.padding.right,n=e.label.style.padding.top,l=e.label.style.padding.bottom;"vertical"===e.label.orientation&&(n=e.label.style.padding.left,l=e.label.style.padding.right,r=e.label.style.padding.top,o=e.label.style.padding.bottom);var h=s.left-a.left-r,c=s.top-a.top-n,d=this.annoCtx.graphics.drawRect(h-i.globals.barPadForNumericAxis,c,s.width+r+o,s.height+n+l,e.label.borderRadius,e.label.style.background,1,e.label.borderWidth,e.label.borderColor,0);return e.id&&d.node.classList.add(e.id),d}},{key:"annotationsBackground",value:function(){var t=this,e=this.w,i=function(i,a,s){var r=e.globals.dom.baseEl.querySelector(".apexcharts-".concat(s,"-annotations .apexcharts-").concat(s,"-annotation-label[rel='").concat(a,"']"));if(r){var o=r.parentNode,n=t.addBackgroundToAnno(r,i);n&&(o.insertBefore(n.node,r),i.label.mouseEnter&&n.node.addEventListener("mouseenter",i.label.mouseEnter.bind(t,i)),i.label.mouseLeave&&n.node.addEventListener("mouseleave",i.label.mouseLeave.bind(t,i)),i.label.click&&n.node.addEventListener("click",i.label.click.bind(t,i)))}};e.config.annotations.xaxis.map((function(t,e){i(t,e,"xaxis")})),e.config.annotations.yaxis.map((function(t,e){i(t,e,"yaxis")})),e.config.annotations.points.map((function(t,e){i(t,e,"point")}))}},{key:"getY1Y2",value:function(t,e){var i,a="y1"===t?e.y:e.y2,s=this.w;if(this.annoCtx.invertAxis){var r=s.globals.labels.indexOf(a);s.config.xaxis.convertedCatToNumeric&&(r=s.globals.categoryLabels.indexOf(a));var o=s.globals.dom.baseEl.querySelector(".apexcharts-yaxis-texts-g text:nth-child("+(r+1)+")");o&&(i=parseFloat(o.getAttribute("y")))}else{var n;n=s.config.yaxis[e.yAxisIndex].logarithmic?(a=new S(this.annoCtx.ctx).getLogVal(a,e.yAxisIndex))/s.globals.yLogRatio[e.yAxisIndex]:(a-s.globals.minYArr[e.yAxisIndex])/(s.globals.yRange[e.yAxisIndex]/s.globals.gridHeight),i=s.globals.gridHeight-n,!e.marker||void 0!==e.y&&null!==e.y||(i=0),s.config.yaxis[e.yAxisIndex]&&s.config.yaxis[e.yAxisIndex].reversed&&(i=n)}return"string"==typeof a&&a.indexOf("px")>-1&&(i=parseFloat(a)),i}},{key:"getX1X2",value:function(t,e){var i=this.w,a=this.annoCtx.invertAxis?i.globals.minY:i.globals.minX,s=this.annoCtx.invertAxis?i.globals.maxY:i.globals.maxX,r=this.annoCtx.invertAxis?i.globals.yRange[0]:i.globals.xRange,o=(e.x-a)/(r/i.globals.gridWidth);this.annoCtx.inversedReversedAxis&&(o=(s-e.x)/(r/i.globals.gridWidth)),"category"!==i.config.xaxis.type&&!i.config.xaxis.convertedCatToNumeric||this.annoCtx.invertAxis||i.globals.dataFormatXNumeric||(o=this.getStringX(e.x));var n=(e.x2-a)/(r/i.globals.gridWidth);return this.annoCtx.inversedReversedAxis&&(n=(s-e.x2)/(r/i.globals.gridWidth)),"category"!==i.config.xaxis.type&&!i.config.xaxis.convertedCatToNumeric||this.annoCtx.invertAxis||i.globals.dataFormatXNumeric||(n=this.getStringX(e.x2)),void 0!==e.x&&null!==e.x||!e.marker||(o=i.globals.gridWidth),"x1"===t&&"string"==typeof e.x&&e.x.indexOf("px")>-1&&(o=parseFloat(e.x)),"x2"===t&&"string"==typeof e.x2&&e.x2.indexOf("px")>-1&&(n=parseFloat(e.x2)),"x1"===t?o:n}},{key:"getStringX",value:function(t){var e=this.w,i=t;e.config.xaxis.convertedCatToNumeric&&e.globals.categoryLabels.length&&(t=e.globals.categoryLabels.indexOf(t)+1);var a=e.globals.labels.indexOf(t),s=e.globals.dom.baseEl.querySelector(".apexcharts-xaxis-texts-g text:nth-child("+(a+1)+")");return s&&(i=parseFloat(s.getAttribute("x"))),i}}]),t}(),L=function(){function t(e){n(this,t),this.w=e.w,this.annoCtx=e,this.invertAxis=this.annoCtx.invertAxis,this.helpers=new C(this.annoCtx)}return h(t,[{key:"addXaxisAnnotation",value:function(t,e,i){var a,s=this.w,r=this.helpers.getX1X2("x1",t),o=t.label.text,n=t.strokeDashArray;if(y.isNumber(r)){if(null===t.x2||void 0===t.x2){var l=this.annoCtx.graphics.drawLine(r+t.offsetX,0+t.offsetY,r+t.offsetX,s.globals.gridHeight+t.offsetY,t.borderColor,n,t.borderWidth);e.appendChild(l.node),t.id&&l.node.classList.add(t.id)}else{if((a=this.helpers.getX1X2("x2",t))o){var h=o;o=a,a=h}var c=this.annoCtx.graphics.drawRect(0+t.offsetX,a+t.offsetY,this._getYAxisAnnotationWidth(t),o-a,0,t.fillColor,t.opacity,1,t.borderColor,r);c.node.classList.add("apexcharts-annotation-rect"),c.attr("clip-path","url(#gridRectMask".concat(s.globals.cuid,")")),e.appendChild(c.node),t.id&&c.node.classList.add(t.id)}var d="right"===t.label.position?s.globals.gridWidth:"center"===t.label.position?s.globals.gridWidth/2:0,g=this.annoCtx.graphics.drawText({x:d+t.label.offsetX,y:(null!=a?a:o)+t.label.offsetY-3,text:n,textAnchor:t.label.textAnchor,fontSize:t.label.style.fontSize,fontFamily:t.label.style.fontFamily,fontWeight:t.label.style.fontWeight,foreColor:t.label.style.color,cssClass:"apexcharts-yaxis-annotation-label ".concat(t.label.style.cssClass," ").concat(t.id?t.id:"")});g.attr({rel:i}),e.appendChild(g.node)}},{key:"_getYAxisAnnotationWidth",value:function(t){var e=this.w;return e.globals.gridWidth,(t.width.indexOf("%")>-1?e.globals.gridWidth*parseInt(t.width,10)/100:parseInt(t.width,10))+t.offsetX}},{key:"drawYAxisAnnotations",value:function(){var t=this,e=this.w,i=this.annoCtx.graphics.group({class:"apexcharts-yaxis-annotations"});return e.config.annotations.yaxis.map((function(e,a){t.addYaxisAnnotation(e,i.node,a)})),i}}]),t}(),T=function(){function t(e){n(this,t),this.w=e.w,this.annoCtx=e,this.helpers=new C(this.annoCtx)}return h(t,[{key:"addPointAnnotation",value:function(t,e,i){this.w;var a=this.helpers.getX1X2("x1",t),s=this.helpers.getY1Y2("y1",t);if(y.isNumber(a)){var r={pSize:t.marker.size,pointStrokeWidth:t.marker.strokeWidth,pointFillColor:t.marker.fillColor,pointStrokeColor:t.marker.strokeColor,shape:t.marker.shape,pRadius:t.marker.radius,class:"apexcharts-point-annotation-marker ".concat(t.marker.cssClass," ").concat(t.id?t.id:"")},o=this.annoCtx.graphics.drawMarker(a+t.marker.offsetX,s+t.marker.offsetY,r);e.appendChild(o.node);var n=t.label.text?t.label.text:"",l=this.annoCtx.graphics.drawText({x:a+t.label.offsetX,y:s+t.label.offsetY-t.marker.size-parseFloat(t.label.style.fontSize)/1.6,text:n,textAnchor:t.label.textAnchor,fontSize:t.label.style.fontSize,fontFamily:t.label.style.fontFamily,fontWeight:t.label.style.fontWeight,foreColor:t.label.style.color,cssClass:"apexcharts-point-annotation-label ".concat(t.label.style.cssClass," ").concat(t.id?t.id:"")});if(l.attr({rel:i}),e.appendChild(l.node),t.customSVG.SVG){var h=this.annoCtx.graphics.group({class:"apexcharts-point-annotations-custom-svg "+t.customSVG.cssClass});h.attr({transform:"translate(".concat(a+t.customSVG.offsetX,", ").concat(s+t.customSVG.offsetY,")")}),h.node.innerHTML=t.customSVG.SVG,e.appendChild(h.node)}if(t.image.path){var c=t.image.width?t.image.width:20,d=t.image.height?t.image.height:20;o=this.annoCtx.addImage({x:a+t.image.offsetX-c/2,y:s+t.image.offsetY-d/2,width:c,height:d,path:t.image.path,appendTo:".apexcharts-point-annotations"})}t.mouseEnter&&o.node.addEventListener("mouseenter",t.mouseEnter.bind(this,t)),t.mouseLeave&&o.node.addEventListener("mouseleave",t.mouseLeave.bind(this,t)),t.click&&o.node.addEventListener("click",t.click.bind(this,t))}}},{key:"drawPointAnnotations",value:function(){var t=this,e=this.w,i=this.annoCtx.graphics.group({class:"apexcharts-point-annotations"});return e.config.annotations.points.map((function(e,a){t.addPointAnnotation(e,i.node,a)})),i}}]),t}(),I={name:"en",options:{months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],toolbar:{exportToSVG:"Download SVG",exportToPNG:"Download PNG",exportToCSV:"Download CSV",menu:"Menu",selection:"Selection",selectionZoom:"Selection Zoom",zoomIn:"Zoom In",zoomOut:"Zoom Out",pan:"Panning",reset:"Reset Zoom"}}},M=function(){function t(){n(this,t),this.yAxis={show:!0,showAlways:!1,showForNullSeries:!0,seriesName:void 0,opposite:!1,reversed:!1,logarithmic:!1,logBase:10,tickAmount:void 0,forceNiceScale:!1,max:void 0,min:void 0,floating:!1,decimalsInFloat:void 0,labels:{show:!0,minWidth:0,maxWidth:160,offsetX:0,offsetY:0,align:void 0,rotate:0,padding:20,style:{colors:[],fontSize:"11px",fontWeight:400,fontFamily:void 0,cssClass:""},formatter:void 0},axisBorder:{show:!1,color:"#e0e0e0",width:1,offsetX:0,offsetY:0},axisTicks:{show:!1,color:"#e0e0e0",width:6,offsetX:0,offsetY:0},title:{text:void 0,rotate:-90,offsetY:0,offsetX:0,style:{color:void 0,fontSize:"11px",fontWeight:900,fontFamily:void 0,cssClass:""}},tooltip:{enabled:!1,offsetX:0},crosshairs:{show:!0,position:"front",stroke:{color:"#b6b6b6",width:1,dashArray:0}}},this.pointAnnotation={id:void 0,x:0,y:null,yAxisIndex:0,seriesIndex:0,mouseEnter:void 0,mouseLeave:void 0,click:void 0,marker:{size:4,fillColor:"#fff",strokeWidth:2,strokeColor:"#333",shape:"circle",offsetX:0,offsetY:0,radius:2,cssClass:""},label:{borderColor:"#c2c2c2",borderWidth:1,borderRadius:2,text:void 0,textAnchor:"middle",offsetX:0,offsetY:0,mouseEnter:void 0,mouseLeave:void 0,click:void 0,style:{background:"#fff",color:void 0,fontSize:"11px",fontFamily:void 0,fontWeight:400,cssClass:"",padding:{left:5,right:5,top:2,bottom:2}}},customSVG:{SVG:void 0,cssClass:void 0,offsetX:0,offsetY:0},image:{path:void 0,width:20,height:20,offsetX:0,offsetY:0}},this.yAxisAnnotation={id:void 0,y:0,y2:null,strokeDashArray:1,fillColor:"#c2c2c2",borderColor:"#c2c2c2",borderWidth:1,opacity:.3,offsetX:0,offsetY:0,width:"100%",yAxisIndex:0,label:{borderColor:"#c2c2c2",borderWidth:1,borderRadius:2,text:void 0,textAnchor:"end",position:"right",offsetX:0,offsetY:-3,mouseEnter:void 0,mouseLeave:void 0,click:void 0,style:{background:"#fff",color:void 0,fontSize:"11px",fontFamily:void 0,fontWeight:400,cssClass:"",padding:{left:5,right:5,top:2,bottom:2}}}},this.xAxisAnnotation={id:void 0,x:0,x2:null,strokeDashArray:1,fillColor:"#c2c2c2",borderColor:"#c2c2c2",borderWidth:1,opacity:.3,offsetX:0,offsetY:0,label:{borderColor:"#c2c2c2",borderWidth:1,borderRadius:2,text:void 0,textAnchor:"middle",orientation:"vertical",position:"top",offsetX:0,offsetY:0,mouseEnter:void 0,mouseLeave:void 0,click:void 0,style:{background:"#fff",color:void 0,fontSize:"11px",fontFamily:void 0,fontWeight:400,cssClass:"",padding:{left:5,right:5,top:2,bottom:2}}}},this.text={x:0,y:0,text:"",textAnchor:"start",foreColor:void 0,fontSize:"13px",fontFamily:void 0,fontWeight:400,appendTo:".apexcharts-annotations",backgroundColor:"transparent",borderColor:"#c2c2c2",borderRadius:0,borderWidth:0,paddingLeft:4,paddingRight:4,paddingTop:2,paddingBottom:2}}return h(t,[{key:"init",value:function(){return{annotations:{yaxis:[this.yAxisAnnotation],xaxis:[this.xAxisAnnotation],points:[this.pointAnnotation],texts:[],images:[],shapes:[]},chart:{animations:{enabled:!0,easing:"easeinout",speed:800,animateGradually:{delay:150,enabled:!0},dynamicAnimation:{enabled:!0,speed:350}},background:"transparent",locales:[I],defaultLocale:"en",dropShadow:{enabled:!1,enabledOnSeries:void 0,top:2,left:2,blur:4,color:"#000",opacity:.35},events:{animationEnd:void 0,beforeMount:void 0,mounted:void 0,updated:void 0,click:void 0,mouseMove:void 0,mouseLeave:void 0,xAxisLabelClick:void 0,legendClick:void 0,markerClick:void 0,selection:void 0,dataPointSelection:void 0,dataPointMouseEnter:void 0,dataPointMouseLeave:void 0,beforeZoom:void 0,beforeResetZoom:void 0,zoomed:void 0,scrolled:void 0,brushScrolled:void 0},foreColor:"#373d3f",fontFamily:"Helvetica, Arial, sans-serif",height:"auto",parentHeightOffset:15,redrawOnParentResize:!0,redrawOnWindowResize:!0,id:void 0,group:void 0,offsetX:0,offsetY:0,selection:{enabled:!1,type:"x",fill:{color:"#24292e",opacity:.1},stroke:{width:1,color:"#24292e",opacity:.4,dashArray:3},xaxis:{min:void 0,max:void 0},yaxis:{min:void 0,max:void 0}},sparkline:{enabled:!1},brush:{enabled:!1,autoScaleYaxis:!0,target:void 0,targets:void 0},stacked:!1,stackType:"normal",toolbar:{show:!0,offsetX:0,offsetY:0,tools:{download:!0,selection:!0,zoom:!0,zoomin:!0,zoomout:!0,pan:!0,reset:!0,customIcons:[]},export:{csv:{filename:void 0,columnDelimiter:",",headerCategory:"category",headerValue:"value",dateFormatter:function(t){return new Date(t).toDateString()}},png:{filename:void 0},svg:{filename:void 0}},autoSelected:"zoom"},type:"line",width:"100%",zoom:{enabled:!0,type:"x",autoScaleYaxis:!1,zoomedArea:{fill:{color:"#90CAF9",opacity:.4},stroke:{color:"#0D47A1",opacity:.4,width:1}}}},plotOptions:{area:{fillTo:"origin"},bar:{horizontal:!1,columnWidth:"70%",barHeight:"70%",distributed:!1,borderRadius:0,borderRadiusApplication:"around",borderRadiusWhenStacked:"last",rangeBarOverlap:!0,rangeBarGroupRows:!1,hideZeroBarsWhenGrouped:!1,isDumbbell:!1,dumbbellColors:void 0,isFunnel:!1,isFunnel3d:!0,colors:{ranges:[],backgroundBarColors:[],backgroundBarOpacity:1,backgroundBarRadius:0},dataLabels:{position:"top",maxItems:100,hideOverflowingLabels:!0,orientation:"horizontal",total:{enabled:!1,formatter:void 0,offsetX:0,offsetY:0,style:{color:"#373d3f",fontSize:"12px",fontFamily:void 0,fontWeight:600}}}},bubble:{zScaling:!0,minBubbleRadius:void 0,maxBubbleRadius:void 0},candlestick:{colors:{upward:"#00B746",downward:"#EF403C"},wick:{useFillColor:!0}},boxPlot:{colors:{upper:"#00E396",lower:"#008FFB"}},heatmap:{radius:2,enableShades:!0,shadeIntensity:.5,reverseNegativeShade:!1,distributed:!1,useFillColorAsStroke:!1,colorScale:{inverse:!1,ranges:[],min:void 0,max:void 0}},treemap:{enableShades:!0,shadeIntensity:.5,distributed:!1,reverseNegativeShade:!1,useFillColorAsStroke:!1,dataLabels:{format:"scale"},colorScale:{inverse:!1,ranges:[],min:void 0,max:void 0}},radialBar:{inverseOrder:!1,startAngle:0,endAngle:360,offsetX:0,offsetY:0,hollow:{margin:5,size:"50%",background:"transparent",image:void 0,imageWidth:150,imageHeight:150,imageOffsetX:0,imageOffsetY:0,imageClipped:!0,position:"front",dropShadow:{enabled:!1,top:0,left:0,blur:3,color:"#000",opacity:.5}},track:{show:!0,startAngle:void 0,endAngle:void 0,background:"#f2f2f2",strokeWidth:"97%",opacity:1,margin:5,dropShadow:{enabled:!1,top:0,left:0,blur:3,color:"#000",opacity:.5}},dataLabels:{show:!0,name:{show:!0,fontSize:"16px",fontFamily:void 0,fontWeight:600,color:void 0,offsetY:0,formatter:function(t){return t}},value:{show:!0,fontSize:"14px",fontFamily:void 0,fontWeight:400,color:void 0,offsetY:16,formatter:function(t){return t+"%"}},total:{show:!1,label:"Total",fontSize:"16px",fontWeight:600,fontFamily:void 0,color:void 0,formatter:function(t){return t.globals.seriesTotals.reduce((function(t,e){return t+e}),0)/t.globals.series.length+"%"}}}},pie:{customScale:1,offsetX:0,offsetY:0,startAngle:0,endAngle:360,expandOnClick:!0,dataLabels:{offset:0,minAngleToShowLabel:10},donut:{size:"65%",background:"transparent",labels:{show:!1,name:{show:!0,fontSize:"16px",fontFamily:void 0,fontWeight:600,color:void 0,offsetY:-10,formatter:function(t){return t}},value:{show:!0,fontSize:"20px",fontFamily:void 0,fontWeight:400,color:void 0,offsetY:10,formatter:function(t){return t}},total:{show:!1,showAlways:!1,label:"Total",fontSize:"16px",fontWeight:400,fontFamily:void 0,color:void 0,formatter:function(t){return t.globals.seriesTotals.reduce((function(t,e){return t+e}),0)}}}}},polarArea:{rings:{strokeWidth:1,strokeColor:"#e8e8e8"},spokes:{strokeWidth:1,connectorColors:"#e8e8e8"}},radar:{size:void 0,offsetX:0,offsetY:0,polygons:{strokeWidth:1,strokeColors:"#e8e8e8",connectorColors:"#e8e8e8",fill:{colors:void 0}}}},colors:void 0,dataLabels:{enabled:!0,enabledOnSeries:void 0,formatter:function(t){return null!==t?t:""},textAnchor:"middle",distributed:!1,offsetX:0,offsetY:0,style:{fontSize:"12px",fontFamily:void 0,fontWeight:600,colors:void 0},background:{enabled:!0,foreColor:"#fff",borderRadius:2,padding:4,opacity:.9,borderWidth:1,borderColor:"#fff",dropShadow:{enabled:!1,top:1,left:1,blur:1,color:"#000",opacity:.45}},dropShadow:{enabled:!1,top:1,left:1,blur:1,color:"#000",opacity:.45}},fill:{type:"solid",colors:void 0,opacity:.85,gradient:{shade:"dark",type:"horizontal",shadeIntensity:.5,gradientToColors:void 0,inverseColors:!0,opacityFrom:1,opacityTo:1,stops:[0,50,100],colorStops:[]},image:{src:[],width:void 0,height:void 0},pattern:{style:"squares",width:6,height:6,strokeWidth:2}},forecastDataPoints:{count:0,fillOpacity:.5,strokeWidth:void 0,dashArray:4},grid:{show:!0,borderColor:"#e0e0e0",strokeDashArray:0,position:"back",xaxis:{lines:{show:!1}},yaxis:{lines:{show:!0}},row:{colors:void 0,opacity:.5},column:{colors:void 0,opacity:.5},padding:{top:0,right:10,bottom:0,left:12}},labels:[],legend:{show:!0,showForSingleSeries:!1,showForNullSeries:!0,showForZeroSeries:!0,floating:!1,position:"bottom",horizontalAlign:"center",inverseOrder:!1,fontSize:"12px",fontFamily:void 0,fontWeight:400,width:void 0,height:void 0,formatter:void 0,tooltipHoverFormatter:void 0,offsetX:-20,offsetY:4,customLegendItems:[],labels:{colors:void 0,useSeriesColors:!1},markers:{width:12,height:12,strokeWidth:0,fillColors:void 0,strokeColor:"#fff",radius:12,customHTML:void 0,offsetX:0,offsetY:0,onClick:void 0},itemMargin:{horizontal:5,vertical:2},onItemClick:{toggleDataSeries:!0},onItemHover:{highlightDataSeries:!0}},markers:{discrete:[],size:0,colors:void 0,strokeColors:"#fff",strokeWidth:2,strokeOpacity:.9,strokeDashArray:0,fillOpacity:1,shape:"circle",width:8,height:8,radius:2,offsetX:0,offsetY:0,onClick:void 0,onDblClick:void 0,showNullDataPoints:!0,hover:{size:void 0,sizeOffset:3}},noData:{text:void 0,align:"center",verticalAlign:"middle",offsetX:0,offsetY:0,style:{color:void 0,fontSize:"14px",fontFamily:void 0}},responsive:[],series:void 0,states:{normal:{filter:{type:"none",value:0}},hover:{filter:{type:"lighten",value:.1}},active:{allowMultipleDataPointsSelection:!1,filter:{type:"darken",value:.5}}},title:{text:void 0,align:"left",margin:5,offsetX:0,offsetY:0,floating:!1,style:{fontSize:"14px",fontWeight:900,fontFamily:void 0,color:void 0}},subtitle:{text:void 0,align:"left",margin:5,offsetX:0,offsetY:30,floating:!1,style:{fontSize:"12px",fontWeight:400,fontFamily:void 0,color:void 0}},stroke:{show:!0,curve:"smooth",lineCap:"butt",width:2,colors:void 0,dashArray:0,fill:{type:"solid",colors:void 0,opacity:.85,gradient:{shade:"dark",type:"horizontal",shadeIntensity:.5,gradientToColors:void 0,inverseColors:!0,opacityFrom:1,opacityTo:1,stops:[0,50,100],colorStops:[]}}},tooltip:{enabled:!0,enabledOnSeries:void 0,shared:!0,followCursor:!1,intersect:!1,inverseOrder:!1,custom:void 0,fillSeriesColor:!1,theme:"light",cssClass:"",style:{fontSize:"12px",fontFamily:void 0},onDatasetHover:{highlightDataSeries:!1},x:{show:!0,format:"dd MMM",formatter:void 0},y:{formatter:void 0,title:{formatter:function(t){return t?t+": ":""}}},z:{formatter:void 0,title:"Size: "},marker:{show:!0,fillColors:void 0},items:{display:"flex"},fixed:{enabled:!1,position:"topRight",offsetX:0,offsetY:0}},xaxis:{type:"category",categories:[],convertedCatToNumeric:!1,offsetX:0,offsetY:0,overwriteCategories:void 0,labels:{show:!0,rotate:-45,rotateAlways:!1,hideOverlappingLabels:!0,trim:!1,minHeight:void 0,maxHeight:120,showDuplicates:!0,style:{colors:[],fontSize:"12px",fontWeight:400,fontFamily:void 0,cssClass:""},offsetX:0,offsetY:0,format:void 0,formatter:void 0,datetimeUTC:!0,datetimeFormatter:{year:"yyyy",month:"MMM 'yy",day:"dd MMM",hour:"HH:mm",minute:"HH:mm:ss",second:"HH:mm:ss"}},group:{groups:[],style:{colors:[],fontSize:"12px",fontWeight:400,fontFamily:void 0,cssClass:""}},axisBorder:{show:!0,color:"#e0e0e0",width:"100%",height:1,offsetX:0,offsetY:0},axisTicks:{show:!0,color:"#e0e0e0",height:6,offsetX:0,offsetY:0},tickAmount:void 0,tickPlacement:"on",min:void 0,max:void 0,range:void 0,floating:!1,decimalsInFloat:void 0,position:"bottom",title:{text:void 0,offsetX:0,offsetY:0,style:{color:void 0,fontSize:"12px",fontWeight:900,fontFamily:void 0,cssClass:""}},crosshairs:{show:!0,width:1,position:"back",opacity:.9,stroke:{color:"#b6b6b6",width:1,dashArray:3},fill:{type:"solid",color:"#B1B9C4",gradient:{colorFrom:"#D8E3F0",colorTo:"#BED1E6",stops:[0,100],opacityFrom:.4,opacityTo:.5}},dropShadow:{enabled:!1,left:0,top:0,blur:1,opacity:.4}},tooltip:{enabled:!0,offsetY:0,formatter:void 0,style:{fontSize:"12px",fontFamily:void 0}}},yaxis:this.yAxis,theme:{mode:"light",palette:"palette1",monochrome:{enabled:!1,color:"#008FFB",shadeTo:"light",shadeIntensity:.65}}}}}]),t}(),X=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.graphics=new A(this.ctx),this.w.globals.isBarHorizontal&&(this.invertAxis=!0),this.helpers=new C(this),this.xAxisAnnotations=new L(this),this.yAxisAnnotations=new P(this),this.pointsAnnotations=new T(this),this.w.globals.isBarHorizontal&&this.w.config.yaxis[0].reversed&&(this.inversedReversedAxis=!0),this.xDivision=this.w.globals.gridWidth/this.w.globals.dataPoints}return h(t,[{key:"drawAxesAnnotations",value:function(){var t=this.w;if(t.globals.axisCharts){for(var e=this.yAxisAnnotations.drawYAxisAnnotations(),i=this.xAxisAnnotations.drawXAxisAnnotations(),a=this.pointsAnnotations.drawPointAnnotations(),s=t.config.chart.animations.enabled,r=[e,i,a],o=[i.node,e.node,a.node],n=0;n<3;n++)t.globals.dom.elGraphical.add(r[n]),!s||t.globals.resized||t.globals.dataChanged||"scatter"!==t.config.chart.type&&"bubble"!==t.config.chart.type&&t.globals.dataPoints>1&&o[n].classList.add("apexcharts-element-hidden"),t.globals.delayedElements.push({el:o[n],index:0});this.helpers.annotationsBackground()}}},{key:"drawImageAnnos",value:function(){var t=this;this.w.config.annotations.images.map((function(e,i){t.addImage(e,i)}))}},{key:"drawTextAnnos",value:function(){var t=this;this.w.config.annotations.texts.map((function(e,i){t.addText(e,i)}))}},{key:"addXaxisAnnotation",value:function(t,e,i){this.xAxisAnnotations.addXaxisAnnotation(t,e,i)}},{key:"addYaxisAnnotation",value:function(t,e,i){this.yAxisAnnotations.addYaxisAnnotation(t,e,i)}},{key:"addPointAnnotation",value:function(t,e,i){this.pointsAnnotations.addPointAnnotation(t,e,i)}},{key:"addText",value:function(t,e){var i=t.x,a=t.y,s=t.text,r=t.textAnchor,o=t.foreColor,n=t.fontSize,l=t.fontFamily,h=t.fontWeight,c=t.cssClass,d=t.backgroundColor,g=t.borderWidth,u=t.strokeDashArray,p=t.borderRadius,f=t.borderColor,x=t.appendTo,b=void 0===x?".apexcharts-annotations":x,v=t.paddingLeft,m=void 0===v?4:v,y=t.paddingRight,w=void 0===y?4:y,k=t.paddingBottom,A=void 0===k?2:k,S=t.paddingTop,C=void 0===S?2:S,L=this.w,P=this.graphics.drawText({x:i,y:a,text:s,textAnchor:r||"start",fontSize:n||"12px",fontWeight:h||"regular",fontFamily:l||L.config.chart.fontFamily,foreColor:o||L.config.chart.foreColor,cssClass:c}),T=L.globals.dom.baseEl.querySelector(b);T&&T.appendChild(P.node);var I=P.bbox();if(s){var M=this.graphics.drawRect(I.x-m,I.y-C,I.width+m+w,I.height+A+C,p,d||"transparent",1,g,f,u);T.insertBefore(M.node,P.node)}}},{key:"addImage",value:function(t,e){var i=this.w,a=t.path,s=t.x,r=void 0===s?0:s,o=t.y,n=void 0===o?0:o,l=t.width,h=void 0===l?20:l,c=t.height,d=void 0===c?20:c,g=t.appendTo,u=void 0===g?".apexcharts-annotations":g,p=i.globals.dom.Paper.image(a);p.size(h,d).move(r,n);var f=i.globals.dom.baseEl.querySelector(u);return f&&f.appendChild(p.node),p}},{key:"addXaxisAnnotationExternal",value:function(t,e,i){return this.addAnnotationExternal({params:t,pushToMemory:e,context:i,type:"xaxis",contextMethod:i.addXaxisAnnotation}),i}},{key:"addYaxisAnnotationExternal",value:function(t,e,i){return this.addAnnotationExternal({params:t,pushToMemory:e,context:i,type:"yaxis",contextMethod:i.addYaxisAnnotation}),i}},{key:"addPointAnnotationExternal",value:function(t,e,i){return void 0===this.invertAxis&&(this.invertAxis=i.w.globals.isBarHorizontal),this.addAnnotationExternal({params:t,pushToMemory:e,context:i,type:"point",contextMethod:i.addPointAnnotation}),i}},{key:"addAnnotationExternal",value:function(t){var e=t.params,i=t.pushToMemory,a=t.context,s=t.type,r=t.contextMethod,o=a,n=o.w,l=n.globals.dom.baseEl.querySelector(".apexcharts-".concat(s,"-annotations")),h=l.childNodes.length+1,c=new M,d=Object.assign({},"xaxis"===s?c.xAxisAnnotation:"yaxis"===s?c.yAxisAnnotation:c.pointAnnotation),g=y.extend(d,e);switch(s){case"xaxis":this.addXaxisAnnotation(g,l,h);break;case"yaxis":this.addYaxisAnnotation(g,l,h);break;case"point":this.addPointAnnotation(g,l,h)}var u=n.globals.dom.baseEl.querySelector(".apexcharts-".concat(s,"-annotations .apexcharts-").concat(s,"-annotation-label[rel='").concat(h,"']")),p=this.helpers.addBackgroundToAnno(u,g);return p&&l.insertBefore(p.node,u),i&&n.globals.memory.methodsToExec.push({context:o,id:g.id?g.id:y.randomId(),method:r,label:"addAnnotation",params:e}),a}},{key:"clearAnnotations",value:function(t){var e=t.w,i=e.globals.dom.baseEl.querySelectorAll(".apexcharts-yaxis-annotations, .apexcharts-xaxis-annotations, .apexcharts-point-annotations");e.globals.memory.methodsToExec.map((function(t,i){"addText"!==t.label&&"addAnnotation"!==t.label||e.globals.memory.methodsToExec.splice(i,1)})),i=y.listToArray(i),Array.prototype.forEach.call(i,(function(t){for(;t.firstChild;)t.removeChild(t.firstChild)}))}},{key:"removeAnnotation",value:function(t,e){var i=t.w,a=i.globals.dom.baseEl.querySelectorAll(".".concat(e));a&&(i.globals.memory.methodsToExec.map((function(t,a){t.id===e&&i.globals.memory.methodsToExec.splice(a,1)})),Array.prototype.forEach.call(a,(function(t){t.parentElement.removeChild(t)})))}}]),t}(),z=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.months31=[1,3,5,7,8,10,12],this.months30=[2,4,6,9,11],this.daysCntOfYear=[0,31,59,90,120,151,181,212,243,273,304,334]}return h(t,[{key:"isValidDate",value:function(t){return!isNaN(this.parseDate(t))}},{key:"getTimeStamp",value:function(t){return Date.parse(t)?this.w.config.xaxis.labels.datetimeUTC?new Date(new Date(t).toISOString().substr(0,25)).getTime():new Date(t).getTime():t}},{key:"getDate",value:function(t){return this.w.config.xaxis.labels.datetimeUTC?new Date(new Date(t).toUTCString()):new Date(t)}},{key:"parseDate",value:function(t){var e=Date.parse(t);if(!isNaN(e))return this.getTimeStamp(t);var i=Date.parse(t.replace(/-/g,"/").replace(/[a-z]+/gi," "));return this.getTimeStamp(i)}},{key:"parseDateWithTimezone",value:function(t){return Date.parse(t.replace(/-/g,"/").replace(/[a-z]+/gi," "))}},{key:"formatDate",value:function(t,e){var i=this.w.globals.locale,a=this.w.config.xaxis.labels.datetimeUTC,s=["\0"].concat(b(i.months)),r=[""].concat(b(i.shortMonths)),o=[""].concat(b(i.days)),n=[""].concat(b(i.shortDays));function l(t,e){var i=t+"";for(e=e||2;i.length12?g-12:0===g?12:g;e=(e=(e=(e=e.replace(/(^|[^\\])HH+/g,"$1"+l(g))).replace(/(^|[^\\])H/g,"$1"+g)).replace(/(^|[^\\])hh+/g,"$1"+l(u))).replace(/(^|[^\\])h/g,"$1"+u);var p=a?t.getUTCMinutes():t.getMinutes();e=(e=e.replace(/(^|[^\\])mm+/g,"$1"+l(p))).replace(/(^|[^\\])m/g,"$1"+p);var f=a?t.getUTCSeconds():t.getSeconds();e=(e=e.replace(/(^|[^\\])ss+/g,"$1"+l(f))).replace(/(^|[^\\])s/g,"$1"+f);var x=a?t.getUTCMilliseconds():t.getMilliseconds();e=e.replace(/(^|[^\\])fff+/g,"$1"+l(x,3)),x=Math.round(x/10),e=e.replace(/(^|[^\\])ff/g,"$1"+l(x)),x=Math.round(x/10);var v=g<12?"AM":"PM";e=(e=(e=e.replace(/(^|[^\\])f/g,"$1"+x)).replace(/(^|[^\\])TT+/g,"$1"+v)).replace(/(^|[^\\])T/g,"$1"+v.charAt(0));var m=v.toLowerCase();e=(e=e.replace(/(^|[^\\])tt+/g,"$1"+m)).replace(/(^|[^\\])t/g,"$1"+m.charAt(0));var y=-t.getTimezoneOffset(),w=a||!y?"Z":y>0?"+":"-";if(!a){var k=(y=Math.abs(y))%60;w+=l(Math.floor(y/60))+":"+l(k)}e=e.replace(/(^|[^\\])K/g,"$1"+w);var A=(a?t.getUTCDay():t.getDay())+1;return(e=(e=(e=(e=e.replace(new RegExp(o[0],"g"),o[A])).replace(new RegExp(n[0],"g"),n[A])).replace(new RegExp(s[0],"g"),s[c])).replace(new RegExp(r[0],"g"),r[c])).replace(/\\(.)/g,"$1")}},{key:"getTimeUnitsfromTimestamp",value:function(t,e,i){var a=this.w;void 0!==a.config.xaxis.min&&(t=a.config.xaxis.min),void 0!==a.config.xaxis.max&&(e=a.config.xaxis.max);var s=this.getDate(t),r=this.getDate(e),o=this.formatDate(s,"yyyy MM dd HH mm ss fff").split(" "),n=this.formatDate(r,"yyyy MM dd HH mm ss fff").split(" ");return{minMillisecond:parseInt(o[6],10),maxMillisecond:parseInt(n[6],10),minSecond:parseInt(o[5],10),maxSecond:parseInt(n[5],10),minMinute:parseInt(o[4],10),maxMinute:parseInt(n[4],10),minHour:parseInt(o[3],10),maxHour:parseInt(n[3],10),minDate:parseInt(o[2],10),maxDate:parseInt(n[2],10),minMonth:parseInt(o[1],10)-1,maxMonth:parseInt(n[1],10)-1,minYear:parseInt(o[0],10),maxYear:parseInt(n[0],10)}}},{key:"isLeapYear",value:function(t){return t%4==0&&t%100!=0||t%400==0}},{key:"calculcateLastDaysOfMonth",value:function(t,e,i){return this.determineDaysOfMonths(t,e)-i}},{key:"determineDaysOfYear",value:function(t){var e=365;return this.isLeapYear(t)&&(e=366),e}},{key:"determineRemainingDaysOfYear",value:function(t,e,i){var a=this.daysCntOfYear[e]+i;return e>1&&this.isLeapYear()&&a++,a}},{key:"determineDaysOfMonths",value:function(t,e){var i=30;switch(t=y.monthMod(t),!0){case this.months30.indexOf(t)>-1:2===t&&(i=this.isLeapYear(e)?29:28);break;case this.months31.indexOf(t)>-1:default:i=31}return i}}]),t}(),E=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.tooltipKeyFormat="dd MMM"}return h(t,[{key:"xLabelFormat",value:function(t,e,i,a){var s=this.w;if("datetime"===s.config.xaxis.type&&void 0===s.config.xaxis.labels.formatter&&void 0===s.config.tooltip.x.formatter){var r=new z(this.ctx);return r.formatDate(r.getDate(e),s.config.tooltip.x.format)}return t(e,i,a)}},{key:"defaultGeneralFormatter",value:function(t){return Array.isArray(t)?t.map((function(t){return t})):t}},{key:"defaultYFormatter",value:function(t,e,i){var a=this.w;return y.isNumber(t)&&(t=0!==a.globals.yValueDecimal?t.toFixed(void 0!==e.decimalsInFloat?e.decimalsInFloat:a.globals.yValueDecimal):a.globals.maxYArr[i]-a.globals.minYArr[i]<5?t.toFixed(1):t.toFixed(0)),t}},{key:"setLabelFormatters",value:function(){var t=this,e=this.w;return e.globals.xaxisTooltipFormatter=function(e){return t.defaultGeneralFormatter(e)},e.globals.ttKeyFormatter=function(e){return t.defaultGeneralFormatter(e)},e.globals.ttZFormatter=function(t){return t},e.globals.legendFormatter=function(e){return t.defaultGeneralFormatter(e)},void 0!==e.config.xaxis.labels.formatter?e.globals.xLabelFormatter=e.config.xaxis.labels.formatter:e.globals.xLabelFormatter=function(t){if(y.isNumber(t)){if(!e.config.xaxis.convertedCatToNumeric&&"numeric"===e.config.xaxis.type){if(y.isNumber(e.config.xaxis.decimalsInFloat))return t.toFixed(e.config.xaxis.decimalsInFloat);var i=e.globals.maxX-e.globals.minX;return i>0&&i<100?t.toFixed(1):t.toFixed(0)}return e.globals.isBarHorizontal&&e.globals.maxY-e.globals.minYArr<4?t.toFixed(1):t.toFixed(0)}return t},"function"==typeof e.config.tooltip.x.formatter?e.globals.ttKeyFormatter=e.config.tooltip.x.formatter:e.globals.ttKeyFormatter=e.globals.xLabelFormatter,"function"==typeof e.config.xaxis.tooltip.formatter&&(e.globals.xaxisTooltipFormatter=e.config.xaxis.tooltip.formatter),(Array.isArray(e.config.tooltip.y)||void 0!==e.config.tooltip.y.formatter)&&(e.globals.ttVal=e.config.tooltip.y),void 0!==e.config.tooltip.z.formatter&&(e.globals.ttZFormatter=e.config.tooltip.z.formatter),void 0!==e.config.legend.formatter&&(e.globals.legendFormatter=e.config.legend.formatter),e.config.yaxis.forEach((function(i,a){void 0!==i.labels.formatter?e.globals.yLabelFormatters[a]=i.labels.formatter:e.globals.yLabelFormatters[a]=function(s){return e.globals.xyCharts?Array.isArray(s)?s.map((function(e){return t.defaultYFormatter(e,i,a)})):t.defaultYFormatter(s,i,a):s}})),e.globals}},{key:"heatmapLabelFormatters",value:function(){var t=this.w;if("heatmap"===t.config.chart.type){t.globals.yAxisScale[0].result=t.globals.seriesNames.slice();var e=t.globals.seriesNames.reduce((function(t,e){return t.length>e.length?t:e}),0);t.globals.yAxisScale[0].niceMax=e,t.globals.yAxisScale[0].niceMin=e}}}]),t}(),Y=function(t){var e,i=t.isTimeline,a=t.ctx,s=t.seriesIndex,r=t.dataPointIndex,o=t.y1,n=t.y2,l=t.w,h=l.globals.seriesRangeStart[s][r],c=l.globals.seriesRangeEnd[s][r],d=l.globals.labels[r],g=l.config.series[s].name?l.config.series[s].name:"",u=l.globals.ttKeyFormatter,p=l.config.tooltip.y.title.formatter,f={w:l,seriesIndex:s,dataPointIndex:r,start:h,end:c};"function"==typeof p&&(g=p(g,f)),null!==(e=l.config.series[s].data[r])&&void 0!==e&&e.x&&(d=l.config.series[s].data[r].x),i||"datetime"===l.config.xaxis.type&&(d=new E(a).xLabelFormat(l.globals.ttKeyFormatter,d,d,{i:void 0,dateFormatter:new z(a).formatDate,w:l})),"function"==typeof u&&(d=u(d,f)),Number.isFinite(o)&&Number.isFinite(n)&&(h=o,c=n);var x="",b="",v=l.globals.colors[s];if(void 0===l.config.tooltip.x.formatter)if("datetime"===l.config.xaxis.type){var m=new z(a);x=m.formatDate(m.getDate(h),l.config.tooltip.x.format),b=m.formatDate(m.getDate(c),l.config.tooltip.x.format)}else x=h,b=c;else x=l.config.tooltip.x.formatter(h),b=l.config.tooltip.x.formatter(c);return{start:h,end:c,startVal:x,endVal:b,ylabel:d,color:v,seriesName:g}},F=function(t){var e=t.color,i=t.seriesName,a=t.ylabel,s=t.start,r=t.end,o=t.seriesIndex,n=t.dataPointIndex,l=t.ctx.tooltip.tooltipLabels.getFormatters(o);s=l.yLbFormatter(s),r=l.yLbFormatter(r);var h=l.yLbFormatter(t.w.globals.series[o][n]),c='\n '.concat(s,'\n - \n ').concat(r,"\n ");return'
'+(i||"")+'
'+a+": "+(t.w.globals.comboCharts?"rangeArea"===t.w.config.series[o].type||"rangeBar"===t.w.config.series[o].type?c:"".concat(h,""):c)+"
"},R=function(){function t(e){n(this,t),this.opts=e}return h(t,[{key:"hideYAxis",value:function(){this.opts.yaxis[0].show=!1,this.opts.yaxis[0].title.text="",this.opts.yaxis[0].axisBorder.show=!1,this.opts.yaxis[0].axisTicks.show=!1,this.opts.yaxis[0].floating=!0}},{key:"line",value:function(){return{chart:{animations:{easing:"swing"}},dataLabels:{enabled:!1},stroke:{width:5,curve:"straight"},markers:{size:0,hover:{sizeOffset:6}},xaxis:{crosshairs:{width:1}}}}},{key:"sparkline",value:function(t){return this.hideYAxis(),y.extend(t,{grid:{show:!1,padding:{left:0,right:0,top:0,bottom:0}},legend:{show:!1},xaxis:{labels:{show:!1},tooltip:{enabled:!1},axisBorder:{show:!1},axisTicks:{show:!1}},chart:{toolbar:{show:!1},zoom:{enabled:!1}},dataLabels:{enabled:!1}})}},{key:"bar",value:function(){return{chart:{stacked:!1,animations:{easing:"swing"}},plotOptions:{bar:{dataLabels:{position:"center"}}},dataLabels:{style:{colors:["#fff"]},background:{enabled:!1}},stroke:{width:0,lineCap:"round"},fill:{opacity:.85},legend:{markers:{shape:"square",radius:2,size:8}},tooltip:{shared:!1,intersect:!0},xaxis:{tooltip:{enabled:!1},tickPlacement:"between",crosshairs:{width:"barWidth",position:"back",fill:{type:"gradient"},dropShadow:{enabled:!1},stroke:{width:0}}}}}},{key:"funnel",value:function(){return this.hideYAxis(),r(r({},this.bar()),{},{chart:{animations:{easing:"linear",speed:800,animateGradually:{enabled:!1}}},plotOptions:{bar:{horizontal:!0,borderRadiusApplication:"around",borderRadius:0,dataLabels:{position:"center"}}},grid:{show:!1,padding:{left:0,right:0}},xaxis:{labels:{show:!1},tooltip:{enabled:!1},axisBorder:{show:!1},axisTicks:{show:!1}}})}},{key:"candlestick",value:function(){var t=this;return{stroke:{width:1,colors:["#333"]},fill:{opacity:1},dataLabels:{enabled:!1},tooltip:{shared:!0,custom:function(e){var i=e.seriesIndex,a=e.dataPointIndex,s=e.w;return t._getBoxTooltip(s,i,a,["Open","High","","Low","Close"],"candlestick")}},states:{active:{filter:{type:"none"}}},xaxis:{crosshairs:{width:1}}}}},{key:"boxPlot",value:function(){var t=this;return{chart:{animations:{dynamicAnimation:{enabled:!1}}},stroke:{width:1,colors:["#24292e"]},dataLabels:{enabled:!1},tooltip:{shared:!0,custom:function(e){var i=e.seriesIndex,a=e.dataPointIndex,s=e.w;return t._getBoxTooltip(s,i,a,["Minimum","Q1","Median","Q3","Maximum"],"boxPlot")}},markers:{size:5,strokeWidth:1,strokeColors:"#111"},xaxis:{crosshairs:{width:1}}}}},{key:"rangeBar",value:function(){return{chart:{animations:{animateGradually:!1}},stroke:{width:0,lineCap:"square"},plotOptions:{bar:{borderRadius:0,dataLabels:{position:"center"}}},dataLabels:{enabled:!1,formatter:function(t,e){e.ctx;var i=e.seriesIndex,a=e.dataPointIndex,s=e.w,r=function(){var t=s.globals.seriesRangeStart[i][a];return s.globals.seriesRangeEnd[i][a]-t};return s.globals.comboCharts?"rangeBar"===s.config.series[i].type||"rangeArea"===s.config.series[i].type?r():t:r()},background:{enabled:!1},style:{colors:["#fff"]}},markers:{size:10},tooltip:{shared:!1,followCursor:!0,custom:function(t){return t.w.config.plotOptions&&t.w.config.plotOptions.bar&&t.w.config.plotOptions.bar.horizontal?function(t){var e=Y(r(r({},t),{},{isTimeline:!0})),i=e.color,a=e.seriesName,s=e.ylabel,o=e.startVal,n=e.endVal;return F(r(r({},t),{},{color:i,seriesName:a,ylabel:s,start:o,end:n}))}(t):function(t){var e=Y(t),i=e.color,a=e.seriesName,s=e.ylabel,o=e.start,n=e.end;return F(r(r({},t),{},{color:i,seriesName:a,ylabel:s,start:o,end:n}))}(t)}},xaxis:{tickPlacement:"between",tooltip:{enabled:!1},crosshairs:{stroke:{width:0}}}}}},{key:"dumbbell",value:function(t){var e,i;return null!==(e=t.plotOptions.bar)&&void 0!==e&&e.barHeight||(t.plotOptions.bar.barHeight=2),null!==(i=t.plotOptions.bar)&&void 0!==i&&i.columnWidth||(t.plotOptions.bar.columnWidth=2),t}},{key:"area",value:function(){return{stroke:{width:4,fill:{type:"solid",gradient:{inverseColors:!1,shade:"light",type:"vertical",opacityFrom:.65,opacityTo:.5,stops:[0,100,100]}}},fill:{type:"gradient",gradient:{inverseColors:!1,shade:"light",type:"vertical",opacityFrom:.65,opacityTo:.5,stops:[0,100,100]}},markers:{size:0,hover:{sizeOffset:6}},tooltip:{followCursor:!1}}}},{key:"rangeArea",value:function(){return{stroke:{curve:"straight",width:0},fill:{type:"solid",opacity:.6},markers:{size:0},states:{hover:{filter:{type:"none"}},active:{filter:{type:"none"}}},tooltip:{intersect:!1,shared:!0,followCursor:!0,custom:function(t){return function(t){var e=Y(t),i=e.color,a=e.seriesName,s=e.ylabel,o=e.start,n=e.end;return F(r(r({},t),{},{color:i,seriesName:a,ylabel:s,start:o,end:n}))}(t)}}}}},{key:"brush",value:function(t){return y.extend(t,{chart:{toolbar:{autoSelected:"selection",show:!1},zoom:{enabled:!1}},dataLabels:{enabled:!1},stroke:{width:1},tooltip:{enabled:!1},xaxis:{tooltip:{enabled:!1}}})}},{key:"stacked100",value:function(t){t.dataLabels=t.dataLabels||{},t.dataLabels.formatter=t.dataLabels.formatter||void 0;var e=t.dataLabels.formatter;return t.yaxis.forEach((function(e,i){t.yaxis[i].min=0,t.yaxis[i].max=100})),"bar"===t.chart.type&&(t.dataLabels.formatter=e||function(t){return"number"==typeof t&&t?t.toFixed(0)+"%":t}),t}},{key:"stackedBars",value:function(){var t=this.bar();return r(r({},t),{},{plotOptions:r(r({},t.plotOptions),{},{bar:r(r({},t.plotOptions.bar),{},{borderRadiusApplication:"end",borderRadiusWhenStacked:"last"})})})}},{key:"convertCatToNumeric",value:function(t){return t.xaxis.convertedCatToNumeric=!0,t}},{key:"convertCatToNumericXaxis",value:function(t,e,i){t.xaxis.type="numeric",t.xaxis.labels=t.xaxis.labels||{},t.xaxis.labels.formatter=t.xaxis.labels.formatter||function(t){return y.isNumber(t)?Math.floor(t):t};var a=t.xaxis.labels.formatter,s=t.xaxis.categories&&t.xaxis.categories.length?t.xaxis.categories:t.labels;return i&&i.length&&(s=i.map((function(t){return Array.isArray(t)?t:String(t)}))),s&&s.length&&(t.xaxis.labels.formatter=function(t){return y.isNumber(t)?a(s[Math.floor(t)-1]):a(t)}),t.xaxis.categories=[],t.labels=[],t.xaxis.tickAmount=t.xaxis.tickAmount||"dataPoints",t}},{key:"bubble",value:function(){return{dataLabels:{style:{colors:["#fff"]}},tooltip:{shared:!1,intersect:!0},xaxis:{crosshairs:{width:0}},fill:{type:"solid",gradient:{shade:"light",inverse:!0,shadeIntensity:.55,opacityFrom:.4,opacityTo:.8}}}}},{key:"scatter",value:function(){return{dataLabels:{enabled:!1},tooltip:{shared:!1,intersect:!0},markers:{size:6,strokeWidth:1,hover:{sizeOffset:2}}}}},{key:"heatmap",value:function(){return{chart:{stacked:!1},fill:{opacity:1},dataLabels:{style:{colors:["#fff"]}},stroke:{colors:["#fff"]},tooltip:{followCursor:!0,marker:{show:!1},x:{show:!1}},legend:{position:"top",markers:{shape:"square",size:10,offsetY:2}},grid:{padding:{right:20}}}}},{key:"treemap",value:function(){return{chart:{zoom:{enabled:!1}},dataLabels:{style:{fontSize:14,fontWeight:600,colors:["#fff"]}},stroke:{show:!0,width:2,colors:["#fff"]},legend:{show:!1},fill:{gradient:{stops:[0,100]}},tooltip:{followCursor:!0,x:{show:!1}},grid:{padding:{left:0,right:0}},xaxis:{crosshairs:{show:!1},tooltip:{enabled:!1}}}}},{key:"pie",value:function(){return{chart:{toolbar:{show:!1}},plotOptions:{pie:{donut:{labels:{show:!1}}}},dataLabels:{formatter:function(t){return t.toFixed(1)+"%"},style:{colors:["#fff"]},background:{enabled:!1},dropShadow:{enabled:!0}},stroke:{colors:["#fff"]},fill:{opacity:1,gradient:{shade:"light",stops:[0,100]}},tooltip:{theme:"dark",fillSeriesColor:!0},legend:{position:"right"}}}},{key:"donut",value:function(){return{chart:{toolbar:{show:!1}},dataLabels:{formatter:function(t){return t.toFixed(1)+"%"},style:{colors:["#fff"]},background:{enabled:!1},dropShadow:{enabled:!0}},stroke:{colors:["#fff"]},fill:{opacity:1,gradient:{shade:"light",shadeIntensity:.35,stops:[80,100],opacityFrom:1,opacityTo:1}},tooltip:{theme:"dark",fillSeriesColor:!0},legend:{position:"right"}}}},{key:"polarArea",value:function(){return this.opts.yaxis[0].tickAmount=this.opts.yaxis[0].tickAmount?this.opts.yaxis[0].tickAmount:6,{chart:{toolbar:{show:!1}},dataLabels:{formatter:function(t){return t.toFixed(1)+"%"},enabled:!1},stroke:{show:!0,width:2},fill:{opacity:.7},tooltip:{theme:"dark",fillSeriesColor:!0},legend:{position:"right"}}}},{key:"radar",value:function(){return this.opts.yaxis[0].labels.offsetY=this.opts.yaxis[0].labels.offsetY?this.opts.yaxis[0].labels.offsetY:6,{dataLabels:{enabled:!1,style:{fontSize:"11px"}},stroke:{width:2},markers:{size:3,strokeWidth:1,strokeOpacity:1},fill:{opacity:.2},tooltip:{shared:!1,intersect:!0,followCursor:!0},grid:{show:!1},xaxis:{labels:{formatter:function(t){return t},style:{colors:["#a8a8a8"],fontSize:"11px"}},tooltip:{enabled:!1},crosshairs:{show:!1}}}}},{key:"radialBar",value:function(){return{chart:{animations:{dynamicAnimation:{enabled:!0,speed:800}},toolbar:{show:!1}},fill:{gradient:{shade:"dark",shadeIntensity:.4,inverseColors:!1,type:"diagonal2",opacityFrom:1,opacityTo:1,stops:[70,98,100]}},legend:{show:!1,position:"right"},tooltip:{enabled:!1,fillSeriesColor:!0}}}},{key:"_getBoxTooltip",value:function(t,e,i,a,s){var r=t.globals.seriesCandleO[e][i],o=t.globals.seriesCandleH[e][i],n=t.globals.seriesCandleM[e][i],l=t.globals.seriesCandleL[e][i],h=t.globals.seriesCandleC[e][i];return t.config.series[e].type&&t.config.series[e].type!==s?'
\n '.concat(t.config.series[e].name?t.config.series[e].name:"series-"+(e+1),": ").concat(t.globals.series[e][i],"\n
"):'
')+"
".concat(a[0],': ')+r+"
"+"
".concat(a[1],': ')+o+"
"+(n?"
".concat(a[2],': ')+n+"
":"")+"
".concat(a[3],': ')+l+"
"+"
".concat(a[4],': ')+h+"
"}}]),t}(),O=function(){function t(e){n(this,t),this.opts=e}return h(t,[{key:"init",value:function(t){var e=t.responsiveOverride,i=this.opts,a=new M,s=new R(i);this.chartType=i.chart.type,i=this.extendYAxis(i),i=this.extendAnnotations(i);var r=a.init(),n={};if(i&&"object"===o(i)){var l,h,c,d,g,u,p,f,x={};x=-1!==["line","area","bar","candlestick","boxPlot","rangeBar","rangeArea","bubble","scatter","heatmap","treemap","pie","polarArea","donut","radar","radialBar"].indexOf(i.chart.type)?s[i.chart.type]():s.line(),null!==(l=i.plotOptions)&&void 0!==l&&null!==(h=l.bar)&&void 0!==h&&h.isFunnel&&(x=s.funnel()),i.chart.stacked&&"bar"===i.chart.type&&(x=s.stackedBars()),null!==(c=i.chart.brush)&&void 0!==c&&c.enabled&&(x=s.brush(x)),i.chart.stacked&&"100%"===i.chart.stackType&&(i=s.stacked100(i)),null!==(d=i.plotOptions)&&void 0!==d&&null!==(g=d.bar)&&void 0!==g&&g.isDumbbell&&(i=s.dumbbell(i)),this.checkForDarkTheme(window.Apex),this.checkForDarkTheme(i),i.xaxis=i.xaxis||window.Apex.xaxis||{},e||(i.xaxis.convertedCatToNumeric=!1),(null!==(u=(i=this.checkForCatToNumericXAxis(this.chartType,x,i)).chart.sparkline)&&void 0!==u&&u.enabled||null!==(p=window.Apex.chart)&&void 0!==p&&null!==(f=p.sparkline)&&void 0!==f&&f.enabled)&&(x=s.sparkline(x)),n=y.extend(r,x)}var b=y.extend(n,window.Apex);return r=y.extend(b,i),this.handleUserInputErrors(r)}},{key:"checkForCatToNumericXAxis",value:function(t,e,i){var a,s,r=new R(i),o=("bar"===t||"boxPlot"===t)&&(null===(a=i.plotOptions)||void 0===a||null===(s=a.bar)||void 0===s?void 0:s.horizontal),n="pie"===t||"polarArea"===t||"donut"===t||"radar"===t||"radialBar"===t||"heatmap"===t,l="datetime"!==i.xaxis.type&&"numeric"!==i.xaxis.type,h=i.xaxis.tickPlacement?i.xaxis.tickPlacement:e.xaxis&&e.xaxis.tickPlacement;return o||n||!l||"between"===h||(i=r.convertCatToNumeric(i)),i}},{key:"extendYAxis",value:function(t,e){var i=new M;(void 0===t.yaxis||!t.yaxis||Array.isArray(t.yaxis)&&0===t.yaxis.length)&&(t.yaxis={}),t.yaxis.constructor!==Array&&window.Apex.yaxis&&window.Apex.yaxis.constructor!==Array&&(t.yaxis=y.extend(t.yaxis,window.Apex.yaxis)),t.yaxis.constructor!==Array?t.yaxis=[y.extend(i.yAxis,t.yaxis)]:t.yaxis=y.extendArray(t.yaxis,i.yAxis);var a=!1;t.yaxis.forEach((function(t){t.logarithmic&&(a=!0)}));var s=t.series;return e&&!s&&(s=e.config.series),a&&s.length!==t.yaxis.length&&s.length&&(t.yaxis=s.map((function(e,a){if(e.name||(s[a].name="series-".concat(a+1)),t.yaxis[a])return t.yaxis[a].seriesName=s[a].name,t.yaxis[a];var r=y.extend(i.yAxis,t.yaxis[0]);return r.show=!1,r}))),a&&s.length>1&&s.length!==t.yaxis.length&&console.warn("A multi-series logarithmic chart should have equal number of series and y-axes. Please make sure to equalize both."),t}},{key:"extendAnnotations",value:function(t){return void 0===t.annotations&&(t.annotations={},t.annotations.yaxis=[],t.annotations.xaxis=[],t.annotations.points=[]),t=this.extendYAxisAnnotations(t),t=this.extendXAxisAnnotations(t),this.extendPointAnnotations(t)}},{key:"extendYAxisAnnotations",value:function(t){var e=new M;return t.annotations.yaxis=y.extendArray(void 0!==t.annotations.yaxis?t.annotations.yaxis:[],e.yAxisAnnotation),t}},{key:"extendXAxisAnnotations",value:function(t){var e=new M;return t.annotations.xaxis=y.extendArray(void 0!==t.annotations.xaxis?t.annotations.xaxis:[],e.xAxisAnnotation),t}},{key:"extendPointAnnotations",value:function(t){var e=new M;return t.annotations.points=y.extendArray(void 0!==t.annotations.points?t.annotations.points:[],e.pointAnnotation),t}},{key:"checkForDarkTheme",value:function(t){t.theme&&"dark"===t.theme.mode&&(t.tooltip||(t.tooltip={}),"light"!==t.tooltip.theme&&(t.tooltip.theme="dark"),t.chart.foreColor||(t.chart.foreColor="#f6f7f8"),t.chart.background||(t.chart.background="#424242"),t.theme.palette||(t.theme.palette="palette4"))}},{key:"handleUserInputErrors",value:function(t){var e=t;if(e.tooltip.shared&&e.tooltip.intersect)throw new Error("tooltip.shared cannot be enabled when tooltip.intersect is true. Turn off any other option by setting it to false.");if("bar"===e.chart.type&&e.plotOptions.bar.horizontal){if(e.yaxis.length>1)throw new Error("Multiple Y Axis for bars are not supported. Switch to column chart by setting plotOptions.bar.horizontal=false");e.yaxis[0].reversed&&(e.yaxis[0].opposite=!0),e.xaxis.tooltip.enabled=!1,e.yaxis[0].tooltip.enabled=!1,e.chart.zoom.enabled=!1}return"bar"!==e.chart.type&&"rangeBar"!==e.chart.type||e.tooltip.shared&&"barWidth"===e.xaxis.crosshairs.width&&e.series.length>1&&(e.xaxis.crosshairs.width="tickWidth"),"candlestick"!==e.chart.type&&"boxPlot"!==e.chart.type||e.yaxis[0].reversed&&(console.warn("Reversed y-axis in ".concat(e.chart.type," chart is not supported.")),e.yaxis[0].reversed=!1),e}}]),t}(),H=function(){function t(){n(this,t)}return h(t,[{key:"initGlobalVars",value:function(t){t.series=[],t.seriesCandleO=[],t.seriesCandleH=[],t.seriesCandleM=[],t.seriesCandleL=[],t.seriesCandleC=[],t.seriesRangeStart=[],t.seriesRangeEnd=[],t.seriesRange=[],t.seriesPercent=[],t.seriesGoals=[],t.seriesX=[],t.seriesZ=[],t.seriesNames=[],t.seriesTotals=[],t.seriesLog=[],t.seriesColors=[],t.stackedSeriesTotals=[],t.seriesXvalues=[],t.seriesYvalues=[],t.labels=[],t.hasXaxisGroups=!1,t.groups=[],t.hasSeriesGroups=!1,t.seriesGroups=[],t.categoryLabels=[],t.timescaleLabels=[],t.noLabelsProvided=!1,t.resizeTimer=null,t.selectionResizeTimer=null,t.delayedElements=[],t.pointsArray=[],t.dataLabelsRects=[],t.isXNumeric=!1,t.skipLastTimelinelabel=!1,t.skipFirstTimelinelabel=!1,t.isDataXYZ=!1,t.isMultiLineX=!1,t.isMultipleYAxis=!1,t.maxY=-Number.MAX_VALUE,t.minY=Number.MIN_VALUE,t.minYArr=[],t.maxYArr=[],t.maxX=-Number.MAX_VALUE,t.minX=Number.MAX_VALUE,t.initialMaxX=-Number.MAX_VALUE,t.initialMinX=Number.MAX_VALUE,t.maxDate=0,t.minDate=Number.MAX_VALUE,t.minZ=Number.MAX_VALUE,t.maxZ=-Number.MAX_VALUE,t.minXDiff=Number.MAX_VALUE,t.yAxisScale=[],t.xAxisScale=null,t.xAxisTicksPositions=[],t.yLabelsCoords=[],t.yTitleCoords=[],t.barPadForNumericAxis=0,t.padHorizontal=0,t.xRange=0,t.yRange=[],t.zRange=0,t.dataPoints=0,t.xTickAmount=0}},{key:"globalVars",value:function(t){return{chartID:null,cuid:null,events:{beforeMount:[],mounted:[],updated:[],clicked:[],selection:[],dataPointSelection:[],zoomed:[],scrolled:[]},colors:[],clientX:null,clientY:null,fill:{colors:[]},stroke:{colors:[]},dataLabels:{style:{colors:[]}},radarPolygons:{fill:{colors:[]}},markers:{colors:[],size:t.markers.size,largestSize:0},animationEnded:!1,isTouchDevice:"ontouchstart"in window||navigator.msMaxTouchPoints,isDirty:!1,isExecCalled:!1,initialConfig:null,initialSeries:[],lastXAxis:[],lastYAxis:[],columnSeries:null,labels:[],timescaleLabels:[],noLabelsProvided:!1,allSeriesCollapsed:!1,collapsedSeries:[],collapsedSeriesIndices:[],ancillaryCollapsedSeries:[],ancillaryCollapsedSeriesIndices:[],risingSeries:[],dataFormatXNumeric:!1,capturedSeriesIndex:-1,capturedDataPointIndex:-1,selectedDataPoints:[],goldenPadding:35,invalidLogScale:!1,ignoreYAxisIndexes:[],yAxisSameScaleIndices:[],maxValsInArrayIndex:0,radialSize:0,selection:void 0,zoomEnabled:"zoom"===t.chart.toolbar.autoSelected&&t.chart.toolbar.tools.zoom&&t.chart.zoom.enabled,panEnabled:"pan"===t.chart.toolbar.autoSelected&&t.chart.toolbar.tools.pan,selectionEnabled:"selection"===t.chart.toolbar.autoSelected&&t.chart.toolbar.tools.selection,yaxis:null,mousedown:!1,lastClientPosition:{},visibleXRange:void 0,yValueDecimal:0,total:0,SVGNS:"http://www.w3.org/2000/svg",svgWidth:0,svgHeight:0,noData:!1,locale:{},dom:{},memory:{methodsToExec:[]},shouldAnimate:!0,skipLastTimelinelabel:!1,skipFirstTimelinelabel:!1,delayedElements:[],axisCharts:!0,isDataXYZ:!1,resized:!1,resizeTimer:null,comboCharts:!1,dataChanged:!1,previousPaths:[],allSeriesHasEqualX:!0,pointsArray:[],dataLabelsRects:[],lastDrawnDataLabelsIndexes:[],hasNullValues:!1,easing:null,zoomed:!1,gridWidth:0,gridHeight:0,rotateXLabels:!1,defaultLabels:!1,xLabelFormatter:void 0,yLabelFormatters:[],xaxisTooltipFormatter:void 0,ttKeyFormatter:void 0,ttVal:void 0,ttZFormatter:void 0,LINE_HEIGHT_RATIO:1.618,xAxisLabelsHeight:0,xAxisGroupLabelsHeight:0,xAxisLabelsWidth:0,yAxisLabelsWidth:0,scaleX:1,scaleY:1,translateX:0,translateY:0,translateYAxisX:[],yAxisWidths:[],translateXAxisY:0,translateXAxisX:0,tooltip:null}}},{key:"init",value:function(t){var e=this.globalVars(t);return this.initGlobalVars(e),e.initialConfig=y.extend({},t),e.initialSeries=y.clone(t.series),e.lastXAxis=y.clone(e.initialConfig.xaxis),e.lastYAxis=y.clone(e.initialConfig.yaxis),e}}]),t}(),D=function(){function t(e){n(this,t),this.opts=e}return h(t,[{key:"init",value:function(){var t=new O(this.opts).init({responsiveOverride:!1});return{config:t,globals:(new H).init(t)}}}]),t}(),N=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.opts=null,this.seriesIndex=0}return h(t,[{key:"clippedImgArea",value:function(t){var e=this.w,i=e.config,a=parseInt(e.globals.gridWidth,10),s=parseInt(e.globals.gridHeight,10),r=a>s?a:s,o=t.image,n=0,l=0;void 0===t.width&&void 0===t.height?void 0!==i.fill.image.width&&void 0!==i.fill.image.height?(n=i.fill.image.width+1,l=i.fill.image.height):(n=r+1,l=r):(n=t.width,l=t.height);var h=document.createElementNS(e.globals.SVGNS,"pattern");A.setAttrs(h,{id:t.patternID,patternUnits:t.patternUnits?t.patternUnits:"userSpaceOnUse",width:n+"px",height:l+"px"});var c=document.createElementNS(e.globals.SVGNS,"image");h.appendChild(c),c.setAttributeNS(window.SVG.xlink,"href",o),A.setAttrs(c,{x:0,y:0,preserveAspectRatio:"none",width:n+"px",height:l+"px"}),c.style.opacity=t.opacity,e.globals.dom.elDefs.node.appendChild(h)}},{key:"getSeriesIndex",value:function(t){var e=this.w,i=e.config.chart.type;return("bar"===i||"rangeBar"===i)&&e.config.plotOptions.bar.distributed||"heatmap"===i||"treemap"===i?this.seriesIndex=t.seriesNumber:this.seriesIndex=t.seriesNumber%e.globals.series.length,this.seriesIndex}},{key:"fillPath",value:function(t){var e=this.w;this.opts=t;var i,a,s,r=this.w.config;this.seriesIndex=this.getSeriesIndex(t);var o=this.getFillColors()[this.seriesIndex];void 0!==e.globals.seriesColors[this.seriesIndex]&&(o=e.globals.seriesColors[this.seriesIndex]),"function"==typeof o&&(o=o({seriesIndex:this.seriesIndex,dataPointIndex:t.dataPointIndex,value:t.value,w:e}));var n=t.fillType?t.fillType:this.getFillType(this.seriesIndex),l=Array.isArray(r.fill.opacity)?r.fill.opacity[this.seriesIndex]:r.fill.opacity;t.color&&(o=t.color);var h=o;if(-1===o.indexOf("rgb")?o.length<9&&(h=y.hexToRgba(o,l)):o.indexOf("rgba")>-1&&(l=y.getOpacityFromRGBA(o)),t.opacity&&(l=t.opacity),"pattern"===n&&(a=this.handlePatternFill({fillConfig:t.fillConfig,patternFill:a,fillColor:o,fillOpacity:l,defaultColor:h})),"gradient"===n&&(s=this.handleGradientFill({fillConfig:t.fillConfig,fillColor:o,fillOpacity:l,i:this.seriesIndex})),"image"===n){var c=r.fill.image.src,d=t.patternID?t.patternID:"";this.clippedImgArea({opacity:l,image:Array.isArray(c)?t.seriesNumber-1&&(u=y.getOpacityFromRGBA(g));var p=void 0===o.gradient.opacityTo?i:Array.isArray(o.gradient.opacityTo)?o.gradient.opacityTo[s]:o.gradient.opacityTo;if(void 0===o.gradient.gradientToColors||0===o.gradient.gradientToColors.length)n="dark"===o.gradient.shade?c.shadeColor(-1*parseFloat(o.gradient.shadeIntensity),e.indexOf("rgb")>-1?y.rgb2hex(e):e):c.shadeColor(parseFloat(o.gradient.shadeIntensity),e.indexOf("rgb")>-1?y.rgb2hex(e):e);else if(o.gradient.gradientToColors[l.seriesNumber]){var f=o.gradient.gradientToColors[l.seriesNumber];n=f,f.indexOf("rgba")>-1&&(p=y.getOpacityFromRGBA(f))}else n=e;if(o.gradient.gradientFrom&&(g=o.gradient.gradientFrom),o.gradient.gradientTo&&(n=o.gradient.gradientTo),o.gradient.inverseColors){var x=g;g=n,n=x}return g.indexOf("rgb")>-1&&(g=y.rgb2hex(g)),n.indexOf("rgb")>-1&&(n=y.rgb2hex(n)),h.drawGradient(d,g,n,u,p,l.size,o.gradient.stops,o.gradient.colorStops,s)}}]),t}(),W=function(){function t(e,i){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"setGlobalMarkerSize",value:function(){var t=this.w;if(t.globals.markers.size=Array.isArray(t.config.markers.size)?t.config.markers.size:[t.config.markers.size],t.globals.markers.size.length>0){if(t.globals.markers.size.length4&&void 0!==arguments[4]&&arguments[4],o=this.w,n=e,l=t,h=null,c=new A(this.ctx),d=o.config.markers.discrete&&o.config.markers.discrete.length;if((o.globals.markers.size[e]>0||r||d)&&(h=c.group({class:r||d?"":"apexcharts-series-markers"})).attr("clip-path","url(#gridRectMarkerMask".concat(o.globals.cuid,")")),Array.isArray(l.x))for(var g=0;g0:o.config.markers.size>0)||r||d){y.isNumber(l.y[g])?p+=" w".concat(y.randomId()):p="apexcharts-nullpoint";var f=this.getMarkerConfig({cssClass:p,seriesIndex:e,dataPointIndex:u});o.config.series[n].data[u]&&(o.config.series[n].data[u].fillColor&&(f.pointFillColor=o.config.series[n].data[u].fillColor),o.config.series[n].data[u].strokeColor&&(f.pointStrokeColor=o.config.series[n].data[u].strokeColor)),a&&(f.pSize=a),(l.x[g]<0||l.x[g]>o.globals.gridWidth||l.y[g]<0||l.y[g]>o.globals.gridHeight)&&(f.pSize=0),(s=c.drawMarker(l.x[g],l.y[g],f)).attr("rel",u),s.attr("j",u),s.attr("index",e),s.node.setAttribute("default-marker-size",f.pSize),new k(this.ctx).setSelectionFilter(s,e,u),this.addEvents(s),h&&h.add(s)}else void 0===o.globals.pointsArray[e]&&(o.globals.pointsArray[e]=[]),o.globals.pointsArray[e].push([l.x[g],l.y[g]])}return h}},{key:"getMarkerConfig",value:function(t){var e=t.cssClass,i=t.seriesIndex,a=t.dataPointIndex,s=void 0===a?null:a,r=t.finishRadius,o=void 0===r?null:r,n=this.w,l=this.getMarkerStyle(i),h=n.globals.markers.size[i],c=n.config.markers;return null!==s&&c.discrete.length&&c.discrete.map((function(t){t.seriesIndex===i&&t.dataPointIndex===s&&(l.pointStrokeColor=t.strokeColor,l.pointFillColor=t.fillColor,h=t.size,l.pointShape=t.shape)})),{pSize:null===o?h:o,pRadius:c.radius,width:Array.isArray(c.width)?c.width[i]:c.width,height:Array.isArray(c.height)?c.height[i]:c.height,pointStrokeWidth:Array.isArray(c.strokeWidth)?c.strokeWidth[i]:c.strokeWidth,pointStrokeColor:l.pointStrokeColor,pointFillColor:l.pointFillColor,shape:l.pointShape||(Array.isArray(c.shape)?c.shape[i]:c.shape),class:e,pointStrokeOpacity:Array.isArray(c.strokeOpacity)?c.strokeOpacity[i]:c.strokeOpacity,pointStrokeDashArray:Array.isArray(c.strokeDashArray)?c.strokeDashArray[i]:c.strokeDashArray,pointFillOpacity:Array.isArray(c.fillOpacity)?c.fillOpacity[i]:c.fillOpacity,seriesIndex:i}}},{key:"addEvents",value:function(t){var e=this.w,i=new A(this.ctx);t.node.addEventListener("mouseenter",i.pathMouseEnter.bind(this.ctx,t)),t.node.addEventListener("mouseleave",i.pathMouseLeave.bind(this.ctx,t)),t.node.addEventListener("mousedown",i.pathMouseDown.bind(this.ctx,t)),t.node.addEventListener("click",e.config.markers.onClick),t.node.addEventListener("dblclick",e.config.markers.onDblClick),t.node.addEventListener("touchstart",i.pathMouseDown.bind(this.ctx,t),{passive:!0})}},{key:"getMarkerStyle",value:function(t){var e=this.w,i=e.globals.markers.colors,a=e.config.markers.strokeColor||e.config.markers.strokeColors;return{pointStrokeColor:Array.isArray(a)?a[t]:a,pointFillColor:Array.isArray(i)?i[t]:i}}}]),t}(),B=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.initialAnim=this.w.config.chart.animations.enabled,this.dynamicAnim=this.initialAnim&&this.w.config.chart.animations.dynamicAnimation.enabled}return h(t,[{key:"draw",value:function(t,e,i){var a=this.w,s=new A(this.ctx),r=i.realIndex,o=i.pointsPos,n=i.zRatio,l=i.elParent,h=s.group({class:"apexcharts-series-markers apexcharts-series-".concat(a.config.chart.type)});if(h.attr("clip-path","url(#gridRectMarkerMask".concat(a.globals.cuid,")")),Array.isArray(o.x))for(var c=0;cf.maxBubbleRadius&&(p=f.maxBubbleRadius)}a.config.chart.animations.enabled||(u=p);var x=o.x[c],b=o.y[c];if(u=u||0,null!==b&&void 0!==a.globals.series[r][d]||(g=!1),g){var v=this.drawPoint(x,b,u,p,r,d,e);h.add(v)}l.add(h)}}},{key:"drawPoint",value:function(t,e,i,a,s,r,o){var n=this.w,l=s,h=new w(this.ctx),c=new k(this.ctx),d=new N(this.ctx),g=new W(this.ctx),u=new A(this.ctx),p=g.getMarkerConfig({cssClass:"apexcharts-marker",seriesIndex:l,dataPointIndex:r,finishRadius:"bubble"===n.config.chart.type||n.globals.comboCharts&&n.config.series[s]&&"bubble"===n.config.series[s].type?a:null});a=p.pSize;var f,x=d.fillPath({seriesNumber:s,dataPointIndex:r,color:p.pointFillColor,patternUnits:"objectBoundingBox",value:n.globals.series[s][o]});if("circle"===p.shape?f=u.drawCircle(i):"square"!==p.shape&&"rect"!==p.shape||(f=u.drawRect(0,0,p.width-p.pointStrokeWidth/2,p.height-p.pointStrokeWidth/2,p.pRadius)),n.config.series[l].data[r]&&n.config.series[l].data[r].fillColor&&(x=n.config.series[l].data[r].fillColor),f.attr({x:t-p.width/2-p.pointStrokeWidth/2,y:e-p.height/2-p.pointStrokeWidth/2,cx:t,cy:e,fill:x,"fill-opacity":p.pointFillOpacity,stroke:p.pointStrokeColor,r:a,"stroke-width":p.pointStrokeWidth,"stroke-dasharray":p.pointStrokeDashArray,"stroke-opacity":p.pointStrokeOpacity}),n.config.chart.dropShadow.enabled){var b=n.config.chart.dropShadow;c.dropShadow(f,b,s)}if(!this.initialAnim||n.globals.dataChanged||n.globals.resized)n.globals.animationEnded=!0;else{var v=n.config.chart.animations.speed;h.animateMarker(f,0,"circle"===p.shape?a:{width:p.width,height:p.height},v,n.globals.easing,(function(){window.setTimeout((function(){h.animationCompleted(f)}),100)}))}if(n.globals.dataChanged&&"circle"===p.shape)if(this.dynamicAnim){var m,y,S,C,L=n.config.chart.animations.dynamicAnimation.speed;null!=(C=n.globals.previousPaths[s]&&n.globals.previousPaths[s][o])&&(m=C.x,y=C.y,S=void 0!==C.r?C.r:a);for(var P=0;Pn.globals.gridHeight+d&&(e=n.globals.gridHeight+d/2),void 0===n.globals.dataLabelsRects[a]&&(n.globals.dataLabelsRects[a]=[]),n.globals.dataLabelsRects[a].push({x:t,y:e,width:c,height:d});var g=n.globals.dataLabelsRects[a].length-2,u=void 0!==n.globals.lastDrawnDataLabelsIndexes[a]?n.globals.lastDrawnDataLabelsIndexes[a][n.globals.lastDrawnDataLabelsIndexes[a].length-1]:0;if(void 0!==n.globals.dataLabelsRects[a][g]){var p=n.globals.dataLabelsRects[a][u];(t>p.x+p.width+2||e>p.y+p.height+2||t+ce.globals.gridWidth+f.textRects.width+10)&&(n="");var x=e.globals.dataLabels.style.colors[r];(("bar"===e.config.chart.type||"rangeBar"===e.config.chart.type)&&e.config.plotOptions.bar.distributed||e.config.dataLabels.distributed)&&(x=e.globals.dataLabels.style.colors[o]),"function"==typeof x&&(x=x({series:e.globals.series,seriesIndex:r,dataPointIndex:o,w:e})),g&&(x=g);var b=d.offsetX,v=d.offsetY;if("bar"!==e.config.chart.type&&"rangeBar"!==e.config.chart.type||(b=0,v=0),f.drawnextLabel){var m=i.drawText({width:100,height:parseInt(d.style.fontSize,10),x:a+b,y:s+v,foreColor:x,textAnchor:l||d.textAnchor,text:n,fontSize:h||d.style.fontSize,fontFamily:d.style.fontFamily,fontWeight:d.style.fontWeight||"normal"});if(m.attr({class:"apexcharts-datalabel",cx:a,cy:s}),d.dropShadow.enabled){var y=d.dropShadow;new k(this.ctx).dropShadow(m,y)}c.add(m),void 0===e.globals.lastDrawnDataLabelsIndexes[r]&&(e.globals.lastDrawnDataLabelsIndexes[r]=[]),e.globals.lastDrawnDataLabelsIndexes[r].push(o)}}}},{key:"addBackgroundToDataLabel",value:function(t,e){var i=this.w,a=i.config.dataLabels.background,s=a.padding,r=a.padding/2,o=e.width,n=e.height,l=new A(this.ctx).drawRect(e.x-s,e.y-r/2,o+2*s,n+r,a.borderRadius,"transparent"===i.config.chart.background?"#fff":i.config.chart.background,a.opacity,a.borderWidth,a.borderColor);return a.dropShadow.enabled&&new k(this.ctx).dropShadow(l,a.dropShadow),l}},{key:"dataLabelsBackground",value:function(){var t=this.w;if("bubble"!==t.config.chart.type)for(var e=t.globals.dom.baseEl.querySelectorAll(".apexcharts-datalabels text"),i=0;i0&&void 0!==arguments[0])||arguments[0],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=this.w,s=y.clone(a.globals.initialSeries);a.globals.previousPaths=[],i?(a.globals.collapsedSeries=[],a.globals.ancillaryCollapsedSeries=[],a.globals.collapsedSeriesIndices=[],a.globals.ancillaryCollapsedSeriesIndices=[]):s=this.emptyCollapsedSeries(s),a.config.series=s,t&&(e&&(a.globals.zoomed=!1,this.ctx.updateHelpers.revertDefaultAxisMinMax()),this.ctx.updateHelpers._updateSeries(s,a.config.chart.animations.dynamicAnimation.enabled))}},{key:"emptyCollapsedSeries",value:function(t){for(var e=this.w,i=0;i-1&&(t[i].data=[]);return t}},{key:"toggleSeriesOnHover",value:function(t,e){var i=this.w;e||(e=t.target);var a=i.globals.dom.baseEl.querySelectorAll(".apexcharts-series, .apexcharts-datalabels");if("mousemove"===t.type){var s=parseInt(e.getAttribute("rel"),10)-1,r=null,o=null;i.globals.axisCharts||"radialBar"===i.config.chart.type?i.globals.axisCharts?(r=i.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(s,"']")),o=i.globals.dom.baseEl.querySelector(".apexcharts-datalabels[data\\:realIndex='".concat(s,"']"))):r=i.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(s+1,"']")):r=i.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(s+1,"'] path"));for(var n=0;n=t.from&&a<=t.to&&s[e].classList.remove(i.legendInactiveClass)}}(a.config.plotOptions.heatmap.colorScale.ranges[o])}else"mouseout"===t.type&&r("remove")}},{key:"getActiveConfigSeriesIndex",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"asc",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=this.w,a=0;if(i.config.series.length>1)for(var s=i.config.series.map((function(t,a){return t.data&&t.data.length>0&&-1===i.globals.collapsedSeriesIndices.indexOf(a)&&(!i.globals.comboCharts||0===e.length||e.length&&e.indexOf(i.config.series[a].type)>-1)?a:-1})),r="asc"===t?0:s.length-1;"asc"===t?r=0;"asc"===t?r++:r--)if(-1!==s[r]){a=s[r];break}return a}},{key:"getBarSeriesIndices",value:function(){return this.w.globals.comboCharts?this.w.config.series.map((function(t,e){return"bar"===t.type||"column"===t.type?e:-1})).filter((function(t){return-1!==t})):this.w.config.series.map((function(t,e){return e}))}},{key:"getPreviousPaths",value:function(){var t=this.w;function e(e,i,a){for(var s=e[i].childNodes,r={type:a,paths:[],realIndex:e[i].getAttribute("data:realIndex")},o=0;o0)for(var a=function(e){for(var i=t.globals.dom.baseEl.querySelectorAll(".apexcharts-".concat(t.config.chart.type," .apexcharts-series[data\\:realIndex='").concat(e,"'] rect")),a=[],s=function(t){var e=function(e){return i[t].getAttribute(e)},s={x:parseFloat(e("x")),y:parseFloat(e("y")),width:parseFloat(e("width")),height:parseFloat(e("height"))};a.push({rect:s,color:i[t].getAttribute("color")})},r=0;r0)for(var a=0;a0?t:[]}))}}]),t}(),j=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.twoDSeries=[],this.threeDSeries=[],this.twoDSeriesX=[],this.seriesGoals=[],this.coreUtils=new S(this.ctx)}return h(t,[{key:"isMultiFormat",value:function(){return this.isFormatXY()||this.isFormat2DArray()}},{key:"isFormatXY",value:function(){var t=this.w.config.series.slice(),e=new V(this.ctx);if(this.activeSeriesIndex=e.getActiveConfigSeriesIndex(),void 0!==t[this.activeSeriesIndex].data&&t[this.activeSeriesIndex].data.length>0&&null!==t[this.activeSeriesIndex].data[0]&&void 0!==t[this.activeSeriesIndex].data[0].x&&null!==t[this.activeSeriesIndex].data[0])return!0}},{key:"isFormat2DArray",value:function(){var t=this.w.config.series.slice(),e=new V(this.ctx);if(this.activeSeriesIndex=e.getActiveConfigSeriesIndex(),void 0!==t[this.activeSeriesIndex].data&&t[this.activeSeriesIndex].data.length>0&&void 0!==t[this.activeSeriesIndex].data[0]&&null!==t[this.activeSeriesIndex].data[0]&&t[this.activeSeriesIndex].data[0].constructor===Array)return!0}},{key:"handleFormat2DArray",value:function(t,e){for(var i=this.w.config,a=this.w.globals,s="boxPlot"===i.chart.type||"boxPlot"===i.series[e].type,r=0;r=5?this.twoDSeries.push(y.parseNumber(t[e].data[r][4])):this.twoDSeries.push(y.parseNumber(t[e].data[r][1])),a.dataFormatXNumeric=!0),"datetime"===i.xaxis.type){var o=new Date(t[e].data[r][0]);o=new Date(o).getTime(),this.twoDSeriesX.push(o)}else this.twoDSeriesX.push(t[e].data[r][0]);for(var n=0;n-1&&(r=this.activeSeriesIndex);for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:this.ctx,s=this.w.config,r=this.w.globals,o=new z(a),n=s.labels.length>0?s.labels.slice():s.xaxis.categories.slice();if(r.isRangeBar="rangeBar"===s.chart.type&&r.isBarHorizontal,r.hasXaxisGroups="category"===s.xaxis.type&&s.xaxis.group.groups.length>0,r.hasXaxisGroups&&(r.groups=s.xaxis.group.groups),r.hasSeriesGroups=null===(e=t[0])||void 0===e?void 0:e.group,r.hasSeriesGroups){var l=[],h=b(new Set(t.map((function(t){return t.group}))));t.forEach((function(t,e){var i=h.indexOf(t.group);l[i]||(l[i]=[]),l[i].push(t.name)})),r.seriesGroups=l}for(var c=function(){for(var t=0;t0&&(this.twoDSeriesX=n,r.seriesX.push(this.twoDSeriesX))),r.labels.push(this.twoDSeriesX);var g=t[d].data.map((function(t){return y.parseNumber(t)}));r.series.push(g)}r.seriesZ.push(this.threeDSeries),void 0!==t[d].name?r.seriesNames.push(t[d].name):r.seriesNames.push("series-"+parseInt(d+1,10)),void 0!==t[d].color?r.seriesColors.push(t[d].color):r.seriesColors.push(void 0)}return this.w}},{key:"parseDataNonAxisCharts",value:function(t){var e=this.w.globals,i=this.w.config;e.series=t.slice(),e.seriesNames=i.labels.slice();for(var a=0;a0?i.labels=e.xaxis.categories:e.labels.length>0?i.labels=e.labels.slice():this.fallbackToCategory?(i.labels=i.labels[0],i.seriesRange.length&&(i.seriesRange.map((function(t){t.forEach((function(t){i.labels.indexOf(t.x)<0&&t.x&&i.labels.push(t.x)}))})),i.labels=Array.from(new Set(i.labels.map(JSON.stringify)),JSON.parse)),e.xaxis.convertedCatToNumeric&&(new R(e).convertCatToNumericXaxis(e,this.ctx,i.seriesX[0]),this._generateExternalLabels(t))):this._generateExternalLabels(t)}},{key:"_generateExternalLabels",value:function(t){var e=this.w.globals,i=this.w.config,a=[];if(e.axisCharts){if(e.series.length>0)if(this.isFormatXY())for(var s=i.series.map((function(t,e){return t.data.filter((function(t,e,i){return i.findIndex((function(e){return e.x===t.x}))===e}))})),r=s.reduce((function(t,e,i,a){return a[t].length>e.length?t:i}),0),o=0;o4&&void 0!==arguments[4]?arguments[4]:[],n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"12px",l=!(arguments.length>6&&void 0!==arguments[6])||arguments[6],h=this.w,c=void 0===t[a]?"":t[a],d=c,g=h.globals.xLabelFormatter,u=h.config.xaxis.labels.formatter,p=!1,f=new E(this.ctx),x=c;l&&(d=f.xLabelFormat(g,c,x,{i:a,dateFormatter:new z(this.ctx).formatDate,w:h}),void 0!==u&&(d=u(c,t[a],{i:a,dateFormatter:new z(this.ctx).formatDate,w:h}))),e.length>0?(s=e[a].unit,r=null,e.forEach((function(t){"month"===t.unit?r="year":"day"===t.unit?r="month":"hour"===t.unit?r="day":"minute"===t.unit&&(r="hour")})),p=r===s,i=e[a].position,d=e[a].value):"datetime"===h.config.xaxis.type&&void 0===u&&(d=""),void 0===d&&(d=""),d=Array.isArray(d)?d:d.toString();var b=new A(this.ctx),v={};v=h.globals.rotateXLabels&&l?b.getTextRects(d,parseInt(n,10),null,"rotate(".concat(h.config.xaxis.labels.rotate," 0 0)"),!1):b.getTextRects(d,parseInt(n,10));var m=!h.config.xaxis.labels.showDuplicates&&this.ctx.timeScale;return!Array.isArray(d)&&(0===d.indexOf("NaN")||0===d.toLowerCase().indexOf("invalid")||d.toLowerCase().indexOf("infinity")>=0||o.indexOf(d)>=0&&m)&&(d=""),{x:i,text:d,textRect:v,isBold:p}}},{key:"checkLabelBasedOnTickamount",value:function(t,e,i){var a=this.w,s=a.config.xaxis.tickAmount;return"dataPoints"===s&&(s=Math.round(a.globals.gridWidth/120)),s>i||t%Math.round(i/(s+1))==0||(e.text=""),e}},{key:"checkForOverflowingLabels",value:function(t,e,i,a,s){var r=this.w;if(0===t&&r.globals.skipFirstTimelinelabel&&(e.text=""),t===i-1&&r.globals.skipLastTimelinelabel&&(e.text=""),r.config.xaxis.labels.hideOverlappingLabels&&a.length>0){var o=s[s.length-1];e.x0){!0===n.config.yaxis[s].opposite&&(t+=a.width);for(var c=e;c>=0;c--){var d=h+e/10+n.config.yaxis[s].labels.offsetY-1;n.globals.isBarHorizontal&&(d=r*c),"heatmap"===n.config.chart.type&&(d+=r/2);var g=l.drawLine(t+i.offsetX-a.width+a.offsetX,d+a.offsetY,t+i.offsetX+a.offsetX,d+a.offsetY,a.color);o.add(g),h+=r}}}}]),t}(),U=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"scaleSvgNode",value:function(t,e){var i=parseFloat(t.getAttributeNS(null,"width")),a=parseFloat(t.getAttributeNS(null,"height"));t.setAttributeNS(null,"width",i*e),t.setAttributeNS(null,"height",a*e),t.setAttributeNS(null,"viewBox","0 0 "+i+" "+a)}},{key:"fixSvgStringForIe11",value:function(t){if(!y.isIE11())return t.replace(/ /g," ");var e=0,i=t.replace(/xmlns="http:\/\/www.w3.org\/2000\/svg"/g,(function(t){return 2==++e?'xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev"':t}));return(i=i.replace(/xmlns:NS\d+=""/g,"")).replace(/NS\d+:(\w+:\w+=")/g,"$1")}},{key:"getSvgString",value:function(t){null==t&&(t=1);var e=this.w.globals.dom.Paper.svg();if(1!==t){var i=this.w.globals.dom.Paper.node.cloneNode(!0);this.scaleSvgNode(i,t),e=(new XMLSerializer).serializeToString(i)}return this.fixSvgStringForIe11(e)}},{key:"cleanup",value:function(){var t=this.w,e=t.globals.dom.baseEl.getElementsByClassName("apexcharts-xcrosshairs"),i=t.globals.dom.baseEl.getElementsByClassName("apexcharts-ycrosshairs"),a=t.globals.dom.baseEl.querySelectorAll(".apexcharts-zoom-rect, .apexcharts-selection-rect");Array.prototype.forEach.call(a,(function(t){t.setAttribute("width",0)})),e&&e[0]&&(e[0].setAttribute("x",-500),e[0].setAttribute("x1",-500),e[0].setAttribute("x2",-500)),i&&i[0]&&(i[0].setAttribute("y",-100),i[0].setAttribute("y1",-100),i[0].setAttribute("y2",-100))}},{key:"svgUrl",value:function(){this.cleanup();var t=this.getSvgString(),e=new Blob([t],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(e)}},{key:"dataURI",value:function(t){var e=this;return new Promise((function(i){var a=e.w,s=t?t.scale||t.width/a.globals.svgWidth:1;e.cleanup();var r=document.createElement("canvas");r.width=a.globals.svgWidth*s,r.height=parseInt(a.globals.dom.elWrap.style.height,10)*s;var o="transparent"===a.config.chart.background?"#fff":a.config.chart.background,n=r.getContext("2d");n.fillStyle=o,n.fillRect(0,0,r.width*s,r.height*s);var l=e.getSvgString(s);if(window.canvg&&y.isIE11()){var h=window.canvg.Canvg.fromString(n,l,{ignoreClear:!0,ignoreDimensions:!0});h.start();var c=r.msToBlob();h.stop(),i({blob:c})}else{var d="data:image/svg+xml,"+encodeURIComponent(l),g=new Image;g.crossOrigin="anonymous",g.onload=function(){if(n.drawImage(g,0,0),r.msToBlob){var t=r.msToBlob();i({blob:t})}else{var e=r.toDataURL("image/png");i({imgURI:e})}},g.src=d}}))}},{key:"exportToSVG",value:function(){this.triggerDownload(this.svgUrl(),this.w.config.chart.toolbar.export.svg.filename,".svg")}},{key:"exportToPng",value:function(){var t=this;this.dataURI().then((function(e){var i=e.imgURI,a=e.blob;a?navigator.msSaveOrOpenBlob(a,t.w.globals.chartID+".png"):t.triggerDownload(i,t.w.config.chart.toolbar.export.png.filename,".png")}))}},{key:"exportToCSV",value:function(t){var e=this,i=t.series,a=t.fileName,s=t.columnDelimiter,r=void 0===s?",":s,o=t.lineDelimiter,n=void 0===o?"\n":o,l=this.w;i||(i=l.config.series);var h=[],c=[],d="",g=l.globals.series.map((function(t,e){return-1===l.globals.collapsedSeriesIndices.indexOf(e)?t:[]})),u=Math.max.apply(Math,b(i.map((function(t){return t.data?t.data.length:0})))),p=new j(this.ctx),f=new _(this.ctx),x=function(t){var i="";if(l.globals.axisCharts){if("category"===l.config.xaxis.type||l.config.xaxis.convertedCatToNumeric)if(l.globals.isBarHorizontal){var a=l.globals.yLabelFormatters[0],s=new V(e.ctx).getActiveConfigSeriesIndex();i=a(l.globals.labels[t],{seriesIndex:s,dataPointIndex:t,w:l})}else i=f.getLabel(l.globals.labels,l.globals.timescaleLabels,0,t).text;"datetime"===l.config.xaxis.type&&(l.config.xaxis.categories.length?i=l.config.xaxis.categories[t]:l.config.labels.length&&(i=l.config.labels[t]))}else i=l.config.labels[t];return Array.isArray(i)&&(i=i.join(" ")),y.isNumber(i)?i:i.split(r).join("")};h.push(l.config.chart.toolbar.export.csv.headerCategory),"boxPlot"===l.config.chart.type?(h.push("minimum"),h.push("q1"),h.push("median"),h.push("q3"),h.push("maximum")):"candlestick"===l.config.chart.type?(h.push("open"),h.push("high"),h.push("low"),h.push("close")):"rangeBar"===l.config.chart.type?(h.push("minimum"),h.push("maximum")):i.map((function(t,e){var i=(t.name?t.name:"series-".concat(e))+"";l.globals.axisCharts&&h.push(i.split(r).join("")?i.split(r).join(""):"series-".concat(e))})),l.globals.axisCharts||(h.push(l.config.chart.toolbar.export.csv.headerValue),c.push(h.join(r))),i.map((function(t,e){l.globals.axisCharts?function(t,e){if(h.length&&0===e&&c.push(h.join(r)),t.data){t.data=t.data.length&&t.data||b(Array(u)).map((function(){return""}));for(var a=0;a=10?l.config.chart.toolbar.export.csv.dateFormatter(s):y.isNumber(s)?s:s.split(r).join("")));for(var o=0;o0&&!a.globals.isBarHorizontal&&(this.xaxisLabels=a.globals.timescaleLabels.slice()),a.config.xaxis.overwriteCategories&&(this.xaxisLabels=a.config.xaxis.overwriteCategories),this.drawnLabels=[],this.drawnLabelsRects=[],"top"===a.config.xaxis.position?this.offY=0:this.offY=a.globals.gridHeight+1,this.offY=this.offY+a.config.xaxis.axisBorder.offsetY,this.isCategoryBarHorizontal="bar"===a.config.chart.type&&a.config.plotOptions.bar.horizontal,this.xaxisFontSize=a.config.xaxis.labels.style.fontSize,this.xaxisFontFamily=a.config.xaxis.labels.style.fontFamily,this.xaxisForeColors=a.config.xaxis.labels.style.colors,this.xaxisBorderWidth=a.config.xaxis.axisBorder.width,this.isCategoryBarHorizontal&&(this.xaxisBorderWidth=a.config.yaxis[0].axisBorder.width.toString()),this.xaxisBorderWidth.indexOf("%")>-1?this.xaxisBorderWidth=a.globals.gridWidth*parseInt(this.xaxisBorderWidth,10)/100:this.xaxisBorderWidth=parseInt(this.xaxisBorderWidth,10),this.xaxisBorderHeight=a.config.xaxis.axisBorder.height,this.yaxis=a.config.yaxis[0]}return h(t,[{key:"drawXaxis",value:function(){var t=this.w,e=new A(this.ctx),i=e.group({class:"apexcharts-xaxis",transform:"translate(".concat(t.config.xaxis.offsetX,", ").concat(t.config.xaxis.offsetY,")")}),a=e.group({class:"apexcharts-xaxis-texts-g",transform:"translate(".concat(t.globals.translateXAxisX,", ").concat(t.globals.translateXAxisY,")")});i.add(a);for(var s=[],r=0;r6&&void 0!==arguments[6]?arguments[6]:{},h=[],c=[],d=this.w,g=l.xaxisFontSize||this.xaxisFontSize,u=l.xaxisFontFamily||this.xaxisFontFamily,p=l.xaxisForeColors||this.xaxisForeColors,f=l.fontWeight||d.config.xaxis.labels.style.fontWeight,x=l.cssClass||d.config.xaxis.labels.style.cssClass,b=d.globals.padHorizontal,v=a.length,m="category"===d.config.xaxis.type?d.globals.dataPoints:v;if(0===m&&v>m&&(m=v),s){var y=m>1?m-1:m;o=d.globals.gridWidth/y,b=b+r(0,o)/2+d.config.xaxis.labels.offsetX}else o=d.globals.gridWidth/m,b=b+r(0,o)+d.config.xaxis.labels.offsetX;for(var w=function(s){var l=b-r(s,o)/2+d.config.xaxis.labels.offsetX;0===s&&1===v&&o/2===b&&1===m&&(l=d.globals.gridWidth/2);var y=n.axesUtils.getLabel(a,d.globals.timescaleLabels,l,s,h,g,t),w=28;if(d.globals.rotateXLabels&&t&&(w=22),d.config.xaxis.title.text&&"top"===d.config.xaxis.position&&(w+=parseFloat(d.config.xaxis.title.style.fontSize)+2),t||(w=w+parseFloat(g)+(d.globals.xAxisLabelsHeight-d.globals.xAxisGroupLabelsHeight)+(d.globals.rotateXLabels?10:0)),y=void 0!==d.config.xaxis.tickAmount&&"dataPoints"!==d.config.xaxis.tickAmount&&"datetime"!==d.config.xaxis.type?n.axesUtils.checkLabelBasedOnTickamount(s,y,v):n.axesUtils.checkForOverflowingLabels(s,y,v,h,c),d.config.xaxis.labels.show){var k=e.drawText({x:y.x,y:n.offY+d.config.xaxis.labels.offsetY+w-("top"===d.config.xaxis.position?d.globals.xAxisHeight+d.config.xaxis.axisTicks.height-2:0),text:y.text,textAnchor:"middle",fontWeight:y.isBold?600:f,fontSize:g,fontFamily:u,foreColor:Array.isArray(p)?t&&d.config.xaxis.convertedCatToNumeric?p[d.globals.minX+s-1]:p[s]:p,isPlainText:!1,cssClass:(t?"apexcharts-xaxis-label ":"apexcharts-xaxis-group-label ")+x});if(i.add(k),k.on("click",(function(t){if("function"==typeof d.config.chart.events.xAxisLabelClick){var e=Object.assign({},d,{labelIndex:s});d.config.chart.events.xAxisLabelClick(t,n.ctx,e)}})),t){var A=document.createElementNS(d.globals.SVGNS,"title");A.textContent=Array.isArray(y.text)?y.text.join(" "):y.text,k.node.appendChild(A),""!==y.text&&(h.push(y.text),c.push(y))}}sa.globals.gridWidth)){var r=this.offY+a.config.xaxis.axisTicks.offsetY;if(e=e+r+a.config.xaxis.axisTicks.height,"top"===a.config.xaxis.position&&(e=r-a.config.xaxis.axisTicks.height),a.config.xaxis.axisTicks.show){var o=new A(this.ctx).drawLine(t+a.config.xaxis.axisTicks.offsetX,r+a.config.xaxis.offsetY,s+a.config.xaxis.axisTicks.offsetX,e+a.config.xaxis.offsetY,a.config.xaxis.axisTicks.color);i.add(o),o.node.classList.add("apexcharts-xaxis-tick")}}}},{key:"getXAxisTicksPositions",value:function(){var t=this.w,e=[],i=this.xaxisLabels.length,a=t.globals.padHorizontal;if(t.globals.timescaleLabels.length>0)for(var s=0;s0){var h=s[s.length-1].getBBox(),c=s[0].getBBox();h.x<-20&&s[s.length-1].parentNode.removeChild(s[s.length-1]),c.x+c.width>t.globals.gridWidth&&!t.globals.isBarHorizontal&&s[0].parentNode.removeChild(s[0]);for(var d=0;d0&&(this.xaxisLabels=i.globals.timescaleLabels.slice())}return h(t,[{key:"drawGridArea",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=this.w,i=new A(this.ctx);null===t&&(t=i.group({class:"apexcharts-grid"}));var a=i.drawLine(e.globals.padHorizontal,1,e.globals.padHorizontal,e.globals.gridHeight,"transparent"),s=i.drawLine(e.globals.padHorizontal,e.globals.gridHeight,e.globals.gridWidth,e.globals.gridHeight,"transparent");return t.add(s),t.add(a),t}},{key:"drawGrid",value:function(){var t=null;return this.w.globals.axisCharts&&(t=this.renderGrid(),this.drawGridArea(t.el)),t}},{key:"createGridMask",value:function(){var t=this.w,e=t.globals,i=new A(this.ctx),a=Array.isArray(t.config.stroke.width)?0:t.config.stroke.width;if(Array.isArray(t.config.stroke.width)){var s=0;t.config.stroke.width.forEach((function(t){s=Math.max(s,t)})),a=s}e.dom.elGridRectMask=document.createElementNS(e.SVGNS,"clipPath"),e.dom.elGridRectMask.setAttribute("id","gridRectMask".concat(e.cuid)),e.dom.elGridRectMarkerMask=document.createElementNS(e.SVGNS,"clipPath"),e.dom.elGridRectMarkerMask.setAttribute("id","gridRectMarkerMask".concat(e.cuid)),e.dom.elForecastMask=document.createElementNS(e.SVGNS,"clipPath"),e.dom.elForecastMask.setAttribute("id","forecastMask".concat(e.cuid)),e.dom.elNonForecastMask=document.createElementNS(e.SVGNS,"clipPath"),e.dom.elNonForecastMask.setAttribute("id","nonForecastMask".concat(e.cuid));var r=t.config.chart.type,o=0,n=0;("bar"===r||"rangeBar"===r||"candlestick"===r||"boxPlot"===r||t.globals.comboBarCount>0)&&t.globals.isXNumeric&&!t.globals.isBarHorizontal&&(o=t.config.grid.padding.left,n=t.config.grid.padding.right,e.barPadForNumericAxis>o&&(o=e.barPadForNumericAxis,n=e.barPadForNumericAxis)),e.dom.elGridRect=i.drawRect(-a/2-o-2,-a/2,e.gridWidth+a+n+o+4,e.gridHeight+a,0,"#fff");var l=t.globals.markers.largestSize+1;e.dom.elGridRectMarker=i.drawRect(2*-l,2*-l,e.gridWidth+4*l,e.gridHeight+4*l,0,"#fff"),e.dom.elGridRectMask.appendChild(e.dom.elGridRect.node),e.dom.elGridRectMarkerMask.appendChild(e.dom.elGridRectMarker.node);var h=e.dom.baseEl.querySelector("defs");h.appendChild(e.dom.elGridRectMask),h.appendChild(e.dom.elForecastMask),h.appendChild(e.dom.elNonForecastMask),h.appendChild(e.dom.elGridRectMarkerMask)}},{key:"_drawGridLines",value:function(t){var e=t.i,i=t.x1,a=t.y1,s=t.x2,r=t.y2,o=t.xCount,n=t.parent,l=this.w;if(!(0===e&&l.globals.skipFirstTimelinelabel||e===o-1&&l.globals.skipLastTimelinelabel&&!l.config.xaxis.labels.formatter||"radar"===l.config.chart.type)){l.config.grid.xaxis.lines.show&&this._drawGridLine({i:e,x1:i,y1:a,x2:s,y2:r,xCount:o,parent:n});var h=0;if(l.globals.hasXaxisGroups&&"between"===l.config.xaxis.tickPlacement){var c=l.globals.groups;if(c){for(var d=0,g=0;d2));s++);return!t.globals.isBarHorizontal||this.isRangeBar?(i=this.xaxisLabels.length,this.isRangeBar&&(i--,a=t.globals.labels.length,t.config.xaxis.tickAmount&&t.config.xaxis.labels.formatter&&(i=t.config.xaxis.tickAmount)),this._drawXYLines({xCount:i,tickAmount:a})):(i=a,a=t.globals.xTickAmount,this._drawInvertedXYLines({xCount:i,tickAmount:a})),this.drawGridBands(i,a),{el:this.elg,elGridBorders:this.elGridBorders,xAxisTickWidth:t.globals.gridWidth/i}}},{key:"drawGridBands",value:function(t,e){var i=this.w;if(void 0!==i.config.grid.row.colors&&i.config.grid.row.colors.length>0)for(var a=0,s=i.globals.gridHeight/e,r=i.globals.gridWidth,o=0,n=0;o=i.config.grid.row.colors.length&&(n=0),this._drawGridBandRect({c:n,x1:0,y1:a,x2:r,y2:s,type:"row"}),a+=i.globals.gridHeight/e;if(void 0!==i.config.grid.column.colors&&i.config.grid.column.colors.length>0)for(var l=i.globals.isBarHorizontal||"category"!==i.config.xaxis.type&&!i.config.xaxis.convertedCatToNumeric?t:t-1,h=i.globals.padHorizontal,c=i.globals.padHorizontal+i.globals.gridWidth/l,d=i.globals.gridHeight,g=0,u=0;g=i.config.grid.column.colors.length&&(u=0),this._drawGridBandRect({c:u,x1:h,y1:0,x2:c,y2:d,type:"column"}),h+=i.globals.gridWidth/l}}]),t}(),$=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"niceScale",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4?arguments[4]:void 0,r=this.w,o=Math.abs(e-t);if("dataPoints"===(i=this._adjustTicksForSmallRange(i,a,o))&&(i=r.globals.dataPoints-1),t===Number.MIN_VALUE&&0===e||!y.isNumber(t)&&!y.isNumber(e)||t===Number.MIN_VALUE&&e===-Number.MAX_VALUE)return t=0,e=i,this.linearScale(t,e,i);t>e?(console.warn("axis.min cannot be greater than axis.max"),e=t+.1):t===e&&(t=0===t?0:t-.5,e=0===e?2:e+.5);var n=[];o<1&&s&&("candlestick"===r.config.chart.type||"candlestick"===r.config.series[a].type||"boxPlot"===r.config.chart.type||"boxPlot"===r.config.series[a].type||r.globals.isRangeData)&&(e*=1.01);var l=i+1;l<2?l=2:l>2&&(l-=2);var h=o/l,c=Math.floor(y.log10(h)),d=Math.pow(10,c),g=Math.round(h/d);g<1&&(g=1);var u=g*d,p=u*Math.floor(t/u),f=u*Math.ceil(e/u),x=p;if(s&&o>2){for(;n.push(y.stripNumber(x,7)),!((x+=u)>f););return{result:n,niceMin:n[0],niceMax:n[n.length-1]}}var b=t;(n=[]).push(y.stripNumber(b,7));for(var v=Math.abs(e-t)/i,m=0;m<=i;m++)b+=v,n.push(b);return n[n.length-2]>=e&&n.pop(),{result:n,niceMin:n[0],niceMax:n[n.length-1]}}},{key:"linearScale",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,a=arguments.length>3?arguments[3]:void 0,s=Math.abs(e-t);"dataPoints"===(i=this._adjustTicksForSmallRange(i,a,s))&&(i=this.w.globals.dataPoints-1);var r=s/i;i===Number.MAX_VALUE&&(i=10,r=1);for(var o=[],n=t;i>=0;)o.push(n),n+=r,i-=1;return{result:o,niceMin:o[0],niceMax:o[o.length-1]}}},{key:"logarithmicScaleNice",value:function(t,e,i){e<=0&&(e=Math.max(t,i)),t<=0&&(t=Math.min(e,i));for(var a=[],s=Math.ceil(Math.log(e)/Math.log(i)+1),r=Math.floor(Math.log(t)/Math.log(i));r5)a.allSeriesCollapsed=!1,a.yAxisScale[t]=this.logarithmicScale(e,i,r.logBase),a.yAxisScale[t]=r.forceNiceScale?this.logarithmicScaleNice(e,i,r.logBase):this.logarithmicScale(e,i,r.logBase);else if(i!==-Number.MAX_VALUE&&y.isNumber(i))if(a.allSeriesCollapsed=!1,void 0===r.min&&void 0===r.max||r.forceNiceScale){var n=void 0===s.yaxis[t].max&&void 0===s.yaxis[t].min||s.yaxis[t].forceNiceScale;a.yAxisScale[t]=this.niceScale(e,i,r.tickAmount?r.tickAmount:o<5&&o>1?o+1:5,t,n)}else a.yAxisScale[t]=this.linearScale(e,i,r.tickAmount,t);else a.yAxisScale[t]=this.linearScale(0,5,5)}},{key:"setXScale",value:function(t,e){var i=this.w,a=i.globals,s=i.config.xaxis,r=Math.abs(e-t);return e!==-Number.MAX_VALUE&&y.isNumber(e)?a.xAxisScale=this.linearScale(t,e,s.tickAmount?s.tickAmount:r<5&&r>1?r+1:5,0):a.xAxisScale=this.linearScale(0,5,5),a.xAxisScale}},{key:"setMultipleYScales",value:function(){var t=this,e=this.w.globals,i=this.w.config,a=e.minYArr.concat([]),s=e.maxYArr.concat([]),r=[];i.yaxis.forEach((function(e,o){var n=o;i.series.forEach((function(t,i){t.name===e.seriesName&&(n=i,o!==i?r.push({index:i,similarIndex:o,alreadyExists:!0}):r.push({index:i}))}));var l=a[n],h=s[n];t.setYScaleForIndex(o,l,h)})),this.sameScaleInMultipleAxes(a,s,r)}},{key:"sameScaleInMultipleAxes",value:function(t,e,i){var a=this,s=this.w.config,r=this.w.globals,o=[];i.forEach((function(t){t.alreadyExists&&(void 0===o[t.index]&&(o[t.index]=[]),o[t.index].push(t.index),o[t.index].push(t.similarIndex))})),r.yAxisSameScaleIndices=o,o.forEach((function(t,e){o.forEach((function(i,a){var s,r;e!==a&&(s=t,r=i,s.filter((function(t){return-1!==r.indexOf(t)}))).length>0&&(o[e]=o[e].concat(o[a]))}))}));var n=o.map((function(t){return t.filter((function(e,i){return t.indexOf(e)===i}))})).map((function(t){return t.sort()}));o=o.filter((function(t){return!!t}));var l=n.slice(),h=l.map((function(t){return JSON.stringify(t)}));l=l.filter((function(t,e){return h.indexOf(JSON.stringify(t))===e}));var c=[],d=[];t.forEach((function(t,i){l.forEach((function(a,s){a.indexOf(i)>-1&&(void 0===c[s]&&(c[s]=[],d[s]=[]),c[s].push({key:i,value:t}),d[s].push({key:i,value:e[i]}))}))}));var g=Array.apply(null,Array(l.length)).map(Number.prototype.valueOf,Number.MIN_VALUE),u=Array.apply(null,Array(l.length)).map(Number.prototype.valueOf,-Number.MAX_VALUE);c.forEach((function(t,e){t.forEach((function(t,i){g[e]=Math.min(t.value,g[e])}))})),d.forEach((function(t,e){t.forEach((function(t,i){u[e]=Math.max(t.value,u[e])}))})),t.forEach((function(t,e){d.forEach((function(t,i){var o=g[i],n=u[i];s.chart.stacked&&(n=0,t.forEach((function(t,e){t.value!==-Number.MAX_VALUE&&(n+=t.value),o!==Number.MIN_VALUE&&(o+=c[i][e].value)}))),t.forEach((function(i,l){t[l].key===e&&(void 0!==s.yaxis[e].min&&(o="function"==typeof s.yaxis[e].min?s.yaxis[e].min(r.minY):s.yaxis[e].min),void 0!==s.yaxis[e].max&&(n="function"==typeof s.yaxis[e].max?s.yaxis[e].max(r.maxY):s.yaxis[e].max),a.setYScaleForIndex(e,o,n))}))}))}))}},{key:"autoScaleY",value:function(t,e,i){t||(t=this);var a=t.w;if(a.globals.isMultipleYAxis||a.globals.collapsedSeries.length)return console.warn("autoScaleYaxis is not supported in a multi-yaxis chart."),e;var s=a.globals.seriesX[0],r=a.config.chart.stacked;return e.forEach((function(t,o){for(var n=0,l=0;l=i.xaxis.min){n=l;break}var h,c,d=a.globals.minYArr[o],g=a.globals.maxYArr[o],u=a.globals.stackedSeriesTotals;a.globals.series.forEach((function(o,l){var p=o[n];r?(p=u[n],h=c=p,u.forEach((function(t,e){s[e]<=i.xaxis.max&&s[e]>=i.xaxis.min&&(t>c&&null!==t&&(c=t),o[e]=i.xaxis.min){var r=t,o=t;a.globals.series.forEach((function(i,a){null!==t&&(r=Math.min(i[e],r),o=Math.max(i[e],o))})),o>c&&null!==o&&(c=o),rd&&(h=d),e.length>1?(e[l].min=void 0===t.min?h:t.min,e[l].max=void 0===t.max?c:t.max):(e[0].min=void 0===t.min?h:t.min,e[0].max=void 0===t.max?c:t.max)}))})),e}}]),t}(),J=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.scales=new $(e)}return h(t,[{key:"init",value:function(){this.setYRange(),this.setXRange(),this.setZRange()}},{key:"getMinYMaxY",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.MAX_VALUE,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-Number.MAX_VALUE,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=this.w.config,r=this.w.globals,o=-Number.MAX_VALUE,n=Number.MIN_VALUE;null===a&&(a=t+1);var l=r.series,h=l,c=l;"candlestick"===s.chart.type?(h=r.seriesCandleL,c=r.seriesCandleH):"boxPlot"===s.chart.type?(h=r.seriesCandleO,c=r.seriesCandleC):r.isRangeData&&(h=r.seriesRangeStart,c=r.seriesRangeEnd);for(var d=t;dh[d][g]&&h[d][g]<0&&(n=h[d][g])):r.hasNullValues=!0}}return"rangeBar"===s.chart.type&&r.seriesRangeStart.length&&r.isBarHorizontal&&(n=e),"bar"===s.chart.type&&(n<0&&o<0&&(o=0),n===Number.MIN_VALUE&&(n=0)),{minY:n,maxY:o,lowestY:e,highestY:i}}},{key:"setYRange",value:function(){var t=this.w.globals,e=this.w.config;t.maxY=-Number.MAX_VALUE,t.minY=Number.MIN_VALUE;var i=Number.MAX_VALUE;if(t.isMultipleYAxis)for(var a=0;a=0&&i<=10||void 0!==e.yaxis[0].min||void 0!==e.yaxis[0].max)&&(o=0),t.minY=i-5*o/100,i>0&&t.minY<0&&(t.minY=0),t.maxY=t.maxY+5*o/100}return e.yaxis.forEach((function(e,i){void 0!==e.max&&("number"==typeof e.max?t.maxYArr[i]=e.max:"function"==typeof e.max&&(t.maxYArr[i]=e.max(t.isMultipleYAxis?t.maxYArr[i]:t.maxY)),t.maxY=t.maxYArr[i]),void 0!==e.min&&("number"==typeof e.min?t.minYArr[i]=e.min:"function"==typeof e.min&&(t.minYArr[i]=e.min(t.isMultipleYAxis?t.minYArr[i]===Number.MIN_VALUE?0:t.minYArr[i]:t.minY)),t.minY=t.minYArr[i])})),t.isBarHorizontal&&["min","max"].forEach((function(i){void 0!==e.xaxis[i]&&"number"==typeof e.xaxis[i]&&("min"===i?t.minY=e.xaxis[i]:t.maxY=e.xaxis[i])})),t.isMultipleYAxis?(this.scales.setMultipleYScales(),t.minY=i,t.yAxisScale.forEach((function(e,i){t.minYArr[i]=e.niceMin,t.maxYArr[i]=e.niceMax}))):(this.scales.setYScaleForIndex(0,t.minY,t.maxY),t.minY=t.yAxisScale[0].niceMin,t.maxY=t.yAxisScale[0].niceMax,t.minYArr[0]=t.yAxisScale[0].niceMin,t.maxYArr[0]=t.yAxisScale[0].niceMax),{minY:t.minY,maxY:t.maxY,minYArr:t.minYArr,maxYArr:t.maxYArr,yAxisScale:t.yAxisScale}}},{key:"setXRange",value:function(){var t=this.w.globals,e=this.w.config,i="numeric"===e.xaxis.type||"datetime"===e.xaxis.type||"category"===e.xaxis.type&&!t.noLabelsProvided||t.noLabelsProvided||t.isXNumeric;if(t.isXNumeric&&function(){for(var e=0;et.dataPoints&&0!==t.dataPoints&&(a=t.dataPoints-1)):"dataPoints"===e.xaxis.tickAmount?(t.series.length>1&&(a=t.series[t.maxValsInArrayIndex].length-1),t.isXNumeric&&(a=t.maxX-t.minX-1)):a=e.xaxis.tickAmount,t.xTickAmount=a,void 0!==e.xaxis.max&&"number"==typeof e.xaxis.max&&(t.maxX=e.xaxis.max),void 0!==e.xaxis.min&&"number"==typeof e.xaxis.min&&(t.minX=e.xaxis.min),void 0!==e.xaxis.range&&(t.minX=t.maxX-e.xaxis.range),t.minX!==Number.MAX_VALUE&&t.maxX!==-Number.MAX_VALUE)if(e.xaxis.convertedCatToNumeric&&!t.dataFormatXNumeric){for(var s=[],r=t.minX-1;r0&&(t.xAxisScale=this.scales.linearScale(1,t.labels.length,a-1),t.seriesX=t.labels.slice());i&&(t.labels=t.xAxisScale.result.slice())}return t.isBarHorizontal&&t.labels.length&&(t.xTickAmount=t.labels.length),this._handleSingleDataPoint(),this._getMinXDiff(),{minX:t.minX,maxX:t.maxX}}},{key:"setZRange",value:function(){var t=this.w.globals;if(t.isDataXYZ)for(var e=0;e0){var s=e-a[i-1];s>0&&(t.minXDiff=Math.min(s,t.minXDiff))}})),1!==t.dataPoints&&t.minXDiff!==Number.MAX_VALUE||(t.minXDiff=.5)}))}},{key:"_setStackedMinMax",value:function(){var t=this,e=this.w.globals;if(e.series.length){var i=e.seriesGroups;i.length||(i=[this.w.config.series.map((function(t){return t.name}))]);var a={},s={};i.forEach((function(i){a[i]=[],s[i]=[],t.w.config.series.map((function(t,e){return i.indexOf(t.name)>-1?e:null})).filter((function(t){return null!==t})).forEach((function(t){for(var r=0;r0?a[i][r]+=parseFloat(e.series[t][r])+1e-4:s[i][r]+=parseFloat(e.series[t][r]))}))})),Object.entries(a).forEach((function(t){var i=x(t,1)[0];a[i].forEach((function(t,r){e.maxY=Math.max(e.maxY,a[i][r]),e.minY=Math.min(e.minY,s[i][r])}))}))}}}]),t}(),Q=function(){function t(e,i){n(this,t),this.ctx=e,this.elgrid=i,this.w=e.w;var a=this.w;this.xaxisFontSize=a.config.xaxis.labels.style.fontSize,this.axisFontFamily=a.config.xaxis.labels.style.fontFamily,this.xaxisForeColors=a.config.xaxis.labels.style.colors,this.isCategoryBarHorizontal="bar"===a.config.chart.type&&a.config.plotOptions.bar.horizontal,this.xAxisoffX=0,"bottom"===a.config.xaxis.position&&(this.xAxisoffX=a.globals.gridHeight),this.drawnLabels=[],this.axesUtils=new _(e)}return h(t,[{key:"drawYaxis",value:function(t){var e=this,i=this.w,a=new A(this.ctx),s=i.config.yaxis[t].labels.style,r=s.fontSize,o=s.fontFamily,n=s.fontWeight,l=a.group({class:"apexcharts-yaxis",rel:t,transform:"translate("+i.globals.translateYAxisX[t]+", 0)"});if(this.axesUtils.isYAxisHidden(t))return l;var h=a.group({class:"apexcharts-yaxis-texts-g"});l.add(h);var c=i.globals.yAxisScale[t].result.length-1,d=i.globals.gridHeight/c,g=i.globals.translateY,u=i.globals.yLabelFormatters[t],p=i.globals.yAxisScale[t].result.slice();p=this.axesUtils.checkForReversedLabels(t,p);var f="";if(i.config.yaxis[t].labels.show)for(var x=function(l){var x=p[l];x=u(x,l,i);var b=i.config.yaxis[t].labels.padding;i.config.yaxis[t].opposite&&0!==i.config.yaxis.length&&(b*=-1);var v="end";i.config.yaxis[t].opposite&&(v="start"),"left"===i.config.yaxis[t].labels.align?v="start":"center"===i.config.yaxis[t].labels.align?v="middle":"right"===i.config.yaxis[t].labels.align&&(v="end");var m=e.axesUtils.getYAxisForeColor(s.colors,t),y=a.drawText({x:b,y:g+c/10+i.config.yaxis[t].labels.offsetY+1,text:x,textAnchor:v,fontSize:r,fontFamily:o,fontWeight:n,maxWidth:i.config.yaxis[t].labels.maxWidth,foreColor:Array.isArray(m)?m[l]:m,isPlainText:!1,cssClass:"apexcharts-yaxis-label "+s.cssClass});l===c&&(f=y),h.add(y);var w=document.createElementNS(i.globals.SVGNS,"title");if(w.textContent=Array.isArray(x)?x.join(" "):x,y.node.appendChild(w),0!==i.config.yaxis[t].labels.rotate){var k=a.rotateAroundCenter(f.node),A=a.rotateAroundCenter(y.node);y.node.setAttribute("transform","rotate(".concat(i.config.yaxis[t].labels.rotate," ").concat(k.x," ").concat(A.y,")"))}g+=d},b=c;b>=0;b--)x(b);if(void 0!==i.config.yaxis[t].title.text){var v=a.group({class:"apexcharts-yaxis-title"}),m=0;i.config.yaxis[t].opposite&&(m=i.globals.translateYAxisX[t]);var y=a.drawText({x:m,y:i.globals.gridHeight/2+i.globals.translateY+i.config.yaxis[t].title.offsetY,text:i.config.yaxis[t].title.text,textAnchor:"end",foreColor:i.config.yaxis[t].title.style.color,fontSize:i.config.yaxis[t].title.style.fontSize,fontWeight:i.config.yaxis[t].title.style.fontWeight,fontFamily:i.config.yaxis[t].title.style.fontFamily,cssClass:"apexcharts-yaxis-title-text "+i.config.yaxis[t].title.style.cssClass});v.add(y),l.add(v)}var w=i.config.yaxis[t].axisBorder,k=31+w.offsetX;if(i.config.yaxis[t].opposite&&(k=-31-w.offsetX),w.show){var S=a.drawLine(k,i.globals.translateY+w.offsetY-2,k,i.globals.gridHeight+i.globals.translateY+w.offsetY+2,w.color,0,w.width);l.add(S)}return i.config.yaxis[t].axisTicks.show&&this.axesUtils.drawYAxisTicks(k,c,w,i.config.yaxis[t].axisTicks,t,d,l),l}},{key:"drawYaxisInversed",value:function(t){var e=this.w,i=new A(this.ctx),a=i.group({class:"apexcharts-xaxis apexcharts-yaxis-inversed"}),s=i.group({class:"apexcharts-xaxis-texts-g",transform:"translate(".concat(e.globals.translateXAxisX,", ").concat(e.globals.translateXAxisY,")")});a.add(s);var r=e.globals.yAxisScale[t].result.length-1,o=e.globals.gridWidth/r+.1,n=o+e.config.xaxis.labels.offsetX,l=e.globals.xLabelFormatter,h=e.globals.yAxisScale[t].result.slice(),c=e.globals.timescaleLabels;c.length>0&&(this.xaxisLabels=c.slice(),r=(h=c.slice()).length),h=this.axesUtils.checkForReversedLabels(t,h);var d=c.length;if(e.config.xaxis.labels.show)for(var g=d?0:r;d?g=0;d?g++:g--){var u=h[g];u=l(u,g,e);var p=e.globals.gridWidth+e.globals.padHorizontal-(n-o+e.config.xaxis.labels.offsetX);if(c.length){var f=this.axesUtils.getLabel(h,c,p,g,this.drawnLabels,this.xaxisFontSize);p=f.x,u=f.text,this.drawnLabels.push(f.text),0===g&&e.globals.skipFirstTimelinelabel&&(u=""),g===h.length-1&&e.globals.skipLastTimelinelabel&&(u="")}var x=i.drawText({x:p,y:this.xAxisoffX+e.config.xaxis.labels.offsetY+30-("top"===e.config.xaxis.position?e.globals.xAxisHeight+e.config.xaxis.axisTicks.height-2:0),text:u,textAnchor:"middle",foreColor:Array.isArray(this.xaxisForeColors)?this.xaxisForeColors[t]:this.xaxisForeColors,fontSize:this.xaxisFontSize,fontFamily:this.xaxisFontFamily,fontWeight:e.config.xaxis.labels.style.fontWeight,isPlainText:!1,cssClass:"apexcharts-xaxis-label "+e.config.xaxis.labels.style.cssClass});s.add(x),x.tspan(u);var b=document.createElementNS(e.globals.SVGNS,"title");b.textContent=u,x.node.appendChild(b),n+=o}return this.inversedYAxisTitleText(a),this.inversedYAxisBorder(a),a}},{key:"inversedYAxisBorder",value:function(t){var e=this.w,i=new A(this.ctx),a=e.config.xaxis.axisBorder;if(a.show){var s=0;"bar"===e.config.chart.type&&e.globals.isXNumeric&&(s-=15);var r=i.drawLine(e.globals.padHorizontal+s+a.offsetX,this.xAxisoffX,e.globals.gridWidth,this.xAxisoffX,a.color,0,a.height);this.elgrid&&this.elgrid.elGridBorders&&e.config.grid.show?this.elgrid.elGridBorders.add(r):t.add(r)}}},{key:"inversedYAxisTitleText",value:function(t){var e=this.w,i=new A(this.ctx);if(void 0!==e.config.xaxis.title.text){var a=i.group({class:"apexcharts-xaxis-title apexcharts-yaxis-title-inversed"}),s=i.drawText({x:e.globals.gridWidth/2+e.config.xaxis.title.offsetX,y:this.xAxisoffX+parseFloat(this.xaxisFontSize)+parseFloat(e.config.xaxis.title.style.fontSize)+e.config.xaxis.title.offsetY+20,text:e.config.xaxis.title.text,textAnchor:"middle",fontSize:e.config.xaxis.title.style.fontSize,fontFamily:e.config.xaxis.title.style.fontFamily,fontWeight:e.config.xaxis.title.style.fontWeight,foreColor:e.config.xaxis.title.style.color,cssClass:"apexcharts-xaxis-title-text "+e.config.xaxis.title.style.cssClass});a.add(s),t.add(a)}}},{key:"yAxisTitleRotate",value:function(t,e){var i=this.w,a=new A(this.ctx),s={width:0,height:0},r={width:0,height:0},o=i.globals.dom.baseEl.querySelector(" .apexcharts-yaxis[rel='".concat(t,"'] .apexcharts-yaxis-texts-g"));null!==o&&(s=o.getBoundingClientRect());var n=i.globals.dom.baseEl.querySelector(".apexcharts-yaxis[rel='".concat(t,"'] .apexcharts-yaxis-title text"));if(null!==n&&(r=n.getBoundingClientRect()),null!==n){var l=this.xPaddingForYAxisTitle(t,s,r,e);n.setAttribute("x",l.xPos-(e?10:0))}if(null!==n){var h=a.rotateAroundCenter(n);n.setAttribute("transform","rotate(".concat(e?-1*i.config.yaxis[t].title.rotate:i.config.yaxis[t].title.rotate," ").concat(h.x," ").concat(h.y,")"))}}},{key:"xPaddingForYAxisTitle",value:function(t,e,i,a){var s=this.w,r=0,o=0,n=10;return void 0===s.config.yaxis[t].title.text||t<0?{xPos:o,padd:0}:(a?(o=e.width+s.config.yaxis[t].title.offsetX+i.width/2+n/2,0===(r+=1)&&(o-=n/2)):(o=-1*e.width+s.config.yaxis[t].title.offsetX+n/2+i.width/2,s.globals.isBarHorizontal&&(n=25,o=-1*e.width-s.config.yaxis[t].title.offsetX-n)),{xPos:o,padd:n})}},{key:"setYAxisXPosition",value:function(t,e){var i=this.w,a=0,s=0,r=18,o=1;i.config.yaxis.length>1&&(this.multipleYs=!0),i.config.yaxis.map((function(n,l){var h=i.globals.ignoreYAxisIndexes.indexOf(l)>-1||!n.show||n.floating||0===t[l].width,c=t[l].width+e[l].width;n.opposite?i.globals.isBarHorizontal?(s=i.globals.gridWidth+i.globals.translateX-1,i.globals.translateYAxisX[l]=s-n.labels.offsetX):(s=i.globals.gridWidth+i.globals.translateX+o,h||(o=o+c+20),i.globals.translateYAxisX[l]=s-n.labels.offsetX+20):(a=i.globals.translateX-r,h||(r=r+c+20),i.globals.translateYAxisX[l]=a+n.labels.offsetX)}))}},{key:"setYAxisTextAlignments",value:function(){var t=this.w,e=t.globals.dom.baseEl.getElementsByClassName("apexcharts-yaxis");(e=y.listToArray(e)).forEach((function(e,i){var a=t.config.yaxis[i];if(a&&!a.floating&&void 0!==a.labels.align){var s=t.globals.dom.baseEl.querySelector(".apexcharts-yaxis[rel='".concat(i,"'] .apexcharts-yaxis-texts-g")),r=t.globals.dom.baseEl.querySelectorAll(".apexcharts-yaxis[rel='".concat(i,"'] .apexcharts-yaxis-label"));r=y.listToArray(r);var o=s.getBoundingClientRect();"left"===a.labels.align?(r.forEach((function(t,e){t.setAttribute("text-anchor","start")})),a.opposite||s.setAttribute("transform","translate(-".concat(o.width,", 0)"))):"center"===a.labels.align?(r.forEach((function(t,e){t.setAttribute("text-anchor","middle")})),s.setAttribute("transform","translate(".concat(o.width/2*(a.opposite?1:-1),", 0)"))):"right"===a.labels.align&&(r.forEach((function(t,e){t.setAttribute("text-anchor","end")})),a.opposite&&s.setAttribute("transform","translate(".concat(o.width,", 0)")))}}))}}]),t}(),K=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.documentEvent=y.bind(this.documentEvent,this)}return h(t,[{key:"addEventListener",value:function(t,e){var i=this.w;i.globals.events.hasOwnProperty(t)?i.globals.events[t].push(e):i.globals.events[t]=[e]}},{key:"removeEventListener",value:function(t,e){var i=this.w;if(i.globals.events.hasOwnProperty(t)){var a=i.globals.events[t].indexOf(e);-1!==a&&i.globals.events[t].splice(a,1)}}},{key:"fireEvent",value:function(t,e){var i=this.w;if(i.globals.events.hasOwnProperty(t)){e&&e.length||(e=[]);for(var a=i.globals.events[t],s=a.length,r=0;r0&&(e=this.w.config.chart.locales.concat(window.Apex.chart.locales));var i=e.filter((function(e){return e.name===t}))[0];if(!i)throw new Error("Wrong locale name provided. Please make sure you set the correct locale name in options");var a=y.extend(I,i);this.w.globals.locale=a.options}}]),t}(),et=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"drawAxis",value:function(t,e){var i,a,s=this,r=this.w.globals,o=this.w.config,n=new q(this.ctx,e),l=new Q(this.ctx,e);r.axisCharts&&"radar"!==t&&(r.isBarHorizontal?(a=l.drawYaxisInversed(0),i=n.drawXaxisInversed(0),r.dom.elGraphical.add(i),r.dom.elGraphical.add(a)):(i=n.drawXaxis(),r.dom.elGraphical.add(i),o.yaxis.map((function(t,e){if(-1===r.ignoreYAxisIndexes.indexOf(e)&&(a=l.drawYaxis(e),r.dom.Paper.add(a),"back"===s.w.config.grid.position)){var i=r.dom.Paper.children()[1];i.remove(),r.dom.Paper.add(i)}}))))}}]),t}(),it=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"drawXCrosshairs",value:function(){var t=this.w,e=new A(this.ctx),i=new k(this.ctx),a=t.config.xaxis.crosshairs.fill.gradient,s=t.config.xaxis.crosshairs.dropShadow,r=t.config.xaxis.crosshairs.fill.type,o=a.colorFrom,n=a.colorTo,l=a.opacityFrom,h=a.opacityTo,c=a.stops,d=s.enabled,g=s.left,u=s.top,p=s.blur,f=s.color,x=s.opacity,b=t.config.xaxis.crosshairs.fill.color;if(t.config.xaxis.crosshairs.show){"gradient"===r&&(b=e.drawGradient("vertical",o,n,l,h,null,c,null));var v=e.drawRect();1===t.config.xaxis.crosshairs.width&&(v=e.drawLine());var m=t.globals.gridHeight;(!y.isNumber(m)||m<0)&&(m=0);var w=t.config.xaxis.crosshairs.width;(!y.isNumber(w)||w<0)&&(w=0),v.attr({class:"apexcharts-xcrosshairs",x:0,y:0,y2:m,width:w,height:m,fill:b,filter:"none","fill-opacity":t.config.xaxis.crosshairs.opacity,stroke:t.config.xaxis.crosshairs.stroke.color,"stroke-width":t.config.xaxis.crosshairs.stroke.width,"stroke-dasharray":t.config.xaxis.crosshairs.stroke.dashArray}),d&&(v=i.dropShadow(v,{left:g,top:u,blur:p,color:f,opacity:x})),t.globals.dom.elGraphical.add(v)}}},{key:"drawYCrosshairs",value:function(){var t=this.w,e=new A(this.ctx),i=t.config.yaxis[0].crosshairs,a=t.globals.barPadForNumericAxis;if(t.config.yaxis[0].crosshairs.show){var s=e.drawLine(-a,0,t.globals.gridWidth+a,0,i.stroke.color,i.stroke.dashArray,i.stroke.width);s.attr({class:"apexcharts-ycrosshairs"}),t.globals.dom.elGraphical.add(s)}var r=e.drawLine(-a,0,t.globals.gridWidth+a,0,i.stroke.color,0,0);r.attr({class:"apexcharts-ycrosshairs-hidden"}),t.globals.dom.elGraphical.add(r)}}]),t}(),at=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"checkResponsiveConfig",value:function(t){var e=this,i=this.w,a=i.config;if(0!==a.responsive.length){var s=a.responsive.slice();s.sort((function(t,e){return t.breakpoint>e.breakpoint?1:e.breakpoint>t.breakpoint?-1:0})).reverse();var r=new O({}),o=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=s[0].breakpoint,o=window.innerWidth>0?window.innerWidth:screen.width;if(o>a){var n=S.extendArrayProps(r,i.globals.initialConfig,i);t=y.extend(n,t),t=y.extend(i.config,t),e.overrideResponsiveOptions(t)}else for(var l=0;l0&&"function"==typeof i.config.colors[0]&&(i.globals.colors=i.config.series.map((function(t,a){var s=i.config.colors[a];return s||(s=i.config.colors[0]),"function"==typeof s?(e.isColorFn=!0,s({value:i.globals.axisCharts?i.globals.series[a][0]?i.globals.series[a][0]:0:i.globals.series[a],seriesIndex:a,dataPointIndex:a,w:i})):s})))),i.globals.seriesColors.map((function(t,e){t&&(i.globals.colors[e]=t)})),i.config.theme.monochrome.enabled){var s=[],r=i.globals.series.length;(this.isBarDistributed||this.isHeatmapDistributed)&&(r=i.globals.series[0].length*i.globals.series.length);for(var o=i.config.theme.monochrome.color,n=1/(r/i.config.theme.monochrome.shadeIntensity),l=i.config.theme.monochrome.shadeTo,h=0,c=0;c2&&void 0!==arguments[2]?arguments[2]:null,a=this.w,s=e||a.globals.series.length;if(null===i&&(i=this.isBarDistributed||this.isHeatmapDistributed||"heatmap"===a.config.chart.type&&a.config.plotOptions.heatmap.colorScale.inverse),i&&a.globals.series.length&&(s=a.globals.series[a.globals.maxValsInArrayIndex].length*a.globals.series.length),t.lengtht.globals.svgWidth&&(this.dCtx.lgRect.width=t.globals.svgWidth/1.5),this.dCtx.lgRect}},{key:"getLargestStringFromMultiArr",value:function(t,e){var i=t;if(this.w.globals.isMultiLineX){var a=e.map((function(t,e){return Array.isArray(t)?t.length:1})),s=Math.max.apply(Math,b(a));i=e[a.indexOf(s)]}return i}}]),t}(),nt=function(){function t(e){n(this,t),this.w=e.w,this.dCtx=e}return h(t,[{key:"getxAxisLabelsCoords",value:function(){var t,e=this.w,i=e.globals.labels.slice();if(e.config.xaxis.convertedCatToNumeric&&0===i.length&&(i=e.globals.categoryLabels),e.globals.timescaleLabels.length>0){var a=this.getxAxisTimeScaleLabelsCoords();t={width:a.width,height:a.height},e.globals.rotateXLabels=!1}else{this.dCtx.lgWidthForSideLegends="left"!==e.config.legend.position&&"right"!==e.config.legend.position||e.config.legend.floating?0:this.dCtx.lgRect.width;var s=e.globals.xLabelFormatter,r=y.getLargestStringFromArr(i),o=this.dCtx.dimHelpers.getLargestStringFromMultiArr(r,i);e.globals.isBarHorizontal&&(o=r=e.globals.yAxisScale[0].result.reduce((function(t,e){return t.length>e.length?t:e}),0));var n=new E(this.dCtx.ctx),l=r;r=n.xLabelFormat(s,r,l,{i:void 0,dateFormatter:new z(this.dCtx.ctx).formatDate,w:e}),o=n.xLabelFormat(s,o,l,{i:void 0,dateFormatter:new z(this.dCtx.ctx).formatDate,w:e}),(e.config.xaxis.convertedCatToNumeric&&void 0===r||""===String(r).trim())&&(o=r="1");var h=new A(this.dCtx.ctx),c=h.getTextRects(r,e.config.xaxis.labels.style.fontSize),d=c;if(r!==o&&(d=h.getTextRects(o,e.config.xaxis.labels.style.fontSize)),(t={width:c.width>=d.width?c.width:d.width,height:c.height>=d.height?c.height:d.height}).width*i.length>e.globals.svgWidth-this.dCtx.lgWidthForSideLegends-this.dCtx.yAxisWidth-this.dCtx.gridPad.left-this.dCtx.gridPad.right&&0!==e.config.xaxis.labels.rotate||e.config.xaxis.labels.rotateAlways){if(!e.globals.isBarHorizontal){e.globals.rotateXLabels=!0;var g=function(t){return h.getTextRects(t,e.config.xaxis.labels.style.fontSize,e.config.xaxis.labels.style.fontFamily,"rotate(".concat(e.config.xaxis.labels.rotate," 0 0)"),!1)};c=g(r),r!==o&&(d=g(o)),t.height=(c.height>d.height?c.height:d.height)/1.5,t.width=c.width>d.width?c.width:d.width}}else e.globals.rotateXLabels=!1}return e.config.xaxis.labels.show||(t={width:0,height:0}),{width:t.width,height:t.height}}},{key:"getxAxisGroupLabelsCoords",value:function(){var t,e=this.w;if(!e.globals.hasXaxisGroups)return{width:0,height:0};var i,a=(null===(t=e.config.xaxis.group.style)||void 0===t?void 0:t.fontSize)||e.config.xaxis.labels.style.fontSize,s=e.globals.groups.map((function(t){return t.title})),r=y.getLargestStringFromArr(s),o=this.dCtx.dimHelpers.getLargestStringFromMultiArr(r,s),n=new A(this.dCtx.ctx),l=n.getTextRects(r,a),h=l;return r!==o&&(h=n.getTextRects(o,a)),i={width:l.width>=h.width?l.width:h.width,height:l.height>=h.height?l.height:h.height},e.config.xaxis.labels.show||(i={width:0,height:0}),{width:i.width,height:i.height}}},{key:"getxAxisTitleCoords",value:function(){var t=this.w,e=0,i=0;if(void 0!==t.config.xaxis.title.text){var a=new A(this.dCtx.ctx).getTextRects(t.config.xaxis.title.text,t.config.xaxis.title.style.fontSize);e=a.width,i=a.height}return{width:e,height:i}}},{key:"getxAxisTimeScaleLabelsCoords",value:function(){var t,e=this.w;this.dCtx.timescaleLabels=e.globals.timescaleLabels.slice();var i=this.dCtx.timescaleLabels.map((function(t){return t.value})),a=i.reduce((function(t,e){return void 0===t?(console.error("You have possibly supplied invalid Date format. Please supply a valid JavaScript Date"),0):t.length>e.length?t:e}),0);return 1.05*(t=new A(this.dCtx.ctx).getTextRects(a,e.config.xaxis.labels.style.fontSize)).width*i.length>e.globals.gridWidth&&0!==e.config.xaxis.labels.rotate&&(e.globals.overlappingXLabels=!0),t}},{key:"additionalPaddingXLabels",value:function(t){var e=this,i=this.w,a=i.globals,s=i.config,r=s.xaxis.type,o=t.width;a.skipLastTimelinelabel=!1,a.skipFirstTimelinelabel=!1;var n=i.config.yaxis[0].opposite&&i.globals.isBarHorizontal,l=function(t,n){s.yaxis.length>1&&function(t){return-1!==a.collapsedSeriesIndices.indexOf(t)}(n)||function(t){if(e.dCtx.timescaleLabels&&e.dCtx.timescaleLabels.length){var n=e.dCtx.timescaleLabels[0],l=e.dCtx.timescaleLabels[e.dCtx.timescaleLabels.length-1].position+o/1.75-e.dCtx.yAxisWidthRight,h=n.position-o/1.75+e.dCtx.yAxisWidthLeft,c="right"===i.config.legend.position&&e.dCtx.lgRect.width>0?e.dCtx.lgRect.width:0;l>a.svgWidth-a.translateX-c&&(a.skipLastTimelinelabel=!0),h<-(t.show&&!t.floating||"bar"!==s.chart.type&&"candlestick"!==s.chart.type&&"rangeBar"!==s.chart.type&&"boxPlot"!==s.chart.type?10:o/1.75)&&(a.skipFirstTimelinelabel=!0)}else"datetime"===r?e.dCtx.gridPad.rightString(n.niceMax).length?c:n.niceMax,g=h(d,{seriesIndex:o,dataPointIndex:-1,w:e}),u=g;if(void 0!==g&&0!==g.length||(g=d),e.globals.isBarHorizontal){a=0;var p=e.globals.labels.slice();g=h(g=y.getLargestStringFromArr(p),{seriesIndex:o,dataPointIndex:-1,w:e}),u=t.dCtx.dimHelpers.getLargestStringFromMultiArr(g,p)}var f=new A(t.dCtx.ctx),x="rotate(".concat(r.labels.rotate," 0 0)"),b=f.getTextRects(g,r.labels.style.fontSize,r.labels.style.fontFamily,x,!1),v=b;g!==u&&(v=f.getTextRects(u,r.labels.style.fontSize,r.labels.style.fontFamily,x,!1)),i.push({width:(l>v.width||l>b.width?l:v.width>b.width?v.width:b.width)+a,height:v.height>b.height?v.height:b.height})}else i.push({width:0,height:0})})),i}},{key:"getyAxisTitleCoords",value:function(){var t=this,e=this.w,i=[];return e.config.yaxis.map((function(e,a){if(e.show&&void 0!==e.title.text){var s=new A(t.dCtx.ctx),r="rotate(".concat(e.title.rotate," 0 0)"),o=s.getTextRects(e.title.text,e.title.style.fontSize,e.title.style.fontFamily,r,!1);i.push({width:o.width,height:o.height})}else i.push({width:0,height:0})})),i}},{key:"getTotalYAxisWidth",value:function(){var t=this.w,e=0,i=0,a=0,s=t.globals.yAxisScale.length>1?10:0,r=new _(this.dCtx.ctx),o=function(o,n){var l=t.config.yaxis[n].floating,h=0;o.width>0&&!l?(h=o.width+s,function(e){return t.globals.ignoreYAxisIndexes.indexOf(e)>-1}(n)&&(h=h-o.width-s)):h=l||r.isYAxisHidden(n)?0:5,t.config.yaxis[n].opposite?a+=h:i+=h,e+=h};return t.globals.yLabelsCoords.map((function(t,e){o(t,e)})),t.globals.yTitleCoords.map((function(t,e){o(t,e)})),t.globals.isBarHorizontal&&!t.config.yaxis[0].floating&&(e=t.globals.yLabelsCoords[0].width+t.globals.yTitleCoords[0].width+15),this.dCtx.yAxisWidthLeft=i,this.dCtx.yAxisWidthRight=a,e}}]),t}(),ht=function(){function t(e){n(this,t),this.w=e.w,this.dCtx=e}return h(t,[{key:"gridPadForColumnsInNumericAxis",value:function(t){var e=this.w;if(e.globals.noData||e.globals.allSeriesCollapsed)return 0;var i=function(t){return"bar"===t||"rangeBar"===t||"candlestick"===t||"boxPlot"===t},a=e.config.chart.type,s=0,r=i(a)?e.config.series.length:1;if(e.globals.comboBarCount>0&&(r=e.globals.comboBarCount),e.globals.collapsedSeries.forEach((function(t){i(t.type)&&(r-=1)})),e.config.chart.stacked&&(r=1),(i(a)||e.globals.comboBarCount>0)&&e.globals.isXNumeric&&!e.globals.isBarHorizontal&&r>0){var o,n,l=Math.abs(e.globals.initialMaxX-e.globals.initialMinX);l<=3&&(l=e.globals.dataPoints),o=l/t,e.globals.minXDiff&&e.globals.minXDiff/o>0&&(n=e.globals.minXDiff/o),n>t/2&&(n/=2),(s=n/r*parseInt(e.config.plotOptions.bar.columnWidth,10)/100)<1&&(s=1),s=s/(r>1?1:1.5)+5,e.globals.barPadForNumericAxis=s}return s}},{key:"gridPadFortitleSubtitle",value:function(){var t=this,e=this.w,i=e.globals,a=this.dCtx.isSparkline||!e.globals.axisCharts?0:10;["title","subtitle"].forEach((function(i){void 0!==e.config[i].text?a+=e.config[i].margin:a+=t.dCtx.isSparkline||!e.globals.axisCharts?0:5})),!e.config.legend.show||"bottom"!==e.config.legend.position||e.config.legend.floating||e.globals.axisCharts||(a+=10);var s=this.dCtx.dimHelpers.getTitleSubtitleCoords("title"),r=this.dCtx.dimHelpers.getTitleSubtitleCoords("subtitle");i.gridHeight=i.gridHeight-s.height-r.height-a,i.translateY=i.translateY+s.height+r.height+a}},{key:"setGridXPosForDualYAxis",value:function(t,e){var i=this.w,a=new _(this.dCtx.ctx);i.config.yaxis.map((function(s,r){-1!==i.globals.ignoreYAxisIndexes.indexOf(r)||s.floating||a.isYAxisHidden(r)||(s.opposite&&(i.globals.translateX=i.globals.translateX-(e[r].width+t[r].width)-parseInt(i.config.yaxis[r].labels.style.fontSize,10)/1.2-12),i.globals.translateX<2&&(i.globals.translateX=2))}))}}]),t}(),ct=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.lgRect={},this.yAxisWidth=0,this.yAxisWidthLeft=0,this.yAxisWidthRight=0,this.xAxisHeight=0,this.isSparkline=this.w.config.chart.sparkline.enabled,this.dimHelpers=new ot(this),this.dimYAxis=new lt(this),this.dimXAxis=new nt(this),this.dimGrid=new ht(this),this.lgWidthForSideLegends=0,this.gridPad=this.w.config.grid.padding,this.xPadRight=0,this.xPadLeft=0}return h(t,[{key:"plotCoords",value:function(){var t=this,e=this.w,i=e.globals;this.lgRect=this.dimHelpers.getLegendsRect(),this.isSparkline&&(e.config.markers.discrete.length>0||e.config.markers.size>0)&&Object.entries(this.gridPad).forEach((function(e){var i=x(e,2),a=i[0],s=i[1];t.gridPad[a]=Math.max(s,t.w.globals.markers.largestSize/1.5)})),i.axisCharts?this.setDimensionsForAxisCharts():this.setDimensionsForNonAxisCharts(),this.dimGrid.gridPadFortitleSubtitle(),i.gridHeight=i.gridHeight-this.gridPad.top-this.gridPad.bottom,i.gridWidth=i.gridWidth-this.gridPad.left-this.gridPad.right-this.xPadRight-this.xPadLeft;var a=this.dimGrid.gridPadForColumnsInNumericAxis(i.gridWidth);i.gridWidth=i.gridWidth-2*a,i.translateX=i.translateX+this.gridPad.left+this.xPadLeft+(a>0?a+4:0),i.translateY=i.translateY+this.gridPad.top}},{key:"setDimensionsForAxisCharts",value:function(){var t=this,e=this.w,i=e.globals,a=this.dimYAxis.getyAxisLabelsCoords(),s=this.dimYAxis.getyAxisTitleCoords();e.globals.yLabelsCoords=[],e.globals.yTitleCoords=[],e.config.yaxis.map((function(t,i){e.globals.yLabelsCoords.push({width:a[i].width,index:i}),e.globals.yTitleCoords.push({width:s[i].width,index:i})})),this.yAxisWidth=this.dimYAxis.getTotalYAxisWidth();var r=this.dimXAxis.getxAxisLabelsCoords(),o=this.dimXAxis.getxAxisGroupLabelsCoords(),n=this.dimXAxis.getxAxisTitleCoords();this.conditionalChecksForAxisCoords(r,n,o),i.translateXAxisY=e.globals.rotateXLabels?this.xAxisHeight/8:-4,i.translateXAxisX=e.globals.rotateXLabels&&e.globals.isXNumeric&&e.config.xaxis.labels.rotate<=-45?-this.xAxisWidth/4:0,e.globals.isBarHorizontal&&(i.rotateXLabels=!1,i.translateXAxisY=parseInt(e.config.xaxis.labels.style.fontSize,10)/1.5*-1),i.translateXAxisY=i.translateXAxisY+e.config.xaxis.labels.offsetY,i.translateXAxisX=i.translateXAxisX+e.config.xaxis.labels.offsetX;var l=this.yAxisWidth,h=this.xAxisHeight;i.xAxisLabelsHeight=this.xAxisHeight-n.height,i.xAxisGroupLabelsHeight=i.xAxisLabelsHeight-r.height,i.xAxisLabelsWidth=this.xAxisWidth,i.xAxisHeight=this.xAxisHeight;var c=10;("radar"===e.config.chart.type||this.isSparkline)&&(l=0,h=i.goldenPadding),this.isSparkline&&(this.lgRect={height:0,width:0}),(this.isSparkline||"treemap"===e.config.chart.type)&&(l=0,h=0,c=0),this.isSparkline||this.dimXAxis.additionalPaddingXLabels(r);var d=function(){i.translateX=l,i.gridHeight=i.svgHeight-t.lgRect.height-h-(t.isSparkline||"treemap"===e.config.chart.type?0:e.globals.rotateXLabels?10:15),i.gridWidth=i.svgWidth-l};switch("top"===e.config.xaxis.position&&(c=i.xAxisHeight-e.config.xaxis.axisTicks.height-5),e.config.legend.position){case"bottom":i.translateY=c,d();break;case"top":i.translateY=this.lgRect.height+c,d();break;case"left":i.translateY=c,i.translateX=this.lgRect.width+l,i.gridHeight=i.svgHeight-h-12,i.gridWidth=i.svgWidth-this.lgRect.width-l;break;case"right":i.translateY=c,i.translateX=l,i.gridHeight=i.svgHeight-h-12,i.gridWidth=i.svgWidth-this.lgRect.width-l-5;break;default:throw new Error("Legend position not supported")}this.dimGrid.setGridXPosForDualYAxis(s,a),new Q(this.ctx).setYAxisXPosition(a,s)}},{key:"setDimensionsForNonAxisCharts",value:function(){var t=this.w,e=t.globals,i=t.config,a=0;t.config.legend.show&&!t.config.legend.floating&&(a=20);var s="pie"===i.chart.type||"polarArea"===i.chart.type||"donut"===i.chart.type?"pie":"radialBar",r=i.plotOptions[s].offsetY,o=i.plotOptions[s].offsetX;if(!i.legend.show||i.legend.floating)return e.gridHeight=e.svgHeight-i.grid.padding.left+i.grid.padding.right,e.gridWidth=e.gridHeight,e.translateY=r,void(e.translateX=o+(e.svgWidth-e.gridWidth)/2);switch(i.legend.position){case"bottom":e.gridHeight=e.svgHeight-this.lgRect.height-e.goldenPadding,e.gridWidth=e.svgWidth,e.translateY=r-10,e.translateX=o+(e.svgWidth-e.gridWidth)/2;break;case"top":e.gridHeight=e.svgHeight-this.lgRect.height-e.goldenPadding,e.gridWidth=e.svgWidth,e.translateY=this.lgRect.height+r+10,e.translateX=o+(e.svgWidth-e.gridWidth)/2;break;case"left":e.gridWidth=e.svgWidth-this.lgRect.width-a,e.gridHeight="auto"!==i.chart.height?e.svgHeight:e.gridWidth,e.translateY=r,e.translateX=o+this.lgRect.width+a;break;case"right":e.gridWidth=e.svgWidth-this.lgRect.width-a-5,e.gridHeight="auto"!==i.chart.height?e.svgHeight:e.gridWidth,e.translateY=r,e.translateX=o+10;break;default:throw new Error("Legend position not supported")}}},{key:"conditionalChecksForAxisCoords",value:function(t,e,i){var a=this.w,s=a.globals.hasXaxisGroups?2:1,r=i.height+t.height+e.height,o=a.globals.isMultiLineX?1.2:a.globals.LINE_HEIGHT_RATIO,n=a.globals.rotateXLabels?22:10,l=a.globals.rotateXLabels&&"bottom"===a.config.legend.position?10:0;this.xAxisHeight=r*o+s*n+l,this.xAxisWidth=t.width,this.xAxisHeight-e.height>a.config.xaxis.labels.maxHeight&&(this.xAxisHeight=a.config.xaxis.labels.maxHeight),a.config.xaxis.labels.minHeight&&this.xAxisHeightc&&(this.yAxisWidth=c)}}]),t}(),dt=function(){function t(e){n(this,t),this.w=e.w,this.lgCtx=e}return h(t,[{key:"getLegendStyles",value:function(){var t=document.createElement("style");t.setAttribute("type","text/css");var e=document.createTextNode("\t\n \t\n .apexcharts-legend {\t\n display: flex;\t\n overflow: auto;\t\n padding: 0 10px;\t\n }\t\n .apexcharts-legend.apx-legend-position-bottom, .apexcharts-legend.apx-legend-position-top {\t\n flex-wrap: wrap\t\n }\t\n .apexcharts-legend.apx-legend-position-right, .apexcharts-legend.apx-legend-position-left {\t\n flex-direction: column;\t\n bottom: 0;\t\n }\t\n .apexcharts-legend.apx-legend-position-bottom.apexcharts-align-left, .apexcharts-legend.apx-legend-position-top.apexcharts-align-left, .apexcharts-legend.apx-legend-position-right, .apexcharts-legend.apx-legend-position-left {\t\n justify-content: flex-start;\t\n }\t\n .apexcharts-legend.apx-legend-position-bottom.apexcharts-align-center, .apexcharts-legend.apx-legend-position-top.apexcharts-align-center {\t\n justify-content: center; \t\n }\t\n .apexcharts-legend.apx-legend-position-bottom.apexcharts-align-right, .apexcharts-legend.apx-legend-position-top.apexcharts-align-right {\t\n justify-content: flex-end;\t\n }\t\n .apexcharts-legend-series {\t\n cursor: pointer;\t\n line-height: normal;\t\n }\t\n .apexcharts-legend.apx-legend-position-bottom .apexcharts-legend-series, .apexcharts-legend.apx-legend-position-top .apexcharts-legend-series{\t\n display: flex;\t\n align-items: center;\t\n }\t\n .apexcharts-legend-text {\t\n position: relative;\t\n font-size: 14px;\t\n }\t\n .apexcharts-legend-text *, .apexcharts-legend-marker * {\t\n pointer-events: none;\t\n }\t\n .apexcharts-legend-marker {\t\n position: relative;\t\n display: inline-block;\t\n cursor: pointer;\t\n margin-right: 3px;\t\n border-style: solid;\n }\t\n \t\n .apexcharts-legend.apexcharts-align-right .apexcharts-legend-series, .apexcharts-legend.apexcharts-align-left .apexcharts-legend-series{\t\n display: inline-block;\t\n }\t\n .apexcharts-legend-series.apexcharts-no-click {\t\n cursor: auto;\t\n }\t\n .apexcharts-legend .apexcharts-hidden-zero-series, .apexcharts-legend .apexcharts-hidden-null-series {\t\n display: none !important;\t\n }\t\n .apexcharts-inactive-legend {\t\n opacity: 0.45;\t\n }");return t.appendChild(e),t}},{key:"getLegendBBox",value:function(){var t=this.w.globals.dom.baseEl.querySelector(".apexcharts-legend").getBoundingClientRect(),e=t.width;return{clwh:t.height,clww:e}}},{key:"appendToForeignObject",value:function(){this.w.globals.dom.elLegendForeign.appendChild(this.getLegendStyles())}},{key:"toggleDataSeries",value:function(t,e){var i=this,a=this.w;if(a.globals.axisCharts||"radialBar"===a.config.chart.type){a.globals.resized=!0;var s=null,r=null;a.globals.risingSeries=[],a.globals.axisCharts?(s=a.globals.dom.baseEl.querySelector(".apexcharts-series[data\\:realIndex='".concat(t,"']")),r=parseInt(s.getAttribute("data:realIndex"),10)):(s=a.globals.dom.baseEl.querySelector(".apexcharts-series[rel='".concat(t+1,"']")),r=parseInt(s.getAttribute("rel"),10)-1),e?[{cs:a.globals.collapsedSeries,csi:a.globals.collapsedSeriesIndices},{cs:a.globals.ancillaryCollapsedSeries,csi:a.globals.ancillaryCollapsedSeriesIndices}].forEach((function(t){i.riseCollapsedSeries(t.cs,t.csi,r)})):this.hideSeries({seriesEl:s,realIndex:r})}else{var o=a.globals.dom.Paper.select(" .apexcharts-series[rel='".concat(t+1,"'] path")),n=a.config.chart.type;if("pie"===n||"polarArea"===n||"donut"===n){var l=a.config.plotOptions.pie.donut.labels;new A(this.lgCtx.ctx).pathMouseDown(o.members[0],null),this.lgCtx.ctx.pie.printDataLabelsInner(o.members[0].node,l)}o.fire("click")}}},{key:"hideSeries",value:function(t){var e=t.seriesEl,i=t.realIndex,a=this.w,s=y.clone(a.config.series);if(a.globals.axisCharts){var r=!1;if(a.config.yaxis[i]&&a.config.yaxis[i].show&&a.config.yaxis[i].showAlways&&(r=!0,a.globals.ancillaryCollapsedSeriesIndices.indexOf(i)<0&&(a.globals.ancillaryCollapsedSeries.push({index:i,data:s[i].data.slice(),type:e.parentNode.className.baseVal.split("-")[1]}),a.globals.ancillaryCollapsedSeriesIndices.push(i))),!r){a.globals.collapsedSeries.push({index:i,data:s[i].data.slice(),type:e.parentNode.className.baseVal.split("-")[1]}),a.globals.collapsedSeriesIndices.push(i);var o=a.globals.risingSeries.indexOf(i);a.globals.risingSeries.splice(o,1)}}else a.globals.collapsedSeries.push({index:i,data:s[i]}),a.globals.collapsedSeriesIndices.push(i);for(var n=e.childNodes,l=0;l0){for(var r=0;r-1&&(t[a].data=[])})):t.forEach((function(i,a){e.globals.collapsedSeriesIndices.indexOf(a)>-1&&(t[a]=0)})),t}}]),t}(),gt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.onLegendClick=this.onLegendClick.bind(this),this.onLegendHovered=this.onLegendHovered.bind(this),this.isBarsDistributed="bar"===this.w.config.chart.type&&this.w.config.plotOptions.bar.distributed&&1===this.w.config.series.length,this.legendHelpers=new dt(this)}return h(t,[{key:"init",value:function(){var t=this.w,e=t.globals,i=t.config;if((i.legend.showForSingleSeries&&1===e.series.length||this.isBarsDistributed||e.series.length>1||!e.axisCharts)&&i.legend.show){for(;e.dom.elLegendWrap.firstChild;)e.dom.elLegendWrap.removeChild(e.dom.elLegendWrap.firstChild);this.drawLegends(),y.isIE11()?document.getElementsByTagName("head")[0].appendChild(this.legendHelpers.getLegendStyles()):this.legendHelpers.appendToForeignObject(),"bottom"===i.legend.position||"top"===i.legend.position?this.legendAlignHorizontal():"right"!==i.legend.position&&"left"!==i.legend.position||this.legendAlignVertical()}}},{key:"drawLegends",value:function(){var t=this,e=this.w,i=e.config.legend.fontFamily,a=e.globals.seriesNames,s=e.globals.colors.slice();if("heatmap"===e.config.chart.type){var r=e.config.plotOptions.heatmap.colorScale.ranges;a=r.map((function(t){return t.name?t.name:t.from+" - "+t.to})),s=r.map((function(t){return t.color}))}else this.isBarsDistributed&&(a=e.globals.labels.slice());e.config.legend.customLegendItems.length&&(a=e.config.legend.customLegendItems);for(var o=e.globals.legendFormatter,n=e.config.legend.inverseOrder,l=n?a.length-1:0;n?l>=0:l<=a.length-1;n?l--:l++){var h,c=o(a[l],{seriesIndex:l,w:e}),d=!1,g=!1;if(e.globals.collapsedSeries.length>0)for(var u=0;u0)for(var p=0;p0?l-10:0)+(h>0?h-10:0)}a.style.position="absolute",r=r+t+i.config.legend.offsetX,o=o+e+i.config.legend.offsetY,a.style.left=r+"px",a.style.top=o+"px","bottom"===i.config.legend.position?(a.style.top="auto",a.style.bottom=5-i.config.legend.offsetY+"px"):"right"===i.config.legend.position&&(a.style.left="auto",a.style.right=25+i.config.legend.offsetX+"px"),["width","height"].forEach((function(t){a.style[t]&&(a.style[t]=parseInt(i.config.legend[t],10)+"px")}))}},{key:"legendAlignHorizontal",value:function(){var t=this.w;t.globals.dom.elLegendWrap.style.right=0;var e=this.legendHelpers.getLegendBBox(),i=new ct(this.ctx),a=i.dimHelpers.getTitleSubtitleCoords("title"),s=i.dimHelpers.getTitleSubtitleCoords("subtitle"),r=0;"bottom"===t.config.legend.position?r=-e.clwh/1.8:"top"===t.config.legend.position&&(r=a.height+s.height+t.config.title.margin+t.config.subtitle.margin-10),this.setLegendWrapXY(20,r)}},{key:"legendAlignVertical",value:function(){var t=this.w,e=this.legendHelpers.getLegendBBox(),i=0;"left"===t.config.legend.position&&(i=20),"right"===t.config.legend.position&&(i=t.globals.svgWidth-e.clww-10),this.setLegendWrapXY(i,20)}},{key:"onLegendHovered",value:function(t){var e=this.w,i=t.target.classList.contains("apexcharts-legend-text")||t.target.classList.contains("apexcharts-legend-marker");if("heatmap"===e.config.chart.type||this.isBarsDistributed){if(i){var a=parseInt(t.target.getAttribute("rel"),10)-1;this.ctx.events.fireEvent("legendHover",[this.ctx,a,this.w]),new V(this.ctx).highlightRangeInSeries(t,t.target)}}else!t.target.classList.contains("apexcharts-inactive-legend")&&i&&new V(this.ctx).toggleSeriesOnHover(t,t.target)}},{key:"onLegendClick",value:function(t){var e=this.w;if(!e.config.legend.customLegendItems.length&&(t.target.classList.contains("apexcharts-legend-text")||t.target.classList.contains("apexcharts-legend-marker"))){var i=parseInt(t.target.getAttribute("rel"),10)-1,a="true"===t.target.getAttribute("data:collapsed"),s=this.w.config.chart.events.legendClick;"function"==typeof s&&s(this.ctx,i,this.w),this.ctx.events.fireEvent("legendClick",[this.ctx,i,this.w]);var r=this.w.config.legend.markers.onClick;"function"==typeof r&&t.target.classList.contains("apexcharts-legend-marker")&&(r(this.ctx,i,this.w),this.ctx.events.fireEvent("legendMarkerClick",[this.ctx,i,this.w])),"treemap"!==e.config.chart.type&&"heatmap"!==e.config.chart.type&&!this.isBarsDistributed&&e.config.legend.onItemClick.toggleDataSeries&&this.legendHelpers.toggleDataSeries(i,a)}}}]),t}(),ut=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w;var i=this.w;this.ev=this.w.config.chart.events,this.selectedClass="apexcharts-selected",this.localeValues=this.w.globals.locale.toolbar,this.minX=i.globals.minX,this.maxX=i.globals.maxX}return h(t,[{key:"createToolbar",value:function(){var t=this,e=this.w,i=function(){return document.createElement("div")},a=i();if(a.setAttribute("class","apexcharts-toolbar"),a.style.top=e.config.chart.toolbar.offsetY+"px",a.style.right=3-e.config.chart.toolbar.offsetX+"px",e.globals.dom.elWrap.appendChild(a),this.elZoom=i(),this.elZoomIn=i(),this.elZoomOut=i(),this.elPan=i(),this.elSelection=i(),this.elZoomReset=i(),this.elMenuIcon=i(),this.elMenu=i(),this.elCustomIcons=[],this.t=e.config.chart.toolbar.tools,Array.isArray(this.t.customIcons))for(var s=0;s\n \n \n\n'),o("zoomOut",this.elZoomOut,'\n \n \n\n');var n=function(i){t.t[i]&&e.config.chart[i].enabled&&r.push({el:"zoom"===i?t.elZoom:t.elSelection,icon:"string"==typeof t.t[i]?t.t[i]:"zoom"===i?'\n \n \n \n':'\n \n \n',title:t.localeValues["zoom"===i?"selectionZoom":"selection"],class:e.globals.isTouchDevice?"apexcharts-element-hidden":"apexcharts-".concat(i,"-icon")})};n("zoom"),n("selection"),this.t.pan&&e.config.chart.zoom.enabled&&r.push({el:this.elPan,icon:"string"==typeof this.t.pan?this.t.pan:'\n \n \n \n \n \n \n \n',title:this.localeValues.pan,class:e.globals.isTouchDevice?"apexcharts-element-hidden":"apexcharts-pan-icon"}),o("reset",this.elZoomReset,'\n \n \n'),this.t.download&&r.push({el:this.elMenuIcon,icon:"string"==typeof this.t.download?this.t.download:'',title:this.localeValues.menu,class:"apexcharts-menu-icon"});for(var l=0;l0&&e.height>0&&this.slDraggableRect.selectize({points:"l, r",pointSize:8,pointType:"rect"}).resize({constraint:{minX:0,minY:0,maxX:t.globals.gridWidth,maxY:t.globals.gridHeight}}).on("resizing",this.selectionDragging.bind(this,"resizing"))}}},{key:"preselectedSelection",value:function(){var t=this.w,e=this.xyRatios;if(!t.globals.zoomEnabled)if(void 0!==t.globals.selection&&null!==t.globals.selection)this.drawSelectionRect(t.globals.selection);else if(void 0!==t.config.chart.selection.xaxis.min&&void 0!==t.config.chart.selection.xaxis.max){var i=(t.config.chart.selection.xaxis.min-t.globals.minX)/e.xRatio,a={x:i,y:0,width:t.globals.gridWidth-(t.globals.maxX-t.config.chart.selection.xaxis.max)/e.xRatio-i,height:t.globals.gridHeight,translateX:0,translateY:0,selectionEnabled:!0};this.drawSelectionRect(a),this.makeSelectionRectDraggable(),"function"==typeof t.config.chart.events.selection&&t.config.chart.events.selection(this.ctx,{xaxis:{min:t.config.chart.selection.xaxis.min,max:t.config.chart.selection.xaxis.max},yaxis:{}})}}},{key:"drawSelectionRect",value:function(t){var e=t.x,i=t.y,a=t.width,s=t.height,r=t.translateX,o=void 0===r?0:r,n=t.translateY,l=void 0===n?0:n,h=this.w,c=this.zoomRect,d=this.selectionRect;if(this.dragged||null!==h.globals.selection){var g={transform:"translate("+o+", "+l+")"};h.globals.zoomEnabled&&this.dragged&&(a<0&&(a=1),c.attr({x:e,y:i,width:a,height:s,fill:h.config.chart.zoom.zoomedArea.fill.color,"fill-opacity":h.config.chart.zoom.zoomedArea.fill.opacity,stroke:h.config.chart.zoom.zoomedArea.stroke.color,"stroke-width":h.config.chart.zoom.zoomedArea.stroke.width,"stroke-opacity":h.config.chart.zoom.zoomedArea.stroke.opacity}),A.setAttrs(c.node,g)),h.globals.selectionEnabled&&(d.attr({x:e,y:i,width:a>0?a:0,height:s>0?s:0,fill:h.config.chart.selection.fill.color,"fill-opacity":h.config.chart.selection.fill.opacity,stroke:h.config.chart.selection.stroke.color,"stroke-width":h.config.chart.selection.stroke.width,"stroke-dasharray":h.config.chart.selection.stroke.dashArray,"stroke-opacity":h.config.chart.selection.stroke.opacity}),A.setAttrs(d.node,g))}}},{key:"hideSelectionRect",value:function(t){t&&t.attr({x:0,y:0,width:0,height:0})}},{key:"selectionDrawing",value:function(t){var e,i=t.context,a=t.zoomtype,s=this.w,r=i,o=this.gridRect.getBoundingClientRect(),n=r.startX-1,l=r.startY,h=!1,c=!1,d=r.clientX-o.left-n,g=r.clientY-o.top-l;return Math.abs(d+n)>s.globals.gridWidth?d=s.globals.gridWidth-n:r.clientX-o.left<0&&(d=n),n>r.clientX-o.left&&(h=!0,d=Math.abs(d)),l>r.clientY-o.top&&(c=!0,g=Math.abs(g)),e="x"===a?{x:h?n-d:n,y:0,width:d,height:s.globals.gridHeight}:"y"===a?{x:0,y:c?l-g:l,width:s.globals.gridWidth,height:g}:{x:h?n-d:n,y:c?l-g:l,width:d,height:g},r.drawSelectionRect(e),r.selectionDragging("resizing"),e}},{key:"selectionDragging",value:function(t,e){var i=this,a=this.w,s=this.xyRatios,r=this.selectionRect,o=0;"resizing"===t&&(o=30);var n=function(t){return parseFloat(r.node.getAttribute(t))},l={x:n("x"),y:n("y"),width:n("width"),height:n("height")};a.globals.selection=l,"function"==typeof a.config.chart.events.selection&&a.globals.selectionEnabled&&(clearTimeout(this.w.globals.selectionResizeTimer),this.w.globals.selectionResizeTimer=window.setTimeout((function(){var t=i.gridRect.getBoundingClientRect(),e=r.node.getBoundingClientRect(),o={xaxis:{min:a.globals.xAxisScale.niceMin+(e.left-t.left)*s.xRatio,max:a.globals.xAxisScale.niceMin+(e.right-t.left)*s.xRatio},yaxis:{min:a.globals.yAxisScale[0].niceMin+(t.bottom-e.bottom)*s.yRatio[0],max:a.globals.yAxisScale[0].niceMax-(e.top-t.top)*s.yRatio[0]}};a.config.chart.events.selection(i.ctx,o),a.config.chart.brush.enabled&&void 0!==a.config.chart.events.brushScrolled&&a.config.chart.events.brushScrolled(i.ctx,o)}),o))}},{key:"selectionDrawn",value:function(t){var e=t.context,i=t.zoomtype,a=this.w,s=e,r=this.xyRatios,o=this.ctx.toolbar;if(s.startX>s.endX){var n=s.startX;s.startX=s.endX,s.endX=n}if(s.startY>s.endY){var l=s.startY;s.startY=s.endY,s.endY=l}var h=void 0,c=void 0;a.globals.isRangeBar?(h=a.globals.yAxisScale[0].niceMin+s.startX*r.invertedYRatio,c=a.globals.yAxisScale[0].niceMin+s.endX*r.invertedYRatio):(h=a.globals.xAxisScale.niceMin+s.startX*r.xRatio,c=a.globals.xAxisScale.niceMin+s.endX*r.xRatio);var d=[],g=[];if(a.config.yaxis.forEach((function(t,e){d.push(a.globals.yAxisScale[e].niceMax-r.yRatio[e]*s.startY),g.push(a.globals.yAxisScale[e].niceMax-r.yRatio[e]*s.endY)})),s.dragged&&(s.dragX>10||s.dragY>10)&&h!==c)if(a.globals.zoomEnabled){var u=y.clone(a.globals.initialConfig.yaxis),p=y.clone(a.globals.initialConfig.xaxis);if(a.globals.zoomed=!0,a.config.xaxis.convertedCatToNumeric&&(h=Math.floor(h),c=Math.floor(c),h<1&&(h=1,c=a.globals.dataPoints),c-h<2&&(c=h+1)),"xy"!==i&&"x"!==i||(p={min:h,max:c}),"xy"!==i&&"y"!==i||u.forEach((function(t,e){u[e].min=g[e],u[e].max=d[e]})),a.config.chart.zoom.autoScaleYaxis){var f=new $(s.ctx);u=f.autoScaleY(s.ctx,u,{xaxis:p})}if(o){var x=o.getBeforeZoomRange(p,u);x&&(p=x.xaxis?x.xaxis:p,u=x.yaxis?x.yaxis:u)}var b={xaxis:p};a.config.chart.group||(b.yaxis=u),s.ctx.updateHelpers._updateOptions(b,!1,s.w.config.chart.animations.dynamicAnimation.enabled),"function"==typeof a.config.chart.events.zoomed&&o.zoomCallback(p,u)}else if(a.globals.selectionEnabled){var v,m=null;v={min:h,max:c},"xy"!==i&&"y"!==i||(m=y.clone(a.config.yaxis)).forEach((function(t,e){m[e].min=g[e],m[e].max=d[e]})),a.globals.selection=s.selection,"function"==typeof a.config.chart.events.selection&&a.config.chart.events.selection(s.ctx,{xaxis:v,yaxis:m})}}},{key:"panDragging",value:function(t){var e=t.context,i=this.w,a=e;if(void 0!==i.globals.lastClientPosition.x){var s=i.globals.lastClientPosition.x-a.clientX,r=i.globals.lastClientPosition.y-a.clientY;Math.abs(s)>Math.abs(r)&&s>0?this.moveDirection="left":Math.abs(s)>Math.abs(r)&&s<0?this.moveDirection="right":Math.abs(r)>Math.abs(s)&&r>0?this.moveDirection="up":Math.abs(r)>Math.abs(s)&&r<0&&(this.moveDirection="down")}i.globals.lastClientPosition={x:a.clientX,y:a.clientY};var o=i.globals.isRangeBar?i.globals.minY:i.globals.minX,n=i.globals.isRangeBar?i.globals.maxY:i.globals.maxX;i.config.xaxis.convertedCatToNumeric||a.panScrolled(o,n)}},{key:"delayedPanScrolled",value:function(){var t=this.w,e=t.globals.minX,i=t.globals.maxX,a=(t.globals.maxX-t.globals.minX)/2;"left"===this.moveDirection?(e=t.globals.minX+a,i=t.globals.maxX+a):"right"===this.moveDirection&&(e=t.globals.minX-a,i=t.globals.maxX-a),e=Math.floor(e),i=Math.floor(i),this.updateScrolledChart({xaxis:{min:e,max:i}},e,i)}},{key:"panScrolled",value:function(t,e){var i=this.w,a=this.xyRatios,s=y.clone(i.globals.initialConfig.yaxis),r=a.xRatio,o=i.globals.minX,n=i.globals.maxX;i.globals.isRangeBar&&(r=a.invertedYRatio,o=i.globals.minY,n=i.globals.maxY),"left"===this.moveDirection?(t=o+i.globals.gridWidth/15*r,e=n+i.globals.gridWidth/15*r):"right"===this.moveDirection&&(t=o-i.globals.gridWidth/15*r,e=n-i.globals.gridWidth/15*r),i.globals.isRangeBar||(ti.globals.initialMaxX)&&(t=o,e=n);var l={min:t,max:e};i.config.chart.zoom.autoScaleYaxis&&(s=new $(this.ctx).autoScaleY(this.ctx,s,{xaxis:l}));var h={xaxis:{min:t,max:e}};i.config.chart.group||(h.yaxis=s),this.updateScrolledChart(h,t,e)}},{key:"updateScrolledChart",value:function(t,e,i){var a=this.w;this.ctx.updateHelpers._updateOptions(t,!1,!1),"function"==typeof a.config.chart.events.scrolled&&a.config.chart.events.scrolled(this.ctx,{xaxis:{min:e,max:i}})}}]),i}(),ft=function(){function t(e){n(this,t),this.w=e.w,this.ttCtx=e,this.ctx=e.ctx}return h(t,[{key:"getNearestValues",value:function(t){var e=t.hoverArea,i=t.elGrid,a=t.clientX,s=t.clientY,r=this.w,o=i.getBoundingClientRect(),n=o.width,l=o.height,h=n/(r.globals.dataPoints-1),c=l/r.globals.dataPoints,d=this.hasBars();!r.globals.comboCharts&&!d||r.config.xaxis.convertedCatToNumeric||(h=n/r.globals.dataPoints);var g=a-o.left-r.globals.barPadForNumericAxis,u=s-o.top;g<0||u<0||g>n||u>l?(e.classList.remove("hovering-zoom"),e.classList.remove("hovering-pan")):r.globals.zoomEnabled?(e.classList.remove("hovering-pan"),e.classList.add("hovering-zoom")):r.globals.panEnabled&&(e.classList.remove("hovering-zoom"),e.classList.add("hovering-pan"));var p=Math.round(g/h),f=Math.floor(u/c);d&&!r.config.xaxis.convertedCatToNumeric&&(p=Math.ceil(g/h),p-=1);var x=null,b=null,v=[],m=[];if(r.globals.seriesXvalues.forEach((function(t){v.push([t[0]+1e-6].concat(t))})),r.globals.seriesYvalues.forEach((function(t){m.push([t[0]+1e-6].concat(t))})),v=v.map((function(t){return t.filter((function(t){return y.isNumber(t)}))})),m=m.map((function(t){return t.filter((function(t){return y.isNumber(t)}))})),r.globals.isXNumeric){var w=this.ttCtx.getElGrid().getBoundingClientRect(),k=g*(w.width/n),A=u*(w.height/l);x=(b=this.closestInMultiArray(k,A,v,m)).index,p=b.j,null!==x&&(v=r.globals.seriesXvalues[x],p=(b=this.closestInArray(k,v)).index)}return r.globals.capturedSeriesIndex=null===x?-1:x,(!p||p<1)&&(p=0),r.globals.isBarHorizontal?r.globals.capturedDataPointIndex=f:r.globals.capturedDataPointIndex=p,{capturedSeries:x,j:r.globals.isBarHorizontal?f:p,hoverX:g,hoverY:u}}},{key:"closestInMultiArray",value:function(t,e,i,a){var s=this.w,r=0,o=null,n=-1;s.globals.series.length>1?r=this.getFirstActiveXArray(i):o=0;var l=i[r][0],h=Math.abs(t-l);if(i.forEach((function(e){e.forEach((function(e,i){var a=Math.abs(t-e);a0?e:-1})),s=0;s0)for(var a=0;a *")):this.w.globals.dom.baseEl.querySelectorAll(".apexcharts-series-markers-wrap > *")}},{key:"getAllMarkers",value:function(){var t=this.w.globals.dom.baseEl.querySelectorAll(".apexcharts-series-markers-wrap");(t=b(t)).sort((function(t,e){var i=Number(t.getAttribute("data:realIndex")),a=Number(e.getAttribute("data:realIndex"));return ai?-1:0}));var e=[];return t.forEach((function(t){e.push(t.querySelector(".apexcharts-marker"))})),e}},{key:"hasMarkers",value:function(t){return this.getElMarkers(t).length>0}},{key:"getElBars",value:function(){return this.w.globals.dom.baseEl.querySelectorAll(".apexcharts-bar-series, .apexcharts-candlestick-series, .apexcharts-boxPlot-series, .apexcharts-rangebar-series")}},{key:"hasBars",value:function(){return this.getElBars().length>0}},{key:"getHoverMarkerSize",value:function(t){var e=this.w,i=e.config.markers.hover.size;return void 0===i&&(i=e.globals.markers.size[t]+e.config.markers.hover.sizeOffset),i}},{key:"toggleAllTooltipSeriesGroups",value:function(t){var e=this.w,i=this.ttCtx;0===i.allTooltipSeriesGroups.length&&(i.allTooltipSeriesGroups=e.globals.dom.baseEl.querySelectorAll(".apexcharts-tooltip-series-group"));for(var a=i.allTooltipSeriesGroups,s=0;s ').concat(i.attrs.name,""),e+="
".concat(i.val,"
")})),v.innerHTML=t+"",m.innerHTML=e+""};o?l.globals.seriesGoals[e][i]&&Array.isArray(l.globals.seriesGoals[e][i])?y():(v.innerHTML="",m.innerHTML=""):y()}else v.innerHTML="",m.innerHTML="";null!==p&&(a[e].querySelector(".apexcharts-tooltip-text-z-label").innerHTML=l.config.tooltip.z.title,a[e].querySelector(".apexcharts-tooltip-text-z-value").innerHTML=void 0!==p?p:""),o&&f[0]&&(null==c||l.globals.ancillaryCollapsedSeriesIndices.indexOf(e)>-1||l.globals.collapsedSeriesIndices.indexOf(e)>-1?f[0].parentNode.style.display="none":f[0].parentNode.style.display=l.config.tooltip.items.display)}},{key:"toggleActiveInactiveSeries",value:function(t){var e=this.w;if(t)this.tooltipUtil.toggleAllTooltipSeriesGroups("enable");else{this.tooltipUtil.toggleAllTooltipSeriesGroups("disable");var i=e.globals.dom.baseEl.querySelector(".apexcharts-tooltip-series-group");i&&(i.classList.add("apexcharts-active"),i.style.display=e.config.tooltip.items.display)}}},{key:"getValuesToPrint",value:function(t){var e=t.i,i=t.j,a=this.w,s=this.ctx.series.filteredSeriesX(),r="",o="",n=null,l=null,h={series:a.globals.series,seriesIndex:e,dataPointIndex:i,w:a},c=a.globals.ttZFormatter;null===i?l=a.globals.series[e]:a.globals.isXNumeric&&"treemap"!==a.config.chart.type?(r=s[e][i],0===s[e].length&&(r=s[this.tooltipUtil.getFirstActiveXArray(s)][i])):r=void 0!==a.globals.labels[i]?a.globals.labels[i]:"";var d=r;return r=a.globals.isXNumeric&&"datetime"===a.config.xaxis.type?new E(this.ctx).xLabelFormat(a.globals.ttKeyFormatter,d,d,{i:void 0,dateFormatter:new z(this.ctx).formatDate,w:this.w}):a.globals.isBarHorizontal?a.globals.yLabelFormatters[0](d,h):a.globals.xLabelFormatter(d,h),void 0!==a.config.tooltip.x.formatter&&(r=a.globals.ttKeyFormatter(d,h)),a.globals.seriesZ.length>0&&a.globals.seriesZ[e].length>0&&(n=c(a.globals.seriesZ[e][i],a)),o="function"==typeof a.config.xaxis.tooltip.formatter?a.globals.xaxisTooltipFormatter(d,h):r,{val:Array.isArray(l)?l.join(" "):l,xVal:Array.isArray(r)?r.join(" "):r,xAxisTTVal:Array.isArray(o)?o.join(" "):o,zVal:n}}},{key:"handleCustomTooltip",value:function(t){var e=t.i,i=t.j,a=t.y1,s=t.y2,r=t.w,o=this.ttCtx.getElTooltip(),n=r.config.tooltip.custom;Array.isArray(n)&&n[e]&&(n=n[e]),o.innerHTML=n({ctx:this.ctx,series:r.globals.series,seriesIndex:e,dataPointIndex:i,y1:a,y2:s,w:r})}}]),t}(),bt=function(){function t(e){n(this,t),this.ttCtx=e,this.ctx=e.ctx,this.w=e.w}return h(t,[{key:"moveXCrosshairs",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=this.ttCtx,a=this.w,s=i.getElXCrosshairs(),r=t-i.xcrosshairsWidth/2,o=a.globals.labels.slice().length;if(null!==e&&(r=a.globals.gridWidth/o*e),null===s||a.globals.isBarHorizontal||(s.setAttribute("x",r),s.setAttribute("x1",r),s.setAttribute("x2",r),s.setAttribute("y2",a.globals.gridHeight),s.classList.add("apexcharts-active")),r<0&&(r=0),r>a.globals.gridWidth&&(r=a.globals.gridWidth),i.isXAxisTooltipEnabled){var n=r;"tickWidth"!==a.config.xaxis.crosshairs.width&&"barWidth"!==a.config.xaxis.crosshairs.width||(n=r+i.xcrosshairsWidth/2),this.moveXAxisTooltip(n)}}},{key:"moveYCrosshairs",value:function(t){var e=this.ttCtx;null!==e.ycrosshairs&&A.setAttrs(e.ycrosshairs,{y1:t,y2:t}),null!==e.ycrosshairsHidden&&A.setAttrs(e.ycrosshairsHidden,{y1:t,y2:t})}},{key:"moveXAxisTooltip",value:function(t){var e=this.w,i=this.ttCtx;if(null!==i.xaxisTooltip&&0!==i.xcrosshairsWidth){i.xaxisTooltip.classList.add("apexcharts-active");var a,s=i.xaxisOffY+e.config.xaxis.tooltip.offsetY+e.globals.translateY+1+e.config.xaxis.offsetY;if(t-=i.xaxisTooltip.getBoundingClientRect().width/2,!isNaN(t))t+=e.globals.translateX,a=new A(this.ctx).getTextRects(i.xaxisTooltipText.innerHTML),i.xaxisTooltipText.style.minWidth=a.width+"px",i.xaxisTooltip.style.left=t+"px",i.xaxisTooltip.style.top=s+"px"}}},{key:"moveYAxisTooltip",value:function(t){var e=this.w,i=this.ttCtx;null===i.yaxisTTEls&&(i.yaxisTTEls=e.globals.dom.baseEl.querySelectorAll(".apexcharts-yaxistooltip"));var a=parseInt(i.ycrosshairsHidden.getAttribute("y1"),10),s=e.globals.translateY+a,r=i.yaxisTTEls[t].getBoundingClientRect().height,o=e.globals.translateYAxisX[t]-2;e.config.yaxis[t].opposite&&(o-=26),s-=r/2,-1===e.globals.ignoreYAxisIndexes.indexOf(t)?(i.yaxisTTEls[t].classList.add("apexcharts-active"),i.yaxisTTEls[t].style.top=s+"px",i.yaxisTTEls[t].style.left=o+e.config.yaxis[t].tooltip.offsetX+"px"):i.yaxisTTEls[t].classList.remove("apexcharts-active")}},{key:"moveTooltip",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=this.w,s=this.ttCtx,r=s.getElTooltip(),o=s.tooltipRect,n=null!==i?parseFloat(i):1,l=parseFloat(t)+n+5,h=parseFloat(e)+n/2;if(l>a.globals.gridWidth/2&&(l=l-o.ttWidth-n-10),l>a.globals.gridWidth-o.ttWidth-10&&(l=a.globals.gridWidth-o.ttWidth),l<-20&&(l=-20),a.config.tooltip.followCursor){var c=s.getElGrid().getBoundingClientRect();(l=s.e.clientX-c.left)>a.globals.gridWidth/2&&(l-=s.tooltipRect.ttWidth),(h=s.e.clientY+a.globals.translateY-c.top)>a.globals.gridHeight/2&&(h-=s.tooltipRect.ttHeight)}else a.globals.isBarHorizontal||o.ttHeight/2+h>a.globals.gridHeight&&(h=a.globals.gridHeight-o.ttHeight+a.globals.translateY);isNaN(l)||(l+=a.globals.translateX,r.style.left=l+"px",r.style.top=h+"px")}},{key:"moveMarkers",value:function(t,e){var i=this.w,a=this.ttCtx;if(i.globals.markers.size[t]>0)for(var s=i.globals.dom.baseEl.querySelectorAll(" .apexcharts-series[data\\:realIndex='".concat(t,"'] .apexcharts-marker")),r=0;r0&&(h.setAttribute("r",n),h.setAttribute("cx",i),h.setAttribute("cy",a)),this.moveXCrosshairs(i),r.fixedTooltip||this.moveTooltip(i,a,n)}}},{key:"moveDynamicPointsOnHover",value:function(t){var e,i=this.ttCtx,a=i.w,s=0,r=0,o=a.globals.pointsArray;e=new V(this.ctx).getActiveConfigSeriesIndex("asc",["line","area","scatter","bubble"]);var n=i.tooltipUtil.getHoverMarkerSize(e);o[e]&&(s=o[e][t][0],r=o[e][t][1]);var l=i.tooltipUtil.getAllMarkers();if(null!==l)for(var h=0;h0?(l[h]&&l[h].setAttribute("r",n),l[h]&&l[h].setAttribute("cy",d)):l[h]&&l[h].setAttribute("r",0)}}this.moveXCrosshairs(s),i.fixedTooltip||this.moveTooltip(s,r||a.globals.gridHeight,n)}},{key:"moveStickyTooltipOverBars",value:function(t,e){var i=this.w,a=this.ttCtx,s=i.globals.columnSeries?i.globals.columnSeries.length:i.globals.series.length,r=s>=2&&s%2==0?Math.floor(s/2):Math.floor(s/2)+1;i.globals.isBarHorizontal&&(r=new V(this.ctx).getActiveConfigSeriesIndex("desc")+1);var o=i.globals.dom.baseEl.querySelector(".apexcharts-bar-series .apexcharts-series[rel='".concat(r,"'] path[j='").concat(t,"'], .apexcharts-candlestick-series .apexcharts-series[rel='").concat(r,"'] path[j='").concat(t,"'], .apexcharts-boxPlot-series .apexcharts-series[rel='").concat(r,"'] path[j='").concat(t,"'], .apexcharts-rangebar-series .apexcharts-series[rel='").concat(r,"'] path[j='").concat(t,"']"));o||"number"!=typeof e||(o=i.globals.dom.baseEl.querySelector(".apexcharts-bar-series .apexcharts-series[data\\:realIndex='".concat(e,"'] path[j='").concat(t,"'],\n .apexcharts-candlestick-series .apexcharts-series[data\\:realIndex='").concat(e,"'] path[j='").concat(t,"'],\n .apexcharts-boxPlot-series .apexcharts-series[data\\:realIndex='").concat(e,"'] path[j='").concat(t,"'],\n .apexcharts-rangebar-series .apexcharts-series[data\\:realIndex='").concat(e,"'] path[j='").concat(t,"']")));var n=o?parseFloat(o.getAttribute("cx")):0,l=o?parseFloat(o.getAttribute("cy")):0,h=o?parseFloat(o.getAttribute("barWidth")):0,c=a.getElGrid().getBoundingClientRect(),d=o&&(o.classList.contains("apexcharts-candlestick-area")||o.classList.contains("apexcharts-boxPlot-area"));i.globals.isXNumeric?(o&&!d&&(n-=s%2!=0?h/2:0),o&&d&&i.globals.comboCharts&&(n-=h/2)):i.globals.isBarHorizontal||(n=a.xAxisTicksPositions[t-1]+a.dataPointsDividedWidth/2,isNaN(n)&&(n=a.xAxisTicksPositions[t]-a.dataPointsDividedWidth/2)),i.globals.isBarHorizontal?l-=a.tooltipRect.ttHeight:i.config.tooltip.followCursor?l=a.e.clientY-c.top-a.tooltipRect.ttHeight/2:l+a.tooltipRect.ttHeight+15>i.globals.gridHeight&&(l=i.globals.gridHeight),i.globals.isBarHorizontal||this.moveXCrosshairs(n),a.fixedTooltip||this.moveTooltip(n,l||i.globals.gridHeight)}}]),t}(),vt=function(){function t(e){n(this,t),this.w=e.w,this.ttCtx=e,this.ctx=e.ctx,this.tooltipPosition=new bt(e)}return h(t,[{key:"drawDynamicPoints",value:function(){var t=this.w,e=new A(this.ctx),i=new W(this.ctx),a=t.globals.dom.baseEl.querySelectorAll(".apexcharts-series");a=b(a),t.config.chart.stacked&&a.sort((function(t,e){return parseFloat(t.getAttribute("data:realIndex"))-parseFloat(e.getAttribute("data:realIndex"))}));for(var s=0;s2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=this.w;"bubble"!==s.config.chart.type&&this.newPointSize(t,e);var r=e.getAttribute("cx"),o=e.getAttribute("cy");if(null!==i&&null!==a&&(r=i,o=a),this.tooltipPosition.moveXCrosshairs(r),!this.fixedTooltip){if("radar"===s.config.chart.type){var n=this.ttCtx.getElGrid().getBoundingClientRect();r=this.ttCtx.e.clientX-n.left}this.tooltipPosition.moveTooltip(r,o,s.config.markers.hover.size)}}},{key:"enlargePoints",value:function(t){for(var e=this.w,i=this,a=this.ttCtx,s=t,r=e.globals.dom.baseEl.querySelectorAll(".apexcharts-series:not(.apexcharts-series-collapsed) .apexcharts-marker"),o=e.config.markers.hover.size,n=0;n=0?t[e].setAttribute("r",i):t[e].setAttribute("r",0)}}}]),t}(),mt=function(){function t(e){n(this,t),this.w=e.w;var i=this.w;this.ttCtx=e,this.isVerticalGroupedRangeBar=!i.globals.isBarHorizontal&&"rangeBar"===i.config.chart.type&&i.config.plotOptions.bar.rangeBarGroupRows}return h(t,[{key:"getAttr",value:function(t,e){return parseFloat(t.target.getAttribute(e))}},{key:"handleHeatTreeTooltip",value:function(t){var e=t.e,i=t.opt,a=t.x,s=t.y,r=t.type,o=this.ttCtx,n=this.w;if(e.target.classList.contains("apexcharts-".concat(r,"-rect"))){var l=this.getAttr(e,"i"),h=this.getAttr(e,"j"),c=this.getAttr(e,"cx"),d=this.getAttr(e,"cy"),g=this.getAttr(e,"width"),u=this.getAttr(e,"height");if(o.tooltipLabels.drawSeriesTexts({ttItems:i.ttItems,i:l,j:h,shared:!1,e:e}),n.globals.capturedSeriesIndex=l,n.globals.capturedDataPointIndex=h,a=c+o.tooltipRect.ttWidth/2+g,s=d+o.tooltipRect.ttHeight/2-u/2,o.tooltipPosition.moveXCrosshairs(c+g/2),a>n.globals.gridWidth/2&&(a=c-o.tooltipRect.ttWidth/2+g),o.w.config.tooltip.followCursor){var p=n.globals.dom.elWrap.getBoundingClientRect();a=n.globals.clientX-p.left-(a>n.globals.gridWidth/2?o.tooltipRect.ttWidth:0),s=n.globals.clientY-p.top-(s>n.globals.gridHeight/2?o.tooltipRect.ttHeight:0)}}return{x:a,y:s}}},{key:"handleMarkerTooltip",value:function(t){var e,i,a=t.e,s=t.opt,r=t.x,o=t.y,n=this.w,l=this.ttCtx;if(a.target.classList.contains("apexcharts-marker")){var h=parseInt(s.paths.getAttribute("cx"),10),c=parseInt(s.paths.getAttribute("cy"),10),d=parseFloat(s.paths.getAttribute("val"));if(i=parseInt(s.paths.getAttribute("rel"),10),e=parseInt(s.paths.parentNode.parentNode.parentNode.getAttribute("rel"),10)-1,l.intersect){var g=y.findAncestor(s.paths,"apexcharts-series");g&&(e=parseInt(g.getAttribute("data:realIndex"),10))}if(l.tooltipLabels.drawSeriesTexts({ttItems:s.ttItems,i:e,j:i,shared:!l.showOnIntersect&&n.config.tooltip.shared,e:a}),"mouseup"===a.type&&l.markerClick(a,e,i),n.globals.capturedSeriesIndex=e,n.globals.capturedDataPointIndex=i,r=h,o=c+n.globals.translateY-1.4*l.tooltipRect.ttHeight,l.w.config.tooltip.followCursor){var u=l.getElGrid().getBoundingClientRect();o=l.e.clientY+n.globals.translateY-u.top}d<0&&(o=c),l.marker.enlargeCurrentPoint(i,s.paths,r,o)}return{x:r,y:o}}},{key:"handleBarTooltip",value:function(t){var e,i,a=t.e,s=t.opt,r=this.w,o=this.ttCtx,n=o.getElTooltip(),l=0,h=0,c=0,d=this.getBarTooltipXY({e:a,opt:s});e=d.i;var g=d.barHeight,u=d.j;r.globals.capturedSeriesIndex=e,r.globals.capturedDataPointIndex=u,r.globals.isBarHorizontal&&o.tooltipUtil.hasBars()||!r.config.tooltip.shared?(h=d.x,c=d.y,i=Array.isArray(r.config.stroke.width)?r.config.stroke.width[e]:r.config.stroke.width,l=h):r.globals.comboCharts||r.config.tooltip.shared||(l/=2),isNaN(c)&&(c=r.globals.svgHeight-o.tooltipRect.ttHeight);var p=parseInt(s.paths.parentNode.getAttribute("data:realIndex"),10),f=r.globals.isMultipleYAxis?r.config.yaxis[p]&&r.config.yaxis[p].reversed:r.config.yaxis[0].reversed;if(h+o.tooltipRect.ttWidth>r.globals.gridWidth&&!f?h-=o.tooltipRect.ttWidth:h<0&&(h=0),o.w.config.tooltip.followCursor){var x=o.getElGrid().getBoundingClientRect();c=o.e.clientY-x.top}null===o.tooltip&&(o.tooltip=r.globals.dom.baseEl.querySelector(".apexcharts-tooltip")),r.config.tooltip.shared||(r.globals.comboBarCount>0?o.tooltipPosition.moveXCrosshairs(l+i/2):o.tooltipPosition.moveXCrosshairs(l)),!o.fixedTooltip&&(!r.config.tooltip.shared||r.globals.isBarHorizontal&&o.tooltipUtil.hasBars())&&(f&&(h-=o.tooltipRect.ttWidth)<0&&(h=0),!f||r.globals.isBarHorizontal&&o.tooltipUtil.hasBars()||(c=c+g-2*(r.globals.series[e][u]<0?g:0)),c=c+r.globals.translateY-o.tooltipRect.ttHeight/2,n.style.left=h+r.globals.translateX+"px",n.style.top=c+"px")}},{key:"getBarTooltipXY",value:function(t){var e=this,i=t.e,a=t.opt,s=this.w,r=null,o=this.ttCtx,n=0,l=0,h=0,c=0,d=0,g=i.target.classList;if(g.contains("apexcharts-bar-area")||g.contains("apexcharts-candlestick-area")||g.contains("apexcharts-boxPlot-area")||g.contains("apexcharts-rangebar-area")){var u=i.target,p=u.getBoundingClientRect(),f=a.elGrid.getBoundingClientRect(),x=p.height;d=p.height;var b=p.width,v=parseInt(u.getAttribute("cx"),10),m=parseInt(u.getAttribute("cy"),10);c=parseFloat(u.getAttribute("barWidth"));var y="touchmove"===i.type?i.touches[0].clientX:i.clientX;r=parseInt(u.getAttribute("j"),10),n=parseInt(u.parentNode.getAttribute("rel"),10)-1;var w=u.getAttribute("data-range-y1"),k=u.getAttribute("data-range-y2");s.globals.comboCharts&&(n=parseInt(u.parentNode.getAttribute("data:realIndex"),10));var A=function(t){return s.globals.isXNumeric?v-b/2:e.isVerticalGroupedRangeBar?v+b/2:v-o.dataPointsDividedWidth+b/2},S=function(){return m-o.dataPointsDividedHeight+x/2-o.tooltipRect.ttHeight/2};o.tooltipLabels.drawSeriesTexts({ttItems:a.ttItems,i:n,j:r,y1:w?parseInt(w,10):null,y2:k?parseInt(k,10):null,shared:!o.showOnIntersect&&s.config.tooltip.shared,e:i}),s.config.tooltip.followCursor?s.globals.isBarHorizontal?(l=y-f.left+15,h=S()):(l=A(),h=i.clientY-f.top-o.tooltipRect.ttHeight/2-15):s.globals.isBarHorizontal?((l=v)0&&i.setAttribute("width",e.xcrosshairsWidth)}},{key:"handleYCrosshair",value:function(){var t=this.w,e=this.ttCtx;e.ycrosshairs=t.globals.dom.baseEl.querySelector(".apexcharts-ycrosshairs"),e.ycrosshairsHidden=t.globals.dom.baseEl.querySelector(".apexcharts-ycrosshairs-hidden")}},{key:"drawYaxisTooltipText",value:function(t,e,i){var a=this.ttCtx,s=this.w,r=s.globals.yLabelFormatters[t];if(a.yaxisTooltips[t]){var o=a.getElGrid().getBoundingClientRect(),n=(e-o.top)*i.yRatio[t],l=s.globals.maxYArr[t]-s.globals.minYArr[t],h=s.globals.minYArr[t]+(l-n);a.tooltipPosition.moveYCrosshairs(e-o.top),a.yaxisTooltipText[t].innerHTML=r(h),a.tooltipPosition.moveYAxisTooltip(t)}}}]),t}(),wt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w;var i=this.w;this.tConfig=i.config.tooltip,this.tooltipUtil=new ft(this),this.tooltipLabels=new xt(this),this.tooltipPosition=new bt(this),this.marker=new vt(this),this.intersect=new mt(this),this.axesTooltip=new yt(this),this.showOnIntersect=this.tConfig.intersect,this.showTooltipTitle=this.tConfig.x.show,this.fixedTooltip=this.tConfig.fixed.enabled,this.xaxisTooltip=null,this.yaxisTTEls=null,this.isBarShared=!i.globals.isBarHorizontal&&this.tConfig.shared,this.lastHoverTime=Date.now()}return h(t,[{key:"getElTooltip",value:function(t){return t||(t=this),t.w.globals.dom.baseEl?t.w.globals.dom.baseEl.querySelector(".apexcharts-tooltip"):null}},{key:"getElXCrosshairs",value:function(){return this.w.globals.dom.baseEl.querySelector(".apexcharts-xcrosshairs")}},{key:"getElGrid",value:function(){return this.w.globals.dom.baseEl.querySelector(".apexcharts-grid")}},{key:"drawTooltip",value:function(t){var e=this.w;this.xyRatios=t,this.isXAxisTooltipEnabled=e.config.xaxis.tooltip.enabled&&e.globals.axisCharts,this.yaxisTooltips=e.config.yaxis.map((function(t,i){return!!(t.show&&t.tooltip.enabled&&e.globals.axisCharts)})),this.allTooltipSeriesGroups=[],e.globals.axisCharts||(this.showTooltipTitle=!1);var i=document.createElement("div");if(i.classList.add("apexcharts-tooltip"),e.config.tooltip.cssClass&&i.classList.add(e.config.tooltip.cssClass),i.classList.add("apexcharts-theme-".concat(this.tConfig.theme)),e.globals.dom.elWrap.appendChild(i),e.globals.axisCharts){this.axesTooltip.drawXaxisTooltip(),this.axesTooltip.drawYaxisTooltip(),this.axesTooltip.setXCrosshairWidth(),this.axesTooltip.handleYCrosshair();var a=new q(this.ctx);this.xAxisTicksPositions=a.getXAxisTicksPositions()}if(!e.globals.comboCharts&&!this.tConfig.intersect&&"rangeBar"!==e.config.chart.type||this.tConfig.shared||(this.showOnIntersect=!0),0!==e.config.markers.size&&0!==e.globals.markers.largestSize||this.marker.drawDynamicPoints(this),e.globals.collapsedSeries.length!==e.globals.series.length){this.dataPointsDividedHeight=e.globals.gridHeight/e.globals.dataPoints,this.dataPointsDividedWidth=e.globals.gridWidth/e.globals.dataPoints,this.showTooltipTitle&&(this.tooltipTitle=document.createElement("div"),this.tooltipTitle.classList.add("apexcharts-tooltip-title"),this.tooltipTitle.style.fontFamily=this.tConfig.style.fontFamily||e.config.chart.fontFamily,this.tooltipTitle.style.fontSize=this.tConfig.style.fontSize,i.appendChild(this.tooltipTitle));var s=e.globals.series.length;(e.globals.xyCharts||e.globals.comboCharts)&&this.tConfig.shared&&(s=this.showOnIntersect?1:e.globals.series.length),this.legendLabels=e.globals.dom.baseEl.querySelectorAll(".apexcharts-legend-text"),this.ttItems=this.createTTElements(s),this.addSVGEvents()}}},{key:"createTTElements",value:function(t){for(var e=this,i=this.w,a=[],s=this.getElTooltip(),r=function(r){var o=document.createElement("div");o.classList.add("apexcharts-tooltip-series-group"),o.style.order=i.config.tooltip.inverseOrder?t-r:r+1,e.tConfig.shared&&e.tConfig.enabledOnSeries&&Array.isArray(e.tConfig.enabledOnSeries)&&e.tConfig.enabledOnSeries.indexOf(r)<0&&o.classList.add("apexcharts-tooltip-series-group-hidden");var n=document.createElement("span");n.classList.add("apexcharts-tooltip-marker"),n.style.backgroundColor=i.globals.colors[r],o.appendChild(n);var l=document.createElement("div");l.classList.add("apexcharts-tooltip-text"),l.style.fontFamily=e.tConfig.style.fontFamily||i.config.chart.fontFamily,l.style.fontSize=e.tConfig.style.fontSize,["y","goals","z"].forEach((function(t){var e=document.createElement("div");e.classList.add("apexcharts-tooltip-".concat(t,"-group"));var i=document.createElement("span");i.classList.add("apexcharts-tooltip-text-".concat(t,"-label")),e.appendChild(i);var a=document.createElement("span");a.classList.add("apexcharts-tooltip-text-".concat(t,"-value")),e.appendChild(a),l.appendChild(e)})),o.appendChild(l),s.appendChild(o),a.push(o)},o=0;o0&&this.addPathsEventListeners(u,c),this.tooltipUtil.hasBars()&&!this.tConfig.shared&&this.addDatapointEventsListeners(c)}}},{key:"drawFixedTooltipRect",value:function(){var t=this.w,e=this.getElTooltip(),i=e.getBoundingClientRect(),a=i.width+10,s=i.height+10,r=this.tConfig.fixed.offsetX,o=this.tConfig.fixed.offsetY,n=this.tConfig.fixed.position.toLowerCase();return n.indexOf("right")>-1&&(r=r+t.globals.svgWidth-a+10),n.indexOf("bottom")>-1&&(o=o+t.globals.svgHeight-s-10),e.style.left=r+"px",e.style.top=o+"px",{x:r,y:o,ttWidth:a,ttHeight:s}}},{key:"addDatapointEventsListeners",value:function(t){var e=this.w.globals.dom.baseEl.querySelectorAll(".apexcharts-series-markers .apexcharts-marker, .apexcharts-bar-area, .apexcharts-candlestick-area, .apexcharts-boxPlot-area, .apexcharts-rangebar-area");this.addPathsEventListeners(e,t)}},{key:"addPathsEventListeners",value:function(t,e){for(var i=this,a=function(a){var s={paths:t[a],tooltipEl:e.tooltipEl,tooltipY:e.tooltipY,tooltipX:e.tooltipX,elGrid:e.elGrid,hoverArea:e.hoverArea,ttItems:e.ttItems};["mousemove","mouseup","touchmove","mouseout","touchend"].map((function(e){return t[a].addEventListener(e,i.onSeriesHover.bind(i,s),{capture:!1,passive:!0})}))},s=0;s=100?this.seriesHover(t,e):(clearTimeout(this.seriesHoverTimeout),this.seriesHoverTimeout=setTimeout((function(){i.seriesHover(t,e)}),100-a))}},{key:"seriesHover",value:function(t,e){var i=this;this.lastHoverTime=Date.now();var a=[],s=this.w;s.config.chart.group&&(a=this.ctx.getGroupedCharts()),s.globals.axisCharts&&(s.globals.minX===-1/0&&s.globals.maxX===1/0||0===s.globals.dataPoints)||(a.length?a.forEach((function(a){var s=i.getElTooltip(a),r={paths:t.paths,tooltipEl:s,tooltipY:t.tooltipY,tooltipX:t.tooltipX,elGrid:t.elGrid,hoverArea:t.hoverArea,ttItems:a.w.globals.tooltip.ttItems};a.w.globals.minX===i.w.globals.minX&&a.w.globals.maxX===i.w.globals.maxX&&a.w.globals.tooltip.seriesHoverByContext({chartCtx:a,ttCtx:a.w.globals.tooltip,opt:r,e:e})})):this.seriesHoverByContext({chartCtx:this.ctx,ttCtx:this.w.globals.tooltip,opt:t,e:e}))}},{key:"seriesHoverByContext",value:function(t){var e=t.chartCtx,i=t.ttCtx,a=t.opt,s=t.e,r=e.w,o=this.getElTooltip();o&&(i.tooltipRect={x:0,y:0,ttWidth:o.getBoundingClientRect().width,ttHeight:o.getBoundingClientRect().height},i.e=s,!i.tooltipUtil.hasBars()||r.globals.comboCharts||i.isBarShared||this.tConfig.onDatasetHover.highlightDataSeries&&new V(e).toggleSeriesOnHover(s,s.target.parentNode),i.fixedTooltip&&i.drawFixedTooltipRect(),r.globals.axisCharts?i.axisChartsTooltips({e:s,opt:a,tooltipRect:i.tooltipRect}):i.nonAxisChartsTooltips({e:s,opt:a,tooltipRect:i.tooltipRect}))}},{key:"axisChartsTooltips",value:function(t){var e,i,a=t.e,s=t.opt,r=this.w,o=s.elGrid.getBoundingClientRect(),n="touchmove"===a.type?a.touches[0].clientX:a.clientX,l="touchmove"===a.type?a.touches[0].clientY:a.clientY;if(this.clientY=l,this.clientX=n,r.globals.capturedSeriesIndex=-1,r.globals.capturedDataPointIndex=-1,lo.top+o.height)this.handleMouseOut(s);else{if(Array.isArray(this.tConfig.enabledOnSeries)&&!r.config.tooltip.shared){var h=parseInt(s.paths.getAttribute("index"),10);if(this.tConfig.enabledOnSeries.indexOf(h)<0)return void this.handleMouseOut(s)}var c=this.getElTooltip(),d=this.getElXCrosshairs(),g=r.globals.xyCharts||"bar"===r.config.chart.type&&!r.globals.isBarHorizontal&&this.tooltipUtil.hasBars()&&this.tConfig.shared||r.globals.comboCharts&&this.tooltipUtil.hasBars();if("mousemove"===a.type||"touchmove"===a.type||"mouseup"===a.type){if(r.globals.collapsedSeries.length+r.globals.ancillaryCollapsedSeries.length===r.globals.series.length)return;null!==d&&d.classList.add("apexcharts-active");var u=this.yaxisTooltips.filter((function(t){return!0===t}));if(null!==this.ycrosshairs&&u.length&&this.ycrosshairs.classList.add("apexcharts-active"),g&&!this.showOnIntersect)this.handleStickyTooltip(a,n,l,s);else if("heatmap"===r.config.chart.type||"treemap"===r.config.chart.type){var p=this.intersect.handleHeatTreeTooltip({e:a,opt:s,x:e,y:i,type:r.config.chart.type});e=p.x,i=p.y,c.style.left=e+"px",c.style.top=i+"px"}else this.tooltipUtil.hasBars()&&this.intersect.handleBarTooltip({e:a,opt:s}),this.tooltipUtil.hasMarkers()&&this.intersect.handleMarkerTooltip({e:a,opt:s,x:e,y:i});if(this.yaxisTooltips.length)for(var f=0;fl.width)this.handleMouseOut(a);else if(null!==n)this.handleStickyCapturedSeries(t,n,a,o);else if(this.tooltipUtil.isXoverlap(o)||s.globals.isBarHorizontal){var h=s.globals.series.findIndex((function(t,e){return!s.globals.collapsedSeriesIndices.includes(e)}));this.create(t,this,h,o,a.ttItems)}}},{key:"handleStickyCapturedSeries",value:function(t,e,i,a){var s=this.w;if(this.tConfig.shared||null!==s.globals.series[e][a]){if(void 0!==s.globals.series[e][a])this.tConfig.shared&&this.tooltipUtil.isXoverlap(a)&&this.tooltipUtil.isInitialSeriesSameLen()?this.create(t,this,e,a,i.ttItems):this.create(t,this,e,a,i.ttItems,!1);else if(this.tooltipUtil.isXoverlap(a)){var r=s.globals.series.findIndex((function(t,e){return!s.globals.collapsedSeriesIndices.includes(e)}));this.create(t,this,r,a,i.ttItems)}}else this.handleMouseOut(i)}},{key:"deactivateHoverFilter",value:function(){for(var t=this.w,e=new A(this.ctx),i=t.globals.dom.Paper.select(".apexcharts-bar-area"),a=0;a5&&void 0!==arguments[5]?arguments[5]:null,S=this.w,C=e;"mouseup"===t.type&&this.markerClick(t,i,a),null===k&&(k=this.tConfig.shared);var L=this.tooltipUtil.hasMarkers(i),P=this.tooltipUtil.getElBars();if(S.config.legend.tooltipHoverFormatter){var T=S.config.legend.tooltipHoverFormatter,I=Array.from(this.legendLabels);I.forEach((function(t){var e=t.getAttribute("data:default-text");t.innerHTML=decodeURIComponent(e)}));for(var M=0;M0?C.marker.enlargePoints(a):C.tooltipPosition.moveDynamicPointsOnHover(a);else if(this.tooltipUtil.hasBars()&&(this.barSeriesHeight=this.tooltipUtil.getBarsHeight(P),this.barSeriesHeight>0)){var R=new A(this.ctx),O=S.globals.dom.Paper.select(".apexcharts-bar-area[j='".concat(a,"']"));this.deactivateHoverFilter(),this.tooltipPosition.moveStickyTooltipOverBars(a,i);for(var H=0;Ha.globals.gridHeight&&(p=a.globals.gridHeight-v)),{bcx:h,bcy:l,dataLabelsX:u,dataLabelsY:p,totalDataLabelsX:i,totalDataLabelsY:e,totalDataLabelsAnchor:"middle"}}},{key:"calculateBarsDataLabelsPosition",value:function(t){var e=this.w,i=t.x,a=t.i,s=t.j,r=t.realIndex,o=t.groupIndex,n=t.bcy,l=t.barHeight,h=t.barWidth,c=t.textRects,d=t.dataLabelsX,g=t.strokeWidth,u=t.dataLabelsConfig,p=t.barDataLabelsConfig,f=t.barTotalDataLabelsConfig,x=t.offX,b=t.offY,v=e.globals.gridHeight/e.globals.dataPoints;h=Math.abs(h);var m,y,w=(n+=-1!==o?o*l:0)-(this.barCtx.isRangeBar?0:v)+l/2+c.height/2+b-3,k="start",S=this.barCtx.series[a][s]<0,C=i;switch(this.barCtx.isReversed&&(C=i+h-(S?2*h:0),i=e.globals.gridWidth-h),p.position){case"center":d=S?C+h/2-x:Math.max(c.width/2,C-h/2)+x;break;case"bottom":d=S?C+h-g-Math.round(c.width/2)-x:C-h+g+Math.round(c.width/2)+x;break;case"top":d=S?C-g+Math.round(c.width/2)-x:C-g-Math.round(c.width/2)+x}if(this.barCtx.lastActiveBarSerieIndex===r&&f.enabled){var L=new A(this.barCtx.ctx).getTextRects(this.getStackedTotalDataLabel({realIndex:r,j:s}),u.fontSize);S?(m=C-g+Math.round(L.width/2)-x-f.offsetX-15,k="end"):m=C-g-Math.round(L.width/2)+x+f.offsetX+15,y=w+f.offsetY}return e.config.chart.stacked||(d<0?d=d+c.width+g:d+c.width/2>e.globals.gridWidth&&(d=e.globals.gridWidth-c.width-g)),{bcx:i,bcy:n,dataLabelsX:d,dataLabelsY:w,totalDataLabelsX:m,totalDataLabelsY:y,totalDataLabelsAnchor:k}}},{key:"drawCalculatedDataLabels",value:function(t){var e=t.x,i=t.y,a=t.val,s=t.i,o=t.j,n=t.textRects,l=t.barHeight,h=t.barWidth,c=t.dataLabelsConfig,d=this.w,g="rotate(0)";"vertical"===d.config.plotOptions.bar.dataLabels.orientation&&(g="rotate(-90, ".concat(e,", ").concat(i,")"));var u=new G(this.barCtx.ctx),p=new A(this.barCtx.ctx),f=c.formatter,x=null,b=d.globals.collapsedSeriesIndices.indexOf(s)>-1;if(c.enabled&&!b){x=p.group({class:"apexcharts-data-labels",transform:g});var v="";void 0!==a&&(v=f(a,r(r({},d),{},{seriesIndex:s,dataPointIndex:o,w:d}))),!a&&d.config.plotOptions.bar.hideZeroBarsWhenGrouped&&(v="");var m=d.globals.series[s][o]<0,y=d.config.plotOptions.bar.dataLabels.position;"vertical"===d.config.plotOptions.bar.dataLabels.orientation&&("top"===y&&(c.textAnchor=m?"end":"start"),"center"===y&&(c.textAnchor="middle"),"bottom"===y&&(c.textAnchor=m?"end":"start")),this.barCtx.isRangeBar&&this.barCtx.barOptions.dataLabels.hideOverflowingLabels&&hMath.abs(h)&&(v=""):n.height/1.6>Math.abs(l)&&(v=""));var w=r({},c);this.barCtx.isHorizontal&&a<0&&("start"===c.textAnchor?w.textAnchor="end":"end"===c.textAnchor&&(w.textAnchor="start")),u.plotDataLabelsText({x:e,y:i,text:v,i:s,j:o,parent:x,dataLabelsConfig:w,alwaysDrawDataLabel:!0,offsetCorrection:!0})}return x}},{key:"drawTotalDataLabels",value:function(t){var e,i=t.x,a=t.y,s=t.val,r=t.realIndex,o=t.textAnchor,n=t.barTotalDataLabelsConfig,l=new A(this.barCtx.ctx);return n.enabled&&void 0!==i&&void 0!==a&&this.barCtx.lastActiveBarSerieIndex===r&&(e=l.drawText({x:i,y:a,foreColor:n.style.color,text:s,textAnchor:o,fontFamily:n.style.fontFamily,fontSize:n.style.fontSize,fontWeight:n.style.fontWeight})),e}}]),t}(),At=function(){function t(e){n(this,t),this.w=e.w,this.barCtx=e}return h(t,[{key:"initVariables",value:function(t){var e=this.w;this.barCtx.series=t,this.barCtx.totalItems=0,this.barCtx.seriesLen=0,this.barCtx.visibleI=-1,this.barCtx.visibleItems=1;for(var i=0;i0&&(this.barCtx.seriesLen=this.barCtx.seriesLen+1,this.barCtx.totalItems+=t[i].length),e.globals.isXNumeric)for(var a=0;ae.globals.minX&&e.globals.seriesX[i][a]0&&(a=l.globals.minXDiff/d),(r=a/c*parseInt(this.barCtx.barOptions.columnWidth,10)/100)<1&&(r=1)}-1===String(this.barCtx.barOptions.columnWidth).indexOf("%")&&(r=parseInt(this.barCtx.barOptions.columnWidth,10)),o=l.globals.gridHeight-this.barCtx.baseLineY[this.barCtx.yaxisIndex]-(this.barCtx.isReversed?l.globals.gridHeight:0)+(this.barCtx.isReversed?2*this.barCtx.baseLineY[this.barCtx.yaxisIndex]:0),t=l.globals.padHorizontal+(a-r*this.barCtx.seriesLen)/2}return{x:t,y:e,yDivision:i,xDivision:a,barHeight:s,barWidth:r,zeroH:o,zeroW:n}}},{key:"initializeStackedPrevVars",value:function(t){var e=t.w;e.globals.hasSeriesGroups?e.globals.seriesGroups.forEach((function(e){t[e]||(t[e]={}),t[e].prevY=[],t[e].prevX=[],t[e].prevYF=[],t[e].prevXF=[],t[e].prevYVal=[],t[e].prevXVal=[]})):(t.prevY=[],t.prevX=[],t.prevYF=[],t.prevXF=[],t.prevYVal=[],t.prevXVal=[])}},{key:"initializeStackedXYVars",value:function(t){var e=t.w;e.globals.hasSeriesGroups?e.globals.seriesGroups.forEach((function(e){t[e]||(t[e]={}),t[e].xArrj=[],t[e].xArrjF=[],t[e].xArrjVal=[],t[e].yArrj=[],t[e].yArrjF=[],t[e].yArrjVal=[]})):(t.xArrj=[],t.xArrjF=[],t.xArrjVal=[],t.yArrj=[],t.yArrjF=[],t.yArrjVal=[])}},{key:"getPathFillColor",value:function(t,e,i,a){var s,r,o,n,l=this.w,h=new N(this.barCtx.ctx),c=null,d=this.barCtx.barOptions.distributed?i:e;return this.barCtx.barOptions.colors.ranges.length>0&&this.barCtx.barOptions.colors.ranges.map((function(a){t[e][i]>=a.from&&t[e][i]<=a.to&&(c=a.color)})),l.config.series[e].data[i]&&l.config.series[e].data[i].fillColor&&(c=l.config.series[e].data[i].fillColor),h.fillPath({seriesNumber:this.barCtx.barOptions.distributed?d:a,dataPointIndex:i,color:c,value:t[e][i],fillConfig:null===(s=l.config.series[e].data[i])||void 0===s?void 0:s.fill,fillType:null!==(r=l.config.series[e].data[i])&&void 0!==r&&null!==(o=r.fill)&&void 0!==o&&o.type?null===(n=l.config.series[e].data[i])||void 0===n?void 0:n.fill.type:l.config.fill.type})}},{key:"getStrokeWidth",value:function(t,e,i){var a=0,s=this.w;return this.barCtx.series[t][e]?this.barCtx.isNullValue=!1:this.barCtx.isNullValue=!0,s.config.stroke.show&&(this.barCtx.isNullValue||(a=Array.isArray(this.barCtx.strokeWidth)?this.barCtx.strokeWidth[i]:this.barCtx.strokeWidth)),a}},{key:"shouldApplyRadius",value:function(t){var e=this.w,i=!1;return e.config.plotOptions.bar.borderRadius>0&&(e.config.chart.stacked&&"last"===e.config.plotOptions.bar.borderRadiusWhenStacked?this.barCtx.lastActiveBarSerieIndex===t&&(i=!0):i=!0),i}},{key:"barBackground",value:function(t){var e=t.j,i=t.i,a=t.x1,s=t.x2,r=t.y1,o=t.y2,n=t.elSeries,l=this.w,h=new A(this.barCtx.ctx),c=new V(this.barCtx.ctx).getActiveConfigSeriesIndex();if(this.barCtx.barOptions.colors.backgroundBarColors.length>0&&c===i){e>=this.barCtx.barOptions.colors.backgroundBarColors.length&&(e%=this.barCtx.barOptions.colors.backgroundBarColors.length);var d=this.barCtx.barOptions.colors.backgroundBarColors[e],g=h.drawRect(void 0!==a?a:0,void 0!==r?r:0,void 0!==s?s:l.globals.gridWidth,void 0!==o?o:l.globals.gridHeight,this.barCtx.barOptions.colors.backgroundBarRadius,d,this.barCtx.barOptions.colors.backgroundBarOpacity);n.add(g),g.node.classList.add("apexcharts-backgroundBar")}}},{key:"getColumnPaths",value:function(t){var e,i=t.barWidth,a=t.barXPosition,s=t.y1,r=t.y2,o=t.strokeWidth,n=t.seriesGroup,l=t.realIndex,h=t.i,c=t.j,d=t.w,g=new A(this.barCtx.ctx);(o=Array.isArray(o)?o[l]:o)||(o=0);var u=i,p=a;null!==(e=d.config.series[l].data[c])&&void 0!==e&&e.columnWidthOffset&&(p=a-d.config.series[l].data[c].columnWidthOffset/2,u=i+d.config.series[l].data[c].columnWidthOffset);var f=p,x=p+u;s+=.001,r+=.001;var b=g.move(f,s),v=g.move(f,s),m=g.line(x-o,s);if(d.globals.previousPaths.length>0&&(v=this.barCtx.getPreviousPath(l,c,!1)),b=b+g.line(f,r)+g.line(x-o,r)+g.line(x-o,s)+("around"===d.config.plotOptions.bar.borderRadiusApplication?" Z":" z"),v=v+g.line(f,s)+m+m+m+m+m+g.line(f,s)+("around"===d.config.plotOptions.bar.borderRadiusApplication?" Z":" z"),this.shouldApplyRadius(l)&&(b=g.roundPathCorners(b,d.config.plotOptions.bar.borderRadius)),d.config.chart.stacked){var y=this.barCtx;d.globals.hasSeriesGroups&&n&&(y=this.barCtx[n]),y.yArrj.push(r),y.yArrjF.push(Math.abs(s-r)),y.yArrjVal.push(this.barCtx.series[h][c])}return{pathTo:b,pathFrom:v}}},{key:"getBarpaths",value:function(t){var e,i=t.barYPosition,a=t.barHeight,s=t.x1,r=t.x2,o=t.strokeWidth,n=t.seriesGroup,l=t.realIndex,h=t.i,c=t.j,d=t.w,g=new A(this.barCtx.ctx);(o=Array.isArray(o)?o[l]:o)||(o=0);var u=i,p=a;null!==(e=d.config.series[l].data[c])&&void 0!==e&&e.barHeightOffset&&(u=i-d.config.series[l].data[c].barHeightOffset/2,p=a+d.config.series[l].data[c].barHeightOffset);var f=u,x=u+p;s+=.001,r+=.001;var b=g.move(s,f),v=g.move(s,f);d.globals.previousPaths.length>0&&(v=this.barCtx.getPreviousPath(l,c,!1));var m=g.line(s,x-o);if(b=b+g.line(r,f)+g.line(r,x-o)+m+("around"===d.config.plotOptions.bar.borderRadiusApplication?" Z":" z"),v=v+g.line(s,f)+m+m+m+m+m+g.line(s,f)+("around"===d.config.plotOptions.bar.borderRadiusApplication?" Z":" z"),this.shouldApplyRadius(l)&&(b=g.roundPathCorners(b,d.config.plotOptions.bar.borderRadius)),d.config.chart.stacked){var y=this.barCtx;d.globals.hasSeriesGroups&&n&&(y=this.barCtx[n]),y.xArrj.push(r),y.xArrjF.push(Math.abs(s-r)),y.xArrjVal.push(this.barCtx.series[h][c])}return{pathTo:b,pathFrom:v}}},{key:"checkZeroSeries",value:function(t){for(var e=t.series,i=this.w,a=0;a2&&void 0!==arguments[2]&&!arguments[2]?null:e;return null!=t&&(i=e+t/this.barCtx.invertedYRatio-2*(this.barCtx.isReversed?t/this.barCtx.invertedYRatio:0)),i}},{key:"getYForValue",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&!arguments[2]?null:e;return null!=t&&(i=e-t/this.barCtx.yRatio[this.barCtx.yaxisIndex]+2*(this.barCtx.isReversed?t/this.barCtx.yRatio[this.barCtx.yaxisIndex]:0)),i}},{key:"getGoalValues",value:function(t,e,i,a,s){var o=this,n=this.w,l=[],h=function(a,s){var r;l.push((c(r={},t,"x"===t?o.getXForValue(a,e,!1):o.getYForValue(a,i,!1)),c(r,"attrs",s),r))};if(n.globals.seriesGoals[a]&&n.globals.seriesGoals[a][s]&&Array.isArray(n.globals.seriesGoals[a][s])&&n.globals.seriesGoals[a][s].forEach((function(t){h(t.value,t)})),this.barCtx.barOptions.isDumbbell&&n.globals.seriesRange.length){var d=this.barCtx.barOptions.dumbbellColors?this.barCtx.barOptions.dumbbellColors:n.globals.colors,g={strokeHeight:"x"===t?0:n.globals.markers.size[a],strokeWidth:"x"===t?n.globals.markers.size[a]:0,strokeDashArray:0,strokeLineCap:"round",strokeColor:Array.isArray(d[a])?d[a][0]:d[a]};h(n.globals.seriesRangeStart[a][s],g),h(n.globals.seriesRangeEnd[a][s],r(r({},g),{},{strokeColor:Array.isArray(d[a])?d[a][1]:d[a]}))}return l}},{key:"drawGoalLine",value:function(t){var e=t.barXPosition,i=t.barYPosition,a=t.goalX,s=t.goalY,r=t.barWidth,o=t.barHeight,n=new A(this.barCtx.ctx),l=n.group({className:"apexcharts-bar-goals-groups"});l.node.classList.add("apexcharts-element-hidden"),this.barCtx.w.globals.delayedElements.push({el:l.node}),l.attr("clip-path","url(#gridRectMarkerMask".concat(this.barCtx.w.globals.cuid,")"));var h=null;return this.barCtx.isHorizontal?Array.isArray(a)&&a.forEach((function(t){var e=void 0!==t.attrs.strokeHeight?t.attrs.strokeHeight:o/2,a=i+e+o/2;h=n.drawLine(t.x,a-2*e,t.x,a,t.attrs.strokeColor?t.attrs.strokeColor:void 0,t.attrs.strokeDashArray,t.attrs.strokeWidth?t.attrs.strokeWidth:2,t.attrs.strokeLineCap),l.add(h)})):Array.isArray(s)&&s.forEach((function(t){var i=void 0!==t.attrs.strokeWidth?t.attrs.strokeWidth:r/2,a=e+i+r/2;h=n.drawLine(a-2*i,t.y,a,t.y,t.attrs.strokeColor?t.attrs.strokeColor:void 0,t.attrs.strokeDashArray,t.attrs.strokeHeight?t.attrs.strokeHeight:2,t.attrs.strokeLineCap),l.add(h)})),l}},{key:"drawBarShadow",value:function(t){var e=t.prevPaths,i=t.currPaths,a=t.color,s=this.w,r=e.x,o=e.x1,n=e.barYPosition,l=i.x,h=i.x1,c=i.barYPosition,d=n+i.barHeight,g=new A(this.barCtx.ctx),u=new y,p=g.move(o,d)+g.line(r,d)+g.line(l,c)+g.line(h,c)+g.line(o,d)+("around"===s.config.plotOptions.bar.borderRadiusApplication?" Z":" z");return g.drawPath({d:p,fill:u.shadeColor(.5,y.rgb2hex(a)),stroke:"none",strokeWidth:0,fillOpacity:1,classes:"apexcharts-bar-shadows"})}}]),t}(),St=function(){function t(e,i){n(this,t),this.ctx=e,this.w=e.w;var a=this.w;this.barOptions=a.config.plotOptions.bar,this.isHorizontal=this.barOptions.horizontal,this.strokeWidth=a.config.stroke.width,this.isNullValue=!1,this.isRangeBar=a.globals.seriesRange.length&&this.isHorizontal,this.isVerticalGroupedRangeBar=!a.globals.isBarHorizontal&&a.globals.seriesRange.length&&a.config.plotOptions.bar.rangeBarGroupRows,this.isFunnel=this.barOptions.isFunnel,this.xyRatios=i,null!==this.xyRatios&&(this.xRatio=i.xRatio,this.initialXRatio=i.initialXRatio,this.yRatio=i.yRatio,this.invertedXRatio=i.invertedXRatio,this.invertedYRatio=i.invertedYRatio,this.baseLineY=i.baseLineY,this.baseLineInvertedY=i.baseLineInvertedY),this.yaxisIndex=0,this.seriesLen=0,this.pathArr=[];var s=new V(this.ctx);this.lastActiveBarSerieIndex=s.getActiveConfigSeriesIndex("desc",["bar","column"]);var r=s.getBarSeriesIndices(),o=new S(this.ctx);this.stackedSeriesTotals=o.getStackedSeriesTotals(this.w.config.series.map((function(t,e){return-1===r.indexOf(e)?e:-1})).filter((function(t){return-1!==t}))),this.barHelpers=new At(this)}return h(t,[{key:"draw",value:function(t,e){var i=this.w,a=new A(this.ctx),s=new S(this.ctx,i);t=s.getLogSeries(t),this.series=t,this.yRatio=s.getLogYRatios(this.yRatio),this.barHelpers.initVariables(t);var o=a.group({class:"apexcharts-bar-series apexcharts-plot-series"});i.config.dataLabels.enabled&&this.totalItems>this.barOptions.dataLabels.maxItems&&console.warn("WARNING: DataLabels are enabled but there are too many to display. This may cause performance issue when rendering.");for(var n=0,l=0;n0&&(this.visibleI=this.visibleI+1);var m=0,w=0;this.yRatio.length>1&&(this.yaxisIndex=b),this.isReversed=i.config.yaxis[this.yaxisIndex]&&i.config.yaxis[this.yaxisIndex].reversed;var k=this.barHelpers.initialPositions();p=k.y,m=k.barHeight,c=k.yDivision,g=k.zeroW,u=k.x,w=k.barWidth,h=k.xDivision,d=k.zeroH,this.horizontal||x.push(u+w/2);var C=a.group({class:"apexcharts-datalabels","data:realIndex":b});i.globals.delayedElements.push({el:C.node}),C.node.classList.add("apexcharts-element-hidden");var L=a.group({class:"apexcharts-bar-goals-markers"}),P=a.group({class:"apexcharts-bar-shadows"});i.globals.delayedElements.push({el:P.node}),P.node.classList.add("apexcharts-element-hidden");for(var T=0;T0){var E=this.barHelpers.drawBarShadow({color:"string"==typeof z&&-1===(null==z?void 0:z.indexOf("url"))?z:y.hexToRgba(i.globals.colors[n]),prevPaths:this.pathArr[this.pathArr.length-1],currPaths:M});E&&P.add(E)}this.pathArr.push(M);var Y=this.barHelpers.drawGoalLine({barXPosition:M.barXPosition,barYPosition:M.barYPosition,goalX:M.goalX,goalY:M.goalY,barHeight:m,barWidth:w});Y&&L.add(Y),p=M.y,u=M.x,T>0&&x.push(u+w/2),f.push(p),this.renderSeries({realIndex:b,pathFill:z,j:T,i:n,pathFrom:M.pathFrom,pathTo:M.pathTo,strokeWidth:I,elSeries:v,x:u,y:p,series:t,barHeight:M.barHeight?M.barHeight:m,barWidth:M.barWidth?M.barWidth:w,elDataLabelsWrap:C,elGoalsMarkers:L,elBarShadows:P,visibleSeries:this.visibleI,type:"bar"})}i.globals.seriesXvalues[b]=x,i.globals.seriesYvalues[b]=f,o.add(v)}return o}},{key:"renderSeries",value:function(t){var e=t.realIndex,i=t.pathFill,a=t.lineFill,s=t.j,r=t.i,o=t.groupIndex,n=t.pathFrom,l=t.pathTo,h=t.strokeWidth,c=t.elSeries,d=t.x,g=t.y,u=t.y1,p=t.y2,f=t.series,x=t.barHeight,b=t.barWidth,v=t.barXPosition,m=t.barYPosition,y=t.elDataLabelsWrap,w=t.elGoalsMarkers,S=t.elBarShadows,C=t.visibleSeries,L=t.type,P=this.w,T=new A(this.ctx);a||(a=this.barOptions.distributed?P.globals.stroke.colors[s]:P.globals.stroke.colors[e]),P.config.series[r].data[s]&&P.config.series[r].data[s].strokeColor&&(a=P.config.series[r].data[s].strokeColor),this.isNullValue&&(i="none");var I=s/P.config.chart.animations.animateGradually.delay*(P.config.chart.animations.speed/P.globals.dataPoints)/2.4,M=T.renderPaths({i:r,j:s,realIndex:e,pathFrom:n,pathTo:l,stroke:a,strokeWidth:h,strokeLineCap:P.config.stroke.lineCap,fill:i,animationDelay:I,initialSpeed:P.config.chart.animations.speed,dataChangeSpeed:P.config.chart.animations.dynamicAnimation.speed,className:"apexcharts-".concat(L,"-area")});M.attr("clip-path","url(#gridRectMask".concat(P.globals.cuid,")"));var X=P.config.forecastDataPoints;X.count>0&&s>=P.globals.dataPoints-X.count&&(M.node.setAttribute("stroke-dasharray",X.dashArray),M.node.setAttribute("stroke-width",X.strokeWidth),M.node.setAttribute("fill-opacity",X.fillOpacity)),void 0!==u&&void 0!==p&&(M.attr("data-range-y1",u),M.attr("data-range-y2",p)),new k(this.ctx).setSelectionFilter(M,e,s),c.add(M);var z=new kt(this).handleBarDataLabels({x:d,y:g,y1:u,y2:p,i:r,j:s,series:f,realIndex:e,groupIndex:o,barHeight:x,barWidth:b,barXPosition:v,barYPosition:m,renderedPath:M,visibleSeries:C});return null!==z.dataLabels&&y.add(z.dataLabels),z.totalDataLabels&&y.add(z.totalDataLabels),c.add(y),w&&c.add(w),S&&c.add(S),c}},{key:"drawBarPaths",value:function(t){var e,i=t.indexes,a=t.barHeight,s=t.strokeWidth,r=t.zeroW,o=t.x,n=t.y,l=t.yDivision,h=t.elSeries,c=this.w,d=i.i,g=i.j;if(c.globals.isXNumeric)e=(n=(c.globals.seriesX[d][g]-c.globals.minX)/this.invertedXRatio-a)+a*this.visibleI;else if(c.config.plotOptions.bar.hideZeroBarsWhenGrouped){var u=0,p=0;c.globals.seriesPercent.forEach((function(t,e){t[g]&&u++,e0&&(a=this.seriesLen*a/u),e=n+a*this.visibleI,e-=a*p}else e=n+a*this.visibleI;this.isFunnel&&(r-=(this.barHelpers.getXForValue(this.series[d][g],r)-r)/2),o=this.barHelpers.getXForValue(this.series[d][g],r);var f=this.barHelpers.getBarpaths({barYPosition:e,barHeight:a,x1:r,x2:o,strokeWidth:s,series:this.series,realIndex:i.realIndex,i:d,j:g,w:c});return c.globals.isXNumeric||(n+=l),this.barHelpers.barBackground({j:g,i:d,y1:e-a*this.visibleI,y2:a*this.seriesLen,elSeries:h}),{pathTo:f.pathTo,pathFrom:f.pathFrom,x1:r,x:o,y:n,goalX:this.barHelpers.getGoalValues("x",r,null,d,g),barYPosition:e,barHeight:a}}},{key:"drawColumnPaths",value:function(t){var e,i=t.indexes,a=t.x,s=t.y,r=t.xDivision,o=t.barWidth,n=t.zeroH,l=t.strokeWidth,h=t.elSeries,c=this.w,d=i.realIndex,g=i.i,u=i.j,p=i.bc;if(c.globals.isXNumeric){var f=d;c.globals.seriesX[d].length||(f=c.globals.maxValsInArrayIndex),c.globals.seriesX[f][u]&&(a=(c.globals.seriesX[f][u]-c.globals.minX)/this.xRatio-o*this.seriesLen/2),e=a+o*this.visibleI}else if(c.config.plotOptions.bar.hideZeroBarsWhenGrouped){var x=0,b=0;c.globals.seriesPercent.forEach((function(t,e){t[u]&&x++,e0&&(o=this.seriesLen*o/x),e=a+o*this.visibleI,e-=o*b}else e=a+o*this.visibleI;s=this.barHelpers.getYForValue(this.series[g][u],n);var v=this.barHelpers.getColumnPaths({barXPosition:e,barWidth:o,y1:n,y2:s,strokeWidth:l,series:this.series,realIndex:i.realIndex,i:g,j:u,w:c});return c.globals.isXNumeric||(a+=r),this.barHelpers.barBackground({bc:p,j:u,i:g,x1:e-l/2-o*this.visibleI,x2:o*this.seriesLen+l/2,elSeries:h}),{pathTo:v.pathTo,pathFrom:v.pathFrom,x:a,y:s,goalY:this.barHelpers.getGoalValues("y",null,n,g,u),barXPosition:e,barWidth:o}}},{key:"getPreviousPath",value:function(t,e){for(var i,a=this.w,s=0;s0&&parseInt(r.realIndex,10)===parseInt(t,10)&&void 0!==a.globals.previousPaths[s].paths[e]&&(i=a.globals.previousPaths[s].paths[e].d)}return i}}]),t}(),Ct=function(t){d(i,St);var e=f(i);function i(){return n(this,i),e.apply(this,arguments)}return h(i,[{key:"draw",value:function(t,e){var i=this,a=this.w;this.graphics=new A(this.ctx),this.bar=new St(this.ctx,this.xyRatios);var s=new S(this.ctx,a);t=s.getLogSeries(t),this.yRatio=s.getLogYRatios(this.yRatio),this.barHelpers.initVariables(t),"100%"===a.config.chart.stackType&&(t=a.globals.seriesPercent.slice()),this.series=t,this.barHelpers.initializeStackedPrevVars(this);for(var o=this.graphics.group({class:"apexcharts-bar-series apexcharts-plot-series"}),n=0,l=0,h=function(s,h){var c=void 0,d=void 0,g=void 0,u=void 0,p=-1;i.groupCtx=i,a.globals.seriesGroups.forEach((function(t,e){t.indexOf(a.config.series[s].name)>-1&&(p=e)})),-1!==p&&(i.groupCtx=i[a.globals.seriesGroups[p]]);var f=[],x=[],b=a.globals.comboCharts?e[s]:s;i.yRatio.length>1&&(i.yaxisIndex=b),i.isReversed=a.config.yaxis[i.yaxisIndex]&&a.config.yaxis[i.yaxisIndex].reversed;var v=i.graphics.group({class:"apexcharts-series",seriesName:y.escapeString(a.globals.seriesNames[b]),rel:s+1,"data:realIndex":b});i.ctx.series.addCollapsedClassToSeries(v,b);var m=i.graphics.group({class:"apexcharts-datalabels","data:realIndex":b}),w=i.graphics.group({class:"apexcharts-bar-goals-markers"}),k=0,A=0,S=i.initialPositions(n,l,c,d,g,u);l=S.y,k=S.barHeight,d=S.yDivision,u=S.zeroW,n=S.x,A=S.barWidth,c=S.xDivision,g=S.zeroH,i.barHelpers.initializeStackedXYVars(i),1===i.groupCtx.prevY.length&&i.groupCtx.prevY[0].every((function(t){return isNaN(t)}))&&(i.groupCtx.prevY[0]=i.groupCtx.prevY[0].map((function(t){return g})),i.groupCtx.prevYF[0]=i.groupCtx.prevYF[0].map((function(t){return 0})));for(var C=0;C1?(i=c.globals.minXDiff/this.xRatio)*parseInt(this.barOptions.columnWidth,10)/100:h*parseInt(c.config.plotOptions.bar.columnWidth,10)/100,-1===String(c.config.plotOptions.bar.columnWidth).indexOf("%")&&(h=parseInt(c.config.plotOptions.bar.columnWidth,10)),s=c.globals.gridHeight-this.baseLineY[this.yaxisIndex]-(this.isReversed?c.globals.gridHeight:0)+(this.isReversed?2*this.baseLineY[this.yaxisIndex]:0),t=c.globals.padHorizontal+(i-h)/2),{x:t,y:e,yDivision:a,xDivision:i,barHeight:null!==(o=c.globals.seriesGroups)&&void 0!==o&&o.length?l/c.globals.seriesGroups.length:l,barWidth:null!==(n=c.globals.seriesGroups)&&void 0!==n&&n.length?h/c.globals.seriesGroups.length:h,zeroH:s,zeroW:r}}},{key:"drawStackedBarPaths",value:function(t){for(var e,i=t.indexes,a=t.barHeight,s=t.strokeWidth,r=t.zeroW,o=t.x,n=t.y,l=t.groupIndex,h=t.seriesGroup,c=t.yDivision,d=t.elSeries,g=this.w,u=n+(-1!==l?l*a:0),p=i.i,f=i.j,x=0,b=0;b0){var m=r;this.groupCtx.prevXVal[v-1][f]<0?m=this.series[p][f]>=0?this.groupCtx.prevX[v-1][f]+x-2*(this.isReversed?x:0):this.groupCtx.prevX[v-1][f]:this.groupCtx.prevXVal[v-1][f]>=0&&(m=this.series[p][f]>=0?this.groupCtx.prevX[v-1][f]:this.groupCtx.prevX[v-1][f]-x+2*(this.isReversed?x:0)),e=m}else e=r;o=null===this.series[p][f]?e:e+this.series[p][f]/this.invertedYRatio-2*(this.isReversed?this.series[p][f]/this.invertedYRatio:0);var y=this.barHelpers.getBarpaths({barYPosition:u,barHeight:a,x1:e,x2:o,strokeWidth:s,series:this.series,realIndex:i.realIndex,seriesGroup:h,i:p,j:f,w:g});return this.barHelpers.barBackground({j:f,i:p,y1:u,y2:a,elSeries:d}),n+=c,{pathTo:y.pathTo,pathFrom:y.pathFrom,goalX:this.barHelpers.getGoalValues("x",r,null,p,f),barYPosition:u,x:o,y:n}}},{key:"drawStackedColumnPaths",value:function(t){var e=t.indexes,i=t.x,a=t.y,s=t.xDivision,r=t.barWidth,o=t.zeroH,n=t.groupIndex,l=t.seriesGroup,h=t.elSeries,c=this.w,d=e.i,g=e.j,u=e.bc;if(c.globals.isXNumeric){var p=c.globals.seriesX[d][g];p||(p=0),i=(p-c.globals.minX)/this.xRatio-r/2,c.globals.seriesGroups.length&&(i=(p-c.globals.minX)/this.xRatio-r/2*c.globals.seriesGroups.length)}for(var f,x=i+(-1!==n?n*r:0),b=0,v=0;v0&&!c.globals.isXNumeric||m>0&&c.globals.isXNumeric&&c.globals.seriesX[d-1][g]===c.globals.seriesX[d][g]){var y,w,k,A=Math.min(this.yRatio.length+1,d+1);if(void 0!==this.groupCtx.prevY[m-1]&&this.groupCtx.prevY[m-1].length)for(var S=1;S=0?k-b+2*(this.isReversed?b:0):k;break}if((null===(T=this.groupCtx.prevYVal[m-L])||void 0===T?void 0:T[g])>=0){w=this.series[d][g]>=0?k:k+b-2*(this.isReversed?b:0);break}}void 0===w&&(w=c.globals.gridHeight),f=null!==(y=this.groupCtx.prevYF[0])&&void 0!==y&&y.every((function(t){return 0===t}))&&this.groupCtx.prevYF.slice(1,m).every((function(t){return t.every((function(t){return isNaN(t)}))}))?o:w}else f=o;a=this.series[d][g]?f-this.series[d][g]/this.yRatio[this.yaxisIndex]+2*(this.isReversed?this.series[d][g]/this.yRatio[this.yaxisIndex]:0):f;var I=this.barHelpers.getColumnPaths({barXPosition:x,barWidth:r,y1:f,y2:a,yRatio:this.yRatio[this.yaxisIndex],strokeWidth:this.strokeWidth,series:this.series,seriesGroup:l,realIndex:e.realIndex,i:d,j:g,w:c});return this.barHelpers.barBackground({bc:u,j:g,i:d,x1:x,x2:r,elSeries:h}),i+=s,{pathTo:I.pathTo,pathFrom:I.pathFrom,goalY:this.barHelpers.getGoalValues("y",null,o,d,g),barXPosition:x,x:c.globals.isXNumeric?i-s:i,y:a}}}]),i}(),Lt=function(t){d(i,St);var e=f(i);function i(){return n(this,i),e.apply(this,arguments)}return h(i,[{key:"draw",value:function(t,e,i){var a=this,s=this.w,o=new A(this.ctx),n=s.globals.comboCharts?e:s.config.chart.type,l=new N(this.ctx);this.candlestickOptions=this.w.config.plotOptions.candlestick,this.boxOptions=this.w.config.plotOptions.boxPlot,this.isHorizontal=s.config.plotOptions.bar.horizontal;var h=new S(this.ctx,s);t=h.getLogSeries(t),this.series=t,this.yRatio=h.getLogYRatios(this.yRatio),this.barHelpers.initVariables(t);for(var c=o.group({class:"apexcharts-".concat(n,"-series apexcharts-plot-series")}),d=function(e){a.isBoxPlot="boxPlot"===s.config.chart.type||"boxPlot"===s.config.series[e].type;var n,h,d,g,u,p,f=void 0,x=void 0,b=[],v=[],m=s.globals.comboCharts?i[e]:e,w=o.group({class:"apexcharts-series",seriesName:y.escapeString(s.globals.seriesNames[m]),rel:e+1,"data:realIndex":m});a.ctx.series.addCollapsedClassToSeries(w,m),t[e].length>0&&(a.visibleI=a.visibleI+1),a.yRatio.length>1&&(a.yaxisIndex=m);var k=a.barHelpers.initialPositions();x=k.y,u=k.barHeight,h=k.yDivision,g=k.zeroW,f=k.x,p=k.barWidth,n=k.xDivision,d=k.zeroH,v.push(f+p/2);for(var A=o.group({class:"apexcharts-datalabels","data:realIndex":m}),S=function(i){var o=a.barHelpers.getStrokeWidth(e,i,m),c=null,y={indexes:{i:e,j:i,realIndex:m},x:f,y:x,strokeWidth:o,elSeries:w};c=a.isHorizontal?a.drawHorizontalBoxPaths(r(r({},y),{},{yDivision:h,barHeight:u,zeroW:g})):a.drawVerticalBoxPaths(r(r({},y),{},{xDivision:n,barWidth:p,zeroH:d})),x=c.y,f=c.x,i>0&&v.push(f+p/2),b.push(x),c.pathTo.forEach((function(r,n){var h=!a.isBoxPlot&&a.candlestickOptions.wick.useFillColor?c.color[n]:s.globals.stroke.colors[e],d=l.fillPath({seriesNumber:m,dataPointIndex:i,color:c.color[n],value:t[e][i]});a.renderSeries({realIndex:m,pathFill:d,lineFill:h,j:i,i:e,pathFrom:c.pathFrom,pathTo:r,strokeWidth:o,elSeries:w,x:f,y:x,series:t,barHeight:u,barWidth:p,elDataLabelsWrap:A,visibleSeries:a.visibleI,type:s.config.chart.type})}))},C=0;Cb.c&&(d=!1);var y=Math.min(b.o,b.c),w=Math.max(b.o,b.c),k=b.m;n.globals.isXNumeric&&(i=(n.globals.seriesX[x][c]-n.globals.minX)/this.xRatio-s/2);var S=i+s*this.visibleI;void 0===this.series[h][c]||null===this.series[h][c]?(y=r,w=r):(y=r-y/f,w=r-w/f,v=r-b.h/f,m=r-b.l/f,k=r-b.m/f);var C=l.move(S,r),L=l.move(S+s/2,y);return n.globals.previousPaths.length>0&&(L=this.getPreviousPath(x,c,!0)),C=this.isBoxPlot?[l.move(S,y)+l.line(S+s/2,y)+l.line(S+s/2,v)+l.line(S+s/4,v)+l.line(S+s-s/4,v)+l.line(S+s/2,v)+l.line(S+s/2,y)+l.line(S+s,y)+l.line(S+s,k)+l.line(S,k)+l.line(S,y+o/2),l.move(S,k)+l.line(S+s,k)+l.line(S+s,w)+l.line(S+s/2,w)+l.line(S+s/2,m)+l.line(S+s-s/4,m)+l.line(S+s/4,m)+l.line(S+s/2,m)+l.line(S+s/2,w)+l.line(S,w)+l.line(S,k)+"z"]:[l.move(S,w)+l.line(S+s/2,w)+l.line(S+s/2,v)+l.line(S+s/2,w)+l.line(S+s,w)+l.line(S+s,y)+l.line(S+s/2,y)+l.line(S+s/2,m)+l.line(S+s/2,y)+l.line(S,y)+l.line(S,w-o/2)],L+=l.move(S,y),n.globals.isXNumeric||(i+=a),{pathTo:C,pathFrom:L,x:i,y:w,barXPosition:S,color:this.isBoxPlot?p:d?[g]:[u]}}},{key:"drawHorizontalBoxPaths",value:function(t){var e=t.indexes;t.x;var i=t.y,a=t.yDivision,s=t.barHeight,r=t.zeroW,o=t.strokeWidth,n=this.w,l=new A(this.ctx),h=e.i,c=e.j,d=this.boxOptions.colors.lower;this.isBoxPlot&&(d=[this.boxOptions.colors.lower,this.boxOptions.colors.upper]);var g=this.invertedYRatio,u=e.realIndex,p=this.getOHLCValue(u,c),f=r,x=r,b=Math.min(p.o,p.c),v=Math.max(p.o,p.c),m=p.m;n.globals.isXNumeric&&(i=(n.globals.seriesX[u][c]-n.globals.minX)/this.invertedXRatio-s/2);var y=i+s*this.visibleI;void 0===this.series[h][c]||null===this.series[h][c]?(b=r,v=r):(b=r+b/g,v=r+v/g,f=r+p.h/g,x=r+p.l/g,m=r+p.m/g);var w=l.move(r,y),k=l.move(b,y+s/2);return n.globals.previousPaths.length>0&&(k=this.getPreviousPath(u,c,!0)),w=[l.move(b,y)+l.line(b,y+s/2)+l.line(f,y+s/2)+l.line(f,y+s/2-s/4)+l.line(f,y+s/2+s/4)+l.line(f,y+s/2)+l.line(b,y+s/2)+l.line(b,y+s)+l.line(m,y+s)+l.line(m,y)+l.line(b+o/2,y),l.move(m,y)+l.line(m,y+s)+l.line(v,y+s)+l.line(v,y+s/2)+l.line(x,y+s/2)+l.line(x,y+s-s/4)+l.line(x,y+s/4)+l.line(x,y+s/2)+l.line(v,y+s/2)+l.line(v,y)+l.line(m,y)+"z"],k+=l.move(b,y),n.globals.isXNumeric||(i+=a),{pathTo:w,pathFrom:k,x:v,y:i,barYPosition:y,color:d}}},{key:"getOHLCValue",value:function(t,e){var i=this.w;return{o:this.isBoxPlot?i.globals.seriesCandleH[t][e]:i.globals.seriesCandleO[t][e],h:this.isBoxPlot?i.globals.seriesCandleO[t][e]:i.globals.seriesCandleH[t][e],m:i.globals.seriesCandleM[t][e],l:this.isBoxPlot?i.globals.seriesCandleC[t][e]:i.globals.seriesCandleL[t][e],c:this.isBoxPlot?i.globals.seriesCandleL[t][e]:i.globals.seriesCandleC[t][e]}}}]),i}(),Pt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"checkColorRange",value:function(){var t=this.w,e=!1,i=t.config.plotOptions[t.config.chart.type];return i.colorScale.ranges.length>0&&i.colorScale.ranges.map((function(t,i){t.from<=0&&(e=!0)})),e}},{key:"getShadeColor",value:function(t,e,i,a){var s=this.w,r=1,o=s.config.plotOptions[t].shadeIntensity,n=this.determineColor(t,e,i);s.globals.hasNegs||a?r=s.config.plotOptions[t].reverseNegativeShade?n.percent<0?n.percent/100*(1.25*o):(1-n.percent/100)*(1.25*o):n.percent<=0?1-(1+n.percent/100)*o:(1-n.percent/100)*o:(r=1-n.percent/100,"treemap"===t&&(r=(1-n.percent/100)*(1.25*o)));var l=n.color,h=new y;return s.config.plotOptions[t].enableShades&&(l="dark"===this.w.config.theme.mode?y.hexToRgba(h.shadeColor(-1*r,n.color),s.config.fill.opacity):y.hexToRgba(h.shadeColor(r,n.color),s.config.fill.opacity)),{color:l,colorProps:n}}},{key:"determineColor",value:function(t,e,i){var a=this.w,s=a.globals.series[e][i],r=a.config.plotOptions[t],o=r.colorScale.inverse?i:e;r.distributed&&"treemap"===a.config.chart.type&&(o=i);var n=a.globals.colors[o],l=null,h=Math.min.apply(Math,b(a.globals.series[e])),c=Math.max.apply(Math,b(a.globals.series[e]));r.distributed||"heatmap"!==t||(h=a.globals.minY,c=a.globals.maxY),void 0!==r.colorScale.min&&(h=r.colorScale.mina.globals.maxY?r.colorScale.max:a.globals.maxY);var d=Math.abs(c)+Math.abs(h),g=100*s/(0===d?d-1e-6:d);return r.colorScale.ranges.length>0&&r.colorScale.ranges.map((function(t,e){if(s>=t.from&&s<=t.to){n=t.color,l=t.foreColor?t.foreColor:null,h=t.from,c=t.to;var i=Math.abs(c)+Math.abs(h);g=100*s/(0===i?i-1e-6:i)}})),{color:n,foreColor:l,percent:g}}},{key:"calculateDataLabels",value:function(t){var e=t.text,i=t.x,a=t.y,s=t.i,r=t.j,o=t.colorProps,n=t.fontSize,l=this.w.config.dataLabels,h=new A(this.ctx),c=new G(this.ctx),d=null;if(l.enabled){d=h.group({class:"apexcharts-data-labels"});var g=l.offsetX,u=l.offsetY,p=i+g,f=a+parseFloat(l.style.fontSize)/3+u;c.plotDataLabelsText({x:p,y:f,text:e,i:s,j:r,color:o.foreColor,parent:d,fontSize:n,dataLabelsConfig:l})}return d}},{key:"addListeners",value:function(t){var e=new A(this.ctx);t.node.addEventListener("mouseenter",e.pathMouseEnter.bind(this,t)),t.node.addEventListener("mouseleave",e.pathMouseLeave.bind(this,t)),t.node.addEventListener("mousedown",e.pathMouseDown.bind(this,t))}}]),t}(),Tt=function(){function t(e,i){n(this,t),this.ctx=e,this.w=e.w,this.xRatio=i.xRatio,this.yRatio=i.yRatio,this.dynamicAnim=this.w.config.chart.animations.dynamicAnimation,this.helpers=new Pt(e),this.rectRadius=this.w.config.plotOptions.heatmap.radius,this.strokeWidth=this.w.config.stroke.show?this.w.config.stroke.width:0}return h(t,[{key:"draw",value:function(t){var e=this.w,i=new A(this.ctx),a=i.group({class:"apexcharts-heatmap"});a.attr("clip-path","url(#gridRectMask".concat(e.globals.cuid,")"));var s=e.globals.gridWidth/e.globals.dataPoints,r=e.globals.gridHeight/e.globals.series.length,o=0,n=!1;this.negRange=this.helpers.checkColorRange();var l=t.slice();e.config.yaxis[0].reversed&&(n=!0,l.reverse());for(var h=n?0:l.length-1;n?h=0;n?h++:h--){var c=i.group({class:"apexcharts-series apexcharts-heatmap-series",seriesName:y.escapeString(e.globals.seriesNames[h]),rel:h+1,"data:realIndex":h});if(this.ctx.series.addCollapsedClassToSeries(c,h),e.config.chart.dropShadow.enabled){var d=e.config.chart.dropShadow;new k(this.ctx).dropShadow(c,d,h)}for(var g=0,u=e.config.plotOptions.heatmap.shadeIntensity,p=0;p-1&&this.pieClicked(d),i.config.dataLabels.enabled){var w=v.x,S=v.y,C=100*u/this.fullAngle+"%";if(0!==u&&i.config.plotOptions.pie.dataLabels.minAngleToShowLabelthis.fullAngle?e.endAngle=e.endAngle-(a+o):a+o=this.fullAngle+this.w.config.plotOptions.pie.startAngle%this.fullAngle&&(n=this.fullAngle+this.w.config.plotOptions.pie.startAngle%this.fullAngle-.01),Math.ceil(n)>this.fullAngle&&(n-=this.fullAngle);var l=Math.PI*(n-90)/180,h=e.centerX+s*Math.cos(o),c=e.centerY+s*Math.sin(o),d=e.centerX+s*Math.cos(l),g=e.centerY+s*Math.sin(l),u=y.polarToCartesian(e.centerX,e.centerY,e.donutSize,n),p=y.polarToCartesian(e.centerX,e.centerY,e.donutSize,r),f=a>180?1:0,x=["M",h,c,"A",s,s,0,f,1,d,g];return"donut"===e.chartType?[].concat(x,["L",u.x,u.y,"A",e.donutSize,e.donutSize,0,f,0,p.x,p.y,"L",h,c,"z"]).join(" "):"pie"===e.chartType||"polarArea"===e.chartType?[].concat(x,["L",e.centerX,e.centerY,"L",h,c]).join(" "):[].concat(x).join(" ")}},{key:"drawPolarElements",value:function(t){var e=this.w,i=new $(this.ctx),a=new A(this.ctx),s=new It(this.ctx),r=a.group(),o=a.group(),n=i.niceScale(0,Math.ceil(this.maxY),e.config.yaxis[0].tickAmount,0,!0),l=n.result.reverse(),h=n.result.length;this.maxY=n.niceMax;for(var c=e.globals.radialSize,d=c/(h-1),g=0;g1&&t.total.show&&(s=t.total.color);var o=r.globals.dom.baseEl.querySelector(".apexcharts-datalabel-label"),n=r.globals.dom.baseEl.querySelector(".apexcharts-datalabel-value");i=(0,t.value.formatter)(i,r),a||"function"!=typeof t.total.formatter||(i=t.total.formatter(r));var l=e===t.total.label;e=t.name.formatter(e,l,r),null!==o&&(o.textContent=e),null!==n&&(n.textContent=i),null!==o&&(o.style.fill=s)}},{key:"printDataLabelsInner",value:function(t,e){var i=this.w,a=t.getAttribute("data:value"),s=i.globals.seriesNames[parseInt(t.parentNode.getAttribute("rel"),10)-1];i.globals.series.length>1&&this.printInnerLabels(e,s,a,t);var r=i.globals.dom.baseEl.querySelector(".apexcharts-datalabels-group");null!==r&&(r.style.opacity=1)}},{key:"drawSpokes",value:function(t){var e=this,i=this.w,a=new A(this.ctx),s=i.config.plotOptions.polarArea.spokes;if(0!==s.strokeWidth){for(var r=[],o=360/i.globals.series.length,n=0;n1)o&&!e.total.showAlways?l({makeSliceOut:!1,printLabel:!0}):this.printInnerLabels(e,e.total.label,e.total.formatter(s));else if(l({makeSliceOut:!1,printLabel:!0}),!o)if(s.globals.selectedDataPoints.length&&s.globals.series.length>1)if(s.globals.selectedDataPoints[0].length>0){var h=s.globals.selectedDataPoints[0],c=s.globals.dom.baseEl.querySelector(".apexcharts-".concat(this.chartType.toLowerCase(),"-slice-").concat(h));this.printDataLabelsInner(c,e)}else r&&s.globals.selectedDataPoints.length&&0===s.globals.selectedDataPoints[0].length&&(r.style.opacity=0);else r&&s.globals.series.length>1&&(r.style.opacity=0)}}]),t}(),Xt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.chartType=this.w.config.chart.type,this.initialAnim=this.w.config.chart.animations.enabled,this.dynamicAnim=this.initialAnim&&this.w.config.chart.animations.dynamicAnimation.enabled,this.animDur=0;var i=this.w;this.graphics=new A(this.ctx),this.lineColorArr=void 0!==i.globals.stroke.colors?i.globals.stroke.colors:i.globals.colors,this.defaultSize=i.globals.svgHeight0&&(f=e.getPreviousPath(n));for(var x=0;x=10?t.x>0?(i="start",a+=10):t.x<0&&(i="end",a-=10):i="middle",Math.abs(t.y)>=e-10&&(t.y<0?s-=10:t.y>0&&(s+=10)),{textAnchor:i,newX:a,newY:s}}},{key:"getPreviousPath",value:function(t){for(var e=this.w,i=null,a=0;a0&&parseInt(s.realIndex,10)===parseInt(t,10)&&void 0!==e.globals.previousPaths[a].paths[0]&&(i=e.globals.previousPaths[a].paths[0].d)}return i}},{key:"getDataPointsPos",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.dataPointsLen;t=t||[],e=e||[];for(var a=[],s=0;s=360&&(g=360-Math.abs(this.startAngle)-.1);var u=i.drawPath({d:"",stroke:c,strokeWidth:o*parseInt(h.strokeWidth,10)/100,fill:"none",strokeOpacity:h.opacity,classes:"apexcharts-radialbar-area"});if(h.dropShadow.enabled){var p=h.dropShadow;s.dropShadow(u,p)}l.add(u),u.attr("id","apexcharts-radialbarTrack-"+n),this.animatePaths(u,{centerX:t.centerX,centerY:t.centerY,endAngle:g,startAngle:d,size:t.size,i:n,totalItems:2,animBeginArr:0,dur:0,isTrack:!0,easing:e.globals.easing})}return a}},{key:"drawArcs",value:function(t){var e=this.w,i=new A(this.ctx),a=new N(this.ctx),s=new k(this.ctx),r=i.group(),o=this.getStrokeWidth(t);t.size=t.size-o/2;var n=e.config.plotOptions.radialBar.hollow.background,l=t.size-o*t.series.length-this.margin*t.series.length-o*parseInt(e.config.plotOptions.radialBar.track.strokeWidth,10)/100/2,h=l-e.config.plotOptions.radialBar.hollow.margin;void 0!==e.config.plotOptions.radialBar.hollow.image&&(n=this.drawHollowImage(t,r,l,n));var c=this.drawHollow({size:h,centerX:t.centerX,centerY:t.centerY,fill:n||"transparent"});if(e.config.plotOptions.radialBar.hollow.dropShadow.enabled){var d=e.config.plotOptions.radialBar.hollow.dropShadow;s.dropShadow(c,d)}var g=1;!this.radialDataLabels.total.show&&e.globals.series.length>1&&(g=0);var u=null;this.radialDataLabels.show&&(u=this.renderInnerDataLabels(this.radialDataLabels,{hollowSize:l,centerX:t.centerX,centerY:t.centerY,opacity:g})),"back"===e.config.plotOptions.radialBar.hollow.position&&(r.add(c),u&&r.add(u));var p=!1;e.config.plotOptions.radialBar.inverseOrder&&(p=!0);for(var f=p?t.series.length-1:0;p?f>=0:f100?100:t.series[f])/100,S=Math.round(this.totalAngle*w)+this.startAngle,C=void 0;e.globals.dataChanged&&(m=this.startAngle,C=Math.round(this.totalAngle*y.negToZero(e.globals.previousPaths[f])/100)+m),Math.abs(S)+Math.abs(v)>=360&&(S-=.01),Math.abs(C)+Math.abs(m)>=360&&(C-=.01);var L=S-v,P=Array.isArray(e.config.stroke.dashArray)?e.config.stroke.dashArray[f]:e.config.stroke.dashArray,T=i.drawPath({d:"",stroke:b,strokeWidth:o,fill:"none",fillOpacity:e.config.fill.opacity,classes:"apexcharts-radialbar-area apexcharts-radialbar-slice-"+f,strokeDashArray:P});if(A.setAttrs(T.node,{"data:angle":L,"data:value":t.series[f]}),e.config.chart.dropShadow.enabled){var I=e.config.chart.dropShadow;s.dropShadow(T,I,f)}s.setSelectionFilter(T,0,f),this.addListeners(T,this.radialDataLabels),x.add(T),T.attr({index:0,j:f});var M=0;!this.initialAnim||e.globals.resized||e.globals.dataChanged||(M=e.config.chart.animations.speed),e.globals.dataChanged&&(M=e.config.chart.animations.dynamicAnimation.speed),this.animDur=M/(1.2*t.series.length)+this.animDur,this.animBeginArr.push(this.animDur),this.animatePaths(T,{centerX:t.centerX,centerY:t.centerY,endAngle:S,startAngle:v,prevEndAngle:C,prevStartAngle:m,size:t.size,i:f,totalItems:2,animBeginArr:this.animBeginArr,dur:M,shouldSetPrevPaths:!0,easing:e.globals.easing})}return{g:r,elHollow:c,dataLabels:u}}},{key:"drawHollow",value:function(t){var e=new A(this.ctx).drawCircle(2*t.size);return e.attr({class:"apexcharts-radialbar-hollow",cx:t.centerX,cy:t.centerY,r:t.size,fill:t.fill}),e}},{key:"drawHollowImage",value:function(t,e,i,a){var s=this.w,r=new N(this.ctx),o=y.randomId(),n=s.config.plotOptions.radialBar.hollow.image;if(s.config.plotOptions.radialBar.hollow.imageClipped)r.clippedImgArea({width:i,height:i,image:n,patternID:"pattern".concat(s.globals.cuid).concat(o)}),a="url(#pattern".concat(s.globals.cuid).concat(o,")");else{var l=s.config.plotOptions.radialBar.hollow.imageWidth,h=s.config.plotOptions.radialBar.hollow.imageHeight;if(void 0===l&&void 0===h){var c=s.globals.dom.Paper.image(n).loaded((function(e){this.move(t.centerX-e.width/2+s.config.plotOptions.radialBar.hollow.imageOffsetX,t.centerY-e.height/2+s.config.plotOptions.radialBar.hollow.imageOffsetY)}));e.add(c)}else{var d=s.globals.dom.Paper.image(n).loaded((function(e){this.move(t.centerX-l/2+s.config.plotOptions.radialBar.hollow.imageOffsetX,t.centerY-h/2+s.config.plotOptions.radialBar.hollow.imageOffsetY),this.size(l,h)}));e.add(d)}}return a}},{key:"getStrokeWidth",value:function(t){var e=this.w;return t.size*(100-parseInt(e.config.plotOptions.radialBar.hollow.size,10))/100/(t.series.length+1)-this.margin}}]),i}(),Et=function(t){d(i,St);var e=f(i);function i(){return n(this,i),e.apply(this,arguments)}return h(i,[{key:"draw",value:function(t,e){var i=this.w,a=new A(this.ctx);this.rangeBarOptions=this.w.config.plotOptions.rangeBar,this.series=t,this.seriesRangeStart=i.globals.seriesRangeStart,this.seriesRangeEnd=i.globals.seriesRangeEnd,this.barHelpers.initVariables(t);for(var s=a.group({class:"apexcharts-rangebar-series apexcharts-plot-series"}),o=0;o0&&(this.visibleI=this.visibleI+1);var x=0,b=0;this.yRatio.length>1&&(this.yaxisIndex=p);var v=this.barHelpers.initialPositions();u=v.y,d=v.zeroW,g=v.x,b=v.barWidth,x=v.barHeight,n=v.xDivision,l=v.yDivision,h=v.zeroH;for(var m=a.group({class:"apexcharts-datalabels","data:realIndex":p}),w=a.group({class:"apexcharts-rangebar-goals-markers"}),k=0;k0}));return this.isHorizontal?(a=g.config.plotOptions.bar.rangeBarGroupRows?r+h*b:r+n*this.visibleI+h*b,v>-1&&!g.config.plotOptions.bar.rangeBarOverlap&&(u=g.globals.seriesRange[e][v].overlaps).indexOf(p)>-1&&(a=(n=d.barHeight/u.length)*this.visibleI+h*(100-parseInt(this.barOptions.barHeight,10))/100/2+n*(this.visibleI+u.indexOf(p))+h*b)):(b>-1&&(s=g.config.plotOptions.bar.rangeBarGroupRows?o+c*b:o+l*this.visibleI+c*b),v>-1&&!g.config.plotOptions.bar.rangeBarOverlap&&(u=g.globals.seriesRange[e][v].overlaps).indexOf(p)>-1&&(s=(l=d.barWidth/u.length)*this.visibleI+c*(100-parseInt(this.barOptions.barWidth,10))/100/2+l*(this.visibleI+u.indexOf(p))+c*b)),{barYPosition:a,barXPosition:s,barHeight:n,barWidth:l}}},{key:"drawRangeColumnPaths",value:function(t){var e=t.indexes,i=t.x,a=t.xDivision,s=t.barWidth,r=t.barXPosition,o=t.zeroH,n=this.w,l=e.i,h=e.j,c=this.yRatio[this.yaxisIndex],d=e.realIndex,g=this.getRangeValue(d,h),u=Math.min(g.start,g.end),p=Math.max(g.start,g.end);void 0===this.series[l][h]||null===this.series[l][h]?u=o:(u=o-u/c,p=o-p/c);var f=Math.abs(p-u),x=this.barHelpers.getColumnPaths({barXPosition:r,barWidth:s,y1:u,y2:p,strokeWidth:this.strokeWidth,series:this.seriesRangeEnd,realIndex:e.realIndex,i:d,j:h,w:n});return n.globals.isXNumeric||(i+=a),{pathTo:x.pathTo,pathFrom:x.pathFrom,barHeight:f,x:i,y:p,goalY:this.barHelpers.getGoalValues("y",null,o,l,h),barXPosition:r}}},{key:"drawRangeBarPaths",value:function(t){var e=t.indexes,i=t.y,a=t.y1,s=t.y2,r=t.yDivision,o=t.barHeight,n=t.barYPosition,l=t.zeroW,h=this.w,c=l+a/this.invertedYRatio,d=l+s/this.invertedYRatio,g=Math.abs(d-c),u=this.barHelpers.getBarpaths({barYPosition:n,barHeight:o,x1:c,x2:d,strokeWidth:this.strokeWidth,series:this.seriesRangeEnd,i:e.realIndex,realIndex:e.realIndex,j:e.j,w:h});return h.globals.isXNumeric||(i+=r),{pathTo:u.pathTo,pathFrom:u.pathFrom,barWidth:g,x:d,goalX:this.barHelpers.getGoalValues("x",l,null,e.realIndex,e.j),y:i}}},{key:"getRangeValue",value:function(t,e){var i=this.w;return{start:i.globals.seriesRangeStart[t][e],end:i.globals.seriesRangeEnd[t][e]}}}]),i}(),Yt=function(){function t(e){n(this,t),this.w=e.w,this.lineCtx=e}return h(t,[{key:"sameValueSeriesFix",value:function(t,e){var i=this.w;if(("gradient"===i.config.fill.type||"gradient"===i.config.fill.type[t])&&new S(this.lineCtx.ctx,i).seriesHaveSameValues(t)){var a=e[t].slice();a[a.length-1]=a[a.length-1]+1e-6,e[t]=a}return e}},{key:"calculatePoints",value:function(t){var e=t.series,i=t.realIndex,a=t.x,s=t.y,r=t.i,o=t.j,n=t.prevY,l=this.w,h=[],c=[];if(0===o){var d=this.lineCtx.categoryAxisCorrection+l.config.markers.offsetX;l.globals.isXNumeric&&(d=(l.globals.seriesX[i][0]-l.globals.minX)/this.lineCtx.xRatio+l.config.markers.offsetX),h.push(d),c.push(y.isNumber(e[r][0])?n+l.config.markers.offsetY:null),h.push(a+l.config.markers.offsetX),c.push(y.isNumber(e[r][o+1])?s+l.config.markers.offsetY:null)}else h.push(a+l.config.markers.offsetX),c.push(y.isNumber(e[r][o+1])?s+l.config.markers.offsetY:null);return{x:h,y:c}}},{key:"checkPreviousPaths",value:function(t){for(var e=t.pathFromLine,i=t.pathFromArea,a=t.realIndex,s=this.w,r=0;r0&&parseInt(o.realIndex,10)===parseInt(a,10)&&("line"===o.type?(this.lineCtx.appendPathFrom=!1,e=s.globals.previousPaths[r].paths[0].d):"area"===o.type&&(this.lineCtx.appendPathFrom=!1,i=s.globals.previousPaths[r].paths[0].d,s.config.stroke.show&&s.globals.previousPaths[r].paths[1]&&(e=s.globals.previousPaths[r].paths[1].d)))}return{pathFromLine:e,pathFromArea:i}}},{key:"determineFirstPrevY",value:function(t){var e,i=t.i,a=t.series,s=t.prevY,r=t.lineYPosition,o=this.w;if(void 0!==(null===(e=a[i])||void 0===e?void 0:e[0]))s=(r=o.config.chart.stacked&&i>0?this.lineCtx.prevSeriesY[i-1][0]:this.lineCtx.zeroY)-a[i][0]/this.lineCtx.yRatio[this.lineCtx.yaxisIndex]+2*(this.lineCtx.isReversed?a[i][0]/this.lineCtx.yRatio[this.lineCtx.yaxisIndex]:0);else if(o.config.chart.stacked&&i>0&&void 0===a[i][0])for(var n=i-1;n>=0;n--)if(null!==a[n][0]&&void 0!==a[n][0]){s=r=this.lineCtx.prevSeriesY[n][0];break}return{prevY:s,lineYPosition:r}}}]),t}(),Ft=function(t){for(var e="",i=0;i4?(e+="C".concat(a[0],", ").concat(a[1]),e+=", ".concat(a[2],", ").concat(a[3]),e+=", ".concat(a[4],", ").concat(a[5])):s>2&&(e+="S".concat(a[0],", ").concat(a[1]),e+=", ".concat(a[2],", ").concat(a[3]))}return e},Rt=function(t){var e=function(t){for(var e,i,a,s,r=function(t){for(var e=[],i=t[0],a=t[1],s=e[0]=Ot(i,a),r=1,o=t.length-1;r9&&(s=3*a/Math.sqrt(s),r[l]=s*e,r[l+1]=s*i);for(var h=0;h<=o;h++)s=(t[Math.min(o,h+1)][0]-t[Math.max(0,h-1)][0])/(6*(1+r[h]*r[h])),n.push([s||0,r[h]*s||0]);return n}(t),i=t[1],a=t[0],s=[],r=e[1],o=e[0];s.push(a,[a[0]+o[0],a[1]+o[1],i[0]-r[0],i[1]-r[1],i[0],i[1]]);for(var n=2,l=e.length;n0&&(x=(s.globals.seriesX[g][0]-s.globals.minX)/this.xRatio),f.push(x);var b,v=x,m=void 0,y=v,w=this.zeroY,k=this.zeroY;w=this.lineHelpers.determineFirstPrevY({i:d,series:t,prevY:w,lineYPosition:0}).prevY,u.push(w),b=w,"rangeArea"===n&&(m=k=this.lineHelpers.determineFirstPrevY({i:d,series:a,prevY:k,lineYPosition:0}).prevY,p.push(k));var C={type:n,series:t,realIndex:g,i:d,x:x,y:1,pX:v,pY:b,pathsFrom:this._calculatePathsFrom({type:n,series:t,i:d,realIndex:g,prevX:y,prevY:w,prevY2:k}),linePaths:[],areaPaths:[],seriesIndex:i,lineYPosition:0,xArrj:f,yArrj:u,y2Arrj:p,seriesRangeEnd:a},L=this._iterateOverDataPoints(r(r({},C),{},{iterations:"rangeArea"===n?t[d].length-1:void 0,isRangeStart:!0}));if("rangeArea"===n){var P=this._calculatePathsFrom({series:a,i:d,realIndex:g,prevX:y,prevY:k}),T=this._iterateOverDataPoints(r(r({},C),{},{series:a,pY:m,pathsFrom:P,iterations:a[d].length-1,isRangeStart:!1}));L.linePaths[0]=T.linePath+L.linePath,L.pathFromLine=T.pathFromLine+L.pathFromLine}this._handlePaths({type:n,realIndex:g,i:d,paths:L}),this.elSeries.add(this.elPointsMain),this.elSeries.add(this.elDataLabelsWrap),c.push(this.elSeries)}if(s.config.chart.stacked)for(var I=c.length;I>0;I--)l.add(c[I-1]);else for(var M=0;M1&&(this.yaxisIndex=i),this.isReversed=a.config.yaxis[this.yaxisIndex]&&a.config.yaxis[this.yaxisIndex].reversed,this.zeroY=a.globals.gridHeight-this.baseLineY[this.yaxisIndex]-(this.isReversed?a.globals.gridHeight:0)+(this.isReversed?2*this.baseLineY[this.yaxisIndex]:0),this.areaBottomY=this.zeroY,(this.zeroY>a.globals.gridHeight||"end"===a.config.plotOptions.area.fillTo)&&(this.areaBottomY=a.globals.gridHeight),this.categoryAxisCorrection=this.xDivision/2,this.elSeries=s.group({class:"apexcharts-series",seriesName:y.escapeString(a.globals.seriesNames[i])}),this.elPointsMain=s.group({class:"apexcharts-series-markers-wrap","data:realIndex":i}),this.elDataLabelsWrap=s.group({class:"apexcharts-datalabels","data:realIndex":i});var r=t[e].length===a.globals.dataPoints;this.elSeries.attr({"data:longestSeries":r,rel:e+1,"data:realIndex":i}),this.appendPathFrom=!0}},{key:"_calculatePathsFrom",value:function(t){var e,i,a,s,r=t.type,o=t.series,n=t.i,l=t.realIndex,h=t.prevX,c=t.prevY,d=t.prevY2,g=this.w,u=new A(this.ctx);if(null===o[n][0]){for(var p=0;p0){var f=this.lineHelpers.checkPreviousPaths({pathFromLine:a,pathFromArea:s,realIndex:l});a=f.pathFromLine,s=f.pathFromArea}return{prevX:h,prevY:c,linePath:e,areaPath:i,pathFromLine:a,pathFromArea:s}}},{key:"_handlePaths",value:function(t){var e=t.type,i=t.realIndex,a=t.i,s=t.paths,o=this.w,n=new A(this.ctx),l=new N(this.ctx);this.prevSeriesY.push(s.yArrj),o.globals.seriesXvalues[i]=s.xArrj,o.globals.seriesYvalues[i]=s.yArrj;var h=o.config.forecastDataPoints;if(h.count>0&&"rangeArea"!==e){var c=o.globals.seriesXvalues[i][o.globals.seriesXvalues[i].length-h.count-1],d=n.drawRect(c,0,o.globals.gridWidth,o.globals.gridHeight,0);o.globals.dom.elForecastMask.appendChild(d.node);var g=n.drawRect(0,0,c,o.globals.gridHeight,0);o.globals.dom.elNonForecastMask.appendChild(g.node)}this.pointsChart||o.globals.delayedElements.push({el:this.elPointsMain.node,index:i});var u={i:a,realIndex:i,animationDelay:a,initialSpeed:o.config.chart.animations.speed,dataChangeSpeed:o.config.chart.animations.dynamicAnimation.speed,className:"apexcharts-".concat(e)};if("area"===e)for(var p=l.fillPath({seriesNumber:i}),f=0;f0&&"rangeArea"!==e){var S=n.renderPaths(w);S.node.setAttribute("stroke-dasharray",h.dashArray),h.strokeWidth&&S.node.setAttribute("stroke-width",h.strokeWidth),this.elSeries.add(S),S.attr("clip-path","url(#forecastMask".concat(o.globals.cuid,")")),k.attr("clip-path","url(#nonForecastMask".concat(o.globals.cuid,")"))}}}}},{key:"_iterateOverDataPoints",value:function(t){var e=t.type,i=t.series,a=t.iterations,s=t.realIndex,r=t.i,o=t.x,n=t.y,l=t.pX,h=t.pY,c=t.pathsFrom,d=t.linePaths,g=t.areaPaths,u=t.seriesIndex,p=t.lineYPosition,f=t.xArrj,x=t.yArrj,b=t.y2Arrj,v=t.isRangeStart,m=t.seriesRangeEnd,w=this.w,k=new A(this.ctx),S=this.yRatio,C=c.prevY,L=c.linePath,P=c.areaPath,T=c.pathFromLine,I=c.pathFromArea,M=y.isNumber(w.globals.minYArr[s])?w.globals.minYArr[s]:w.globals.minY;a||(a=w.globals.dataPoints>1?w.globals.dataPoints-1:w.globals.dataPoints);for(var X=n,z=0;z0&&w.globals.collapsedSeries.length-1){e--;break}return e>=0?e:0}(r-1)][z+1]:this.zeroY,E?n=p-M/S[this.yaxisIndex]+2*(this.isReversed?M/S[this.yaxisIndex]:0):(n=p-i[r][z+1]/S[this.yaxisIndex]+2*(this.isReversed?i[r][z+1]/S[this.yaxisIndex]:0),"rangeArea"===e&&(X=p-m[r][z+1]/S[this.yaxisIndex]+2*(this.isReversed?m[r][z+1]/S[this.yaxisIndex]:0))),f.push(o),x.push(n),b.push(X);var F=this.lineHelpers.calculatePoints({series:i,x:o,y:n,realIndex:s,i:r,j:z,prevY:C}),R=this._createPaths({type:e,series:i,i:r,realIndex:s,j:z,x:o,y:n,y2:X,xArrj:f,yArrj:x,y2Arrj:b,pX:l,pY:h,linePath:L,areaPath:P,linePaths:d,areaPaths:g,seriesIndex:u,isRangeStart:v});g=R.areaPaths,d=R.linePaths,l=R.pX,h=R.pY,P=R.areaPath,L=R.linePath,!this.appendPathFrom||"monotoneCubic"===w.config.stroke.curve&&"rangeArea"===e||(T+=k.line(o,this.zeroY),I+=k.line(o,this.zeroY)),this.handleNullDataPoints(i,F,r,z,s),this._handleMarkersAndLabels({type:e,pointsPos:F,i:r,j:z,realIndex:s,isRangeStart:v})}return{yArrj:x,xArrj:f,pathFromArea:I,areaPaths:g,pathFromLine:T,linePaths:d,linePath:L,areaPath:P}}},{key:"_handleMarkersAndLabels",value:function(t){var e=t.type,i=t.pointsPos,a=t.isRangeStart,s=t.i,r=t.j,o=t.realIndex,n=this.w,l=new G(this.ctx);if(this.pointsChart)this.scatter.draw(this.elSeries,r,{realIndex:o,pointsPos:i,zRatio:this.zRatio,elParent:this.elPointsMain});else{n.globals.series[s].length>1&&this.elPointsMain.node.classList.add("apexcharts-element-hidden");var h=this.markers.plotChartMarkers(i,o,r+1);null!==h&&this.elPointsMain.add(h)}var c=l.drawDataLabel({type:e,isRangeStart:a,pos:i,i:o,j:r+1});null!==c&&this.elDataLabelsWrap.add(c)}},{key:"_createPaths",value:function(t){var e=t.type,i=t.series,a=t.i,s=t.realIndex,r=t.j,o=t.x,n=t.y,l=t.xArrj,h=t.yArrj,c=t.y2,d=t.y2Arrj,g=t.pX,u=t.pY,p=t.linePath,f=t.areaPath,x=t.linePaths,b=t.areaPaths,v=t.seriesIndex,m=t.isRangeStart,y=this.w,w=new A(this.ctx),k=y.config.stroke.curve,S=this.areaBottomY;if(Array.isArray(y.config.stroke.curve)&&(k=Array.isArray(v)?y.config.stroke.curve[v[a]]:y.config.stroke.curve[a]),("rangeArea"===e&&(y.globals.hasNullValues||y.config.forecastDataPoints.count>0)||y.globals.hasNullValues)&&"monotoneCubic"===k&&(k="straight"),"smooth"===k){var C=.35*(o-g);y.globals.hasNullValues?(null!==i[a][r]&&(null!==i[a][r+1]?(p=w.move(g,u)+w.curve(g+C,u,o-C,n,o+1,n),f=w.move(g+1,u)+w.curve(g+C,u,o-C,n,o+1,n)+w.line(o,S)+w.line(g,S)+"z"):(p=w.move(g,u),f=w.move(g,u)+"z")),x.push(p),b.push(f)):(p+=w.curve(g+C,u,o-C,n,o,n),f+=w.curve(g+C,u,o-C,n,o,n)),g=o,u=n,r===i[a].length-2&&(f+=w.curve(g,u,o,n,o,S)+w.move(o,n)+"z","rangeArea"===e&&m?p+=w.curve(g,u,o,n,o,c)+w.move(o,c)+"z":y.globals.hasNullValues||(x.push(p),b.push(f)))}else if("monotoneCubic"===k){if("rangeArea"===e?l.length===y.globals.dataPoints:r===i[a].length-2){var L=l.map((function(t,e){return[l[e],h[e]]})),P=Rt(L);if(p+=Ft(P),f+=Ft(P),g=o,u=n,"rangeArea"===e&&m){p+=w.line(l[l.length-1],d[d.length-1]);var T=l.slice().reverse(),I=d.slice().reverse(),M=T.map((function(t,e){return[T[e],I[e]]})),X=Rt(M);f=p+=Ft(X)}else f+=w.curve(g,u,o,n,o,S)+w.move(o,n)+"z";x.push(p),b.push(f)}}else{if(null===i[a][r+1]){p+=w.move(o,n);var z=y.globals.isXNumeric?(y.globals.seriesX[s][r]-y.globals.minX)/this.xRatio:o-this.xDivision;f=f+w.line(z,S)+w.move(o,n)+"z"}null===i[a][r]&&(p+=w.move(o,n),f+=w.move(o,S)),"stepline"===k?(p=p+w.line(o,null,"H")+w.line(null,n,"V"),f=f+w.line(o,null,"H")+w.line(null,n,"V")):"straight"===k&&(p+=w.line(o,n),f+=w.line(o,n)),r===i[a].length-2&&(f=f+w.line(o,S)+w.move(o,n)+"z","rangeArea"===e&&m?p=p+w.line(o,c)+w.move(o,c)+"z":(x.push(p),b.push(f)))}return{linePaths:x,areaPaths:b,pX:g,pY:u,linePath:p,areaPath:f}}},{key:"handleNullDataPoints",value:function(t,e,i,a,s){var r=this.w;if(null===t[i][a]&&r.config.markers.showNullDataPoints||1===t[i].length){var o=this.markers.plotChartMarkers(e,s,a+1,this.strokeWidth-r.config.markers.strokeWidth/2,!0);null!==o&&this.elPointsMain.add(o)}}}]),t}();window.TreemapSquared={},window.TreemapSquared.generate=function(){function t(e,i,a,s){this.xoffset=e,this.yoffset=i,this.height=s,this.width=a,this.shortestEdge=function(){return Math.min(this.height,this.width)},this.getCoordinates=function(t){var e,i=[],a=this.xoffset,s=this.yoffset,o=r(t)/this.height,n=r(t)/this.width;if(this.width>=this.height)for(e=0;e=this.height){var a=e/this.height,s=this.width-a;i=new t(this.xoffset+a,this.yoffset,s,this.height)}else{var r=e/this.width,o=this.height-r;i=new t(this.xoffset,this.yoffset+r,this.width,o)}return i}}function e(e,a,s,o,n){return o=void 0===o?0:o,n=void 0===n?0:n,function(t){var e,i,a=[];for(e=0;e=a(s,i))}(e,l=t[0],n)?(e.push(l),i(t.slice(1),e,s,o)):(h=s.cutArea(r(e),o),o.push(s.getCoordinates(e)),i(t,[],h,o)),o;o.push(s.getCoordinates(e))}function a(t,e){var i=Math.min.apply(Math,t),a=Math.max.apply(Math,t),s=r(t);return Math.max(Math.pow(e,2)*a/Math.pow(s,2),Math.pow(s,2)/(Math.pow(e,2)*i))}function s(t){return t&&t.constructor===Array}function r(t){var e,i=0;for(e=0;er-a&&l.width<=o-s){var h=n.rotateAroundCenter(t.node);t.node.setAttribute("transform","rotate(-90 ".concat(h.x," ").concat(h.y,") translate(").concat(l.height/3,")"))}}},{key:"truncateLabels",value:function(t,e,i,a,s,r){var o=new A(this.ctx),n=o.getTextRects(t,e).width+this.w.config.stroke.width+5>s-i&&r-a>s-i?r-a:s-i,l=o.getTextBasedOnMaxWidth({text:t,maxWidth:n,fontSize:e});return t.length!==l.length&&n/e<5?"":l}},{key:"animateTreemap",value:function(t,e,i,a){var s=new w(this.ctx);s.animateRect(t,{x:e.x,y:e.y,width:e.width,height:e.height},{x:i.x,y:i.y,width:i.width,height:i.height},a,(function(){s.animationCompleted(t)}))}}]),t}(),Bt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w,this.timeScaleArray=[],this.utc=this.w.config.xaxis.labels.datetimeUTC}return h(t,[{key:"calculateTimeScaleTicks",value:function(t,e){var i=this,a=this.w;if(a.globals.allSeriesCollapsed)return a.globals.labels=[],a.globals.timescaleLabels=[],[];var s=new z(this.ctx),o=(e-t)/864e5;this.determineInterval(o),a.globals.disableZoomIn=!1,a.globals.disableZoomOut=!1,o<.00011574074074074075?a.globals.disableZoomIn=!0:o>5e4&&(a.globals.disableZoomOut=!0);var n=s.getTimeUnitsfromTimestamp(t,e,this.utc),l=a.globals.gridWidth/o,h=l/24,c=h/60,d=c/60,g=Math.floor(24*o),u=Math.floor(1440*o),p=Math.floor(86400*o),f=Math.floor(o),x=Math.floor(o/30),b=Math.floor(o/365),v={minMillisecond:n.minMillisecond,minSecond:n.minSecond,minMinute:n.minMinute,minHour:n.minHour,minDate:n.minDate,minMonth:n.minMonth,minYear:n.minYear},m={firstVal:v,currentMillisecond:v.minMillisecond,currentSecond:v.minSecond,currentMinute:v.minMinute,currentHour:v.minHour,currentMonthDate:v.minDate,currentDate:v.minDate,currentMonth:v.minMonth,currentYear:v.minYear,daysWidthOnXAxis:l,hoursWidthOnXAxis:h,minutesWidthOnXAxis:c,secondsWidthOnXAxis:d,numberOfSeconds:p,numberOfMinutes:u,numberOfHours:g,numberOfDays:f,numberOfMonths:x,numberOfYears:b};switch(this.tickInterval){case"years":this.generateYearScale(m);break;case"months":case"half_year":this.generateMonthScale(m);break;case"months_days":case"months_fortnight":case"days":case"week_days":this.generateDayScale(m);break;case"hours":this.generateHourScale(m);break;case"minutes_fives":case"minutes":this.generateMinuteScale(m);break;case"seconds_tens":case"seconds_fives":case"seconds":this.generateSecondScale(m)}var y=this.timeScaleArray.map((function(t){var e={position:t.position,unit:t.unit,year:t.year,day:t.day?t.day:1,hour:t.hour?t.hour:0,month:t.month+1};return"month"===t.unit?r(r({},e),{},{day:1,value:t.value+1}):"day"===t.unit||"hour"===t.unit?r(r({},e),{},{value:t.value}):"minute"===t.unit?r(r({},e),{},{value:t.value,minute:t.value}):"second"===t.unit?r(r({},e),{},{value:t.value,minute:t.minute,second:t.second}):t}));return y.filter((function(t){var e=1,s=Math.ceil(a.globals.gridWidth/120),r=t.value;void 0!==a.config.xaxis.tickAmount&&(s=a.config.xaxis.tickAmount),y.length>s&&(e=Math.floor(y.length/s));var o=!1,n=!1;switch(i.tickInterval){case"years":"year"===t.unit&&(o=!0);break;case"half_year":e=7,"year"===t.unit&&(o=!0);break;case"months":e=1,"year"===t.unit&&(o=!0);break;case"months_fortnight":e=15,"year"!==t.unit&&"month"!==t.unit||(o=!0),30===r&&(n=!0);break;case"months_days":e=10,"month"===t.unit&&(o=!0),30===r&&(n=!0);break;case"week_days":e=8,"month"===t.unit&&(o=!0);break;case"days":e=1,"month"===t.unit&&(o=!0);break;case"hours":"day"===t.unit&&(o=!0);break;case"minutes_fives":case"seconds_fives":r%5!=0&&(n=!0);break;case"seconds_tens":r%10!=0&&(n=!0)}if("hours"===i.tickInterval||"minutes_fives"===i.tickInterval||"seconds_tens"===i.tickInterval||"seconds_fives"===i.tickInterval){if(!n)return!0}else if((r%e==0||o)&&!n)return!0}))}},{key:"recalcDimensionsBasedOnFormat",value:function(t,e){var i=this.w,a=this.formatDates(t),s=this.removeOverlappingTS(a);i.globals.timescaleLabels=s.slice(),new ct(this.ctx).plotCoords()}},{key:"determineInterval",value:function(t){var e=24*t,i=60*e;switch(!0){case t/365>5:this.tickInterval="years";break;case t>800:this.tickInterval="half_year";break;case t>180:this.tickInterval="months";break;case t>90:this.tickInterval="months_fortnight";break;case t>60:this.tickInterval="months_days";break;case t>30:this.tickInterval="week_days";break;case t>2:this.tickInterval="days";break;case e>2.4:this.tickInterval="hours";break;case i>15:this.tickInterval="minutes_fives";break;case i>5:this.tickInterval="minutes";break;case i>1:this.tickInterval="seconds_tens";break;case 60*i>20:this.tickInterval="seconds_fives";break;default:this.tickInterval="seconds"}}},{key:"generateYearScale",value:function(t){var e=t.firstVal,i=t.currentMonth,a=t.currentYear,s=t.daysWidthOnXAxis,r=t.numberOfYears,o=e.minYear,n=0,l=new z(this.ctx),h="year";if(e.minDate>1||e.minMonth>0){var c=l.determineRemainingDaysOfYear(e.minYear,e.minMonth,e.minDate);n=(l.determineDaysOfYear(e.minYear)-c+1)*s,o=e.minYear+1,this.timeScaleArray.push({position:n,value:o,unit:h,year:o,month:y.monthMod(i+1)})}else 1===e.minDate&&0===e.minMonth&&this.timeScaleArray.push({position:n,value:o,unit:h,year:a,month:y.monthMod(i+1)});for(var d=o,g=n,u=0;u1){l=(h.determineDaysOfMonths(a+1,e.minYear)-i+1)*r,n=y.monthMod(a+1);var g=s+d,u=y.monthMod(n),p=n;0===n&&(c="year",p=g,u=1,g+=d+=1),this.timeScaleArray.push({position:l,value:p,unit:c,year:g,month:u})}else this.timeScaleArray.push({position:l,value:n,unit:c,year:s,month:y.monthMod(a)});for(var f=n+1,x=l,b=0,v=1;bo.determineDaysOfMonths(e+1,i)?(h=1,n="month",g=e+=1,e):e},d=(24-e.minHour)*s,g=l,u=c(h,i,a);0===e.minHour&&1===e.minDate?(d=0,g=y.monthMod(e.minMonth),n="month",h=e.minDate,r++):1!==e.minDate&&0===e.minHour&&0===e.minMinute&&(d=0,l=e.minDate,g=l,u=c(h=l,i,a)),this.timeScaleArray.push({position:d,value:g,unit:n,year:this._getYear(a,u,0),month:y.monthMod(u),day:h});for(var p=d,f=0;fn.determineDaysOfMonths(e+1,s)&&(f=1,e+=1),{month:e,date:f}},c=function(t,e){return t>n.determineDaysOfMonths(e+1,s)?e+=1:e},d=60-(e.minMinute+e.minSecond/60),g=d*r,u=e.minHour+1,p=u+1;60===d&&(g=0,p=(u=e.minHour)+1);var f=i,x=c(f,a);this.timeScaleArray.push({position:g,value:u,unit:l,day:f,hour:p,year:s,month:y.monthMod(x)});for(var b=g,v=0;v=24&&(p=0,l="day",x=h(f+=1,x).month,x=c(f,x));var m=this._getYear(s,x,0);b=60*r+b;var w=0===p?f:p;this.timeScaleArray.push({position:b,value:w,unit:l,hour:p,day:f,year:m,month:y.monthMod(x)}),p++}}},{key:"generateMinuteScale",value:function(t){for(var e=t.currentMillisecond,i=t.currentSecond,a=t.currentMinute,s=t.currentHour,r=t.currentDate,o=t.currentMonth,n=t.currentYear,l=t.minutesWidthOnXAxis,h=t.secondsWidthOnXAxis,c=t.numberOfMinutes,d=a+1,g=r,u=o,p=n,f=s,x=(60-i-e/1e3)*h,b=0;b=60&&(d=0,24===(f+=1)&&(f=0)),this.timeScaleArray.push({position:x,value:d,unit:"minute",hour:f,minute:d,day:g,year:this._getYear(p,u,0),month:y.monthMod(u)}),x+=l,d++}},{key:"generateSecondScale",value:function(t){for(var e=t.currentMillisecond,i=t.currentSecond,a=t.currentMinute,s=t.currentHour,r=t.currentDate,o=t.currentMonth,n=t.currentYear,l=t.secondsWidthOnXAxis,h=t.numberOfSeconds,c=i+1,d=a,g=r,u=o,p=n,f=s,x=(1e3-e)/1e3*l,b=0;b=60&&(c=0,++d>=60&&(d=0,24==++f&&(f=0))),this.timeScaleArray.push({position:x,value:c,unit:"second",hour:f,minute:d,second:c,day:g,year:this._getYear(p,u,0),month:y.monthMod(u)}),x+=l,c++}},{key:"createRawDateString",value:function(t,e){var i=t.year;return 0===t.month&&(t.month=1),i+="-"+("0"+t.month.toString()).slice(-2),"day"===t.unit?i+="day"===t.unit?"-"+("0"+e).slice(-2):"-01":i+="-"+("0"+(t.day?t.day:"1")).slice(-2),"hour"===t.unit?i+="hour"===t.unit?"T"+("0"+e).slice(-2):"T00":i+="T"+("0"+(t.hour?t.hour:"0")).slice(-2),"minute"===t.unit?i+=":"+("0"+e).slice(-2):i+=":"+(t.minute?("0"+t.minute).slice(-2):"00"),"second"===t.unit?i+=":"+("0"+e).slice(-2):i+=":00",this.utc&&(i+=".000Z"),i}},{key:"formatDates",value:function(t){var e=this,i=this.w;return t.map((function(t){var a=t.value.toString(),s=new z(e.ctx),r=e.createRawDateString(t,a),o=s.getDate(s.parseDate(r));if(e.utc||(o=s.getDate(s.parseDateWithTimezone(r))),void 0===i.config.xaxis.labels.format){var n="dd MMM",l=i.config.xaxis.labels.datetimeFormatter;"year"===t.unit&&(n=l.year),"month"===t.unit&&(n=l.month),"day"===t.unit&&(n=l.day),"hour"===t.unit&&(n=l.hour),"minute"===t.unit&&(n=l.minute),"second"===t.unit&&(n=l.second),a=s.formatDate(o,n)}else a=s.formatDate(o,i.config.xaxis.labels.format);return{dateString:r,position:t.position,value:a,unit:t.unit,year:t.year,month:t.month}}))}},{key:"removeOverlappingTS",value:function(t){var e,i=this,a=new A(this.ctx),s=!1;t.length>0&&t[0].value&&t.every((function(e){return e.value.length===t[0].value.length}))&&(s=!0,e=a.getTextRects(t[0].value).width);var r=0,o=t.map((function(o,n){if(n>0&&i.w.config.xaxis.labels.hideOverlappingLabels){var l=s?e:a.getTextRects(t[r].value).width,h=t[r].position;return o.position>h+l+10?(r=n,o):null}return o}));return o.filter((function(t){return null!==t}))}},{key:"_getYear",value:function(t,e,i){return t+Math.floor(e/12)+i}}]),t}(),Gt=function(){function t(e,i){n(this,t),this.ctx=i,this.w=i.w,this.el=e}return h(t,[{key:"setupElements",value:function(){var t=this.w.globals,e=this.w.config,i=e.chart.type;t.axisCharts=["line","area","bar","rangeBar","rangeArea","candlestick","boxPlot","scatter","bubble","radar","heatmap","treemap"].indexOf(i)>-1,t.xyCharts=["line","area","bar","rangeBar","rangeArea","candlestick","boxPlot","scatter","bubble"].indexOf(i)>-1,t.isBarHorizontal=("bar"===e.chart.type||"rangeBar"===e.chart.type||"boxPlot"===e.chart.type)&&e.plotOptions.bar.horizontal,t.chartClass=".apexcharts"+t.chartID,t.dom.baseEl=this.el,t.dom.elWrap=document.createElement("div"),A.setAttrs(t.dom.elWrap,{id:t.chartClass.substring(1),class:"apexcharts-canvas "+t.chartClass.substring(1)}),this.el.appendChild(t.dom.elWrap),t.dom.Paper=new window.SVG.Doc(t.dom.elWrap),t.dom.Paper.attr({class:"apexcharts-svg","xmlns:data":"ApexChartsNS",transform:"translate(".concat(e.chart.offsetX,", ").concat(e.chart.offsetY,")")}),t.dom.Paper.node.style.background=e.chart.background,this.setSVGDimensions(),t.dom.elLegendForeign=document.createElementNS(t.SVGNS,"foreignObject"),A.setAttrs(t.dom.elLegendForeign,{x:0,y:0,width:t.svgWidth,height:t.svgHeight}),t.dom.elLegendWrap=document.createElement("div"),t.dom.elLegendWrap.classList.add("apexcharts-legend"),t.dom.elLegendWrap.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),t.dom.elLegendForeign.appendChild(t.dom.elLegendWrap),t.dom.Paper.node.appendChild(t.dom.elLegendForeign),t.dom.elGraphical=t.dom.Paper.group().attr({class:"apexcharts-inner apexcharts-graphical"}),t.dom.elDefs=t.dom.Paper.defs(),t.dom.Paper.add(t.dom.elGraphical),t.dom.elGraphical.add(t.dom.elDefs)}},{key:"plotChartType",value:function(t,e){var i=this.w,a=i.config,s=i.globals,r={series:[],i:[]},o={series:[],i:[]},n={series:[],i:[]},l={series:[],i:[]},h={series:[],i:[]},c={series:[],i:[]},d={series:[],i:[]},g={series:[],i:[]},u={series:[],seriesRangeEnd:[],i:[]};s.series.map((function(e,p){var f=0;void 0!==t[p].type?("column"===t[p].type||"bar"===t[p].type?(s.series.length>1&&a.plotOptions.bar.horizontal&&console.warn("Horizontal bars are not supported in a mixed/combo chart. Please turn off `plotOptions.bar.horizontal`"),h.series.push(e),h.i.push(p),f++,i.globals.columnSeries=h.series):"area"===t[p].type?(o.series.push(e),o.i.push(p),f++):"line"===t[p].type?(r.series.push(e),r.i.push(p),f++):"scatter"===t[p].type?(n.series.push(e),n.i.push(p)):"bubble"===t[p].type?(l.series.push(e),l.i.push(p),f++):"candlestick"===t[p].type?(c.series.push(e),c.i.push(p),f++):"boxPlot"===t[p].type?(d.series.push(e),d.i.push(p),f++):"rangeBar"===t[p].type?(g.series.push(e),g.i.push(p),f++):"rangeArea"===t[p].type?(u.series.push(s.seriesRangeStart[p]),u.seriesRangeEnd.push(s.seriesRangeEnd[p]),u.i.push(p),f++):console.warn("You have specified an unrecognized chart type. Available types for this property are line/area/column/bar/scatter/bubble/candlestick/boxPlot/rangeBar/rangeArea"),f>1&&(s.comboCharts=!0)):(r.series.push(e),r.i.push(p))}));var p=new Ht(this.ctx,e),f=new Lt(this.ctx,e);this.ctx.pie=new Mt(this.ctx);var x=new zt(this.ctx);this.ctx.rangeBar=new Et(this.ctx,e);var b=new Xt(this.ctx),v=[];if(s.comboCharts){if(o.series.length>0&&v.push(p.draw(o.series,"area",o.i)),h.series.length>0)if(i.config.chart.stacked){var m=new Ct(this.ctx,e);v.push(m.draw(h.series,h.i))}else this.ctx.bar=new St(this.ctx,e),v.push(this.ctx.bar.draw(h.series,h.i));if(u.series.length>0&&v.push(p.draw(u.series,"rangeArea",u.i,u.seriesRangeEnd)),r.series.length>0&&v.push(p.draw(r.series,"line",r.i)),c.series.length>0&&v.push(f.draw(c.series,"candlestick",c.i)),d.series.length>0&&v.push(f.draw(d.series,"boxPlot",d.i)),g.series.length>0&&v.push(this.ctx.rangeBar.draw(g.series,g.i)),n.series.length>0){var y=new Ht(this.ctx,e,!0);v.push(y.draw(n.series,"scatter",n.i))}if(l.series.length>0){var w=new Ht(this.ctx,e,!0);v.push(w.draw(l.series,"bubble",l.i))}}else switch(a.chart.type){case"line":v=p.draw(s.series,"line");break;case"area":v=p.draw(s.series,"area");break;case"bar":a.chart.stacked?v=new Ct(this.ctx,e).draw(s.series):(this.ctx.bar=new St(this.ctx,e),v=this.ctx.bar.draw(s.series));break;case"candlestick":v=new Lt(this.ctx,e).draw(s.series,"candlestick");break;case"boxPlot":v=new Lt(this.ctx,e).draw(s.series,a.chart.type);break;case"rangeBar":v=this.ctx.rangeBar.draw(s.series);break;case"rangeArea":v=p.draw(s.seriesRangeStart,"rangeArea",void 0,s.seriesRangeEnd);break;case"heatmap":v=new Tt(this.ctx,e).draw(s.series);break;case"treemap":v=new Wt(this.ctx,e).draw(s.series);break;case"pie":case"donut":case"polarArea":v=this.ctx.pie.draw(s.series);break;case"radialBar":v=x.draw(s.series);break;case"radar":v=b.draw(s.series);break;default:v=p.draw(s.series)}return v}},{key:"setSVGDimensions",value:function(){var t=this.w.globals,e=this.w.config;t.svgWidth=e.chart.width,t.svgHeight=e.chart.height;var i=y.getDimensions(this.el),a=e.chart.width.toString().split(/[0-9]+/g).pop();"%"===a?y.isNumber(i[0])&&(0===i[0].width&&(i=y.getDimensions(this.el.parentNode)),t.svgWidth=i[0]*parseInt(e.chart.width,10)/100):"px"!==a&&""!==a||(t.svgWidth=parseInt(e.chart.width,10));var s=e.chart.height.toString().split(/[0-9]+/g).pop();if("auto"!==t.svgHeight&&""!==t.svgHeight)if("%"===s){var r=y.getDimensions(this.el.parentNode);t.svgHeight=r[1]*parseInt(e.chart.height,10)/100}else t.svgHeight=parseInt(e.chart.height,10);else t.axisCharts?t.svgHeight=t.svgWidth/1.61:t.svgHeight=t.svgWidth/1.2;if(t.svgWidth<0&&(t.svgWidth=0),t.svgHeight<0&&(t.svgHeight=0),A.setAttrs(t.dom.Paper.node,{width:t.svgWidth,height:t.svgHeight}),"%"!==s){var o=e.chart.sparkline.enabled?0:t.axisCharts?e.chart.parentHeightOffset:0;t.dom.Paper.node.parentNode.parentNode.style.minHeight=t.svgHeight+o+"px"}t.dom.elWrap.style.width=t.svgWidth+"px",t.dom.elWrap.style.height=t.svgHeight+"px"}},{key:"shiftGraphPosition",value:function(){var t=this.w.globals,e=t.translateY,i={transform:"translate("+t.translateX+", "+e+")"};A.setAttrs(t.dom.elGraphical.node,i)}},{key:"resizeNonAxisCharts",value:function(){var t=this.w,e=t.globals,i=0,a=t.config.chart.sparkline.enabled?1:15;a+=t.config.grid.padding.bottom,"top"!==t.config.legend.position&&"bottom"!==t.config.legend.position||!t.config.legend.show||t.config.legend.floating||(i=new gt(this.ctx).legendHelpers.getLegendBBox().clwh+10);var s=t.globals.dom.baseEl.querySelector(".apexcharts-radialbar, .apexcharts-pie"),r=2.05*t.globals.radialSize;if(s&&!t.config.chart.sparkline.enabled&&0!==t.config.plotOptions.radialBar.startAngle){var o=y.getBoundingClientRect(s);r=o.bottom;var n=o.bottom-o.top;r=Math.max(2.05*t.globals.radialSize,n)}var l=r+e.translateY+i+a;e.dom.elLegendForeign&&e.dom.elLegendForeign.setAttribute("height",l),t.config.chart.height&&String(t.config.chart.height).indexOf("%")>0||(e.dom.elWrap.style.height=l+"px",A.setAttrs(e.dom.Paper.node,{height:l}),e.dom.Paper.node.parentNode.parentNode.style.minHeight=l+"px")}},{key:"coreCalculations",value:function(){new J(this.ctx).init()}},{key:"resetGlobals",value:function(){var t=this,e=function(){return t.w.config.series.map((function(t){return[]}))},i=new H,a=this.w.globals;i.initGlobalVars(a),a.seriesXvalues=e(),a.seriesYvalues=e()}},{key:"isMultipleY",value:function(){if(this.w.config.yaxis.constructor===Array&&this.w.config.yaxis.length>1)return this.w.globals.isMultipleYAxis=!0,!0}},{key:"xySettings",value:function(){var t=null,e=this.w;if(e.globals.axisCharts){if("back"===e.config.xaxis.crosshairs.position&&new it(this.ctx).drawXCrosshairs(),"back"===e.config.yaxis[0].crosshairs.position&&new it(this.ctx).drawYCrosshairs(),"datetime"===e.config.xaxis.type&&void 0===e.config.xaxis.labels.formatter){this.ctx.timeScale=new Bt(this.ctx);var i=[];isFinite(e.globals.minX)&&isFinite(e.globals.maxX)&&!e.globals.isBarHorizontal?i=this.ctx.timeScale.calculateTimeScaleTicks(e.globals.minX,e.globals.maxX):e.globals.isBarHorizontal&&(i=this.ctx.timeScale.calculateTimeScaleTicks(e.globals.minY,e.globals.maxY)),this.ctx.timeScale.recalcDimensionsBasedOnFormat(i)}t=new S(this.ctx).getCalculatedRatios()}return t}},{key:"updateSourceChart",value:function(t){this.ctx.w.globals.selection=void 0,this.ctx.updateHelpers._updateOptions({chart:{selection:{xaxis:{min:t.w.globals.minX,max:t.w.globals.maxX}}}},!1,!1)}},{key:"setupBrushHandler",value:function(){var t=this,e=this.w;if(e.config.chart.brush.enabled&&"function"!=typeof e.config.chart.events.selection){var i=Array.isArray(e.config.chart.brush.targets)||[e.config.chart.brush.target];i.forEach((function(e){var i=ApexCharts.getChartByID(e);i.w.globals.brushSource=t.ctx,"function"!=typeof i.w.config.chart.events.zoomed&&(i.w.config.chart.events.zoomed=function(){t.updateSourceChart(i)}),"function"!=typeof i.w.config.chart.events.scrolled&&(i.w.config.chart.events.scrolled=function(){t.updateSourceChart(i)})})),e.config.chart.events.selection=function(t,a){i.forEach((function(t){var i=ApexCharts.getChartByID(t),s=y.clone(e.config.yaxis);if(e.config.chart.brush.autoScaleYaxis&&1===i.w.globals.series.length){var o=new $(i);s=o.autoScaleY(i,s,a)}var n=i.w.config.yaxis.reduce((function(t,e,a){return[].concat(b(t),[r(r({},i.w.config.yaxis[a]),{},{min:s[0].min,max:s[0].max})])}),[]);i.ctx.updateHelpers._updateOptions({xaxis:{min:a.xaxis.min,max:a.xaxis.max},yaxis:n},!1,!1,!1,!1)}))}}}}]),t}(),Vt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"_updateOptions",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return new Promise((function(n){var l=[e.ctx];s&&(l=e.ctx.getSyncedCharts()),e.ctx.w.globals.isExecCalled&&(l=[e.ctx],e.ctx.w.globals.isExecCalled=!1),l.forEach((function(s,h){var c=s.w;if(c.globals.shouldAnimate=a,i||(c.globals.resized=!0,c.globals.dataChanged=!0,a&&s.series.getPreviousPaths()),t&&"object"===o(t)&&(s.config=new O(t),t=S.extendArrayProps(s.config,t,c),s.w.globals.chartID!==e.ctx.w.globals.chartID&&delete t.series,c.config=y.extend(c.config,t),r&&(c.globals.lastXAxis=t.xaxis?y.clone(t.xaxis):[],c.globals.lastYAxis=t.yaxis?y.clone(t.yaxis):[],c.globals.initialConfig=y.extend({},c.config),c.globals.initialSeries=y.clone(c.config.series),t.series))){for(var d=0;d2&&void 0!==arguments[2]&&arguments[2];return new Promise((function(s){var r,o=i.w;return o.globals.shouldAnimate=e,o.globals.dataChanged=!0,e&&i.ctx.series.getPreviousPaths(),o.globals.axisCharts?(0===(r=t.map((function(t,e){return i._extendSeries(t,e)}))).length&&(r=[{data:[]}]),o.config.series=r):o.config.series=t.slice(),a&&(o.globals.initialConfig.series=y.clone(o.config.series),o.globals.initialSeries=y.clone(o.config.series)),i.ctx.update().then((function(){s(i.ctx)}))}))}},{key:"_extendSeries",value:function(t,e){var i=this.w,a=i.config.series[e];return r(r({},i.config.series[e]),{},{name:t.name?t.name:a&&a.name,color:t.color?t.color:a&&a.color,type:t.type?t.type:a&&a.type,group:t.group?t.group:a&&a.group,data:t.data?t.data:a&&a.data})}},{key:"toggleDataPointSelection",value:function(t,e){var i=this.w,a=null,s=".apexcharts-series[data\\:realIndex='".concat(t,"']");return i.globals.axisCharts?a=i.globals.dom.Paper.select("".concat(s," path[j='").concat(e,"'], ").concat(s," circle[j='").concat(e,"'], ").concat(s," rect[j='").concat(e,"']")).members[0]:void 0===e&&(a=i.globals.dom.Paper.select("".concat(s," path[j='").concat(t,"']")).members[0],"pie"!==i.config.chart.type&&"polarArea"!==i.config.chart.type&&"donut"!==i.config.chart.type||this.ctx.pie.pieClicked(t)),a?(new A(this.ctx).pathMouseDown(a,null),a.node?a.node:null):(console.warn("toggleDataPointSelection: Element not found"),null)}},{key:"forceXAxisUpdate",value:function(t){var e=this.w;if(["min","max"].forEach((function(i){void 0!==t.xaxis[i]&&(e.config.xaxis[i]=t.xaxis[i],e.globals.lastXAxis[i]=t.xaxis[i])})),t.xaxis.categories&&t.xaxis.categories.length&&(e.config.xaxis.categories=t.xaxis.categories),e.config.xaxis.convertedCatToNumeric){var i=new R(t);t=i.convertCatToNumericXaxis(t,this.ctx)}return t}},{key:"forceYAxisUpdate",value:function(t){return t.chart&&t.chart.stacked&&"100%"===t.chart.stackType&&(Array.isArray(t.yaxis)?t.yaxis.forEach((function(e,i){t.yaxis[i].min=0,t.yaxis[i].max=100})):(t.yaxis.min=0,t.yaxis.max=100)),t}},{key:"revertDefaultAxisMinMax",value:function(t){var e=this,i=this.w,a=i.globals.lastXAxis,s=i.globals.lastYAxis;t&&t.xaxis&&(a=t.xaxis),t&&t.yaxis&&(s=t.yaxis),i.config.xaxis.min=a.min,i.config.xaxis.max=a.max;i.config.yaxis.map((function(t,a){i.globals.zoomed||void 0!==s[a]?function(t){void 0!==s[t]&&(i.config.yaxis[t].min=s[t].min,i.config.yaxis[t].max=s[t].max)}(a):void 0!==e.ctx.opts.yaxis[a]&&(t.min=e.ctx.opts.yaxis[a].min,t.max=e.ctx.opts.yaxis[a].max)}))}}]),t}();Dt="undefined"!=typeof window?window:void 0,Nt=function(t,e){var i=(void 0!==this?this:t).SVG=function(t){if(i.supported)return t=new i.Doc(t),i.parser.draw||i.prepare(),t};if(i.ns="http://www.w3.org/2000/svg",i.xmlns="http://www.w3.org/2000/xmlns/",i.xlink="http://www.w3.org/1999/xlink",i.svgjs="http://svgjs.dev",i.supported=!0,!i.supported)return!1;i.did=1e3,i.eid=function(t){return"Svgjs"+d(t)+i.did++},i.create=function(t){var i=e.createElementNS(this.ns,t);return i.setAttribute("id",this.eid(t)),i},i.extend=function(){var t,e;e=(t=[].slice.call(arguments)).pop();for(var a=t.length-1;a>=0;a--)if(t[a])for(var s in e)t[a].prototype[s]=e[s];i.Set&&i.Set.inherit&&i.Set.inherit()},i.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,i.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&i.extend(e,t.extend),t.construct&&i.extend(t.parent||i.Container,t.construct),e},i.adopt=function(e){return e?e.instance?e.instance:((a="svg"==e.nodeName?e.parentNode instanceof t.SVGElement?new i.Nested:new i.Doc:"linearGradient"==e.nodeName?new i.Gradient("linear"):"radialGradient"==e.nodeName?new i.Gradient("radial"):i[d(e.nodeName)]?new(i[d(e.nodeName)]):new i.Element(e)).type=e.nodeName,a.node=e,e.instance=a,a instanceof i.Doc&&a.namespace().defs(),a.setData(JSON.parse(e.getAttribute("svgjs:data"))||{}),a):null;var a},i.prepare=function(){var t=e.getElementsByTagName("body")[0],a=(t?new i.Doc(t):i.adopt(e.documentElement).nested()).size(2,0);i.parser={body:t||e.documentElement,draw:a.style("opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden").node,poly:a.polyline().node,path:a.path().node,native:i.create("svg")}},i.parser={native:i.create("svg")},e.addEventListener("DOMContentLoaded",(function(){i.parser.draw||i.prepare()}),!1),i.regex={numberAndUnit:/^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,hex:/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,rgb:/rgb\((\d+),(\d+),(\d+)\)/,reference:/#([a-z0-9\-_]+)/i,transforms:/\)\s*,?\s*/,whitespace:/\s/g,isHex:/^#[a-f0-9]{3,6}$/i,isRgb:/^rgb\(/,isCss:/[^:]+:[^;]+;?/,isBlank:/^(\s+)?$/,isNumber:/^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,isPercent:/^-?[\d\.]+%$/,isImage:/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,delimiter:/[\s,]+/,hyphen:/([^e])\-/gi,pathLetters:/[MLHVCSQTAZ]/gi,isPathLetter:/[MLHVCSQTAZ]/i,numbersWithDots:/((\d?\.\d+(?:e[+-]?\d+)?)((?:\.\d+(?:e[+-]?\d+)?)+))+/gi,dots:/\./g},i.utils={map:function(t,e){for(var i=t.length,a=[],s=0;s1?1:t,new i.Color({r:~~(this.r+(this.destination.r-this.r)*t),g:~~(this.g+(this.destination.g-this.g)*t),b:~~(this.b+(this.destination.b-this.b)*t)})):this}}),i.Color.test=function(t){return t+="",i.regex.isHex.test(t)||i.regex.isRgb.test(t)},i.Color.isRgb=function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b},i.Color.isColor=function(t){return i.Color.isRgb(t)||i.Color.test(t)},i.Array=function(t,e){0==(t=(t||[]).valueOf()).length&&e&&(t=e.valueOf()),this.value=this.parse(t)},i.extend(i.Array,{toString:function(){return this.value.join(" ")},valueOf:function(){return this.value},parse:function(t){return t=t.valueOf(),Array.isArray(t)?t:this.split(t)}}),i.PointArray=function(t,e){i.Array.call(this,t,e||[[0,0]])},i.PointArray.prototype=new i.Array,i.PointArray.prototype.constructor=i.PointArray;for(var a={M:function(t,e,i){return e.x=i.x=t[0],e.y=i.y=t[1],["M",e.x,e.y]},L:function(t,e){return e.x=t[0],e.y=t[1],["L",t[0],t[1]]},H:function(t,e){return e.x=t[0],["H",t[0]]},V:function(t,e){return e.y=t[0],["V",t[0]]},C:function(t,e){return e.x=t[4],e.y=t[5],["C",t[0],t[1],t[2],t[3],t[4],t[5]]},Q:function(t,e){return e.x=t[2],e.y=t[3],["Q",t[0],t[1],t[2],t[3]]},S:function(t,e){return e.x=t[2],e.y=t[3],["S",t[0],t[1],t[2],t[3]]},Z:function(t,e,i){return e.x=i.x,e.y=i.y,["Z"]}},s="mlhvqtcsaz".split(""),r=0,n=s.length;rl);return r},bbox:function(){return i.parser.draw||i.prepare(),i.parser.path.setAttribute("d",this.toString()),i.parser.path.getBBox()}}),i.Number=i.invent({create:function(t,e){this.value=0,this.unit=e||"","number"==typeof t?this.value=isNaN(t)?0:isFinite(t)?t:t<0?-34e37:34e37:"string"==typeof t?(e=t.match(i.regex.numberAndUnit))&&(this.value=parseFloat(e[1]),"%"==e[5]?this.value/=100:"s"==e[5]&&(this.value*=1e3),this.unit=e[5]):t instanceof i.Number&&(this.value=t.valueOf(),this.unit=t.unit)},extend:{toString:function(){return("%"==this.unit?~~(1e8*this.value)/1e6:"s"==this.unit?this.value/1e3:this.value)+this.unit},toJSON:function(){return this.toString()},valueOf:function(){return this.value},plus:function(t){return t=new i.Number(t),new i.Number(this+t,this.unit||t.unit)},minus:function(t){return t=new i.Number(t),new i.Number(this-t,this.unit||t.unit)},times:function(t){return t=new i.Number(t),new i.Number(this*t,this.unit||t.unit)},divide:function(t){return t=new i.Number(t),new i.Number(this/t,this.unit||t.unit)},to:function(t){var e=new i.Number(this);return"string"==typeof t&&(e.unit=t),e},morph:function(t){return this.destination=new i.Number(t),t.relative&&(this.destination.value+=this.value),this},at:function(t){return this.destination?new i.Number(this.destination).minus(this).times(t).plus(this):this}}}),i.Element=i.invent({create:function(t){this._stroke=i.defaults.attrs.stroke,this._event=null,this.dom={},(this.node=t)&&(this.type=t.nodeName,this.node.instance=this,this._stroke=t.getAttribute("stroke")||this._stroke)},extend:{x:function(t){return this.attr("x",t)},y:function(t){return this.attr("y",t)},cx:function(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)},cy:function(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},width:function(t){return this.attr("width",t)},height:function(t){return this.attr("height",t)},size:function(t,e){var a=u(this,t,e);return this.width(new i.Number(a.width)).height(new i.Number(a.height))},clone:function(t){this.writeDataToDom();var e=x(this.node.cloneNode(!0));return t?t.add(e):this.after(e),e},remove:function(){return this.parent()&&this.parent().removeElement(this),this},replace:function(t){return this.after(t).remove(),t},addTo:function(t){return t.put(this)},putIn:function(t){return t.add(this)},id:function(t){return this.attr("id",t)},show:function(){return this.style("display","")},hide:function(){return this.style("display","none")},visible:function(){return"none"!=this.style("display")},toString:function(){return this.attr("id")},classes:function(){var t=this.attr("class");return null==t?[]:t.trim().split(i.regex.delimiter)},hasClass:function(t){return-1!=this.classes().indexOf(t)},addClass:function(t){if(!this.hasClass(t)){var e=this.classes();e.push(t),this.attr("class",e.join(" "))}return this},removeClass:function(t){return this.hasClass(t)&&this.attr("class",this.classes().filter((function(e){return e!=t})).join(" ")),this},toggleClass:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t)},reference:function(t){return i.get(this.attr(t))},parent:function(e){var a=this;if(!a.node.parentNode)return null;if(a=i.adopt(a.node.parentNode),!e)return a;for(;a&&a.node instanceof t.SVGElement;){if("string"==typeof e?a.matches(e):a instanceof e)return a;if(!a.node.parentNode||"#document"==a.node.parentNode.nodeName)return null;a=i.adopt(a.node.parentNode)}},doc:function(){return this instanceof i.Doc?this:this.parent(i.Doc)},parents:function(t){var e=[],i=this;do{if(!(i=i.parent(t))||!i.node)break;e.push(i)}while(i.parent);return e},matches:function(t){return function(t,e){return(t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector).call(t,e)}(this.node,t)},native:function(){return this.node},svg:function(t){var a=e.createElement("svg");if(!(t&&this instanceof i.Parent))return a.appendChild(t=e.createElement("svg")),this.writeDataToDom(),t.appendChild(this.node.cloneNode(!0)),a.innerHTML.replace(/^/,"").replace(/<\/svg>$/,"");a.innerHTML=""+t.replace(/\n/,"").replace(/<([\w:-]+)([^<]+?)\/>/g,"<$1$2>")+"";for(var s=0,r=a.firstChild.childNodes.length;s":function(t){return-Math.cos(t*Math.PI)/2+.5},">":function(t){return Math.sin(t*Math.PI/2)},"<":function(t){return 1-Math.cos(t*Math.PI/2)}},i.morph=function(t){return function(e,a){return new i.MorphObj(e,a).at(t)}},i.Situation=i.invent({create:function(t){this.init=!1,this.reversed=!1,this.reversing=!1,this.duration=new i.Number(t.duration).valueOf(),this.delay=new i.Number(t.delay).valueOf(),this.start=+new Date+this.delay,this.finish=this.start+this.duration,this.ease=t.ease,this.loop=0,this.loops=!1,this.animations={},this.attrs={},this.styles={},this.transforms=[],this.once={}}}),i.FX=i.invent({create:function(t){this._target=t,this.situations=[],this.active=!1,this.situation=null,this.paused=!1,this.lastPos=0,this.pos=0,this.absPos=0,this._speed=1},extend:{animate:function(t,e,a){"object"===o(t)&&(e=t.ease,a=t.delay,t=t.duration);var s=new i.Situation({duration:t||1e3,delay:a||0,ease:i.easing[e||"-"]||e});return this.queue(s),this},target:function(t){return t&&t instanceof i.Element?(this._target=t,this):this._target},timeToAbsPos:function(t){return(t-this.situation.start)/(this.situation.duration/this._speed)},absPosToTime:function(t){return this.situation.duration/this._speed*t+this.situation.start},startAnimFrame:function(){this.stopAnimFrame(),this.animationFrame=t.requestAnimationFrame(function(){this.step()}.bind(this))},stopAnimFrame:function(){t.cancelAnimationFrame(this.animationFrame)},start:function(){return!this.active&&this.situation&&(this.active=!0,this.startCurrent()),this},startCurrent:function(){return this.situation.start=+new Date+this.situation.delay/this._speed,this.situation.finish=this.situation.start+this.situation.duration/this._speed,this.initAnimations().step()},queue:function(t){return("function"==typeof t||t instanceof i.Situation)&&this.situations.push(t),this.situation||(this.situation=this.situations.shift()),this},dequeue:function(){return this.stop(),this.situation=this.situations.shift(),this.situation&&(this.situation instanceof i.Situation?this.start():this.situation.call(this)),this},initAnimations:function(){var t,e=this.situation;if(e.init)return this;for(var a in e.animations){t=this.target()[a](),Array.isArray(t)||(t=[t]),Array.isArray(e.animations[a])||(e.animations[a]=[e.animations[a]]);for(var s=t.length;s--;)e.animations[a][s]instanceof i.Number&&(t[s]=new i.Number(t[s])),e.animations[a][s]=t[s].morph(e.animations[a][s])}for(var a in e.attrs)e.attrs[a]=new i.MorphObj(this.target().attr(a),e.attrs[a]);for(var a in e.styles)e.styles[a]=new i.MorphObj(this.target().style(a),e.styles[a]);return e.initialTransformation=this.target().matrixify(),e.init=!0,this},clearQueue:function(){return this.situations=[],this},clearCurrent:function(){return this.situation=null,this},stop:function(t,e){var i=this.active;return this.active=!1,e&&this.clearQueue(),t&&this.situation&&(!i&&this.startCurrent(),this.atEnd()),this.stopAnimFrame(),this.clearCurrent()},after:function(t){var e=this.last();return this.target().on("finished.fx",(function i(a){a.detail.situation==e&&(t.call(this,e),this.off("finished.fx",i))})),this._callStart()},during:function(t){var e=this.last(),a=function(a){a.detail.situation==e&&t.call(this,a.detail.pos,i.morph(a.detail.pos),a.detail.eased,e)};return this.target().off("during.fx",a).on("during.fx",a),this.after((function(){this.off("during.fx",a)})),this._callStart()},afterAll:function(t){var e=function e(i){t.call(this),this.off("allfinished.fx",e)};return this.target().off("allfinished.fx",e).on("allfinished.fx",e),this._callStart()},last:function(){return this.situations.length?this.situations[this.situations.length-1]:this.situation},add:function(t,e,i){return this.last()[i||"animations"][t]=e,this._callStart()},step:function(t){var e,i,a;t||(this.absPos=this.timeToAbsPos(+new Date)),!1!==this.situation.loops?(e=Math.max(this.absPos,0),i=Math.floor(e),!0===this.situation.loops||ithis.lastPos&&r<=s&&(this.situation.once[r].call(this.target(),this.pos,s),delete this.situation.once[r]);return this.active&&this.target().fire("during",{pos:this.pos,eased:s,fx:this,situation:this.situation}),this.situation?(this.eachAt(),1==this.pos&&!this.situation.reversed||this.situation.reversed&&0==this.pos?(this.stopAnimFrame(),this.target().fire("finished",{fx:this,situation:this.situation}),this.situations.length||(this.target().fire("allfinished"),this.situations.length||(this.target().off(".fx"),this.active=!1)),this.active?this.dequeue():this.clearCurrent()):!this.paused&&this.active&&this.startAnimFrame(),this.lastPos=s,this):this},eachAt:function(){var t,e=this,a=this.target(),s=this.situation;for(var r in s.animations)t=[].concat(s.animations[r]).map((function(t){return"string"!=typeof t&&t.at?t.at(s.ease(e.pos),e.pos):t})),a[r].apply(a,t);for(var r in s.attrs)t=[r].concat(s.attrs[r]).map((function(t){return"string"!=typeof t&&t.at?t.at(s.ease(e.pos),e.pos):t})),a.attr.apply(a,t);for(var r in s.styles)t=[r].concat(s.styles[r]).map((function(t){return"string"!=typeof t&&t.at?t.at(s.ease(e.pos),e.pos):t})),a.style.apply(a,t);if(s.transforms.length){t=s.initialTransformation,r=0;for(var o=s.transforms.length;r=0;--a)this[v[a]]=null!=t[v[a]]?t[v[a]]:e[v[a]]},extend:{extract:function(){var t=p(this,0,1);p(this,1,0);var e=180/Math.PI*Math.atan2(t.y,t.x)-90;return{x:this.e,y:this.f,transformedX:(this.e*Math.cos(e*Math.PI/180)+this.f*Math.sin(e*Math.PI/180))/Math.sqrt(this.a*this.a+this.b*this.b),transformedY:(this.f*Math.cos(e*Math.PI/180)+this.e*Math.sin(-e*Math.PI/180))/Math.sqrt(this.c*this.c+this.d*this.d),rotation:e,a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f,matrix:new i.Matrix(this)}},clone:function(){return new i.Matrix(this)},morph:function(t){return this.destination=new i.Matrix(t),this},multiply:function(t){return new i.Matrix(this.native().multiply(function(t){return t instanceof i.Matrix||(t=new i.Matrix(t)),t}(t).native()))},inverse:function(){return new i.Matrix(this.native().inverse())},translate:function(t,e){return new i.Matrix(this.native().translate(t||0,e||0))},native:function(){for(var t=i.parser.native.createSVGMatrix(),e=v.length-1;e>=0;e--)t[v[e]]=this[v[e]];return t},toString:function(){return"matrix("+b(this.a)+","+b(this.b)+","+b(this.c)+","+b(this.d)+","+b(this.e)+","+b(this.f)+")"}},parent:i.Element,construct:{ctm:function(){return new i.Matrix(this.node.getCTM())},screenCTM:function(){if(this instanceof i.Nested){var t=this.rect(1,1),e=t.node.getScreenCTM();return t.remove(),new i.Matrix(e)}return new i.Matrix(this.node.getScreenCTM())}}}),i.Point=i.invent({create:function(t,e){var i;i=Array.isArray(t)?{x:t[0],y:t[1]}:"object"===o(t)?{x:t.x,y:t.y}:null!=t?{x:t,y:null!=e?e:t}:{x:0,y:0},this.x=i.x,this.y=i.y},extend:{clone:function(){return new i.Point(this)},morph:function(t,e){return this.destination=new i.Point(t,e),this}}}),i.extend(i.Element,{point:function(t,e){return new i.Point(t,e).transform(this.screenCTM().inverse())}}),i.extend(i.Element,{attr:function(t,e,a){if(null==t){for(t={},a=(e=this.node.attributes).length-1;a>=0;a--)t[e[a].nodeName]=i.regex.isNumber.test(e[a].nodeValue)?parseFloat(e[a].nodeValue):e[a].nodeValue;return t}if("object"===o(t))for(var s in t)this.attr(s,t[s]);else if(null===e)this.node.removeAttribute(t);else{if(null==e)return null==(e=this.node.getAttribute(t))?i.defaults.attrs[t]:i.regex.isNumber.test(e)?parseFloat(e):e;"stroke-width"==t?this.attr("stroke",parseFloat(e)>0?this._stroke:null):"stroke"==t&&(this._stroke=e),"fill"!=t&&"stroke"!=t||(i.regex.isImage.test(e)&&(e=this.doc().defs().image(e,0,0)),e instanceof i.Image&&(e=this.doc().defs().pattern(0,0,(function(){this.add(e)})))),"number"==typeof e?e=new i.Number(e):i.Color.isColor(e)?e=new i.Color(e):Array.isArray(e)&&(e=new i.Array(e)),"leading"==t?this.leading&&this.leading(e):"string"==typeof a?this.node.setAttributeNS(a,t,e.toString()):this.node.setAttribute(t,e.toString()),!this.rebuild||"font-size"!=t&&"x"!=t||this.rebuild(t,e)}return this}}),i.extend(i.Element,{transform:function(t,e){var a;return"object"!==o(t)?(a=new i.Matrix(this).extract(),"string"==typeof t?a[t]:a):(a=new i.Matrix(this),e=!!e||!!t.relative,null!=t.a&&(a=e?a.multiply(new i.Matrix(t)):new i.Matrix(t)),this.attr("transform",a))}}),i.extend(i.Element,{untransform:function(){return this.attr("transform",null)},matrixify:function(){return(this.attr("transform")||"").split(i.regex.transforms).slice(0,-1).map((function(t){var e=t.trim().split("(");return[e[0],e[1].split(i.regex.delimiter).map((function(t){return parseFloat(t)}))]})).reduce((function(t,e){return"matrix"==e[0]?t.multiply(f(e[1])):t[e[0]].apply(t,e[1])}),new i.Matrix)},toParent:function(t){if(this==t)return this;var e=this.screenCTM(),i=t.screenCTM().inverse();return this.addTo(t).untransform().transform(i.multiply(e)),this},toDoc:function(){return this.toParent(this.doc())}}),i.Transformation=i.invent({create:function(t,e){if(arguments.length>1&&"boolean"!=typeof e)return this.constructor.call(this,[].slice.call(arguments));if(Array.isArray(t))for(var i=0,a=this.arguments.length;i=0},index:function(t){return[].slice.call(this.node.childNodes).indexOf(t.node)},get:function(t){return i.adopt(this.node.childNodes[t])},first:function(){return this.get(0)},last:function(){return this.get(this.node.childNodes.length-1)},each:function(t,e){for(var a=this.children(),s=0,r=a.length;s=0;a--)e.childNodes[a]instanceof t.SVGElement&&x(e.childNodes[a]);return i.adopt(e).id(i.eid(e.nodeName))}function b(t){return Math.abs(t)>1e-37?t:0}["fill","stroke"].forEach((function(t){var e={};e[t]=function(e){if(void 0===e)return this;if("string"==typeof e||i.Color.isRgb(e)||e&&"function"==typeof e.fill)this.attr(t,e);else for(var a=l[t].length-1;a>=0;a--)null!=e[l[t][a]]&&this.attr(l.prefix(t,l[t][a]),e[l[t][a]]);return this},i.extend(i.Element,i.FX,e)})),i.extend(i.Element,i.FX,{translate:function(t,e){return this.transform({x:t,y:e})},matrix:function(t){return this.attr("transform",new i.Matrix(6==arguments.length?[].slice.call(arguments):t))},opacity:function(t){return this.attr("opacity",t)},dx:function(t){return this.x(new i.Number(t).plus(this instanceof i.FX?0:this.x()),!0)},dy:function(t){return this.y(new i.Number(t).plus(this instanceof i.FX?0:this.y()),!0)}}),i.extend(i.Path,{length:function(){return this.node.getTotalLength()},pointAt:function(t){return this.node.getPointAtLength(t)}}),i.Set=i.invent({create:function(t){Array.isArray(t)?this.members=t:this.clear()},extend:{add:function(){for(var t=[].slice.call(arguments),e=0,i=t.length;e-1&&this.members.splice(e,1),this},each:function(t){for(var e=0,i=this.members.length;e=0},index:function(t){return this.members.indexOf(t)},get:function(t){return this.members[t]},first:function(){return this.get(0)},last:function(){return this.get(this.members.length-1)},valueOf:function(){return this.members}},construct:{set:function(t){return new i.Set(t)}}}),i.FX.Set=i.invent({create:function(t){this.set=t}}),i.Set.inherit=function(){var t=[];for(var e in i.Shape.prototype)"function"==typeof i.Shape.prototype[e]&&"function"!=typeof i.Set.prototype[e]&&t.push(e);for(var e in t.forEach((function(t){i.Set.prototype[t]=function(){for(var e=0,a=this.members.length;e=0;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory||(this._memory={})}}),i.get=function(t){var a=e.getElementById(function(t){var e=(t||"").toString().match(i.regex.reference);if(e)return e[1]}(t)||t);return i.adopt(a)},i.select=function(t,a){return new i.Set(i.utils.map((a||e).querySelectorAll(t),(function(t){return i.adopt(t)})))},i.extend(i.Parent,{select:function(t){return i.select(t,this.node)}});var v="abcdef".split("");if("function"!=typeof t.CustomEvent){var m=function(t,i){i=i||{bubbles:!1,cancelable:!1,detail:void 0};var a=e.createEvent("CustomEvent");return a.initCustomEvent(t,i.bubbles,i.cancelable,i.detail),a};m.prototype=t.Event.prototype,i.CustomEvent=m}else i.CustomEvent=t.CustomEvent;return i},void 0!==(a=function(){return Nt(Dt,Dt.document)}.call(e,i,e,t))&&(t.exports=a), /*! svg.filter.js - v2.0.2 - 2016-02-24 * https://github.com/wout/svg.filter.js * Copyright (c) 2016 Wout Fierens; Licensed MIT */ -function(){SVG.Filter=SVG.invent({create:"filter",inherit:SVG.Parent,extend:{source:"SourceGraphic",sourceAlpha:"SourceAlpha",background:"BackgroundImage",backgroundAlpha:"BackgroundAlpha",fill:"FillPaint",stroke:"StrokePaint",autoSetIn:!0,put:function(t,e){return this.add(t,e),!t.attr("in")&&this.autoSetIn&&t.attr("in",this.source),t.attr("result")||t.attr("result",t),t},blend:function(t,e,i){return this.put(new SVG.BlendEffect(t,e,i))},colorMatrix:function(t,e){return this.put(new SVG.ColorMatrixEffect(t,e))},convolveMatrix:function(t){return this.put(new SVG.ConvolveMatrixEffect(t))},componentTransfer:function(t){return this.put(new SVG.ComponentTransferEffect(t))},composite:function(t,e,i){return this.put(new SVG.CompositeEffect(t,e,i))},flood:function(t,e){return this.put(new SVG.FloodEffect(t,e))},offset:function(t,e){return this.put(new SVG.OffsetEffect(t,e))},image:function(t){return this.put(new SVG.ImageEffect(t))},merge:function(){var t=[void 0];for(var e in arguments)t.push(arguments[e]);return this.put(new(SVG.MergeEffect.bind.apply(SVG.MergeEffect,t)))},gaussianBlur:function(t,e){return this.put(new SVG.GaussianBlurEffect(t,e))},morphology:function(t,e){return this.put(new SVG.MorphologyEffect(t,e))},diffuseLighting:function(t,e,i){return this.put(new SVG.DiffuseLightingEffect(t,e,i))},displacementMap:function(t,e,i,a,s){return this.put(new SVG.DisplacementMapEffect(t,e,i,a,s))},specularLighting:function(t,e,i,a){return this.put(new SVG.SpecularLightingEffect(t,e,i,a))},tile:function(){return this.put(new SVG.TileEffect)},turbulence:function(t,e,i,a,s){return this.put(new SVG.TurbulenceEffect(t,e,i,a,s))},toString:function(){return"url(#"+this.attr("id")+")"}}}),SVG.extend(SVG.Defs,{filter:function(t){var e=this.put(new SVG.Filter);return"function"==typeof t&&t.call(e,e),e}}),SVG.extend(SVG.Container,{filter:function(t){return this.defs().filter(t)}}),SVG.extend(SVG.Element,SVG.G,SVG.Nested,{filter:function(t){return this.filterer=t instanceof SVG.Element?t:this.doc().filter(t),this.doc()&&this.filterer.doc()!==this.doc()&&this.doc().defs().add(this.filterer),this.attr("filter",this.filterer),this.filterer},unfilter:function(t){return this.filterer&&!0===t&&this.filterer.remove(),delete this.filterer,this.attr("filter",null)}}),SVG.Effect=SVG.invent({create:function(){this.constructor.call(this)},inherit:SVG.Element,extend:{in:function(t){return null==t?this.parent()&&this.parent().select('[result="'+this.attr("in")+'"]').get(0)||this.attr("in"):this.attr("in",t)},result:function(t){return null==t?this.attr("result"):this.attr("result",t)},toString:function(){return this.result()}}}),SVG.ParentEffect=SVG.invent({create:function(){this.constructor.call(this)},inherit:SVG.Parent,extend:{in:function(t){return null==t?this.parent()&&this.parent().select('[result="'+this.attr("in")+'"]').get(0)||this.attr("in"):this.attr("in",t)},result:function(t){return null==t?this.attr("result"):this.attr("result",t)},toString:function(){return this.result()}}});var t={blend:function(t,e){return this.parent()&&this.parent().blend(this,t,e)},colorMatrix:function(t,e){return this.parent()&&this.parent().colorMatrix(t,e).in(this)},convolveMatrix:function(t){return this.parent()&&this.parent().convolveMatrix(t).in(this)},componentTransfer:function(t){return this.parent()&&this.parent().componentTransfer(t).in(this)},composite:function(t,e){return this.parent()&&this.parent().composite(this,t,e)},flood:function(t,e){return this.parent()&&this.parent().flood(t,e)},offset:function(t,e){return this.parent()&&this.parent().offset(t,e).in(this)},image:function(t){return this.parent()&&this.parent().image(t)},merge:function(){return this.parent()&&this.parent().merge.apply(this.parent(),[this].concat(arguments))},gaussianBlur:function(t,e){return this.parent()&&this.parent().gaussianBlur(t,e).in(this)},morphology:function(t,e){return this.parent()&&this.parent().morphology(t,e).in(this)},diffuseLighting:function(t,e,i){return this.parent()&&this.parent().diffuseLighting(t,e,i).in(this)},displacementMap:function(t,e,i,a){return this.parent()&&this.parent().displacementMap(this,t,e,i,a)},specularLighting:function(t,e,i,a){return this.parent()&&this.parent().specularLighting(t,e,i,a).in(this)},tile:function(){return this.parent()&&this.parent().tile().in(this)},turbulence:function(t,e,i,a,s){return this.parent()&&this.parent().turbulence(t,e,i,a,s).in(this)}};SVG.extend(SVG.Effect,t),SVG.extend(SVG.ParentEffect,t),SVG.ChildEffect=SVG.invent({create:function(){this.constructor.call(this)},inherit:SVG.Element,extend:{in:function(t){this.attr("in",t)}}});var e={blend:function(t,e,i){this.attr({in:t,in2:e,mode:i||"normal"})},colorMatrix:function(t,e){"matrix"==t&&(e=s(e)),this.attr({type:t,values:void 0===e?null:e})},convolveMatrix:function(t){t=s(t),this.attr({order:Math.sqrt(t.split(" ").length),kernelMatrix:t})},composite:function(t,e,i){this.attr({in:t,in2:e,operator:i})},flood:function(t,e){this.attr("flood-color",t),null!=e&&this.attr("flood-opacity",e)},offset:function(t,e){this.attr({dx:t,dy:e})},image:function(t){this.attr("href",t,SVG.xlink)},displacementMap:function(t,e,i,a,s){this.attr({in:t,in2:e,scale:i,xChannelSelector:a,yChannelSelector:s})},gaussianBlur:function(t,e){null!=t||null!=e?this.attr("stdDeviation",r(Array.prototype.slice.call(arguments))):this.attr("stdDeviation","0 0")},morphology:function(t,e){this.attr({operator:t,radius:e})},tile:function(){},turbulence:function(t,e,i,a,s){this.attr({numOctaves:e,seed:i,stitchTiles:a,baseFrequency:t,type:s})}},i={merge:function(){var t;if(arguments[0]instanceof SVG.Set){var e=this;arguments[0].each((function(t){this instanceof SVG.MergeNode?e.put(this):(this instanceof SVG.Effect||this instanceof SVG.ParentEffect)&&e.put(new SVG.MergeNode(this))}))}else{t=Array.isArray(arguments[0])?arguments[0]:arguments;for(var i=0;i1&&(T*=a=Math.sqrt(a),M*=a),s=(new SVG.Matrix).rotate(I).scale(1/T,1/M).rotate(-I),F=F.transform(s),n=(r=[(R=R.transform(s)).x-F.x,R.y-F.y])[0]*r[0]+r[1]*r[1],o=Math.sqrt(n),r[0]/=o,r[1]/=o,l=n<4?Math.sqrt(1-n/4):0,z===E&&(l*=-1),h=new SVG.Point((R.x+F.x)/2+l*-r[1],(R.y+F.y)/2+l*r[0]),c=new SVG.Point(F.x-h.x,F.y-h.y),d=new SVG.Point(R.x-h.x,R.y-h.y),g=Math.acos(c.x/Math.sqrt(c.x*c.x+c.y*c.y)),c.y<0&&(g*=-1),u=Math.acos(d.x/Math.sqrt(d.x*d.x+d.y*d.y)),d.y<0&&(u*=-1),E&&g>u&&(u+=2*Math.PI),!E&&g1&&(T*=a=Math.sqrt(a),I*=a),s=(new SVG.Matrix).rotate(M).scale(1/T,1/I).rotate(-M),F=F.transform(s),n=(r=[(R=R.transform(s)).x-F.x,R.y-F.y])[0]*r[0]+r[1]*r[1],o=Math.sqrt(n),r[0]/=o,r[1]/=o,l=n<4?Math.sqrt(1-n/4):0,X===z&&(l*=-1),h=new SVG.Point((R.x+F.x)/2+l*-r[1],(R.y+F.y)/2+l*r[0]),c=new SVG.Point(F.x-h.x,F.y-h.y),d=new SVG.Point(R.x-h.x,R.y-h.y),g=Math.acos(c.x/Math.sqrt(c.x*c.x+c.y*c.y)),c.y<0&&(g*=-1),u=Math.acos(d.x/Math.sqrt(d.x*d.x+d.y*d.y)),d.y<0&&(u*=-1),z&&g>u&&(u+=2*Math.PI),!z&&gr.maxX-e.width&&(o=(a=r.maxX-e.width)-this.startPoints.box.x),null!=r.minY&&sr.maxY-e.height&&(n=(s=r.maxY-e.height)-this.startPoints.box.y),null!=r.snapToGrid&&(a-=a%r.snapToGrid,s-=s%r.snapToGrid,o-=o%r.snapToGrid,n-=n%r.snapToGrid),this.el instanceof SVG.G?this.el.matrix(this.startPoints.transform).transform({x:o,y:n},!0):this.el.move(a,s));return i},t.prototype.end=function(t){var e=this.drag(t);this.el.fire("dragend",{event:t,p:e,m:this.m,handler:this}),SVG.off(window,"mousemove.drag"),SVG.off(window,"touchmove.drag"),SVG.off(window,"mouseup.drag"),SVG.off(window,"touchend.drag")},SVG.extend(SVG.Element,{draggable:function(e,i){"function"!=typeof e&&"object"!=typeof e||(i=e,e=!0);var a=this.remember("_draggable")||new t(this);return(e=void 0===e||e)?a.init(i||{},e):(this.off("mousedown.drag"),this.off("touchstart.drag")),this}})}.call(void 0),function(){function t(t){this.el=t,t.remember("_selectHandler",this),this.pointSelection={isSelected:!1},this.rectSelection={isSelected:!1},this.pointsList={lt:[0,0],rt:["width",0],rb:["width","height"],lb:[0,"height"],t:["width",0],r:["width","height"],b:["width","height"],l:[0,"height"]},this.pointCoord=function(t,e,i){var a="string"!=typeof t?t:e[t];return i?a/2:a},this.pointCoords=function(t,e){var i=this.pointsList[t];return{x:this.pointCoord(i[0],e,"t"===t||"b"===t),y:this.pointCoord(i[1],e,"r"===t||"l"===t)}}}t.prototype.init=function(t,e){var i=this.el.bbox();this.options={};var a=this.el.selectize.defaults.points;for(var s in this.el.selectize.defaults)this.options[s]=this.el.selectize.defaults[s],void 0!==e[s]&&(this.options[s]=e[s]);var r=["points","pointsExclude"];for(var s in r){var o=this.options[r[s]];"string"==typeof o?o=o.length>0?o.split(/\s*,\s*/i):[]:"boolean"==typeof o&&"points"===r[s]&&(o=o?a:[]),this.options[r[s]]=o}this.options.points=[a,this.options.points].reduce((function(t,e){return t.filter((function(t){return e.indexOf(t)>-1}))})),this.options.points=[this.options.points,this.options.pointsExclude].reduce((function(t,e){return t.filter((function(t){return e.indexOf(t)<0}))})),this.parent=this.el.parent(),this.nested=this.nested||this.parent.group(),this.nested.matrix(new SVG.Matrix(this.el).translate(i.x,i.y)),this.options.deepSelect&&-1!==["line","polyline","polygon"].indexOf(this.el.type)?this.selectPoints(t):this.selectRect(t),this.observe(),this.cleanup()},t.prototype.selectPoints=function(t){return this.pointSelection.isSelected=t,this.pointSelection.set||(this.pointSelection.set=this.parent.set(),this.drawPoints()),this},t.prototype.getPointArray=function(){var t=this.el.bbox();return this.el.array().valueOf().map((function(e){return[e[0]-t.x,e[1]-t.y]}))},t.prototype.drawPoints=function(){for(var t=this,e=this.getPointArray(),i=0,a=e.length;i0&&this.parameters.box.height-i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x+i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize-i[0]);i=this.checkAspectRatio(i),this.el.move(this.parameters.box.x+i[0],this.parameters.box.y+i[1]).size(this.parameters.box.width-i[0],this.parameters.box.height-i[1])}};break;case"rt":this.calc=function(t,e){var i=this.snapToGrid(t,e,2);if(this.parameters.box.width+i[0]>0&&this.parameters.box.height-i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x-i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize+i[0]);i=this.checkAspectRatio(i,!0),this.el.move(this.parameters.box.x,this.parameters.box.y+i[1]).size(this.parameters.box.width+i[0],this.parameters.box.height-i[1])}};break;case"rb":this.calc=function(t,e){var i=this.snapToGrid(t,e,0);if(this.parameters.box.width+i[0]>0&&this.parameters.box.height+i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x-i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize+i[0]);i=this.checkAspectRatio(i),this.el.move(this.parameters.box.x,this.parameters.box.y).size(this.parameters.box.width+i[0],this.parameters.box.height+i[1])}};break;case"lb":this.calc=function(t,e){var i=this.snapToGrid(t,e,1);if(this.parameters.box.width-i[0]>0&&this.parameters.box.height+i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x+i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize-i[0]);i=this.checkAspectRatio(i,!0),this.el.move(this.parameters.box.x+i[0],this.parameters.box.y).size(this.parameters.box.width-i[0],this.parameters.box.height+i[1])}};break;case"t":this.calc=function(t,e){var i=this.snapToGrid(t,e,2);if(this.parameters.box.height-i[1]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y+i[1]).height(this.parameters.box.height-i[1])}};break;case"r":this.calc=function(t,e){var i=this.snapToGrid(t,e,0);if(this.parameters.box.width+i[0]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y).width(this.parameters.box.width+i[0])}};break;case"b":this.calc=function(t,e){var i=this.snapToGrid(t,e,0);if(this.parameters.box.height+i[1]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y).height(this.parameters.box.height+i[1])}};break;case"l":this.calc=function(t,e){var i=this.snapToGrid(t,e,1);if(this.parameters.box.width-i[0]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x+i[0],this.parameters.box.y).width(this.parameters.box.width-i[0])}};break;case"rot":this.calc=function(t,e){var i=t+this.parameters.p.x,a=e+this.parameters.p.y,s=Math.atan2(this.parameters.p.y-this.parameters.box.y-this.parameters.box.height/2,this.parameters.p.x-this.parameters.box.x-this.parameters.box.width/2),r=Math.atan2(a-this.parameters.box.y-this.parameters.box.height/2,i-this.parameters.box.x-this.parameters.box.width/2),o=this.parameters.rotation+180*(r-s)/Math.PI+this.options.snapToAngle/2;this.el.center(this.parameters.box.cx,this.parameters.box.cy).rotate(o-o%this.options.snapToAngle,this.parameters.box.cx,this.parameters.box.cy)};break;case"point":this.calc=function(t,e){var i=this.snapToGrid(t,e,this.parameters.pointCoords[0],this.parameters.pointCoords[1]),a=this.el.array().valueOf();a[this.parameters.i][0]=this.parameters.pointCoords[0]+i[0],a[this.parameters.i][1]=this.parameters.pointCoords[1]+i[1],this.el.plot(a)}}this.el.fire("resizestart",{dx:this.parameters.x,dy:this.parameters.y,event:t}),SVG.on(window,"touchmove.resize",(function(t){e.update(t||window.event)})),SVG.on(window,"touchend.resize",(function(){e.done()})),SVG.on(window,"mousemove.resize",(function(t){e.update(t||window.event)})),SVG.on(window,"mouseup.resize",(function(){e.done()}))},t.prototype.update=function(t){if(t){var e=this._extractPosition(t),i=this.transformPoint(e.x,e.y),a=i.x-this.parameters.p.x,s=i.y-this.parameters.p.y;this.lastUpdateCall=[a,s],this.calc(a,s),this.el.fire("resizing",{dx:a,dy:s,event:t})}else this.lastUpdateCall&&this.calc(this.lastUpdateCall[0],this.lastUpdateCall[1])},t.prototype.done=function(){this.lastUpdateCall=null,SVG.off(window,"mousemove.resize"),SVG.off(window,"mouseup.resize"),SVG.off(window,"touchmove.resize"),SVG.off(window,"touchend.resize"),this.el.fire("resizedone")},t.prototype.snapToGrid=function(t,e,i,a){var s;return void 0!==a?s=[(i+t)%this.options.snapToGrid,(a+e)%this.options.snapToGrid]:(i=null==i?3:i,s=[(this.parameters.box.x+t+(1&i?0:this.parameters.box.width))%this.options.snapToGrid,(this.parameters.box.y+e+(2&i?0:this.parameters.box.height))%this.options.snapToGrid]),t<0&&(s[0]-=this.options.snapToGrid),e<0&&(s[1]-=this.options.snapToGrid),t-=Math.abs(s[0])o.maxX&&(t=o.maxX-s),void 0!==o.minY&&r+eo.maxY&&(e=o.maxY-r),[t,e]},t.prototype.checkAspectRatio=function(t,e){if(!this.options.saveAspectRatio)return t;var i=t.slice(),a=this.parameters.box.width/this.parameters.box.height,s=this.parameters.box.width+t[0],r=this.parameters.box.height-t[1],o=s/r;return oa&&(i[0]=this.parameters.box.width-r*a,e&&(i[0]=-i[0])),i},SVG.extend(SVG.Element,{resize:function(e){return(this.remember("_resizeHandler")||new t(this)).init(e||{}),this}}),SVG.Element.prototype.resize.defaults={snapToAngle:.1,snapToGrid:1,constraint:{},saveAspectRatio:!1}}).call(this)}(),void 0===window.Apex&&(window.Apex={});var Wt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"initModules",value:function(){this.ctx.publicMethods=["updateOptions","updateSeries","appendData","appendSeries","toggleSeries","showSeries","hideSeries","setLocale","resetSeries","zoomX","toggleDataPointSelection","dataURI","exportToCSV","addXaxisAnnotation","addYaxisAnnotation","addPointAnnotation","clearAnnotations","removeAnnotation","paper","destroy"],this.ctx.eventList=["click","mousedown","mousemove","mouseleave","touchstart","touchmove","touchleave","mouseup","touchend"],this.ctx.animations=new y(this.ctx),this.ctx.axes=new tt(this.ctx),this.ctx.core=new Ot(this.ctx.el,this.ctx),this.ctx.config=new F({}),this.ctx.data=new G(this.ctx),this.ctx.grid=new q(this.ctx),this.ctx.graphics=new k(this.ctx),this.ctx.coreUtils=new A(this.ctx),this.ctx.crosshairs=new et(this.ctx),this.ctx.events=new Q(this.ctx),this.ctx.exports=new _(this.ctx),this.ctx.localization=new K(this.ctx),this.ctx.options=new M,this.ctx.responsive=new it(this.ctx),this.ctx.series=new B(this.ctx),this.ctx.theme=new at(this.ctx),this.ctx.formatters=new V(this.ctx),this.ctx.titleSubtitle=new st(this.ctx),this.ctx.legend=new dt(this.ctx),this.ctx.toolbar=new gt(this.ctx),this.ctx.tooltip=new yt(this.ctx),this.ctx.dimensions=new ht(this.ctx),this.ctx.updateHelpers=new Nt(this.ctx),this.ctx.zoomPanSelection=new ut(this.ctx),this.ctx.w.globals.tooltip=new yt(this.ctx)}}]),t}(),Bt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"clear",value:function(t){var e=t.isUpdating;this.ctx.zoomPanSelection&&this.ctx.zoomPanSelection.destroy(),this.ctx.toolbar&&this.ctx.toolbar.destroy(),this.ctx.animations=null,this.ctx.axes=null,this.ctx.annotations=null,this.ctx.core=null,this.ctx.data=null,this.ctx.grid=null,this.ctx.series=null,this.ctx.responsive=null,this.ctx.theme=null,this.ctx.formatters=null,this.ctx.titleSubtitle=null,this.ctx.legend=null,this.ctx.dimensions=null,this.ctx.options=null,this.ctx.crosshairs=null,this.ctx.zoomPanSelection=null,this.ctx.updateHelpers=null,this.ctx.toolbar=null,this.ctx.localization=null,this.ctx.w.globals.tooltip=null,this.clearDomElements({isUpdating:e})}},{key:"killSVG",value:function(t){t.each((function(t,e){this.removeClass("*"),this.off(),this.stop()}),!0),t.ungroup(),t.clear()}},{key:"clearDomElements",value:function(t){var e=this,i=t.isUpdating,a=this.w.globals.dom.Paper.node;a.parentNode&&a.parentNode.parentNode&&!i&&(a.parentNode.parentNode.style.minHeight="unset");var s=this.w.globals.dom.baseEl;s&&this.ctx.eventList.forEach((function(t){s.removeEventListener(t,e.ctx.events.documentEvent)}));var r=this.w.globals.dom;if(null!==this.ctx.el)for(;this.ctx.el.firstChild;)this.ctx.el.removeChild(this.ctx.el.firstChild);this.killSVG(r.Paper),r.Paper.remove(),r.elWrap=null,r.elGraphical=null,r.elAnnotations=null,r.elLegendWrap=null,r.baseEl=null,r.elGridRect=null,r.elGridRectMask=null,r.elGridRectMarkerMask=null,r.elForecastMask=null,r.elNonForecastMask=null,r.elDefs=null}}]),t}(),Gt=new WeakMap,Vt=function(){function t(e,i){n(this,t),this.opts=i,this.ctx=this,this.w=new D(i).init(),this.el=e,this.w.globals.cuid=m.randomId(),this.w.globals.chartID=this.w.config.chart.id?m.escapeString(this.w.config.chart.id):this.w.globals.cuid,new Wt(this).initModules(),this.create=m.bind(this.create,this),this.windowResizeHandler=this._windowResizeHandler.bind(this),this.parentResizeHandler=this._parentResizeCallback.bind(this)}return h(t,[{key:"render",value:function(){var t=this;return new Promise((function(e,i){if(null!==t.el){void 0===Apex._chartInstances&&(Apex._chartInstances=[]),t.w.config.chart.id&&Apex._chartInstances.push({id:t.w.globals.chartID,group:t.w.config.chart.group,chart:t}),t.setLocale(t.w.config.chart.defaultLocale);var a=t.w.config.chart.events.beforeMount;if("function"==typeof a&&a(t,t.w),t.events.fireEvent("beforeMount",[t,t.w]),window.addEventListener("resize",t.windowResizeHandler),function(t,e){var i=!1;if(t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE){var a=t.getBoundingClientRect();"none"!==t.style.display&&0!==a.width||(i=!0)}var s=new ResizeObserver((function(a){i&&e.call(t,a),i=!0}));t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(t.children).forEach((function(t){return s.observe(t)})):s.observe(t),Gt.set(e,s)}(t.el.parentNode,t.parentResizeHandler),!t.css){var s=t.el.getRootNode&&t.el.getRootNode(),r=m.is("ShadowRoot",s),o=t.el.ownerDocument,n=o.getElementById("apexcharts-css");!r&&n||(t.css=document.createElement("style"),t.css.id="apexcharts-css",t.css.textContent='@keyframes opaque {\n 0% {\n opacity: 0\n }\n\n to {\n opacity: 1\n }\n}\n\n@keyframes resizeanim {\n 0%,to {\n opacity: 0\n }\n}\n\n.apexcharts-canvas {\n position: relative;\n user-select: none\n}\n\n.apexcharts-canvas ::-webkit-scrollbar {\n -webkit-appearance: none;\n width: 6px\n}\n\n.apexcharts-canvas ::-webkit-scrollbar-thumb {\n border-radius: 4px;\n background-color: rgba(0,0,0,.5);\n box-shadow: 0 0 1px rgba(255,255,255,.5);\n -webkit-box-shadow: 0 0 1px rgba(255,255,255,.5)\n}\n\n.apexcharts-inner {\n position: relative\n}\n\n.apexcharts-text tspan {\n font-family: inherit\n}\n\n.legend-mouseover-inactive {\n transition: .15s ease all;\n opacity: .2\n}\n\n.apexcharts-legend-text {\n padding-left: 15px;\n margin-left: -15px;\n}\n\n.apexcharts-series-collapsed {\n opacity: 0\n}\n\n.apexcharts-tooltip {\n border-radius: 5px;\n box-shadow: 2px 2px 6px -4px #999;\n cursor: default;\n font-size: 14px;\n left: 62px;\n opacity: 0;\n pointer-events: none;\n position: absolute;\n top: 20px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n white-space: nowrap;\n z-index: 12;\n transition: .15s ease all\n}\n\n.apexcharts-tooltip.apexcharts-active {\n opacity: 1;\n transition: .15s ease all\n}\n\n.apexcharts-tooltip.apexcharts-theme-light {\n border: 1px solid #e3e3e3;\n background: rgba(255,255,255,.96)\n}\n\n.apexcharts-tooltip.apexcharts-theme-dark {\n color: #fff;\n background: rgba(30,30,30,.8)\n}\n\n.apexcharts-tooltip * {\n font-family: inherit\n}\n\n.apexcharts-tooltip-title {\n padding: 6px;\n font-size: 15px;\n margin-bottom: 4px\n}\n\n.apexcharts-tooltip.apexcharts-theme-light .apexcharts-tooltip-title {\n background: #eceff1;\n border-bottom: 1px solid #ddd\n}\n\n.apexcharts-tooltip.apexcharts-theme-dark .apexcharts-tooltip-title {\n background: rgba(0,0,0,.7);\n border-bottom: 1px solid #333\n}\n\n.apexcharts-tooltip-text-goals-value,.apexcharts-tooltip-text-y-value,.apexcharts-tooltip-text-z-value {\n display: inline-block;\n margin-left: 5px;\n font-weight: 600\n}\n\n.apexcharts-tooltip-text-goals-label:empty,.apexcharts-tooltip-text-goals-value:empty,.apexcharts-tooltip-text-y-label:empty,.apexcharts-tooltip-text-y-value:empty,.apexcharts-tooltip-text-z-value:empty,.apexcharts-tooltip-title:empty {\n display: none\n}\n\n.apexcharts-tooltip-text-goals-label,.apexcharts-tooltip-text-goals-value {\n padding: 6px 0 5px\n}\n\n.apexcharts-tooltip-goals-group,.apexcharts-tooltip-text-goals-label,.apexcharts-tooltip-text-goals-value {\n display: flex\n}\n\n.apexcharts-tooltip-text-goals-label:not(:empty),.apexcharts-tooltip-text-goals-value:not(:empty) {\n margin-top: -6px\n}\n\n.apexcharts-tooltip-marker {\n width: 12px;\n height: 12px;\n position: relative;\n top: 0;\n margin-right: 10px;\n border-radius: 50%\n}\n\n.apexcharts-tooltip-series-group {\n padding: 0 10px;\n display: none;\n text-align: left;\n justify-content: left;\n align-items: center\n}\n\n.apexcharts-tooltip-series-group.apexcharts-active .apexcharts-tooltip-marker {\n opacity: 1\n}\n\n.apexcharts-tooltip-series-group.apexcharts-active,.apexcharts-tooltip-series-group:last-child {\n padding-bottom: 4px\n}\n\n.apexcharts-tooltip-series-group-hidden {\n opacity: 0;\n height: 0;\n line-height: 0;\n padding: 0!important\n}\n\n.apexcharts-tooltip-y-group {\n padding: 6px 0 5px\n}\n\n.apexcharts-custom-tooltip,.apexcharts-tooltip-box {\n padding: 4px 8px\n}\n\n.apexcharts-tooltip-boxPlot {\n display: flex;\n flex-direction: column-reverse\n}\n\n.apexcharts-tooltip-box>div {\n margin: 4px 0\n}\n\n.apexcharts-tooltip-box span.value {\n font-weight: 700\n}\n\n.apexcharts-tooltip-rangebar {\n padding: 5px 8px\n}\n\n.apexcharts-tooltip-rangebar .category {\n font-weight: 600;\n color: #777\n}\n\n.apexcharts-tooltip-rangebar .series-name {\n font-weight: 700;\n display: block;\n margin-bottom: 5px\n}\n\n.apexcharts-xaxistooltip,.apexcharts-yaxistooltip {\n opacity: 0;\n pointer-events: none;\n color: #373d3f;\n font-size: 13px;\n text-align: center;\n border-radius: 2px;\n position: absolute;\n z-index: 10;\n background: #eceff1;\n border: 1px solid #90a4ae\n}\n\n.apexcharts-xaxistooltip {\n padding: 9px 10px;\n transition: .15s ease all\n}\n\n.apexcharts-xaxistooltip.apexcharts-theme-dark {\n background: rgba(0,0,0,.7);\n border: 1px solid rgba(0,0,0,.5);\n color: #fff\n}\n\n.apexcharts-xaxistooltip:after,.apexcharts-xaxistooltip:before {\n left: 50%;\n border: solid transparent;\n content: " ";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none\n}\n\n.apexcharts-xaxistooltip:after {\n border-color: transparent;\n border-width: 6px;\n margin-left: -6px\n}\n\n.apexcharts-xaxistooltip:before {\n border-color: transparent;\n border-width: 7px;\n margin-left: -7px\n}\n\n.apexcharts-xaxistooltip-bottom:after,.apexcharts-xaxistooltip-bottom:before {\n bottom: 100%\n}\n\n.apexcharts-xaxistooltip-top:after,.apexcharts-xaxistooltip-top:before {\n top: 100%\n}\n\n.apexcharts-xaxistooltip-bottom:after {\n border-bottom-color: #eceff1\n}\n\n.apexcharts-xaxistooltip-bottom:before {\n border-bottom-color: #90a4ae\n}\n\n.apexcharts-xaxistooltip-bottom.apexcharts-theme-dark:after,.apexcharts-xaxistooltip-bottom.apexcharts-theme-dark:before {\n border-bottom-color: rgba(0,0,0,.5)\n}\n\n.apexcharts-xaxistooltip-top:after {\n border-top-color: #eceff1\n}\n\n.apexcharts-xaxistooltip-top:before {\n border-top-color: #90a4ae\n}\n\n.apexcharts-xaxistooltip-top.apexcharts-theme-dark:after,.apexcharts-xaxistooltip-top.apexcharts-theme-dark:before {\n border-top-color: rgba(0,0,0,.5)\n}\n\n.apexcharts-xaxistooltip.apexcharts-active {\n opacity: 1;\n transition: .15s ease all\n}\n\n.apexcharts-yaxistooltip {\n padding: 4px 10px\n}\n\n.apexcharts-yaxistooltip.apexcharts-theme-dark {\n background: rgba(0,0,0,.7);\n border: 1px solid rgba(0,0,0,.5);\n color: #fff\n}\n\n.apexcharts-yaxistooltip:after,.apexcharts-yaxistooltip:before {\n top: 50%;\n border: solid transparent;\n content: " ";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none\n}\n\n.apexcharts-yaxistooltip:after {\n border-color: transparent;\n border-width: 6px;\n margin-top: -6px\n}\n\n.apexcharts-yaxistooltip:before {\n border-color: transparent;\n border-width: 7px;\n margin-top: -7px\n}\n\n.apexcharts-yaxistooltip-left:after,.apexcharts-yaxistooltip-left:before {\n left: 100%\n}\n\n.apexcharts-yaxistooltip-right:after,.apexcharts-yaxistooltip-right:before {\n right: 100%\n}\n\n.apexcharts-yaxistooltip-left:after {\n border-left-color: #eceff1\n}\n\n.apexcharts-yaxistooltip-left:before {\n border-left-color: #90a4ae\n}\n\n.apexcharts-yaxistooltip-left.apexcharts-theme-dark:after,.apexcharts-yaxistooltip-left.apexcharts-theme-dark:before {\n border-left-color: rgba(0,0,0,.5)\n}\n\n.apexcharts-yaxistooltip-right:after {\n border-right-color: #eceff1\n}\n\n.apexcharts-yaxistooltip-right:before {\n border-right-color: #90a4ae\n}\n\n.apexcharts-yaxistooltip-right.apexcharts-theme-dark:after,.apexcharts-yaxistooltip-right.apexcharts-theme-dark:before {\n border-right-color: rgba(0,0,0,.5)\n}\n\n.apexcharts-yaxistooltip.apexcharts-active {\n opacity: 1\n}\n\n.apexcharts-yaxistooltip-hidden {\n display: none\n}\n\n.apexcharts-xcrosshairs,.apexcharts-ycrosshairs {\n pointer-events: none;\n opacity: 0;\n transition: .15s ease all\n}\n\n.apexcharts-xcrosshairs.apexcharts-active,.apexcharts-ycrosshairs.apexcharts-active {\n opacity: 1;\n transition: .15s ease all\n}\n\n.apexcharts-ycrosshairs-hidden {\n opacity: 0\n}\n\n.apexcharts-selection-rect {\n cursor: move\n}\n\n.svg_select_boundingRect,.svg_select_points_rot {\n pointer-events: none;\n opacity: 0;\n visibility: hidden\n}\n\n.apexcharts-selection-rect+g .svg_select_boundingRect,.apexcharts-selection-rect+g .svg_select_points_rot {\n opacity: 0;\n visibility: hidden\n}\n\n.apexcharts-selection-rect+g .svg_select_points_l,.apexcharts-selection-rect+g .svg_select_points_r {\n cursor: ew-resize;\n opacity: 1;\n visibility: visible\n}\n\n.svg_select_points {\n fill: #efefef;\n stroke: #333;\n rx: 2\n}\n\n.apexcharts-svg.apexcharts-zoomable.hovering-zoom {\n cursor: crosshair\n}\n\n.apexcharts-svg.apexcharts-zoomable.hovering-pan {\n cursor: move\n}\n\n.apexcharts-menu-icon,.apexcharts-pan-icon,.apexcharts-reset-icon,.apexcharts-selection-icon,.apexcharts-toolbar-custom-icon,.apexcharts-zoom-icon,.apexcharts-zoomin-icon,.apexcharts-zoomout-icon {\n cursor: pointer;\n width: 20px;\n height: 20px;\n line-height: 24px;\n color: #6e8192;\n text-align: center\n}\n\n.apexcharts-menu-icon svg,.apexcharts-reset-icon svg,.apexcharts-zoom-icon svg,.apexcharts-zoomin-icon svg,.apexcharts-zoomout-icon svg {\n fill: #6e8192\n}\n\n.apexcharts-selection-icon svg {\n fill: #444;\n transform: scale(.76)\n}\n\n.apexcharts-theme-dark .apexcharts-menu-icon svg,.apexcharts-theme-dark .apexcharts-pan-icon svg,.apexcharts-theme-dark .apexcharts-reset-icon svg,.apexcharts-theme-dark .apexcharts-selection-icon svg,.apexcharts-theme-dark .apexcharts-toolbar-custom-icon svg,.apexcharts-theme-dark .apexcharts-zoom-icon svg,.apexcharts-theme-dark .apexcharts-zoomin-icon svg,.apexcharts-theme-dark .apexcharts-zoomout-icon svg {\n fill: #f3f4f5\n}\n\n.apexcharts-canvas .apexcharts-reset-zoom-icon.apexcharts-selected svg,.apexcharts-canvas .apexcharts-selection-icon.apexcharts-selected svg,.apexcharts-canvas .apexcharts-zoom-icon.apexcharts-selected svg {\n fill: #008ffb\n}\n\n.apexcharts-theme-light .apexcharts-menu-icon:hover svg,.apexcharts-theme-light .apexcharts-reset-icon:hover svg,.apexcharts-theme-light .apexcharts-selection-icon:not(.apexcharts-selected):hover svg,.apexcharts-theme-light .apexcharts-zoom-icon:not(.apexcharts-selected):hover svg,.apexcharts-theme-light .apexcharts-zoomin-icon:hover svg,.apexcharts-theme-light .apexcharts-zoomout-icon:hover svg {\n fill: #333\n}\n\n.apexcharts-menu-icon,.apexcharts-selection-icon {\n position: relative\n}\n\n.apexcharts-reset-icon {\n margin-left: 5px\n}\n\n.apexcharts-menu-icon,.apexcharts-reset-icon,.apexcharts-zoom-icon {\n transform: scale(.85)\n}\n\n.apexcharts-zoomin-icon,.apexcharts-zoomout-icon {\n transform: scale(.7)\n}\n\n.apexcharts-zoomout-icon {\n margin-right: 3px\n}\n\n.apexcharts-pan-icon {\n transform: scale(.62);\n position: relative;\n left: 1px;\n top: 0\n}\n\n.apexcharts-pan-icon svg {\n fill: #fff;\n stroke: #6e8192;\n stroke-width: 2\n}\n\n.apexcharts-pan-icon.apexcharts-selected svg {\n stroke: #008ffb\n}\n\n.apexcharts-pan-icon:not(.apexcharts-selected):hover svg {\n stroke: #333\n}\n\n.apexcharts-toolbar {\n position: absolute;\n z-index: 11;\n max-width: 176px;\n text-align: right;\n border-radius: 3px;\n padding: 0 6px 2px;\n display: flex;\n justify-content: space-between;\n align-items: center\n}\n\n.apexcharts-menu {\n background: #fff;\n position: absolute;\n top: 100%;\n border: 1px solid #ddd;\n border-radius: 3px;\n padding: 3px;\n right: 10px;\n opacity: 0;\n min-width: 110px;\n transition: .15s ease all;\n pointer-events: none\n}\n\n.apexcharts-menu.apexcharts-menu-open {\n opacity: 1;\n pointer-events: all;\n transition: .15s ease all\n}\n\n.apexcharts-menu-item {\n padding: 6px 7px;\n font-size: 12px;\n cursor: pointer\n}\n\n.apexcharts-theme-light .apexcharts-menu-item:hover {\n background: #eee\n}\n\n.apexcharts-theme-dark .apexcharts-menu {\n background: rgba(0,0,0,.7);\n color: #fff\n}\n\n@media screen and (min-width:768px) {\n .apexcharts-canvas:hover .apexcharts-toolbar {\n opacity: 1\n }\n}\n\n.apexcharts-canvas .apexcharts-element-hidden,.apexcharts-datalabel.apexcharts-element-hidden,.apexcharts-hide .apexcharts-series-points {\n opacity: 0\n}\n\n.apexcharts-datalabel,.apexcharts-datalabel-label,.apexcharts-datalabel-value,.apexcharts-datalabels,.apexcharts-pie-label {\n cursor: default;\n pointer-events: none\n}\n\n.apexcharts-pie-label-delay {\n opacity: 0;\n animation-name: opaque;\n animation-duration: .3s;\n animation-fill-mode: forwards;\n animation-timing-function: ease\n}\n\n.apexcharts-annotation-rect,.apexcharts-area-series .apexcharts-area,.apexcharts-area-series .apexcharts-series-markers .apexcharts-marker.no-pointer-events,.apexcharts-gridline,.apexcharts-line,.apexcharts-line-series .apexcharts-series-markers .apexcharts-marker.no-pointer-events,.apexcharts-point-annotation-label,.apexcharts-radar-series path,.apexcharts-radar-series polygon,.apexcharts-toolbar svg,.apexcharts-tooltip .apexcharts-marker,.apexcharts-xaxis-annotation-label,.apexcharts-yaxis-annotation-label,.apexcharts-zoom-rect {\n pointer-events: none\n}\n\n.apexcharts-marker {\n transition: .15s ease all\n}\n\n.resize-triggers {\n animation: 1ms resizeanim;\n visibility: hidden;\n opacity: 0;\n height: 100%;\n width: 100%;\n overflow: hidden\n}\n\n.contract-trigger:before,.resize-triggers,.resize-triggers>div {\n content: " ";\n display: block;\n position: absolute;\n top: 0;\n left: 0\n}\n\n.resize-triggers>div {\n height: 100%;\n width: 100%;\n background: #eee;\n overflow: auto\n}\n\n.contract-trigger:before {\n overflow: hidden;\n width: 200%;\n height: 200%\n}\n',r?s.prepend(t.css):o.head.appendChild(t.css))}var l=t.create(t.w.config.series,{});if(!l)return e(t);t.mount(l).then((function(){"function"==typeof t.w.config.chart.events.mounted&&t.w.config.chart.events.mounted(t,t.w),t.events.fireEvent("mounted",[t,t.w]),e(l)})).catch((function(t){i(t)}))}else i(new Error("Element not found"))}))}},{key:"create",value:function(t,e){var i=this.w;new Wt(this).initModules();var a=this.w.globals;if(a.noData=!1,a.animationEnded=!1,this.responsive.checkResponsiveConfig(e),i.config.xaxis.convertedCatToNumeric&&new Y(i.config).convertCatToNumericXaxis(i.config,this.ctx),null===this.el)return a.animationEnded=!0,null;if(this.core.setupElements(),"treemap"===i.config.chart.type&&(i.config.grid.show=!1,i.config.yaxis[0].show=!1),0===a.svgWidth)return a.animationEnded=!0,null;var s=A.checkComboSeries(t);a.comboCharts=s.comboCharts,a.comboBarCount=s.comboBarCount;var r=t.every((function(t){return t.data&&0===t.data.length}));(0===t.length||r)&&this.series.handleNoData(),this.events.setupEventHandlers(),this.data.parseData(t),this.theme.init(),new O(this).setGlobalMarkerSize(),this.formatters.setLabelFormatters(),this.titleSubtitle.draw(),a.noData&&a.collapsedSeries.length!==a.series.length&&!i.config.legend.showForSingleSeries||this.legend.init(),this.series.hasAllSeriesEqualX(),a.axisCharts&&(this.core.coreCalculations(),"category"!==i.config.xaxis.type&&this.formatters.setLabelFormatters(),this.ctx.toolbar.minX=i.globals.minX,this.ctx.toolbar.maxX=i.globals.maxX),this.formatters.heatmapLabelFormatters(),new A(this).getLargestMarkerSize(),this.dimensions.plotCoords();var o=this.core.xySettings();this.grid.createGridMask();var n=this.core.plotChartType(t,o),l=new W(this);l.bringForward(),i.config.dataLabels.background.enabled&&l.dataLabelsBackground(),this.core.shiftGraphPosition();var h={plot:{left:i.globals.translateX,top:i.globals.translateY,width:i.globals.gridWidth,height:i.globals.gridHeight}};return{elGraph:n,xyRatios:o,elInner:i.globals.dom.elGraphical,dimensions:h}}},{key:"mount",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=this,a=i.w;return new Promise((function(s,r){if(null===i.el)return r(new Error("Not enough data to display or target element not found"));(null===e||a.globals.allSeriesCollapsed)&&i.series.handleNoData(),i.grid=new q(i);var o=i.grid.drawGrid();"treemap"!==a.config.chart.type&&i.axes.drawAxis(a.config.chart.type,o),i.annotations=new I(i),i.annotations.drawImageAnnos(),i.annotations.drawTextAnnos(),"back"===a.config.grid.position&&o&&a.globals.dom.elGraphical.add(o.el);var n=new U(t.ctx,o),l=new J(t.ctx,o);if(null!==o&&(n.xAxisLabelCorrections(o.xAxisTickWidth),l.setYAxisTextAlignments(),a.config.yaxis.map((function(t,e){-1===a.globals.ignoreYAxisIndexes.indexOf(e)&&l.yAxisTitleRotate(e,t.opposite)}))),"back"===a.config.annotations.position&&(a.globals.dom.Paper.add(a.globals.dom.elAnnotations),i.annotations.drawAxesAnnotations()),Array.isArray(e.elGraph))for(var h=0;h0&&a.globals.memory.methodsToExec.forEach((function(t){t.method(t.params,!1,t.context)})),a.globals.axisCharts||a.globals.noData||i.core.resizeNonAxisCharts(),s(i)}))}},{key:"destroy",value:function(){var t,e;window.removeEventListener("resize",this.windowResizeHandler),this.el.parentNode,t=this.parentResizeHandler,(e=Gt.get(t))&&(e.disconnect(),Gt.delete(t));var i=this.w.config.chart.id;i&&Apex._chartInstances.forEach((function(t,e){t.id===m.escapeString(i)&&Apex._chartInstances.splice(e,1)})),new Bt(this.ctx).clear({isUpdating:!1})}},{key:"updateOptions",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=this.w;return o.globals.selection=void 0,t.series&&(this.series.resetSeries(!1,!0,!1),t.series.length&&t.series[0].data&&(t.series=t.series.map((function(t,i){return e.updateHelpers._extendSeries(t,i)}))),this.updateHelpers.revertDefaultAxisMinMax()),t.xaxis&&(t=this.updateHelpers.forceXAxisUpdate(t)),t.yaxis&&(t=this.updateHelpers.forceYAxisUpdate(t)),o.globals.collapsedSeriesIndices.length>0&&this.series.clearPreviousPaths(),t.theme&&(t=this.theme.updateThemeOptions(t)),this.updateHelpers._updateOptions(t,i,a,s,r)}},{key:"updateSeries",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return this.series.resetSeries(!1),this.updateHelpers.revertDefaultAxisMinMax(),this.updateHelpers._updateSeries(t,e,i)}},{key:"appendSeries",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=this.w.config.series.slice();return a.push(t),this.series.resetSeries(!1),this.updateHelpers.revertDefaultAxisMinMax(),this.updateHelpers._updateSeries(a,e,i)}},{key:"appendData",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this;i.w.globals.dataChanged=!0,i.series.getPreviousPaths();for(var a=i.w.config.series.slice(),s=0;s0&&void 0!==arguments[0])||arguments[0],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.series.resetSeries(t,e)}},{key:"addEventListener",value:function(t,e){this.events.addEventListener(t,e)}},{key:"removeEventListener",value:function(t,e){this.events.removeEventListener(t,e)}},{key:"addXaxisAnnotation",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=this;i&&(a=i),a.annotations.addXaxisAnnotationExternal(t,e,a)}},{key:"addYaxisAnnotation",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=this;i&&(a=i),a.annotations.addYaxisAnnotationExternal(t,e,a)}},{key:"addPointAnnotation",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=this;i&&(a=i),a.annotations.addPointAnnotationExternal(t,e,a)}},{key:"clearAnnotations",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,e=this;t&&(e=t),e.annotations.clearAnnotations(e)}},{key:"removeAnnotation",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=this;e&&(i=e),i.annotations.removeAnnotation(i,t)}},{key:"getChartArea",value:function(){return this.w.globals.dom.baseEl.querySelector(".apexcharts-inner")}},{key:"getSeriesTotalXRange",value:function(t,e){return this.coreUtils.getSeriesTotalsXRange(t,e)}},{key:"getHighestValueInSeries",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=new $(this.ctx);return e.getMinYMaxY(t).highestY}},{key:"getLowestValueInSeries",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=new $(this.ctx);return e.getMinYMaxY(t).lowestY}},{key:"getSeriesTotal",value:function(){return this.w.globals.seriesTotals}},{key:"toggleDataPointSelection",value:function(t,e){return this.updateHelpers.toggleDataPointSelection(t,e)}},{key:"zoomX",value:function(t,e){this.ctx.toolbar.zoomUpdateOptions(t,e)}},{key:"setLocale",value:function(t){this.localization.setCurrentLocaleValues(t)}},{key:"dataURI",value:function(t){return new _(this.ctx).dataURI(t)}},{key:"exportToCSV",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=new _(this.ctx);return e.exportToCSV(t)}},{key:"paper",value:function(){return this.w.globals.dom.Paper}},{key:"_parentResizeCallback",value:function(){this.w.globals.animationEnded&&this.w.config.chart.redrawOnParentResize&&this._windowResize()}},{key:"_windowResize",value:function(){var t=this;clearTimeout(this.w.globals.resizeTimer),this.w.globals.resizeTimer=window.setTimeout((function(){t.w.globals.resized=!0,t.w.globals.dataChanged=!1,t.ctx.update()}),150)}},{key:"_windowResizeHandler",value:function(){var t=this.w.config.chart.redrawOnWindowResize;"function"==typeof t&&(t=t()),t&&this._windowResize()}}],[{key:"getChartByID",value:function(t){var e=m.escapeString(t),i=Apex._chartInstances.filter((function(t){return t.id===e}))[0];return i&&i.chart}},{key:"initOnLoad",value:function(){for(var e=document.querySelectorAll("[data-apexcharts]"),i=0;i2?s-2:0),o=2;or.maxX-e.width&&(o=(a=r.maxX-e.width)-this.startPoints.box.x),null!=r.minY&&sr.maxY-e.height&&(n=(s=r.maxY-e.height)-this.startPoints.box.y),null!=r.snapToGrid&&(a-=a%r.snapToGrid,s-=s%r.snapToGrid,o-=o%r.snapToGrid,n-=n%r.snapToGrid),this.el instanceof SVG.G?this.el.matrix(this.startPoints.transform).transform({x:o,y:n},!0):this.el.move(a,s));return i},t.prototype.end=function(t){var e=this.drag(t);this.el.fire("dragend",{event:t,p:e,m:this.m,handler:this}),SVG.off(window,"mousemove.drag"),SVG.off(window,"touchmove.drag"),SVG.off(window,"mouseup.drag"),SVG.off(window,"touchend.drag")},SVG.extend(SVG.Element,{draggable:function(e,i){"function"!=typeof e&&"object"!=typeof e||(i=e,e=!0);var a=this.remember("_draggable")||new t(this);return(e=void 0===e||e)?a.init(i||{},e):(this.off("mousedown.drag"),this.off("touchstart.drag")),this}})}.call(void 0),function(){function t(t){this.el=t,t.remember("_selectHandler",this),this.pointSelection={isSelected:!1},this.rectSelection={isSelected:!1},this.pointsList={lt:[0,0],rt:["width",0],rb:["width","height"],lb:[0,"height"],t:["width",0],r:["width","height"],b:["width","height"],l:[0,"height"]},this.pointCoord=function(t,e,i){var a="string"!=typeof t?t:e[t];return i?a/2:a},this.pointCoords=function(t,e){var i=this.pointsList[t];return{x:this.pointCoord(i[0],e,"t"===t||"b"===t),y:this.pointCoord(i[1],e,"r"===t||"l"===t)}}}t.prototype.init=function(t,e){var i=this.el.bbox();this.options={};var a=this.el.selectize.defaults.points;for(var s in this.el.selectize.defaults)this.options[s]=this.el.selectize.defaults[s],void 0!==e[s]&&(this.options[s]=e[s]);var r=["points","pointsExclude"];for(var s in r){var o=this.options[r[s]];"string"==typeof o?o=o.length>0?o.split(/\s*,\s*/i):[]:"boolean"==typeof o&&"points"===r[s]&&(o=o?a:[]),this.options[r[s]]=o}this.options.points=[a,this.options.points].reduce((function(t,e){return t.filter((function(t){return e.indexOf(t)>-1}))})),this.options.points=[this.options.points,this.options.pointsExclude].reduce((function(t,e){return t.filter((function(t){return e.indexOf(t)<0}))})),this.parent=this.el.parent(),this.nested=this.nested||this.parent.group(),this.nested.matrix(new SVG.Matrix(this.el).translate(i.x,i.y)),this.options.deepSelect&&-1!==["line","polyline","polygon"].indexOf(this.el.type)?this.selectPoints(t):this.selectRect(t),this.observe(),this.cleanup()},t.prototype.selectPoints=function(t){return this.pointSelection.isSelected=t,this.pointSelection.set||(this.pointSelection.set=this.parent.set(),this.drawPoints()),this},t.prototype.getPointArray=function(){var t=this.el.bbox();return this.el.array().valueOf().map((function(e){return[e[0]-t.x,e[1]-t.y]}))},t.prototype.drawPoints=function(){for(var t=this,e=this.getPointArray(),i=0,a=e.length;i0&&this.parameters.box.height-i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x+i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize-i[0]);i=this.checkAspectRatio(i),this.el.move(this.parameters.box.x+i[0],this.parameters.box.y+i[1]).size(this.parameters.box.width-i[0],this.parameters.box.height-i[1])}};break;case"rt":this.calc=function(t,e){var i=this.snapToGrid(t,e,2);if(this.parameters.box.width+i[0]>0&&this.parameters.box.height-i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x-i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize+i[0]);i=this.checkAspectRatio(i,!0),this.el.move(this.parameters.box.x,this.parameters.box.y+i[1]).size(this.parameters.box.width+i[0],this.parameters.box.height-i[1])}};break;case"rb":this.calc=function(t,e){var i=this.snapToGrid(t,e,0);if(this.parameters.box.width+i[0]>0&&this.parameters.box.height+i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x-i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize+i[0]);i=this.checkAspectRatio(i),this.el.move(this.parameters.box.x,this.parameters.box.y).size(this.parameters.box.width+i[0],this.parameters.box.height+i[1])}};break;case"lb":this.calc=function(t,e){var i=this.snapToGrid(t,e,1);if(this.parameters.box.width-i[0]>0&&this.parameters.box.height+i[1]>0){if("text"===this.parameters.type)return this.el.move(this.parameters.box.x+i[0],this.parameters.box.y),void this.el.attr("font-size",this.parameters.fontSize-i[0]);i=this.checkAspectRatio(i,!0),this.el.move(this.parameters.box.x+i[0],this.parameters.box.y).size(this.parameters.box.width-i[0],this.parameters.box.height+i[1])}};break;case"t":this.calc=function(t,e){var i=this.snapToGrid(t,e,2);if(this.parameters.box.height-i[1]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y+i[1]).height(this.parameters.box.height-i[1])}};break;case"r":this.calc=function(t,e){var i=this.snapToGrid(t,e,0);if(this.parameters.box.width+i[0]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y).width(this.parameters.box.width+i[0])}};break;case"b":this.calc=function(t,e){var i=this.snapToGrid(t,e,0);if(this.parameters.box.height+i[1]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x,this.parameters.box.y).height(this.parameters.box.height+i[1])}};break;case"l":this.calc=function(t,e){var i=this.snapToGrid(t,e,1);if(this.parameters.box.width-i[0]>0){if("text"===this.parameters.type)return;this.el.move(this.parameters.box.x+i[0],this.parameters.box.y).width(this.parameters.box.width-i[0])}};break;case"rot":this.calc=function(t,e){var i=t+this.parameters.p.x,a=e+this.parameters.p.y,s=Math.atan2(this.parameters.p.y-this.parameters.box.y-this.parameters.box.height/2,this.parameters.p.x-this.parameters.box.x-this.parameters.box.width/2),r=Math.atan2(a-this.parameters.box.y-this.parameters.box.height/2,i-this.parameters.box.x-this.parameters.box.width/2),o=this.parameters.rotation+180*(r-s)/Math.PI+this.options.snapToAngle/2;this.el.center(this.parameters.box.cx,this.parameters.box.cy).rotate(o-o%this.options.snapToAngle,this.parameters.box.cx,this.parameters.box.cy)};break;case"point":this.calc=function(t,e){var i=this.snapToGrid(t,e,this.parameters.pointCoords[0],this.parameters.pointCoords[1]),a=this.el.array().valueOf();a[this.parameters.i][0]=this.parameters.pointCoords[0]+i[0],a[this.parameters.i][1]=this.parameters.pointCoords[1]+i[1],this.el.plot(a)}}this.el.fire("resizestart",{dx:this.parameters.x,dy:this.parameters.y,event:t}),SVG.on(window,"touchmove.resize",(function(t){e.update(t||window.event)})),SVG.on(window,"touchend.resize",(function(){e.done()})),SVG.on(window,"mousemove.resize",(function(t){e.update(t||window.event)})),SVG.on(window,"mouseup.resize",(function(){e.done()}))},t.prototype.update=function(t){if(t){var e=this._extractPosition(t),i=this.transformPoint(e.x,e.y),a=i.x-this.parameters.p.x,s=i.y-this.parameters.p.y;this.lastUpdateCall=[a,s],this.calc(a,s),this.el.fire("resizing",{dx:a,dy:s,event:t})}else this.lastUpdateCall&&this.calc(this.lastUpdateCall[0],this.lastUpdateCall[1])},t.prototype.done=function(){this.lastUpdateCall=null,SVG.off(window,"mousemove.resize"),SVG.off(window,"mouseup.resize"),SVG.off(window,"touchmove.resize"),SVG.off(window,"touchend.resize"),this.el.fire("resizedone")},t.prototype.snapToGrid=function(t,e,i,a){var s;return void 0!==a?s=[(i+t)%this.options.snapToGrid,(a+e)%this.options.snapToGrid]:(i=null==i?3:i,s=[(this.parameters.box.x+t+(1&i?0:this.parameters.box.width))%this.options.snapToGrid,(this.parameters.box.y+e+(2&i?0:this.parameters.box.height))%this.options.snapToGrid]),t<0&&(s[0]-=this.options.snapToGrid),e<0&&(s[1]-=this.options.snapToGrid),t-=Math.abs(s[0])o.maxX&&(t=o.maxX-s),void 0!==o.minY&&r+eo.maxY&&(e=o.maxY-r),[t,e]},t.prototype.checkAspectRatio=function(t,e){if(!this.options.saveAspectRatio)return t;var i=t.slice(),a=this.parameters.box.width/this.parameters.box.height,s=this.parameters.box.width+t[0],r=this.parameters.box.height-t[1],o=s/r;return oa&&(i[0]=this.parameters.box.width-r*a,e&&(i[0]=-i[0])),i},SVG.extend(SVG.Element,{resize:function(e){return(this.remember("_resizeHandler")||new t(this)).init(e||{}),this}}),SVG.Element.prototype.resize.defaults={snapToAngle:.1,snapToGrid:1,constraint:{},saveAspectRatio:!1}}).call(this)}(),void 0===window.Apex&&(window.Apex={});var jt=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"initModules",value:function(){this.ctx.publicMethods=["updateOptions","updateSeries","appendData","appendSeries","toggleSeries","showSeries","hideSeries","setLocale","resetSeries","zoomX","toggleDataPointSelection","dataURI","exportToCSV","addXaxisAnnotation","addYaxisAnnotation","addPointAnnotation","clearAnnotations","removeAnnotation","paper","destroy"],this.ctx.eventList=["click","mousedown","mousemove","mouseleave","touchstart","touchmove","touchleave","mouseup","touchend"],this.ctx.animations=new w(this.ctx),this.ctx.axes=new et(this.ctx),this.ctx.core=new Gt(this.ctx.el,this.ctx),this.ctx.config=new O({}),this.ctx.data=new j(this.ctx),this.ctx.grid=new Z(this.ctx),this.ctx.graphics=new A(this.ctx),this.ctx.coreUtils=new S(this.ctx),this.ctx.crosshairs=new it(this.ctx),this.ctx.events=new K(this.ctx),this.ctx.exports=new U(this.ctx),this.ctx.localization=new tt(this.ctx),this.ctx.options=new M,this.ctx.responsive=new at(this.ctx),this.ctx.series=new V(this.ctx),this.ctx.theme=new st(this.ctx),this.ctx.formatters=new E(this.ctx),this.ctx.titleSubtitle=new rt(this.ctx),this.ctx.legend=new gt(this.ctx),this.ctx.toolbar=new ut(this.ctx),this.ctx.tooltip=new wt(this.ctx),this.ctx.dimensions=new ct(this.ctx),this.ctx.updateHelpers=new Vt(this.ctx),this.ctx.zoomPanSelection=new pt(this.ctx),this.ctx.w.globals.tooltip=new wt(this.ctx)}}]),t}(),_t=function(){function t(e){n(this,t),this.ctx=e,this.w=e.w}return h(t,[{key:"clear",value:function(t){var e=t.isUpdating;this.ctx.zoomPanSelection&&this.ctx.zoomPanSelection.destroy(),this.ctx.toolbar&&this.ctx.toolbar.destroy(),this.ctx.animations=null,this.ctx.axes=null,this.ctx.annotations=null,this.ctx.core=null,this.ctx.data=null,this.ctx.grid=null,this.ctx.series=null,this.ctx.responsive=null,this.ctx.theme=null,this.ctx.formatters=null,this.ctx.titleSubtitle=null,this.ctx.legend=null,this.ctx.dimensions=null,this.ctx.options=null,this.ctx.crosshairs=null,this.ctx.zoomPanSelection=null,this.ctx.updateHelpers=null,this.ctx.toolbar=null,this.ctx.localization=null,this.ctx.w.globals.tooltip=null,this.clearDomElements({isUpdating:e})}},{key:"killSVG",value:function(t){t.each((function(t,e){this.removeClass("*"),this.off(),this.stop()}),!0),t.ungroup(),t.clear()}},{key:"clearDomElements",value:function(t){var e=this,i=t.isUpdating,a=this.w.globals.dom.Paper.node;a.parentNode&&a.parentNode.parentNode&&!i&&(a.parentNode.parentNode.style.minHeight="unset");var s=this.w.globals.dom.baseEl;s&&this.ctx.eventList.forEach((function(t){s.removeEventListener(t,e.ctx.events.documentEvent)}));var r=this.w.globals.dom;if(null!==this.ctx.el)for(;this.ctx.el.firstChild;)this.ctx.el.removeChild(this.ctx.el.firstChild);this.killSVG(r.Paper),r.Paper.remove(),r.elWrap=null,r.elGraphical=null,r.elLegendWrap=null,r.elLegendForeign=null,r.baseEl=null,r.elGridRect=null,r.elGridRectMask=null,r.elGridRectMarkerMask=null,r.elForecastMask=null,r.elNonForecastMask=null,r.elDefs=null}}]),t}(),Ut=new WeakMap,qt=function(){function t(e,i){n(this,t),this.opts=i,this.ctx=this,this.w=new D(i).init(),this.el=e,this.w.globals.cuid=y.randomId(),this.w.globals.chartID=this.w.config.chart.id?y.escapeString(this.w.config.chart.id):this.w.globals.cuid,new jt(this).initModules(),this.create=y.bind(this.create,this),this.windowResizeHandler=this._windowResizeHandler.bind(this),this.parentResizeHandler=this._parentResizeCallback.bind(this)}return h(t,[{key:"render",value:function(){var t=this;return new Promise((function(e,i){if(null!==t.el){void 0===Apex._chartInstances&&(Apex._chartInstances=[]),t.w.config.chart.id&&Apex._chartInstances.push({id:t.w.globals.chartID,group:t.w.config.chart.group,chart:t}),t.setLocale(t.w.config.chart.defaultLocale);var a=t.w.config.chart.events.beforeMount;if("function"==typeof a&&a(t,t.w),t.events.fireEvent("beforeMount",[t,t.w]),window.addEventListener("resize",t.windowResizeHandler),function(t,e){var i=!1;if(t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE){var a=t.getBoundingClientRect();"none"!==t.style.display&&0!==a.width||(i=!0)}var s=new ResizeObserver((function(a){i&&e.call(t,a),i=!0}));t.nodeType===Node.DOCUMENT_FRAGMENT_NODE?Array.from(t.children).forEach((function(t){return s.observe(t)})):s.observe(t),Ut.set(e,s)}(t.el.parentNode,t.parentResizeHandler),!t.css){var s=t.el.getRootNode&&t.el.getRootNode(),r=y.is("ShadowRoot",s),o=t.el.ownerDocument,n=o.getElementById("apexcharts-css");!r&&n||(t.css=document.createElement("style"),t.css.id="apexcharts-css",t.css.textContent='@keyframes opaque {\n 0% {\n opacity: 0\n }\n\n to {\n opacity: 1\n }\n}\n\n@keyframes resizeanim {\n 0%,to {\n opacity: 0\n }\n}\n\n.apexcharts-canvas {\n position: relative;\n user-select: none\n}\n\n.apexcharts-canvas ::-webkit-scrollbar {\n -webkit-appearance: none;\n width: 6px\n}\n\n.apexcharts-canvas ::-webkit-scrollbar-thumb {\n border-radius: 4px;\n background-color: rgba(0,0,0,.5);\n box-shadow: 0 0 1px rgba(255,255,255,.5);\n -webkit-box-shadow: 0 0 1px rgba(255,255,255,.5)\n}\n\n.apexcharts-inner {\n position: relative\n}\n\n.apexcharts-text tspan {\n font-family: inherit\n}\n\n.legend-mouseover-inactive {\n transition: .15s ease all;\n opacity: .2\n}\n\n.apexcharts-legend-text {\n padding-left: 15px;\n margin-left: -15px;\n}\n\n.apexcharts-series-collapsed {\n opacity: 0\n}\n\n.apexcharts-tooltip {\n border-radius: 5px;\n box-shadow: 2px 2px 6px -4px #999;\n cursor: default;\n font-size: 14px;\n left: 62px;\n opacity: 0;\n pointer-events: none;\n position: absolute;\n top: 20px;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n white-space: nowrap;\n z-index: 12;\n transition: .15s ease all\n}\n\n.apexcharts-tooltip.apexcharts-active {\n opacity: 1;\n transition: .15s ease all\n}\n\n.apexcharts-tooltip.apexcharts-theme-light {\n border: 1px solid #e3e3e3;\n background: rgba(255,255,255,.96)\n}\n\n.apexcharts-tooltip.apexcharts-theme-dark {\n color: #fff;\n background: rgba(30,30,30,.8)\n}\n\n.apexcharts-tooltip * {\n font-family: inherit\n}\n\n.apexcharts-tooltip-title {\n padding: 6px;\n font-size: 15px;\n margin-bottom: 4px\n}\n\n.apexcharts-tooltip.apexcharts-theme-light .apexcharts-tooltip-title {\n background: #eceff1;\n border-bottom: 1px solid #ddd\n}\n\n.apexcharts-tooltip.apexcharts-theme-dark .apexcharts-tooltip-title {\n background: rgba(0,0,0,.7);\n border-bottom: 1px solid #333\n}\n\n.apexcharts-tooltip-text-goals-value,.apexcharts-tooltip-text-y-value,.apexcharts-tooltip-text-z-value {\n display: inline-block;\n margin-left: 5px;\n font-weight: 600\n}\n\n.apexcharts-tooltip-text-goals-label:empty,.apexcharts-tooltip-text-goals-value:empty,.apexcharts-tooltip-text-y-label:empty,.apexcharts-tooltip-text-y-value:empty,.apexcharts-tooltip-text-z-value:empty,.apexcharts-tooltip-title:empty {\n display: none\n}\n\n.apexcharts-tooltip-text-goals-label,.apexcharts-tooltip-text-goals-value {\n padding: 6px 0 5px\n}\n\n.apexcharts-tooltip-goals-group,.apexcharts-tooltip-text-goals-label,.apexcharts-tooltip-text-goals-value {\n display: flex\n}\n\n.apexcharts-tooltip-text-goals-label:not(:empty),.apexcharts-tooltip-text-goals-value:not(:empty) {\n margin-top: -6px\n}\n\n.apexcharts-tooltip-marker {\n width: 12px;\n height: 12px;\n position: relative;\n top: 0;\n margin-right: 10px;\n border-radius: 50%\n}\n\n.apexcharts-tooltip-series-group {\n padding: 0 10px;\n display: none;\n text-align: left;\n justify-content: left;\n align-items: center\n}\n\n.apexcharts-tooltip-series-group.apexcharts-active .apexcharts-tooltip-marker {\n opacity: 1\n}\n\n.apexcharts-tooltip-series-group.apexcharts-active,.apexcharts-tooltip-series-group:last-child {\n padding-bottom: 4px\n}\n\n.apexcharts-tooltip-series-group-hidden {\n opacity: 0;\n height: 0;\n line-height: 0;\n padding: 0!important\n}\n\n.apexcharts-tooltip-y-group {\n padding: 6px 0 5px\n}\n\n.apexcharts-custom-tooltip,.apexcharts-tooltip-box {\n padding: 4px 8px\n}\n\n.apexcharts-tooltip-boxPlot {\n display: flex;\n flex-direction: column-reverse\n}\n\n.apexcharts-tooltip-box>div {\n margin: 4px 0\n}\n\n.apexcharts-tooltip-box span.value {\n font-weight: 700\n}\n\n.apexcharts-tooltip-rangebar {\n padding: 5px 8px\n}\n\n.apexcharts-tooltip-rangebar .category {\n font-weight: 600;\n color: #777\n}\n\n.apexcharts-tooltip-rangebar .series-name {\n font-weight: 700;\n display: block;\n margin-bottom: 5px\n}\n\n.apexcharts-xaxistooltip,.apexcharts-yaxistooltip {\n opacity: 0;\n pointer-events: none;\n color: #373d3f;\n font-size: 13px;\n text-align: center;\n border-radius: 2px;\n position: absolute;\n z-index: 10;\n background: #eceff1;\n border: 1px solid #90a4ae\n}\n\n.apexcharts-xaxistooltip {\n padding: 9px 10px;\n transition: .15s ease all\n}\n\n.apexcharts-xaxistooltip.apexcharts-theme-dark {\n background: rgba(0,0,0,.7);\n border: 1px solid rgba(0,0,0,.5);\n color: #fff\n}\n\n.apexcharts-xaxistooltip:after,.apexcharts-xaxistooltip:before {\n left: 50%;\n border: solid transparent;\n content: " ";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none\n}\n\n.apexcharts-xaxistooltip:after {\n border-color: transparent;\n border-width: 6px;\n margin-left: -6px\n}\n\n.apexcharts-xaxistooltip:before {\n border-color: transparent;\n border-width: 7px;\n margin-left: -7px\n}\n\n.apexcharts-xaxistooltip-bottom:after,.apexcharts-xaxistooltip-bottom:before {\n bottom: 100%\n}\n\n.apexcharts-xaxistooltip-top:after,.apexcharts-xaxistooltip-top:before {\n top: 100%\n}\n\n.apexcharts-xaxistooltip-bottom:after {\n border-bottom-color: #eceff1\n}\n\n.apexcharts-xaxistooltip-bottom:before {\n border-bottom-color: #90a4ae\n}\n\n.apexcharts-xaxistooltip-bottom.apexcharts-theme-dark:after,.apexcharts-xaxistooltip-bottom.apexcharts-theme-dark:before {\n border-bottom-color: rgba(0,0,0,.5)\n}\n\n.apexcharts-xaxistooltip-top:after {\n border-top-color: #eceff1\n}\n\n.apexcharts-xaxistooltip-top:before {\n border-top-color: #90a4ae\n}\n\n.apexcharts-xaxistooltip-top.apexcharts-theme-dark:after,.apexcharts-xaxistooltip-top.apexcharts-theme-dark:before {\n border-top-color: rgba(0,0,0,.5)\n}\n\n.apexcharts-xaxistooltip.apexcharts-active {\n opacity: 1;\n transition: .15s ease all\n}\n\n.apexcharts-yaxistooltip {\n padding: 4px 10px\n}\n\n.apexcharts-yaxistooltip.apexcharts-theme-dark {\n background: rgba(0,0,0,.7);\n border: 1px solid rgba(0,0,0,.5);\n color: #fff\n}\n\n.apexcharts-yaxistooltip:after,.apexcharts-yaxistooltip:before {\n top: 50%;\n border: solid transparent;\n content: " ";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none\n}\n\n.apexcharts-yaxistooltip:after {\n border-color: transparent;\n border-width: 6px;\n margin-top: -6px\n}\n\n.apexcharts-yaxistooltip:before {\n border-color: transparent;\n border-width: 7px;\n margin-top: -7px\n}\n\n.apexcharts-yaxistooltip-left:after,.apexcharts-yaxistooltip-left:before {\n left: 100%\n}\n\n.apexcharts-yaxistooltip-right:after,.apexcharts-yaxistooltip-right:before {\n right: 100%\n}\n\n.apexcharts-yaxistooltip-left:after {\n border-left-color: #eceff1\n}\n\n.apexcharts-yaxistooltip-left:before {\n border-left-color: #90a4ae\n}\n\n.apexcharts-yaxistooltip-left.apexcharts-theme-dark:after,.apexcharts-yaxistooltip-left.apexcharts-theme-dark:before {\n border-left-color: rgba(0,0,0,.5)\n}\n\n.apexcharts-yaxistooltip-right:after {\n border-right-color: #eceff1\n}\n\n.apexcharts-yaxistooltip-right:before {\n border-right-color: #90a4ae\n}\n\n.apexcharts-yaxistooltip-right.apexcharts-theme-dark:after,.apexcharts-yaxistooltip-right.apexcharts-theme-dark:before {\n border-right-color: rgba(0,0,0,.5)\n}\n\n.apexcharts-yaxistooltip.apexcharts-active {\n opacity: 1\n}\n\n.apexcharts-yaxistooltip-hidden {\n display: none\n}\n\n.apexcharts-xcrosshairs,.apexcharts-ycrosshairs {\n pointer-events: none;\n opacity: 0;\n transition: .15s ease all\n}\n\n.apexcharts-xcrosshairs.apexcharts-active,.apexcharts-ycrosshairs.apexcharts-active {\n opacity: 1;\n transition: .15s ease all\n}\n\n.apexcharts-ycrosshairs-hidden {\n opacity: 0\n}\n\n.apexcharts-selection-rect {\n cursor: move\n}\n\n.svg_select_boundingRect,.svg_select_points_rot {\n pointer-events: none;\n opacity: 0;\n visibility: hidden\n}\n\n.apexcharts-selection-rect+g .svg_select_boundingRect,.apexcharts-selection-rect+g .svg_select_points_rot {\n opacity: 0;\n visibility: hidden\n}\n\n.apexcharts-selection-rect+g .svg_select_points_l,.apexcharts-selection-rect+g .svg_select_points_r {\n cursor: ew-resize;\n opacity: 1;\n visibility: visible\n}\n\n.svg_select_points {\n fill: #efefef;\n stroke: #333;\n rx: 2\n}\n\n.apexcharts-svg.apexcharts-zoomable.hovering-zoom {\n cursor: crosshair\n}\n\n.apexcharts-svg.apexcharts-zoomable.hovering-pan {\n cursor: move\n}\n\n.apexcharts-menu-icon,.apexcharts-pan-icon,.apexcharts-reset-icon,.apexcharts-selection-icon,.apexcharts-toolbar-custom-icon,.apexcharts-zoom-icon,.apexcharts-zoomin-icon,.apexcharts-zoomout-icon {\n cursor: pointer;\n width: 20px;\n height: 20px;\n line-height: 24px;\n color: #6e8192;\n text-align: center\n}\n\n.apexcharts-menu-icon svg,.apexcharts-reset-icon svg,.apexcharts-zoom-icon svg,.apexcharts-zoomin-icon svg,.apexcharts-zoomout-icon svg {\n fill: #6e8192\n}\n\n.apexcharts-selection-icon svg {\n fill: #444;\n transform: scale(.76)\n}\n\n.apexcharts-theme-dark .apexcharts-menu-icon svg,.apexcharts-theme-dark .apexcharts-pan-icon svg,.apexcharts-theme-dark .apexcharts-reset-icon svg,.apexcharts-theme-dark .apexcharts-selection-icon svg,.apexcharts-theme-dark .apexcharts-toolbar-custom-icon svg,.apexcharts-theme-dark .apexcharts-zoom-icon svg,.apexcharts-theme-dark .apexcharts-zoomin-icon svg,.apexcharts-theme-dark .apexcharts-zoomout-icon svg {\n fill: #f3f4f5\n}\n\n.apexcharts-canvas .apexcharts-reset-zoom-icon.apexcharts-selected svg,.apexcharts-canvas .apexcharts-selection-icon.apexcharts-selected svg,.apexcharts-canvas .apexcharts-zoom-icon.apexcharts-selected svg {\n fill: #008ffb\n}\n\n.apexcharts-theme-light .apexcharts-menu-icon:hover svg,.apexcharts-theme-light .apexcharts-reset-icon:hover svg,.apexcharts-theme-light .apexcharts-selection-icon:not(.apexcharts-selected):hover svg,.apexcharts-theme-light .apexcharts-zoom-icon:not(.apexcharts-selected):hover svg,.apexcharts-theme-light .apexcharts-zoomin-icon:hover svg,.apexcharts-theme-light .apexcharts-zoomout-icon:hover svg {\n fill: #333\n}\n\n.apexcharts-menu-icon,.apexcharts-selection-icon {\n position: relative\n}\n\n.apexcharts-reset-icon {\n margin-left: 5px\n}\n\n.apexcharts-menu-icon,.apexcharts-reset-icon,.apexcharts-zoom-icon {\n transform: scale(.85)\n}\n\n.apexcharts-zoomin-icon,.apexcharts-zoomout-icon {\n transform: scale(.7)\n}\n\n.apexcharts-zoomout-icon {\n margin-right: 3px\n}\n\n.apexcharts-pan-icon {\n transform: scale(.62);\n position: relative;\n left: 1px;\n top: 0\n}\n\n.apexcharts-pan-icon svg {\n fill: #fff;\n stroke: #6e8192;\n stroke-width: 2\n}\n\n.apexcharts-pan-icon.apexcharts-selected svg {\n stroke: #008ffb\n}\n\n.apexcharts-pan-icon:not(.apexcharts-selected):hover svg {\n stroke: #333\n}\n\n.apexcharts-toolbar {\n position: absolute;\n z-index: 11;\n max-width: 176px;\n text-align: right;\n border-radius: 3px;\n padding: 0 6px 2px;\n display: flex;\n justify-content: space-between;\n align-items: center\n}\n\n.apexcharts-menu {\n background: #fff;\n position: absolute;\n top: 100%;\n border: 1px solid #ddd;\n border-radius: 3px;\n padding: 3px;\n right: 10px;\n opacity: 0;\n min-width: 110px;\n transition: .15s ease all;\n pointer-events: none\n}\n\n.apexcharts-menu.apexcharts-menu-open {\n opacity: 1;\n pointer-events: all;\n transition: .15s ease all\n}\n\n.apexcharts-menu-item {\n padding: 6px 7px;\n font-size: 12px;\n cursor: pointer\n}\n\n.apexcharts-theme-light .apexcharts-menu-item:hover {\n background: #eee\n}\n\n.apexcharts-theme-dark .apexcharts-menu {\n background: rgba(0,0,0,.7);\n color: #fff\n}\n\n@media screen and (min-width:768px) {\n .apexcharts-canvas:hover .apexcharts-toolbar {\n opacity: 1\n }\n}\n\n.apexcharts-canvas .apexcharts-element-hidden,.apexcharts-datalabel.apexcharts-element-hidden,.apexcharts-hide .apexcharts-series-points {\n opacity: 0\n}\n\n.apexcharts-hidden-element-shown {\n opacity: 1;\n transition: 0.25s ease all;\n}\n.apexcharts-datalabel,.apexcharts-datalabel-label,.apexcharts-datalabel-value,.apexcharts-datalabels,.apexcharts-pie-label {\n cursor: default;\n pointer-events: none\n}\n\n.apexcharts-pie-label-delay {\n opacity: 0;\n animation-name: opaque;\n animation-duration: .3s;\n animation-fill-mode: forwards;\n animation-timing-function: ease\n}\n\n.apexcharts-annotation-rect,.apexcharts-area-series .apexcharts-area,.apexcharts-area-series .apexcharts-series-markers .apexcharts-marker.no-pointer-events,.apexcharts-gridline,.apexcharts-line,.apexcharts-line-series .apexcharts-series-markers .apexcharts-marker.no-pointer-events,.apexcharts-point-annotation-label,.apexcharts-radar-series path,.apexcharts-radar-series polygon,.apexcharts-toolbar svg,.apexcharts-tooltip .apexcharts-marker,.apexcharts-xaxis-annotation-label,.apexcharts-yaxis-annotation-label,.apexcharts-zoom-rect {\n pointer-events: none\n}\n\n.apexcharts-marker {\n transition: .15s ease all\n}\n\n.resize-triggers {\n animation: 1ms resizeanim;\n visibility: hidden;\n opacity: 0;\n height: 100%;\n width: 100%;\n overflow: hidden\n}\n\n.contract-trigger:before,.resize-triggers,.resize-triggers>div {\n content: " ";\n display: block;\n position: absolute;\n top: 0;\n left: 0\n}\n\n.resize-triggers>div {\n height: 100%;\n width: 100%;\n background: #eee;\n overflow: auto\n}\n\n.contract-trigger:before {\n overflow: hidden;\n width: 200%;\n height: 200%\n}\n\n.apexcharts-bar-goals-markers{\n pointer-events: none\n}\n\n.apexcharts-bar-shadows{\n pointer-events: none\n}\n\n.apexcharts-rangebar-goals-markers{\n pointer-events: none\n}',r?s.prepend(t.css):o.head.appendChild(t.css))}var l=t.create(t.w.config.series,{});if(!l)return e(t);t.mount(l).then((function(){"function"==typeof t.w.config.chart.events.mounted&&t.w.config.chart.events.mounted(t,t.w),t.events.fireEvent("mounted",[t,t.w]),e(l)})).catch((function(t){i(t)}))}else i(new Error("Element not found"))}))}},{key:"create",value:function(t,e){var i=this.w;new jt(this).initModules();var a=this.w.globals;if(a.noData=!1,a.animationEnded=!1,this.responsive.checkResponsiveConfig(e),i.config.xaxis.convertedCatToNumeric&&new R(i.config).convertCatToNumericXaxis(i.config,this.ctx),null===this.el)return a.animationEnded=!0,null;if(this.core.setupElements(),"treemap"===i.config.chart.type&&(i.config.grid.show=!1,i.config.yaxis[0].show=!1),0===a.svgWidth)return a.animationEnded=!0,null;var s=S.checkComboSeries(t);a.comboCharts=s.comboCharts,a.comboBarCount=s.comboBarCount;var r=t.every((function(t){return t.data&&0===t.data.length}));(0===t.length||r)&&this.series.handleNoData(),this.events.setupEventHandlers(),this.data.parseData(t),this.theme.init(),new W(this).setGlobalMarkerSize(),this.formatters.setLabelFormatters(),this.titleSubtitle.draw(),a.noData&&a.collapsedSeries.length!==a.series.length&&!i.config.legend.showForSingleSeries||this.legend.init(),this.series.hasAllSeriesEqualX(),a.axisCharts&&(this.core.coreCalculations(),"category"!==i.config.xaxis.type&&this.formatters.setLabelFormatters(),this.ctx.toolbar.minX=i.globals.minX,this.ctx.toolbar.maxX=i.globals.maxX),this.formatters.heatmapLabelFormatters(),new S(this).getLargestMarkerSize(),this.dimensions.plotCoords();var o=this.core.xySettings();this.grid.createGridMask();var n=this.core.plotChartType(t,o),l=new G(this);return l.bringForward(),i.config.dataLabels.background.enabled&&l.dataLabelsBackground(),this.core.shiftGraphPosition(),{elGraph:n,xyRatios:o,dimensions:{plot:{left:i.globals.translateX,top:i.globals.translateY,width:i.globals.gridWidth,height:i.globals.gridHeight}}}}},{key:"mount",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=this,a=i.w;return new Promise((function(s,r){if(null===i.el)return r(new Error("Not enough data to display or target element not found"));(null===e||a.globals.allSeriesCollapsed)&&i.series.handleNoData(),i.grid=new Z(i);var o,n,l=i.grid.drawGrid();if(i.annotations=new X(i),i.annotations.drawImageAnnos(),i.annotations.drawTextAnnos(),"back"===a.config.grid.position&&(l&&a.globals.dom.elGraphical.add(l.el),null!=l&&null!==(o=l.elGridBorders)&&void 0!==o&&o.node&&a.globals.dom.elGraphical.add(l.elGridBorders)),Array.isArray(e.elGraph))for(var h=0;h0&&a.globals.memory.methodsToExec.forEach((function(t){t.method(t.params,!1,t.context)})),a.globals.axisCharts||a.globals.noData||i.core.resizeNonAxisCharts(),s(i)}))}},{key:"destroy",value:function(){var t,e;window.removeEventListener("resize",this.windowResizeHandler),this.el.parentNode,t=this.parentResizeHandler,(e=Ut.get(t))&&(e.disconnect(),Ut.delete(t));var i=this.w.config.chart.id;i&&Apex._chartInstances.forEach((function(t,e){t.id===y.escapeString(i)&&Apex._chartInstances.splice(e,1)})),new _t(this.ctx).clear({isUpdating:!1})}},{key:"updateOptions",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=this.w;return o.globals.selection=void 0,t.series&&(this.series.resetSeries(!1,!0,!1),t.series.length&&t.series[0].data&&(t.series=t.series.map((function(t,i){return e.updateHelpers._extendSeries(t,i)}))),this.updateHelpers.revertDefaultAxisMinMax()),t.xaxis&&(t=this.updateHelpers.forceXAxisUpdate(t)),t.yaxis&&(t=this.updateHelpers.forceYAxisUpdate(t)),o.globals.collapsedSeriesIndices.length>0&&this.series.clearPreviousPaths(),t.theme&&(t=this.theme.updateThemeOptions(t)),this.updateHelpers._updateOptions(t,i,a,s,r)}},{key:"updateSeries",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return this.series.resetSeries(!1),this.updateHelpers.revertDefaultAxisMinMax(),this.updateHelpers._updateSeries(t,e,i)}},{key:"appendSeries",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=this.w.config.series.slice();return a.push(t),this.series.resetSeries(!1),this.updateHelpers.revertDefaultAxisMinMax(),this.updateHelpers._updateSeries(a,e,i)}},{key:"appendData",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this;i.w.globals.dataChanged=!0,i.series.getPreviousPaths();for(var a=i.w.config.series.slice(),s=0;s0&&void 0!==arguments[0])||arguments[0],e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.series.resetSeries(t,e)}},{key:"addEventListener",value:function(t,e){this.events.addEventListener(t,e)}},{key:"removeEventListener",value:function(t,e){this.events.removeEventListener(t,e)}},{key:"addXaxisAnnotation",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=this;i&&(a=i),a.annotations.addXaxisAnnotationExternal(t,e,a)}},{key:"addYaxisAnnotation",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=this;i&&(a=i),a.annotations.addYaxisAnnotationExternal(t,e,a)}},{key:"addPointAnnotation",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=this;i&&(a=i),a.annotations.addPointAnnotationExternal(t,e,a)}},{key:"clearAnnotations",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,e=this;t&&(e=t),e.annotations.clearAnnotations(e)}},{key:"removeAnnotation",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=this;e&&(i=e),i.annotations.removeAnnotation(i,t)}},{key:"getChartArea",value:function(){return this.w.globals.dom.baseEl.querySelector(".apexcharts-inner")}},{key:"getSeriesTotalXRange",value:function(t,e){return this.coreUtils.getSeriesTotalsXRange(t,e)}},{key:"getHighestValueInSeries",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new J(this.ctx).getMinYMaxY(t).highestY}},{key:"getLowestValueInSeries",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new J(this.ctx).getMinYMaxY(t).lowestY}},{key:"getSeriesTotal",value:function(){return this.w.globals.seriesTotals}},{key:"toggleDataPointSelection",value:function(t,e){return this.updateHelpers.toggleDataPointSelection(t,e)}},{key:"zoomX",value:function(t,e){this.ctx.toolbar.zoomUpdateOptions(t,e)}},{key:"setLocale",value:function(t){this.localization.setCurrentLocaleValues(t)}},{key:"dataURI",value:function(t){return new U(this.ctx).dataURI(t)}},{key:"exportToCSV",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new U(this.ctx).exportToCSV(t)}},{key:"paper",value:function(){return this.w.globals.dom.Paper}},{key:"_parentResizeCallback",value:function(){this.w.globals.animationEnded&&this.w.config.chart.redrawOnParentResize&&this._windowResize()}},{key:"_windowResize",value:function(){var t=this;clearTimeout(this.w.globals.resizeTimer),this.w.globals.resizeTimer=window.setTimeout((function(){t.w.globals.resized=!0,t.w.globals.dataChanged=!1,t.ctx.update()}),150)}},{key:"_windowResizeHandler",value:function(){var t=this.w.config.chart.redrawOnWindowResize;"function"==typeof t&&(t=t()),t&&this._windowResize()}}],[{key:"getChartByID",value:function(t){var e=y.escapeString(t),i=Apex._chartInstances.filter((function(t){return t.id===e}))[0];return i&&i.chart}},{key:"initOnLoad",value:function(){for(var e=document.querySelectorAll("[data-apexcharts]"),i=0;i2?s-2:0),o=2;o1&&void 0!==arguments[1]?arguments[1]:{container:document.body},i="";return"string"==typeof t?i=d(t,e):t instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(null==t?void 0:t.type)?i=d(t.value,e):(i=l()(t),h("copy")),i};function u(t){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var f=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.action,i=void 0===e?"copy":e,a=t.container,s=t.target,r=t.text;if("copy"!==i&&"cut"!==i)throw new Error('Invalid "action" value, use either "copy" or "cut"');if(void 0!==s){if(!s||"object"!==u(s)||1!==s.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===i&&s.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===i&&(s.hasAttribute("readonly")||s.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes')}return r?g(r,{container:a}):s?"cut"===i?c(s):g(s,{container:a}):void 0};function p(t){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function x(t,e){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:{container:document.body};return g(t,e)}},{key:"cut",value:function(t){return c(t)}},{key:"isSupported",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],e="string"==typeof t?[t]:t,i=!!document.queryCommandSupported;return e.forEach((function(t){i=i&&!!document.queryCommandSupported(t)})),i}}],(i=[{key:"resolveOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===p(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=o()(t,"click",(function(t){return e.onClick(t)}))}},{key:"onClick",value:function(t){var e=t.delegateTarget||t.currentTarget,i=this.action(e)||"copy",a=f({action:i,container:this.container,target:this.target(e),text:this.text(e)});this.emit(a?"success":"error",{action:i,text:a,trigger:e,clearSelection:function(){e&&e.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(t){return w("action",t)}},{key:"defaultTarget",value:function(t){var e=w("target",t);if(e)return document.querySelector(e)}},{key:"defaultText",value:function(t){return w("text",t)}},{key:"destroy",value:function(){this.listener.destroy()}}])&&x(e.prototype,i),a&&x(e,a),r}(s())},828:function(t){if("undefined"!=typeof Element&&!Element.prototype.matches){var e=Element.prototype;e.matches=e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector}t.exports=function(t,e){for(;t&&9!==t.nodeType;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}},438:function(t,e,i){var a=i(828);function s(t,e,i,a,s){var o=r.apply(this,arguments);return t.addEventListener(i,o,s),{destroy:function(){t.removeEventListener(i,o,s)}}}function r(t,e,i,s){return function(i){i.delegateTarget=a(i.target,e),i.delegateTarget&&s.call(t,i)}}t.exports=function(t,e,i,a,r){return"function"==typeof t.addEventListener?s.apply(null,arguments):"function"==typeof i?s.bind(null,document).apply(null,arguments):("string"==typeof t&&(t=document.querySelectorAll(t)),Array.prototype.map.call(t,(function(t){return s(t,e,i,a,r)})))}},879:function(t,e){e.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},e.nodeList=function(t){var i=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===i||"[object HTMLCollection]"===i)&&"length"in t&&(0===t.length||e.node(t[0]))},e.string=function(t){return"string"==typeof t||t instanceof String},e.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},370:function(t,e,i){var a=i(879),s=i(438);t.exports=function(t,e,i){if(!t&&!e&&!i)throw new Error("Missing required arguments");if(!a.string(e))throw new TypeError("Second argument must be a String");if(!a.fn(i))throw new TypeError("Third argument must be a Function");if(a.node(t))return function(t,e,i){return t.addEventListener(e,i),{destroy:function(){t.removeEventListener(e,i)}}}(t,e,i);if(a.nodeList(t))return function(t,e,i){return Array.prototype.forEach.call(t,(function(t){t.addEventListener(e,i)})),{destroy:function(){Array.prototype.forEach.call(t,(function(t){t.removeEventListener(e,i)}))}}}(t,e,i);if(a.string(t))return function(t,e,i){return s(document.body,t,e,i)}(t,e,i);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}},817:function(t){t.exports=function(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var i=t.hasAttribute("readonly");i||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),i||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var a=window.getSelection(),s=document.createRange();s.selectNodeContents(t),a.removeAllRanges(),a.addRange(s),e=a.toString()}return e}},279:function(t){function e(){}e.prototype={on:function(t,e,i){var a=this.e||(this.e={});return(a[t]||(a[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var a=this;function s(){a.off(t,s),e.apply(i,arguments)}return s._=e,this.on(t,s,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),a=0,s=i.length;a1&&void 0!==arguments[1]?arguments[1]:{container:document.body},i="";return"string"==typeof t?i=d(t,e):t instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(null==t?void 0:t.type)?i=d(t.value,e):(i=l()(t),h("copy")),i};function u(t){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var p=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.action,i=void 0===e?"copy":e,a=t.container,s=t.target,r=t.text;if("copy"!==i&&"cut"!==i)throw new Error('Invalid "action" value, use either "copy" or "cut"');if(void 0!==s){if(!s||"object"!==u(s)||1!==s.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===i&&s.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===i&&(s.hasAttribute("readonly")||s.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes')}return r?g(r,{container:a}):s?"cut"===i?c(s):g(s,{container:a}):void 0};function f(t){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function x(t,e){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:{container:document.body};return g(t,e)}},{key:"cut",value:function(t){return c(t)}},{key:"isSupported",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],e="string"==typeof t?[t]:t,i=!!document.queryCommandSupported;return e.forEach((function(t){i=i&&!!document.queryCommandSupported(t)})),i}}],(i=[{key:"resolveOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof t.action?t.action:this.defaultAction,this.target="function"==typeof t.target?t.target:this.defaultTarget,this.text="function"==typeof t.text?t.text:this.defaultText,this.container="object"===f(t.container)?t.container:document.body}},{key:"listenClick",value:function(t){var e=this;this.listener=o()(t,"click",(function(t){return e.onClick(t)}))}},{key:"onClick",value:function(t){var e=t.delegateTarget||t.currentTarget,i=this.action(e)||"copy",a=p({action:i,container:this.container,target:this.target(e),text:this.text(e)});this.emit(a?"success":"error",{action:i,text:a,trigger:e,clearSelection:function(){e&&e.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(t){return w("action",t)}},{key:"defaultTarget",value:function(t){var e=w("target",t);if(e)return document.querySelector(e)}},{key:"defaultText",value:function(t){return w("text",t)}},{key:"destroy",value:function(){this.listener.destroy()}}])&&x(e.prototype,i),a&&x(e,a),r}(s())},828:function(t){if("undefined"!=typeof Element&&!Element.prototype.matches){var e=Element.prototype;e.matches=e.matchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector}t.exports=function(t,e){for(;t&&9!==t.nodeType;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}},438:function(t,e,i){var a=i(828);function s(t,e,i,a,s){var o=r.apply(this,arguments);return t.addEventListener(i,o,s),{destroy:function(){t.removeEventListener(i,o,s)}}}function r(t,e,i,s){return function(i){i.delegateTarget=a(i.target,e),i.delegateTarget&&s.call(t,i)}}t.exports=function(t,e,i,a,r){return"function"==typeof t.addEventListener?s.apply(null,arguments):"function"==typeof i?s.bind(null,document).apply(null,arguments):("string"==typeof t&&(t=document.querySelectorAll(t)),Array.prototype.map.call(t,(function(t){return s(t,e,i,a,r)})))}},879:function(t,e){e.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},e.nodeList=function(t){var i=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===i||"[object HTMLCollection]"===i)&&"length"in t&&(0===t.length||e.node(t[0]))},e.string=function(t){return"string"==typeof t||t instanceof String},e.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},370:function(t,e,i){var a=i(879),s=i(438);t.exports=function(t,e,i){if(!t&&!e&&!i)throw new Error("Missing required arguments");if(!a.string(e))throw new TypeError("Second argument must be a String");if(!a.fn(i))throw new TypeError("Third argument must be a Function");if(a.node(t))return function(t,e,i){return t.addEventListener(e,i),{destroy:function(){t.removeEventListener(e,i)}}}(t,e,i);if(a.nodeList(t))return function(t,e,i){return Array.prototype.forEach.call(t,(function(t){t.addEventListener(e,i)})),{destroy:function(){Array.prototype.forEach.call(t,(function(t){t.removeEventListener(e,i)}))}}}(t,e,i);if(a.string(t))return function(t,e,i){return s(document.body,t,e,i)}(t,e,i);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}},817:function(t){t.exports=function(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var i=t.hasAttribute("readonly");i||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),i||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var a=window.getSelection(),s=document.createRange();s.selectNodeContents(t),a.removeAllRanges(),a.addRange(s),e=a.toString()}return e}},279:function(t){function e(){}e.prototype={on:function(t,e,i){var a=this.e||(this.e={});return(a[t]||(a[t]=[])).push({fn:e,ctx:i}),this},once:function(t,e,i){var a=this;function s(){a.off(t,s),e.apply(i,arguments)}return s._=e,this.on(t,s,i)},emit:function(t){for(var e=[].slice.call(arguments,1),i=((this.e||(this.e={}))[t]||[]).slice(),a=0,s=i.length;asettingsModel === null && $this->createSettingsModel()) { @@ -58,7 +51,7 @@ public function getSettings() */ $this->settingsModel = $this->createSettingsModel(); - $pluginSettings = Snipcart::$plugin->getSettings(); + $pluginSettings = Snipcart::$plugin->getSettings(); $providerSettings = $pluginSettings->providerSettings[static::refHandle()] ?? []; $this->settingsModel->setAttributes($providerSettings); @@ -67,78 +60,51 @@ public function getSettings() return $this->settingsModel; } - /** - * @inheritdoc - */ - public function setSettings(array $settings) + public function setSettings(array $settings): void { if ($this->getSettings()) { $this->getSettings()->setAttributes($settings, false); } } - /** - * @inheritdoc - */ public function isConfigured(): bool { return false; } - /** - * @inheritdoc - */ public function getRatesForOrder(SnipcartOrder $snipcartOrder, Package $package): array { return []; } - /** - * @inheritdoc - */ public function createOrder(SnipcartOrder $snipcartOrder) { return null; } - /** - * @inheritdoc - */ public function getClient(): Client { return Craft::createGuzzleClient(); } - /** - * @inheritdoc - */ public function getOrderById($providerId) { return null; } - /** - * @inheritdoc - */ public function getOrderBySnipcartInvoice(string $snipcartInvoice) { return null; } - /** - * @inheritdoc - */ public function createShippingLabelForOrder(SnipcartOrder $snipcartOrder) { return null; } - /** - * @inheritdoc - */ public function get(string $endpoint, array $params = []) { - if (count($params) > 0) { + if ($params !== []) { $endpoint .= '?' . http_build_query($params); } @@ -147,25 +113,22 @@ public function get(string $endpoint, array $params = []) return $this->prepResponseData( $response->getBody() ); - } catch (RequestException $exception) { - $this->handleRequestException($exception, $endpoint); + } catch (RequestException $requestException) { + $this->handleRequestException($requestException, $endpoint); return null; } } - /** - * @inheritdoc - */ public function post(string $endpoint, array $data = []) { try { $response = $this->getClient()->post($endpoint, [ - \GuzzleHttp\RequestOptions::JSON => $data + RequestOptions::JSON => $data, ]); return $this->prepResponseData($response->getBody()); - } catch (RequestException $exception) { - $this->handleRequestException($exception, $endpoint); + } catch (RequestException $requestException) { + $this->handleRequestException($requestException, $endpoint); return null; } } @@ -207,7 +170,7 @@ public function getValueFromCustomFields($customFields, $fieldName, $emptyAsNull * @return mixed Appropriate PHP type, or null if json cannot be decoded * or encoded data is deeper than the recursion limit. */ - public function prepResponseData($body) + public function prepResponseData(mixed $body) { return Json::decode($body, false); } @@ -217,12 +180,10 @@ public function prepResponseData($body) * * @param RequestException $exception the exception that was thrown * @param string $endpoint the endpoint that was queried - * - * @return null */ public function handleRequestException( $exception, - string $endpoint + string $endpoint, ) { /** * Get the status code, which should be 200 or 201 if things went well. @@ -235,7 +196,7 @@ public function handleRequestException( */ $reason = $exception->getResponse()->getBody() ?? null; - if ($statusCode !== null && $reason !== null) { + if ($statusCode !== null && $reason instanceof StreamInterface) { // return code and message Craft::warning(sprintf( '%s API responded with %d: %s', @@ -264,5 +225,4 @@ protected function createSettingsModel() { return null; } - } diff --git a/src/base/ShippingProviderInterface.php b/src/base/ShippingProviderInterface.php index ed5e568..84d377c 100644 --- a/src/base/ShippingProviderInterface.php +++ b/src/base/ShippingProviderInterface.php @@ -2,16 +2,17 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\base; +use craft\base\Model; use craft\base\ComponentInterface; use fostercommerce\snipcart\models\snipcart\Order as SnipcartOrder; -use fostercommerce\snipcart\models\snipcart\ShippingRate as SnipcartRate; use fostercommerce\snipcart\models\snipcart\Package; +use fostercommerce\snipcart\models\snipcart\ShippingRate as SnipcartRate; use GuzzleHttp\Client; interface ShippingProviderInterface extends ComponentInterface @@ -25,8 +26,6 @@ public static function refHandle(); /** * Gets the base URL for the provider's REST API, used by client. - * - * @return string */ public static function apiBaseUrl(): string; @@ -34,7 +33,7 @@ public static function apiBaseUrl(): string; * Gets the provider settings model, null if it's not ready, false * if there isn’t one. * - * @return \craft\base\Model|bool|null + * @return Model|bool|null */ public function getSettings(); @@ -47,16 +46,12 @@ public function setSettings(array $settings); /** * Whether the provider is ready to go. - * - * @return bool */ public function isConfigured(): bool; /** * Gets shipping rates for the provided Snipcart order. * - * @param SnipcartOrder $snipcartOrder - * @param Package $package * @return SnipcartRate[] */ public function getRatesForOrder(SnipcartOrder $snipcartOrder, Package $package): array; @@ -64,15 +59,12 @@ public function getRatesForOrder(SnipcartOrder $snipcartOrder, Package $package) /** * Creates an equivalent order in the provider’s system. * - * @param SnipcartOrder $snipcartOrder * @return mixed|null The created order model. */ public function createOrder(SnipcartOrder $snipcartOrder); /** * Gets an instance of the Guzzle client. - * - * @return Client */ public function getClient(): Client; @@ -87,7 +79,6 @@ public function getOrderById($providerId); /** * Gets an order by Snipcart invoice number. * - * @param string $snipcartInvoice * @return mixed provider order model or null */ public function getOrderBySnipcartInvoice(string $snipcartInvoice); @@ -95,7 +86,6 @@ public function getOrderBySnipcartInvoice(string $snipcartInvoice); /** * Creates a shipping label for the provided order. * - * @param SnipcartOrder $snipcartOrder * @return string|null URL to the label * @todo decide on sensible uniform return value */ @@ -106,7 +96,6 @@ public function createShippingLabelForOrder(SnipcartOrder $snipcartOrder); * as an object, array of objects, or null. * * @param $endpoint - * @param array $params * @return mixed */ public function get(string $endpoint, array $params = []); @@ -116,9 +105,7 @@ public function get(string $endpoint, array $params = []); * as an object, array of objects, or null. * * @param $endpoint - * @param array $data * @return mixed */ public function post(string $endpoint, array $data = []); - -} \ No newline at end of file +} diff --git a/src/behaviors/BillingAddressBehavior.php b/src/behaviors/BillingAddressBehavior.php index 7e9205b..33dbbe3 100644 --- a/src/behaviors/BillingAddressBehavior.php +++ b/src/behaviors/BillingAddressBehavior.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -20,9 +20,9 @@ */ class BillingAddressBehavior extends Behavior { - private $billingAddress; + private ?Address $billingAddress = null; - public function getBillingAddress() + public function getBillingAddress(): ?Address { return $this->billingAddress; } @@ -41,7 +41,7 @@ public function getBillingAddressName() */ public function setBillingAddressName($name) { - if ($this->billingAddress === null) { + if (! $this->billingAddress instanceof Address) { $this->billingAddress = new Address(); } @@ -62,7 +62,7 @@ public function getBillingAddressFirstName() */ public function setBillingAddressFirstName($firstName) { - if ($this->billingAddress === null) { + if (! $this->billingAddress instanceof Address) { $this->billingAddress = new Address(); } @@ -83,7 +83,7 @@ public function getBillingAddressCompanyName() */ public function setBillingAddressCompanyName($companyName) { - if ($this->billingAddress === null) { + if (! $this->billingAddress instanceof Address) { $this->billingAddress = new Address(); } @@ -104,7 +104,7 @@ public function getBillingAddressAddress1() */ public function setBillingAddressAddress1($address1) { - if ($this->billingAddress === null) { + if (! $this->billingAddress instanceof Address) { $this->billingAddress = new Address(); } @@ -125,16 +125,13 @@ public function getBillingAddressAddress2() */ public function setBillingAddressAddress2($address2) { - if ($this->billingAddress === null) { + if (! $this->billingAddress instanceof Address) { $this->billingAddress = new Address(); } return $this->billingAddress->address2 = $address2; } - /** - * @return string - */ public function getBillingAddressCity(): string { return $this->getBillingAddress()->city; @@ -146,7 +143,7 @@ public function getBillingAddressCity(): string */ public function setBillingAddressCity($city) { - if ($this->billingAddress === null) { + if (! $this->billingAddress instanceof Address) { $this->billingAddress = new Address(); } @@ -167,7 +164,7 @@ public function getBillingAddressCountry() */ public function setBillingAddressCountry($country) { - if ($this->billingAddress === null) { + if (! $this->billingAddress instanceof Address) { $this->billingAddress = new Address(); } @@ -188,7 +185,7 @@ public function getBillingAddressProvince() */ public function setBillingAddressProvince($province) { - if ($this->billingAddress === null) { + if (! $this->billingAddress instanceof Address) { $this->billingAddress = new Address(); } @@ -209,7 +206,7 @@ public function getBillingAddressPostalCode() */ public function setBillingAddressPostalCode($postalCode) { - if ($this->billingAddress === null) { + if (! $this->billingAddress instanceof Address) { $this->billingAddress = new Address(); } @@ -230,11 +227,10 @@ public function getBillingAddressPhone() */ public function setBillingAddressPhone($phone) { - if ($this->billingAddress === null) { + if (! $this->billingAddress instanceof Address) { $this->billingAddress = new Address(); } return $this->billingAddress->phone = $phone; } - -} \ No newline at end of file +} diff --git a/src/behaviors/ShippingAddressBehavior.php b/src/behaviors/ShippingAddressBehavior.php index f33be3d..9505306 100644 --- a/src/behaviors/ShippingAddressBehavior.php +++ b/src/behaviors/ShippingAddressBehavior.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -20,9 +20,9 @@ */ class ShippingAddressBehavior extends Behavior { - private $shippingAddress; + private ?Address $shippingAddress = null; - public function getShippingAddress() + public function getShippingAddress(): ?Address { return $this->shippingAddress; } @@ -41,7 +41,7 @@ public function getShippingAddressName() */ public function setShippingAddressName($name) { - if ($this->shippingAddress === null) { + if (! $this->shippingAddress instanceof Address) { $this->shippingAddress = new Address(); } @@ -62,7 +62,7 @@ public function getShippingAddressFirstName() */ public function setShippingAddressFirstName($firstName) { - if ($this->shippingAddress === null) { + if (! $this->shippingAddress instanceof Address) { $this->shippingAddress = new Address(); } @@ -83,7 +83,7 @@ public function getShippingAddressCompanyName() */ public function setShippingAddressCompanyName($companyName) { - if ($this->shippingAddress === null) { + if (! $this->shippingAddress instanceof Address) { $this->shippingAddress = new Address(); } @@ -104,7 +104,7 @@ public function getShippingAddressAddress1() */ public function setShippingAddressAddress1($address1) { - if ($this->shippingAddress === null) { + if (! $this->shippingAddress instanceof Address) { $this->shippingAddress = new Address(); } @@ -125,7 +125,7 @@ public function getShippingAddressAddress2() */ public function setShippingAddressAddress2($address2) { - if ($this->shippingAddress === null) { + if (! $this->shippingAddress instanceof Address) { $this->shippingAddress = new Address(); } @@ -146,7 +146,7 @@ public function getShippingAddressCity() */ public function setShippingAddressCity($city) { - if ($this->shippingAddress === null) { + if (! $this->shippingAddress instanceof Address) { $this->shippingAddress = new Address(); } @@ -167,7 +167,7 @@ public function getShippingAddressCountry() */ public function setShippingAddressCountry($country) { - if ($this->shippingAddress === null) { + if (! $this->shippingAddress instanceof Address) { $this->shippingAddress = new Address(); } @@ -188,7 +188,7 @@ public function getShippingAddressProvince() */ public function setShippingAddressProvince($province) { - if ($this->shippingAddress === null) { + if (! $this->shippingAddress instanceof Address) { $this->shippingAddress = new Address(); } @@ -209,7 +209,7 @@ public function getShippingAddressPostalCode() */ public function setShippingAddressPostalCode($postalCode) { - if ($this->shippingAddress === null) { + if (! $this->shippingAddress instanceof Address) { $this->shippingAddress = new Address(); } @@ -230,10 +230,10 @@ public function getShippingAddressPhone() */ public function setShippingAddressPhone($phone) { - if ($this->shippingAddress === null) { + if (! $this->shippingAddress instanceof Address) { $this->shippingAddress = new Address(); } return $this->shippingAddress->phone = $phone; } -} \ No newline at end of file +} diff --git a/src/console/controllers/CleanupController.php b/src/console/controllers/CleanupController.php new file mode 100644 index 0000000..8024282 --- /dev/null +++ b/src/console/controllers/CleanupController.php @@ -0,0 +1,32 @@ +getDb()->createCommand()->dropTable($table)->execute(); + echo "dropped\r\n"; + } + + return ExitCode::OK; + } +} diff --git a/src/console/controllers/VerifyController.php b/src/console/controllers/VerifyController.php index ffa0efb..c66adc8 100644 --- a/src/console/controllers/VerifyController.php +++ b/src/console/controllers/VerifyController.php @@ -2,16 +2,17 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ + namespace fostercommerce\snipcart\console\controllers; use Craft; use craft\helpers\DateTimeHelper; -use fostercommerce\snipcart\Snipcart; use fostercommerce\snipcart\models\snipcart\Order; use fostercommerce\snipcart\providers\shipstation\ShipStation; +use fostercommerce\snipcart\Snipcart; use yii\console\Controller; use yii\console\ExitCode; @@ -23,8 +24,9 @@ */ class VerifyController extends Controller { - const SUCCESS_CHAR = '✓'; - const FAIL_CHAR = '✗'; + public const SUCCESS_CHAR = '✓'; + + public const FAIL_CHAR = '✗'; /** * Checks that most recent orders exist in Snipcart and ShipStation. @@ -33,25 +35,24 @@ class VerifyController extends Controller * @param bool $forceFeed forcefully re-send missing orders * @param int $limit number of recent orders to check * - * @return int * @throws */ public function actionCheckOrders($forceFeed = false, $limit = 3): int { - $startTime = microtime(true); + $startTime = microtime(true); $failedOrders = []; - + $this->stdout('-------------------------------------' . PHP_EOL); - $this->stdout("Checking last $limit orders..." . PHP_EOL); + $this->stdout(sprintf('Checking last %d orders...', $limit) . PHP_EOL); $this->stdout('-------------------------------------' . PHP_EOL); $orders = Snipcart::$plugin->orders->getOrders([ 'limit' => $limit, - 'cache' => false + 'cache' => false, ]); foreach ($orders as $order) { - $this->stdout("Snipcart $order->invoiceNumber … "); + $this->stdout(sprintf('Snipcart %s … ', $order->invoiceNumber)); if ($order->hasShippableItems()) { $success = true; @@ -59,7 +60,7 @@ public function actionCheckOrders($forceFeed = false, $limit = 3): int ->shipStation ->getOrderBySnipcartInvoice($order->invoiceNumber); - if (! $shipStationOrder) { + if (! $shipStationOrder instanceof \fostercommerce\snipcart\models\shipstation\Order) { $success = false; $failedOrders[] = $order; } @@ -76,7 +77,7 @@ public function actionCheckOrders($forceFeed = false, $limit = 3): int } } - if (count($failedOrders) > 0) { + if ($failedOrders !== []) { $reFeedResults = $this->reFeedToShipStation( $failedOrders, $forceFeed @@ -87,10 +88,10 @@ public function actionCheckOrders($forceFeed = false, $limit = 3): int $this->stdout('-------------------------------------' . PHP_EOL); - $endTime = microtime(true); + $endTime = microtime(true); $executionTime = ($endTime - $startTime); - $this->stdout("Finished in ${executionTime} seconds." . PHP_EOL . PHP_EOL); + $this->stdout(sprintf('Finished in %s seconds.', $executionTime) . PHP_EOL . PHP_EOL); return ExitCode::OK; } @@ -154,12 +155,10 @@ private function reFeedToShipStation($orders, $force): array * Lets somebody know that one or more orders didn’t make it to ShipStation. * * @param Order[] $snipcartOrders - * @param array $reFeedResults * - * @return int * @throws */ - private function sendAdminNotification($snipcartOrders, $reFeedResults): int + private function sendAdminNotification($snipcartOrders, array $reFeedResults): int { Snipcart::$plugin->notifications->setEmailTemplate( 'snipcart/email/recovery' @@ -177,17 +176,16 @@ private function sendAdminNotification($snipcartOrders, $reFeedResults): int Snipcart::$plugin->notifications->setNotificationVars([ 'orders' => $snipcartOrders, 'reattempt' => $reFeedResults, - 'containsFailures' => $containsFailures + 'containsFailures' => $containsFailures, ]); $toEmails = Snipcart::$plugin->getSettings()->notificationEmails; $subject = 'Recovered Snipcart Orders'; if (! Snipcart::$plugin->notifications->sendEmail($toEmails, $subject)) { - $this->stderr('Notifications failed.'. PHP_EOL); + $this->stderr('Notifications failed.' . PHP_EOL); } return ExitCode::OK; } - -} \ No newline at end of file +} diff --git a/src/controllers/CartsController.php b/src/controllers/CartsController.php index 1a511cb..2c7e998 100644 --- a/src/controllers/CartsController.php +++ b/src/controllers/CartsController.php @@ -2,37 +2,38 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\controllers; -use fostercommerce\snipcart\Snipcart; -use craft\helpers\UrlHelper; -use craft\helpers\DateTimeHelper; +use craft\web\Controller; use Craft; +use craft\helpers\DateTimeHelper; +use craft\helpers\UrlHelper; +use fostercommerce\snipcart\Snipcart; +use yii\web\Response; -class CartsController extends \craft\web\Controller +class CartsController extends Controller { /** * Displays paginated list of abandoned carts. * - * @return \yii\web\Response * @throws */ - public function actionIndex(): \yii\web\Response + public function actionIndex(): Response { - $page = Craft::$app->getRequest()->getPageNum(); + $page = Craft::$app->getRequest()->getPageNum(); $carts = Snipcart::$plugin->carts->listAbandonedCarts($page); return $this->renderTemplate( 'snipcart/cp/abandoned-carts/index', [ - 'pageNumber' => $page, - 'carts' => $carts->items, + 'pageNumber' => $page, + 'carts' => $carts->items, 'continuationToken' => $carts->continuationToken ?? null, - 'hasMoreResults' => $carts->hasMoreResults ?? false, + 'hasMoreResults' => $carts->hasMoreResults ?? false, ] ); } @@ -40,17 +41,16 @@ public function actionIndex(): \yii\web\Response /** * Gets the next page/grouping of abandoned carts. * - * @return \yii\web\Response * @throws */ - public function actionGetNextCarts(): \yii\web\Response + public function actionGetNextCarts(): Response { $this->requirePostRequest(); $token = Craft::$app->getRequest()->getRequiredParam('continuationToken'); $response = Snipcart::$plugin->api->get('carts/abandoned', [ - 'continuationToken' => $token + 'continuationToken' => $token, ]); if (isset($response->items)) { @@ -70,11 +70,9 @@ public function actionGetNextCarts(): \yii\web\Response /** * Displays abandoned cart detail. * - * @param string $cartId - * @return \yii\web\Response * @throws \Exception */ - public function actionDetail(string $cartId): \yii\web\Response + public function actionDetail(string $cartId): Response { $abandonedCart = Snipcart::$plugin->carts->getAbandonedCart($cartId); @@ -85,5 +83,4 @@ public function actionDetail(string $cartId): \yii\web\Response ] ); } - -} \ No newline at end of file +} diff --git a/src/controllers/ChartsController.php b/src/controllers/ChartsController.php index d290e73..37ce6bc 100644 --- a/src/controllers/ChartsController.php +++ b/src/controllers/ChartsController.php @@ -2,34 +2,35 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\controllers; -use fostercommerce\snipcart\Snipcart; +use craft\web\Controller; +use yii\web\BadRequestHttpException; use Craft; -use yii\base\Response; -use DateTimeZone; -use DateTime; use craft\helpers\DateTimeHelper; +use DateTime; +use DateTimeZone; +use fostercommerce\snipcart\Snipcart; +use yii\base\Response; -class ChartsController extends \craft\web\Controller +class ChartsController extends Controller { /** * Fetches order data JSON for the Dashboard widget's chart. * - * @return Response - * @throws \yii\web\BadRequestHttpException + * @throws BadRequestHttpException */ public function actionGetOrdersData(): Response { $this->requirePostRequest(); $request = Craft::$app->getRequest(); - $type = $request->getRequiredParam('type'); - $range = $request->getRequiredParam('range'); + $type = $request->getRequiredParam('type'); + $range = $request->getRequiredParam('range'); if ($range === 'weekly') { $startDate = (new \DateTime('now'))->modify('-1 week'); @@ -59,7 +60,7 @@ public function actionGetOrdersData(): Response } return $this->asJson([ - 'series' => $chartData['series'], + 'series' => $chartData['series'], 'columns' => $chartData['columns'], 'formats' => $formats, ]); @@ -68,8 +69,7 @@ public function actionGetOrdersData(): Response /** * Fetches order and sales stats in one response for the CP overview chart. * - * @return Response - * @throws \yii\web\BadRequestHttpException + * @throws BadRequestHttpException * @throws */ public function actionGetCombinedData(): Response @@ -109,7 +109,6 @@ public function actionGetCombinedData(): Response * Gets chart series for Snipcart sales data. * * @param $data - * @return array */ private function getTotalSales($data): array { @@ -120,7 +119,6 @@ private function getTotalSales($data): array * Gets chart series for Snipcart orders data. * * @param $data - * @return array */ private function getNumberOfOrders($data): array { @@ -131,11 +129,8 @@ private function getNumberOfOrders($data): array * Translates Snipcart’s returned data into a chart-friendly series. * * @param $data - * @param string $label - * - * @return array */ - private function formatForChart($data, $label): array + private function formatForChart($data, string $label): array { $rows = []; $columns = []; @@ -150,45 +145,53 @@ private function formatForChart($data, $label): array [ 'name' => $label, 'data' => $rows, - ] + ], ], - 'columns' => $columns + 'columns' => $columns, ]; } /** * Gets the beginning of the range used for visualizing stats. * - * @return DateTime * @throws */ private function getStartDate(): DateTime { $startDateParam = Craft::$app->getRequest()->getParam('startDate'); + if (! $startDateParam) { + return (new DateTime('now', new DateTimeZone(Craft::$app->getTimeZone()))) + ->modify('-1 month'); + } - if ($startDateParam && is_string($startDateParam)) { - return DateTimeHelper::toDateTime([ 'date' => $startDateParam ]); + if (! is_string($startDateParam)) { + return (new DateTime('now', new DateTimeZone(Craft::$app->getTimeZone()))) + ->modify('-1 month'); } - - return (new DateTime('now', new DateTimeZone(Craft::$app->getTimeZone()))) - ->modify('-1 month'); + + return DateTimeHelper::toDateTime([ + 'date' => $startDateParam, + ]); } /** * Gets the end of the range used for visualizing stats. * - * @return DateTime * @throws */ private function getEndDate(): DateTime { $endDateParam = Craft::$app->getRequest()->getParam('endDate'); + if (! $endDateParam) { + return new DateTime('now', new DateTimeZone(Craft::$app->getTimeZone())); + } - if ($endDateParam && is_string($endDateParam)) { - return DateTimeHelper::toDateTime([ 'date' => $endDateParam ]); + if (! is_string($endDateParam)) { + return new DateTime('now', new DateTimeZone(Craft::$app->getTimeZone())); } - return new DateTime('now', new DateTimeZone(Craft::$app->getTimeZone())); + return DateTimeHelper::toDateTime([ + 'date' => $endDateParam, + ]); } - -} \ No newline at end of file +} diff --git a/src/controllers/CustomersController.php b/src/controllers/CustomersController.php index 01a4708..08a1b2a 100644 --- a/src/controllers/CustomersController.php +++ b/src/controllers/CustomersController.php @@ -2,35 +2,38 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\controllers; -use fostercommerce\snipcart\Snipcart; +use craft\web\Controller; +use yii\web\Response; +use craft\errors\MissingComponentException; use Craft; +use fostercommerce\snipcart\Snipcart; -class CustomersController extends \craft\web\Controller +class CustomersController extends Controller { - const SEARCH_KEYWORD_PARAM = 'searchKeywords'; - const SEARCH_KEYWORD_SESSION_KEY = 'snipcartSearchKeywords'; + public const SEARCH_KEYWORD_PARAM = 'searchKeywords'; + + public const SEARCH_KEYWORD_SESSION_KEY = 'snipcartSearchKeywords'; /** * Displays paginated list of customers. * - * @return \yii\web\Response * @throws */ - public function actionIndex(): \yii\web\Response + public function actionIndex(): Response { - $request = Craft::$app->getRequest(); + $request = Craft::$app->getRequest(); $searchKeywords = $this->getSearchKeywords(); - $page = $request->getPageNum(); + $page = $request->getPageNum(); if (! empty($searchKeywords)) { $customers = Snipcart::$plugin->customers->listCustomers($page, 20, [ - 'name' => $searchKeywords + 'name' => $searchKeywords, ]); } else { $customers = Snipcart::$plugin->customers->listCustomers($page); @@ -44,8 +47,8 @@ public function actionIndex(): \yii\web\Response 'pageNumber' => $page, 'totalPages' => $totalPages, 'totalItems' => $customers->totalItems, - 'customers' => $customers->items, - 'keywords' => $searchKeywords, + 'customers' => $customers->items, + 'keywords' => $searchKeywords, ] ); } @@ -53,11 +56,9 @@ public function actionIndex(): \yii\web\Response /** * Displays customer detail. * - * @param string $customerId - * @return \yii\web\Response * @throws */ - public function actionCustomerDetail(string $customerId): \yii\web\Response + public function actionCustomerDetail(string $customerId): Response { $customer = Snipcart::$plugin->customers->getCustomer($customerId); $customerOrders = Snipcart::$plugin->customers->getCustomerOrders($customerId); @@ -66,7 +67,7 @@ public function actionCustomerDetail(string $customerId): \yii\web\Response 'snipcart/cp/customers/detail', [ 'customer' => $customer, - 'orders' => $customerOrders, + 'orders' => $customerOrders, ] ); } @@ -76,7 +77,7 @@ public function actionCustomerDetail(string $customerId): \yii\web\Response * session in the process. Returns empty string if no keywords are present. * * @return array|mixed|string - * @throws \craft\errors\MissingComponentException + * @throws MissingComponentException */ private function getSearchKeywords() { @@ -94,5 +95,4 @@ private function getSearchKeywords() return $keywords; } - -} \ No newline at end of file +} diff --git a/src/controllers/DiscountsController.php b/src/controllers/DiscountsController.php index 085978e..30432a2 100644 --- a/src/controllers/DiscountsController.php +++ b/src/controllers/DiscountsController.php @@ -2,31 +2,34 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\controllers; +use craft\web\Controller; +use yii\web\Response; +use craft\errors\MissingComponentException; +use yii\web\BadRequestHttpException; +use Craft; +use craft\helpers\UrlHelper; use fostercommerce\snipcart\models\snipcart\Discount; use fostercommerce\snipcart\Snipcart; -use craft\helpers\UrlHelper; -use Craft; -class DiscountsController extends \craft\web\Controller +class DiscountsController extends Controller { /** * Displays discounts, which don’t come paginated. * - * @return \yii\web\Response * @throws */ - public function actionIndex(): \yii\web\Response + public function actionIndex(): Response { return $this->renderTemplate( 'snipcart/cp/discounts/index', [ - 'discounts' => Snipcart::$plugin->discounts->listDiscounts() + 'discounts' => Snipcart::$plugin->discounts->listDiscounts(), ] ); } @@ -34,26 +37,22 @@ public function actionIndex(): \yii\web\Response /** * Displays discount detail. * - * @param string $discountId - * @return \yii\web\Response * @throws */ - public function actionDiscountDetail(string $discountId): \yii\web\Response + public function actionDiscountDetail(string $discountId): Response { return $this->renderTemplate( 'snipcart/cp/discounts/detail', [ - 'discount' => Snipcart::$plugin->discounts->getDiscount($discountId) + 'discount' => Snipcart::$plugin->discounts->getDiscount($discountId), ] ); } /** * Displays new discount form. - * - * @return \yii\web\Response */ - public function actionNew(): \yii\web\Response + public function actionNew(): Response { return $this->renderTemplate('snipcart/cp/discounts/new'); } @@ -61,11 +60,10 @@ public function actionNew(): \yii\web\Response /** * Saves a new discount. * - * @return \yii\web\Response - * @throws \craft\errors\MissingComponentException - * @throws \yii\web\BadRequestHttpException + * @throws MissingComponentException + * @throws BadRequestHttpException */ - public function actionSave(): \yii\web\Response + public function actionSave(): Response { $this->requirePostRequest(); @@ -75,11 +73,15 @@ public function actionSave(): \yii\web\Response if (! $discount = new Discount($params)) { Craft::$app->getUrlManager()->setRouteParams([ - 'variables' => ['discount' => $discount] + 'variables' => [ + 'discount' => $discount, + ], ]); } elseif (! $discount->validate()) { Craft::$app->getUrlManager()->setRouteParams([ - 'variables' => ['discount' => $discount] + 'variables' => [ + 'discount' => $discount, + ], ]); Craft::$app->getSession()->setError('Invalid Discount details.'); @@ -93,9 +95,9 @@ public function actionSave(): \yii\web\Response } /** - * @throws \yii\web\BadRequestHttpException + * @throws BadRequestHttpException */ - public function actionUpdateDiscount() + public function actionUpdateDiscount(): void { $this->requirePostRequest(); } @@ -103,14 +105,14 @@ public function actionUpdateDiscount() /** * Deletes a discount. * - * @throws \yii\web\BadRequestHttpException - * @throws \craft\errors\MissingComponentException + * @throws BadRequestHttpException + * @throws MissingComponentException */ - public function actionDeleteDiscount(): \yii\web\Response + public function actionDeleteDiscount(): Response { $this->requirePostRequest(); - $discountId = (string)Craft::$app->getRequest()->post('discountId'); + $discountId = (string) Craft::$app->getRequest()->post('discountId'); // successful response will be `null`, do don't bother checking Snipcart::$plugin->discounts->deleteDiscountById($discountId); @@ -127,4 +129,4 @@ public function actionDeleteDiscount(): \yii\web\Response return $this->redirect(UrlHelper::cpUrl('snipcart/discounts')); } -} \ No newline at end of file +} diff --git a/src/controllers/OrdersController.php b/src/controllers/OrdersController.php index e6a1b92..d9aa7b2 100644 --- a/src/controllers/OrdersController.php +++ b/src/controllers/OrdersController.php @@ -2,38 +2,45 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\controllers; -use fostercommerce\snipcart\Snipcart; +use craft\web\Controller; +use yii\web\Response; +use craft\errors\MissingComponentException; +use yii\web\BadRequestHttpException; +use Craft; use craft\helpers\DateTimeHelper; use DateTime; -use Craft; +use fostercommerce\snipcart\Snipcart; -class OrdersController extends \craft\web\Controller +class OrdersController extends Controller { - const START_DATE_PARAM = 'startDate'; - const START_DATE_SESSION_KEY = 'snipcartStartDate'; - const END_DATE_PARAM = 'endDate'; - const END_DATE_SESSION_KEY = 'snipcartEndDate'; + public const START_DATE_PARAM = 'startDate'; + + public const START_DATE_SESSION_KEY = 'snipcartStartDate'; + + public const END_DATE_PARAM = 'endDate'; + + public const END_DATE_SESSION_KEY = 'snipcartEndDate'; /** * Displays paginated list of orders. * - * @return \yii\web\Response * @throws */ - public function actionIndex(): \yii\web\Response + public function actionIndex(): Response { - $startDate = $this->getDateRangeExtent('start'); - $endDate = $this->getDateRangeExtent('end'); - $page = Craft::$app->getRequest()->getPageNum(); - $orders = Snipcart::$plugin->orders->listOrders($page, 20, [ + $startDate = $this->getDateRangeExtent('start'); + $endDate = $this->getDateRangeExtent('end'); + + $page = Craft::$app->getRequest()->getPageNum(); + $orders = Snipcart::$plugin->orders->listOrders($page, 20, [ 'from' => $startDate, - 'to' => $endDate + 'to' => $endDate, ]); $totalPages = ceil($orders->totalItems / $orders->limit); @@ -41,12 +48,12 @@ public function actionIndex(): \yii\web\Response return $this->renderTemplate( 'snipcart/cp/orders/index', [ - 'startDate' => $startDate, - 'endDate' => $endDate, + 'startDate' => $startDate, + 'endDate' => $endDate, 'pageNumber' => $page, 'totalPages' => $totalPages, 'totalItems' => $orders->totalItems, - 'orders' => $orders->items, + 'orders' => $orders->items, ] ); } @@ -54,15 +61,12 @@ public function actionIndex(): \yii\web\Response /** * Displays order detail. * - * @param string $orderId - * @return \yii\web\Response * @throws */ - public function actionOrderDetail(string $orderId): \yii\web\Response + public function actionOrderDetail(string $orderId): Response { $order = Snipcart::$plugin->orders->getOrder($orderId); $orderRefunds = Snipcart::$plugin->orders->getOrderRefunds($orderId); - return $this->renderTemplate( 'snipcart/cp/orders/detail', [ @@ -75,11 +79,10 @@ public function actionOrderDetail(string $orderId): \yii\web\Response /** * Refunds an order. * - * @return \yii\web\Response - * @throws \craft\errors\MissingComponentException - * @throws \yii\web\BadRequestHttpException + * @throws MissingComponentException + * @throws BadRequestHttpException */ - public function actionRefund(): \yii\web\Response + public function actionRefund(): Response { $this->requirePostRequest(); @@ -101,9 +104,9 @@ public function actionRefund(): \yii\web\Response * @param string $extent `start` or `end` * * @return array|bool|\DateTime|false|int|string|null - * @throws \craft\errors\MissingComponentException + * @throws MissingComponentException */ - private function getDateRangeExtent($extent) + private function getDateRangeExtent(string $extent) { $request = Craft::$app->getRequest(); $session = Craft::$app->getSession(); @@ -166,5 +169,4 @@ private function getDateRangeExtent($extent) return $date; } - -} \ No newline at end of file +} diff --git a/src/controllers/OverviewController.php b/src/controllers/OverviewController.php index dcd73fb..68e1582 100644 --- a/src/controllers/OverviewController.php +++ b/src/controllers/OverviewController.php @@ -2,28 +2,30 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\controllers; -use fostercommerce\snipcart\Snipcart; -use fostercommerce\snipcart\helpers\FormatHelper; +use craft\web\Controller; +use yii\web\Response; +use yii\base\InvalidConfigException; +use Craft; use craft\helpers\DateTimeHelper; -use DateTimeZone; use DateTime; -use Craft; +use DateTimeZone; +use fostercommerce\snipcart\helpers\FormatHelper; +use fostercommerce\snipcart\Snipcart; -class OverviewController extends \craft\web\Controller +class OverviewController extends Controller { /** * Displays store overview. * - * @return \yii\web\Response * @throws */ - public function actionIndex(): \yii\web\Response + public function actionIndex(): Response { if (! Snipcart::$plugin->getSettings()->isConfigured()) { return $this->renderTemplate('snipcart/cp/welcome'); @@ -38,10 +40,9 @@ public function actionIndex(): \yii\web\Response /** * Gets the stats for the top panels. * - * @return \yii\web\Response * @throws */ - public function actionGetStats(): \yii\web\Response + public function actionGetStats(): Response { return $this->asJson( $this->getOverviewStats(true) @@ -51,10 +52,9 @@ public function actionGetStats(): \yii\web\Response /** * Gets the data for the recent order and top customer summary tables. * - * @return \yii\web\Response - * @throws \yii\base\InvalidConfigException + * @throws InvalidConfigException */ - public function actionGetOrdersCustomers(): \yii\web\Response + public function actionGetOrdersCustomers(): Response { return $this->asJson( $this->getOrderAndCustomerSummary(true) @@ -64,15 +64,13 @@ public function actionGetOrdersCustomers(): \yii\web\Response /** * Gets store statistics for the Snipcart landing/overview. * - * @param bool $preFormat - * @return array - * @throws \yii\base\InvalidConfigException + * @throws InvalidConfigException */ - private function getOverviewStats($preFormat = false): array + private function getOverviewStats(bool $preFormat = false): array { $startDate = $this->getStartDate(); - $endDate = $this->getEndDate(); - $stats = Snipcart::$plugin->data->getPerformance($startDate, $endDate); + $endDate = $this->getEndDate(); + $stats = Snipcart::$plugin->data->getPerformance($startDate, $endDate); if ($preFormat) { $defaultCurrency = Snipcart::$plugin->getSettings()->defaultCurrency; @@ -91,24 +89,26 @@ private function getOverviewStats($preFormat = false): array $defaultCurrency ); } - - return [ 'stats' => $stats ]; + + return [ + 'stats' => $stats, + ]; } /** * Gets recent order and top customer statistics. * - * @param bool $preFormat - * @return array - * @throws \yii\base\InvalidConfigException + * @throws InvalidConfigException */ - private function getOrderAndCustomerSummary($preFormat = false): array + private function getOrderAndCustomerSummary(bool $preFormat = false): array { $startDate = $this->getStartDate(); - $endDate = $this->getEndDate(); - $orders = Snipcart::$plugin->orders->listOrders(1, 10); + $endDate = $this->getEndDate(); + + $orders = Snipcart::$plugin->orders->listOrders(1, 10); + $customers = Snipcart::$plugin->customers->listCustomers(1, 10, [ - 'orderBy' => 'ordersValue' + 'orderBy' => 'ordersValue', ]); if ($preFormat) { @@ -134,11 +134,11 @@ private function getOrderAndCustomerSummary($preFormat = false): array $item['statistics']['ordersAmount'] = FormatHelper::formatCurrency($item['statistics']['ordersAmount']); } } - + return [ 'startDate' => $startDate, - 'endDate' => $endDate, - 'orders' => $orders, + 'endDate' => $endDate, + 'orders' => $orders, 'customers' => $customers, ]; } @@ -146,35 +146,44 @@ private function getOrderAndCustomerSummary($preFormat = false): array /** * Gets the beginning of the range used for visualizing stats. * - * @return DateTime * @throws */ private function getStartDate(): DateTime { $startDateParam = Craft::$app->getRequest()->getParam('startDate'); + if (! $startDateParam) { + return (new DateTime('now', new DateTimeZone(Craft::$app->getTimeZone()))) + ->modify('-1 month'); + } - if ($startDateParam && is_string($startDateParam)) { - return DateTimeHelper::toDateTime([ 'date' => $startDateParam ]); + if (! is_string($startDateParam)) { + return (new DateTime('now', new DateTimeZone(Craft::$app->getTimeZone()))) + ->modify('-1 month'); } - return (new DateTime('now', new DateTimeZone(Craft::$app->getTimeZone()))) - ->modify('-1 month'); + return DateTimeHelper::toDateTime([ + 'date' => $startDateParam, + ]); } /** * Gets the end of the range used for visualizing stats. * - * @return DateTime * @throws */ private function getEndDate(): DateTime { $endDateParam = Craft::$app->getRequest()->getParam('endDate'); + if (! $endDateParam) { + return new DateTime('now', new DateTimeZone(Craft::$app->getTimeZone())); + } - if ($endDateParam && is_string($endDateParam)) { - return DateTimeHelper::toDateTime([ 'date' => $endDateParam ]); + if (! is_string($endDateParam)) { + return new DateTime('now', new DateTimeZone(Craft::$app->getTimeZone())); } - return new DateTime('now', new DateTimeZone(Craft::$app->getTimeZone())); + return DateTimeHelper::toDateTime([ + 'date' => $endDateParam, + ]); } -} \ No newline at end of file +} diff --git a/src/controllers/ShipStationWebhooksController.php b/src/controllers/ShipStationWebhooksController.php index 9a278a8..bcba458 100644 --- a/src/controllers/ShipStationWebhooksController.php +++ b/src/controllers/ShipStationWebhooksController.php @@ -2,15 +2,15 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\controllers; -use craft\helpers\Json; - use Craft; + +use craft\helpers\Json; use craft\web\Controller; use yii\web\Response; @@ -24,7 +24,7 @@ class ShipStationWebhooksController extends Controller /** * @var bool Allow anonymous, unauthenticated access to our one method. */ - protected $allowAnonymous = true; + protected array|bool|int $allowAnonymous = true; /** * Handles the $_POST data that ShipStation sent, which is a raw body of JSON. @@ -40,32 +40,23 @@ public function actionHandle() * empty data or a bad format. */ return $this->badResponse([ - 'reason' => 'NULL response body or missing resource_type.' + 'reason' => 'NULL response body or missing resource_type.', ]); } - /** - * Respond to different types of Snipcart events—in this case only one. - */ - switch ($body->resource_type) { - case 'ORDER_NOTIFY': - return $this->handleOrderNotifyEvent($body); - case 'ITEM_ORDER_NOTIFY': - return $this->handleItemOrderNotifyEvent($body); - case 'SHIP_NOTIFY': - return $this->handleShipNotifyEvent($body); - case 'ITEM_SHIP_NOTIFY': - return $this->handleItemShipNotifyEvent($body); - default: - return $this->notSupportedResponse(); - } + return match ($body->resource_type) { + 'ORDER_NOTIFY' => $this->handleOrderNotifyEvent($body), + 'ITEM_ORDER_NOTIFY' => $this->handleItemOrderNotifyEvent($body), + 'SHIP_NOTIFY' => $this->handleShipNotifyEvent($body), + 'ITEM_SHIP_NOTIFY' => $this->handleItemShipNotifyEvent($body), + default => $this->notSupportedResponse(), + }; } /** * Responds to an order notification. (Currently, we don’t.) * - * @param $body Object ShipStation webhook payload - * @return Response + * @param object $body ShipStation webhook payload */ private function handleOrderNotifyEvent($body): Response { @@ -75,8 +66,7 @@ private function handleOrderNotifyEvent($body): Response /** * Responds to an *item* order notification. (Currently, we don’t.) * - * @param $body Object ShipStation webhook payload - * @return Response + * @param object $body ShipStation webhook payload */ private function handleItemOrderNotifyEvent($body): Response { @@ -86,21 +76,19 @@ private function handleItemOrderNotifyEvent($body): Response /** * Responds to a shipment notification. (Currently, we don’t.) * - * @param $body Object ShipStation webhook payload - * @return Response + * @param object $body ShipStation webhook payload */ private function handleShipNotifyEvent($body): Response { // TODO: notify customer that the order has shipped + provide tracking number - // follow $body->resource_url to get more information + // follow $body->resource_url to get more information return $this->notSupportedResponse(); } /** * Responds to an *item* shipment notification. (Currently, we don’t.) * - * @param $body Object ShipStation webhook payload - * @return Response + * @param object $body ShipStation webhook payload */ private function handleItemShipNotifyEvent($body): Response { @@ -117,11 +105,11 @@ private function badResponse(array $errors): Response { $response = Craft::$app->getResponse(); - $response->format = Response::FORMAT_JSON; + $response->format = Response::FORMAT_JSON; $response->content = json_encode([ 'success' => false, - 'errors' => $errors - ]); + 'errors' => $errors, + ], JSON_THROW_ON_ERROR); $response->setStatusCode(400, 'Bad Request'); @@ -131,8 +119,6 @@ private function badResponse(array $errors): Response /** * Sends back a 200 response so ShipStation knows we’re okay * but not handling the event. - * - * @return Response */ private function notSupportedResponse(): Response { @@ -141,5 +127,4 @@ private function notSupportedResponse(): Response return $response; } - -} \ No newline at end of file +} diff --git a/src/controllers/SubscriptionsController.php b/src/controllers/SubscriptionsController.php index 2aea329..8f3f496 100644 --- a/src/controllers/SubscriptionsController.php +++ b/src/controllers/SubscriptionsController.php @@ -2,35 +2,38 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\controllers; -use fostercommerce\snipcart\Snipcart; +use craft\web\Controller; +use yii\web\Response; +use craft\errors\MissingComponentException; +use yii\web\BadRequestHttpException; use Craft; +use fostercommerce\snipcart\Snipcart; -class SubscriptionsController extends \craft\web\Controller +class SubscriptionsController extends Controller { /** * Displays paginated list of subscriptions. * - * @return \yii\web\Response * @throws */ - public function actionIndex(): \yii\web\Response + public function actionIndex(): Response { - $page = Craft::$app->getRequest()->getPageNum(); + $page = Craft::$app->getRequest()->getPageNum(); $subscriptions = Snipcart::$plugin->subscriptions->listSubscriptions($page); - $totalPages = ceil($subscriptions->totalItems / $subscriptions->limit); + $totalPages = ceil($subscriptions->totalItems / $subscriptions->limit); return $this->renderTemplate( 'snipcart/cp/subscriptions/index', [ - 'pageNumber' => $page, - 'totalPages' => $totalPages, - 'totalItems' => $subscriptions->totalItems, + 'pageNumber' => $page, + 'totalPages' => $totalPages, + 'totalItems' => $subscriptions->totalItems, 'subscriptions' => $subscriptions->items, ] ); @@ -39,11 +42,9 @@ public function actionIndex(): \yii\web\Response /** * Displays subscription detail. * - * @param string $subscriptionId - * @return \yii\web\Response * @throws \Exception */ - public function actionDetail(string $subscriptionId): \yii\web\Response + public function actionDetail(string $subscriptionId): Response { $subscription = Snipcart::$plugin->subscriptions->getSubscription($subscriptionId); @@ -58,11 +59,10 @@ public function actionDetail(string $subscriptionId): \yii\web\Response /** * Cancels a subscription. * - * @return \yii\web\Response - * @throws \craft\errors\MissingComponentException - * @throws \yii\web\BadRequestHttpException + * @throws MissingComponentException + * @throws BadRequestHttpException */ - public function actionCancel(): \yii\web\Response + public function actionCancel(): Response { $this->requirePostRequest(); @@ -76,4 +76,4 @@ public function actionCancel(): \yii\web\Response return $this->redirectToPostedUrl(); } -} \ No newline at end of file +} diff --git a/src/controllers/TestController.php b/src/controllers/TestController.php index 5f9580e..accaa50 100644 --- a/src/controllers/TestController.php +++ b/src/controllers/TestController.php @@ -2,33 +2,33 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\controllers; +use yii\web\Response; use craft\web\Controller; class TestController extends Controller { public $enableCsrfValidation = false; // disable CSRF for this controller - protected $allowAnonymous = true; - + protected array|int|bool $allowAnonymous = true; + /** * Provides a simple webhook that makes sure the plugin is alive * and taking requests. Useful for keyword-based uptime check services. * * /actions/snipcart/test/check-health */ - public function actionCheckHealth(): \yii\web\Response + public function actionCheckHealth(): Response { $this->requirePostRequest(); - + return $this->asJson([ - 'status' => 'healthy' + 'status' => 'healthy', ]); } - } diff --git a/src/controllers/WebhooksController.php b/src/controllers/WebhooksController.php index b0a59ad..bc37623 100755 --- a/src/controllers/WebhooksController.php +++ b/src/controllers/WebhooksController.php @@ -2,83 +2,88 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\controllers; +use Craft; use craft\helpers\Json; +use craft\web\Controller; + use fostercommerce\snipcart\services\Webhooks; use fostercommerce\snipcart\Snipcart; - -use Craft; -use craft\web\Controller; -use yii\web\Response; -use yii\web\BadRequestHttpException; use yii\base\Exception; +use yii\web\BadRequestHttpException; +use yii\web\Response; class WebhooksController extends Controller { /** * Snipcart's available webhook events */ - const WEBHOOK_ORDER_COMPLETED = 'order.completed'; - const WEBHOOK_SHIPPINGRATES_FETCH = 'shippingrates.fetch'; - const WEBHOOK_ORDER_STATUS_CHANGED = 'order.status.changed'; - const WEBHOOK_ORDER_PAYMENT_STATUS_CHANGED = 'order.paymentStatus.changed'; - const WEBHOOK_ORDER_TRACKING_NUMBER_CHANGED = 'order.trackingNumber.changed'; - const WEBHOOK_SUBSCRIPTION_CREATED = 'subscription.created'; - const WEBHOOK_SUBSCRIPTION_CANCELLED = 'subscription.cancelled'; - const WEBHOOK_SUBSCRIPTION_PAUSED = 'subscription.paused'; - const WEBHOOK_SUBSCRIPTION_RESUMED = 'subscription.resumed'; - const WEBHOOK_SUBSCRIPTION_INVOICE_CREATED = 'subscription.invoice.created'; - const WEBHOOK_TAXES_CALCULATE = 'taxes.calculate'; - const WEBHOOK_CUSTOMER_UPDATED = 'customauth:customer_updated'; - const WEBHOOK_REFUND_CREATED = 'order.refund.created'; - const WEBHOOK_NOTIFICATION_CREATED = 'order.notification.created'; + public const WEBHOOK_ORDER_COMPLETED = 'order.completed'; + + public const WEBHOOK_SHIPPINGRATES_FETCH = 'shippingrates.fetch'; + + public const WEBHOOK_ORDER_STATUS_CHANGED = 'order.status.changed'; + + public const WEBHOOK_ORDER_PAYMENT_STATUS_CHANGED = 'order.paymentStatus.changed'; + + public const WEBHOOK_ORDER_TRACKING_NUMBER_CHANGED = 'order.trackingNumber.changed'; + + public const WEBHOOK_SUBSCRIPTION_CREATED = 'subscription.created'; + + public const WEBHOOK_SUBSCRIPTION_CANCELLED = 'subscription.cancelled'; + + public const WEBHOOK_SUBSCRIPTION_PAUSED = 'subscription.paused'; + + public const WEBHOOK_SUBSCRIPTION_RESUMED = 'subscription.resumed'; + + public const WEBHOOK_SUBSCRIPTION_INVOICE_CREATED = 'subscription.invoice.created'; + + public const WEBHOOK_TAXES_CALCULATE = 'taxes.calculate'; + + public const WEBHOOK_CUSTOMER_UPDATED = 'customauth:customer_updated'; + + public const WEBHOOK_REFUND_CREATED = 'order.refund.created'; + + public const WEBHOOK_NOTIFICATION_CREATED = 'order.notification.created'; /** * What we call to handle each event */ - const WEBHOOK_EVENT_MAP = [ - self::WEBHOOK_ORDER_COMPLETED => 'handleOrderCompleted', - self::WEBHOOK_SHIPPINGRATES_FETCH => 'handleShippingRatesFetch', - self::WEBHOOK_ORDER_STATUS_CHANGED => 'handleOrderStatusChange', - self::WEBHOOK_ORDER_PAYMENT_STATUS_CHANGED => 'handleOrderPaymentStatusChange', + public const WEBHOOK_EVENT_MAP = [ + self::WEBHOOK_ORDER_COMPLETED => 'handleOrderCompleted', + self::WEBHOOK_SHIPPINGRATES_FETCH => 'handleShippingRatesFetch', + self::WEBHOOK_ORDER_STATUS_CHANGED => 'handleOrderStatusChange', + self::WEBHOOK_ORDER_PAYMENT_STATUS_CHANGED => 'handleOrderPaymentStatusChange', self::WEBHOOK_ORDER_TRACKING_NUMBER_CHANGED => 'handleOrderTrackingNumberChange', - self::WEBHOOK_SUBSCRIPTION_CREATED => 'handleSubscriptionCreated', - self::WEBHOOK_SUBSCRIPTION_CANCELLED => 'handleSubscriptionCancelled', - self::WEBHOOK_SUBSCRIPTION_PAUSED => 'handleSubscriptionPaused', - self::WEBHOOK_SUBSCRIPTION_RESUMED => 'handleSubscriptionResumed', - self::WEBHOOK_SUBSCRIPTION_INVOICE_CREATED => 'handleSubscriptionInvoiceCreated', - self::WEBHOOK_TAXES_CALCULATE => 'handleTaxesCalculate', - self::WEBHOOK_CUSTOMER_UPDATED => 'handleCustomerUpdated', - self::WEBHOOK_REFUND_CREATED => 'handleRefundCreated', - self::WEBHOOK_NOTIFICATION_CREATED => 'handleNotificationCreated', + self::WEBHOOK_SUBSCRIPTION_CREATED => 'handleSubscriptionCreated', + self::WEBHOOK_SUBSCRIPTION_CANCELLED => 'handleSubscriptionCancelled', + self::WEBHOOK_SUBSCRIPTION_PAUSED => 'handleSubscriptionPaused', + self::WEBHOOK_SUBSCRIPTION_RESUMED => 'handleSubscriptionResumed', + self::WEBHOOK_SUBSCRIPTION_INVOICE_CREATED => 'handleSubscriptionInvoiceCreated', + self::WEBHOOK_TAXES_CALCULATE => 'handleTaxesCalculate', + self::WEBHOOK_CUSTOMER_UPDATED => 'handleCustomerUpdated', + self::WEBHOOK_REFUND_CREATED => 'handleRefundCreated', + self::WEBHOOK_NOTIFICATION_CREATED => 'handleNotificationCreated', ]; /** - * @inheritdoc * @var bool Disable CSRF for this controller */ - public $enableCsrfValidation = false; + // public bool $enableCsrfValidation = false; /** - * @inheritdoc * @var bool allow all endpoints in this controller to be used publicly */ - protected $allowAnonymous = true; + protected array|int|bool $allowAnonymous = true; - /** - * @var bool - */ - private static $validateWebhook = true; + private static bool $validateWebhook = true; - /** - * @inheritdoc - */ - public function init() + public function init(): void { parent::init(); @@ -91,7 +96,6 @@ public function init() /** * Validates and responds to the post request. * - * @return Response * @throws BadRequestHttpException if method isn't post or if something's * wrong with the post itself. * @throws Exception if the mapped handler method doesn't exist. @@ -104,7 +108,9 @@ public function actionHandle(): Response $payload = Json::decode($requestBody, false); if ($reason = $this->hasInvalidRequestData($payload)) { - return $this->badRequestResponse(['reason' => $reason ]); + return $this->badRequestResponse([ + 'reason' => $reason, + ]); } Snipcart::$plugin->webhooks->setData($payload); @@ -116,7 +122,6 @@ public function actionHandle(): Response * Sends the webhook’s POST payload to the appropriate handler method. * * @param string $eventName Event name from `WEBHOOK_EVENT_MAP`. - * @return Response * @throws Exception if the mapped handler method doesn’t exist. */ private function handleWebhookData($eventName): Response @@ -145,18 +150,16 @@ private function handleWebhookData($eventName): Response * Returns a 400 response with an optional JSON error array. * * @param array $errors Array of errors that explain the 400 response - * - * @return Response */ private function badRequestResponse(array $errors): Response { $response = Craft::$app->getResponse(); - $response->format = Response::FORMAT_JSON; + $response->format = Response::FORMAT_JSON; $response->content = json_encode([ 'success' => false, - 'errors' => $errors - ]); + 'errors' => $errors, + ], JSON_THROW_ON_ERROR); $response->setStatusCode(400, 'Bad Request'); @@ -167,10 +170,9 @@ private function badRequestResponse(array $errors): Response * Make sure we don’t have invalid data, or return a reason if we do. * * @param mixed $payload Decoded post payload to be checked. - * @return bool|string * @throws BadRequestHttpException if there's a problem with the token. */ - private function hasInvalidRequestData($payload) + private function hasInvalidRequestData(mixed $payload): bool|string { /** * Reject requests that can’t be validated. @@ -183,7 +185,7 @@ private function hasInvalidRequestData($payload) * Every Snipcart post should have an eventName, so we’ve got * missing data or a bad format. */ - if ($payload === null || !isset($payload->eventName)) { + if ($payload === null || ! isset($payload->eventName)) { return 'NULL request body or missing eventName.'; } @@ -236,7 +238,7 @@ private function hasInvalidRequestData($payload) */ private function requestIsValid(): bool { - $key = 'x-snipcart-requesttoken'; + $key = 'x-snipcart-requesttoken'; $headers = Craft::$app->getRequest()->getHeaders(); $devMode = Craft::$app->getConfig()->general->devMode; @@ -261,5 +263,4 @@ private function requestIsValid(): bool return Snipcart::$plugin->api->tokenIsValid($token); } - } diff --git a/src/db/Table.php b/src/db/Table.php index 2c24c34..7d8309b 100644 --- a/src/db/Table.php +++ b/src/db/Table.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2020 Working Concept Inc. */ @@ -10,7 +10,9 @@ abstract class Table { - const WEBHOOK_LOG = '{{%snipcart_webhook_log}}'; - const SHIPPING_QUOTES = '{{%snipcart_shipping_quotes}}'; - const PRODUCT_DETAILS = '{{%snipcart_product_details}}'; -} \ No newline at end of file + public const WEBHOOK_LOG = '{{%snipcart_webhook_log}}'; + + public const SHIPPING_QUOTES = '{{%snipcart_shipping_quotes}}'; + + public const PRODUCT_DETAILS = '{{%snipcart_product_details}}'; +} diff --git a/src/errors/ShippingRateException.php b/src/errors/ShippingRateException.php index e36f0d9..cf208a7 100644 --- a/src/errors/ShippingRateException.php +++ b/src/errors/ShippingRateException.php @@ -11,13 +11,14 @@ class ShippingRateException extends \Exception */ public $event; - public function __construct(ShippingRateEvent $event, string $message = null, int $code = 0, \Throwable $previous = null) { - $this->event = $event; + public function __construct(ShippingRateEvent $shippingRateEvent, string $message = null, int $code = 0, \Throwable $throwable = null) + { + $this->event = $shippingRateEvent; if ($message === null) { - $message = 'An error occurred while fetching the shipping rates for order "' . ($event->order->invoiceNumber ?? $event->order->token) . '": ' . implode(', ', array_column($event->getErrors(), 'message')); + $message = 'An error occurred while fetching the shipping rates for order "' . ($shippingRateEvent->order->invoiceNumber ?? $shippingRateEvent->order->token) . '": ' . implode(', ', array_column($shippingRateEvent->getErrors(), 'message')); } - parent::__construct($message, $code, $previous); + parent::__construct($message, $code, $throwable); } } diff --git a/src/events/CustomerEvent.php b/src/events/CustomerEvent.php index 6c68785..d450f71 100644 --- a/src/events/CustomerEvent.php +++ b/src/events/CustomerEvent.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -14,7 +14,7 @@ /** * Customer event class. * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ class CustomerEvent extends Event @@ -23,5 +23,4 @@ class CustomerEvent extends Event * @var Customer */ public $customer; - } diff --git a/src/events/InventoryEvent.php b/src/events/InventoryEvent.php index f055e28..a592552 100644 --- a/src/events/InventoryEvent.php +++ b/src/events/InventoryEvent.php @@ -2,20 +2,20 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\events; use craft\base\Element; -use yii\base\Event; use craft\elements\Entry; +use yii\base\Event; /** * Inventory event class. * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ class InventoryEvent extends Event @@ -35,5 +35,4 @@ class InventoryEvent extends Event * @var int The value (+/-) that should be added to the existing inventory. */ public $quantity; - } diff --git a/src/events/OrderEvent.php b/src/events/OrderEvent.php index 9c9ffff..1f1e9d7 100644 --- a/src/events/OrderEvent.php +++ b/src/events/OrderEvent.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -14,7 +14,7 @@ /** * Order event class. * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ class OrderEvent extends Event @@ -23,5 +23,4 @@ class OrderEvent extends Event * @var Order */ public $order; - } diff --git a/src/events/OrderNotificationEvent.php b/src/events/OrderNotificationEvent.php index 62aa5bd..9ac4777 100644 --- a/src/events/OrderNotificationEvent.php +++ b/src/events/OrderNotificationEvent.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2020 Working Concept Inc. */ @@ -14,15 +14,13 @@ /** * Order refund event class. * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2020 Working Concept Inc. */ class OrderNotificationEvent extends Event { - /** * @var Notification */ public $notification; - } diff --git a/src/events/OrderRefundEvent.php b/src/events/OrderRefundEvent.php index 27fb57d..8fe65ad 100644 --- a/src/events/OrderRefundEvent.php +++ b/src/events/OrderRefundEvent.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2020 Working Concept Inc. */ @@ -14,7 +14,7 @@ /** * Order refund event class. * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2020 Working Concept Inc. */ class OrderRefundEvent extends Event diff --git a/src/events/OrderStatusEvent.php b/src/events/OrderStatusEvent.php index 3470e9b..68ba12a 100644 --- a/src/events/OrderStatusEvent.php +++ b/src/events/OrderStatusEvent.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -14,7 +14,7 @@ /** * Order status event class. * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ class OrderStatusEvent extends Event @@ -33,5 +33,4 @@ class OrderStatusEvent extends Event * @var string */ public $toStatus; - } diff --git a/src/events/OrderTrackingEvent.php b/src/events/OrderTrackingEvent.php index 86f4f32..4f1decd 100644 --- a/src/events/OrderTrackingEvent.php +++ b/src/events/OrderTrackingEvent.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -14,7 +14,7 @@ /** * Order tracking event class. * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ class OrderTrackingEvent extends Event @@ -33,5 +33,4 @@ class OrderTrackingEvent extends Event * @var string */ public $trackingUrl; - } diff --git a/src/events/RegisterShippingProvidersEvent.php b/src/events/RegisterShippingProvidersEvent.php index 0ceb216..78b6b31 100644 --- a/src/events/RegisterShippingProvidersEvent.php +++ b/src/events/RegisterShippingProvidersEvent.php @@ -2,19 +2,19 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\events; -use yii\base\Event; use fostercommerce\snipcart\base\ShippingProvider; +use yii\base\Event; /** * Register shipping provider event class. * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ class RegisterShippingProvidersEvent extends Event @@ -22,6 +22,5 @@ class RegisterShippingProvidersEvent extends Event /** * @var ShippingProvider[] */ - public $shippingProviders; - + public $shippingProviders = []; } diff --git a/src/events/ShippingRateEvent.php b/src/events/ShippingRateEvent.php index ffddda8..54a460b 100644 --- a/src/events/ShippingRateEvent.php +++ b/src/events/ShippingRateEvent.php @@ -2,21 +2,21 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\events; +use craft\events\CancelableEvent; use fostercommerce\snipcart\models\snipcart\Order; -use fostercommerce\snipcart\models\snipcart\ShippingRate; use fostercommerce\snipcart\models\snipcart\Package; -use craft\events\CancelableEvent; +use fostercommerce\snipcart\models\snipcart\ShippingRate; /** * Shipping rate event class. * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ class ShippingRateEvent extends CancelableEvent @@ -29,7 +29,7 @@ class ShippingRateEvent extends CancelableEvent /** * @var ShippingRate[] */ - public $rates; + public $rates = []; /** * @var Package @@ -39,7 +39,7 @@ class ShippingRateEvent extends CancelableEvent /** * @var array[] with 'key' and 'message' keys */ - public $errors; + public $errors = []; public function getErrors() { diff --git a/src/events/SubscriptionEvent.php b/src/events/SubscriptionEvent.php index d01ba7a..0a9d398 100644 --- a/src/events/SubscriptionEvent.php +++ b/src/events/SubscriptionEvent.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -14,7 +14,7 @@ /** * Subscription event class. * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ class SubscriptionEvent extends Event @@ -23,5 +23,4 @@ class SubscriptionEvent extends Event * @var Subscription */ public $subscription; - } diff --git a/src/events/TaxesEvent.php b/src/events/TaxesEvent.php index 07604a9..a6177ae 100644 --- a/src/events/TaxesEvent.php +++ b/src/events/TaxesEvent.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -15,7 +15,7 @@ /** * Taxes event class. * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ class TaxesEvent extends Event @@ -28,6 +28,5 @@ class TaxesEvent extends Event /** * @var Tax[] */ - public $taxes; - + public $taxes = []; } diff --git a/src/fields/ProductDetails.php b/src/fields/ProductDetails.php index f0f73d9..dde1191 100644 --- a/src/fields/ProductDetails.php +++ b/src/fields/ProductDetails.php @@ -2,51 +2,51 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\fields; -use craft\helpers\Localization; -use fostercommerce\snipcart\db\Table; -use fostercommerce\snipcart\helpers\VersionHelper; -use fostercommerce\snipcart\Snipcart; -use fostercommerce\snipcart\models\ProductDetails as ProductDetailsModel; -use fostercommerce\snipcart\assetbundles\ProductDetailsFieldAsset; -use Craft; use craft\base\ElementInterface; -use craft\elements\db\ElementQuery; -use craft\elements\db\ElementQueryInterface; -use craft\helpers\Db; +use Craft; +use craft\base\Field; use craft\gql\GqlEntityRegistry; use craft\gql\TypeLoader; -use GraphQL\Type\Definition\Type; +use fostercommerce\snipcart\assetbundles\ProductDetailsFieldAsset; +use fostercommerce\snipcart\db\Table; +use fostercommerce\snipcart\helpers\VersionHelper; +use fostercommerce\snipcart\models\ProductDetails as ProductDetailsModel; +use fostercommerce\snipcart\Snipcart; +use fostercommerce\snipcart\validators\ProductDetailsValidator; use GraphQL\Type\Definition\ObjectType; -use yii\base\UnknownPropertyException; +use GraphQL\Type\Definition\Type; +use LitEmoji\LitEmoji; +use yii\db\Schema; /** * ProductDetails * * @property ProductDetails $value */ -class ProductDetails extends \craft\base\Field +class ProductDetails extends Field { /** - * @inheritdoc - */ - public static function displayName(): string - { - return Craft::t('snipcart', 'Snipcart Product Details'); - } - - /** - * @return bool + * @var string The type of database column the field should have in the content table */ - public static function hasContentColumn(): bool - { - return false; - } + public $columnType = [ + 'sku' => Schema::TYPE_STRING, + 'inventory' => Schema::TYPE_INTEGER, + 'price' => Schema::TYPE_MONEY, + 'taxable' => Schema::TYPE_BOOLEAN, + 'shippable' => Schema::TYPE_BOOLEAN, + 'weight' => Schema::TYPE_FLOAT, + 'weightUnit' => Schema::TYPE_STRING, + 'length' => Schema::TYPE_FLOAT, + 'width' => Schema::TYPE_FLOAT, + 'height' => Schema::TYPE_FLOAT, + 'dimensionsUnit' => Schema::TYPE_STRING, + ]; /** * @var bool Whether to display "shippable" option for this field instance @@ -57,7 +57,6 @@ public static function hasContentColumn(): bool /** * @var bool Whether to display "taxable" option for this field instance * and allow it to be set per entry. - * */ public $displayTaxableSwitch = false; @@ -111,34 +110,24 @@ public static function hasContentColumn(): bool */ public $skuDefault = ''; - /** - * Saves the Product Details data to table after element save. - * - * @inheritdoc - */ - public function afterElementSave(ElementInterface $element, bool $isNew) + public static function displayName(): string { - Snipcart::$plugin->fields->saveProductDetailsField( - $this, - $element - ); + return Craft::t('snipcart', 'Snipcart Product Details'); + } - parent::afterElementSave($element, $isNew); + public static function hasContentColumn(): bool + { + return true; } - /** - * Saves the Product Details data to table after element propagation. - * - * @inheritdoc - */ - public function afterElementPropagate(ElementInterface $element, bool $isNew) + public function init(): void { - Snipcart::$plugin->fields->saveProductDetailsField( - $this, - $element - ); + parent::init(); + } - parent::afterElementPropagate($element, $isNew); + public function getContentColumnType(): array|string + { + return $this->columnType; } /** @@ -146,7 +135,7 @@ public function afterElementPropagate(ElementInterface $element, bool $isNew) * * @inheritdoc */ - public function normalizeValue($value, ElementInterface $element = null) + public function normalizeValue(mixed $value, ?ElementInterface $element = null): mixed { return Snipcart::$plugin->fields->getProductDetailsField( $this, @@ -155,102 +144,67 @@ public function normalizeValue($value, ElementInterface $element = null) ); } - /** - * @inheritdoc - */ - public function modifyElementsQuery(ElementQueryInterface $query, $value) + public function serializeValue(mixed $value, ?ElementInterface $element = null): mixed { - $queryable = [ - 'sku', - 'price', - 'shippable', - 'taxable', - 'weight', - 'length', - 'width', - 'height', - 'inventory' - ]; - - $subQueries = []; - if ($value !== null) { - if (! is_array($value)) { - return false; - } - - foreach ($value as $key => $val) { - if (! in_array($key, $queryable, false)) { - throw new UnknownPropertyException( - 'Setting unknown property: ' . get_class($this) . '::' . $key - ); + foreach ($value as $k => $v) { + if (is_array($v)) { + continue; } - $subQueries['snipcart_product_details.' . $key] = $value; - } - - if (count($subQueries) > 0) { - /** @var ElementQuery $query */ - $query->subQuery->innerJoin( - Table::PRODUCT_DETAILS . ' snipcart_product_details', - '[[snipcart_product_details.elementId]] = [[elements.id]]' - ); - - $query->subQuery->andWhere( - Db::parseParam('snipcart_product_details.fieldId', $this->id) - ); + if ($v === null) { + continue; + } - foreach ($subQueries as $column => $val) { - $query->subQuery->andWhere(Db::parseParam($column, $val)); + if (is_string($v)) { + $value[$k] = LitEmoji::unicodeToShortcode($v); + } elseif ($v instanceof \Stringable) { + $value[$k] = LitEmoji::unicodeToShortcode($v->__toString()); + } else { + $value[$k] = $v; } } } - return null; + return $value; } /** - * @inheritdoc * @since 3.3.0 */ - public function getContentGqlType() + public function getContentGqlType(): array { - $typeName = $this->handle.'_SnipcartField'; + $typeName = $this->handle . '_SnipcartField'; $productDetailsType = GqlEntityRegistry::getEntity($typeName) ?: GqlEntityRegistry::createEntity($typeName, new ObjectType([ - 'name' => $typeName, + 'name' => $typeName, 'fields' => [ - 'sku' => Type::string(), - 'price' => Type::float(), - 'shippable' => Type::boolean(), - 'taxable' => Type::boolean(), - 'weight' => Type::float(), - 'weightUnit' => Type::string(), - 'length' => Type::float(), - 'width' => Type::float(), - 'height' => Type::float(), - 'inventory' => Type::int(), + 'sku' => Type::string(), + 'price' => Type::float(), + 'shippable' => Type::boolean(), + 'taxable' => Type::boolean(), + 'weight' => Type::float(), + 'weightUnit' => Type::string(), + 'length' => Type::float(), + 'width' => Type::float(), + 'height' => Type::float(), + 'inventory' => Type::int(), 'dimensionsUnit' => Type::string(), ], ])); TypeLoader::registerType( $typeName, - static function () use ($productDetailsType) { - return $productDetailsType; - } + static fn(): mixed => $productDetailsType ); return $productDetailsType; } - /** - * @inheritdoc - */ public function getInputHtml( - $value, - ElementInterface $element = null + mixed $value, + ?ElementInterface $element = null, ): string { Craft::$app->getView()->registerAssetBundle( ProductDetailsFieldAsset::class @@ -259,21 +213,18 @@ public function getInputHtml( return Craft::$app->getView()->renderTemplate( 'snipcart/fields/product-details/field', [ - 'name' => $this->handle, - 'field' => $this, - 'element' => $element, - 'value' => $value, - 'settings' => $this->getSettings(), - 'weightUnitOptions' => ProductDetailsModel::getWeightUnitOptions(), + 'name' => $this->handle, + 'field' => $this, + 'element' => $element, + 'value' => $value, + 'settings' => $this->getSettings(), + 'weightUnitOptions' => ProductDetailsModel::getWeightUnitOptions(), 'dimensionsUnitOptions' => ProductDetailsModel::getDimensionsUnitOptions(), - 'isCraft34' => VersionHelper::isCraft34() + 'isCraft34' => VersionHelper::isCraft34(), ] ); } - /** - * @inheritdoc - */ public function getSettingsHtml(): string { Craft::$app->getView()->registerAssetBundle( @@ -283,8 +234,8 @@ public function getSettingsHtml(): string return Craft::$app->getView()->renderTemplate( 'snipcart/fields/product-details/settings', [ - 'field' => $this, - 'weightUnitOptions' => ProductDetailsModel::getWeightUnitOptions(), + 'field' => $this, + 'weightUnitOptions' => ProductDetailsModel::getWeightUnitOptions(), 'dimensionsUnitOptions' => ProductDetailsModel::getDimensionsUnitOptions(), ] ); @@ -299,39 +250,11 @@ public function getSettingsHtml(): string public function getElementValidationRules(): array { return [ - 'validateProductDetails', + [ + ProductDetailsValidator::class, + ], ]; } - - /** - * Validates the ProductDetails model, adding errors to the Element. - * - * @param ElementInterface $element - */ - public function validateProductDetails(ElementInterface $element) - { - $productDetails = $element->getFieldValue($this->handle); - - if ($element->isFieldDirty($this->handle)) { - // first normalize a new value that came from the control panel - $productDetails->price = Localization::normalizeNumber($productDetails->price); - } - - $productDetails->validate(); - - $errors = $productDetails->getErrors(); - - if (count($errors) > 0) { - foreach ($errors as $subfield => $subErrors) { - foreach ($subErrors as $message) { - $element->addError( - $this->handle.'['.$subfield.']', - $message - ); - } - } - } - } } -class_alias(ProductDetails::class, \workingconcept\snipcart\fields\ProductDetails::class); +//class_alias(ProductDetails::class, \fostercommerce\snipcart\fields\ProductDetails::class); diff --git a/src/helpers/CraftQlHelper.php b/src/helpers/CraftQlHelper.php index 32f2c44..257d021 100644 --- a/src/helpers/CraftQlHelper.php +++ b/src/helpers/CraftQlHelper.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -17,68 +17,46 @@ class CraftQlHelper * field information. * * @param string $handle Field handle - * @param SchemaBuilder $schema Schema instance + * @param SchemaBuilder $schemaBuilder Schema instance * * @return SchemaBuilder */ - public static function addFieldTypeToSchema(string $handle, SchemaBuilder $schema) + public static function addFieldTypeToSchema(string $handle, SchemaBuilder $schemaBuilder): mixed // @phpstan-ignore-line { - $outputSchema = $schema->createObjectType(ucfirst($handle).'FieldData'); + $outputSchema = $schemaBuilder->createObjectType(ucfirst($handle) . 'FieldData'); $outputSchema->addFloatField('price') - ->resolve(static function ($root) { - return (float)$root->price; - }); + ->resolve(static fn($root): float => (float) $root->price); $outputSchema->addStringField('sku') - ->resolve(static function ($root) { - return (string)$root->sku; - }); + ->resolve(static fn($root): string => (string) $root->sku); $outputSchema->addBooleanField('shippable') - ->resolve(static function ($root) { - return (boolean)$root->shippable; - }); + ->resolve(static fn($root): bool => (bool) $root->shippable); $outputSchema->addBooleanField('taxable') - ->resolve(static function ($root) { - return (boolean)$root->taxable; - }); + ->resolve(static fn($root): bool => (bool) $root->taxable); $outputSchema->addFloatField('weight') - ->resolve(static function ($root) { - return (float)$root->weight; - }); + ->resolve(static fn($root): float => (float) $root->weight); $outputSchema->addStringField('weightUnit') - ->resolve(static function ($root) { - return (string)$root->weightUnit; - }); + ->resolve(static fn($root): string => (string) $root->weightUnit); $outputSchema->addFloatField('length') - ->resolve(static function ($root) { - return (float)$root->length; - }); + ->resolve(static fn($root): float => (float) $root->length); $outputSchema->addFloatField('width') - ->resolve(static function ($root) { - return (float)$root->width; - }); + ->resolve(static fn($root): float => (float) $root->width); $outputSchema->addFloatField('height') - ->resolve(static function ($root) { - return (float)$root->height; - }); + ->resolve(static fn($root): float => (float) $root->height); $outputSchema->addStringField('dimensionsUnit') - ->resolve(static function ($root) { - return (string)$root->dimensionsUnit; - }); + ->resolve(static fn($root): string => (string) $root->dimensionsUnit); $outputSchema->addIntField('inventory') - ->resolve(static function ($root) { - return (int)$root->inventory; - }); + ->resolve(static fn($root): int => (int) $root->inventory); return $outputSchema; } diff --git a/src/helpers/FieldHelper.php b/src/helpers/FieldHelper.php index aced73a..5e8a742 100644 --- a/src/helpers/FieldHelper.php +++ b/src/helpers/FieldHelper.php @@ -2,12 +2,14 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\helpers; +use craft\base\Element; +use craft\models\FieldLayout; use fostercommerce\snipcart\fields\ProductDetails; /** @@ -19,7 +21,7 @@ class FieldHelper * Returns product info for the provided Element regardless of the * field handle. * - * @param \craft\base\Element $element + * @param Element $element * * @return ProductDetails|null */ @@ -30,13 +32,17 @@ public static function getProductInfo($element) return null; } - if (($fieldLayout = $element->getFieldLayout()) - && $fields = $fieldLayout->getFields() - ) { - foreach ($fields as $field) { - if ($field instanceof ProductDetails) { - return $element->getFieldValue($field->handle); - } + if (! ($fieldLayout = $element->getFieldLayout()) instanceof FieldLayout) { + return null; + } + + if (($fields = $fieldLayout->getCustomFields()) === []) { + return null; + } + + foreach ($fields as $field) { + if ($field instanceof ProductDetails) { + return $element->getFieldValue($field->handle); } } @@ -47,19 +53,17 @@ public static function getProductInfo($element) * Returns the field handle for the Element’s Product Details field, * if it exists. * - * @param \craft\base\Element $element - * - * @return string|null + * @param Element $element */ - public static function getProductInfoFieldHandle($element) + public static function getProductInfoFieldHandle($element): ?string { // if we don't have an Element, there's nothing to get if (! isset($element)) { return null; } - if ($fieldLayout = $element->getFieldLayout()) { - $fields = $fieldLayout->getFields(); + if (($fieldLayout = $element->getFieldLayout()) instanceof FieldLayout) { + $fields = $fieldLayout->getCustomFields(); foreach ($fields as $field) { if ($field instanceof ProductDetails) { diff --git a/src/helpers/FormatHelper.php b/src/helpers/FormatHelper.php index 8aa8c65..a6dc10f 100644 --- a/src/helpers/FormatHelper.php +++ b/src/helpers/FormatHelper.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2019 Working Concept Inc. */ @@ -23,10 +23,9 @@ class FormatHelper * @param string $currencyType Optional string representing desired currency * to be explicitly set. * - * @return string * @throws InvalidConfigException if no currency is given and [[currencyCode]] is not defined. */ - public static function formatCurrency($value, $currencyType = null): string + public static function formatCurrency(mixed $value, $currencyType = null): string { if (is_string($value)) { $includesSymbol = self::containsSupportedCurrencySymbol($value); @@ -57,23 +56,21 @@ public static function formatCurrency($value, $currencyType = null): string * * @param string $value * @param string|null $currencyType - * - * @return bool */ public static function containsSupportedCurrencySymbol($value, $currencyType = null): bool { $supportedSymbols = Settings::getCurrencySymbols(); if ($currencyType) { - if ( ! array_key_exists($currencyType, $supportedSymbols)) { + if (! array_key_exists($currencyType, $supportedSymbols)) { return false; } - return strpos($value, $supportedSymbols[$currencyType]) !== false; + return str_contains($value, $supportedSymbols[$currencyType]); } foreach ($supportedSymbols as $currency => $symbol) { - if (strpos($value, $symbol) !== false) { + if (str_contains($value, $symbol)) { return true; } } @@ -90,15 +87,11 @@ public static function containsSupportedCurrencySymbol($value, $currencyType = n * - `12d` * - `2h` or `1h` * - `<1h` (no minutes or seconds) - * - * @param \DateTime $date - * - * @return string */ - public static function tinyDateInterval(\DateTime $date): string + public static function tinyDateInterval(\DateTime $dateTime): string { - $now = new DateTimeImmutable(); - $interval = $now->diff($date); + $dateTimeImmutable = new DateTimeImmutable(); + $interval = $dateTimeImmutable->diff($dateTime); if ($interval->y > 0) { return $interval->y . 'y'; @@ -126,10 +119,11 @@ public static function tinyDateInterval(\DateTime $date): string * * @return string|string[]|null */ - private static function normalizeCurrencyValue($value) { + private static function normalizeCurrencyValue($value): string|array|null + { return preg_replace( "/[^0-9\.]/", - "", + '', $value ); } diff --git a/src/helpers/MeasurementHelper.php b/src/helpers/MeasurementHelper.php index 2c39edf..b55b665 100644 --- a/src/helpers/MeasurementHelper.php +++ b/src/helpers/MeasurementHelper.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -15,10 +15,6 @@ class MeasurementHelper { /** * Converts pounds to grams. - * - * @param float $pounds - * - * @return float */ public static function poundsToGrams(float $pounds): float { @@ -27,10 +23,6 @@ public static function poundsToGrams(float $pounds): float /** * Converts ounces to grams. - * - * @param float $ounces - * - * @return float */ public static function ouncesToGrams(float $ounces): float { @@ -39,10 +31,6 @@ public static function ouncesToGrams(float $ounces): float /** * Converts inches to centimeters. - * - * @param float $inches - * - * @return float */ public static function inchesToCentimeters(float $inches): float { diff --git a/src/helpers/ModelHelper.php b/src/helpers/ModelHelper.php index 8b7b614..b5db6d8 100644 --- a/src/helpers/ModelHelper.php +++ b/src/helpers/ModelHelper.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -19,8 +19,6 @@ class ModelHelper * * @param array $array array where each item can be transformed into model * @param string $class name of desired model class - * - * @return array */ public static function populateArrayWithModels(array $array, $class): array { @@ -40,8 +38,9 @@ public static function populateArrayWithModels(array $array, $class): array * * @return mixed */ - public static function safePopulateModel($data, $class) + public static function safePopulateModel(mixed $data, string $class) { + //\Craft::dd((object)$data); $cleanData = self::stripUnknownProperties($data, $class); return new $class($cleanData); @@ -54,13 +53,11 @@ public static function safePopulateModel($data, $class) * @param array $array Array in which each item contains data for * populating a model. * @param string $class Model to be populated. - * - * @return array */ - public static function safePopulateArrayWithModels(array $array, $class): array + public static function safePopulateArrayWithModels(array $array, string $class): array { foreach ($array as &$item) { - $item = self::safePopulateModel($item, $class); + $item = self::safePopulateModel((array) $item, $class); } return $array; @@ -73,13 +70,14 @@ public static function safePopulateArrayWithModels(array $array, $class): array * @param object $data Object with data, like a webhook payload. * @param string $class Model to be populated, which can't receive any * unknown attributes. - * @return object + * @return array * @throws */ - public static function stripUnknownProperties($data, $class) + public static function stripUnknownProperties(mixed $data, string $class): mixed { + // instantiate the model so we can poke at it - $model = new $class; + $model = new $class(); // get normal model attributes $fields = array_keys($model->fields()); diff --git a/src/helpers/RouteHelper.php b/src/helpers/RouteHelper.php index 516a1fb..0ba56d2 100644 --- a/src/helpers/RouteHelper.php +++ b/src/helpers/RouteHelper.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -12,8 +12,6 @@ class RouteHelper { /** * Returns an array of control panel routes. - * - * @return array */ public static function getCpRoutes(): array { diff --git a/src/helpers/VersionHelper.php b/src/helpers/VersionHelper.php index 985b34a..ebab272 100644 --- a/src/helpers/VersionHelper.php +++ b/src/helpers/VersionHelper.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2019 Working Concept Inc. */ @@ -12,8 +12,6 @@ class VersionHelper { /** * Returns true if the current Craft version is 3.1 or greater. - * - * @return bool */ public static function isCraft31(): bool { @@ -26,8 +24,6 @@ public static function isCraft31(): bool /** * Returns true if the current Craft version is 3.2 or greater. - * - * @return bool */ public static function isCraft32(): bool { @@ -40,8 +36,6 @@ public static function isCraft32(): bool /** * Returns true if the current Craft version is 3.4 or greater. - * - * @return bool */ public static function isCraft34(): bool { diff --git a/src/migrations/Install.php b/src/migrations/Install.php index ee0dd9e..6e4726c 100644 --- a/src/migrations/Install.php +++ b/src/migrations/Install.php @@ -2,58 +2,53 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\migrations; -use fostercommerce\snipcart\db\Table; -use fostercommerce\snipcart\models\ProductDetails; -use fostercommerce\snipcart\controllers\WebhooksController; use Craft; use craft\db\Migration; use craft\helpers\MigrationHelper; +use fostercommerce\snipcart\controllers\WebhooksController; +use fostercommerce\snipcart\db\Table; +use fostercommerce\snipcart\models\ProductDetails; /** * m181205_000036_api_log migration. */ class Install extends Migration { - /** - * @inheritdoc - */ public function safeUp(): bool { $this->createTables(); return true; } - /** - * @inheritdoc - */ public function safeDown(): bool { - $this->dropForeignKeys(); - $this->dropTables(); - $this->dropProjectConfig(); + // don't remove the tables yet while we are testing + //$this->dropForeignKeys(); + //$this->dropTables(); + //$this->dropProjectConfig(); return true; } - private function createTables() + private function createTables(): void { if (! $this->getDb()->tableExists(Table::WEBHOOK_LOG)) { $typeValues = array_keys(WebhooksController::WEBHOOK_EVENT_MAP); $this->createTable(Table::WEBHOOK_LOG, [ - 'id' => $this->primaryKey(), - 'siteId' => $this->integer(), - 'type' => $this->enum('type', $typeValues), - 'mode' => $this->enum('mode', ['live', 'test']), - 'body' => $this->longText(), + 'id' => $this->primaryKey(), + 'siteId' => $this->integer(), + 'type' => $this->enum('type', $typeValues), + 'mode' => $this->enum('mode', ['live', 'test']), + 'body' => $this->longText(), 'dateCreated' => $this->dateTime()->notNull(), 'dateUpdated' => $this->dateTime()->notNull(), - 'uid' => $this->uid(), + 'uid' => $this->uid(), ]); $this->createIndex(null, Table::WEBHOOK_LOG, ['siteId']); @@ -62,13 +57,13 @@ private function createTables() if (! $this->getDb()->tableExists(Table::SHIPPING_QUOTES)) { $this->createTable(Table::SHIPPING_QUOTES, [ - 'id' => $this->primaryKey(), - 'siteId' => $this->integer(), - 'token' => $this->text(), - 'body' => $this->mediumText(), + 'id' => $this->primaryKey(), + 'siteId' => $this->integer(), + 'token' => $this->text(), + 'body' => $this->mediumText(), 'dateCreated' => $this->dateTime()->notNull(), 'dateUpdated' => $this->dateTime()->notNull(), - 'uid' => $this->uid(), + 'uid' => $this->uid(), ]); $this->createIndex(null, Table::SHIPPING_QUOTES, ['siteId']); @@ -85,25 +80,25 @@ private function createTables() ); $this->createTable(Table::PRODUCT_DETAILS, [ - 'id' => $this->primaryKey(), - 'elementId' => $this->integer()->notNull(), - 'fieldId' => $this->integer()->notNull(), - 'siteId' => $this->integer(), - 'sku' => $this->string(), - 'price' => $this->decimal(14, 2)->unsigned(), - 'shippable' => $this->boolean(), - 'taxable' => $this->boolean(), - 'weight' => $this->decimal(12, 2)->unsigned(), - 'weightUnit' => $this->enum('weightUnit', $weightUnitOptions), - 'length' => $this->decimal(12, 2)->unsigned(), - 'width' => $this->decimal(12, 2)->unsigned(), - 'height' => $this->decimal(12, 2)->unsigned(), + 'id' => $this->primaryKey(), + 'elementId' => $this->integer()->notNull(), + 'fieldId' => $this->integer()->notNull(), + 'siteId' => $this->integer(), + 'sku' => $this->string(), + 'price' => $this->decimal(14, 2)->unsigned(), + 'shippable' => $this->boolean(), + 'taxable' => $this->boolean(), + 'weight' => $this->decimal(12, 2)->unsigned(), + 'weightUnit' => $this->enum('weightUnit', $weightUnitOptions), + 'length' => $this->decimal(12, 2)->unsigned(), + 'width' => $this->decimal(12, 2)->unsigned(), + 'height' => $this->decimal(12, 2)->unsigned(), 'dimensionsUnit' => $this->enum('dimensionsUnit', $dimensionsUnitOptions), - 'inventory' => $this->integer(), - 'customOptions' => $this->longText(), - 'dateCreated' => $this->dateTime()->notNull(), - 'dateUpdated' => $this->dateTime()->notNull(), - 'uid' => $this->uid(), + 'inventory' => $this->integer(), + 'customOptions' => $this->longText(), + 'dateCreated' => $this->dateTime()->notNull(), + 'dateUpdated' => $this->dateTime()->notNull(), + 'uid' => $this->uid(), ]); $this->createIndex(null, Table::PRODUCT_DETAILS, ['elementId']); @@ -116,12 +111,12 @@ private function createTables() } } - private function dropForeignKeys() + private function dropForeignKeys(): void { $tables = [ Table::WEBHOOK_LOG, Table::SHIPPING_QUOTES, - Table::PRODUCT_DETAILS + Table::PRODUCT_DETAILS, ]; foreach ($tables as $table) { @@ -132,14 +127,14 @@ private function dropForeignKeys() } } - private function dropTables() + private function dropTables(): void { $this->dropTableIfExists(Table::WEBHOOK_LOG); $this->dropTableIfExists(Table::SHIPPING_QUOTES); $this->dropTableIfExists(Table::PRODUCT_DETAILS); } - private function dropProjectConfig() + private function dropProjectConfig(): void { Craft::$app->projectConfig->remove('snipcart'); } diff --git a/src/migrations/m190304_034411_allow_null_sku.php b/src/migrations/m190304_034411_allow_null_sku.php index a91349f..a8d230b 100644 --- a/src/migrations/m190304_034411_allow_null_sku.php +++ b/src/migrations/m190304_034411_allow_null_sku.php @@ -10,10 +10,7 @@ */ class m190304_034411_allow_null_sku extends Migration { - /** - * @inheritdoc - */ - public function safeUp() + public function safeUp(): void { if ($this->getDb()->tableExists(Table::PRODUCT_DETAILS)) { /** @@ -29,9 +26,6 @@ public function safeUp() } } - /** - * @inheritdoc - */ public function safeDown(): bool { echo "m190304_034411_allow_null_sku cannot be reverted.\n"; diff --git a/src/migrations/m200616_222231_float_to_decimal.php b/src/migrations/m200616_222231_float_to_decimal.php index 01b4ff4..e0244c0 100644 --- a/src/migrations/m200616_222231_float_to_decimal.php +++ b/src/migrations/m200616_222231_float_to_decimal.php @@ -12,10 +12,7 @@ */ class m200616_222231_float_to_decimal extends Migration { - /** - * @inheritdoc - */ - public function safeUp() + public function safeUp(): void { if ($this->getDb()->tableExists(Table::PRODUCT_DETAILS)) { $this->alterColumn( @@ -50,9 +47,6 @@ public function safeUp() } } - /** - * @inheritdoc - */ public function safeDown(): bool { echo "m200616_222231_float_to_decimal cannot be reverted.\n"; diff --git a/src/migrations/m200921_165936_webhook_types.php b/src/migrations/m200921_165936_webhook_types.php index f407ab2..18d2d50 100644 --- a/src/migrations/m200921_165936_webhook_types.php +++ b/src/migrations/m200921_165936_webhook_types.php @@ -11,10 +11,7 @@ */ class m200921_165936_webhook_types extends Migration { - /** - * @inheritdoc - */ - public function safeUp() + public function safeUp(): void { if ($this->getDb()->tableExists(Table::WEBHOOK_LOG)) { /** @@ -29,12 +26,9 @@ public function safeUp() } } - /** - * @inheritdoc - */ - public function safeDown() + public function safeDown(): bool { echo "m200921_165936_webhook_types cannot be reverted.\n"; return false; } -} \ No newline at end of file +} diff --git a/src/migrations/m210122_204103_update_namespace.php b/src/migrations/m210122_204103_update_namespace.php index 322bff7..ec64c56 100644 --- a/src/migrations/m210122_204103_update_namespace.php +++ b/src/migrations/m210122_204103_update_namespace.php @@ -10,26 +10,24 @@ */ class m210122_204103_update_namespace extends Migration { - /** - * @inheritdoc - */ public function safeUp(): bool { // update namespace for existing fields: `workingconcept/...` → `fostercommerce/...` \Craft::$app->db->createCommand() ->update( Table::FIELDS, - ['type' => 'fostercommerce\snipcart\fields\ProductDetails'], - ['type' => 'workingconcept\snipcart\fields\ProductDetails'] + [ + 'type' => 'fostercommerce\snipcart\fields\ProductDetails', + ], + [ + 'type' => 'workingconcept\snipcart\fields\ProductDetails', + ] ) ->execute(); return true; } - /** - * @inheritdoc - */ public function safeDown(): bool { echo "m210122_204103_update_namespace cannot be reverted.\n"; diff --git a/src/migrations/m230907_112944_migrate_field_to_multicolumn_content.php b/src/migrations/m230907_112944_migrate_field_to_multicolumn_content.php new file mode 100644 index 0000000..39d1faa --- /dev/null +++ b/src/migrations/m230907_112944_migrate_field_to_multicolumn_content.php @@ -0,0 +1,107 @@ +from('{{%fields}}') + ->all(); + + $fieldsService = Craft::$app->getFields(); + $fieldsService->refreshFields(); + + foreach ($fields as $field) { + $field = $fieldsService->getFieldById($field['id']); + + if (! $field) { + continue; + } + + if (! $fieldsService->saveField($field)) { + throw new \RuntimeException(Json::encode($field->getErrors())); + } + } + } + + public function safeUp(): bool + { + $this->resaveFields(); + + $productData = (new Query()) + ->select('*') + ->from('{{%snipcart_product_details}}') + ->where([ + 'not', [ + 'sku' => '', + + ], ]) + ->all(); + + $fieldsService = Craft::$app->getFields(); + + foreach ($productData as $product) { + // find the entry it is on + $element = (new Query()) + ->select('canonicalId') + ->from('{{%elements}}') + ->where([ + 'id' => $product['elementId'], + ]) + ->one(); + + $entry = Entry::find()->id($element['canonicalId'])->one(); + $field = $fieldsService->getFieldById($product['fieldId']); + // set the field data + if (! $entry) { + continue; + } + + if (! $field) { + continue; + } + + $entry->setFieldValue($field->handle, [ + 'sku' => $product['sku'], + 'price' => $product['price'], + 'shippable' => $product['shippable'], + 'taxable' => $product['taxable'], + 'weight' => $product['weight'], + 'length' => $product['length'], + 'width' => $product['width'], + 'height' => $product['height'], + 'dimensionsUnit' => $product['dimensionsUnit'], + 'inventory' => $product['inventory'], + 'customOptions' => $product['customOptions'], + ]); + + Craft::$app->elements->saveElement($entry, false); + } + + return true; + } + + public function safeDown(): bool + { + echo "m220816_153427_switch_to_multi_column_field cannot be reverted.\n"; + return false; + } +} diff --git a/src/models/ProductDetails.php b/src/models/ProductDetails.php index 55a5ae0..90b2bc0 100644 --- a/src/models/ProductDetails.php +++ b/src/models/ProductDetails.php @@ -2,21 +2,30 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models; -use craft\elements\Entry; +use craft\base\Model; +use craft\base\ElementInterface; use craft\elements\MatrixBlock; -use Twig\Markup; +use craft\base\FieldInterface; +use yii\base\InvalidConfigException; +use yii\base\ExitException; +use Twig\Error\LoaderError; +use Twig\Error\RuntimeError; +use Twig\Error\SyntaxError; +use yii\base\Exception; +use Craft; +use craft\elements\Entry; +use craft\helpers\Template as TemplateHelper; +use fostercommerce\snipcart\fields\ProductDetails as ProductDetailsField; use fostercommerce\snipcart\helpers\MeasurementHelper; use fostercommerce\snipcart\helpers\VersionHelper; use fostercommerce\snipcart\records\ProductDetails as ProductDetailsRecord; -use fostercommerce\snipcart\fields\ProductDetails as ProductDetailsField; -use Craft; -use craft\helpers\Template as TemplateHelper; +use Twig\Markup; /** * This model is used explicitly for storing Product Details field data and @@ -24,13 +33,17 @@ * * @package fostercommerce\snipcart\models */ -class ProductDetails extends \craft\base\Model +class ProductDetails extends Model { - const WEIGHT_UNIT_GRAMS = 'grams'; - const WEIGHT_UNIT_POUNDS = 'pounds'; - const WEIGHT_UNIT_OUNCES = 'ounces'; - const DIMENSIONS_UNIT_CENTIMETERS = 'centimeters'; - const DIMENSIONS_UNIT_INCHES = 'inches'; + public const WEIGHT_UNIT_GRAMS = 'grams'; + + public const WEIGHT_UNIT_POUNDS = 'pounds'; + + public const WEIGHT_UNIT_OUNCES = 'ounces'; + + public const DIMENSIONS_UNIT_CENTIMETERS = 'centimeters'; + + public const DIMENSIONS_UNIT_INCHES = 'inches'; /** * @var @@ -134,7 +147,7 @@ class ProductDetails extends \craft\base\Model * @param bool $entryOnly Whether to return the immediately-associated * Element, like a Matrix block, or the closest Entry. * - * @return \craft\base\ElementInterface|null + * @return ElementInterface|null */ public function getElement($entryOnly = false) { @@ -143,8 +156,8 @@ public function getElement($entryOnly = false) return null; } - $element = Craft::$app->elements->getElementById($this->elementId); - $isMatrix = isset($element) && get_class($element) === MatrixBlock::class; + $element = Craft::$app->elements->getElementById($this->elementId); + $isMatrix = isset($element) && $element instanceof MatrixBlock; if ($isMatrix && $entryOnly) { return $element->getOwner(); @@ -156,44 +169,58 @@ public function getElement($entryOnly = false) /** * Get the relevant Field instance. * - * @return \craft\base\FieldInterface|ProductDetailsField|null + * @return FieldInterface|ProductDetailsField|null */ public function getField() { return Craft::$app->fields->getFieldById($this->fieldId); } - /** - * @inheritdoc - */ public function rules(): array { return [ ['sku', 'validateSku'], [['sku', 'weightUnit', 'dimensionsUnit'], 'string'], - [['length', 'width', 'height', 'weight'], 'number', 'integerOnly' => false], - [['elementId', 'fieldId', 'inventory'], 'number', 'integerOnly' => true], + [['length', 'width', 'height', 'weight'], + 'number', + 'integerOnly' => false, + ], + [['elementId', 'fieldId', 'inventory'], + 'number', + 'integerOnly' => true, + ], [['shippable'], 'boolean'], [['taxable'], 'boolean'], [['sku'], 'required'], - [['weightUnit'], 'in', 'range' => [ - self::WEIGHT_UNIT_GRAMS, - self::WEIGHT_UNIT_OUNCES, - self::WEIGHT_UNIT_POUNDS - ]], - [['dimensionsUnit'], 'in', 'range' => [ - self::DIMENSIONS_UNIT_CENTIMETERS, - self::DIMENSIONS_UNIT_INCHES - ]], - [['weight', 'weightUnit'], 'required', 'when' => function ($model) { - return $this->isShippable($model); - }, 'message' => '{attribute} is required when product is shippable.'], - [['length', 'width', 'height'], 'required', 'when' => function ($model) { - return $this->hasDimensions($model); - }, 'message' => '{attribute} required if there are other dimensions.'], - [['dimensionsUnit'], 'required', 'when' => function ($model) { - return $this->hasAllDimensions($model); - }], + [['weightUnit'], + 'in', + 'range' => [ + self::WEIGHT_UNIT_GRAMS, + self::WEIGHT_UNIT_OUNCES, + self::WEIGHT_UNIT_POUNDS, + ], + ], + [['dimensionsUnit'], + 'in', + 'range' => [ + self::DIMENSIONS_UNIT_CENTIMETERS, + self::DIMENSIONS_UNIT_INCHES, + ], + ], + [['weight', 'weightUnit'], + 'required', + 'when' => fn($model): bool => $this->isShippable($model), + 'message' => '{attribute} is required when product is shippable.', + ], + [['length', 'width', 'height'], + 'required', + 'when' => fn($model): bool => $this->hasDimensions($model), + 'message' => '{attribute} required if there are other dimensions.', + ], + [['dimensionsUnit'], + 'required', + 'when' => fn($model): bool => $this->hasAllDimensions($model), + ], ]; } @@ -202,8 +229,7 @@ public function rules(): array * * @param $attribute * - * @return bool - * @throws \yii\base\InvalidConfigException + * @throws InvalidConfigException */ public function validateSku($attribute): bool { @@ -226,27 +252,25 @@ public function validateSku($attribute): bool /** * Sets default values according to what’s configured on the field instance. */ - public function populateDefaults() + public function populateDefaults(): void { $field = $this->getField(); $isProductDetails = $field instanceof ProductDetailsField; if ($field && $isProductDetails) { - $this->shippable = $field->defaultShippable; - $this->taxable = $field->defaultTaxable; - $this->weight = $field->defaultWeight; - $this->weightUnit = $field->defaultWeightUnit; - $this->length = $field->defaultLength; - $this->width = $field->defaultWidth; - $this->height = $field->defaultHeight; + $this->shippable = $field->defaultShippable; + $this->taxable = $field->defaultTaxable; + $this->weight = $field->defaultWeight; + $this->weightUnit = $field->defaultWeightUnit; + $this->length = $field->defaultLength; + $this->width = $field->defaultWidth; + $this->height = $field->defaultHeight; $this->dimensionsUnit = $field->defaultDimensionsUnit; } } /** * Returns weight unit options for menus. - * - * @return array */ public static function getWeightUnitOptions(): array { @@ -259,8 +283,6 @@ public static function getWeightUnitOptions(): array /** * Gets dimension unit options for menus. - * - * @return array */ public static function getDimensionsUnitOptions(): array { @@ -285,8 +307,6 @@ public function getDimensionInCentimeters($dimension): float * non-zero value. * * @param ProductDetails $model - * - * @return bool */ public function hasDimensions($model = null): bool { @@ -297,7 +317,6 @@ public function hasDimensions($model = null): bool /** * Returns true if each dimension (length, width, height) as a non-zero value. * @param ProductDetails $model - * @return bool */ public function hasAllDimensions($model = null): bool { @@ -309,24 +328,20 @@ public function hasAllDimensions($model = null): bool * Returns true if product is shippable. * * @param ProductDetails $model - * - * @return bool */ public function isShippable($model = null): bool { - return ($model ?? $this)->shippable === true; + return ($model ?? $this)->shippable; } /** * Return the current item's weight in grams. - * - * @return float */ - public function getWeightInGrams() + public function getWeightInGrams(): float { if ($this->weightUnit === self::WEIGHT_UNIT_GRAMS) { // Already in grams, safe to return. - return (float) $this->weight; + return $this->weight; } if ($this->weightUnit === self::WEIGHT_UNIT_OUNCES) { @@ -336,13 +351,14 @@ public function getWeightInGrams() if ($this->weightUnit === self::WEIGHT_UNIT_POUNDS) { return MeasurementHelper::poundsToGrams((float) $this->weight); } + + return 0.0; } /** * Get markup for a "buy now" button on the public end of the site. * * @param array $params - * @return Markup * @throws */ public function getBuyNowButton($params = []): Markup @@ -352,7 +368,7 @@ public function getBuyNowButton($params = []): Markup return TemplateHelper::raw($this->renderFieldTemplate( 'snipcart/fields/front-end/buy-now', [ - 'fieldData' => $this, + 'fieldData' => $this, 'templateParams' => $params, ] )); @@ -399,20 +415,19 @@ public function getBuyNowButton($params = []): Markup * ``` * * @param array $params - * @return array */ private function getBuyButtonParams($params = []): array { $defaults = [ - 'href' => '#', - 'target' => null, - 'rel' => null, - 'title' => null, - 'image' => null, - 'text' => 'Buy Now', - 'quantity' => 1, - 'classes' => ['btn'], - 'customOptions' => [], + 'href' => '#', + 'target' => null, + 'rel' => null, + 'title' => null, + 'image' => null, + 'text' => 'Buy Now', + 'quantity' => 1, + 'classes' => ['btn'], + 'customOptions' => [], ]; $params = array_merge($defaults, $params); @@ -422,7 +437,7 @@ private function getBuyButtonParams($params = []): array * for consistency and set all prices to 0. */ if (is_array($params['customOptions']) && - count($params['customOptions']) > 0 + $params['customOptions'] !== [] ) { foreach ($params['customOptions'] as &$customOption) { $customOptionOptions = []; @@ -432,13 +447,13 @@ private function getBuyButtonParams($params = []): array if (! isset($option['name']) && ! isset($option['price'])) { $customOptionOptions[] = [ 'name' => $option, - 'price' => 0 + 'price' => 0, ]; } else { $customOptionOptions[] = $option; } } - + $customOption['options'] = $customOptionOptions; } } @@ -454,16 +469,17 @@ private function getBuyButtonParams($params = []): array * This tests uniqueness of a SKU in Craft<=3.1. * * @param $attribute - * @return bool */ private function skuIsUniqueRecordAttribute($attribute): bool { $duplicateCount = ProductDetailsRecord::find() - ->where([$attribute => $this->{$attribute}]) + ->where([ + $attribute => $this->{$attribute}, + ]) ->andWhere(['!=', 'elementId', $this->elementId]) ->count(); - return (int)$duplicateCount === 0; + return (int) $duplicateCount === 0; } /** @@ -475,16 +491,17 @@ private function skuIsUniqueRecordAttribute($attribute): bool * * @param $attribute * - * @return bool - * @throws \yii\base\InvalidConfigException|\yii\base\ExitException + * @throws InvalidConfigException|ExitException */ private function skuIsUniqueElementAttribute($attribute): bool { $hasConflict = false; + $currentElement = $this->getElement(); /** * Get product details with matching SKUs on published Elements. */ + /* $potentialDuplicates = ProductDetailsRecord::find() ->leftJoin('{{%elements}} elements', '[[elements.id]] = {{%snipcart_product_details.elementId}}') ->where([$attribute => $this->{$attribute}]) @@ -496,25 +513,30 @@ private function skuIsUniqueElementAttribute($attribute): bool 'elements.dateDeleted' => null, ]) ->all(); + */ + $potentialDuplicates = Entry::find() + ->id(['not', $currentElement->id]) + ->sectionId($currentElement->section->id) + ->all(); /** * Check each published Element to see if it’s a variation of the current * one or a totally separate one with a clashing SKU. */ - $currentElement = $this->getElement(); - - foreach ($potentialDuplicates as $record) { - $duplicateElement = Craft::$app->elements->getElementById($record->elementId); + foreach ($potentialDuplicates as $potentialDuplicate) { + $duplicateElement = Craft::$app->elements->getElementById($potentialDuplicate->elementId); // Let’s be paranoid. - if ($duplicateElement === null || - is_a($duplicateElement, \craft\base\ElementInterface::class) === false - ) { + if ($duplicateElement === null) { continue; } - if ($currentElement === null || - get_class($duplicateElement) !== get_class($currentElement) + if (is_a($duplicateElement, ElementInterface::class) === false) { + continue; + } + + if (! $currentElement instanceof ElementInterface || + $duplicateElement::class !== $currentElement::class ) { // Different element types with the same SKU are a conflict, as // are new and existing. @@ -522,15 +544,15 @@ private function skuIsUniqueElementAttribute($attribute): bool break; } - $getCanonicalId = function ($element) { + $getCanonicalId = static function($element): int { if (version_compare(Craft::$app->getVersion(), '3.7', '>=')) { return (int) $element->canonicalId; - } else { - return (int) $element->sourceId; } + + return (int) $element->sourceId; }; - if (is_a($duplicateElement, Entry::class)) { + if ($duplicateElement instanceof Entry) { // Don’t worry about unpublished Elements. if ($duplicateElement->revisionId === null) { continue; @@ -543,18 +565,18 @@ private function skuIsUniqueElementAttribute($attribute): bool } } - if (is_a($duplicateElement, MatrixBlock::class)) { + if ($duplicateElement instanceof MatrixBlock) { // A duplicate in a different field is a conflict. - if ((int)$duplicateElement->fieldId !== (int)$currentElement->fieldId) { + if ((int) $duplicateElement->fieldId !== (int) $currentElement->fieldId) { $hasConflict = true; break; } // Duplicate within same Matrix field on the same Entry. $sameSource = $getCanonicalId($duplicateElement->getOwner()) === $getCanonicalId($currentElement->getOwner()); - $sameOwner = (int)$duplicateElement->ownerId === (int)$currentElement->ownerId; + $sameOwner = (int) $duplicateElement->ownerId === (int) $currentElement->ownerId; - if ($sameSource and $sameOwner) { + if ($sameSource && $sameOwner) { $hasConflict = true; break; } @@ -570,13 +592,12 @@ private function skuIsUniqueElementAttribute($attribute): bool * @param $template * @param $data * - * @return string - * @throws \Twig\Error\LoaderError - * @throws \Twig\Error\RuntimeError - * @throws \Twig\Error\SyntaxError - * @throws \yii\base\Exception + * @throws LoaderError + * @throws RuntimeError + * @throws SyntaxError + * @throws Exception */ - private function renderFieldTemplate($template, $data): string + private function renderFieldTemplate(string $template, array $data): string { $view = Craft::$app->getView(); $templateMode = $view->getTemplateMode(); diff --git a/src/models/Settings.php b/src/models/Settings.php index e566096..a0573a2 100644 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -2,16 +2,16 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models; -use fostercommerce\snipcart\models\snipcart\Address; use Craft; use craft\base\Model; use fostercommerce\snipcart\helpers\VersionHelper; +use fostercommerce\snipcart\models\snipcart\Address; /** * Settings model @@ -21,11 +21,15 @@ */ class Settings extends Model { - const CURRENCY_USD = 'usd'; - const CURRENCY_CAD = 'cad'; - const CURRENCY_EUR = 'eur'; - const CURRENCY_GBP = 'gbp'; - const CURRENCY_CHF = 'chf'; + public const CURRENCY_USD = 'usd'; + + public const CURRENCY_CAD = 'cad'; + + public const CURRENCY_EUR = 'eur'; + + public const CURRENCY_GBP = 'gbp'; + + public const CURRENCY_CHF = 'chf'; /** * @var string Snipcart public API key @@ -52,7 +56,7 @@ class Settings extends Model * order is completed and email addresses are specified */ public $sendOrderNotificationEmail = false; - + /** * @var array Valid email addresses */ @@ -85,7 +89,7 @@ class Settings extends Model /** * @var array */ - public $enabledCurrencies = [ self::CURRENCY_USD ]; + public $enabledCurrencies = [self::CURRENCY_USD]; /** * @var string Name of custom field sent to Snipcart for order gift notes @@ -126,7 +130,7 @@ class Settings extends Model public $logWebhookRequests = false; /** - * @var array Used for storage of $_shipFrom + * @var array Used for storage of */ public $shipFromAddress = []; @@ -163,18 +167,16 @@ class Settings extends Model /** * @var Address Origin shipping address */ - private $_shipFrom; + private ?Address $_shipFrom = null; /** * @var array Key-value array of refHandle => instance of each * registered provider */ - private $_providers = []; + private array $_providers = []; /** * Returns an indexed array of store currency options. - * - * @return array */ public static function getCurrencyOptions(): array { @@ -189,8 +191,6 @@ public static function getCurrencyOptions(): array /** * Returns an indexed array of store currency options. - * - * @return array */ public static function getCurrencySymbols(): array { @@ -205,8 +205,6 @@ public static function getCurrencySymbols(): array /** * Returns the stored public API key value depending on testMode. - * - * @return string */ public function publicKey(): string { @@ -215,8 +213,6 @@ public function publicKey(): string /** * Returns the stored secret API key value depending on testMode. - * - * @return string */ public function secretKey(): string { @@ -226,8 +222,6 @@ public function secretKey(): string /** * Is the plugin ready to attempt Snipcart REST API requests with * honoring our `testMode` setting? - * - * @return bool */ public function isConfigured(): bool { @@ -240,16 +234,20 @@ public function isConfigured(): bool $this->hasNonEmptyEnvValue('secretApiKey'); } - /** - * @inheritdoc - */ public function rules(): array { return array_merge(parent::rules(), [ [['publicApiKey', 'secretApiKey', 'publicTestApiKey', 'secretTestApiKey', 'orderGiftNoteFieldName', 'orderCommentsFieldName'], 'string'], [['publicApiKey', 'secretApiKey'], 'required'], - [['cacheDurationLimit'], 'number', 'integerOnly' => true], - ['notificationEmails', 'each', 'rule' => ['email']], + [['cacheDurationLimit'], + 'number', + 'integerOnly' => true, + ], + [ + 'notificationEmails', + 'each', + 'rule' => ['email'], + ], ]); } @@ -278,8 +276,6 @@ public function validate($attributeNames = null, $clearErrors = true): bool /** * Requires valid ship from Address if we're using any shipping providers. - * - * @return bool */ public function validateShipFrom(): bool { @@ -294,8 +290,6 @@ public function validateShipFrom(): bool /** * Validates shipping provider settings, which are basically like * sub-plugins with their own settings models. - * - * @return bool */ public function validateProviderSettings(): bool { @@ -303,15 +297,12 @@ public function validateProviderSettings(): bool if ($this->hasEnabledProviders()) { foreach ($this->getProviders() as $provider) { - if ($request->getBodyParam('providers')[$provider->refHandle()]['enabled']) { - if (! $provider->getSettings()->validate()) { - $this->addError( - 'providerSettings', - 'Provider settings are missing.' - ); - - return false; - } + if ($request->getBodyParam('providers')[$provider->refHandle()]['enabled'] && ! $provider->getSettings()->validate()) { + $this->addError( + 'providerSettings', + 'Provider settings are missing.' + ); + return false; } } } @@ -322,8 +313,6 @@ public function validateProviderSettings(): bool /** * Grabs email addresses posted from a table input and reformat them before * this model is validated. - * - * @return bool */ public function beforeValidate(): bool { @@ -335,8 +324,6 @@ public function beforeValidate(): bool * Formats an array of email addresses * (`['gob@bluth.com', 'george@bluth.com']`) for a control panel table input * (`[[0 => 'gob@bluth.com'], [0 => 'george@bluth.com']]`). - * - * @return array */ public function getNotificationEmailsForTable(): array { @@ -346,9 +333,9 @@ public function getNotificationEmailsForTable(): array return $rows; } - foreach ($this->notificationEmails as $email) { + foreach ($this->notificationEmails as $notificationEmail) { $rows[] = [ - 0 => $email, + 0 => $notificationEmail, ]; } @@ -357,12 +344,10 @@ public function getNotificationEmailsForTable(): array /** * Gets the ship from address. - * - * @return Address|null */ - public function getShipFrom() + public function getShipFrom(): ?Address { - if (! empty($this->shipFromAddress)) { + if ($this->shipFromAddress !== []) { $this->setShipFrom($this->shipFromAddress); } @@ -373,8 +358,6 @@ public function getShipFrom() * Sets the ship from address. * * @param $address - * - * @return Address */ public function setShipFrom($address): Address { @@ -383,8 +366,6 @@ public function setShipFrom($address): Address /** * Gets the default (first listed) currency. - * - * @return string */ public function getDefaultCurrency(): string { @@ -397,18 +378,16 @@ public function getDefaultCurrency(): string /** * Gets the symbol for the default currency. - * - * @return string */ public function getDefaultCurrencySymbol(): string { - $currency = $this->getDefaultCurrency(); + $defaultCurrency = $this->getDefaultCurrency(); - if ( ! array_key_exists($currency, self::getCurrencySymbols())) { + if (! array_key_exists($defaultCurrency, self::getCurrencySymbols())) { return ''; } - return self::getCurrencySymbols()[$currency]; + return self::getCurrencySymbols()[$defaultCurrency]; } /** @@ -416,14 +395,13 @@ public function getDefaultCurrencySymbol(): string * don’t yet support setting multiple currencies. * * @param $value - * @return array */ public function setCurrency($value): array { - return $this->enabledCurrencies = [ $value ]; + return $this->enabledCurrencies = [$value]; } - public function addProvider($handle, $instance) + public function addProvider($handle, $instance): void { $this->_providers[$handle] = $instance; } @@ -443,9 +421,8 @@ public function getProviders(): array * simply an unparsed environment variable. * * @param $property - * @return bool */ - private function hasNonEmptyEnvValue($property): bool + private function hasNonEmptyEnvValue(string $property): bool { // value stored on the model $settingValue = $this->{$property}; @@ -487,7 +464,7 @@ private function hasNonEmptyEnvValue($property): bool * Takes email addresses posted from a table input and formats them into a * clean, one-dimensional array. */ - private function getNotificationEmailsFromTable() + private function getNotificationEmailsFromTable(): void { if (is_array($this->notificationEmails) && count($this->notificationEmails) && @@ -495,8 +472,8 @@ private function getNotificationEmailsFromTable() ) { $arrayFromTableData = []; - foreach ($this->notificationEmails as $row) { - $arrayFromTableData[] = trim($row[0]); + foreach ($this->notificationEmails as $notificationEmail) { + $arrayFromTableData[] = trim($notificationEmail[0]); } $this->notificationEmails = $arrayFromTableData; @@ -505,8 +482,6 @@ private function getNotificationEmailsFromTable() /** * Did the posted settings include any enabled shipping providers? - * - * @return bool */ private function hasEnabledProviders(): bool { @@ -523,4 +498,3 @@ private function hasEnabledProviders(): bool return false; } } - diff --git a/src/models/ShippingQuoteLog.php b/src/models/ShippingQuoteLog.php index c73a35e..a6a7e99 100644 --- a/src/models/ShippingQuoteLog.php +++ b/src/models/ShippingQuoteLog.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ diff --git a/src/models/WebhookLog.php b/src/models/WebhookLog.php index 5fdc13f..d3dca1a 100644 --- a/src/models/WebhookLog.php +++ b/src/models/WebhookLog.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ diff --git a/src/models/shipstation/Address.php b/src/models/shipstation/Address.php index 262f3ba..506d0e5 100644 --- a/src/models/shipstation/Address.php +++ b/src/models/shipstation/Address.php @@ -2,24 +2,28 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; use fostercommerce\snipcart\models\snipcart\Address as SnipcartAddress; /** * ShipStation Address Model * https://www.shipstation.com/developer-api/#/reference/model-address */ -class Address extends \craft\base\Model +class Address extends Model { - const ADDRESS_NOT_VALIDATED = 'Address not yet validated'; - const ADDRESS_VALIDATED = 'Address validated successfully'; - const ADDRESS_VALIDATION_WARNING = 'Address validation warning'; - const ADDRESS_VALIDATION_FAILED = 'Address validation failed'; + public const ADDRESS_NOT_VALIDATED = 'Address not yet validated'; + + public const ADDRESS_VALIDATED = 'Address validated successfully'; + + public const ADDRESS_VALIDATION_WARNING = 'Address validation warning'; + + public const ADDRESS_VALIDATION_FAILED = 'Address validation failed'; /** * @var string|null Name of person. @@ -82,37 +86,41 @@ class Address extends \craft\base\Model */ public $addressVerified; - /** - * @param SnipcartAddress $address - * @return Address - */ - public static function populateFromSnipcartAddress(SnipcartAddress $address): Address + public static function populateFromSnipcartAddress(SnipcartAddress $snipcartAddress): self { return new self([ - 'name' => $address->name, - 'street1' => $address->address1, - 'street2' => $address->address2, - 'city' => $address->city, - 'state' => $address->province, - 'postalCode' => $address->postalCode, - 'country' => $address->country, - 'phone' => $address->phone, + 'name' => $snipcartAddress->name, + 'street1' => $snipcartAddress->address1, + 'street2' => $snipcartAddress->address2, + 'city' => $snipcartAddress->city, + 'state' => $snipcartAddress->province, + 'postalCode' => $snipcartAddress->postalCode, + 'country' => $snipcartAddress->country, + 'phone' => $snipcartAddress->phone, ]); } - /** - * @inheritdoc - */ public function rules(): array { return [ - [['name', 'street1', 'street2', 'street3', 'city', 'state', 'postalCode', 'phone', 'addressVerified'], 'string', 'max' => 255], + [['name', 'street1', 'street2', 'street3', 'city', 'state', 'postalCode', 'phone', 'addressVerified'], + 'string', + 'max' => 255, + ], [['name', 'street1', 'city', 'state', 'postalCode'], 'required'], [['residential'], 'boolean'], - [['company', 'street2', 'street3'], 'default', 'value' => null], - [['country'], 'default', 'value' => 'US'], - [['country'], 'string', 'length' => 2], + [['company', 'street2', 'street3'], + 'default', + 'value' => null, + ], + [['country'], + 'default', + 'value' => 'US', + ], + [['country'], + 'string', + 'length' => 2, + ], ]; } - } diff --git a/src/models/shipstation/AdvancedOptions.php b/src/models/shipstation/AdvancedOptions.php index 9a8735b..57cf471 100644 --- a/src/models/shipstation/AdvancedOptions.php +++ b/src/models/shipstation/AdvancedOptions.php @@ -2,17 +2,18 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; /** * ShipStation Advanced Options Model * https://www.shipstation.com/developer-api/#/reference/model-advancedoptions */ -class AdvancedOptions extends \craft\base\Model +class AdvancedOptions extends Model { /** * @var int|null Specifies the warehouse where to the order is to ship from. @@ -79,7 +80,7 @@ class AdvancedOptions extends \craft\base\Model * @var int[] Read-Only: Array of orderIds. Each orderId identifies an order * that was merged with the associated order. */ - public $mergedIds; + public $mergedIds = []; /** * @var int Read-Only: If an order has been split, it will return the @@ -117,18 +118,24 @@ class AdvancedOptions extends \craft\base\Model */ public $billToMyOtherAccount; - /** - * @inheritdoc - */ public function rules(): array { return [ - [['warehouseId', 'storeId', 'parentId'], 'number', 'integerOnly' => true], + [['warehouseId', 'storeId', 'parentId'], + 'number', + 'integerOnly' => true, + ], [['customField1', 'customField2', 'customField3', 'source', 'billToParty', 'billToAccount', 'billToPostalCode', 'billToCountryCode', 'billToMyOtherAccount'], 'string'], [['nonMachinable', 'saturdayDelivery', 'containsAlcohol', 'mergedOrSplit'], 'boolean'], - ['mergedIds', 'each', 'rule' => ['integer']], - [['billToCountryCode'], 'string', 'length' => 2], + [ + 'mergedIds', + 'each', + 'rule' => ['integer'], + ], + [['billToCountryCode'], + 'string', + 'length' => 2, + ], ]; } - } diff --git a/src/models/shipstation/CustomsItem.php b/src/models/shipstation/CustomsItem.php index 3f8f412..c3d1e5d 100644 --- a/src/models/shipstation/CustomsItem.php +++ b/src/models/shipstation/CustomsItem.php @@ -2,17 +2,18 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; /** * ShipStation CustomsItem Model * https://www.shipstation.com/developer-api/#/reference/model-customsitem */ -class CustomsItem extends \craft\base\Model +class CustomsItem extends Model { /** * @var string Read Only field. When this field is not submitted in the @@ -48,17 +49,22 @@ class CustomsItem extends \craft\base\Model */ public $countryOfOrigin; - /** - * @inheritdoc - */ public function rules(): array { return [ [['customsItemId', 'description', 'harmonizedTariffCode', 'countryOfOrigin'], 'string'], - [['quantity'], 'number', 'integerOnly' => true], - [['value'], 'number', 'integerOnly' => false], - [['countryOfOrigin'], 'string', 'length' => 2], + [['quantity'], + 'number', + 'integerOnly' => true, + ], + [['value'], + 'number', + 'integerOnly' => false, + ], + [['countryOfOrigin'], + 'string', + 'length' => 2, + ], ]; } - } diff --git a/src/models/shipstation/Dimensions.php b/src/models/shipstation/Dimensions.php index 74c4e1d..fcc6996 100644 --- a/src/models/shipstation/Dimensions.php +++ b/src/models/shipstation/Dimensions.php @@ -2,22 +2,24 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; use fostercommerce\snipcart\models\snipcart\Package as SnipcartPackage; /** * ShipStation Dimensions Model * https://www.shipstation.com/developer-api/#/reference/model-dimensions */ -class Dimensions extends \craft\base\Model +class Dimensions extends Model { - const UNIT_INCHES = 'inches'; - const UNIT_CENTIMETERS = 'centimeters'; + public const UNIT_INCHES = 'inches'; + + public const UNIT_CENTIMETERS = 'centimeters'; /** * @var int|null Length of package. @@ -39,38 +41,36 @@ class Dimensions extends \craft\base\Model */ public $units; - /** - * @inheritdoc - */ public function rules(): array { return [ - [['length', 'width', 'height'], 'number', 'integerOnly' => true], + [['length', 'width', 'height'], + 'number', + 'integerOnly' => true, + ], [['units'], 'string'], - [['units'], 'in', 'range' => [self::UNIT_INCHES, self::UNIT_CENTIMETERS]], + [['units'], + 'in', + 'range' => [self::UNIT_INCHES, self::UNIT_CENTIMETERS], + ], ]; } /** * Populate this model from a Package. - * - * @param SnipcartPackage $package - * @return Dimensions */ - public static function populateFromSnipcartPackage(SnipcartPackage $package): Dimensions + public static function populateFromSnipcartPackage(SnipcartPackage $snipcartPackage): self { return new self([ - 'length' => $package->length, - 'width' => $package->width, - 'height' => $package->height, + 'length' => $snipcartPackage->length, + 'width' => $snipcartPackage->width, + 'height' => $snipcartPackage->height, 'units' => self::UNIT_INCHES, ]); } /** * True if valid, non-zero length, width, and height are all present. - * - * @return bool */ public function hasPhysicalDimensions(): bool { @@ -78,5 +78,4 @@ public function hasPhysicalDimensions(): bool $this->width !== null && $this->width > 0 && $this->height !== null && $this->height > 0; } - } diff --git a/src/models/shipstation/InsuranceOptions.php b/src/models/shipstation/InsuranceOptions.php index 42d0bd3..e82b4db 100644 --- a/src/models/shipstation/InsuranceOptions.php +++ b/src/models/shipstation/InsuranceOptions.php @@ -2,20 +2,22 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; /** * ShipStation Insurance Options Model * https://www.shipstation.com/developer-api/#/reference/model-insuranceoptions */ -class InsuranceOptions extends \craft\base\Model +class InsuranceOptions extends Model { - const PROVIDER_CARRIER = 'carrier'; - const PROVIDER_SHIPSURANCE = 'shipsurance'; + public const PROVIDER_CARRIER = 'carrier'; + + public const PROVIDER_SHIPSURANCE = 'shipsurance'; /** * @var string|null Preferred Insurance provider. @@ -33,18 +35,23 @@ class InsuranceOptions extends \craft\base\Model */ public $insuredValue; - /** - * @inheritdoc - */ public function rules(): array { return [ [['provider'], 'string'], - [['provider'], 'in', 'range' => [self::PROVIDER_CARRIER, self::PROVIDER_SHIPSURANCE]], + [['provider'], + 'in', + 'range' => [self::PROVIDER_CARRIER, self::PROVIDER_SHIPSURANCE], + ], [['insureShipment'], 'boolean'], - [['insuredValue'], 'number', 'integerOnly' => false], - [['insuredValue'], 'default', 'value' => 0], + [['insuredValue'], + 'number', + 'integerOnly' => false, + ], + [['insuredValue'], + 'default', + 'value' => 0, + ], ]; } - } diff --git a/src/models/shipstation/InternationalOptions.php b/src/models/shipstation/InternationalOptions.php index b268c2c..6df689f 100644 --- a/src/models/shipstation/InternationalOptions.php +++ b/src/models/shipstation/InternationalOptions.php @@ -2,26 +2,32 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; /** * ShipStation International Options Model * https://www.shipstation.com/developer-api/#/reference/model-internationaloptions */ -class InternationalOptions extends \craft\base\Model +class InternationalOptions extends Model { - const CONTENTS_MERCHANDISE = 'merchandise'; - const CONTENTS_DOCUMENTS = 'documents'; - const CONTENTS_GIFT = 'gift'; - const CONTENTS_RETURNED_GOODS = 'returned_goods'; - const CONTENTS_SAMPLE = 'sample'; + public const CONTENTS_MERCHANDISE = 'merchandise'; - const NON_DELIVERY_RETURN_TO_SENDER = 'return_to_sender'; - const NON_DELIVERY_TREAT_AS_ABANDONED = 'treat_as_abandoned'; + public const CONTENTS_DOCUMENTS = 'documents'; + + public const CONTENTS_GIFT = 'gift'; + + public const CONTENTS_RETURNED_GOODS = 'returned_goods'; + + public const CONTENTS_SAMPLE = 'sample'; + + public const NON_DELIVERY_RETURN_TO_SENDER = 'return_to_sender'; + + public const NON_DELIVERY_TREAT_AS_ABANDONED = 'treat_as_abandoned'; /** * @var string|null Contents of international shipment. Available options: @@ -30,17 +36,6 @@ class InternationalOptions extends \craft\base\Model */ public $contents; - /** - * @var CustomsItem[]|null An array of customs items. Please note: If you - * wish to supply customsItems in the CreateOrder - * call and have the values not be overwritten - * by ShipStation, you must have the - * International Settings > Customs Declarations set - * to "Leave blank (Enter Manually)" in the UI: - * https://ss.shipstation.com/#/settings/international - */ - private $customsItems; - /** * @var string|null Non-Delivery option for international shipment. * Available options are: "return_to_sender" or @@ -54,6 +49,17 @@ class InternationalOptions extends \craft\base\Model */ public $nonDelivery; + /** + * @var CustomsItem[]|null An array of customs items. Please note: If you + * wish to supply customsItems in the CreateOrder + * call and have the values not be overwritten + * by ShipStation, you must have the + * International Settings > Customs Declarations set + * to "Leave blank (Enter Manually)" in the UI: + * https://ss.shipstation.com/#/settings/international + */ + private $customsItems; + // Public Methods // ========================================================================= @@ -74,7 +80,6 @@ public function getCustomsItems(): array return $this->customsItems; } - /** * Sets customs items. * @@ -87,17 +92,18 @@ public function setCustomsItems($customsItems) return $this->customsItems = $customsItems; } - - /** - * @inheritdoc - */ public function rules(): array { return [ [['contents', 'nonDelivery'], 'string'], - [['contents'], 'in', 'range' => [self::CONTENTS_MERCHANDISE, self::CONTENTS_DOCUMENTS, self::CONTENTS_GIFT, self::CONTENTS_RETURNED_GOODS, self::CONTENTS_SAMPLE]], - [['nonDelivery'], 'in', 'range' => [self::NON_DELIVERY_RETURN_TO_SENDER, self::NON_DELIVERY_TREAT_AS_ABANDONED]], + [['contents'], + 'in', + 'range' => [self::CONTENTS_MERCHANDISE, self::CONTENTS_DOCUMENTS, self::CONTENTS_GIFT, self::CONTENTS_RETURNED_GOODS, self::CONTENTS_SAMPLE], + ], + [['nonDelivery'], + 'in', + 'range' => [self::NON_DELIVERY_RETURN_TO_SENDER, self::NON_DELIVERY_TREAT_AS_ABANDONED], + ], ]; } - -} \ No newline at end of file +} diff --git a/src/models/shipstation/ItemOption.php b/src/models/shipstation/ItemOption.php index 07bc0e1..06980fd 100644 --- a/src/models/shipstation/ItemOption.php +++ b/src/models/shipstation/ItemOption.php @@ -2,12 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; use fostercommerce\snipcart\models\snipcart\CustomField; /** @@ -15,7 +16,7 @@ * https://www.shipstation.com/developer-api/#/reference/model-itemoption */ -class ItemOption extends \craft\base\Model +class ItemOption extends Model { /** * @var string|null Name of item option. Example: "Size" @@ -27,9 +28,6 @@ class ItemOption extends \craft\base\Model */ public $value; - /** - * @inheritdoc - */ public function rules(): array { return [ @@ -43,20 +41,19 @@ public function rules(): array * @return ItemOption|null * @todo strictly use CustomField as param */ - public static function populateFromSnipcartCustomField($item) + public static function populateFromSnipcartCustomField($item): ?self { if (is_array($item)) { - $item = (object)$item; + $item = (object) $item; } if (isset($item->name, $item->value)) { return new self([ - 'name' => $item->name, + 'name' => $item->name, 'value' => $item->value, ]); } return null; } - } diff --git a/src/models/shipstation/Order.php b/src/models/shipstation/Order.php index ef6501f..40e27a0 100644 --- a/src/models/shipstation/Order.php +++ b/src/models/shipstation/Order.php @@ -2,12 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; use fostercommerce\snipcart\models\snipcart\Order as SnipcartOrder; /** @@ -23,17 +24,20 @@ * @property InternationalOptions $internationalOptions * @property AdvancedOptions $advancedOptions */ -class Order extends \craft\base\Model +class Order extends Model { /** * Used for creating a new Order with the ShipStation API. */ - const SCENARIO_NEW = 'new'; + public const SCENARIO_NEW = 'new'; - const STATUS_AWAITING_PAYMENT = 'awaiting_payment'; - const STATUS_AWAITING_SHIPMENT = 'awaiting_shipment'; - const STATUS_ON_HOLD = 'on_hold'; - const STATUS_CANCELLED = 'cancelled'; + public const STATUS_AWAITING_PAYMENT = 'awaiting_payment'; + + public const STATUS_AWAITING_SHIPMENT = 'awaiting_shipment'; + + public const STATUS_ON_HOLD = 'on_hold'; + + public const STATUS_CANCELLED = 'cancelled'; /** * @var int|null Order ID (read-only) @@ -95,21 +99,6 @@ class Order extends \craft\base\Model */ public $customerEmail; - /** - * @var Address|null - */ - private $_billTo; - - /** - * @var Address|null - */ - private $_shipTo; - - /** - * @var OrderItem[]|null - */ - private $_items; - /** * @var float|null Order Total (read-only) */ @@ -190,31 +179,6 @@ class Order extends \craft\base\Model */ public $holdUntilDate; - /** - * @var Weight|null - */ - private $_weight; - - /** - * @var Dimensions|null - */ - private $_dimensions; - - /** - * @var InsuranceOptions|null - */ - private $_insuranceOptions; - - /** - * @var InternationalOptions|null - */ - private $_internationalOptions; - - /** - * @var AdvancedOptions|null - */ - private $_advancedOptions; - /** * @var int[]|null */ @@ -240,12 +204,31 @@ class Order extends \craft\base\Model */ public $labelMessages; + private ?Address $_billTo = null; + + private ?Address $_shipTo = null; + + /** + * @var OrderItem[]|null + */ + private ?array $_items = null; + + private ?Weight $_weight = null; + + private ?Dimensions $_dimensions = null; + + private ?InsuranceOptions $_insuranceOptions = null; + + private ?InternationalOptions $_internationalOptions = null; + + private ?AdvancedOptions $_advancedOptions = null; + /** * Gets the order’s billing address. * * @return Address|null */ - public function getBillTo() + public function getBillTo(): ?Address { return $this->_billTo; } @@ -254,8 +237,6 @@ public function getBillTo() * Sets the order’s billing address. * * @param Address|array $address The order's billing address. - * - * @return Address */ public function setBillTo($address): Address { @@ -271,7 +252,7 @@ public function setBillTo($address): Address * * @return Address|null */ - public function getShipTo() + public function getShipTo(): ?Address { return $this->_shipTo; } @@ -280,8 +261,6 @@ public function getShipTo() * Sets the order’s shipping address. * * @param Address|array $address The order's shipping address. - * - * @return Address */ public function setShipTo($address): Address { @@ -312,10 +291,8 @@ public function getItems(): array * Sets the order’s items. * * @param OrderItem[] $items The order's items. - * - * @return void */ - public function setItems(array $items) + public function setItems(array $items): void { $this->_items = $items; } @@ -325,7 +302,7 @@ public function setItems(array $items) * * @return Weight|null */ - public function getWeight() + public function getWeight(): ?Weight { return $this->_weight; } @@ -351,7 +328,7 @@ public function setWeight($weight) * * @return Dimensions|null */ - public function getDimensions() + public function getDimensions(): ?Dimensions { return $this->_dimensions; } @@ -377,7 +354,7 @@ public function setDimensions($dimensions) * * @return InsuranceOptions|null */ - public function getInsuranceOptions() + public function getInsuranceOptions(): ?InsuranceOptions { return $this->_insuranceOptions; } @@ -403,7 +380,7 @@ public function setInsuranceOptions($insuranceOptions) * * @return InternationalOptions|null */ - public function getInternationalOptions() + public function getInternationalOptions(): ?InternationalOptions { return $this->_internationalOptions; } @@ -429,7 +406,7 @@ public function setInternationalOptions($internationalOptions) * * @return AdvancedOptions|null */ - public function getAdvancedOptions() + public function getAdvancedOptions(): ?AdvancedOptions { return $this->_advancedOptions; } @@ -452,41 +429,35 @@ public function setAdvancedOptions($advancedOptions) /** * Map Order properties to this model. - * - * @param SnipcartOrder $order - * @return Order */ - public static function populateFromSnipcartOrder(SnipcartOrder $order): Order + public static function populateFromSnipcartOrder(SnipcartOrder $snipcartOrder): self { $items = []; - foreach ($order->items as $item) { + foreach ($snipcartOrder->items as $item) { $items[] = OrderItem::populateFromSnipcartItem($item); } return new self([ - 'orderNumber' => $order->invoiceNumber, - 'orderKey' => $order->token, - 'orderDate' => $order->creationDate, - 'paymentDate' => $order->completionDate, - 'customerEmail' => $order->email, - 'amountPaid' => $order->total, - 'shippingAmount' => $order->shippingFees, - 'requestedShippingService' => $order->shippingMethod, - 'taxAmount' => $order->taxesTotal, + 'orderNumber' => $snipcartOrder->invoiceNumber, + 'orderKey' => $snipcartOrder->token, + 'orderDate' => $snipcartOrder->creationDate, + 'paymentDate' => $snipcartOrder->completionDate, + 'customerEmail' => $snipcartOrder->email, + 'amountPaid' => $snipcartOrder->total, + 'shippingAmount' => $snipcartOrder->shippingFees, + 'requestedShippingService' => $snipcartOrder->shippingMethod, + 'taxAmount' => $snipcartOrder->taxesTotal, 'shipTo' => Address::populateFromSnipcartAddress( - $order->shippingAddress + $snipcartOrder->shippingAddress ), 'billTo' => Address::populateFromSnipcartAddress( - $order->billingAddress + $snipcartOrder->billingAddress ), - 'items' => $items + 'items' => $items, ]); } - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return [ @@ -500,9 +471,6 @@ public function datetimeAttributes(): array ]; } - /** - * @inheritdoc - */ public function extraFields(): array { return [ @@ -513,13 +481,10 @@ public function extraFields(): array 'dimensions', 'insuranceOptions', 'internationalOptions', - 'advancedOptions' + 'advancedOptions', ]; } - /** - * @inheritdoc - */ public function rules(): array { /** @@ -531,21 +496,34 @@ public function rules(): array * and submit any dateTime requests in PST/PDT. */ return [ - [['orderId', 'customerId', 'userId'], 'number', 'integerOnly' => true], - [['orderTotal', 'amountPaid', 'taxAmount', 'shippingAmount'], 'number', 'integerOnly' => false], - [['orderTotal', 'amountPaid', 'taxAmount', 'shippingAmount'], 'default', 'value' => 0], + [['orderId', 'customerId', 'userId'], + 'number', + 'integerOnly' => true, + ], + [['orderTotal', 'amountPaid', 'taxAmount', 'shippingAmount'], + 'number', + 'integerOnly' => false, + ], + [['orderTotal', 'amountPaid', 'taxAmount', 'shippingAmount'], + 'default', + 'value' => 0, + ], [['orderNumber', 'orderStatus'], 'string'], [['orderKey', 'customerUsername', 'customerEmail', 'customerNotes', 'internalNotes', 'giftMessage', 'paymentMethod', 'requestedShippingService', 'carrierCode', 'serviceCode', 'packageCode', 'confirmation', 'externallyFulfilledBy'], 'string'], [['customerEmail'], 'email'], [['gift', 'externallyFulfilled'], 'boolean'], - [['gift', 'externallyFulfilled'], 'default', 'value' => false], - ['tagIds', 'each', 'rule' => ['integer']], + [['gift', 'externallyFulfilled'], + 'default', + 'value' => false, + ], + [ + 'tagIds', + 'each', + 'rule' => ['integer'], + ], ]; } - /** - * @inheritdoc - */ public function scenarios(): array { $scenarios = parent::scenarios(); @@ -553,9 +531,6 @@ public function scenarios(): array return $scenarios; } - /** - * @return array - */ public function getPayloadForPost(): array { $payload = $this->toArray( @@ -608,12 +583,12 @@ public function getPayloadForPost(): array 'orderItemId', 'adjustment', 'createDate', - 'modifyDate' + 'modifyDate', ]; foreach ($payload['items'] as &$item) { - foreach ($removeFromItems as $removeKey) { - unset($item[$removeKey]); + foreach ($removeFromItems as $removeFromItem) { + unset($item[$removeFromItem]); } unset($item['weight']['WeightUnits']); @@ -623,5 +598,4 @@ public function getPayloadForPost(): array return $payload; } - } diff --git a/src/models/shipstation/OrderItem.php b/src/models/shipstation/OrderItem.php index 6e498d4..0bfd797 100644 --- a/src/models/shipstation/OrderItem.php +++ b/src/models/shipstation/OrderItem.php @@ -2,12 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; use fostercommerce\snipcart\models\snipcart\Item as SnipcartItem; /** @@ -19,7 +20,7 @@ * @property Weight|null $weight * @property ItemOption[]|null $options */ -class OrderItem extends \craft\base\Model +class OrderItem extends Model { /** * @var int|null The system generated identifier for the OrderItem. This is a read-only field. @@ -46,11 +47,6 @@ class OrderItem extends \craft\base\Model */ public $imageUrl; - /** - * @var Weight|null - */ - private $_weight; - /** * @var int|null The quantity of product ordered. */ @@ -76,11 +72,6 @@ class OrderItem extends \craft\base\Model */ public $warehouseLocation; - /** - * @var ItemOption[]|null - */ - private $_options; - /** * @var int|null The identifier for the Product Resource associated with this OrderItem. */ @@ -114,6 +105,16 @@ class OrderItem extends \craft\base\Model */ public $modifyDate; + /** + * @var Weight|null + */ + private $_weight; + + /** + * @var ItemOption[]|null + */ + private $_options; + /** * Returns the item’s weight. * @@ -160,7 +161,7 @@ public function getOptions(): array * * @param ItemOption[]|null $options The item’s options. */ - public function setOptions($options) + public function setOptions($options): void { $this->_options = $options ?? []; } @@ -169,10 +170,8 @@ public function setOptions($options) * Populate model from Item. * * @param SnipcartItem $item - * - * @return OrderItem */ - public static function populateFromSnipcartItem($item): OrderItem + public static function populateFromSnipcartItem($item): self { if (! empty($item->customFields)) { $itemOptions = []; @@ -188,41 +187,40 @@ public static function populateFromSnipcartItem($item): OrderItem 'quantity' => $item->quantity, 'unitPrice' => $item->unitPrice, 'weight' => Weight::populateFromSnipcartItem($item), - 'options' => $itemOptions ?? null + 'options' => $itemOptions ?? null, ]); } - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return ['createDate', 'modifyDate']; } - /** - * @inheritdoc - */ public function fields(): array { $fields = array_keys(\Yii::getObjectVars($this)); - $fields = array_merge($fields, ['weight', 'options']); + $fields = [...$fields, 'weight', 'options']; return array_combine($fields, $fields); } - /** - * @inheritdoc - */ public function rules(): array { return [ - [['orderItemId', 'quantity', 'productId'], 'number', 'integerOnly' => true], - [['unitPrice', 'taxAmount', 'shippingAmount'], 'number', 'integerOnly' => false], - [['lineItemKey', 'sku', 'name', 'warehouseLocation', 'fulfillmentSku', 'upc', 'createDate', 'modifyDate'], 'string', 'max' => 255], + [['orderItemId', 'quantity', 'productId'], + 'number', + 'integerOnly' => true, + ], + [['unitPrice', 'taxAmount', 'shippingAmount'], + 'number', + 'integerOnly' => false, + ], + [['lineItemKey', 'sku', 'name', 'warehouseLocation', 'fulfillmentSku', 'upc', 'createDate', 'modifyDate'], + 'string', + 'max' => 255, + ], [['name'], 'required'], [['imageUrl'], 'url'], [['adjustment'], 'boolean'], ]; } - } diff --git a/src/models/shipstation/Product.php b/src/models/shipstation/Product.php index 4947897..d07d067 100644 --- a/src/models/shipstation/Product.php +++ b/src/models/shipstation/Product.php @@ -2,17 +2,18 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; /** * ShipStation Product Model * https://www.shipstation.com/developer-api/#/reference/model-product */ -class Product extends \craft\base\Model +class Product extends Model { /** * @var int|null The system generated identifier for the product. @@ -195,25 +196,24 @@ class Product extends \craft\base\Model // Public Methods // ========================================================================= - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return ['createDate', 'modifyDate']; } - /** - * @inheritdoc - */ public function rules(): array { return [ [['sku', 'name', 'internalNotes', 'fulfillmentSku', 'createDate', 'modifyDate', 'productType', 'warehouseLocation', 'defaultCarrierCode', 'defaultServiceCode', 'defaultPackageCode', 'defaultIntlCarrierCode', 'defaultIntlServiceCode', 'defaultIntlPackageCode', 'defaultConfirmation', 'defaultIntlConfirmation', 'customsDescription', 'customsTariffNo', 'customsCountryCode'], 'string'], - [['productId', 'length', 'width', 'height', 'weightOz'], 'number', 'integerOnly' => true], - [['price', 'defaultCost', 'customsValue'], 'number', 'integerOnly' => false], + [['productId', 'length', 'width', 'height', 'weightOz'], + 'number', + 'integerOnly' => true, + ], + [['price', 'defaultCost', 'customsValue'], + 'number', + 'integerOnly' => false, + ], [['active', 'noCustoms'], 'boolean'], ]; } - } diff --git a/src/models/shipstation/ProductCategory.php b/src/models/shipstation/ProductCategory.php index 9c76aff..ad5b1ca 100644 --- a/src/models/shipstation/ProductCategory.php +++ b/src/models/shipstation/ProductCategory.php @@ -2,18 +2,18 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; /** * ShipStation Product Category Model * https://www.shipstation.com/developer-api/#/reference/model-product-category */ - -class ProductCategory extends \craft\base\Model +class ProductCategory extends Model { /** * @var number The system generated identifier for the product category. @@ -25,15 +25,14 @@ class ProductCategory extends \craft\base\Model */ public $name; - /** - * @inheritdoc - */ public function rules(): array { return [ - [['categoryId'], 'number', 'integerOnly' => true], + [['categoryId'], + 'number', + 'integerOnly' => true, + ], [['name'], 'string'], ]; } - -} \ No newline at end of file +} diff --git a/src/models/shipstation/ProductTag.php b/src/models/shipstation/ProductTag.php index 82257c8..ea91c58 100644 --- a/src/models/shipstation/ProductTag.php +++ b/src/models/shipstation/ProductTag.php @@ -2,18 +2,18 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; /** * ShipStation Product Tag Model * https://www.shipstation.com/developer-api/#/reference/model-product-tag */ - -class ProductTag extends \craft\base\Model +class ProductTag extends Model { /** * @var number The system generated identifier for the product tag. @@ -25,15 +25,14 @@ class ProductTag extends \craft\base\Model */ public $name; - /** - * @inheritdoc - */ public function rules(): array { return [ - [['tagId'], 'number', 'integerOnly' => true], + [['tagId'], + 'number', + 'integerOnly' => true, + ], [['name'], 'string'], ]; } - -} \ No newline at end of file +} diff --git a/src/models/shipstation/Rate.php b/src/models/shipstation/Rate.php index 7314fe2..4253535 100644 --- a/src/models/shipstation/Rate.php +++ b/src/models/shipstation/Rate.php @@ -2,17 +2,18 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; /** * ShipStation Rate Model * https://www.shipstation.com/developer-api/#/reference/shipments/get-rates/get-rates */ -class Rate extends \craft\base\Model +class Rate extends Model { /** * @var string Example: "FedEx First Overnight®" @@ -34,15 +35,14 @@ class Rate extends \craft\base\Model */ public $otherCost; - /** - * @inheritdoc - */ public function rules(): array { return [ [['serviceName', 'serviceCode'], 'string'], - [['shipmentCost', 'otherCost'], 'number', 'integerOnly' => false], + [['shipmentCost', 'otherCost'], + 'number', + 'integerOnly' => false, + ], ]; } - } diff --git a/src/models/shipstation/Webhook.php b/src/models/shipstation/Webhook.php index d05125f..3d5ced4 100644 --- a/src/models/shipstation/Webhook.php +++ b/src/models/shipstation/Webhook.php @@ -2,22 +2,26 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; /** * ShipStation Webhook Model * https://www.shipstation.com/developer-api/#/reference/model-webhook */ -class Webhook extends \craft\base\Model +class Webhook extends Model { - const TYPE_ORDER_NOTIFY = 'ORDER_NOTIFY'; - const TYPE_ITEM_ORDER_NOTIFY = 'ITEM_ORDER_NOTIFY'; - const TYPE_SHIP_NOTIFY = 'SHIP_NOTIFY'; - const TYPE_ITEM_SHIP_NOTIFY = 'ITEM_SHIP_NOTIFY'; + public const TYPE_ORDER_NOTIFY = 'ORDER_NOTIFY'; + + public const TYPE_ITEM_ORDER_NOTIFY = 'ITEM_ORDER_NOTIFY'; + + public const TYPE_SHIP_NOTIFY = 'SHIP_NOTIFY'; + + public const TYPE_ITEM_SHIP_NOTIFY = 'ITEM_SHIP_NOTIFY'; /** * @var string This URL can be used to get the resource which triggered the webhook. 200 character limit. @@ -31,21 +35,23 @@ class Webhook extends \craft\base\Model */ public $resource_type; - /** - * @inheritdoc - */ public function rules(): array { return [ - [['resource_url', 'resource_type'], 'string', 'max' => 200], + [['resource_url', 'resource_type'], + 'string', + 'max' => 200, + ], [['resource_url'], 'url'], - [['resource_type'], 'in', 'range' => [ - self::TYPE_ORDER_NOTIFY, - self::TYPE_ITEM_ORDER_NOTIFY, - self::TYPE_SHIP_NOTIFY, - self::TYPE_ITEM_SHIP_NOTIFY - ]], + [['resource_type'], + 'in', + 'range' => [ + self::TYPE_ORDER_NOTIFY, + self::TYPE_ITEM_ORDER_NOTIFY, + self::TYPE_SHIP_NOTIFY, + self::TYPE_ITEM_SHIP_NOTIFY, + ], + ], ]; } - -} \ No newline at end of file +} diff --git a/src/models/shipstation/Weight.php b/src/models/shipstation/Weight.php index 0c4c819..a9afb31 100644 --- a/src/models/shipstation/Weight.php +++ b/src/models/shipstation/Weight.php @@ -2,12 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\shipstation; +use craft\base\Model; use fostercommerce\snipcart\models\snipcart\Item as SnipcartItem; /** @@ -15,11 +16,13 @@ * https://www.shipstation.com/developer-api/#/reference/model-weight */ -class Weight extends \craft\base\Model +class Weight extends Model { - const UNIT_POUNDS = 'pounds'; - const UNIT_OUNCES = 'ounces'; - const UNIT_GRAMS = 'grams'; + public const UNIT_POUNDS = 'pounds'; + + public const UNIT_OUNCES = 'ounces'; + + public const UNIT_GRAMS = 'grams'; /** * @var int Weight value. @@ -38,9 +41,8 @@ class Weight extends \craft\base\Model /** * @param SnipcartItem|\stdClass $item - * @return Weight */ - public static function populateFromSnipcartItem($item): Weight + public static function populateFromSnipcartItem($item): self { return new self([ 'value' => $item->weight ?? 0, @@ -48,16 +50,18 @@ public static function populateFromSnipcartItem($item): Weight ]); } - /** - * @inheritdoc - */ public function rules(): array { return [ - [['value'], 'number', 'integerOnly' => true], + [['value'], + 'number', + 'integerOnly' => true, + ], [['units'], 'string'], - [['units'], 'in', 'range' => [self::UNIT_POUNDS, self::UNIT_OUNCES, self::UNIT_GRAMS]], + [['units'], + 'in', + 'range' => [self::UNIT_POUNDS, self::UNIT_OUNCES, self::UNIT_GRAMS], + ], ]; } - } diff --git a/src/models/snipcart/AbandonedCart.php b/src/models/snipcart/AbandonedCart.php index f0c962b..3719e8a 100644 --- a/src/models/snipcart/AbandonedCart.php +++ b/src/models/snipcart/AbandonedCart.php @@ -2,19 +2,20 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; +use craft\helpers\UrlHelper; /** * https://docs.snipcart.com/v2/api-reference/abandoned-carts */ - -class AbandonedCart extends \craft\base\Model +class AbandonedCart extends Model { - const STATUS_IN_PROGRESS = 'InProgress'; + public const STATUS_IN_PROGRESS = 'InProgress'; /** * @var @@ -82,6 +83,7 @@ class AbandonedCart extends \craft\base\Model public $invoiceNumber; public $shippingInformation; + /* "shippingInformation": { "provider": null, @@ -93,6 +95,7 @@ class AbandonedCart extends \craft\base\Model public $paymentMethod; public $summary; + /* summary": { "subtotal": 20, @@ -304,9 +307,6 @@ class AbandonedCart extends \craft\base\Model */ public $totalPriceWithoutDiscountsAndTaxes; - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return ['modificationDate', 'completionDate']; @@ -314,16 +314,14 @@ public function datetimeAttributes(): array /** * Returns the Craft control panel URL for the detail page. - * @return string */ public function getCpUrl(): string { - return \craft\helpers\UrlHelper::cpUrl('snipcart/abandoned/' . $this->token); + return UrlHelper::cpUrl('snipcart/abandoned/' . $this->token); } public function getDashboardUrl(): string { return 'https://app.snipcart.com/dashboard/abandoned/' . $this->token; } - } diff --git a/src/models/snipcart/Address.php b/src/models/snipcart/Address.php index 497ea73..e79c306 100644 --- a/src/models/snipcart/Address.php +++ b/src/models/snipcart/Address.php @@ -2,18 +2,19 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; /** * Class Address * * @package fostercommerce\snipcart\models */ -class Address extends \craft\base\Model +class Address extends Model { /** * @var string Full name of addressee. @@ -104,26 +105,34 @@ public function getFormattedPhone() if (strlen($num) === 10 && is_numeric($num)) { // format US phone numbers (555) 555-5555 - return ($num) ? - '('.substr($num,0,3).') '.substr($num,3,3).'-'.substr($num,6,4) + return ($num !== '' && $num !== '0') ? + '(' . substr($num,0,3) . ') ' . substr($num,3,3) . '-' . substr($num,6,4) : ' '; } return $num; } - /** - * @inheritdoc - */ public function rules(): array { return [ - [['name', 'companyName', 'address1', 'address2', 'city', 'country', 'province', 'postalCode', 'phone', 'email'], 'string', 'max' => 255], + [['name', 'companyName', 'address1', 'address2', 'city', 'country', 'province', 'postalCode', 'phone', 'email'], + 'string', + 'max' => 255, + ], [['name', 'address1', 'city', 'country', 'province', 'postalCode'], 'required'], - [['companyName', 'address2', 'phone'], 'default', 'value' => null], - [['country'], 'default', 'value' => 'US'], - [['country', 'province'], 'string', 'length' => 2], + [['companyName', 'address2', 'phone'], + 'default', + 'value' => null, + ], + [['country'], + 'default', + 'value' => 'US', + ], + [['country', 'province'], + 'string', + 'length' => 2, + ], ]; } - } diff --git a/src/models/snipcart/Category.php b/src/models/snipcart/Category.php index cc15048..bb83b59 100644 --- a/src/models/snipcart/Category.php +++ b/src/models/snipcart/Category.php @@ -2,13 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class Category extends \craft\base\Model +use craft\base\Model; +class Category extends Model { - } diff --git a/src/models/snipcart/CustomField.php b/src/models/snipcart/CustomField.php index 207955d..b36f173 100644 --- a/src/models/snipcart/CustomField.php +++ b/src/models/snipcart/CustomField.php @@ -2,13 +2,14 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class CustomField extends \craft\base\Model +use craft\base\Model; +class CustomField extends Model { /** * @var @@ -44,5 +45,4 @@ class CustomField extends \craft\base\Model * @var */ public $optionsArray; - } diff --git a/src/models/snipcart/Customer.php b/src/models/snipcart/Customer.php index ea5f846..4460812 100644 --- a/src/models/snipcart/Customer.php +++ b/src/models/snipcart/Customer.php @@ -2,20 +2,23 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; +use craft\helpers\UrlHelper; /** * Snipcart Customer model * https://docs.snipcart.com/v2/api-reference/customers */ -class Customer extends \craft\base\Model +class Customer extends Model { - const STATUS_CONFIRMED = 'Confirmed'; - const STATUS_UNCONFIRMED = 'Unconfirmed'; + public const STATUS_CONFIRMED = 'Confirmed'; + + public const STATUS_UNCONFIRMED = 'Unconfirmed'; /** * @var string @@ -183,43 +186,33 @@ class Customer extends \craft\base\Model /** * Returns the Craft control panel URL for the detail page. - * @return string */ public function getCpUrl(): string { - return \craft\helpers\UrlHelper::cpUrl('snipcart/customer/' . $this->id); + return UrlHelper::cpUrl('snipcart/customer/' . $this->id); } /** * Returns the URL for the customer in the Snipcart customer dashboard. - * - * @return string|null */ - public function getDashboardUrl() + public function getDashboardUrl(): ?string { - if (! isset($this->id)) { + if ($this->id === null) { return null; } return 'https://app.snipcart.com/dashboard/customers/' . $this->id; } - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return ['creationDate']; } - /** - * @inheritdoc - */ public function extraFields(): array { return [ - 'cpUrl' + 'cpUrl', ]; } - } diff --git a/src/models/snipcart/CustomerStatistics.php b/src/models/snipcart/CustomerStatistics.php index 0cceedf..5469165 100644 --- a/src/models/snipcart/CustomerStatistics.php +++ b/src/models/snipcart/CustomerStatistics.php @@ -2,13 +2,14 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class CustomerStatistics extends \craft\base\Model +use craft\base\Model; +class CustomerStatistics extends Model { /** * @var int @@ -20,15 +21,21 @@ class CustomerStatistics extends \craft\base\Model */ public $ordersAmount; - /** - * @inheritdoc - */ public function rules(): array { return [ - [['ordersCount'], 'number', 'integerOnly' => true], - [['ordersAmount'], 'number', 'integerOnly' => false], - [['ordersCount', 'ordersAmount'], 'default', 'value' => 0], + [['ordersCount'], + 'number', + 'integerOnly' => true, + ], + [['ordersAmount'], + 'number', + 'integerOnly' => false, + ], + [['ordersCount', 'ordersAmount'], + 'default', + 'value' => 0, + ], ]; } } diff --git a/src/models/snipcart/DigitalGood.php b/src/models/snipcart/DigitalGood.php index 0c9f245..f14dd99 100644 --- a/src/models/snipcart/DigitalGood.php +++ b/src/models/snipcart/DigitalGood.php @@ -2,12 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class DigitalGood extends \craft\base\Model +use craft\base\Model; +class DigitalGood extends Model { -} \ No newline at end of file +} diff --git a/src/models/snipcart/Dimensions.php b/src/models/snipcart/Dimensions.php index 8fd0144..1d3d33c 100644 --- a/src/models/snipcart/Dimensions.php +++ b/src/models/snipcart/Dimensions.php @@ -2,13 +2,14 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class Dimensions extends \craft\base\Model +use craft\base\Model; +class Dimensions extends Model { /** * @var @@ -29,5 +30,4 @@ class Dimensions extends \craft\base\Model * @var */ public $weight; - } diff --git a/src/models/snipcart/Discount.php b/src/models/snipcart/Discount.php index 46448b1..06eca2d 100644 --- a/src/models/snipcart/Discount.php +++ b/src/models/snipcart/Discount.php @@ -2,27 +2,34 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; +use craft\helpers\UrlHelper; /** * https://docs.snipcart.com/v2/api-reference/discounts */ - -class Discount extends \craft\base\Model +class Discount extends Model { - const TRIGGER_CODE = 'Code'; - const TRIGGER_TOTAL = 'Total'; - const TRIGGER_PRODUCT = 'Product'; + public const TRIGGER_CODE = 'Code'; + + public const TRIGGER_TOTAL = 'Total'; + + public const TRIGGER_PRODUCT = 'Product'; + + public const TYPE_FIXED_AMOUNT = 'FixedAmount'; + + public const TYPE_FIXED_AMOUNT_ON_ITEMS = 'FixedAmountOnItems'; - const TYPE_FIXED_AMOUNT = 'FixedAmount'; - const TYPE_FIXED_AMOUNT_ON_ITEMS = 'FixedAmountOnItems'; - const TYPE_RATE = 'Rate'; - const TYPE_ALTERNATE_PRICE = 'AlternatePrice'; - const TYPE_ALTERNATE_SHIPPING = 'Shipping'; + public const TYPE_RATE = 'Rate'; + + public const TYPE_ALTERNATE_PRICE = 'AlternatePrice'; + + public const TYPE_ALTERNATE_SHIPPING = 'Shipping'; /** * @var string "2223490d-84c1-480c-b713-50cb0b819313" @@ -263,30 +270,30 @@ class Discount extends \craft\base\Model */ public $savedAmount; - private $_triggerOptionFieldMap = [ + private array $_triggerOptionFieldMap = [ self::TRIGGER_CODE => [ - 'code' + 'code', ], self::TRIGGER_TOTAL => [ - 'totalToReach' + 'totalToReach', ], self::TRIGGER_PRODUCT => [ - 'itemId' + 'itemId', ], ]; - private $_typeOptionFieldMap = [ + private array $_typeOptionFieldMap = [ self::TYPE_FIXED_AMOUNT => [ - 'amount' + 'amount', ], self::TYPE_FIXED_AMOUNT_ON_ITEMS => [ - 'productIds' + 'productIds', ], self::TYPE_RATE => [ - 'rate' + 'rate', ], self::TYPE_ALTERNATE_PRICE => [ - 'alternatePrice' + 'alternatePrice', ], self::TYPE_ALTERNATE_SHIPPING => [ 'shippingDescription', @@ -295,24 +302,24 @@ class Discount extends \craft\base\Model ], ]; - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return ['expires']; } - /** - * @inheritdoc - */ public function rules(): array { return [ [['name', 'trigger', 'code', 'itemId', 'type', 'productIds', 'shippingDescription'], 'string'], [['name', 'trigger', 'type'], 'required'], - [['maxNumberOfUsages', 'shippingGuaranteedDaysToDelivery', 'numberOfUsages', 'numberOfUsagesUncompleted'], 'number', 'integerOnly' => true], - [['totalToReach', 'amount', 'amountSaved', 'rate', 'alternatePrice', 'shippingCost'], 'number', 'integerOnly' => false], + [['maxNumberOfUsages', 'shippingGuaranteedDaysToDelivery', 'numberOfUsages', 'numberOfUsagesUncompleted'], + 'number', + 'integerOnly' => true, + ], + [['totalToReach', 'amount', 'amountSaved', 'rate', 'alternatePrice', 'shippingCost'], + 'number', + 'integerOnly' => false, + ], ]; } @@ -321,8 +328,6 @@ public function rules(): array * once it's clear how to get them working. * * @param bool $isNew true if this is a new Discount record - * - * @return array */ public function getPayloadForPost($isNew = true): array { @@ -354,8 +359,6 @@ public function getPayloadForPost($isNew = true): array /** * Gets a list of field options relevant to the selected trigger. - * - * @return array */ public function getTriggerOptionFields(): array { @@ -364,8 +367,6 @@ public function getTriggerOptionFields(): array /** * Gets a list of discount field options relevant to the selected type. - * - * @return array */ public function getTypeOptionFields(): array { @@ -374,22 +375,17 @@ public function getTypeOptionFields(): array /** * Returns the Craft control panel URL for the detail page. - * - * @return string */ public function getCpUrl(): string { - return \craft\helpers\UrlHelper::cpUrl('snipcart/discount/' . $this->id); + return UrlHelper::cpUrl('snipcart/discount/' . $this->id); } /** * Returns the Snipcart dashboard URL for the discount. - * - * @return string */ public function getDashboardUrl(): string { return 'https://app.snipcart.com/dashboard/discounts/edit/' . $this->id; } - } diff --git a/src/models/snipcart/Domain.php b/src/models/snipcart/Domain.php index a4b4e59..48654be 100644 --- a/src/models/snipcart/Domain.php +++ b/src/models/snipcart/Domain.php @@ -2,17 +2,17 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; /** * https://docs.snipcart.com/v2/api-reference/domains */ - -class Domain extends \craft\base\Model +class Domain extends Model { /** * @var @@ -23,5 +23,4 @@ class Domain extends \craft\base\Model * @var */ public $protocol; - } diff --git a/src/models/snipcart/Item.php b/src/models/snipcart/Item.php index f0f3ad1..847f895 100644 --- a/src/models/snipcart/Item.php +++ b/src/models/snipcart/Item.php @@ -2,17 +2,17 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; +use craft\elements\MatrixBlock; use craft\base\ElementInterface; -use fostercommerce\snipcart\models\snipcart\PaymentSchedule; use fostercommerce\snipcart\helpers\ModelHelper; use fostercommerce\snipcart\records\ProductDetails as ProductDetailsRecord; -use craft\elements\MatrixBlock; /** * Class Item @@ -21,7 +21,7 @@ * * @property PaymentSchedule|null $paymentSchedule */ -class Item extends \craft\base\Model +class Item extends Model { /** * @var string Snipcart's own unique ID for the item. @@ -212,7 +212,7 @@ class Item extends \craft\base\Model * @var */ public $hasTaxesIncluded; - + /** * @var */ @@ -233,22 +233,13 @@ class Item extends \craft\base\Model */ public $cancellationAction; - /** - * @var PaymentSchedule - */ - private $paymentSchedule; + private ?PaymentSchedule $paymentSchedule = null; - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return ['modificationDate']; } - /** - * @inheritdoc - */ public function extraFields(): array { return ['paymentSchedule']; @@ -265,14 +256,16 @@ public function extraFields(): array public function getRelatedElement($entryOnly = false) { // get related record by SKU - if (! $record = ProductDetailsRecord::findOne([ 'sku' => $this->id ])) { + if (! ($record = ProductDetailsRecord::findOne([ + 'sku' => $this->id, + ])) instanceof ProductDetailsRecord) { // bail without a Record, which can happen if the product's details // aren't stored in our Product Details field type return null; } if ($element = \Craft::$app->getElements()->getElementById($record->elementId)) { - $isMatrix = $element && get_class($element) === MatrixBlock::class; + $isMatrix = $element && $element instanceof MatrixBlock; if ($isMatrix && $entryOnly) { return $element->getOwner(); @@ -295,15 +288,13 @@ public function getPaymentSchedule() /** * @param PaymentSchedule|array|null $paymentSchedule - * @return PaymentSchedule|null */ - public function setPaymentSchedule($paymentSchedule) + public function setPaymentSchedule($paymentSchedule): ?PaymentSchedule { if ($paymentSchedule === null) { return $this->paymentSchedule = null; } - if (! $paymentSchedule instanceof PaymentSchedule) { $paymentScheduleData = ModelHelper::stripUnknownProperties( $paymentSchedule, diff --git a/src/models/snipcart/Notification.php b/src/models/snipcart/Notification.php index e1756e8..d81def0 100644 --- a/src/models/snipcart/Notification.php +++ b/src/models/snipcart/Notification.php @@ -2,34 +2,47 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; /** * https://docs.snipcart.com/v2/api-reference/notifications */ - -class Notification extends \craft\base\Model +class Notification extends Model { - const TYPE_INVOICE = 'Invoice'; - const TYPE_COMMENT = 'Comment'; - const TYPE_TRACKING_NUMBER = 'TrackingNumber'; - const TYPE_ORDER_CANCELLED = 'OrderCancelled'; - const TYPE_REFUND = 'Refund'; - const TYPE_ORDER_SHIPPED = 'OrderShipped'; - const TYPE_ORDER_RECEIVED = 'OrderReceived'; - const TYPE_ORDER_PAYMENT_EXPIRED = 'OrderPaymentExpired'; - const TYPE_ORDER_STATUS_CHANGED = 'OrderStatusChanged'; - const TYPE_RECOVERY_CAMPAIGN = 'RecoveryCampaign'; - const TYPE_DIGITAL_DOWNLOAD = 'DigitalDownload'; - const TYPE_LOGS = 'Logs'; - const TYPE_OTHER = 'Other'; - - const DELIVERY_METHOD_EMAIL = 'Email'; - const DELIVERY_METHOD_NONE = 'None'; + public const TYPE_INVOICE = 'Invoice'; + + public const TYPE_COMMENT = 'Comment'; + + public const TYPE_TRACKING_NUMBER = 'TrackingNumber'; + + public const TYPE_ORDER_CANCELLED = 'OrderCancelled'; + + public const TYPE_REFUND = 'Refund'; + + public const TYPE_ORDER_SHIPPED = 'OrderShipped'; + + public const TYPE_ORDER_RECEIVED = 'OrderReceived'; + + public const TYPE_ORDER_PAYMENT_EXPIRED = 'OrderPaymentExpired'; + + public const TYPE_ORDER_STATUS_CHANGED = 'OrderStatusChanged'; + + public const TYPE_RECOVERY_CAMPAIGN = 'RecoveryCampaign'; + + public const TYPE_DIGITAL_DOWNLOAD = 'DigitalDownload'; + + public const TYPE_LOGS = 'Logs'; + + public const TYPE_OTHER = 'Other'; + + public const DELIVERY_METHOD_EMAIL = 'Email'; + + public const DELIVERY_METHOD_NONE = 'None'; /** * @var string "0c3ac0bb-a94a-45c5-a4d8-a7934a7f180a" @@ -98,9 +111,6 @@ class Notification extends \craft\base\Model */ public $resourceUrl; - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return ['creationDate', 'sentByEmailOn', 'sentOn']; @@ -128,5 +138,4 @@ public function getNotificationTypes(): array self::TYPE_OTHER, ]; } - } diff --git a/src/models/snipcart/Order.php b/src/models/snipcart/Order.php index 3e728d9..e78bf90 100644 --- a/src/models/snipcart/Order.php +++ b/src/models/snipcart/Order.php @@ -2,15 +2,18 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; +use craft\helpers\UrlHelper; use fostercommerce\snipcart\behaviors\BillingAddressBehavior; use fostercommerce\snipcart\behaviors\ShippingAddressBehavior; use fostercommerce\snipcart\helpers\ModelHelper; +use fostercommerce\snipcart\Snipcart; /** * Snipcart Order model @@ -46,153 +49,83 @@ * @property string $shippingAddressPhone * @property string $dashboardUrl */ -class Order extends \craft\base\Model +class Order extends Model { - const PAYMENT_METHOD_CREDIT_CARD = 'CreditCard'; - const PAYMENT_STATUS_PAID = 'Paid'; + public const PAYMENT_METHOD_CREDIT_CARD = 'CreditCard'; - const STATUS_IN_PROGRESS = 'InProgress'; - const STATUS_PROCESSED = 'Processed'; - const STATUS_DISPUTED = 'Disputed'; - const STATUS_SHIPPPED = 'Shipped'; - const STATUS_DELIVERED = 'Delivered'; - const STATUS_PENDING = 'Pending'; - const STATUS_CANCELLED = 'Cancelled'; + public const PAYMENT_STATUS_PAID = 'Paid'; - /** - * @var string - */ - public $token; + public const STATUS_IN_PROGRESS = 'InProgress'; - /** - * @var string|null - */ - public $parentToken; + public const STATUS_PROCESSED = 'Processed'; - /** - * @var \DateTime Date order was created. ("2018-12-05T18:37:19Z") - */ - public $creationDate; + public const STATUS_DISPUTED = 'Disputed'; - /** - * @var \DateTime Date order was last modified. ("2018-12-05T18:37:19Z") - */ - public $modificationDate; + public const STATUS_SHIPPPED = 'Shipped'; - /** - * @var \DateTime Date the order was completed. - */ - public $completionDate; + public const STATUS_DELIVERED = 'Delivered'; - /** - * @var string Order status. - */ - public $status; + public const STATUS_PENDING = 'Pending'; - /** - * @var string - */ - public $paymentStatus; + public const STATUS_CANCELLED = 'Cancelled'; - /** - * @var string - */ - public $paymentMethod; + public string $token; /** - * @var string + * @var string|null */ - public $invoiceNumber; + public string $parentToken; /** - * @var string + * @var \DateTime Date order was created. ("2018-12-05T18:37:19Z") */ - public $parentInvoiceNumber; + public \DateTime $creationDate; /** - * @var string + * @var \DateTime Date order was last modified. ("2018-12-05T18:37:19Z") */ - public $email; + public \DateTime $modificationDate; /** - * @var Customer|null + * @var \DateTime Date the order was completed. */ - private $_user; + public \DateTime $completionDate; /** - * @var string + * @var string Order status. */ - public $cardHolderName; + public string $status; - /** - * @var - */ - public $creditCardLast4Digits; + public string $paymentStatus; - /** - * @var Address - */ - private $_billingAddress; + public string $paymentMethod; - /** - * @var Address - */ - private $_shippingAddress; + public string $invoiceNumber; - /** - * @var string - */ - public $notes; + public string $parentInvoiceNumber; - /** - * @var bool - */ - public $shippingAddressSameAsBilling; + public string $email; - /** - * @var bool - */ - public $isRecurringOrder; + public string $cardHolderName; /** - * @var float + * @var */ - public $finalGrandTotal; + public string $creditCardLast4Digits; - /** - * @var float - */ - public $shippingFees; + public string $notes; - /** - * @var string - */ - public $shippingMethod; + public bool $shippingAddressSameAsBilling; - /** - * @var Discount[] - */ - private $_discounts = []; + public bool $isRecurringOrder; - /** - * @var Plan[] - */ - private $_plans = []; + public float $finalGrandTotal; - /** - * @var Item[] - */ - private $_items = []; + public float $shippingFees; - /** - * @var Refund[] - */ - private $_refunds = []; + public string $shippingMethod; - /** - * @var array - */ - public $taxes; + public array $taxes = []; /** * @var @@ -415,8 +348,34 @@ class Order extends \craft\base\Model public $paymentDetails; /** - * @return array + * @var Customer|null */ + private mixed $_user; + + private Address $_billingAddress; + + private Address $_shippingAddress; + + /** + * @var Discount[] + */ + private array $_discounts = []; + + /** + * @var Plan[] + */ + private array $_plans = []; + + /** + * @var Item[] + */ + private array $_items = []; + + /** + * @var Refund[] + */ + private array $_refunds = []; + public function getDiscounts(): array { return $this->_discounts; @@ -424,16 +383,12 @@ public function getDiscounts(): array /** * @param $discounts - * @return mixed */ - public function setDiscounts($discounts) + public function setDiscounts(array $discounts): mixed { return $this->_discounts = $discounts; } - /** - * @return array - */ public function getItems(): array { return $this->_items; @@ -441,9 +396,8 @@ public function getItems(): array /** * @param mixed[] $items - * @return array|null */ - public function setItems($items) + public function setItems(array $items): ?array { foreach ($items as &$item) { if (! $item instanceof Item) { @@ -459,9 +413,6 @@ public function setItems($items) return $this->_items = $items; } - /** - * @return array - */ public function getPlans(): array { return $this->_plans; @@ -469,16 +420,12 @@ public function getPlans(): array /** * @param $plans - * @return mixed */ - public function setPlans($plans) + public function setPlans(array $plans): mixed { return $this->_plans = $plans; } - /** - * @return array - */ public function getRefunds(): array { return $this->_refunds; @@ -486,9 +433,8 @@ public function getRefunds(): array /** * @param $refunds - * @return mixed */ - public function setRefunds($refunds) + public function setRefunds(array $refunds): mixed { return $this->_refunds = $refunds; } @@ -496,34 +442,46 @@ public function setRefunds($refunds) /** * @return Customer|null */ - public function getUser() + public function getUser(): Customer { return $this->_user; } /** * @param $user - * @return mixed */ - public function setUser($user) + public function setUser(mixed $user): mixed { - return $this->_user = $user; - } + if ($user === null) { + return null; + } + + if (gettype($user) === 'object') { + $user = (array) $user; + } + // added a bit to get a user element based on the email passed in from $user as it is an array + $craftUser = \Craft::$app->users->getUserByUsernameOrEmail($user['email']); + return $this->_user = $craftUser; + } /** * @param Address|array $address * @return Address */ - public function setBillingAddress($address): Address + public function setBillingAddress($address): ?Address { if (! $address instanceof Address) { + if ($address === null) { + $address = []; + } + $addrData = ModelHelper::stripUnknownProperties( $address, Address::class ); - $address = new Address($addrData); + $address = new Address((array) $addrData); } return $this->_billingAddress = $address; @@ -533,36 +491,35 @@ public function setBillingAddress($address): Address * @param Address|array $address * @return Address */ - public function setShippingAddress($address): Address + public function setShippingAddress($address): ?Address { if (! $address instanceof Address) { + if ($address === null) { + $address = []; + } + $addrData = ModelHelper::stripUnknownProperties( $address, Address::class ); - - $address = new Address($addrData); + $addressModel = new Address((array) $addrData); } - return $this->_shippingAddress = $address; + return $this->_shippingAddress = $addressModel; } /** * Returns the Craft control panel URL for the detail page. - * - * @return string */ public function getCpUrl(): string { - return \craft\helpers\UrlHelper::cpUrl('snipcart/order/' . $this->token); + return UrlHelper::cpUrl('snipcart/order/' . $this->token); } /** * Returns the URL for the order in the Snipcart customer dashboard. - * - * @return string|null */ - public function getDashboardUrl() + public function getDashboardUrl(): ?string { if (! isset($this->token)) { return null; @@ -574,8 +531,6 @@ public function getDashboardUrl() /** * Returns `true` if order items contain at least one OrderItem with * a `shippable` property that's `true. - * - * @return bool */ public function hasShippableItems(): bool { @@ -588,9 +543,6 @@ public function hasShippableItems(): bool return false; } - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return ['creationDate', 'modificationDate', 'completionDate']; @@ -607,19 +559,16 @@ public function behaviors(): array $behaviors = parent::behaviors(); $behaviors['billingAddress'] = [ - 'class' => BillingAddressBehavior::class + 'class' => BillingAddressBehavior::class, ]; $behaviors['shippingAddress'] = [ - 'class' => ShippingAddressBehavior::class + 'class' => ShippingAddressBehavior::class, ]; return $behaviors; } - /** - * @inheritdoc - */ public function rules(): array { return [ @@ -650,23 +599,23 @@ public function rules(): array 'recoveredFromCampaignId', 'trackingNumber', 'trackingUrl', - ], 'string'], + ], 'string'], [[ 'shippingAddressSameAsBilling', 'willBePaidLater', 'billingAddressComplete', 'shippingAddressComplete', 'shippingMethodComplete', - 'isRecurringOrder' - ], 'boolean'], + 'isRecurringOrder', + ], 'boolean'], //[['creationDate', 'modificationDate', 'completionDate'], 'date', 'format' => 'php:c'], - [['finalGrandTotal', 'shippingFees', 'rebateAmount'], 'number', 'integerOnly' => false], + [['finalGrandTotal', 'shippingFees', 'rebateAmount'], + 'number', + 'integerOnly' => false, + ], ]; } - /** - * @inheritdoc - */ public function extraFields(): array { return [ @@ -697,8 +646,7 @@ public function extraFields(): array 'shippingAddressProvince', 'shippingAddressPostalCode', 'shippingAddressPhone', - 'cpUrl' + 'cpUrl', ]; } - } diff --git a/src/models/snipcart/OrderEvent.php b/src/models/snipcart/OrderEvent.php index 54d2654..680bec6 100644 --- a/src/models/snipcart/OrderEvent.php +++ b/src/models/snipcart/OrderEvent.php @@ -2,13 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class OrderEvent extends \craft\base\Model +use craft\base\Model; +class OrderEvent extends Model { - } diff --git a/src/models/snipcart/Package.php b/src/models/snipcart/Package.php index 3713b26..c0c317a 100644 --- a/src/models/snipcart/Package.php +++ b/src/models/snipcart/Package.php @@ -2,20 +2,24 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class Package extends \craft\base\Model +use craft\base\Model; +class Package extends Model { - const WEIGHT_UNIT_GRAM = 'gram'; - const WEIGHT_UNIT_POUND = 'pound'; - const WEIGHT_UNIT_OUNCE = 'ounce'; + public const WEIGHT_UNIT_GRAM = 'gram'; - const DIMENSION_UNIT_INCH = 'inch'; - const DIMENSION_UNIT_CENTIMETER = 'centimeter'; + public const WEIGHT_UNIT_POUND = 'pound'; + + public const WEIGHT_UNIT_OUNCE = 'ounce'; + + public const DIMENSION_UNIT_INCH = 'inch'; + + public const DIMENSION_UNIT_CENTIMETER = 'centimeter'; /** * @var string Friendly slug for this packaging type. @@ -52,24 +56,28 @@ class Package extends \craft\base\Model */ public $dimensionUnit = self::DIMENSION_UNIT_INCH; - /** - * @inheritdoc - */ public function rules(): array { return [ - [['length', 'width', 'height', 'weight'], 'number', 'integerOnly' => false], + [['length', 'width', 'height', 'weight'], + 'number', + 'integerOnly' => false, + ], [['name'], 'string'], [['name', 'length', 'width', 'height', 'weight'], 'required'], - [['weightUnit'], 'in', 'range' => [self::WEIGHT_UNIT_GRAM, self::WEIGHT_UNIT_POUND, self::WEIGHT_UNIT_OUNCE]], - [['dimensionUnit'], 'in', 'range' => [self::DIMENSION_UNIT_INCH, self::DIMENSION_UNIT_CENTIMETER]], + [['weightUnit'], + 'in', + 'range' => [self::WEIGHT_UNIT_GRAM, self::WEIGHT_UNIT_POUND, self::WEIGHT_UNIT_OUNCE], + ], + [['dimensionUnit'], + 'in', + 'range' => [self::DIMENSION_UNIT_INCH, self::DIMENSION_UNIT_CENTIMETER], + ], ]; } /** * True if valid, non-zero length, width, and height are all present. - * - * @return bool */ public function hasPhysicalDimensions(): bool { @@ -77,5 +85,4 @@ public function hasPhysicalDimensions(): bool $this->width !== null && $this->width > 0 && $this->height !== null && $this->height > 0; } - } diff --git a/src/models/snipcart/PaymentSchedule.php b/src/models/snipcart/PaymentSchedule.php index 8629771..988f958 100644 --- a/src/models/snipcart/PaymentSchedule.php +++ b/src/models/snipcart/PaymentSchedule.php @@ -2,13 +2,14 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class PaymentSchedule extends \craft\base\Model +use craft\base\Model; +class PaymentSchedule extends Model { /** * @var string|bool @@ -30,9 +31,6 @@ class PaymentSchedule extends \craft\base\Model */ public $startsOn; - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return ['startsOn']; @@ -50,25 +48,23 @@ public function datetimeAttributes(): array * - `2 weeks` * - `3 months` * - `year` - * - * @return string */ public function getIntervalLabel(): string { - if (!$this->intervalCount) { - return ""; + if ($this->intervalCount === 0) { + return ''; } - $label = ""; + $label = ''; if ($this->intervalCount > 1) { - $label .= $this->intervalCount . " "; + $label .= $this->intervalCount . ' '; } $label .= strtolower($this->interval); if ($this->intervalCount !== 1) { - $label .= "s"; + $label .= 's'; } return $label; diff --git a/src/models/snipcart/Plan.php b/src/models/snipcart/Plan.php index c932125..af8e22c 100644 --- a/src/models/snipcart/Plan.php +++ b/src/models/snipcart/Plan.php @@ -2,13 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class Plan extends \craft\base\Model +use craft\base\Model; +class Plan extends Model { - } diff --git a/src/models/snipcart/Product.php b/src/models/snipcart/Product.php index 82efdba..83bd4f9 100644 --- a/src/models/snipcart/Product.php +++ b/src/models/snipcart/Product.php @@ -2,17 +2,17 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; /** * https://docs.snipcart.com/v2/api-reference/products */ - -class Product extends \craft\base\Model +class Product extends Model { /** * @var @@ -73,8 +73,9 @@ class Product extends \craft\base\Model * @var */ public $statistics; - // numberOfSales - // totalSales + + // numberOfSales + // totalSales /** * @var @@ -157,12 +158,8 @@ class Product extends \craft\base\Model ] */ - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return ['creationDate', 'modificationDate']; } - } diff --git a/src/models/snipcart/ProductVariant.php b/src/models/snipcart/ProductVariant.php index 8784678..770f829 100644 --- a/src/models/snipcart/ProductVariant.php +++ b/src/models/snipcart/ProductVariant.php @@ -2,13 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class ProductVariant extends \craft\base\Model +use craft\base\Model; +class ProductVariant extends Model { - } diff --git a/src/models/snipcart/Refund.php b/src/models/snipcart/Refund.php index 534deaf..65d63e2 100644 --- a/src/models/snipcart/Refund.php +++ b/src/models/snipcart/Refund.php @@ -2,13 +2,14 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class Refund extends \craft\base\Model +use craft\base\Model; +class Refund extends Model { /** * @var string The refund's unique identifier. @@ -60,17 +61,11 @@ class Refund extends \craft\base\Model */ public $modificationDate; - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return ['creationDate', 'modificationDate']; } - /** - * @return array - */ public function getPayloadForPost(): array { $payload = $this->toArray(); @@ -89,5 +84,4 @@ public function getPayloadForPost(): array return $payload; } - } diff --git a/src/models/snipcart/ShippingEvent.php b/src/models/snipcart/ShippingEvent.php index a9e2aa2..2686cdb 100644 --- a/src/models/snipcart/ShippingEvent.php +++ b/src/models/snipcart/ShippingEvent.php @@ -2,13 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class ShippingEvent extends \craft\base\Model +use craft\base\Model; +class ShippingEvent extends Model { - } diff --git a/src/models/snipcart/ShippingMethod.php b/src/models/snipcart/ShippingMethod.php index 0f88ef0..e93e587 100644 --- a/src/models/snipcart/ShippingMethod.php +++ b/src/models/snipcart/ShippingMethod.php @@ -2,17 +2,17 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; /** * https://docs.snipcart.com/v2/api-reference/custom-shipping-methods */ - -class ShippingMethod extends \craft\base\Model +class ShippingMethod extends Model { /** * @var @@ -43,46 +43,45 @@ class ShippingMethod extends \craft\base\Model * @var */ public $guaranteedEstimatedDelivery; - // minimumDaysForDelivery 10 - // maximumDaysForDelivery null + + // minimumDaysForDelivery 10 + // maximumDaysForDelivery null /** * @var */ public $location; - // country null, - // province null + + // country null, + // province null /** * @var */ public $rates; - // { - // "cost": 20, - // "weight": { - // "to": 1000 - // } - // }, - // { - // "cost": 30, - // "weight": { - // "from": 1000, - // "to": 2000 - // } - // }, - // { - // "cost": 60, - // "weight": { - // "from": 3000 - // } - // } - /** - * @inheritdoc - */ + // { + // "cost": 20, + // "weight": { + // "to": 1000 + // } + // }, + // { + // "cost": 30, + // "weight": { + // "from": 1000, + // "to": 2000 + // } + // }, + // { + // "cost": 60, + // "weight": { + // "from": 3000 + // } + // } + public function datetimeAttributes(): array { return ['creationDate', 'modificationDate']; } - } diff --git a/src/models/snipcart/ShippingRate.php b/src/models/snipcart/ShippingRate.php index 08bf59f..e181860 100644 --- a/src/models/snipcart/ShippingRate.php +++ b/src/models/snipcart/ShippingRate.php @@ -2,23 +2,23 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; /** * https://docs.snipcart.com/v2/api-reference/custom-shipping-methods */ - -class ShippingRate extends \craft\base\Model +class ShippingRate extends Model { /** * @var float */ public $cost; - + /** * @var string */ @@ -34,22 +34,22 @@ class ShippingRate extends \craft\base\Model */ public $guaranteedDaysToDelivery; - /** - * @inheritdoc - */ public function rules(): array { return [ - [['guaranteedDaysToDelivery'], 'number', 'integerOnly' => true], - [['cost'], 'number', 'integerOnly' => false], + [['guaranteedDaysToDelivery'], + 'number', + 'integerOnly' => true, + ], + [['cost'], + 'number', + 'integerOnly' => false, + ], [['description', 'code'], 'string'], [['cost', 'description'], 'required'], ]; } - /** - * @inheritdoc - */ public function fields(): array { $return = [ diff --git a/src/models/snipcart/Subscription.php b/src/models/snipcart/Subscription.php index 8676449..2882602 100644 --- a/src/models/snipcart/Subscription.php +++ b/src/models/snipcart/Subscription.php @@ -2,12 +2,14 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; +use craft\helpers\UrlHelper; use fostercommerce\snipcart\Snipcart; /** @@ -16,11 +18,13 @@ * * @package fostercommerce\snipcart\models */ -class Subscription extends \craft\base\Model +class Subscription extends Model { - const STATUS_ACTIVE = 'Active'; - const STATUS_PAUSED = 'Paused'; - const STATUS_CANCELED = 'Canceled'; + public const STATUS_ACTIVE = 'Active'; + + public const STATUS_PAUSED = 'Paused'; + + public const STATUS_CANCELED = 'Canceled'; /** * @var @@ -137,9 +141,6 @@ class Subscription extends \craft\base\Model */ public $invoiceNumber; - /** - * @inheritdoc - */ public function datetimeAttributes(): array { return ['creationDate', 'modificationDate', 'cancelledOn', 'nextBillingDate', 'firstInvoiceReceivedOn']; @@ -147,7 +148,7 @@ public function datetimeAttributes(): array public function getCpUrl(): string { - return \craft\helpers\UrlHelper::cpUrl('snipcart/subscription/' . $this->id); + return UrlHelper::cpUrl('snipcart/subscription/' . $this->id); } public function getDashboardUrl(): string diff --git a/src/models/snipcart/SubscriptionEvent.php b/src/models/snipcart/SubscriptionEvent.php index c0b1892..24b9981 100644 --- a/src/models/snipcart/SubscriptionEvent.php +++ b/src/models/snipcart/SubscriptionEvent.php @@ -2,13 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class SubscriptionEvent extends \craft\base\Model +use craft\base\Model; +class SubscriptionEvent extends Model { - } diff --git a/src/models/snipcart/Tax.php b/src/models/snipcart/Tax.php index 9817a50..eb726d6 100644 --- a/src/models/snipcart/Tax.php +++ b/src/models/snipcart/Tax.php @@ -2,21 +2,21 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; +use craft\base\Model; /** * Class Tax * https://docs.snipcart.com/v2/webhooks/taxes * * @package fostercommerce\snipcart\models */ -class Tax extends \craft\base\Model +class Tax extends Model { - /** * @var string */ @@ -31,5 +31,4 @@ class Tax extends \craft\base\Model * @var string */ public $numberForInvoice; - } diff --git a/src/models/snipcart/TaxesEvent.php b/src/models/snipcart/TaxesEvent.php index 39a09c4..66b0e40 100644 --- a/src/models/snipcart/TaxesEvent.php +++ b/src/models/snipcart/TaxesEvent.php @@ -2,13 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class TaxesEvent extends \craft\base\Model +use craft\base\Model; +class TaxesEvent extends Model { - } diff --git a/src/models/snipcart/UserSession.php b/src/models/snipcart/UserSession.php index ac391a2..95e922c 100644 --- a/src/models/snipcart/UserSession.php +++ b/src/models/snipcart/UserSession.php @@ -2,13 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\models\snipcart; -class UserSession extends \craft\base\Model +use craft\base\Model; +class UserSession extends Model { - } diff --git a/src/providers/shipstation/Settings.php b/src/providers/shipstation/Settings.php index d38acc0..ab8a602 100644 --- a/src/providers/shipstation/Settings.php +++ b/src/providers/shipstation/Settings.php @@ -2,15 +2,16 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\providers\shipstation; -class Settings extends \craft\base\Model +use craft\base\Model; +class Settings extends Model { - const ORDER_CONFIRMATION_DELIVERY = 'delivery'; + public const ORDER_CONFIRMATION_DELIVERY = 'delivery'; /** * @var string @@ -57,18 +58,20 @@ class Settings extends \craft\base\Model */ public $sendCompletedOrders = false; - /** - * @inheritdoc - */ public function rules(): array { return [ [['apiKey', 'apiSecret', 'defaultCountry', 'defaultWarehouseId', 'defaultOrderConfirmation'], 'required'], [['apiKey', 'apiSecret', 'defaultCarrierCode', 'defaultPackageCode', 'defaultOrderConfirmation'], 'string'], - [['defaultWarehouseId'], 'number', 'integerOnly' => true], + [['defaultWarehouseId'], + 'number', + 'integerOnly' => true, + ], [['enableShippingRates', 'sendCompletedOrders'], 'boolean'], - [['defaultCountry'], 'string', 'length' => 2], + [['defaultCountry'], + 'string', + 'length' => 2, + ], ]; } - } diff --git a/src/providers/shipstation/ShipStation.php b/src/providers/shipstation/ShipStation.php index 32755a7..42cdc62 100644 --- a/src/providers/shipstation/ShipStation.php +++ b/src/providers/shipstation/ShipStation.php @@ -2,27 +2,29 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\providers\shipstation; +use GuzzleHttp\Client; +use fostercommerce\snipcart\errors\ShippingRateException; use Craft; use craft\helpers\Json; +use fostercommerce\snipcart\base\ShippingProvider; +use fostercommerce\snipcart\helpers\ModelHelper; use fostercommerce\snipcart\helpers\VersionHelper; -use fostercommerce\snipcart\models\snipcart\Order as SnipcartOrder; -use fostercommerce\snipcart\models\snipcart\Package; -use fostercommerce\snipcart\models\snipcart\ShippingRate as SnipcartRate; use fostercommerce\snipcart\models\shipstation\Dimensions; use fostercommerce\snipcart\models\shipstation\Order; use fostercommerce\snipcart\models\shipstation\Rate; use fostercommerce\snipcart\models\shipstation\Weight; -use fostercommerce\snipcart\Snipcart; -use fostercommerce\snipcart\helpers\ModelHelper; -use fostercommerce\snipcart\base\ShippingProvider; -use fostercommerce\snipcart\providers\shipstation\Settings as ShipStationSettings; +use fostercommerce\snipcart\models\snipcart\Order as SnipcartOrder; +use fostercommerce\snipcart\models\snipcart\Package; +use fostercommerce\snipcart\models\snipcart\ShippingRate as SnipcartRate; use fostercommerce\snipcart\providers\shipstation\events\OrderEvent; +use fostercommerce\snipcart\providers\shipstation\Settings as ShipStationSettings; +use fostercommerce\snipcart\Snipcart; /** * Class ShipStation @@ -35,45 +37,28 @@ class ShipStation extends ShippingProvider /** * @event WebhookEvent Triggered before an order is sent to ShipStation. */ - const EVENT_BEFORE_SEND_ORDER = 'beforeSendOrder'; + public const EVENT_BEFORE_SEND_ORDER = 'beforeSendOrder'; /** * @var int fake ID returned to simulate success in test mode */ - const TEST_ORDER_ID = 99999999; + public const TEST_ORDER_ID = 99_999_999; /** - * @var \GuzzleHttp\Client + * @var Client */ protected $client; - /** - * @inheritdoc - */ public static function refHandle(): string { return 'shipStation'; } - /** - * @inheritdoc - */ public static function apiBaseUrl(): string { return 'https://ssapi.shipstation.com/'; } - /** - * @inheritdoc - */ - protected function createSettingsModel() - { - return new ShipStationSettings(); - } - - /** - * @inheritdoc - */ public function isConfigured(): bool { if ($settings = $this->getSettings()) { @@ -87,12 +72,9 @@ public function isConfigured(): bool return false; } - /** - * @inheritdoc - */ - public function getClient(): \GuzzleHttp\Client + public function getClient(): Client { - if ($this->client !== null) { + if ($this->client instanceof Client) { return $this->client; } @@ -106,13 +88,13 @@ public function getClient(): \GuzzleHttp\Client $clientConfig = [ 'base_uri' => self::apiBaseUrl(), - 'auth' => [ $key, $secret ], + 'auth' => [$key, $secret], 'headers' => [ 'Content-Type' => 'application/json; charset=utf-8', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], 'verify' => false, - 'debug' => false + 'debug' => false, ]; $this->client = Craft::createGuzzleClient($clientConfig); @@ -120,9 +102,6 @@ public function getClient(): \GuzzleHttp\Client return $this->client; } - /** - * @inheritdoc - */ public function getRatesForOrder(SnipcartOrder $snipcartOrder, Package $package): array { $rates = []; @@ -135,9 +114,9 @@ public function getRatesForOrder(SnipcartOrder $snipcartOrder, Package $package) $rate = new Rate($responseItem); $rates[] = new SnipcartRate([ - 'cost' => number_format($rate->shipmentCost + $rate->otherCost, 2), + 'cost' => number_format($rate->shipmentCost + $rate->otherCost, 2), 'description' => $rate->serviceName, - 'code' => $rate->serviceCode + 'code' => $rate->serviceCode, ]); } @@ -151,12 +130,12 @@ public function getRatesForOrder(SnipcartOrder $snipcartOrder, Package $package) public function createOrder(SnipcartOrder $snipcartOrder) { $package = Snipcart::$plugin->orders->getOrderPackaging($snipcartOrder); - $order = Order::populateFromSnipcartOrder($snipcartOrder); + $order = Order::populateFromSnipcartOrder($snipcartOrder); - $order->orderStatus = Order::STATUS_AWAITING_SHIPMENT; + $order->orderStatus = Order::STATUS_AWAITING_SHIPMENT; $order->customerNotes = $this->getOrderNotes($snipcartOrder->customFields); - $order->giftMessage = $this->getGiftNote($snipcartOrder->customFields); - $order->weight = $this->getOrderWeight($snipcartOrder, $package); + $order->giftMessage = $this->getGiftNote($snipcartOrder->customFields); + $order->weight = $this->getOrderWeight($snipcartOrder, $package); // it's a gift order if it has a gift message $order->gift = $order->giftMessage !== null; @@ -164,9 +143,9 @@ public function createOrder(SnipcartOrder $snipcartOrder) if ($package->hasPhysicalDimensions()) { $order->dimensions = new Dimensions([ 'length' => $package->length, - 'width' => $package->width, + 'width' => $package->width, 'height' => $package->height, - 'units' => Dimensions::UNIT_INCHES, + 'units' => Dimensions::UNIT_INCHES, ]); $order->dimensions->validate(); @@ -184,13 +163,13 @@ public function createOrder(SnipcartOrder $snipcartOrder) $isTestMode = Snipcart::$plugin->getSettings()->testMode; if ($this->hasEventHandlers(self::EVENT_BEFORE_SEND_ORDER)) { - $event = new OrderEvent([ + $orderEvent = new OrderEvent([ 'order' => $order, ]); - $this->trigger(self::EVENT_BEFORE_SEND_ORDER, $event); + $this->trigger(self::EVENT_BEFORE_SEND_ORDER, $orderEvent); - $order = $event->order; + $order = $orderEvent->order; } if ($isDevMode || $isTestMode) { @@ -201,7 +180,7 @@ public function createOrder(SnipcartOrder $snipcartOrder) return $order; } - if ($createdOrder = $this->sendOrder($order)) { + if (($createdOrder = $this->sendOrder($order)) instanceof Order) { /** * TODO: delete related rate quotes when order makes it to * ShipStation, or after a sensible amount of time @@ -229,10 +208,8 @@ public function createOrder(SnipcartOrder $snipcartOrder) * * https://shipstation.docs.apiary.io/#reference/orders/create-label-for-order/create-label-for-order * - * @param Order $order * @param bool $isTest true if we only want to create a sample label * @param string $packageCode package code to be sent - * * @return \stdClass|null response data, with ->labelData * base64-encoded PDF body */ @@ -244,7 +221,7 @@ public function createLabelForOrder(Order $order, $isTest = false, $packageCode true ); - $payload['testLabel'] = $isTest; + $payload['testLabel'] = $isTest; $payload['packageCode'] = $packageCode; return $this->post('orders/createlabelfororder', $payload); @@ -254,7 +231,7 @@ public function createLabelForOrder(Order $order, $isTest = false, $packageCode * @inheritdoc * https://www.shipstation.com/developer-api/#/reference/orders/getdelete-order/get-order */ - public function getOrderById($providerId) + public function getOrderById($providerId): ?Order { $responseData = $this->get(sprintf( 'order/%d', @@ -272,47 +249,47 @@ public function getOrderById($providerId) * @inheritdoc * https://www.shipstation.com/developer-api/#/reference/orders/list-orders/list-orders-with-parameters */ - public function getOrderBySnipcartInvoice(string $snipcartInvoice) + public function getOrderBySnipcartInvoice(string $snipcartInvoice): ?Order { $responseData = $this->get(sprintf( 'orders?orderNumber=%s', $snipcartInvoice )); - if (count($responseData->orders) === 1) { + if ((is_countable($responseData->orders) ? count($responseData->orders) : 0) === 1) { return new Order($responseData->orders[0]); } return null; } + protected function createSettingsModel(): ShipStationSettings + { + return new ShipStationSettings(); + } + /** * Gets an array of shipment information for requesting a rate quote. - * - * @param SnipcartOrder $snipcartOrder - * @param Dimensions $dimensions - * @param Weight $weight - * @return array */ private function prepShipmentInfo( SnipcartOrder $snipcartOrder, Dimensions $dimensions, - Weight $weight + Weight $weight, ): array { - $pluginSettings = Snipcart::$plugin->getSettings(); + $model = Snipcart::$plugin->getSettings(); $shipmentInfo = [ - 'carrierCode' => $this->getSettings()->defaultCarrierCode, + 'carrierCode' => $this->getSettings()->defaultCarrierCode, //'serviceCode' => '', - 'packageCode' => $this->getSettings()->defaultPackageCode, - 'fromPostalCode' => $pluginSettings->shipFromAddress['postalCode'], - 'toCity' => $snipcartOrder->shippingAddress->city, - 'toState' => $snipcartOrder->shippingAddress->province, - 'toPostalCode' => $snipcartOrder->shippingAddress->postalCode, - 'toCountry' => $snipcartOrder->shippingAddress->country, - 'weight' => $weight->toArray(), - 'confirmation' => $this->getSettings()->defaultOrderConfirmation, - 'residential' => false + 'packageCode' => $this->getSettings()->defaultPackageCode, + 'fromPostalCode' => $model->shipFromAddress['postalCode'], + 'toCity' => $snipcartOrder->shippingAddress->city, + 'toState' => $snipcartOrder->shippingAddress->province, + 'toPostalCode' => $snipcartOrder->shippingAddress->postalCode, + 'toCountry' => $snipcartOrder->shippingAddress->country, + 'weight' => $weight->toArray(), + 'confirmation' => $this->getSettings()->defaultOrderConfirmation, + 'residential' => false, ]; if ($dimensions->hasPhysicalDimensions()) { @@ -325,10 +302,9 @@ private function prepShipmentInfo( /** * Send the order to ShipStation via API. * - * @param Order $order * @return Order|null */ - private function sendOrder(Order $order) + private function sendOrder(Order $order): Order { $responseData = $this->post( 'orders/createorder', @@ -340,11 +316,6 @@ private function sendOrder(Order $order) /** * Get a Weight model for the order, adding package weight when relevant. - * - * @param SnipcartOrder $snipcartOrder - * @param Package $package - * - * @return Weight */ private function getOrderWeight(SnipcartOrder $snipcartOrder, Package $package): Weight { @@ -356,7 +327,7 @@ private function getOrderWeight(SnipcartOrder $snipcartOrder, Package $package): $weight = new Weight([ 'value' => $orderWeight, - 'units' => Weight::UNIT_GRAMS + 'units' => Weight::UNIT_GRAMS, ]); $weight->validate(); @@ -401,13 +372,11 @@ private function getGiftNote($customFields) /** * Return ShipStation rates for a Snipcart order. * - * @param SnipcartOrder $snipcartOrder - * @param Package $package * @return Rate[] */ private function getShipStationRatesForOrder( SnipcartOrder $snipcartOrder, - Package $package + Package $package, ): array { $dimensions = Dimensions::populateFromSnipcartPackage($package); $weight = $this->getOrderWeight($snipcartOrder, $package); @@ -444,21 +413,21 @@ private function getShipStationRatesForOrder( * * @todo Or can we? Does an order have a unique ID beyond its invoice number? * - * @param SnipcartOrder $order Snipcart order. + * @param SnipcartOrder $snipcartOrder Snipcart order. * @return Rate|null */ - private function getShippingMethodFromOrder(SnipcartOrder $order) + private function getShippingMethodFromOrder(SnipcartOrder $snipcartOrder) { /** * First try and find a matching rate quote, which would have preceded * the completed order. */ - $rateQuote = Snipcart::$plugin->shipments->getQuoteLogForOrder($order); + $rateQuote = Snipcart::$plugin->shipments->getQuoteLogForOrder($snipcartOrder); if (! empty($rateQuote)) { - $rate = $this->getMatchingRateFromLog($rateQuote, $order); + $rate = $this->getMatchingRateFromLog($rateQuote, $snipcartOrder); - if ($rate !== null) { + if ($rate instanceof Rate) { return $rate; } } @@ -467,7 +436,7 @@ private function getShippingMethodFromOrder(SnipcartOrder $order) * If there wasn't a matching option, query the API for rates again * and look for the closest match. */ - return $this->getClosestRateForOrder($order); + return $this->getClosestRateForOrder($snipcartOrder); } /** @@ -475,9 +444,8 @@ private function getShippingMethodFromOrder(SnipcartOrder $order) * matches the rate cost and description for this order. * * @param $rateQuoteLog - * @return Rate|null */ - private function getMatchingRateFromLog($rateQuoteLog, $order) + private function getMatchingRateFromLog($rateQuoteLog, SnipcartOrder $snipcartOrder): ?Rate { // get the rates that were already returned to Snipcart earlier $quoteRecord = Json::decode($rateQuoteLog->body, false); @@ -487,15 +455,15 @@ private function getMatchingRateFromLog($rateQuoteLog, $order) * See if the collected shipping fees and service name are * an exact match. */ - $labelAndCostMatch = $quotedRate->description === $order->shippingMethod - && (float)$quotedRate->cost === $order->shippingFees; + $labelAndCostMatch = $quotedRate->description === $snipcartOrder->shippingMethod + && (float) $quotedRate->cost === $snipcartOrder->shippingFees; if ($labelAndCostMatch) { return new Rate([ - 'serviceName' => $quotedRate->description, - 'serviceCode' => $quotedRate->code ?? null, + 'serviceName' => $quotedRate->description, + 'serviceCode' => $quotedRate->code ?? null, 'shipmentCost' => $quotedRate->cost, - 'otherCost' => 0, + 'otherCost' => 0, ]); } } @@ -507,15 +475,14 @@ private function getMatchingRateFromLog($rateQuoteLog, $order) * Fetch new rates based on this order, and choose either the exact match * or next-closest rate to what was purchased and specified at checkout. * - * @param $order * @return Rate|null - * @throws fostercommerce\snipcart\errors\ShippingRateException + * @throws ShippingRateException */ - private function getClosestRateForOrder($order) + private function getClosestRateForOrder(SnipcartOrder $snipcartOrder) { $closest = null; - $package = Snipcart::$plugin->orders->getOrderPackaging($order); - $rates = $this->getShipStationRatesForOrder($order, $package); + $package = Snipcart::$plugin->orders->getOrderPackaging($snipcartOrder); + $rates = $this->getShipStationRatesForOrder($snipcartOrder, $package); // check rates for matching name and/or price, otherwise take closest foreach ($rates as $rate) { @@ -523,21 +490,21 @@ private function getClosestRateForOrder($order) * See if the collected shipping fees and service name are * an exact match. */ - $labelAndCostMatch = $rate->serviceName === $order->shippingMethod - && ($rate->shipmentCost + $rate->otherCost) === $order->shippingFees; + $labelAndCostMatch = $rate->serviceName === $snipcartOrder->shippingMethod + && ($rate->shipmentCost + $rate->otherCost) === $snipcartOrder->shippingFees; if ($labelAndCostMatch) { // return exact match return $rate; } - if ($closest === null) { + if (! $closest instanceof Rate) { $closest = $rate; continue; } - $currentRateDelta = abs($rate->shipmentCost - $order->shippingFees); - $closestRateDelta = abs($closest->shipmentCost - $order->shippingFees); + $currentRateDelta = abs($rate->shipmentCost - $snipcartOrder->shippingFees); + $closestRateDelta = abs($closest->shipmentCost - $snipcartOrder->shippingFees); if ($currentRateDelta < $closestRateDelta) { // use the rate that has the least cost difference @@ -547,5 +514,4 @@ private function getClosestRateForOrder($order) return $closest; } - } diff --git a/src/providers/shipstation/events/OrderEvent.php b/src/providers/shipstation/events/OrderEvent.php index d5c825a..aba0cf0 100644 --- a/src/providers/shipstation/events/OrderEvent.php +++ b/src/providers/shipstation/events/OrderEvent.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -14,7 +14,7 @@ /** * Order event class. * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ class OrderEvent extends Event @@ -23,5 +23,4 @@ class OrderEvent extends Event * @var Order */ public $order; - } diff --git a/src/records/ProductDetails.php b/src/records/ProductDetails.php index 7d477f9..504b9e4 100644 --- a/src/records/ProductDetails.php +++ b/src/records/ProductDetails.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -43,9 +43,6 @@ class ProductDetails extends ActiveRecord */ public $isNew = false; - /** - * @inheritdoc - */ public static function tableName(): string { return Table::PRODUCT_DETAILS; diff --git a/src/records/ShippingQuoteLog.php b/src/records/ShippingQuoteLog.php index 416a299..e6ccb44 100644 --- a/src/records/ShippingQuoteLog.php +++ b/src/records/ShippingQuoteLog.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -22,9 +22,6 @@ */ class ShippingQuoteLog extends ActiveRecord { - /** - * @inheritdoc - */ public static function tableName(): string { return Table::SHIPPING_QUOTES; diff --git a/src/records/WebhookLog.php b/src/records/WebhookLog.php index 14ba8c5..a6ba107 100644 --- a/src/records/WebhookLog.php +++ b/src/records/WebhookLog.php @@ -2,7 +2,7 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ @@ -26,9 +26,6 @@ */ class WebhookLog extends ActiveRecord { - /** - * @inheritdoc - */ public static function tableName(): string { return Table::WEBHOOK_LOG; diff --git a/src/services/Api.php b/src/services/Api.php index 405bd3b..a1980a1 100644 --- a/src/services/Api.php +++ b/src/services/Api.php @@ -2,22 +2,25 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; +use GuzzleHttp\RequestOptions; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\ResponseInterface; +use Craft; +use craft\base\Component; use craft\helpers\Json; + use fostercommerce\snipcart\helpers\VersionHelper; use fostercommerce\snipcart\Snipcart; - -use Craft; -use craft\base\Component; use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; -use yii\caching\TagDependency; use yii\base\Exception; +use yii\caching\TagDependency; /** * Class Api @@ -34,12 +37,12 @@ class Api extends Component * @var string The tag we'll attach to our caches here so they can be * neatly invalidated with a reference to it. */ - const CACHE_TAG = 'snipcart-api-cache'; + public const CACHE_TAG = 'snipcart-api-cache'; /** * @var string Characters to prepend to any cache keys that are used. */ - const CACHE_KEY_PREFIX = 'snipcart_'; + public const CACHE_KEY_PREFIX = 'snipcart_'; /** * @var string Snipcart's base API URL used for all interactions. @@ -56,10 +59,7 @@ class Api extends Component */ protected $client; - /** - * @inheritdoc - */ - public function init() + public function init(): void { parent::init(); $this->isLinked = $this->getSecretApiKey() !== null; @@ -68,7 +68,6 @@ public function init() /** * Returns a configured Guzzle client. * - * @return Client * @throws \Exception if our API key is missing. */ public function getClient(): Client @@ -77,19 +76,19 @@ public function getClient(): Client throw new Exception('Snipcart plugin not configured.'); } - if ($this->client !== null) { + if ($this->client instanceof Client) { return $this->client; } $clientConfig = [ 'base_uri' => self::$apiBaseUrl, - 'auth' => [$this->getSecretApiKey(), 'password' ], + 'auth' => [$this->getSecretApiKey(), 'password'], 'headers' => [ 'Content-Type' => 'application/json; charset=utf-8', - 'Accept' => 'application/json', + 'Accept' => 'application/json', ], 'verify' => false, - 'debug' => false + 'debug' => false, ]; return $this->client = Craft::createGuzzleClient($clientConfig); @@ -108,18 +107,18 @@ public function getClient(): Client */ public function get(string $endpoint, array $parameters = [], bool $useCache = true) { - if (! empty($parameters)) { + if ($parameters !== []) { $endpoint .= '?' . http_build_query($parameters); } $cacheService = Craft::$app->getCache(); - $cacheKey = self::CACHE_KEY_PREFIX . $endpoint; + $cacheKey = self::CACHE_KEY_PREFIX . $endpoint; /** * Make sure plugin settings *and* local parameter both allow caching. */ $useCache = $useCache && Snipcart::$plugin->getSettings()->cacheResponses; - + if ($useCache && $cachedResponseData = $cacheService->get($cacheKey)) { return $cachedResponseData; } @@ -131,7 +130,9 @@ public function get(string $endpoint, array $parameters = [], bool $useCache = t $cacheKey, $responseData, Snipcart::$plugin->getSettings()->cacheDurationLimit, - new TagDependency([ 'tags' => [ self::CACHE_TAG ] ]) + new TagDependency([ + 'tags' => [self::CACHE_TAG], + ]) ); } @@ -191,7 +192,6 @@ public function delete(string $endpoint, array $data = []) * @param string $token token to be validated, probably * from $_POST['HTTP_X_SNIPCART_REQUESTTOKEN'] * - * @return bool * @throws \Exception if our API key is missing. */ public function tokenIsValid($token): bool @@ -207,7 +207,7 @@ public function tokenIsValid($token): bool /** * Invalidate any cached GET requests we may have accumulated. */ - public static function invalidateCache() + public static function invalidateCache(): void { TagDependency::invalidate( Craft::$app->getCache(), @@ -239,8 +239,8 @@ private function getRequest(string $endpoint) try { $response = $this->getClient()->get($endpoint); return $this->prepResponseData($response->getBody()); - } catch (RequestException $exception) { - return $this->handleRequestException($exception, $endpoint); + } catch (RequestException $requestException) { + return $this->handleRequestException($requestException, $endpoint); } } @@ -257,12 +257,12 @@ private function postRequest(string $endpoint, array $data = []) { try { $response = $this->getClient()->post($endpoint, [ - \GuzzleHttp\RequestOptions::JSON => $data + RequestOptions::JSON => $data, ]); return $this->prepResponseData($response->getBody()); - } catch (RequestException $exception) { - return $this->handleRequestException($exception, $endpoint); + } catch (RequestException $requestException) { + return $this->handleRequestException($requestException, $endpoint); } } @@ -279,12 +279,12 @@ private function putRequest(string $endpoint, array $data = []) { try { $response = $this->getClient()->put($endpoint, [ - \GuzzleHttp\RequestOptions::JSON => $data + RequestOptions::JSON => $data, ]); return $this->prepResponseData($response->getBody()); - } catch (RequestException $exception) { - return $this->handleRequestException($exception, $endpoint); + } catch (RequestException $requestException) { + return $this->handleRequestException($requestException, $endpoint); } } @@ -301,48 +301,45 @@ private function deleteRequest(string $endpoint, array $data = []) { try { $response = $this->getClient()->delete($endpoint, [ - \GuzzleHttp\RequestOptions::JSON => $data + RequestOptions::JSON => $data, ]); return $this->prepResponseData($response->getBody()); - } catch (RequestException $exception) { - return $this->handleRequestException($exception, $endpoint); + } catch (RequestException $requestException) { + return $this->handleRequestException($requestException, $endpoint); } } /** * Takes the raw response body and gives it back as data that’s ready to use. * - * @param $body - * * @return mixed Appropriate PHP type, or null if json cannot be decoded * or encoded data is deeper than the recursion limit. */ - private function prepResponseData($body) + private function prepResponseData(StreamInterface $stream) { /** * Get the response data as an object, not an associative array. */ - return Json::decode($body, false); + return Json::decode($stream, false); } /** * Handles a failed request. * - * @param RequestException $exception Exception that was thrown + * @param RequestException $requestException Exception that was thrown * @param string $endpoint Endpoint that was queried * - * @return null * @throws \Exception */ private function handleRequestException( - RequestException $exception, - string $endpoint + RequestException $requestException, + string $endpoint, ) { $statusCode = null; $reason = null; - if ($response = $exception->getResponse()) { + if (($response = $requestException->getResponse()) instanceof ResponseInterface) { /** * Get the status code, which should be 200 or 201 if things went well. */ @@ -355,7 +352,7 @@ private function handleRequestException( $reason = $response->getBody(); } - if ($statusCode !== null && $reason !== null) { + if ($statusCode !== null && $reason instanceof StreamInterface) { // return code and message Craft::warning(sprintf( 'Snipcart API responded with %d: %s', @@ -382,5 +379,4 @@ private function handleRequestException( return null; } - -} \ No newline at end of file +} diff --git a/src/services/Carts.php b/src/services/Carts.php index cc2edc3..f5c833d 100644 --- a/src/services/Carts.php +++ b/src/services/Carts.php @@ -2,15 +2,16 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; -use fostercommerce\snipcart\Snipcart; -use fostercommerce\snipcart\models\snipcart\AbandonedCart; +use craft\base\Component; use fostercommerce\snipcart\helpers\ModelHelper; +use fostercommerce\snipcart\models\snipcart\AbandonedCart; +use fostercommerce\snipcart\Snipcart; /** * Class Carts @@ -19,7 +20,7 @@ * * @package fostercommerce\snipcart\services */ -class Carts extends \craft\base\Component +class Carts extends Component { /** * Lists abandoned carts. @@ -40,13 +41,13 @@ class Carts extends \craft\base\Component * ->hasMoreResults (boolean) * @throws \Exception if our API key is missing. */ - public function listAbandonedCarts($page = 1, $limit = 20, $params = []): \stdClass + public function listAbandonedCarts($page = 1, $limit = 20, array $params = []): \stdClass { /** * Define offset and limit since that's pretty much all we're doing here. */ $params['offset'] = ($page - 1) * $limit; - $params['limit'] = $limit; + $params['limit'] = $limit; $response = Snipcart::$plugin->api->get( 'carts/abandoned', @@ -59,8 +60,8 @@ public function listAbandonedCarts($page = 1, $limit = 20, $params = []): \stdCl AbandonedCart::class ), 'continuationToken' => $response->continuationToken ?? null, - 'hasMoreResults' => $response->hasMoreResults ?? false, - 'limit' => $limit + 'hasMoreResults' => $response->hasMoreResults ?? false, + 'limit' => $limit, ]; } @@ -79,7 +80,7 @@ public function getAbandonedCart($cartId) $cartId ))) { return ModelHelper::safePopulateModel( - (array)$abandonedCartData, + (array) $abandonedCartData, AbandonedCart::class ); } diff --git a/src/services/Customers.php b/src/services/Customers.php index 5d7869a..630f9d3 100644 --- a/src/services/Customers.php +++ b/src/services/Customers.php @@ -2,16 +2,17 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; -use fostercommerce\snipcart\Snipcart; +use craft\base\Component; +use fostercommerce\snipcart\helpers\ModelHelper; use fostercommerce\snipcart\models\snipcart\Customer; use fostercommerce\snipcart\models\snipcart\Order; -use fostercommerce\snipcart\helpers\ModelHelper; +use fostercommerce\snipcart\Snipcart; /** * Class Customers @@ -20,7 +21,7 @@ * * @package fostercommerce\snipcart\services */ -class Customers extends \craft\base\Component +class Customers extends Component { /** * Lists Snipcart customers. @@ -36,15 +37,14 @@ class Customers extends \craft\base\Component * ->items (Customer[]) * @throws \Exception if our API key is missing. */ - public function listCustomers($page = 1, $limit = 20, $params = []) + public function listCustomers($page = 1, $limit = 20, array $params = []) { $params['offset'] = ($page - 1) * $limit; - $params['limit'] = $limit; + $params['limit'] = $limit; $customerData = Snipcart::$plugin->api->get('customers', $params); - $customerData->items = ModelHelper::safePopulateArrayWithModels( - (array)$customerData->items, + (array) $customerData->items, Customer::class ); @@ -66,7 +66,7 @@ public function getCustomer($customerId) $customerId ))) { return ModelHelper::safePopulateModel( - (array)$customerData, + (array) $customerData, Customer::class ); } @@ -85,14 +85,16 @@ public function getCustomer($customerId) public function getCustomerOrders($customerId): array { $orders = ModelHelper::safePopulateArrayWithModels( - (array)Snipcart::$plugin->api->get(sprintf( + (array) Snipcart::$plugin->api->get(sprintf( 'customers/%s/orders', $customerId - ), ['orderBy' => 'creationDate']), + ), [ + 'orderBy' => 'creationDate', + ]), Order::class ); - usort($orders, [$this, 'sortOrdersByDateDescending']); + usort($orders, fn($a, $b): bool => $this->sortOrdersByDateDescending($a, $b)); return $orders; } @@ -102,7 +104,6 @@ public function getCustomerOrders($customerId): array * * @param $a * @param $b - * @return bool */ private function sortOrdersByDateDescending($a, $b): bool { diff --git a/src/services/Data.php b/src/services/Data.php index 3b0ba84..97c0ed1 100644 --- a/src/services/Data.php +++ b/src/services/Data.php @@ -2,12 +2,13 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; +use craft\base\Component; use fostercommerce\snipcart\Snipcart; /** @@ -15,7 +16,7 @@ * * @package fostercommerce\snipcart\services */ -class Data extends \craft\base\Component +class Data extends Component { /** * Gets number of orders, by date, between two dates. @@ -54,7 +55,7 @@ public function getOrderCount($from, $to) 'data/orders/count', [ 'from' => $this->prepDate($from), - 'to' => $this->prepDate($to), + 'to' => $this->prepDate($to), ] ); } @@ -93,7 +94,7 @@ public function getPerformance($from, $to) 'data/performance', [ 'from' => $this->prepDate($from), - 'to' => $this->prepDate($to), + 'to' => $this->prepDate($to), ] ); } @@ -135,7 +136,7 @@ public function getSales($from, $to) 'data/orders/sales', [ 'from' => $this->prepDate($from), - 'to' => $this->prepDate($to), + 'to' => $this->prepDate($to), ] ); } @@ -145,7 +146,6 @@ public function getSales($from, $to) * string for the REST API request. * * @param int|\DateTime $date - * @return string */ private function prepDate($date): string { @@ -155,4 +155,4 @@ private function prepDate($date): string return (string) $date; } -} \ No newline at end of file +} diff --git a/src/services/DigitalGoods.php b/src/services/DigitalGoods.php index 8c0a590..70fc9ad 100644 --- a/src/services/DigitalGoods.php +++ b/src/services/DigitalGoods.php @@ -2,17 +2,18 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; +use craft\base\Component; /** * These exist but aren't yet documented. * * @package fostercommerce\snipcart\services */ -class DigitalGoods extends \craft\base\Component +class DigitalGoods extends Component { -} \ No newline at end of file +} diff --git a/src/services/Discounts.php b/src/services/Discounts.php index 0c85938..a05502e 100644 --- a/src/services/Discounts.php +++ b/src/services/Discounts.php @@ -2,15 +2,16 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; -use fostercommerce\snipcart\Snipcart; -use fostercommerce\snipcart\models\snipcart\Discount; +use craft\base\Component; use fostercommerce\snipcart\helpers\ModelHelper; +use fostercommerce\snipcart\models\snipcart\Discount; +use fostercommerce\snipcart\Snipcart; /** * Class Discounts @@ -19,7 +20,7 @@ * * @package fostercommerce\snipcart\services */ -class Discounts extends \craft\base\Component +class Discounts extends Component { /** * Lists discounts. @@ -32,7 +33,7 @@ public function listDiscounts(): array $response = Snipcart::$plugin->api->get('discounts'); return ModelHelper::safePopulateArrayWithModels( - (array)$response, + (array) $response, Discount::class ); } @@ -42,7 +43,7 @@ public function listDiscounts(): array * * @param Discount $discount * - * @return mixed $response + * @return mixed * @throws \Exception when there isn't an API key to authenticate requests. */ public function createDiscount($discount) @@ -68,7 +69,7 @@ public function getDiscount($discountId) $discountId ))) { return ModelHelper::safePopulateModel( - (array)$discountData, + (array) $discountData, Discount::class ); } diff --git a/src/services/Fields.php b/src/services/Fields.php index 81b3824..4b77bfa 100644 --- a/src/services/Fields.php +++ b/src/services/Fields.php @@ -2,23 +2,24 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; +use craft\base\Component; +use Craft; +use craft\base\ElementInterface; use craft\elements\Entry; use fostercommerce\snipcart\fields\ProductDetails; use fostercommerce\snipcart\models\ProductDetails as ProductDetailsModel; use fostercommerce\snipcart\records\ProductDetails as ProductDetailsRecord; -use Craft; -use craft\base\ElementInterface; /** * @package fostercommerce\snipcart\services */ -class Fields extends \craft\base\Component +class Fields extends Component { /** * Saves data for a Product Details field. @@ -26,10 +27,9 @@ class Fields extends \craft\base\Component * @param ProductDetails $field Related Field instance * @param ElementInterface $element Related Element * - * @return bool|null * @throws */ - public function saveProductDetailsField($field, $element) + public function saveProductDetailsField($field, $element): ?bool { $data = $element->getFieldValue($field->handle); @@ -55,10 +55,9 @@ public function saveProductDetailsField($field, $element) * @param mixed $value Data that should be used * to populate the model * - * @return ProductDetailsModel|null * @throws */ - public function getProductDetailsField($field, ElementInterface $element = null, $value = null) + public function getProductDetailsField($field, ElementInterface $element = null, mixed $value = null): ?ProductDetailsModel { // if we’ve already got a model, just give it back if ($value instanceof ProductDetailsModel) { @@ -77,7 +76,7 @@ public function getProductDetailsField($field, ElementInterface $element = null, $model = new ProductDetailsModel($value); $model->fieldId = $field->id; - $model->siteId = $siteId; + $model->siteId = $siteId; if ($elementId !== null) { $model->elementId = $elementId; @@ -87,7 +86,7 @@ public function getProductDetailsField($field, ElementInterface $element = null, } // if we have an Entry, we’re working with a source ID and need the corresponding Element ID - if (is_a($element, Entry::class) && + if ($element instanceof Entry && $currentRevision = $element->getCurrentRevision() ) { $elementId = $currentRevision->getId(); @@ -123,7 +122,7 @@ public function getProductDetailsField($field, ElementInterface $element = null, $model = new ProductDetailsModel(); $model->fieldId = $field->id; - $model->siteId = $siteId; + $model->siteId = $siteId; if ($elementId !== null) { $model->elementId = $elementId; @@ -138,13 +137,10 @@ public function getProductDetailsField($field, ElementInterface $element = null, * Returns true if the record has not yet been saved to the database, or * if it was created without yet being populated like during a bulk Element * re-save after the field is newly added. - * - * @param ProductDetailsRecord $record - * @return bool */ - private function isUnsavedRecord($record): bool + private function isUnsavedRecord(ProductDetailsRecord $productDetailsRecord): bool { - if ($record->isNew) { + if ($productDetailsRecord->isNew) { return true; } @@ -152,7 +148,7 @@ private function isUnsavedRecord($record): bool * A record can only have a `null` sku and price if saved during a * bulk operation. */ - return $record->sku === null && $record->price === null; + return $productDetailsRecord->sku === null && $productDetailsRecord->price === null; } /** @@ -162,29 +158,27 @@ private function isUnsavedRecord($record): bool * @param int $siteId Relevant Site ID * @param int $elementId Relevant Element ID * @param int $fieldId Relevant Field ID - * - * @return bool */ private function saveRecord($data, $siteId, $elementId, $fieldId): bool { - $record = $this->getRecord($siteId, $elementId, $fieldId); - - $record->setAttributes([ - 'sku' => $data->sku, - 'price' => $data->price, - 'shippable' => $data->shippable, - 'taxable' => $data->taxable, - 'weight' => $data->weight, - 'weightUnit' => $data->weightUnit, - 'length' => $data->length, - 'width' => $data->width, - 'height' => $data->height, - 'inventory' => $data->inventory, + $productDetailsRecord = $this->getRecord($siteId, $elementId, $fieldId); + + $productDetailsRecord->setAttributes([ + 'sku' => $data->sku, + 'price' => $data->price, + 'shippable' => $data->shippable, + 'taxable' => $data->taxable, + 'weight' => $data->weight, + 'weightUnit' => $data->weightUnit, + 'length' => $data->length, + 'width' => $data->width, + 'height' => $data->height, + 'inventory' => $data->inventory, 'dimensionsUnit' => $data->dimensionsUnit, - 'customOptions' => $data->customOptions, + 'customOptions' => $data->customOptions, ], false); - return $record->save(); + return $productDetailsRecord->save(); } /** @@ -194,24 +188,22 @@ private function saveRecord($data, $siteId, $elementId, $fieldId): bool * @param int $siteId Relevant Site ID * @param int $elementId Relevant Element ID * @param int $fieldId Relevant Field ID - * - * @return ProductDetailsRecord */ private function getRecord($siteId, $elementId, $fieldId): ProductDetailsRecord { $record = ProductDetailsRecord::findOne([ - 'siteId' => $siteId, + 'siteId' => $siteId, 'elementId' => $elementId, - 'fieldId' => $fieldId + 'fieldId' => $fieldId, ]); - if ($record === null) { + if (! $record instanceof ProductDetailsRecord) { $record = new ProductDetailsRecord(); - $record->isNew = true; - $record->siteId = $siteId; + $record->isNew = true; + $record->siteId = $siteId; $record->elementId = $elementId; - $record->fieldId = $fieldId; + $record->fieldId = $fieldId; } return $record; diff --git a/src/services/Notifications.php b/src/services/Notifications.php index a4816da..625233e 100644 --- a/src/services/Notifications.php +++ b/src/services/Notifications.php @@ -2,17 +2,19 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; +use craft\base\Component; +use yii\base\Exception; use Craft; use craft\mail\Message; -use Pelago\Emogrifier\CssInliner; -use fostercommerce\snipcart\Snipcart; use fostercommerce\snipcart\helpers\VersionHelper; +use fostercommerce\snipcart\Snipcart; +use Pelago\Emogrifier\CssInliner; /** * Sends notifications as things happen. Currently just email. @@ -20,7 +22,7 @@ * @package fostercommerce\snipcart\services * @todo Make a proper Notification model */ -class Notifications extends \craft\base\Component +class Notifications extends Component { /** * @var string Path to Twig template for HTML email. @@ -52,15 +54,13 @@ class Notifications extends \craft\base\Component /** * @var array Error strings accumulated during notification setup+attempt. */ - private $errors = []; + private array $errors = []; /** * Sets template variables for the notification. * Should be called before `sendEmail()`. - * - * @param mixed $data */ - public function setNotificationVars($data) + public function setNotificationVars(mixed $data): void { $this->notificationVars = $data; } @@ -80,7 +80,7 @@ public function getNotificationVars() * * @param $errors */ - public function setErrors($errors) + public function setErrors(array $errors): void { $this->errors = $errors; } @@ -96,7 +96,7 @@ public function setErrors($errors) * (site) end or the back (plugin) end, which * matters for setting the template mode. */ - public function setEmailTemplate($htmlTemplate, $textTemplate = null, $frontend = false) + public function setEmailTemplate($htmlTemplate, $textTemplate = null, $frontend = false): void { $this->htmlEmailTemplate = $htmlTemplate; $this->textEmailTemplate = $textTemplate; @@ -108,7 +108,7 @@ public function setEmailTemplate($htmlTemplate, $textTemplate = null, $frontend * * @param string $url */ - public function setSlackWebhook($url) + public function setSlackWebhook($url): void { $this->slackWebhook = $url; } @@ -124,10 +124,10 @@ public function setSlackWebhook($url) */ public function sendEmail($to, $subject): bool { - $pluginSettings = Snipcart::$plugin->getSettings(); + $model = Snipcart::$plugin->getSettings(); // Bail if we’re in test mode and don’t want to send emails. - if ($pluginSettings->testMode && ! $pluginSettings->sendTestModeEmail) { + if ($model->testMode && ! $model->sendTestModeEmail) { // pretend it went well return true; } @@ -164,7 +164,7 @@ public function sendEmail($to, $subject): bool * switched the view mode. */ if (! $this->ensureTemplatesExist()) { - $this->setErrors([ 'Email template(s) are missing.' ]); + $this->setErrors(['Email template(s) are missing.']); return false; } @@ -179,7 +179,7 @@ public function sendEmail($to, $subject): bool $messageText = ''; - if ($this->textEmailTemplate) { + if ($this->textEmailTemplate !== '' && $this->textEmailTemplate !== '0') { $messageText = $view->renderPageTemplate( $this->textEmailTemplate, $this->getNotificationVars() @@ -190,7 +190,7 @@ public function sendEmail($to, $subject): bool $message = new Message(); $message->setFrom([ - $emailSettings['fromEmail'] => $emailSettings['fromName'] + $emailSettings['fromEmail'] => $emailSettings['fromName'], ]); $message->setTo($address); @@ -202,7 +202,7 @@ public function sendEmail($to, $subject): bool } if (! Craft::$app->getMailer()->send($message)) { - $problem = "Notification failed to send to {$address}!"; + $problem = sprintf('Notification failed to send to %s!', $address); Craft::warning($problem, 'snipcart'); $errors[] = $problem; } @@ -216,15 +216,14 @@ public function sendEmail($to, $subject): bool $this->setErrors($errors); - return count($errors) === 0; + return $errors === []; } /** * Makes sure that the HTML email template exists at the specified path, * and that the text template exists if it was provided. * - * @return bool - * @throws \yii\base\Exception + * @throws Exception */ private function ensureTemplatesExist(): bool { @@ -232,7 +231,7 @@ private function ensureTemplatesExist(): bool return false; } - if ($this->textEmailTemplate) { + if ($this->textEmailTemplate !== '' && $this->textEmailTemplate !== '0') { $this->ensureTemplateExists($this->textEmailTemplate); return false; @@ -246,8 +245,7 @@ private function ensureTemplatesExist(): bool * * @param $path * - * @return bool - * @throws \yii\base\Exception + * @throws Exception */ private function ensureTemplateExists($path): bool { diff --git a/src/services/Orders.php b/src/services/Orders.php index 6629d84..a91d950 100644 --- a/src/services/Orders.php +++ b/src/services/Orders.php @@ -2,21 +2,22 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; +use craft\base\Component; +use Craft; +use fostercommerce\snipcart\errors\ShippingRateException; use fostercommerce\snipcart\events\ShippingRateEvent; -use fostercommerce\snipcart\Snipcart; -use fostercommerce\snipcart\models\snipcart\Order; +use fostercommerce\snipcart\helpers\ModelHelper; use fostercommerce\snipcart\models\snipcart\Notification; -use fostercommerce\snipcart\models\snipcart\Refund; +use fostercommerce\snipcart\models\snipcart\Order; use fostercommerce\snipcart\models\snipcart\Package; -use fostercommerce\snipcart\helpers\ModelHelper; -use fostercommerce\snipcart\errors\ShippingRateException; -use Craft; +use fostercommerce\snipcart\models\snipcart\Refund; +use fostercommerce\snipcart\Snipcart; /** * The Orders service lets you interact with Snipcart orders as tidy, @@ -28,23 +29,23 @@ * @todo clean up interfaces to be more Craft-y and obscure pagination concerns * @todo return null for invalid single-object requests, otherwise empty arrays */ -class Orders extends \craft\base\Component +class Orders extends Component { /** * @event ShippingRateEvent Triggered before shipping rates are requested * from any third parties. */ - const EVENT_BEFORE_REQUEST_SHIPPING_RATES = 'beforeRequestShippingRates'; + public const EVENT_BEFORE_REQUEST_SHIPPING_RATES = 'beforeRequestShippingRates'; /** * @var string */ - const NOTIFICATION_TYPE_ADMIN = 'notifyAdmin'; + public const NOTIFICATION_TYPE_ADMIN = 'notifyAdmin'; /** * @var string */ - const NOTIFICATION_TYPE_CUSTOMER = 'notifyCustomer'; + public const NOTIFICATION_TYPE_CUSTOMER = 'notifyCustomer'; /** * Gets a Snipcart order. @@ -54,14 +55,14 @@ class Orders extends \craft\base\Component * @return Order|null * @throws \Exception if our API key is missing. */ - public function getOrder($orderId) + public function getOrder(String $orderId) { if ($orderData = Snipcart::$plugin->api->get(sprintf( 'orders/%s', $orderId ))) { return ModelHelper::safePopulateModel( - (array)$orderData, + (array) $orderData, Order::class ); } @@ -82,7 +83,7 @@ public function getOrder($orderId) public function getOrders($params = []): array { return ModelHelper::safePopulateArrayWithModels( - (array)$this->fetchOrders($params)->items, + (array) $this->fetchOrders($params)->items, Order::class ); } @@ -96,7 +97,7 @@ public function getOrders($params = []): array * @return Order[] * @throws */ - public function getAllOrders($params = []): array + public function getAllOrders(array $params = []): array { $collection = []; $collected = 0; @@ -107,12 +108,12 @@ public function getAllOrders($params = []): array $params['offset'] = $offset; if ($result = $this->fetchOrders($params)) { - $currentItems = (array)$result->items; + $currentItems = (array) $result->items; $collected += count($currentItems); $collection[] = $currentItems; if ($result->totalItems > $collected) { - $offset++; + ++$offset; } else { $finished = true; } @@ -140,7 +141,7 @@ public function getAllOrders($params = []): array public function getOrderNotifications($orderId): array { return ModelHelper::safePopulateArrayWithModels( - (array)Snipcart::$plugin->api->get(sprintf( + (array) Snipcart::$plugin->api->get(sprintf( 'orders/%s/notifications', $orderId )), @@ -159,7 +160,7 @@ public function getOrderNotifications($orderId): array public function getOrderRefunds($orderId): array { return ModelHelper::safePopulateArrayWithModels( - (array)Snipcart::$plugin->api->get(sprintf( + (array) Snipcart::$plugin->api->get(sprintf( 'orders/%s/refunds', $orderId )), @@ -181,32 +182,33 @@ public function getOrderRefunds($orderId): array * ->limit (int) * @throws \Exception if our API key is missing. */ - public function listOrders($page = 1, $limit = 25, $params = []): \stdClass + public function listOrders($page = 1, $limit = 25, array $params = []): \stdClass { /** * define offset and limit since that's pretty much all we're doing here */ $params['offset'] = ($page - 1) * $limit; - $params['limit'] = $limit; + $params['limit'] = $limit; $response = $this->fetchOrders($params); + // convert the data from an stdClass to an array + $items = json_decode(json_encode($response->items, JSON_THROW_ON_ERROR), true, 512, JSON_THROW_ON_ERROR); + return (object) [ 'items' => ModelHelper::safePopulateArrayWithModels( - $response->items, + $items, Order::class ), 'totalItems' => $response->totalItems, 'offset' => $response->offset, - 'limit' => $limit + 'limit' => $limit, ]; } /** * Reduce product inventory for each item in a completed order. * - * @param Order $order - * * @return bool true if successful * @throws */ @@ -226,8 +228,6 @@ public function updateProductsFromOrder(Order $order): bool * Gets Craft Elements that relate to order items, updating quantities * and sending a notification if relevant. * - * @param Order $order - * * @return bool|array true if successful, or an array of notification errors * @throws * @deprecated in 1.1. Use updateProductsFromOrder() instead. @@ -242,25 +242,23 @@ public function updateElementsFromOrder(Order $order): bool * packaging details and/or modify an order before shipping rates * are requested for that order. * - * @param Order $order - * - * @return Package - * @throws fostercommerce\snipcart\errors\ShippingRateException + * @throws ShippingRateException */ public function getOrderPackaging(Order $order): Package { $package = new Package(); if ($this->hasEventHandlers(self::EVENT_BEFORE_REQUEST_SHIPPING_RATES)) { - $event = new ShippingRateEvent([ - 'order' => $order, - 'package' => $package + $shippingRateEvent = new ShippingRateEvent([ + 'order' => $order, + 'package' => $package, ]); - $this->trigger(self::EVENT_BEFORE_REQUEST_SHIPPING_RATES, $event); - if (!$event->isValid) { - throw new ShippingRateException($event); + $this->trigger(self::EVENT_BEFORE_REQUEST_SHIPPING_RATES, $shippingRateEvent); + if (! $shippingRateEvent->isValid) { + throw new ShippingRateException($shippingRateEvent); } - $package = $event->package; + + $package = $shippingRateEvent->package; } return $package; @@ -281,7 +279,7 @@ public function sendOrderEmailNotification($order, $extra = [], $type = self::NO $templateSettings = $this->selectNotificationTemplate($type); $emailVars = array_merge([ 'order' => $order, - 'settings' => Snipcart::$plugin->getSettings() + 'settings' => Snipcart::$plugin->getSettings(), ], $extra); Snipcart::$plugin->notifications->setEmailTemplate( @@ -296,19 +294,21 @@ public function sendOrderEmailNotification($order, $extra = [], $type = self::NO $subject = Craft::t( 'snipcart', '{name} just placed an order', - [ 'name' => $order->billingAddressName ] + [ + 'name' => $order->billingAddressName, + ] ); if ($type === self::NOTIFICATION_TYPE_ADMIN) { $toEmails = Snipcart::$plugin->getSettings()->notificationEmails; } elseif ($type === self::NOTIFICATION_TYPE_CUSTOMER) { - $toEmails = [ $order->email ]; + $toEmails = [$order->email]; $subject = Craft::t( 'snipcart', '{siteName} Order #{invoiceNumber}', [ 'siteName' => Craft::$app->getSites()->getCurrentSite()->name, - 'invoiceNumber' => $order->invoiceNumber + 'invoiceNumber' => $order->invoiceNumber, ] ); } @@ -335,9 +335,9 @@ public function sendOrderEmailNotification($order, $extra = [], $type = self::NO public function refundOrder($orderId, $amount, $comment = '', $notifyCustomer = false) { $refund = new Refund([ - 'orderToken' => $orderId, - 'amount' => $amount, - 'comment' => $comment, + 'orderToken' => $orderId, + 'amount' => $amount, + 'comment' => $comment, 'notifyCustomer' => $notifyCustomer, ]); @@ -368,9 +368,9 @@ private function fetchOrders($params = []) 'placedBy', ]; - $apiParams = []; - $hasCacheParam = isset($params['cache']) && is_bool($params['cache']); - $cacheSetting = $hasCacheParam ? $params['cache'] : true; + $apiParams = []; + $hasCacheParam = isset($params['cache']) && is_bool($params['cache']); + $cacheSetting = $hasCacheParam ? $params['cache'] : true; $dateTimeFormat = 'Y-m-d\TH:i:sP'; if (isset($params['from']) && $params['from'] instanceof \DateTime) { @@ -406,16 +406,16 @@ private function fetchOrders($params = []) */ private function selectNotificationTemplate($type): array { - $settings = Snipcart::$plugin->getSettings(); + $model = Snipcart::$plugin->getSettings(); $defaultTemplatePath = ''; $customTemplatePath = ''; if ($type === self::NOTIFICATION_TYPE_ADMIN) { $defaultTemplatePath = 'snipcart/email/order'; - $customTemplatePath = $settings->notificationEmailTemplate; + $customTemplatePath = $model->notificationEmailTemplate; } elseif ($type === self::NOTIFICATION_TYPE_CUSTOMER) { $defaultTemplatePath = 'snipcart/email/customer-order'; - $customTemplatePath = $settings->customerNotificationEmailTemplate; + $customTemplatePath = $model->customerNotificationEmailTemplate; } $useCustom = ! empty($customTemplatePath); @@ -423,7 +423,7 @@ private function selectNotificationTemplate($type): array return [ 'path' => $templatePath, - 'user' => $useCustom + 'user' => $useCustom, ]; } } diff --git a/src/services/Products.php b/src/services/Products.php index 233a0be..37d843b 100644 --- a/src/services/Products.php +++ b/src/services/Products.php @@ -2,18 +2,18 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; +use Craft; +use craft\base\Component; +use craft\elements\Entry; use fostercommerce\snipcart\events\InventoryEvent; use fostercommerce\snipcart\helpers\FieldHelper; use fostercommerce\snipcart\models\snipcart\Item; -use craft\elements\Entry; -use craft\base\Component; -use Craft; /** * The Products service lets you interact with Snipcart products as tidy, @@ -30,7 +30,7 @@ class Products extends Component * @event InventoryEvent Triggered when a product's inventory has changed * because an order was created or updated. */ - const EVENT_PRODUCT_INVENTORY_CHANGE = 'productInventoryChange'; + public const EVENT_PRODUCT_INVENTORY_CHANGE = 'productInventoryChange'; /** * Adjusts the supplied Item's inventory value if... @@ -44,10 +44,10 @@ class Products extends Component * * @throws */ - public function reduceInventory($orderItem) + public function reduceInventory($orderItem): void { // subtract the order quantity - $quantityToAdjust = - $orderItem->quantity; + $quantityToAdjust = -$orderItem->quantity; // get the Entry or Matrix block owning the Product Details field $element = $orderItem->getRelatedElement(); @@ -64,24 +64,24 @@ public function reduceInventory($orderItem) } if ($this->hasEventHandlers(self::EVENT_PRODUCT_INVENTORY_CHANGE)) { - $event = new InventoryEvent([ - 'element' => $element, - 'entry' => $element, + $inventoryEvent = new InventoryEvent([ + 'element' => $element, + 'entry' => $element, 'quantity' => $quantityToAdjust, ]); - $this->trigger(self::EVENT_PRODUCT_INVENTORY_CHANGE, $event); + $this->trigger(self::EVENT_PRODUCT_INVENTORY_CHANGE, $inventoryEvent); /** * Allow an event handler to override the quantity change before * it gets applied. */ - $quantityToAdjust = $event->quantity; + $quantityToAdjust = $inventoryEvent->quantity; } - if ($fieldHandle) { + if ($fieldHandle !== '' && $fieldHandle !== '0') { $originalQuantity = $element->{$fieldHandle}->inventory; - $newQuantity = $originalQuantity + $quantityToAdjust; + $newQuantity = $originalQuantity + $quantityToAdjust; if ($originalQuantity > 0 && $originalQuantity !== $newQuantity) { $element->{$fieldHandle}->inventory = $newQuantity; @@ -105,10 +105,10 @@ public function reduceInventory($orderItem) * * @deprecated in 1.1. Use reduceInventory() instead. */ - public function reduceProductInventory($entry, $quantity) + public function reduceProductInventory($entry, $quantity): void { // subtract the order quantity - $quantityToAdjust = - $quantity; + $quantityToAdjust = -$quantity; $fieldHandle = FieldHelper::getProductInfoFieldHandle($entry); $usesInventory = isset($fieldHandle) && $entry->{$fieldHandle}->inventory !== null; @@ -118,23 +118,23 @@ public function reduceProductInventory($entry, $quantity) } if ($this->hasEventHandlers(self::EVENT_PRODUCT_INVENTORY_CHANGE)) { - $event = new InventoryEvent([ - 'entry' => $entry, + $inventoryEvent = new InventoryEvent([ + 'entry' => $entry, 'quantity' => $quantityToAdjust, ]); - $this->trigger(self::EVENT_PRODUCT_INVENTORY_CHANGE, $event); + $this->trigger(self::EVENT_PRODUCT_INVENTORY_CHANGE, $inventoryEvent); /** * Allow an event handler to override the quantity change before * it gets adjusted. */ - $quantityToAdjust = $event->quantity; + $quantityToAdjust = $inventoryEvent->quantity; } - if ($fieldHandle) { + if ($fieldHandle !== '' && $fieldHandle !== '0') { $originalQuantity = $entry->{$fieldHandle}->inventory; - $newQuantity = $originalQuantity + $quantityToAdjust; + $newQuantity = $originalQuantity + $quantityToAdjust; if ($originalQuantity > 0 && $originalQuantity !== $newQuantity) { $entry->{$fieldHandle}->inventory = $newQuantity; diff --git a/src/services/Shipments.php b/src/services/Shipments.php index 26ef54a..53af03a 100644 --- a/src/services/Shipments.php +++ b/src/services/Shipments.php @@ -2,19 +2,21 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; +use craft\base\Component; +use yii\db\ActiveRecord; +use Craft; +use fostercommerce\snipcart\errors\ShippingRateException; use fostercommerce\snipcart\events\ShippingRateEvent; use fostercommerce\snipcart\models\snipcart\Order; -use fostercommerce\snipcart\Snipcart; use fostercommerce\snipcart\providers\shipstation\ShipStation; use fostercommerce\snipcart\records\ShippingQuoteLog; -use fostercommerce\snipcart\errors\ShippingRateException; -use Craft; +use fostercommerce\snipcart\Snipcart; /** * Class Shipments @@ -24,12 +26,12 @@ * @package fostercommerce\snipcart\services * @property ShipStation $shipStation */ -class Shipments extends \craft\base\Component +class Shipments extends Component { /** * @event WebhookEvent Triggered before shipping rates are returned to Snipcart. */ - const EVENT_BEFORE_RETURN_SHIPPING_RATES = 'beforeReturnShippingRates'; + public const EVENT_BEFORE_RETURN_SHIPPING_RATES = 'beforeReturnShippingRates'; /** * @var ShipStation Local reference to instantiated ShipStation provider @@ -38,12 +40,10 @@ class Shipments extends \craft\base\Component /** * Returns an instance of the ShipStation provider. - * - * @return ShipStation */ public function getShipStation(): ShipStation { - if ($this->_shipStation === null) { + if (! $this->_shipStation instanceof ShipStation) { $settings = Snipcart::$plugin->getSettings(); return $this->_shipStation = $settings->getProvider('shipStation'); } @@ -54,8 +54,6 @@ public function getShipStation(): ShipStation /** * Collects shipping rate options for a Snipcart order. * - * @param Order $order - * * @return array [ 'rates' => ShippingRate[], 'package' => Package ] or [ 'errors' => [ ['key' => '...', 'message' => '...'] ] ] */ public function collectRatesForOrder(Order $order): array @@ -83,28 +81,28 @@ public function collectRatesForOrder(Order $order): array } if ($this->hasEventHandlers(self::EVENT_BEFORE_RETURN_SHIPPING_RATES)) { - $event = new ShippingRateEvent([ - 'rates' => $rates, - 'order' => $order, - 'package' => $package + $shippingRateEvent = new ShippingRateEvent([ + 'rates' => $rates, + 'order' => $order, + 'package' => $package, ]); - $this->trigger(self::EVENT_BEFORE_RETURN_SHIPPING_RATES, $event); + $this->trigger(self::EVENT_BEFORE_RETURN_SHIPPING_RATES, $shippingRateEvent); - if (!$event->isValid) { - throw new ShippingRateException($event); + if (! $shippingRateEvent->isValid) { + throw new ShippingRateException($shippingRateEvent); } - $rates = $event->rates; + $rates = $shippingRateEvent->rates; } - } catch (ShippingRateException $exception) { + } catch (ShippingRateException $shippingRateException) { Craft::warning(sprintf( 'Snipcart plugin returned an error while fetching rates for %s', $order->invoiceNumber ), 'snipcart'); return [ - 'errors' => $exception->event->getErrors(), + 'errors' => $shippingRateException->event->getErrors(), ]; } @@ -116,7 +114,7 @@ public function collectRatesForOrder(Order $order): array } return [ - 'rates' => $rates, + 'rates' => $rates, 'package' => $package, ]; } @@ -125,14 +123,13 @@ public function collectRatesForOrder(Order $order): array * Handles an order that’s been completed, normally sent after * receiving a webhook post from Snipcart. * - * @param Order $order * @return object */ public function handleCompletedOrder(Order $order) { $response = (object) [ 'orders' => [], - 'errors' => [] + 'errors' => [], ]; // is the plugin in test mode? @@ -155,7 +152,7 @@ public function handleCompletedOrder(Order $order) $shipStationOrder = $this->getShipStation()->createOrder($order); $response->orders['shipStation'] = $shipStationOrder; - if (count($shipStationOrder->getErrors()) > 0) { + if ((is_countable($shipStationOrder->getErrors()) ? count($shipStationOrder->getErrors()) : 0) > 0) { $response->errors['shipStation'] = $shipStationOrder->getErrors(); } } @@ -167,13 +164,17 @@ public function handleCompletedOrder(Order $order) * Gets the last shipping rate quote that was returned for the given order. * * @param $order - * @return array|ShippingQuoteLog|\yii\db\ActiveRecord|null + * @return array|ShippingQuoteLog|ActiveRecord|null */ public function getQuoteLogForOrder($order) { return ShippingQuoteLog::find() - ->where(['token' => $order->token]) - ->orderBy(['dateCreated' => SORT_DESC]) + ->where([ + 'token' => $order->token, + ]) + ->orderBy([ + 'dateCreated' => SORT_DESC, + ]) ->one(); } } diff --git a/src/services/Subscriptions.php b/src/services/Subscriptions.php index c50008c..ad02860 100644 --- a/src/services/Subscriptions.php +++ b/src/services/Subscriptions.php @@ -2,15 +2,16 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; -use fostercommerce\snipcart\Snipcart; +use craft\base\Component; use fostercommerce\snipcart\helpers\ModelHelper; use fostercommerce\snipcart\models\snipcart\Subscription; +use fostercommerce\snipcart\Snipcart; /** * Class Subscriptions @@ -19,7 +20,7 @@ * * @package fostercommerce\snipcart\services */ -class Subscriptions extends \craft\base\Component +class Subscriptions extends Component { /** * Lists subscriptions. @@ -35,13 +36,13 @@ class Subscriptions extends \craft\base\Component * ->limit (int) * @throws \Exception when there isn't an API key to authenticate requests. */ - public function listSubscriptions($page = 1, $limit = 20, $params = []): \stdClass + public function listSubscriptions($page = 1, $limit = 20, array $params = []): \stdClass { /** * Define offset and limit since that's pretty much all we're doing here. */ $params['offset'] = ($page - 1) * $limit; - $params['limit'] = $limit; + $params['limit'] = $limit; $response = Snipcart::$plugin->api->get( 'subscriptions', @@ -54,8 +55,8 @@ public function listSubscriptions($page = 1, $limit = 20, $params = []): \stdCla Subscription::class ), 'totalItems' => $response->totalItems, - 'offset' => $response->offset, - 'limit' => $limit + 'offset' => $response->offset, + 'limit' => $limit, ]; } @@ -74,7 +75,7 @@ public function getSubscription($subscriptionId) $subscriptionId ))) { return ModelHelper::safePopulateModel( - (array)$subscriptionData, + (array) $subscriptionData, Subscription::class ); } @@ -87,7 +88,6 @@ public function getSubscription($subscriptionId) * * @param $subscriptionId * - * @return array * @throws \Exception */ public function getSubscriptionInvoices($subscriptionId): array diff --git a/src/services/Webhooks.php b/src/services/Webhooks.php index ef8177c..c2dc6d9 100644 --- a/src/services/Webhooks.php +++ b/src/services/Webhooks.php @@ -2,112 +2,113 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\services; +use craft\base\Component; +use Craft; use fostercommerce\snipcart\events\CustomerEvent; +use fostercommerce\snipcart\events\OrderEvent; use fostercommerce\snipcart\events\OrderNotificationEvent; use fostercommerce\snipcart\events\OrderRefundEvent; use fostercommerce\snipcart\events\OrderStatusEvent; use fostercommerce\snipcart\events\OrderTrackingEvent; use fostercommerce\snipcart\events\SubscriptionEvent; use fostercommerce\snipcart\events\TaxesEvent; +use fostercommerce\snipcart\helpers\ModelHelper; +use fostercommerce\snipcart\models\snipcart\Customer; use fostercommerce\snipcart\models\snipcart\Notification; +use fostercommerce\snipcart\models\snipcart\Order; use fostercommerce\snipcart\models\snipcart\Refund; use fostercommerce\snipcart\models\snipcart\Subscription; -use fostercommerce\snipcart\models\snipcart\Customer; -use fostercommerce\snipcart\Snipcart; -use fostercommerce\snipcart\events\OrderEvent; use fostercommerce\snipcart\records\ShippingQuoteLog; -use fostercommerce\snipcart\models\snipcart\Order; -use fostercommerce\snipcart\helpers\ModelHelper; use fostercommerce\snipcart\records\WebhookLog; -use Craft; +use fostercommerce\snipcart\Snipcart; /** * This class handles valid data that's posted to Snipcart’s webhook endpoint. * * @package fostercommerce\snipcart\services */ -class Webhooks extends \craft\base\Component +class Webhooks extends Component { /** * @event OrderEvent Triggered before a completed event is handled by the plugin. */ - const EVENT_BEFORE_PROCESS_COMPLETED_ORDER = 'beforeProcessCompletedOrder'; + public const EVENT_BEFORE_PROCESS_COMPLETED_ORDER = 'beforeProcessCompletedOrder'; /** * @event OrderStatusEvent */ - const EVENT_ON_ORDER_STATUS_CHANGED = 'onOrderStatusChanged'; + public const EVENT_ON_ORDER_STATUS_CHANGED = 'onOrderStatusChanged'; /** * @event OrderStatusEvent */ - const EVENT_ON_ORDER_PAYMENT_STATUS_CHANGED = 'onOrderPaymentStatusChanged'; + public const EVENT_ON_ORDER_PAYMENT_STATUS_CHANGED = 'onOrderPaymentStatusChanged'; /** * @event OrderTrackingEvent */ - const EVENT_ON_ORDER_TRACKING_CHANGED = 'onOrderTrackingChanged'; + public const EVENT_ON_ORDER_TRACKING_CHANGED = 'onOrderTrackingChanged'; /** * @event SubscriptionEvent */ - const EVENT_ON_SUBSCRIPTION_CREATED = 'onSubscriptionCreated'; + public const EVENT_ON_SUBSCRIPTION_CREATED = 'onSubscriptionCreated'; /** * @event SubscriptionEvent */ - const EVENT_ON_SUBSCRIPTION_CANCELLED = 'onSubscriptionCancelled'; + public const EVENT_ON_SUBSCRIPTION_CANCELLED = 'onSubscriptionCancelled'; /** * @event SubscriptionEvent */ - const EVENT_ON_SUBSCRIPTION_PAUSED = 'onSubscriptionPaused'; + public const EVENT_ON_SUBSCRIPTION_PAUSED = 'onSubscriptionPaused'; /** * @event SubscriptionEvent */ - const EVENT_ON_SUBSCRIPTION_RESUMED = 'onSubscriptionResumed'; + public const EVENT_ON_SUBSCRIPTION_RESUMED = 'onSubscriptionResumed'; /** * @event SubscriptionEvent */ - const EVENT_ON_SUBSCRIPTION_INVOICE_CREATED = 'onSubscriptionInvoiceCreated'; + public const EVENT_ON_SUBSCRIPTION_INVOICE_CREATED = 'onSubscriptionInvoiceCreated'; /** * @event TaxesEvent */ - const EVENT_ON_TAXES_CALCULATE = 'onTaxesCalculate'; + public const EVENT_ON_TAXES_CALCULATE = 'onTaxesCalculate'; /** * @event CustomerEvent */ - const EVENT_ON_CUSTOMER_UPDATE = 'onCustomerUpdate'; + public const EVENT_ON_CUSTOMER_UPDATE = 'onCustomerUpdate'; /** * @event OrderRefundEvent */ - const EVENT_ON_ORDER_REFUND_CREATED = 'onOrderRefundCreated'; + public const EVENT_ON_ORDER_REFUND_CREATED = 'onOrderRefundCreated'; /** * @event OrderNotificationEvent */ - const EVENT_ON_ORDER_NOTIFICATION_CREATED = 'onOrderNotificationCreated'; + public const EVENT_ON_ORDER_NOTIFICATION_CREATED = 'onOrderNotificationCreated'; /** * @var string Indicates that the webhook payload is live */ - const WEBHOOK_MODE_LIVE = 'Live'; + public const WEBHOOK_MODE_LIVE = 'Live'; /** * @var string Indicates that the webhook payload is for testing */ - const WEBHOOK_MODE_TEST = 'Test'; + public const WEBHOOK_MODE_TEST = 'Test'; /** * @var mixed local reference to decoded post data @@ -117,7 +118,7 @@ class Webhooks extends \craft\base\Component /** * @var string Should be either WEBHOOK_MODE_LIVE or WEBHOOK_MODE_TEST */ - private $currentMode; + private string $currentMode = ''; /** * Sets the payload data and derived mode to be utilized within the service @@ -125,7 +126,7 @@ class Webhooks extends \craft\base\Component * * @param $payload */ - public function setData($payload) + public function setData($payload): void { /** * Track whether we’re in live or test mode. We know ->mode exists @@ -163,14 +164,13 @@ public function getData() * * @return mixed */ - public function setMode($mode) + public function setMode(string $mode): string { return $this->currentMode = $mode; } /** * Gets the mode of the current request, which is either `Live` or `Test`. - * @return string */ public function getMode(): string { @@ -196,7 +196,7 @@ public function handleOrderCompleted(): array $this->trigger( self::EVENT_BEFORE_PROCESS_COMPLETED_ORDER, new OrderEvent([ - 'order' => $order + 'order' => $order, ]) ); } @@ -204,14 +204,14 @@ public function handleOrderCompleted(): array $providerOrders = Snipcart::$plugin->shipments->handleCompletedOrder($order); if (! empty($providerOrders->errors)) { - $responseData['success'] = false; + $responseData['success'] = false; $responseData['errors'][] = $providerOrders->errors; } if (! Snipcart::$plugin->orders->updateProductsFromOrder($order)) { - $responseData['success'] = false; + $responseData['success'] = false; $responseData['errors'][] = [ - 'elements' => 'Failed to update product Elements.' + 'elements' => 'Failed to update product Elements.', ]; } @@ -226,7 +226,9 @@ public function handleOrderCompleted(): array if (Snipcart::$plugin->getSettings()->sendOrderNotificationEmail) { Snipcart::$plugin->orders->sendOrderEmailNotification( $order, - [ 'providerOrders' => $providerOrders->orders ?? null ], + [ + 'providerOrders' => $providerOrders->orders ?? null, + ], Orders::NOTIFICATION_TYPE_ADMIN ); } @@ -234,12 +236,14 @@ public function handleOrderCompleted(): array if (Snipcart::$plugin->getSettings()->sendCustomerOrderNotificationEmail) { Snipcart::$plugin->orders->sendOrderEmailNotification( $order, - [ 'providerOrders' => $providerOrders->orders ?? null ], + [ + 'providerOrders' => $providerOrders->orders ?? null, + ], Orders::NOTIFICATION_TYPE_CUSTOMER ); } - if (count($responseData['errors']) === 0) { + if ($responseData['errors'] === []) { unset($responseData['errors']); } @@ -258,10 +262,10 @@ public function handleShippingRatesFetch(): array $rates = Snipcart::$plugin->shipments->collectRatesForOrder($order); if (Snipcart::$plugin->getSettings()->logCustomRates) { - $shippingQuoteLog = new ShippingQuoteLog(); + $shippingQuoteLog = new ShippingQuoteLog(); $shippingQuoteLog->siteId = Craft::$app->sites->currentSite->id; - $shippingQuoteLog->token = $order->token; - $shippingQuoteLog->body = $rates; + $shippingQuoteLog->token = $order->token; + $shippingQuoteLog->body = $rates; $shippingQuoteLog->save(); } @@ -270,22 +274,20 @@ public function handleShippingRatesFetch(): array /** * Handles an order status change. - * - * @return array */ public function handleOrderStatusChange(): array { $fromStatus = $this->getData()->from; - $toStatus = $this->getData()->to; - $order = $this->getCleanOrder(); + $toStatus = $this->getData()->to; + $order = $this->getCleanOrder(); if ($this->hasEventHandlers(self::EVENT_ON_ORDER_STATUS_CHANGED)) { $this->trigger( self::EVENT_ON_ORDER_STATUS_CHANGED, new OrderStatusEvent([ - 'order' => $order, + 'order' => $order, 'fromStatus' => $fromStatus, - 'toStatus' => $toStatus, + 'toStatus' => $toStatus, ]) ); } @@ -295,22 +297,20 @@ public function handleOrderStatusChange(): array /** * Handles an order payment status change. - * - * @return array */ public function handleOrderPaymentStatusChange(): array { $fromStatus = $this->getData()->from; - $toStatus = $this->getData()->to; - $order = $this->getCleanOrder(); + $toStatus = $this->getData()->to; + $order = $this->getCleanOrder(); if ($this->hasEventHandlers(self::EVENT_ON_ORDER_PAYMENT_STATUS_CHANGED)) { $this->trigger( self::EVENT_ON_ORDER_PAYMENT_STATUS_CHANGED, new OrderStatusEvent([ - 'order' => $order, + 'order' => $order, 'fromStatus' => $fromStatus, - 'toStatus' => $toStatus, + 'toStatus' => $toStatus, ]) ); } @@ -320,22 +320,20 @@ public function handleOrderPaymentStatusChange(): array /** * Handles an order tracking number change. - * - * @return array */ public function handleOrderTrackingNumberChange(): array { $trackingNumber = $this->getData()->trackingNumber; - $trackingUrl = $this->getData()->trackingUrl; - $order = $this->getCleanOrder(); + $trackingUrl = $this->getData()->trackingUrl; + $order = $this->getCleanOrder(); if ($this->hasEventHandlers(self::EVENT_ON_ORDER_TRACKING_CHANGED)) { $this->trigger( self::EVENT_ON_ORDER_TRACKING_CHANGED, new OrderTrackingEvent([ - 'order' => $order, + 'order' => $order, 'trackingNumber' => $trackingNumber, - 'trackingUrl' => $trackingUrl, + 'trackingUrl' => $trackingUrl, ]) ); } @@ -345,8 +343,6 @@ public function handleOrderTrackingNumberChange(): array /** * Handles a created subscription. - * - * @return array */ public function handleSubscriptionCreated(): array { @@ -366,8 +362,6 @@ public function handleSubscriptionCreated(): array /** * Handles a cancelled subscription. - * - * @return array */ public function handleSubscriptionCancelled(): array { @@ -387,8 +381,6 @@ public function handleSubscriptionCancelled(): array /** * Handles a paused subscription. - * - * @return array */ public function handleSubscriptionPaused(): array { @@ -408,8 +400,6 @@ public function handleSubscriptionPaused(): array /** * Handles a resumed subscription. - * - * @return array */ public function handleSubscriptionResumed(): array { @@ -429,8 +419,6 @@ public function handleSubscriptionResumed(): array /** * Handles a new subscription invoice. - * - * @return array */ public function handleSubscriptionInvoiceCreated(): array { @@ -459,22 +447,22 @@ public function handleTaxesCalculate(): array $taxes = []; if ($this->hasEventHandlers(self::EVENT_ON_TAXES_CALCULATE)) { - $event = new TaxesEvent([ + $taxesEvent = new TaxesEvent([ 'order' => $order, 'taxes' => [], ]); - $this->trigger(self::EVENT_ON_TAXES_CALCULATE, $event); - $taxes = array_merge($taxes, $event->taxes); + $this->trigger(self::EVENT_ON_TAXES_CALCULATE, $taxesEvent); + $taxes = array_merge($taxes, $taxesEvent->taxes); } - return [ 'taxes' => $taxes ]; + return [ + 'taxes' => $taxes, + ]; } /** * Handles updated customer details. - * - * @return array */ public function handleCustomerUpdated(): array { @@ -494,8 +482,6 @@ public function handleCustomerUpdated(): array /** * Handles new refund. - * - * @return array */ public function handleRefundCreated(): array { @@ -505,7 +491,7 @@ public function handleRefundCreated(): array $this->trigger( self::EVENT_ON_ORDER_REFUND_CREATED, new OrderRefundEvent([ - 'refund' => $refund + 'refund' => $refund, ]) ); } @@ -515,8 +501,6 @@ public function handleRefundCreated(): array /** * Handles new order notification. - * - * @return array */ public function handleNotificationCreated(): array { @@ -526,7 +510,7 @@ public function handleNotificationCreated(): array $this->trigger( self::EVENT_ON_ORDER_NOTIFICATION_CREATED, new OrderNotificationEvent([ - 'notification' => $notification + 'notification' => $notification, ]) ); } @@ -540,8 +524,6 @@ public function handleNotificationCreated(): array * * This is important because Snipcart payloads sometimes include new * attributes without warning and we don’t want errors in production. - * - * @return Order */ private function getCleanOrder(): Order { @@ -557,8 +539,6 @@ private function getCleanOrder(): Order * * This is important because Snipcart payloads sometimes include new * attributes without warning and we don’t want errors in production. - * - * @return Subscription */ private function getCleanSubscription(): Subscription { @@ -574,8 +554,6 @@ private function getCleanSubscription(): Subscription * * This is important because Snipcart payloads sometimes include new * attributes without warning and we don’t want errors in production. - * - * @return Customer */ private function getCleanCustomer(): Customer { @@ -591,8 +569,6 @@ private function getCleanCustomer(): Customer * * This is important because Snipcart payloads sometimes include new * attributes without warning and we don’t want errors in production. - * - * @return Refund */ private function getCleanRefund(): Refund { @@ -608,8 +584,6 @@ private function getCleanRefund(): Refund * * This is important because Snipcart payloads sometimes include new * attributes without warning and we don’t want errors in production. - * - * @return Notification */ private function getCleanNotification(): Notification { @@ -622,14 +596,14 @@ private function getCleanNotification(): Notification /** * Stores webhook details to the database for later scrutiny. */ - private function logWebhookTransaction() + private function logWebhookTransaction(): void { $webhookLog = new WebhookLog(); $webhookLog->siteId = Craft::$app->sites->currentSite->id; - $webhookLog->type = $this->getData()->eventName; - $webhookLog->body = $this->getData(); - $webhookLog->mode = strtolower($this->getMode()); + $webhookLog->type = $this->getData()->eventName; + $webhookLog->body = $this->getData(); + $webhookLog->mode = strtolower($this->getMode()); $webhookLog->save(); } @@ -637,11 +611,11 @@ private function logWebhookTransaction() /** * Sends back a positive non-response to indicate the webhook was handled * even though we don't have any meaningful data to give back. - * - * @return array */ private function nonResponse(): array { - return [ 'success' => true ]; + return [ + 'success' => true, + ]; } } diff --git a/src/templates/cp/index.twig b/src/templates/cp/index.twig index 496be41..160e605 100644 --- a/src/templates/cp/index.twig +++ b/src/templates/cp/index.twig @@ -141,14 +141,20 @@ {{ "Total"|t }} - {% for order in orders.items %} -
- {{ order.invoiceNumber }} - {{ craft.snipcart.tinyDateInterval(order.completionDate) }} {{ "ago"|t }} - {{ order.billingAddress.name }} - {{ craft.snipcart.formatCurrency(order.finalGrandTotal, order.currency) }} + {% if orders %} + {% for order in orders.items %} +
+ {{ order.invoiceNumber }} + {{ craft.snipcart.tinyDateInterval(order.completionDate) }} {{ "ago"|t }} + {{ order.billingAddress.name }} + {{ craft.snipcart.formatCurrency(order.finalGrandTotal, order.currency) }} +
+ {% endfor %} + {% else %} +
+ {{ "No orders found."|t }}
- {% endfor %} + {% endif %}
@@ -166,13 +172,19 @@ {{ "Total Spent"|t }} - {% for customer in customers.items %} -
- {{ customer.billingAddressName }} - {{ customer.statistics.ordersCount }} - {{ craft.snipcart.formatCurrency(customer.statistics.ordersAmount, craft.snipcart.defaultCurrency) }} + {% if customers %} + {% for customer in customers.items %} +
+ {{ customer.billingAddressName }} + {{ customer.statistics.ordersCount }} + {{ craft.snipcart.formatCurrency(customer.statistics.ordersAmount, craft.snipcart.defaultCurrency) }} +
+ {% endfor %} + {% else %} +
+ {{ "No customers found."|t }}
- {% endfor %} + {% endif %}
diff --git a/src/templates/cp/orders/index.twig b/src/templates/cp/orders/index.twig index bfae99c..e88688f 100755 --- a/src/templates/cp/orders/index.twig +++ b/src/templates/cp/orders/index.twig @@ -9,11 +9,8 @@ {% block content %}
- - - {% if orders|length %} + +
{{ csrfInput() }} @@ -43,7 +40,12 @@
+ + + {% if orders|length %} diff --git a/src/validators/ProductDetailsValidator.php b/src/validators/ProductDetailsValidator.php new file mode 100644 index 0000000..41d3598 --- /dev/null +++ b/src/validators/ProductDetailsValidator.php @@ -0,0 +1,144 @@ +{$attribute}; + + $sectionHandle = $model->section->handle; + + // Remove prefix from field handle + $fieldHandle = preg_replace('/^field:/', '', $attribute); + + // don't like this but... + // we are using a money field so when we try to save the value + // there is an issue with the column type in the database (DECIMAL) + // and it doesn't like the value being passed to it + // so we remove the comma from the value + // there's definitely a better way to do this ¯\_(ツ)_/¯ + $value['price'] = str_replace(',', '', $value['price']); + + /* SKU field validations */ + // test for empty SKU + if ($value['sku'] === null || trim($value['sku']) === '') { + $this->addError($model, $attribute, 'SKU cannot be blank'); + } + + // test for unique SKU + // query for all product details SKU fields + + /* + if(!$model->$attribute->validateSku('sku')){ + $this->addError($model, $attribute, 'SKU must be unique'); + } + */ + + if (! $this->skuIsUnique($model, $value['sku'], $sectionHandle, $fieldHandle)) { + $this->addError($model, $attribute, 'SKU must be unique'); + } + + /* Inventory field validations */ + + if ($value['inventory'] !== null) { + if ($value['inventory'] < 0) { + $this->addError($model, $attribute, 'Inventory cannot be less than 0'); + } elseif (! is_numeric($value['inventory'])) { + $this->addError($model, $attribute, 'Inventory must be a number'); + } + } + + /* Price field validations */ + if ($value['price'] === null || trim($value['price'] === '')) { + $this->addError($model, $attribute, 'Price cannot be blank'); + } elseif ($value['price'] !== null && $value['price'] < 0) { + $this->addError($model, $attribute, 'Price cannot be negative'); + } elseif ($value['price'] !== null && ! is_numeric($value['price'])) { + $this->addError($model, $attribute, 'Price must be numeric'); + } + } + + public function isEmpty($value): bool + { + if ($this->isEmpty !== null) { + return parent::isEmpty($value); + } + + return empty($value); + } + + public function skuIsUnique($model, $sku, mixed $sectionHandle, $fieldHandle): bool + { + + /* + $entryQuery = craft\elements\Entry::find() + ->section($sectionHandle) + ->where(["field_${fieldHandle}_mduolzrl" => $sku]); + + $entries = $entryQuery->count(); + */ + + /* + $entryQuery = craft\elements\Entry::find() + ->section($sectionHandle); + + //$entryQuery->subQuery->andWhere(Db::parseParam($fieldHandle, $sku)); + $entryQuery->andWhere("${fieldHandle} = '${sku}'"); + //$entryQuery->andWhere("'elementId' = 352"); + + $entries = $entryQuery->count(); + */ + + $entries = Entry::find()->section($sectionHandle)->id(['not', $model->id])->all(); + + foreach ($entries as $entry) { + if (ElementHelper::isDraft($entry)) { + continue; + } + + if (! ($entry->enabled && $entry->getEnabledForSite())) { + continue; + } + + if (ElementHelper::rootElement($entry)->isProvisionalDraft) { + continue; + } + + if (ElementHelper::isRevision($entry)) { + continue; + } + + if ($entry->{$fieldHandle} === null) { + continue; + } + + if ($entry->{$fieldHandle}->sku === $model->{$fieldHandle}->sku) { + return false; + } + } + + return true; + } +} diff --git a/src/variables/SnipcartVariable.php b/src/variables/SnipcartVariable.php index bc558c1..9f32f93 100755 --- a/src/variables/SnipcartVariable.php +++ b/src/variables/SnipcartVariable.php @@ -2,12 +2,20 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\variables; +use craft\base\Element; +use Twig\Error\LoaderError; +use Twig\Error\RuntimeError; +use Twig\Error\SyntaxError; +use yii\base\Exception; +use Twig\Markup; +use Craft; +use craft\helpers\Template as TemplateHelper; use fostercommerce\snipcart\fields\ProductDetails; use fostercommerce\snipcart\helpers\FieldHelper; use fostercommerce\snipcart\helpers\FormatHelper; @@ -16,16 +24,12 @@ use fostercommerce\snipcart\models\snipcart\Order; use fostercommerce\snipcart\models\snipcart\Subscription; use fostercommerce\snipcart\Snipcart; -use Craft; -use craft\helpers\Template as TemplateHelper; use yii\base\InvalidConfigException; class SnipcartVariable { /** * Returns Snipcart public API key. - * - * @return string */ public function publicApiKey(): string { @@ -34,8 +38,6 @@ public function publicApiKey(): string /** * Returns the default currency. - * - * @return string */ public function defaultCurrency(): string { @@ -44,8 +46,6 @@ public function defaultCurrency(): string /** * Returns the default currency symbol. - * - * @return string */ public function defaultCurrencySymbol(): string { @@ -59,10 +59,9 @@ public function defaultCurrencySymbol(): string * @param string $currencyType Optional string representing desired currency * to be explicitly set. * - * @return string * @throws InvalidConfigException if no currency is given and [[currencyCode]] is not defined. */ - public function formatCurrency($value, $currencyType = null): string + public function formatCurrency(mixed $value, $currencyType = null): string { return FormatHelper::formatCurrency($value, $currencyType); } @@ -70,14 +69,10 @@ public function formatCurrency($value, $currencyType = null): string /** * Returns a compact, general, relative, human-readable string representing * the age of the provided DateTime. - * - * @param \DateTime $date - * - * @return string */ - public function tinyDateInterval(\DateTime $date): string + public function tinyDateInterval(\DateTime $dateTime): string { - return FormatHelper::tinyDateInterval($date); + return FormatHelper::tinyDateInterval($dateTime); } /** @@ -95,11 +90,10 @@ public function getCustomer($customerId) /** * Returns a Snipcart order by ID. * - * @param string $orderId * @return Order|null * @throws \Exception if API key is missing. */ - public function getOrder($orderId) + public function getOrder(string $orderId) { return Snipcart::$plugin->orders->getOrder($orderId); } @@ -120,7 +114,7 @@ public function getSubscription($subscriptionId) * Returns product info for the provided Element regardless of what the * field handle might be. * - * @param \craft\base\Element $element + * @param Element $element * @return ProductDetails|null */ public function getProductInfo($element) @@ -134,19 +128,18 @@ public function getProductInfo($element) * @param string $text Button's inner text. Defaults to `Shopping Cart`. * @param bool $showCount `false` to remove dynamic item count. * - * @return \Twig\Markup - * @throws \Twig\Error\LoaderError - * @throws \Twig\Error\RuntimeError - * @throws \Twig\Error\SyntaxError - * @throws \yii\base\Exception + * @throws LoaderError + * @throws RuntimeError + * @throws SyntaxError + * @throws Exception */ - public function cartLink($text = null, $showCount = true): \Twig\Markup + public function cartLink($text = null, $showCount = true): Markup { return $this->renderTemplate( 'snipcart/front-end/cart-link', [ 'text' => $text, - 'showCount' => $showCount + 'showCount' => $showCount, ] ); } @@ -159,16 +152,15 @@ public function cartLink($text = null, $showCount = true): \Twig\Markup * @param string $onload * @param bool $includeStyles * - * @return \Twig\Markup - * @throws \Twig\Error\LoaderError - * @throws \Twig\Error\RuntimeError - * @throws \Twig\Error\SyntaxError - * @throws \yii\base\Exception + * @throws LoaderError + * @throws RuntimeError + * @throws SyntaxError + * @throws Exception */ - public function cartSnippet($includejQuery = true, $onload = '', $includeStyles = true): \Twig\Markup + public function cartSnippet($includejQuery = true, $onload = '', $includeStyles = true): Markup { - $settings = Snipcart::$plugin->getSettings(); - $publicApiKey = $settings->publicKey(); + $model = Snipcart::$plugin->getSettings(); + $publicApiKey = $model->publicKey(); if (VersionHelper::isCraft31()) { $publicApiKey = Craft::parseEnv($publicApiKey); @@ -177,31 +169,28 @@ public function cartSnippet($includejQuery = true, $onload = '', $includeStyles return $this->renderTemplate( 'snipcart/front-end/cart-js', [ - 'settings' => $settings, + 'settings' => $model, 'includejQuery' => $includejQuery, 'includeStyles' => $includeStyles, - 'publicApiKey' => $publicApiKey, - 'onload' => $onload + 'publicApiKey' => $publicApiKey, + 'onload' => $onload, ] ); } - /** * Renders an internal (plugin) Twig template. * * @param $template - * @param array $data * - * @return \Twig\Markup - * @throws \Twig\Error\LoaderError - * @throws \Twig\Error\RuntimeError - * @throws \Twig\Error\SyntaxError - * @throws \yii\base\Exception + * @throws LoaderError + * @throws RuntimeError + * @throws SyntaxError + * @throws Exception */ - private function renderTemplate($template, $data = []): \Twig\Markup + private function renderTemplate(string $template, array $data = []): Markup { - $view = Craft::$app->getView(); + $view = Craft::$app->getView(); $templateMode = $view->getTemplateMode(); // use CP mode @@ -215,5 +204,4 @@ private function renderTemplate($template, $data = []): \Twig\Markup return TemplateHelper::raw($html); } - } diff --git a/src/widgets/Orders.php b/src/widgets/Orders.php index 23fe6fd..9cbef82 100644 --- a/src/widgets/Orders.php +++ b/src/widgets/Orders.php @@ -2,16 +2,21 @@ /** * Snipcart plugin for Craft CMS 3.x * - * @link https://workingconcept.com + * @link https://fostercommerce.com * @copyright Copyright (c) 2018 Working Concept Inc. */ namespace fostercommerce\snipcart\widgets; -use fostercommerce\snipcart\assetbundles\OrdersWidgetAsset; -use fostercommerce\snipcart\Snipcart; +use Twig\Error\LoaderError; +use Twig\Error\RuntimeError; +use Twig\Error\SyntaxError; +use yii\base\Exception; +use yii\base\InvalidConfigException; use Craft; use craft\base\Widget; +use fostercommerce\snipcart\assetbundles\OrdersWidgetAsset; +use fostercommerce\snipcart\Snipcart; /** * Orders Widget @@ -21,44 +26,32 @@ class Orders extends Widget /** * @var string Type of order data to be displayed. */ - public $chartType = 'itemsSold'; + public string $chartType = 'itemsSold'; /** * @var string Range of time for which data should be summarized. */ - public $chartRange = 'weekly'; + public string $chartRange = 'weekly'; - /** - * @inheritdoc - */ public static function displayName(): string { return Craft::t('snipcart', 'Snipcart Orders'); } - /** - * @inheritdoc - */ - public static function iconPath() + public static function iconPath(): string { return Craft::getAlias('@fostercommerce/snipcart/assetbundles/dist/img/orders-icon.svg'); } - /** - * @inheritdoc - */ public static function maxColspan(): int { return 3; } - /** - * @inheritdoc - */ public function getTitle(): string { $rangeName = $this->getChartRangeOptions()[$this->chartRange]; - $typeName = $this->getChartTypeOptions()[$this->chartType]; + $typeName = $this->getChartTypeOptions()[$this->chartType]; return Craft::t('snipcart', sprintf( 'Snipcart %s %s', @@ -67,9 +60,6 @@ public function getTitle(): string )); } - /** - * @inheritdoc - */ public function rules(): array { $rules = parent::rules(); @@ -94,13 +84,13 @@ public function rules(): array * Returns the widget body HTML. * * @return false|string - * @throws \Twig\Error\LoaderError - * @throws \Twig\Error\RuntimeError - * @throws \Twig\Error\SyntaxError - * @throws \yii\base\Exception - * @throws \yii\base\InvalidConfigException + * @throws LoaderError + * @throws RuntimeError + * @throws SyntaxError + * @throws Exception + * @throws InvalidConfigException */ - public function getBodyHtml() + public function getBodyHtml(): ?string { $view = Craft::$app->getView(); @@ -113,49 +103,41 @@ public function getBodyHtml() return Craft::$app->getView()->renderTemplate( 'snipcart/widgets/orders/orders', [ - 'widget' => $this, - 'settings' => Snipcart::$plugin->getSettings() + 'widget' => $this, + 'settings' => Snipcart::$plugin->getSettings(), ] ); } - /** - * @inheritdoc - */ - public function getSettingsHtml() + public function getSettingsHtml(): ?string { return Craft::$app->getView()->renderTemplate( 'snipcart/widgets/orders/settings', [ - 'widget' => $this + 'widget' => $this, ] ); } /** * Get a key-value array representing options for the type of data to be charted. - * - * @return array */ public function getChartTypeOptions(): array { return [ - 'totalSales' => 'Sales', + 'totalSales' => 'Sales', 'numberOfOrders' => 'Orders', ]; } /** * Get a key-value array representing options for the chart's time range. - * - * @return array */ public function getChartRangeOptions(): array { return [ - 'weekly' => 'Weekly', + 'weekly' => 'Weekly', 'monthly' => 'Monthly', ]; } - }
{{ "Invoice"|t }}