diff --git a/README.md b/README.md index e5087aa..f97504f 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ You can now see your download stats in the panel. This currently works only, if ## Features +* ✅ Import wizard, move your existing podcast to kirby * ✅ Panel blueprint section for episodes * ✅ Panel blueprint for extended RSS feed (including all new iTunes specifications) * ✅ Run multiple podcasts with just one Kirby installation @@ -29,10 +30,11 @@ You can now see your download stats in the panel. This currently works only, if * ✅ Statistics view in Panel * ✅ Prefill fields from your ID3 data -### Planned -* Import your old podcast to Kirby Podcaster -* Snippet for Podlove Subscribe box +### Changelog + +* 2019-07-25 - Podcaster Wizard, import your existing podcast into kirby +* 2019-07-24 - New Apple Podcast Categories ## Installation @@ -40,6 +42,22 @@ You can now see your download stats in the panel. This currently works only, if - unzip [master.zip](https://github.com/mauricerenck/kirby-podcaster/releases/latest) as folder `site/plugins/kirby-podcaster` - `git submodule add https://github.com/mauricerenck/kirby-podcaster.git site/plugins/kirby-podcaster` +### Move your existing Podcast to Kirby + +![stats sample](doc-assets/create-wizard.png) + +1. In the panel create a new page. Name it however you want, select the template `Podcaster Wizard`. After the page is created, open it in the panel. +2. Enter your current feed url, select the target page. Below this page all episodes and the feed will be created. Make sure there are no other pages within your target page, otherwise the import may fail. +3. Enter the template that should be used for your episodes. If your content files look like `article.txt` your template name i `article`. +4. You can now decide if the episodes should be created as draft (default and recommended) or unlisted. +5. Hit the `Start import` button and lean back. + +![stats sample](doc-assets/wizard-panel.png) + +**Please do not close the wizard page, or the import will be interrupted and fail** + +After the import is finished, you should delete the import wizard page, you don't need it anymore. + ### Create RSS-Feed Log into the panel and go to the folder containing your podcast episodes. Add a new unlisted page and name it `feed` using the template `podcasterfeed`. Please note that there is a problem, the template currently doesn't appear in the template list, so you have to add or change it by hand, naming the markdown-file `podcasterfeed`. The feed can then be edited in the panel. diff --git a/UPDATE-FROM-K2.md b/UPDATE-FROM-K2.md deleted file mode 100644 index 90e6b75..0000000 --- a/UPDATE-FROM-K2.md +++ /dev/null @@ -1,23 +0,0 @@ -# Changes - -title -> podcasterTitel -Itunesimage -> podcasterCover -Itunessubtitle -> podcasterSubtitle -Language -> podcasterLanguage -Ituneskeywords -> podcasterKeywords -Description -> podcasterDescription -Itunesblock -> podcasterBlock -Itunesexplicit -> podcasterExplicit -Itunesauthor -> podcasterAuthor -Itunesowner, Itunesemail -> podcasterOwner -iTunesType -> podcasterType -iTunesCategories -> podcasterCategories - - -``` - -foreach($children as $episode) { - snippet('podcaster-player', ['page' => $episode]); -} - -``` diff --git a/blueprints/pages/podcasterwizard.yml b/blueprints/pages/podcasterwizard.yml new file mode 100644 index 0000000..b3ecc19 --- /dev/null +++ b/blueprints/pages/podcasterwizard.yml @@ -0,0 +1,62 @@ +title: Podcaster Wizard +tabs: + wizard: + label: Wizard + icon: wand + columns: + - width: 1/3 + sections: + wizardInfo: + type: fields + fields: + wizardHead: + type: headline + label: Import Wizard + wizardInfo: + type: info + label: Hello there!️️ + theme: positive + text: This wizard helps you transfering your existing podcast to Kirby. It uses your RSS-Feed for that. All information will be imported from this feed. + wizardStep1: + type: info + label: Needed information + text: Please enter the URL of your current podcast feed. Then select the page which will function as your target. All episodes and the feed will be created as children of this page. Hit save, then start the import. + wizardStep2: + type: info + label: Be aware + theme: negative + text: This feature is experimental. It'll create new pages and add information. Please backup your data before you do this. Also make sure the target page has no other pages in it. Otherwise the import may fail! + - width: 2/3 + sections: + wizardSteps: + type: fields + fields: + wizardInfos: + type: headline + label: Start your import + podcasterWizardSrcFeed: + type: url + label: Your source RSS-Feed + required: true + podcasterWizardDestination: + type: pages + label: Parent Page + width: 1/3 + required: true + podcasterWizardTemplate: + type: text + label: Template Name + help: Without file extension, if your content files look like 'article.txt' then your template name is 'article' + width: 1/3 + required: true + podcasterWizardPageStatus: + type: toggle + label: Page Status + default: no + text: + Draft + Unlisted + help: Pages created by this wizard will be drafts. If you want, they can also be unlisted. + width: 1/3 + podstatsFeed: + type: podcasterWizard diff --git a/composer.json b/composer.json index 572b09b..09d3127 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "mauricerenck/podcaster", - "version": "1.1.4", + "version": "1.2.0", "description": "A podcast plugin for Kirby 3", "type": "kirby-plugin", "license": "MIT", @@ -18,6 +18,7 @@ "utils/PodcasterStatsFile.php", "utils/PodcasterStatsMysql.php", "utils/PodcasterStatsPodTrac.php", + "utils/PodcasterWizard.php", "lib/PiwikTracker.php" ] }, diff --git a/composer.lock b/composer.lock index ed28c21..8c9c69c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "b33ed9709cf46af6c495485f56e31150", + "content-hash": "f7b44db4b5f4718f8236c011bbbf3387", "packages": [ { "name": "getkirby/composer-installer", diff --git a/config/api.php b/config/api.php new file mode 100644 index 0000000..ff9f926 --- /dev/null +++ b/config/api.php @@ -0,0 +1,174 @@ + [ + [ + 'pattern' => 'podcaster/stats/(:any)/year/(:num)/month/(:num)', + 'action' => function ($podcast, $year, $month) { + if (option('mauricerenck.podcaster.statsInternal') === false || option('mauricerenck.podcaster.statsType') === 'file') { + $errorMessage = ['error' => 'cannot use stats on file method, use mysql version instead']; + echo new Response(json_encode($errorMessage), 'application/json', 501); + } + + $podcasterStats = new PodcasterStats(); + $stats = $podcasterStats->getEpisodeStatsOfMonth($podcast, $year, $month); + return [ + 'stats' => $stats + ]; + } + ], + [ + 'pattern' => 'podcaster/stats/(:any)/(:any)/yearly-downloads/(:any)', + 'action' => function ($podcast, $type, $year) { + if (option('mauricerenck.podcaster.statsInternal') === false || option('mauricerenck.podcaster.statsType') === 'file') { + $errorMessage = ['error' => 'cannot use stats on file method, use mysql version instead']; + echo new Response(json_encode($errorMessage), 'application/json', 501); + } + + $podcasterStats = new PodcasterStats(); + $stats = $podcasterStats->getDownloadsOfYear($podcast, $year, $type); + return [ + 'stats' => $stats + ]; + } + ], + [ + 'pattern' => 'podcaster/stats/(:any)/top/(:num)', + 'action' => function ($podcast, $limit) { + if (option('mauricerenck.podcaster.statsInternal') === false || option('mauricerenck.podcaster.statsType') === 'file') { + $errorMessage = ['error' => 'cannot use stats on file method, use mysql version instead']; + echo new Response(json_encode($errorMessage), 'application/json', 501); + } + + $podcasterStats = new PodcasterStats(); + $stats = $podcasterStats->getTopDownloads($podcast, $limit); + return [ + 'stats' => $stats + ]; + } + ], + [ + 'pattern' => 'podcaster/wizard/checkfeed', + 'action' => function () { + try { + $feedUrl = $_SERVER['HTTP_X_FEED_URI']; + } catch (Exeption $e) { + echo 'Could not read feed'; + } + + $feed = implode(file($feedUrl)); + return Xml::parse($feed); + } + ], + [ + 'pattern' => 'podcaster/wizard/createFeed', + 'action' => function () { + $headerTarget = $_SERVER['HTTP_X_TARGET_PAGE']; + + $targetPage = kirby()->page($headerTarget); + $pageData = json_decode(file_get_contents('php://input')); + + $wizardHelper = new PodcasterWizard(); + + $newPageData = [ + 'slug' => 'feed', + 'template' => 'podcasterfeed', + 'draft' => false, + 'content' => [ + 'podcasterSource' => $targetPage->slug(), + 'title' => $wizardHelper->getField($pageData, 'title'), + 'podcasterTitle' => $wizardHelper->getField($pageData, 'title'), + 'podcasterDescription' => $wizardHelper->getField($pageData, 'description'), + 'podcasterSubtitle' => $wizardHelper->getField($pageData, 'itunessubtitle'), + 'podcasterKeywords' => $wizardHelper->getField($pageData, 'ituneskeywords'), + 'podcasterCopyright' => $wizardHelper->getField($pageData, 'copyright'), + 'podcasterLink' => $wizardHelper->getField($pageData, 'link'), + 'podcasterLanguage' => $wizardHelper->getField($pageData, 'language'), + 'podcasterType' => $wizardHelper->getField($pageData, 'itunestype'), + 'podcasterExplicit' => $wizardHelper->getField($pageData, 'itunesexplicit'), + 'podcasterBlock' => $wizardHelper->getField($pageData, 'itunesblock') + ] + ]; + + $feed = $targetPage->createChild($newPageData); + + return json_encode(['title' => $pageData->title, 'slug' => $feed->id()]); + }, + 'method' => 'POST' + ], + [ + 'pattern' => 'podcaster/wizard/createEpisode', + 'action' => function () { + $headerTarget = $_SERVER['HTTP_X_TARGET_PAGE']; + $headerTemplate = $_SERVER['HTTP_X_PAGE_TEMPLATE']; + $pageStatus = ($_SERVER['HTTP_X_PAGE_STATUS'] === 'false'); + + $targetPage = kirby()->page($headerTarget); + $pageData = json_decode(file_get_contents('php://input')); + + $wizardHelper = new PodcasterWizard(); + $slug = $wizardHelper->getPageSlug($wizardHelper->getField($pageData, 'link'), $wizardHelper->getField($pageData, 'title')); + + $newPageData = [ + 'slug' => $slug, + 'template' => $headerTemplate, + 'draft' => $pageStatus, + 'content' => [ + 'title' => $wizardHelper->getField($pageData, 'title'), + 'date' => $wizardHelper->getField($pageData, 'pubDate'), + 'podcasterSeason' => $wizardHelper->getField($pageData, 'itunesseason'), + 'podcasterEpisode' => $wizardHelper->getField($pageData, 'itunesepisode'), + 'podcasterEpisodeType' => $wizardHelper->getField($pageData, 'itunesepisodetype'), + 'podcasterExplizit' => $wizardHelper->getField($pageData, 'itunesexplicit'), + 'podcasterBlock' => $wizardHelper->getField($pageData, 'itunesblock'), + 'podcasterTitle' => $wizardHelper->getField($pageData, 'title'), + 'podcasterSubtitle' => $wizardHelper->getField($pageData, 'itunessubtitle'), + 'podcasterDescription' => $wizardHelper->getField($pageData, 'description'), + ] + ]; + + $episode = $targetPage->createChild($newPageData); + $mp3FileName = $slug . '.mp3'; + + return json_encode(['title' => $pageData->title, 'slug' => $episode->id(), 'file' => $wizardHelper->getField($pageData, 'file')]); + }, + 'method' => 'POST' + ], + [ + 'pattern' => 'podcaster/wizard/createFile', + 'action' => function () { + $headerTarget = $_SERVER['HTTP_X_TARGET_PAGE']; + + $episode = kirby()->page($headerTarget); + $pageData = json_decode(file_get_contents('php://input')); + + $wizardHelper = new PodcasterWizard(); + $slug = $episode->slug(); + + $mp3FileName = $slug . '.mp3'; + $mp3 = $wizardHelper->downloadMp3($wizardHelper->getField($pageData, 'file'), $mp3FileName); + + $file = File::create([ + 'source' => kirby()->root('plugins') . '/kirby-podcaster/tmp/' . $mp3FileName, + 'parent' => $episode, + 'filename' => $mp3FileName, + 'template' => 'podcaster-episode', + 'content' => [ + 'duration' => $wizardHelper->getField($pageData, 'itunesduration'), + 'episodeTitle' => $wizardHelper->getField($pageData, 'itunestitle') + ] + ]); + + unlink(kirby()->root('plugins') . '/kirby-podcaster/tmp/' . $mp3FileName); + + return json_encode(['created' => $mp3FileName]); + }, + 'method' => 'POST' + ] + ] +]; diff --git a/doc-assets/create-wizard.png b/doc-assets/create-wizard.png new file mode 100644 index 0000000..8a9c691 Binary files /dev/null and b/doc-assets/create-wizard.png differ diff --git a/doc-assets/wizard-panel.png b/doc-assets/wizard-panel.png new file mode 100644 index 0000000..bedb6c2 Binary files /dev/null and b/doc-assets/wizard-panel.png differ diff --git a/index.css b/index.css index 2d41a0f..4a58e65 100644 --- a/index.css +++ b/index.css @@ -1 +1 @@ -.k-section-name-podstatsEpisodic table{width:100%;border:1px solid #ccc;background:#fff;margin-top:.5em}.k-section-name-podstatsEpisodic td{border-bottom:1px solid #ccc;line-height:2;padding:0 10px}.k-section-name-podstatsEpisodic td:first-child{text-align:right}.k-section-name-podstatsEpisodic .podcaster-prev-next{display:inline;text-align:right;color:#666}.k-section-name-podstatsEpisodic .k-headline{display:inline}.k-section-name-podstatsEpisodic .k-text{color:red}.chart-container{position:relative;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.chart-container .axis,.chart-container .chart-label{fill:#555b51}.chart-container .axis line,.chart-container .chart-label line{stroke:#dadada}.chart-container .dataset-units circle{stroke:#fff;stroke-width:2}.chart-container .dataset-units path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container .dataset-path{stroke-width:2px}.chart-container .path-group path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container line.dashed{stroke-dasharray:5,3}.chart-container .axis-line .specific-value{text-anchor:start}.chart-container .axis-line .y-line{text-anchor:end}.chart-container .axis-line .x-line{text-anchor:middle}.chart-container .legend-dataset-text{fill:#6c7680;font-weight:600}.graph-svg-tip{position:absolute;z-index:1;padding:10px;font-size:12px;color:#959da5;text-align:center;background:rgba(0,0,0,.8);border-radius:3px}.graph-svg-tip ol,.graph-svg-tip ul{padding-left:0;display:-webkit-box;display:-ms-flexbox;display:flex}.graph-svg-tip ul.data-point-list li{min-width:90px;-webkit-box-flex:1;-ms-flex:1;flex:1;font-weight:600}.graph-svg-tip strong{color:#dfe2e5;font-weight:600}.graph-svg-tip .svg-pointer{position:absolute;height:5px;margin:0 0 0 -5px;content:" ";border:5px solid transparent;border-top-color:rgba(0,0,0,.8)}.graph-svg-tip.comparison{padding:0;text-align:left;pointer-events:none}.graph-svg-tip.comparison .title{display:block;padding:10px;margin:0;font-weight:600;line-height:1;pointer-events:none}.graph-svg-tip.comparison ul{margin:0;white-space:nowrap;list-style:none}.graph-svg-tip.comparison li{display:inline-block;padding:5px 10px}.line-graph-path{stroke-width:2px!important}.k-section-name-podstatsTop table{width:100%;border:1px solid #ccc;background:#fff;margin-top:.5em}.k-section-name-podstatsTop td{border-bottom:1px solid #ccc;line-height:2;padding:0 10px}.k-section-name-podstatsTop td:first-child{text-align:right}.k-section-name-podstatsTop .podcaster-prev-next{display:inline;text-align:right;color:#666}.k-section-name-podstatsTop .k-headline{display:inline}.k-section-name-podstatsTop .k-text{color:red}.line-graph-path{stroke-width:2px!important} \ No newline at end of file +.k-section-name-podstatsEpisodic table{width:100%;border:1px solid #ccc;background:#fff;margin-top:.5em}.k-section-name-podstatsEpisodic td{border-bottom:1px solid #ccc;line-height:2;padding:0 10px}.k-section-name-podstatsEpisodic td:first-child{text-align:right}.k-section-name-podstatsEpisodic .podcaster-prev-next{display:inline;text-align:right;color:#666}.k-section-name-podstatsEpisodic .k-headline{display:inline}.k-section-name-podstatsEpisodic .k-text{color:red}.chart-container{position:relative;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.chart-container .axis,.chart-container .chart-label{fill:#555b51}.chart-container .axis line,.chart-container .chart-label line{stroke:#dadada}.chart-container .dataset-units circle{stroke:#fff;stroke-width:2}.chart-container .dataset-units path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container .dataset-path{stroke-width:2px}.chart-container .path-group path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container line.dashed{stroke-dasharray:5,3}.chart-container .axis-line .specific-value{text-anchor:start}.chart-container .axis-line .y-line{text-anchor:end}.chart-container .axis-line .x-line{text-anchor:middle}.chart-container .legend-dataset-text{fill:#6c7680;font-weight:600}.graph-svg-tip{position:absolute;z-index:1;padding:10px;font-size:12px;color:#959da5;text-align:center;background:rgba(0,0,0,.8);border-radius:3px}.graph-svg-tip ol,.graph-svg-tip ul{padding-left:0;display:-webkit-box;display:-ms-flexbox;display:flex}.graph-svg-tip ul.data-point-list li{min-width:90px;-webkit-box-flex:1;-ms-flex:1;flex:1;font-weight:600}.graph-svg-tip strong{color:#dfe2e5;font-weight:600}.graph-svg-tip .svg-pointer{position:absolute;height:5px;margin:0 0 0 -5px;content:" ";border:5px solid transparent;border-top-color:rgba(0,0,0,.8)}.graph-svg-tip.comparison{padding:0;text-align:left;pointer-events:none}.graph-svg-tip.comparison .title{display:block;padding:10px;margin:0;font-weight:600;line-height:1;pointer-events:none}.graph-svg-tip.comparison ul{margin:0;white-space:nowrap;list-style:none}.graph-svg-tip.comparison li{display:inline-block;padding:5px 10px}.line-graph-path{stroke-width:2px!important}.k-section-name-podstatsTop table{width:100%;border:1px solid #ccc;background:#fff;margin-top:.5em}.k-section-name-podstatsTop td{border-bottom:1px solid #ccc;line-height:2;padding:0 10px}.k-section-name-podstatsTop td:first-child{text-align:right}.k-section-name-podstatsTop .podcaster-prev-next{display:inline;text-align:right;color:#666}.k-section-name-podstatsTop .k-headline{display:inline}.k-section-name-podstatsTop .k-text{color:red}.line-graph-path{stroke-width:2px!important}.podcaster-import-wizard button{border:1px solid green;padding:5px 10px;background:#fff;margin:5px}.podcaster-import-wizard .start-file-transfer{display:none}.podcaster-import-wizard .log{display:none;background:#fff;font-family:courier;font-size:14px}.podcaster-import-wizard .log div{padding:10px 20px}.podcaster-import-wizard .log .currentState{font-weight:700;background:#333;color:#fff}.podcaster-import-wizard .log .important{background:#eec6c6;border-left:2px solid #d16464} \ No newline at end of file diff --git a/index.js b/index.js index 7dd2988..1b7eaab 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -(function () {function cb(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return G(e).getMonth()}function G(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new Date(e.getTime()):"number"==typeof e||"[object Number]"===t?new Date(e):("string"!=typeof e&&"[object String]"!==t||"undefined"==typeof console||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn(new Error().stack)),new Date(NaN))}function na(t,e){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=G(t),a=va(e),$=r.getMonth()+a,n=new Date(0);n.setFullYear(r.getFullYear(),$,1),n.setHours(0,0,0,0);var o=Pa(n);return r.setMonth($,Math.min(o,r.getDate())),r}function va(r){if(null===r||!0===r||!1===r)return NaN;var t=Number(r);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function Pa(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=G(e),r=t.getFullYear(),$=t.getMonth(),a=new Date(0);return a.setFullYear(r,$+1,0),a.setHours(0,0,0,0),a.getDate()}function Xa(e,r){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var t=va(r);return na(e,-t)}function L(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return G(e).getFullYear()}var i={data:function(){return{currentDate:new Date,currentMonthName:null,currentMonth:null,currentYear:null,headline:null,episodes:[],error:null,podcasterSlug:null}},created:function(){this.setNewDateVars()},mounted:function(){this.podcasterSlug=this.sanitizeTitle(this.pageValues.podcastertitle),this.getStats()},computed:{id:function(){return this.$store.state.form.current},pageValues:function(){return this.$store.getters["form/values"](this.id)}},watch:{currentDate:{immediate:!1,handler:function(t,e){this.getStats()}}},methods:{getStats:function(){var t=this;fetch("/api/podcaster/stats/"+this.podcasterSlug+"/year/"+this.currentYear+"/month/"+(this.currentMonth+1),{method:"GET",headers:{"X-CSRF":panel.csrf}}).then(function(t){if(200!==t.status)throw"You are tracking your downloads, using the file method. Stats are currently available only when using mysql";return t}).then(function(t){return t.json()}).then(function(e){t.episodes=t.computeStats(e.stats)}).catch(function(e){t.error=e,console.log(t.error)})},computeStats:function(t){return t.episodes.map(function(t){return{title:t.episode.replace(/-/g," "),downloads:t.downloaded}})},prevMonth:function(){var t=Xa(this.currentDate,1);this.currentDate=t,this.setNewDateVars()},nextMonth:function(){var t=na(this.currentDate,1);this.currentDate=t,this.setNewDateVars()},setNewDateVars:function(){this.currentMonth=cb(this.currentDate),this.currentYear=L(this.currentDate),this.currentMonthName=this.currentDate.toLocaleString("en",{month:"long"}),this.headline="Stats for "+this.currentMonthName+" "+this.currentYear},sanitizeTitle:function(t){return t.toLowerCase().replace(/e|é|è|ẽ|ẻ|ẹ|ê|ế|ề|ễ|ể|ệ/gi,"e").replace(/a|á|à|ã|ả|ạ|ă|ắ|ằ|ẵ|ẳ|ặ|â|ấ|ầ|ẫ|ẩ|ậ/gi,"a").replace(/o|ó|ò|õ|ỏ|ọ|ô|ố|ồ|ỗ|ổ|ộ|ơ|ớ|ờ|ỡ|ở|ợ/gi,"o").replace(/u|ú|ù|ũ|ủ|ụ|ư|ứ|ừ|ữ|ử|ự/gi,"u").replace(/đ/gi,"d").replace(/\s*$/g,"").replace(/\s+/g,"-")}}};if(typeof i==="function"){i=i.options}Object.assign(i,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("section",{staticClass:"k-modified-section"},[_c("div",{staticClass:"podcaster-prev-next"},[_c("button",{staticClass:"k-link k-button",on:{"click":_vm.prevMonth}},[_c("k-icon",{attrs:{"type":"angle-left"}})],1),_vm._v(" "),_c("button",{staticClass:"k-link k-button",on:{"click":_vm.nextMonth}},[_c("k-icon",{attrs:{"type":"angle-right"}})],1)]),_vm._v(" "),_c("k-text",[_vm._v(_vm._s(_vm.error))]),_vm._v(" "),_c("k-headline",[_vm._v(_vm._s(_vm.headline))]),_vm._v(" "),_c("table",{attrs:{"id":"episodeStats"}},_vm._l(_vm.episodes,function(episode){return _c("tr",[_c("td",[_vm._v(_vm._s(episode.downloads))]),_vm._v(" "),_c("td",[_vm._v(_vm._s(episode.title))])])}),0)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());function g(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function x(t){let e=t.getBoundingClientRect();return{top:e.top+(document.documentElement.scrollTop||document.body.scrollTop),left:e.left+(document.documentElement.scrollLeft||document.body.scrollLeft)}}function fb(t){var e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function Cb(t){var e=window.getComputedStyle(t),a=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight);return t.clientWidth-a}function Ha(t,e,a){var i=document.createEvent("HTMLEvents");for(var s in i.initEvent(e,!0,!0),a)i[s]=a[s];return t.dispatchEvent(i)}g.create=(t,e)=>{var a=document.createElement(t);for(var i in e){var s=e[i];if("inside"===i)g(s).appendChild(a);else if("around"===i){var r=g(s);r.parentNode.insertBefore(a,r),a.appendChild(r)}else"styles"===i?"object"==typeof s&&Object.keys(s).map(t=>{a.style[t]=s[t]}):i in a?a[i]=s:a.setAttribute(i,s)}return a};const Ma={margins:{top:10,bottom:10,left:20,right:20},paddings:{top:20,bottom:40,left:30,right:10},baseHeight:240,titleHeight:20,legendHeight:30,titleFontSize:12};function r(t){return t.titleHeight+t.margins.top+t.paddings.top}function D(t){return t.margins.left+t.paddings.left}function ra(t){return t.margins.top+t.margins.bottom+t.paddings.top+t.paddings.bottom+t.titleHeight+t.legendHeight}function E(t){return t.margins.left+t.margins.right+t.paddings.left+t.paddings.right}const lb=700,ob=400,wb=["line","bar"],qa=100,Nb=.5,Aa=.01,Ca=4,Ea=20,pa=2,N=5,o=10,Va=7,Wa=5,a=["light-blue","blue","violet","red","orange","yellow","green","light-green","purple","magenta","light-grey","dark-grey"],Ya=["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"],Za={bar:a,line:a,pie:a,percentage:a,heatmap:Ya,donut:a},ma=Math.PI/180,la=360;class ib{constructor({parent:t=null,colors:e=[]}){this.parent=t,this.colors=e,this.titleName="",this.titleValue="",this.listValues=[],this.titleValueFirst=0,this.x=0,this.y=0,this.top=0,this.left=0,this.setup()}setup(){this.makeTooltip()}refresh(){this.fill(),this.calcPosition()}makeTooltip(){this.container=g.create("div",{inside:this.parent,className:"graph-svg-tip comparison",innerHTML:"\n\t\t\t\t\n\t\t\t\t
"}),this.hideTip(),this.title=this.container.querySelector(".title"),this.dataPointList=this.container.querySelector(".data-point-list"),this.parent.addEventListener("mouseleave",()=>{this.hideTip()})}fill(){let t;this.index&&this.container.setAttribute("data-point-index",this.index),t=this.titleValueFirst?`${this.titleValue}${this.titleName}`:`${this.titleName}${this.titleValue}`,this.title.innerHTML=t,this.dataPointList.innerHTML="",this.listValues.map((t,e)=>{const a=this.colors[e]||"black";let i=0===t.formatted||t.formatted?t.formatted:t.value,s=g.create("li",{styles:{"border-top":`3px solid ${a}`},innerHTML:`${0===i||i?i:""}\n\t\t\t\t\t${t.title?t.title:""}`});this.dataPointList.appendChild(s)})}calcPosition(){let t=this.container.offsetWidth;this.top=this.y-this.container.offsetHeight-Wa,this.left=this.x-t/2;let e=this.parent.offsetWidth-t,a=this.container.querySelector(".svg-pointer");if(this.left<0)a.style.left=`calc(50% - ${-1*this.left}px)`,this.left=0;else if(this.left>e){let t=`calc(50% + ${this.left-e}px)`;a.style.left=t,this.left=e}else a.style.left="50%"}setValues(t,e,a={},i=[],s=-1){this.titleName=a.name,this.titleValue=a.value,this.listValues=i,this.x=t,this.y=e,this.titleValueFirst=a.valueFirst||0,this.index=s,this.refresh()}hideTip(){this.container.style.top="0px",this.container.style.left="0px",this.container.style.opacity="0"}showTip(){this.container.style.top=this.top+"px",this.container.style.left=this.left+"px",this.container.style.opacity="1"}}function X(t){return parseFloat(t.toFixed(2))}function P(t,e,a,i=!1){a||(a=i?t[0]:t[t.length-1]);let s=new Array(Math.abs(e)).fill(a);return t=i?s.concat(t):t.concat(s)}function aa(t,e){return(t+"").length*e}function w(t,e){return{x:Math.sin(t*ma)*e,y:Math.cos(t*ma)*e}}function Y(t,e){let a,i;return t<=e?(a=e-t,i=t):(a=t-e,i=e),[a,i]}function d(t,e,a=e.length-t.length){return a>0?t=P(t,a):e=P(e,a),[t,e]}const Ba={"light-blue":"#7cd6fd",blue:"#5e64ff",violet:"#743ee2",red:"#ff5858",orange:"#ffa00a",yellow:"#feef72",green:"#28a745","light-green":"#98d85b",purple:"#b554ff",magenta:"#ffa3ef",black:"#36114C",grey:"#bdd3e6","light-grey":"#f0f4f7","dark-grey":"#b8c2cc"};function U(t){return t>255?255:t<0?0:t}function T(t,e){let a=ca(t),i=!1;"#"==a[0]&&(a=a.slice(1),i=!0);let s=parseInt(a,16),r=U((s>>16)+e),n=U((s>>8&255)+e);return(i?"#":"")+(U((255&s)+e)|n<<8|r<<16).toString(16)}function Fa(t){return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)}const ca=t=>Ba[t]||t,n=6,j=4,c=10,l="#dadada",Q="#555b51";function ea(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function b(t,e){var a=document.createElementNS("http://www.w3.org/2000/svg",t);for(var i in e){var s=e[i];if("inside"===i)ea(s).appendChild(a);else if("around"===i){var r=ea(s);r.parentNode.insertBefore(a,r),a.appendChild(r)}else"styles"===i?"object"==typeof s&&Object.keys(s).map(t=>{a.style[t]=s[t]}):("className"===i&&(i="class"),"innerHTML"===i?a.textContent=s:a.setAttribute(i,s))}return a}function $a(t,e){return b("linearGradient",{inside:t,id:e,x1:0,x2:0,y1:0,y2:1})}function S(t,e,a,i){return b("stop",{inside:t,style:`stop-color: ${a}`,offset:e,"stop-opacity":i})}function db(t,e,a,i){return b("svg",{className:e,inside:t,width:a,height:i})}function eb(t){return b("defs",{inside:t})}function K(t,e="",a){let i={className:t,transform:e};return a&&(i.inside=a),b("g",i)}function I(t,e="",a="none",i="none",s=0){return b("path",{className:e,d:t,styles:{stroke:a,fill:i,"stroke-width":s}})}function jb(t,e,a,i,s=1,r=0){let[n,o]=[a.x+t.x,a.y+t.y],[$,l]=[a.x+e.x,a.y+e.y];return`M${a.x} ${a.y}\n\t\tL${n} ${o}\n\t\tA ${i} ${i} 0 ${r} ${s?1:0}\n\t\t${$} ${l} z`}function kb(t,e,a,i,s=1){let[r,n]=[a.x+t.x,a.y+t.y],[o,$]=[a.x+e.x,a.y+e.y];return`M${r} ${n}\n\t\tA ${i} ${i} 0 0 ${s?1:0}\n\t\t${o} ${$}`}function ua(t,e,a=!1){let i="path-fill-gradient-"+e+"-"+(a?"lighter":"default"),s=$a(t,i),r=[1,.6,.2];return a&&(r=[.4,.2,0]),S(s,"0%",e,r[0]),S(s,"50%",e,r[1]),S(s,"100%",e,r[2]),i}function nb(t,e,a,i,s=pa,r="none"){return b("rect",{className:"percentage-bar",x:t,y:e,width:a,height:i,fill:r,styles:{stroke:T(r,-25),"stroke-dasharray":`0, ${i+a}, ${a}, ${i}`,"stroke-width":s}})}function sa(t,e,a,i,s="none",r={}){let n={className:t,x:e,y:a,width:i,height:i,fill:s};return Object.keys(r).map(t=>{n[t]=r[t]}),b("rect",n)}function rb(t,e,a,i="none",s){let r={className:"legend-bar",x:0,y:0,width:a,height:"2px",fill:i},n=b("text",{className:"legend-dataset-text",x:0,y:0,dy:2*c+"px","font-size":1.2*c+"px","text-anchor":"start",fill:Q,innerHTML:s}),o=b("g",{transform:`translate(${t}, ${e})`});return o.appendChild(b("rect",r)),o.appendChild(n),o}function tb(t,e,a,i="none",s){let r={className:"legend-dot",cx:0,cy:0,r:a,fill:i},n=b("text",{className:"legend-dataset-text",x:0,y:0,dx:c+"px",dy:c/3+"px","font-size":1.2*c+"px","text-anchor":"start",fill:Q,innerHTML:s}),o=b("g",{transform:`translate(${t}, ${e})`});return o.appendChild(b("circle",r)),o.appendChild(n),o}function z(t,e,a,i,s={}){let r=s.fontSize||c;return b("text",{className:t,x:e,y:a,dy:(void 0!==s.dy?s.dy:r/2)+"px","font-size":r+"px",fill:s.fill||Q,"text-anchor":s.textAnchor||"start",innerHTML:i})}function yb(t,e,a,i,s={}){s.stroke||(s.stroke=l);let r=b("line",{className:"line-vertical "+s.className,x1:0,x2:0,y1:a,y2:i,styles:{stroke:s.stroke}}),n=b("text",{x:0,y:a>i?a+j:a-j-c,dy:c+"px","font-size":c+"px","text-anchor":"middle",innerHTML:e+""}),o=b("g",{transform:`translate(${t}, 0)`});return o.appendChild(r),o.appendChild(n),o}function fa(t,e,a,i,s={}){s.stroke||(s.stroke=l),s.lineType||(s.lineType="");let r=b("line",{className:"line-horizontal "+s.className+("dashed"===s.lineType?"dashed":""),x1:a,x2:i,y1:0,y2:0,styles:{stroke:s.stroke}}),n=b("text",{x:at[a]+","+e).join("L"),n=I("M"+r,"line-graph-path",a);if(i.heatline){let t=ua(s.svgDefs,a);n.style.stroke=`url(#${t})`}let o={path:n};if(i.regionFill){let e=ua(s.svgDefs,a,!0),i="M"+`${t[0]},${s.zeroLine}L`+r+`L${t.slice(-1)[0]},${s.zeroLine}`;o.region=I(i,"region-fill","none",`url(#${e})`)}return o}let ya={bar:t=>{let e;"rect"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);let a=t.cloneNode();return a.style.fill="#000000",a.style.opacity="0.4",e&&a.setAttribute("transform",e),a},dot:t=>{let e;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);let a=t.cloneNode(),i=t.getAttribute("r"),s=t.getAttribute("fill");return a.setAttribute("r",parseInt(i)+4),a.setAttribute("fill",s),a.style.opacity="0.6",e&&a.setAttribute("transform",e),a},heat_square:t=>{let e;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);let a=t.cloneNode(),i=t.getAttribute("r"),s=t.getAttribute("fill");return a.setAttribute("r",parseInt(i)+4),a.setAttribute("fill",s),a.style.opacity="0.6",e&&a.setAttribute("transform",e),a}},za={bar:(t,e)=>{let a;"rect"!==t.nodeName&&(a=t.getAttribute("transform"),t=t.childNodes[0]);let i=["x","y","width","height"];Object.values(t.attributes).filter(t=>i.includes(t.name)&&t.specified).map(t=>{e.setAttribute(t.name,t.nodeValue)}),a&&e.setAttribute("transform",a)},dot:(t,e)=>{let a;"circle"!==t.nodeName&&(a=t.getAttribute("transform"),t=t.childNodes[0]);let i=["cx","cy"];Object.values(t.attributes).filter(t=>i.includes(t.name)&&t.specified).map(t=>{e.setAttribute(t.name,t.nodeValue)}),a&&e.setAttribute("transform",a)},heat_square:(t,e)=>{let a;"circle"!==t.nodeName&&(a=t.getAttribute("transform"),t=t.childNodes[0]);let i=["cx","cy"];Object.values(t.attributes).filter(t=>i.includes(t.name)&&t.specified).map(t=>{e.setAttribute(t.name,t.nodeValue)}),a&&e.setAttribute("transform",a)}};const B=350,da=350,p=B,Da=250,h="easein";function u(t,e,a,i){let s="string"==typeof e?e:e.join(", ");return[t,{transform:a.join(", ")},i,h,"translate",{transform:s}]}function Ga(t,e,a){return u(t,[a,0],[e,0],p)}function $(t,e,a){return u(t,[0,a],[0,e],p)}function Ia(t,e,a,i){let s=e-a,r=t.childNodes[0],n=r.getAttribute("width");return[[r,{height:s,"stroke-dasharray":`${n}, ${s}`},p,h],u(t,[0,i],[0,a],p)]}function Ja(t,e,a,i,s=0,r={}){let[n,o]=Y(a,r.zeroLine);if(o-=s,"rect"!==t.nodeName){let a=[t.childNodes[0],{width:i,height:n},B,h],s=t.getAttribute("transform").split("(")[1].slice(0,-1);return[a,u(t,s,[e,o],p)]}return[[t,{width:i,height:n,x:e,y:o},B,h]]}function Ka(t,e,a){if("circle"!==t.nodeName){let i=t.getAttribute("transform").split("(")[1].slice(0,-1);return[u(t,i,[e,a],p)]}return[[t,{cx:e,cy:a},B,h]]}function La(t,e,a,i){let s=[],r=a.map((t,a)=>e[a]+","+t).join("L");const n=[t.path,{d:"M"+r},da,h];if(s.push(n),t.region){let a=`${e[0]},${i}L`,n=`L${e.slice(-1)[0]}, ${i}`;const o=[t.region,{d:"M"+a+r+n},da,h];s.push(o)}return s}function Z(t,e){return[t,{d:e},B,h]}const Na={ease:"0.25 0.1 0.25 1",linear:"0 0 1 1",easein:"0.1 0.8 0.2 1",easeout:"0 0 0.58 1",easeinout:"0.42 0 0.58 1"};function Oa(t,e,a,i="linear",s,r={}){let n=t.cloneNode(!0),o=t.cloneNode(!0);for(var $ in e){let u;u="transform"===$?document.createElementNS("http://www.w3.org/2000/svg","animateTransform"):document.createElementNS("http://www.w3.org/2000/svg","animate");let h=r[$]||t.getAttribute($),d=e[$],c={attributeName:$,from:h,to:d,begin:"0s",dur:a/1e3+"s",values:h+";"+d,keySplines:Na[i],keyTimes:"0;1",calcMode:"spline",fill:"freeze"};for(var l in s&&(c.type=s),c)u.setAttribute(l,c[l]);n.appendChild(u),s?o.setAttribute($,`translate(${d})`):o.setAttribute($,d)}return[n,o]}function F(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.mozTransform=e,t.style.oTransform=e}function Qa(t,e){let a=[],i=[];e.map(t=>{let e,s,r=t[0],n=r.parentNode;t[0]=r,[e,s]=Oa(...t),a.push(s),i.push([e,n]),n.replaceChild(e,r)});let s=t.cloneNode(!0);return i.map((t,i)=>{t[1].replaceChild(a[i],t[0]),e[i][0]=a[i]}),s}function Ra(t,e,a){if(0===a.length)return;let i=Qa(e,a);e.parentNode==t&&(t.removeChild(e),t.appendChild(i)),setTimeout(()=>{i.parentNode==t&&(t.removeChild(i),t.appendChild(e))},Da)}const Sa=".chart-container{position:relative;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Roboto','Oxygen','Ubuntu','Cantarell','Fira Sans','Droid Sans','Helvetica Neue',sans-serif}.chart-container .axis,.chart-container .chart-label{fill:#555b51}.chart-container .axis line,.chart-container .chart-label line{stroke:#dadada}.chart-container .dataset-units circle{stroke:#fff;stroke-width:2}.chart-container .dataset-units path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container .dataset-path{stroke-width:2px}.chart-container .path-group path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container line.dashed{stroke-dasharray:5,3}.chart-container .axis-line .specific-value{text-anchor:start}.chart-container .axis-line .y-line{text-anchor:end}.chart-container .axis-line .x-line{text-anchor:middle}.chart-container .legend-dataset-text{fill:#6c7680;font-weight:600}.graph-svg-tip{position:absolute;z-index:99999;padding:10px;font-size:12px;color:#959da5;text-align:center;background:rgba(0,0,0,.8);border-radius:3px}.graph-svg-tip ul{padding-left:0;display:flex}.graph-svg-tip ol{padding-left:0;display:flex}.graph-svg-tip ul.data-point-list li{min-width:90px;flex:1;font-weight:600}.graph-svg-tip strong{color:#dfe2e5;font-weight:600}.graph-svg-tip .svg-pointer{position:absolute;height:5px;margin:0 0 0 -5px;content:' ';border:5px solid transparent;border-top-color:rgba(0,0,0,.8)}.graph-svg-tip.comparison{padding:0;text-align:left;pointer-events:none}.graph-svg-tip.comparison .title{display:block;padding:10px;margin:0;font-weight:600;line-height:1;pointer-events:none}.graph-svg-tip.comparison ul{margin:0;white-space:nowrap;list-style:none}.graph-svg-tip.comparison li{display:inline-block;padding:5px 10px}";function Ta(t,e){var a=document.createElement("a");a.style="display: none";var i=new Blob(e,{type:"image/svg+xml; charset=utf-8"}),s=window.URL.createObjectURL(i);a.href=s,a.download=t,document.body.appendChild(a),a.click(),setTimeout(function(){document.body.removeChild(a),window.URL.revokeObjectURL(s)},300)}function Ua(t){let e=t.cloneNode(!0);e.classList.add("chart-container"),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");let a=g.create("style",{innerHTML:Sa});e.insertBefore(a,e.firstChild);let i=g.create("div");return i.appendChild(e),i.innerHTML}let ja;class W{constructor(t,e){if(this.parent="string"==typeof t?document.querySelector(t):t,!(this.parent instanceof HTMLElement))throw new Error("No `parent` element to render on was provided.");this.rawChartArgs=e,this.title=e.title||"",this.type=e.type||"",this.realData=this.prepareData(e.data),this.data=this.prepareFirstData(this.realData),this.colors=this.validateColors(e.colors,this.type),this.config={showTooltip:1,showLegend:1,isNavigable:e.isNavigable||0,animate:1},this.measures=JSON.parse(JSON.stringify(Ma));let a=this.measures;this.setMeasures(e),this.title.length||(a.titleHeight=0),this.config.showLegend||(a.legendHeight=0),this.argHeight=e.height||a.baseHeight,this.state={},this.options={},this.initTimeout=lb,this.config.isNavigable&&(this.overlays=[]),this.configure(e)}prepareData(t){return t}prepareFirstData(t){return t}validateColors(t,e){const a=[];return(t=(t||[]).concat(Za[e])).forEach(t=>{const e=ca(t);Fa(e)?a.push(e):console.warn("\""+t+"\" is not a valid color.")}),a}setMeasures(){}configure(){let t=this.argHeight;this.baseHeight=t,this.height=t-ra(this.measures),ja=this.boundDrawFn.bind(this),window.addEventListener("resize",ja),window.addEventListener("orientationchange",this.boundDrawFn.bind(this))}boundDrawFn(){this.draw(!0)}unbindWindowEvents(){window.removeEventListener("resize",ja),window.removeEventListener("orientationchange",this.boundDrawFn.bind(this))}setup(){this.makeContainer(),this.updateWidth(),this.makeTooltip(),this.draw(!1,!0)}makeContainer(){this.parent.innerHTML="";let t={inside:this.parent,className:"chart-container"};this.independentWidth&&(t.styles={width:this.independentWidth+"px"}),this.container=g.create("div",t)}makeTooltip(){this.tip=new ib({parent:this.container,colors:this.colors}),this.bindTooltip()}bindTooltip(){}draw(t=!1,e=!1){this.updateWidth(),this.calc(t),this.makeChartArea(),this.setupComponents(),this.components.forEach(t=>t.setup(this.drawArea)),this.render(this.components,!1),e&&(this.data=this.realData,setTimeout(()=>{this.update(this.data)},this.initTimeout)),this.renderLegend(),this.setupNavigation(e)}calc(){}updateWidth(){this.baseWidth=Cb(this.parent),this.width=this.baseWidth-E(this.measures)}makeChartArea(){this.svg&&this.container.removeChild(this.svg);let t=this.measures;this.svg=db(this.container,"frappe-chart chart",this.baseWidth,this.baseHeight),this.svgDefs=eb(this.svg),this.title.length&&(this.titleEL=z("title",t.margins.left,t.margins.top,this.title,{fontSize:t.titleFontSize,fill:"#666666",dy:t.titleFontSize}));let e=r(t);this.drawArea=K(this.type+"-chart chart-draw-area",`translate(${D(t)}, ${e})`),this.config.showLegend&&(e+=this.height+t.paddings.bottom,this.legendArea=K("chart-legend",`translate(${D(t)}, ${e})`)),this.title.length&&this.svg.appendChild(this.titleEL),this.svg.appendChild(this.drawArea),this.config.showLegend&&this.svg.appendChild(this.legendArea),this.updateTipOffset(D(t),r(t))}updateTipOffset(t,e){this.tip.offset={x:t,y:e}}setupComponents(){this.components=new Map}update(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.calc(),this.render()}render(t=this.components,e=!0){this.config.isNavigable&&this.overlays.map(t=>t.parentNode.removeChild(t));let a=[];t.forEach(t=>{a=a.concat(t.update(e))}),a.length>0?(Ra(this.container,this.svg,a),setTimeout(()=>{t.forEach(t=>t.make()),this.updateNav()},ob)):(t.forEach(t=>t.make()),this.updateNav())}updateNav(){this.config.isNavigable&&(this.makeOverlay(),this.bindUnits())}renderLegend(){}setupNavigation(t=!1){this.config.isNavigable&&t&&(this.bindOverlay(),this.keyActions={13:this.onEnterKey.bind(this),37:this.onLeftArrow.bind(this),38:this.onUpArrow.bind(this),39:this.onRightArrow.bind(this),40:this.onDownArrow.bind(this)},document.addEventListener("keydown",t=>{fb(this.container)&&(t=t||window.event,this.keyActions[t.keyCode]&&this.keyActions[t.keyCode]())}))}makeOverlay(){}updateOverlay(){}bindOverlay(){}bindUnits(){}onLeftArrow(){}onRightArrow(){}onUpArrow(){}onDownArrow(){}onEnterKey(){}addDataPoint(){}removeDataPoint(){}getDataPoint(){}setCurrentDataPoint(){}updateDataset(){}export(){let t=Ua(this.svg);Ta(this.title||"Chart",[t])}}class V extends W{constructor(t,e){super(t,e)}configure(t){super.configure(t),this.config.maxSlices=t.maxSlices||20,this.config.maxLegendPoints=t.maxLegendPoints||20}calc(){let t=this.state,e=this.config.maxSlices;t.sliceTotals=[];let a=this.data.labels.map((t,e)=>{let a=0;return this.data.datasets.map(t=>{a+=t.values[e]}),[a,t]}).filter(t=>t[0]>=0),i=a;if(a.length>e){a.sort((t,e)=>e[0]-t[0]),i=a.slice(0,e-1);let t=a.slice(e-1),s=0;t.map(t=>{s+=t[0]}),i.push([s,"Rest"]),this.colors[e-1]="grey"}t.labels=[],i.map(e=>{t.sliceTotals.push(e[0]),t.labels.push(e[1])}),t.grandTotal=t.sliceTotals.reduce((t,e)=>t+e,0),this.center={x:this.width/2,y:this.height/2}}renderLegend(){let t=this.state;this.legendArea.textContent="",this.legendTotals=t.sliceTotals.slice(0,this.config.maxLegendPoints);let e=0,a=0;this.legendTotals.map((i,s)=>{let r=Math.floor((this.width-E(this.measures))/110);e>r&&(e=0,a+=20);let n=tb(110*e+5,a,5,this.colors[s],`${t.labels[s]}: ${i}`);this.legendArea.appendChild(n),e++})}}const _=12,C=7,ba=1e3,_a=86400,ab=["January","February","March","April","May","June","July","August","September","October","November","December"],bb=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function xa(t){let e=new Date(t);return e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),e}function R(t){let e=t.getDate(),a=t.getMonth()+1;return[t.getFullYear(),(a>9?"":"0")+a,(e>9?"":"0")+e].join("-")}function k(t){return new Date(t.getTime())}function O(t,e){let a=ia(t);return Math.ceil(gb(a,e)/C)}function gb(t,e){let a=_a*ba;return(xa(e)-xa(t))/a}function hb(t,e){return t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}function ga(t,e=!1){let a=ab[t];return e?a.slice(0,3):a}function ha(t,e){return new Date(e,t+1,0)}function ia(t){let e=k(t);const a=e.getDay();return 0!==a&&m(e,-1*a),e}function m(t,e){t.setDate(t.getDate()+e)}class mb{constructor({layerClass:t="",layerTransform:e="",constants:a,getData:i,makeElements:s,animateElements:r}){this.layerTransform=e,this.constants=a,this.makeElements=s,this.getData=i,this.animateElements=r,this.store=[],this.labels=[],this.layerClass=t,this.layerClass="function"==typeof this.layerClass?this.layerClass():this.layerClass,this.refresh()}refresh(t){this.data=t||this.getData()}setup(t){this.layer=K(this.layerClass,this.layerTransform,t)}make(){this.render(this.data),this.oldData=this.data}render(t){this.store=this.makeElements(t),this.layer.textContent="",this.store.forEach(t=>{this.layer.appendChild(t)}),this.labels.forEach(t=>{this.layer.appendChild(t)})}update(t=!0){this.refresh();let e=[];return t&&(e=this.animateElements(this.data)||[]),e}}let ka={donutSlices:{layerClass:"donut-slices",makeElements:t=>t.sliceStrings.map((e,a)=>{let i=I(e,"donut-path",t.colors[a],"none",t.strokeWidth);return i.style.transition="transform .3s;",i}),animateElements(t){return this.store.map((e,a)=>Z(e,t.sliceStrings[a]))}},pieSlices:{layerClass:"pie-slices",makeElements:t=>t.sliceStrings.map((e,a)=>{let i=I(e,"pie-path","none",t.colors[a]);return i.style.transition="transform .3s;",i}),animateElements(t){return this.store.map((e,a)=>Z(e,t.sliceStrings[a]))}},percentageBars:{layerClass:"percentage-bars",makeElements(t){return t.xPositions.map((e,a)=>{return nb(e,0,t.widths[a],this.constants.barHeight,this.constants.barDepth,t.colors[a])})},animateElements(t){if(t)return[]}},yAxis:{layerClass:"y axis",makeElements(t){return t.positions.map((e,a)=>Db(e,t.labels[a],this.constants.width,{mode:this.constants.mode,pos:this.constants.pos}))},animateElements(t){let e=t.positions,a=t.labels,i=this.oldData.positions,s=this.oldData.labels;return[i,e]=d(i,e),[s,a]=d(s,a),this.render({positions:i,labels:a}),this.store.map((t,a)=>$(t,e[a],i[a]))}},xAxis:{layerClass:"x axis",makeElements(t){return t.positions.map((e,a)=>Ib(e,t.calcLabels[a],this.constants.height,{mode:this.constants.mode,pos:this.constants.pos}))},animateElements(t){let e=t.positions,a=t.calcLabels,i=this.oldData.positions,s=this.oldData.calcLabels;return[i,e]=d(i,e),[s,a]=d(s,a),this.render({positions:i,calcLabels:a}),this.store.map((t,a)=>Ga(t,e[a],i[a]))}},yMarkers:{layerClass:"y-markers",makeElements(t){return t.map(t=>Kb(t.position,t.label,this.constants.width,{labelPos:t.options.labelPos,mode:"span",lineType:"dashed"}))},animateElements(t){[this.oldData,t]=d(this.oldData,t);let e=t.map(t=>t.position),a=t.map(t=>t.label),i=t.map(t=>t.options),s=this.oldData.map(t=>t.position);return this.render(s.map((t,e)=>({position:s[e],label:a[e],options:i[e]}))),this.store.map((t,a)=>$(t,e[a],s[a]))}},yRegions:{layerClass:"y-regions",makeElements(t){return t.map(t=>Mb(t.startPos,t.endPos,this.constants.width,t.label,{labelPos:t.options.labelPos}))},animateElements(t){[this.oldData,t]=d(this.oldData,t);let e=t.map(t=>t.endPos),a=t.map(t=>t.label),i=t.map(t=>t.startPos),s=t.map(t=>t.options),r=this.oldData.map(t=>t.endPos),n=this.oldData.map(t=>t.startPos);this.render(r.map((t,e)=>({startPos:n[e],endPos:r[e],label:a[e],options:s[e]})));let o=[];return this.store.map((t,a)=>{o=o.concat(Ia(t,i[a],e[a],r[a]))}),o}},heatDomain:{layerClass:function(){return"heat-domain domain-"+this.constants.index},makeElements(t){let{index:e,colWidth:a,rowHeight:i,squareSize:s,xTranslate:r}=this.constants,n=r,o=0;return this.serializedSubDomains=[],t.cols.map((t,r)=>{1===r&&this.labels.push(z("domain-name",n,-12,ga(e,!0).toUpperCase(),{fontSize:9})),t.map((t,e)=>{if(t.fill){let a={"data-date":t.yyyyMmDd,"data-value":t.dataValue,"data-day":e},i=sa("day",n,o,s,t.fill,a);this.serializedSubDomains.push(i)}o+=i}),o=0,n+=a}),this.serializedSubDomains},animateElements(t){if(t)return[]}},barGraph:{layerClass:function(){return"dataset-units dataset-bars dataset-"+this.constants.index},makeElements(t){let e=this.constants;return this.unitType="bar",this.units=t.yPositions.map((a,i)=>Qb(t.xPositions[i],a,t.barWidth,e.color,t.labels[i],i,t.offsets[i],{zeroLine:t.zeroLine,barsWidth:t.barsWidth,minHeight:e.minHeight})),this.units},animateElements(t){let e=t.xPositions,a=t.yPositions,i=t.offsets,s=t.labels,r=this.oldData.xPositions,n=this.oldData.yPositions,o=this.oldData.offsets,$=this.oldData.labels;[r,e]=d(r,e),[n,a]=d(n,a),[o,i]=d(o,i),[$,s]=d($,s),this.render({xPositions:r,yPositions:n,offsets:o,labels:s,zeroLine:this.oldData.zeroLine,barsWidth:this.oldData.barsWidth,barWidth:this.oldData.barWidth});let l=[];return this.store.map((s,r)=>{l=l.concat(Ja(s,e[r],a[r],t.barWidth,i[r],{zeroLine:t.zeroLine}))}),l}},lineGraph:{layerClass:function(){return"dataset-units dataset-line dataset-"+this.constants.index},makeElements(t){let e=this.constants;return this.unitType="dot",this.paths={},e.hideLine||(this.paths=Pb(t.xPositions,t.yPositions,e.color,{heatline:e.heatline,regionFill:e.regionFill},{svgDefs:e.svgDefs,zeroLine:t.zeroLine})),this.units=[],e.hideDots||(this.units=t.yPositions.map((a,i)=>Ob(t.xPositions[i],a,t.radius,e.color,e.valuesOverPoints?t.values[i]:"",i))),Object.values(this.paths).concat(this.units)},animateElements(t){let e=t.xPositions,a=t.yPositions,i=t.values,s=this.oldData.xPositions,r=this.oldData.yPositions,n=this.oldData.values;[s,e]=d(s,e),[r,a]=d(r,a),[n,i]=d(n,i),this.render({xPositions:s,yPositions:r,values:i,zeroLine:this.oldData.zeroLine,radius:this.oldData.radius});let o=[];return Object.keys(this.paths).length&&(o=o.concat(La(this.paths,e,a,t.zeroLine))),this.units.length&&this.units.map((t,i)=>{o=o.concat(Ka(t,e[i],a[i]))}),o}}};function v(t,e,a){let i=Object.keys(ka).filter(e=>t.includes(e)),s=ka[i[0]];return Object.assign(s,{constants:e,getData:a}),new mb(s)}class pb extends V{constructor(t,e){super(t,e),this.type="percentage",this.setup()}setMeasures(t){let e=this.measures;this.barOptions=t.barOptions||{};let a=this.barOptions;a.height=a.height||Ea,a.depth=a.depth||pa,e.paddings.right=30,e.legendHeight=80,e.baseHeight=8*(a.height+.5*a.depth)}setupComponents(){let t=this.state,e=[["percentageBars",{barHeight:this.barOptions.height,barDepth:this.barOptions.depth},function(){return{xPositions:t.xPositions,widths:t.widths,colors:this.colors}}.bind(this)]];this.components=new Map(e.map(t=>{let e=v(...t);return[t[0],e]}))}calc(){super.calc();let t=this.state;t.xPositions=[],t.widths=[];let e=0;t.sliceTotals.map(a=>{let i=this.width*a/t.grandTotal;t.widths.push(i),t.xPositions.push(e),e+=i})}makeDataByIndex(){}bindTooltip(){let t=this.state;this.container.addEventListener("mousemove",e=>{let a=this.components.get("percentageBars").store,i=e.target;if(a.includes(i)){let e=a.indexOf(i),s=x(this.container),r=x(i),n=r.left-s.left+parseInt(i.getAttribute("width"))/2,o=r.top-s.top,$=(this.formattedLabels&&this.formattedLabels.length>0?this.formattedLabels[e]:this.state.labels[e])+": ",l=t.sliceTotals[e]/t.grandTotal;this.tip.setValues(n,o,{name:$,value:(100*l).toFixed(1)+"%"}),this.tip.showTip()}})}}class qb extends V{constructor(t,e){super(t,e),this.type="pie",this.initTimeout=0,this.init=1,this.setup()}configure(t){super.configure(t),this.mouseMove=this.mouseMove.bind(this),this.mouseLeave=this.mouseLeave.bind(this),this.hoverRadio=t.hoverRadio||.1,this.config.startAngle=t.startAngle||0,this.clockWise=t.clockWise||!1}calc(){super.calc();let t=this.state;this.radius=this.height>this.width?this.center.x:this.center.y;const{radius:e,clockWise:a}=this,i=t.slicesProperties||[];t.sliceStrings=[],t.slicesProperties=[];let s=180-this.config.startAngle;t.sliceTotals.map((r,n)=>{const o=s,$=r/t.grandTotal*la;let l=0;$>180&&(l=1);const u=a?-$:$,h=s+=u,d=w(o,e),c=w(h,e),p=this.init&&i[n];let S,v;this.init?(S=p?p.startPosition:d,v=p?p.endPosition:d):(S=d,v=c);const P=jb(S,v,this.center,this.radius,a,l);t.sliceStrings.push(P),t.slicesProperties.push({startPosition:d,endPosition:c,value:r,total:t.grandTotal,startAngle:o,endAngle:h,angle:u})}),this.init=0}setupComponents(){let t=this.state,e=[["pieSlices",{},function(){return{sliceStrings:t.sliceStrings,colors:this.colors}}.bind(this)]];this.components=new Map(e.map(t=>{let e=v(...t);return[t[0],e]}))}calTranslateByAngle(t){const{radius:e,hoverRadio:a}=this,i=w(t.startAngle+t.angle/2,e);return`translate3d(${i.x*a}px,${i.y*a}px,0)`}hoverSlice(t,e,a,i){if(!t)return;const s=this.colors[e];if(a){F(t,this.calTranslateByAngle(this.state.slicesProperties[e])),t.style.fill=T(s,50);let a=x(this.svg),r=i.pageX-a.left+10,n=i.pageY-a.top-10,o=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[e]:this.state.labels[e])+": ",$=(100*this.state.sliceTotals[e]/this.state.grandTotal).toFixed(1);this.tip.setValues(r,n,{name:o,value:$+"%"}),this.tip.showTip()}else F(t,"translate3d(0,0,0)"),this.tip.hideTip(),t.style.fill=s}bindTooltip(){this.container.addEventListener("mousemove",this.mouseMove),this.container.addEventListener("mouseleave",this.mouseLeave)}mouseMove(t){const e=t.target;let a=this.components.get("pieSlices").store,i=this.curActiveSliceIndex,s=this.curActiveSlice;if(a.includes(e)){let r=a.indexOf(e);this.hoverSlice(s,i,!1),this.curActiveSlice=e,this.curActiveSliceIndex=r,this.hoverSlice(e,r,!0,t)}else this.mouseLeave()}mouseLeave(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)}}function A(t){if(0===t)return[0,0];if(isNaN(t))return{mantissa:-6755399441055744,exponent:972};var e=t>0?1:-1;if(!isFinite(t))return{mantissa:4503599627370496*e,exponent:972};t=Math.abs(t);var a=Math.floor(Math.log10(t));return[e*(t/Math.pow(10,a)),a]}function sb(t,e=0){let a=Math.ceil(t),i=Math.floor(e),s=a-i,r=s,n=1;s>5&&(s%2!=0&&(s=++a-i),r=s/2,n=2),s<=2&&(n=s/(r=4)),0===s&&(r=5,n=1);let o=[];for(var $=0;$<=r;$++)o.push(i+n*$);return o}function y(t,e=0){let[a,i]=A(t),s=e?e/Math.pow(10,i):0,r=sb(a=a.toFixed(6),s);return r=r.map(t=>t*Math.pow(10,i))}function ub(t,e=!1){let a=Math.max(...t),i=Math.min(...t),s=0,r=[];function n(t,e){let a=y(t),i=a[1]-a[0],s=0;for(var r=1;s=0&&i>=0)s=A(a)[1],r=e?y(a,i):y(a);else if(a>0&&i<0){let t=Math.abs(i);if(a>=t)s=A(a)[1],r=n(a,t);else{s=A(t)[1],r=n(t,a).map(t=>-1*t)}}else if(a<=0&&i<=0){let t=Math.abs(i),n=Math.abs(a);s=A(t)[1],r=(r=e?y(t,n):y(t)).reverse().map(t=>-1*t)}return r}function vb(t){let e,a=oa(t);if(t.indexOf(0)>=0)e=t.indexOf(0);else if(t[0]>0){e=-1*t[0]/a}else{e=-1*t[t.length-1]/a+(t.length-1)}return e}function oa(t){return t[1]-t[0]}function xb(t){return t[t.length-1]-t[0]}function s(t,e){return X(e.zeroLine-t*e.scaleMultiplier)}function zb(t,e,a=!1){let i=e.reduce(function(e,a){return Math.abs(a-t)et.end)throw new Error("Start date cannot be greater than end date.");if(t.start||(t.start=new Date,t.start.setFullYear(t.start.getFullYear()-1)),t.end||(t.end=new Date),t.dataPoints=t.dataPoints||{},parseInt(Object.keys(t.dataPoints)[0])>1e5){let e={};Object.keys(t.dataPoints).forEach(a=>{let i=new Date(a*ba);e[R(i)]=t.dataPoints[a]}),t.dataPoints=e}return t}calc(){let t=this.state;t.start=k(this.data.start),t.end=k(this.data.end),t.firstWeekStart=k(t.start),t.noOfWeeks=O(t.start,t.end),t.distribution=Ab(Object.values(this.data.dataPoints),N),t.domainConfigs=this.getDomains()}setupComponents(){let t=this.state,e=this.discreteDomains?0:1,a=t.domainConfigs.map((a,i)=>["heatDomain",{index:a.index,colWidth:f,rowHeight:q,squareSize:o,xTranslate:t.domainConfigs.filter((t,e)=>et.cols.length-e).reduce((t,e)=>t+e,0)*f},function(){return t.domainConfigs[i]}.bind(this)]);this.components=new Map(a.map((t,e)=>{let a=v(...t);return[t[0]+"-"+e,a]}));let i=0;bb.forEach((t,e)=>{if([1,3,5].includes(e)){let e=z("subdomain-name",-f/2,i,t,{fontSize:o,dy:8,textAnchor:"end"});this.drawArea.appendChild(e)}i+=q})}update(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.draw(),this.bindTooltip()}bindTooltip(){this.container.addEventListener("mousemove",t=>{this.components.forEach(e=>{let a=e.store,i=t.target;if(a.includes(i)){let e=i.getAttribute("data-value"),a=i.getAttribute("data-date").split("-"),s=ga(parseInt(a[1])-1,!0),r=this.container.getBoundingClientRect(),n=i.getBoundingClientRect(),o=parseInt(t.target.getAttribute("width")),$=n.left-r.left+o/2,l=n.top-r.top,u=e+" "+this.countLabel,h=" on "+s+" "+a[0]+", "+a[2];this.tip.setValues($,l,{name:h,value:u,valueFirst:1},[]),this.tip.showTip()}})})}renderLegend(){this.legendArea.textContent="";let t=0,e=q,a=z("subdomain-name",t,e,"Less",{fontSize:o+1,dy:9});t=2*f+f/2,this.legendArea.appendChild(a),this.colors.slice(0,N).map((a,i)=>{const s=sa("heatmap-legend-unit",t+(f+3)*i,e,o,a);this.legendArea.appendChild(s)});let i=z("subdomain-name",t+N*(f+3)+f/4,e,"More",{fontSize:o+1,dy:9});this.legendArea.appendChild(i)}getDomains(){let t=this.state;const[e,a]=[t.start.getMonth(),t.start.getFullYear()],[i,s]=[t.end.getMonth(),t.end.getFullYear()],r=i-e+1+12*(s-a);let n=[],o=k(t.start);for(var $=0;$=i.start&&s<=i.end;a||s.getMonth()!==e||!n?t.yyyyMmDd=R(s):t=this.getSubDomainConfig(s),r.push(t)}return r}getSubDomainConfig(t){let e=R(t),a=this.data.dataPoints[e];return{yyyyMmDd:e,dataValue:a||0,fill:this.colors[Bb(a,this.state.distribution)]}}}function Fb(t,e){t.labels=t.labels||[];let a=t.labels.length,i=t.datasets,s=new Array(a).fill(0);return i||(i=[{values:s}]),i.map(t=>{if(t.values){let e=t.values;e=(e=e.map(t=>isNaN(t)?0:t)).length>a?e.slice(0,a):P(e,a-e.length,0)}else t.values=s;t.chartType||(wb.includes(e),t.chartType=e)}),t.yRegions&&t.yRegions.map(t=>{t.end({name:"",values:a.slice(0,-1),chartType:t.chartType}))};return t.yMarkers&&(i.yMarkers=[{value:0,label:""}]),t.yRegions&&(i.yRegions=[{start:0,end:0,label:""}]),i}function Hb(t,e=[],a=!0){let i=t/e.length;i<=0&&(i=1);let s=i/Va;return e.map((t,e)=>{if((t+="").length>s)if(a){e%Math.ceil(t.length/s)!=0&&(t="")}else t=s-3>0?t.slice(0,s-3)+" ...":t.slice(0,s)+"..";return t})}class M extends W{constructor(t,e){super(t,e),this.barOptions=e.barOptions||{},this.lineOptions=e.lineOptions||{},this.type=e.type||"line",this.init=1,this.setup()}setMeasures(){this.data.datasets.length<=1&&(this.config.showLegend=0,this.measures.paddings.bottom=30)}configure(t){super.configure(t),t.axisOptions=t.axisOptions||{},t.tooltipOptions=t.tooltipOptions||{},this.config.xAxisMode=t.axisOptions.xAxisMode||"span",this.config.yAxisMode=t.axisOptions.yAxisMode||"span",this.config.xIsSeries=t.axisOptions.xIsSeries||0,this.config.formatTooltipX=t.tooltipOptions.formatTooltipX,this.config.formatTooltipY=t.tooltipOptions.formatTooltipY,this.config.valuesOverPoints=t.valuesOverPoints}prepareData(t=this.data){return Fb(t,this.type)}prepareFirstData(t=this.data){return Gb(t)}calc(t=!1){this.calcXPositions(),t||this.calcYAxisParameters(this.getAllYValues(),"line"===this.type),this.makeDataByIndex()}calcXPositions(){let t=this.state,e=this.data.labels;t.datasetLength=e.length,t.unitWidth=this.width/t.datasetLength,t.xOffset=t.unitWidth/2,t.xAxis={labels:e,positions:e.map((e,a)=>X(t.xOffset+a*t.unitWidth))}}calcYAxisParameters(t,e="false"){const a=ub(t,e),i=this.height/xb(a),s=oa(a)*i,r=this.height-vb(a)*s;this.state.yAxis={labels:a,positions:a.map(t=>r-t*i),scaleMultiplier:i,zeroLine:r},this.calcDatasetPoints(),this.calcYExtremes(),this.calcYRegions()}calcDatasetPoints(){let t=this.state,e=e=>e.map(e=>s(e,t.yAxis));t.datasets=this.data.datasets.map((t,a)=>{let i=t.values,s=t.cumulativeYs||[];return{name:t.name,index:a,chartType:t.chartType,values:i,yPositions:e(i),cumulativeYs:s,cumulativeYPos:e(s)}})}calcYExtremes(){let t=this.state;this.barOptions.stacked?t.yExtremes=t.datasets[t.datasets.length-1].cumulativeYPos:(t.yExtremes=new Array(t.datasetLength).fill(9999),t.datasets.map(e=>{e.yPositions.map((e,a)=>{e(e.position=s(e.value,t.yAxis),e.options||(e.options={}),e))),this.data.yRegions&&(this.state.yRegions=this.data.yRegions.map(e=>(e.startPos=s(e.start,t.yAxis),e.endPos=s(e.end,t.yAxis),e.options||(e.options={}),e)))}getAllYValues(){let t="values";if(this.barOptions.stacked){t="cumulativeYs";let e=new Array(this.state.datasetLength).fill(0);this.data.datasets.map((a,i)=>{let s=this.data.datasets[i].values;a[t]=e=e.map((t,e)=>t+s[e])})}let e=this.data.datasets.map(e=>e[t]);return this.data.yMarkers&&e.push(this.data.yMarkers.map(t=>t.value)),this.data.yRegions&&this.data.yRegions.map(t=>{e.push([t.end,t.start])}),[].concat(...e)}setupComponents(){let t=[["yAxis",{mode:this.config.yAxisMode,width:this.width},function(){return this.state.yAxis}.bind(this)],["xAxis",{mode:this.config.xAxisMode,height:this.height},function(){let t=this.state;return t.xAxis.calcLabels=Hb(this.width,t.xAxis.labels,this.config.xIsSeries),t.xAxis}.bind(this)],["yRegions",{width:this.width,pos:"right"},function(){return this.state.yRegions}.bind(this)]],e=this.state.datasets.filter(t=>"bar"===t.chartType),a=this.state.datasets.filter(t=>"line"===t.chartType),i=e.map(t=>{let a=t.index;return["barGraph-"+t.index,{index:a,color:this.colors[a],stacked:this.barOptions.stacked,valuesOverPoints:this.config.valuesOverPoints,minHeight:this.height*Aa},function(){let t=this.state,i=t.datasets[a],s=this.barOptions.stacked,r=this.barOptions.spaceRatio||Nb,n=t.unitWidth*(1-r),o=n/(s?1:e.length),$=t.xAxis.positions.map(t=>t-n/2);s||($=$.map(t=>t+o*a));let l=new Array(t.datasetLength).fill("");this.config.valuesOverPoints&&(l=s&&i.index===t.datasets.length-1?i.cumulativeYs:i.values);let u=new Array(t.datasetLength).fill(0);return s&&(u=i.yPositions.map((t,e)=>t-i.cumulativeYPos[e])),{xPositions:$,yPositions:i.yPositions,offsets:u,labels:l,zeroLine:t.yAxis.zeroLine,barsWidth:n,barWidth:o}}.bind(this)]}),s=a.map(t=>{let e=t.index;return["lineGraph-"+t.index,{index:e,color:this.colors[e],svgDefs:this.svgDefs,heatline:this.lineOptions.heatline,regionFill:this.lineOptions.regionFill,hideDots:this.lineOptions.hideDots,hideLine:this.lineOptions.hideLine,valuesOverPoints:this.config.valuesOverPoints},function(){let t=this.state,a=t.datasets[e],i=t.yAxis.positions[0]!n.includes(t[0])||this.state[t[0]]).map(t=>{let e=v(...t);return(t[0].includes("lineGraph")||t[0].includes("barGraph"))&&this.dataUnitComponents.push(e),[t[0],e]}))}makeDataByIndex(){this.dataByIndex={};let t=this.state,e=this.config.formatTooltipX,a=this.config.formatTooltipY;t.xAxis.labels.map((i,s)=>{let r=this.state.datasets.map((t,e)=>{let i=t.values[s];return{title:t.name,value:i,yPos:t.yPositions[s],color:this.colors[e],formatted:a?a(i):i}});this.dataByIndex[s]={label:i,formattedLabel:e?e(i):i,xPos:t.xAxis.positions[s],values:r,yExtreme:t.yExtremes[s]}})}bindTooltip(){this.container.addEventListener("mousemove",t=>{let e=this.measures,a=x(this.container),i=t.pageX-a.left-D(e),s=t.pageY-a.top;sr(e)?this.mapTooltipXPosition(i):this.tip.hideTip()})}mapTooltipXPosition(t){let e=this.state;if(!e.yExtremes)return;let a=zb(t,e.xAxis.positions,!0),i=this.dataByIndex[a];this.tip.setValues(i.xPos+this.tip.offset.x,i.yExtreme+this.tip.offset.y,{name:i.formattedLabel,value:""},i.values,a),this.tip.showTip()}renderLegend(){let t=this.data;t.datasets.length>1&&(this.legendArea.textContent="",t.datasets.map((t,e)=>{let a=rb(qa*e,"0",qa,this.colors[e],t.name);this.legendArea.appendChild(a)}))}makeOverlay(){this.init?this.init=0:(this.overlayGuides&&this.overlayGuides.forEach(t=>{let e=t.overlay;e.parentNode.removeChild(e)}),this.overlayGuides=this.dataUnitComponents.map(t=>({type:t.unitType,overlay:void 0,units:t.units})),void 0===this.state.currentIndex&&(this.state.currentIndex=this.state.datasetLength-1),this.overlayGuides.map(t=>{let e=t.units[this.state.currentIndex];t.overlay=ya[t.type](e),this.drawArea.appendChild(t.overlay)}))}updateOverlayGuides(){this.overlayGuides&&this.overlayGuides.forEach(t=>{let e=t.overlay;e.parentNode.removeChild(e)})}bindOverlay(){this.parent.addEventListener("data-select",()=>{this.updateOverlay()})}bindUnits(){this.dataUnitComponents.map(t=>{t.units.map(t=>{t.addEventListener("click",()=>{let e=t.getAttribute("data-point-index");this.setCurrentDataPoint(e)})})}),this.tip.container.addEventListener("click",()=>{let t=this.tip.container.getAttribute("data-point-index");this.setCurrentDataPoint(t)})}updateOverlay(){this.overlayGuides.map(t=>{let e=t.units[this.state.currentIndex];za[t.type](e,t.overlay)})}onLeftArrow(){this.setCurrentDataPoint(this.state.currentIndex-1)}onRightArrow(){this.setCurrentDataPoint(this.state.currentIndex+1)}getDataPoint(t=this.state.currentIndex){let e=this.state;return{index:t,label:e.xAxis.labels[t],values:e.datasets.map(e=>e.values[t])}}setCurrentDataPoint(t){let e=this.state;(t=parseInt(t))<0&&(t=0),t>=e.xAxis.labels.length&&(t=e.xAxis.labels.length-1),t!==e.currentIndex&&(e.currentIndex=t,Ha(this.parent,"data-select",this.getDataPoint()))}addDataPoint(t,e,a=this.state.datasetLength){super.addDataPoint(t,e,a),this.data.labels.splice(a,0,t),this.data.datasets.map((t,i)=>{t.values.splice(a,0,e[i])}),this.update(this.data)}removeDataPoint(t=this.state.datasetLength-1){this.data.labels.length<=1||(super.removeDataPoint(t),this.data.labels.splice(t,1),this.data.datasets.map(e=>{e.values.splice(t,1)}),this.update(this.data))}updateDataset(t,e=0){this.data.datasets[e].values=t,this.update(this.data)}updateDatasets(t){this.data.datasets.map((e,a)=>{t[a]&&(e.values=t[a])}),this.update(this.data)}}class Jb extends V{constructor(t,e){super(t,e),this.type="donut",this.initTimeout=0,this.init=1,this.setup()}configure(t){super.configure(t),this.mouseMove=this.mouseMove.bind(this),this.mouseLeave=this.mouseLeave.bind(this),this.hoverRadio=t.hoverRadio||.1,this.config.startAngle=t.startAngle||0,this.clockWise=t.clockWise||!1,this.strokeWidth=t.strokeWidth||30}calc(){super.calc();let t=this.state;this.radius=this.height>this.width?this.center.x-this.strokeWidth/2:this.center.y-this.strokeWidth/2;const{radius:e,clockWise:a}=this,i=t.slicesProperties||[];t.sliceStrings=[],t.slicesProperties=[];let s=180-this.config.startAngle;t.sliceTotals.map((r,n)=>{const o=s,$=r/t.grandTotal*la,l=a?-$:$,u=s+=l,h=w(o,e),d=w(u,e),c=this.init&&i[n];let p,S;this.init?(p=c?c.startPosition:h,S=c?c.endPosition:h):(p=h,S=d);const v=kb(p,S,this.center,this.radius,this.clockWise);t.sliceStrings.push(v),t.slicesProperties.push({startPosition:h,endPosition:d,value:r,total:t.grandTotal,startAngle:o,endAngle:u,angle:l})}),this.init=0}setupComponents(){let t=this.state,e=[["donutSlices",{},function(){return{sliceStrings:t.sliceStrings,colors:this.colors,strokeWidth:this.strokeWidth}}.bind(this)]];this.components=new Map(e.map(t=>{let e=v(...t);return[t[0],e]}))}calTranslateByAngle(t){const{radius:e,hoverRadio:a}=this,i=w(t.startAngle+t.angle/2,e);return`translate3d(${i.x*a}px,${i.y*a}px,0)`}hoverSlice(t,e,a,i){if(!t)return;const s=this.colors[e];if(a){F(t,this.calTranslateByAngle(this.state.slicesProperties[e])),t.style.stroke=T(s,50);let a=x(this.svg),r=i.pageX-a.left+10,n=i.pageY-a.top-10,o=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[e]:this.state.labels[e])+": ",$=(100*this.state.sliceTotals[e]/this.state.grandTotal).toFixed(1);this.tip.setValues(r,n,{name:o,value:$+"%"}),this.tip.showTip()}else F(t,"translate3d(0,0,0)"),this.tip.hideTip(),t.style.stroke=s}bindTooltip(){this.container.addEventListener("mousemove",this.mouseMove),this.container.addEventListener("mouseleave",this.mouseLeave)}mouseMove(t){const e=t.target;let a=this.components.get("donutSlices").store,i=this.curActiveSliceIndex,s=this.curActiveSlice;if(a.includes(e)){let r=a.indexOf(e);this.hoverSlice(s,i,!1),this.curActiveSlice=e,this.curActiveSliceIndex=r,this.hoverSlice(e,r,!0,t)}else this.mouseLeave()}mouseLeave(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)}}const ta={bar:M,line:M,percentage:pb,heatmap:Eb,pie:qb,donut:Jb};function Lb(t="line",e,a){return"axis-mixed"===t?(a.type="line",new M(e,a)):ta[t]?new ta[t](e,a):void console.error("Undefined chart type: "+t)}class e{constructor(t,e){return Lb(e.type,t,e)}}var H={components:{Chart:e},data:function(){return{podcasterSlug:null,currentDate:new Date,currentYear:null,yearlyStats:[0],data:{labels:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],datasets:[]}}},computed:{id:function(){return this.$store.state.form.current},pageValues:function(){return this.$store.getters["form/values"](this.id)}},mounted:function(){var t=L(this.currentDate);this.podcasterSlug=this.sanitizeTitle(this.pageValues.podcastertitle),this.getStats(t)},methods:{getStats:function(t){var e=this;fetch("/api/podcaster/stats/"+this.podcasterSlug+"/episodes/yearly-downloads/"+t+"+"+(t-1),{method:"GET",headers:{"X-CSRF":panel.csrf}}).then(function(t){if(200!==t.status)throw"You are tracking your downloads, using the file method. Stats are currently available only when using mysql";return t}).then(function(t){return t.json()}).then(function(a){e.addChartData(a.stats,t)}).catch(function(t){e.error=t})},addChartData:function(t,e){var a={current:{name:e,values:[0,0,0,0,0,0,0,0,0,0,0,0]},past:{name:e-1,values:[0,0,0,0,0,0,0,0,0,0,0,0]}};t.map(function(t){t.year===e?a.current.values[t.month-1]=t.downloaded:a.past.values[t.month-1]=t.downloaded}),this.data.datasets=[a.current,a.past],this.drawChart()},drawChart:function(){new e("#chart",{title:"Monthly Episode Downloads",data:this.data,type:"line",height:350,colors:["green","dark-grey"],lineOptions:{hideLine:0,regionFill:1,hideDots:0},barOptions:{spaceRatio:.25}})},sanitizeTitle:function(t){return t.toLowerCase().replace(/e|é|è|ẽ|ẻ|ẹ|ê|ế|ề|ễ|ể|ệ/gi,"e").replace(/a|á|à|ã|ả|ạ|ă|ắ|ằ|ẵ|ẳ|ặ|â|ấ|ầ|ẫ|ẩ|ậ/gi,"a").replace(/o|ó|ò|õ|ỏ|ọ|ô|ố|ồ|ỗ|ổ|ộ|ơ|ớ|ờ|ỡ|ở|ợ/gi,"o").replace(/u|ú|ù|ũ|ủ|ụ|ư|ứ|ừ|ữ|ử|ự/gi,"u").replace(/đ/gi,"d").replace(/\s*$/g,"").replace(/\s+/g,"-")}}};if(typeof H==="function"){H=H.options}Object.assign(H,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",[_vm._v(" "+_vm._s(_vm.error)+" "),_c("div",{attrs:{"id":"chart"}})])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var wa=function(e){return e.toLowerCase().replace(/e|é|è|ẽ|ẻ|ẹ|ê|ế|ề|ễ|ể|ệ/gi,"e").replace(/a|á|à|ã|ả|ạ|ă|ắ|ằ|ẵ|ẳ|ặ|â|ấ|ầ|ẫ|ẩ|ậ/gi,"a").replace(/o|ó|ò|õ|ỏ|ọ|ô|ố|ồ|ỗ|ổ|ộ|ơ|ớ|ờ|ỡ|ở|ợ/gi,"o").replace(/u|ú|ù|ũ|ủ|ụ|ư|ứ|ừ|ữ|ử|ự/gi,"u").replace(/đ/gi,"d").replace(/\s*$/g,"").replace(/\s+/g,"-")};var J={data:function(){return{limit:10,headline:null,topEpisodes:[],error:null,podcasterSlug:null}},mounted:function(){this.podcasterSlug=wa(this.pageValues.podcastertitle),this.getStats()},created:function(){var t=this;this.load().then(function(e){t.headline=e.headline})},computed:{id:function(){return this.$store.state.form.current},pageValues:function(){return this.$store.getters["form/values"](this.id)}},methods:{getStats:function(){var t=this;fetch("/api/podcaster/stats/"+this.podcasterSlug+"/top/"+this.limit,{method:"GET",headers:{"X-CSRF":panel.csrf}}).then(function(t){if(200!==t.status)throw"You are tracking your downloads, using the file method. Stats are currently available only when using mysql";return t}).then(function(t){return t.json()}).then(function(e){t.topEpisodes=t.computeStats(e.stats)}).catch(function(e){t.error=e})},computeStats:function(t){return t.map(function(t){return{title:t.episode.replace(/-/g," "),downloads:t.downloaded}})}}};if(typeof J==="function"){J=J.options}Object.assign(J,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("section",{staticClass:"k-modified-section"},[_c("k-text",[_vm._v(_vm._s(_vm.error))]),_vm._v(" "),_c("k-headline",[_vm._v(_vm._s(_vm.headline))]),_vm._v(" "),_c("table",{attrs:{"id":"topTen"}},_vm._l(_vm.topEpisodes,function(episode){return _c("tr",[_c("td",[_vm._v(_vm._s(episode.downloads))]),_vm._v(" "),_c("td",[_vm._v(_vm._s(episode.title))])])}),0)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var t={components:{Chart:e},data:function(){return{podcasterSlug:null,currentDate:new Date,currentYear:null,yearlyStats:[0],data:{labels:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],datasets:[]}}},computed:{id:function(){return this.$store.state.form.current},pageValues:function(){return this.$store.getters["form/values"](this.id)}},mounted:function(){var t=L(this.currentDate);this.podcasterSlug=wa(this.pageValues.podcastertitle),this.getStats(t)},methods:{getStats:function(t){var e=this;fetch("/api/podcaster/stats/"+this.podcasterSlug+"/feed/yearly-downloads/"+t+"+"+(t-1),{method:"GET",headers:{"X-CSRF":panel.csrf}}).then(function(t){if(200!==t.status)throw"You are tracking your downloads, using the file method. Stats are currently available only when using mysql";return t}).then(function(t){return t.json()}).then(function(a){e.addChartData(a.stats,t)}).catch(function(t){e.error=t})},addChartData:function(t,e){var a={current:{name:e,values:[0,0,0,0,0,0,0,0,0,0,0,0]},past:{name:e-1,values:[0,0,0,0,0,0,0,0,0,0,0,0]}};t.map(function(t){t.year===e?a.current.values[t.month-1]=t.downloaded:a.past.values[t.month-1]=t.downloaded}),this.data.datasets=[a.current,a.past],this.drawChart()},drawChart:function(){new e("#feedChart",{title:"Monthly Feed Downloads",data:this.data,type:"line",height:350,colors:["blue","dark-grey"],lineOptions:{hideLine:0,regionFill:1,hideDots:0},barOptions:{spaceRatio:.25}})}}};if(typeof t==="function"){t=t.options}Object.assign(t,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",[_vm._v(" "+_vm._s(_vm.error)+" "),_c("div",{attrs:{"id":"feedChart"}})])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());panel.plugin("mauricerenck/podcaster",{sections:{podcasterEpisodeStats:i,podcasterYearlyGraph:H,podcasterTopTen:J,podcasterFeedStats:t}});})(); \ No newline at end of file +(function () {function cb(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return I(e).getMonth()}function I(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=Object.prototype.toString.call(e);return e instanceof Date||"object"==typeof e&&"[object Date]"===t?new Date(e.getTime()):"number"==typeof e||"[object Number]"===t?new Date(e):("string"!=typeof e&&"[object String]"!==t||"undefined"==typeof console||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn(new Error().stack)),new Date(NaN))}function sa(t,e){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var r=I(t),a=xa(e),$=r.getMonth()+a,n=new Date(0);n.setFullYear(r.getFullYear(),$,1),n.setHours(0,0,0,0);var o=Pa(n);return r.setMonth($,Math.min(o,r.getDate())),r}function xa(r){if(null===r||!0===r||!1===r)return NaN;var t=Number(r);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function Pa(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");var t=I(e),r=t.getFullYear(),$=t.getMonth(),a=new Date(0);return a.setFullYear(r,$+1,0),a.setHours(0,0,0,0),a.getDate()}function Xa(e,r){if(arguments.length<2)throw new TypeError("2 arguments required, but only "+arguments.length+" present");var t=xa(r);return sa(e,-t)}function M(e){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");return I(e).getFullYear()}var t={data:function(){return{currentDate:new Date,currentMonthName:null,currentMonth:null,currentYear:null,headline:null,episodes:[],error:null,podcasterSlug:null}},created:function(){this.setNewDateVars()},mounted:function(){this.podcasterSlug=this.sanitizeTitle(this.pageValues.podcastertitle),this.getStats()},computed:{id:function(){return this.$store.state.form.current},pageValues:function(){return this.$store.getters["form/values"](this.id)}},watch:{currentDate:{immediate:!1,handler:function(t,e){this.getStats()}}},methods:{getStats:function(){var t=this;fetch("/api/podcaster/stats/"+this.podcasterSlug+"/year/"+this.currentYear+"/month/"+(this.currentMonth+1),{method:"GET",headers:{"X-CSRF":panel.csrf}}).then(function(t){if(200!==t.status)throw"You are tracking your downloads, using the file method. Stats are currently available only when using mysql";return t}).then(function(t){return t.json()}).then(function(e){t.episodes=t.computeStats(e.stats)}).catch(function(e){t.error=e,console.log(t.error)})},computeStats:function(t){return t.episodes.map(function(t){return{title:t.episode.replace(/-/g," "),downloads:t.downloaded}})},prevMonth:function(){var t=Xa(this.currentDate,1);this.currentDate=t,this.setNewDateVars()},nextMonth:function(){var t=sa(this.currentDate,1);this.currentDate=t,this.setNewDateVars()},setNewDateVars:function(){this.currentMonth=cb(this.currentDate),this.currentYear=M(this.currentDate),this.currentMonthName=this.currentDate.toLocaleString("en",{month:"long"}),this.headline="Stats for "+this.currentMonthName+" "+this.currentYear},sanitizeTitle:function(t){return t.toLowerCase().replace(/e|é|è|ẽ|ẻ|ẹ|ê|ế|ề|ễ|ể|ệ/gi,"e").replace(/a|á|à|ã|ả|ạ|ă|ắ|ằ|ẵ|ẳ|ặ|â|ấ|ầ|ẫ|ẩ|ậ/gi,"a").replace(/o|ó|ò|õ|ỏ|ọ|ô|ố|ồ|ỗ|ổ|ộ|ơ|ớ|ờ|ỡ|ở|ợ/gi,"o").replace(/u|ú|ù|ũ|ủ|ụ|ư|ứ|ừ|ữ|ử|ự/gi,"u").replace(/đ/gi,"d").replace(/\s*$/g,"").replace(/\s+/g,"-")}}};if(typeof t==="function"){t=t.options}Object.assign(t,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("section",{staticClass:"k-modified-section"},[_c("div",{staticClass:"podcaster-prev-next"},[_c("button",{staticClass:"k-link k-button",on:{"click":_vm.prevMonth}},[_c("k-icon",{attrs:{"type":"angle-left"}})],1),_vm._v(" "),_c("button",{staticClass:"k-link k-button",on:{"click":_vm.nextMonth}},[_c("k-icon",{attrs:{"type":"angle-right"}})],1)]),_vm._v(" "),_c("k-text",[_vm._v(_vm._s(_vm.error))]),_vm._v(" "),_c("k-headline",[_vm._v(_vm._s(_vm.headline))]),_vm._v(" "),_c("table",{attrs:{"id":"episodeStats"}},_vm._l(_vm.episodes,function(episode){return _c("tr",[_c("td",[_vm._v(_vm._s(episode.downloads))]),_vm._v(" "),_c("td",[_vm._v(_vm._s(episode.title))])])}),0)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());function h(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function A(t){let e=t.getBoundingClientRect();return{top:e.top+(document.documentElement.scrollTop||document.body.scrollTop),left:e.left+(document.documentElement.scrollLeft||document.body.scrollLeft)}}function fb(t){var e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function Cb(t){var e=window.getComputedStyle(t),a=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight);return t.clientWidth-a}function Ha(t,e,a){var i=document.createEvent("HTMLEvents");for(var s in i.initEvent(e,!0,!0),a)i[s]=a[s];return t.dispatchEvent(i)}h.create=(t,e)=>{var a=document.createElement(t);for(var i in e){var s=e[i];if("inside"===i)h(s).appendChild(a);else if("around"===i){var r=h(s);r.parentNode.insertBefore(a,r),a.appendChild(r)}else"styles"===i?"object"==typeof s&&Object.keys(s).map(t=>{a.style[t]=s[t]}):i in a?a[i]=s:a.setAttribute(i,s)}return a};const Ma={margins:{top:10,bottom:10,left:20,right:20},paddings:{top:20,bottom:40,left:30,right:10},baseHeight:240,titleHeight:20,legendHeight:30,titleFontSize:12};function r(t){return t.titleHeight+t.margins.top+t.paddings.top}function E(t){return t.margins.left+t.paddings.left}function ua(t){return t.margins.top+t.margins.bottom+t.paddings.top+t.paddings.bottom+t.titleHeight+t.legendHeight}function F(t){return t.margins.left+t.margins.right+t.paddings.left+t.paddings.right}const lb=700,ob=400,wb=["line","bar"],ra=100,Ob=.5,Aa=.01,Ca=4,Ea=20,qa=2,O=5,n=10,Va=7,Wa=5,a=["light-blue","blue","violet","red","orange","yellow","green","light-green","purple","magenta","light-grey","dark-grey"],Ya=["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"],Za={bar:a,line:a,pie:a,percentage:a,heatmap:Ya,donut:a},na=Math.PI/180,ma=360;class ib{constructor({parent:t=null,colors:e=[]}){this.parent=t,this.colors=e,this.titleName="",this.titleValue="",this.listValues=[],this.titleValueFirst=0,this.x=0,this.y=0,this.top=0,this.left=0,this.setup()}setup(){this.makeTooltip()}refresh(){this.fill(),this.calcPosition()}makeTooltip(){this.container=h.create("div",{inside:this.parent,className:"graph-svg-tip comparison",innerHTML:"\n\t\t\t\t
    \n\t\t\t\t
    "}),this.hideTip(),this.title=this.container.querySelector(".title"),this.dataPointList=this.container.querySelector(".data-point-list"),this.parent.addEventListener("mouseleave",()=>{this.hideTip()})}fill(){let t;this.index&&this.container.setAttribute("data-point-index",this.index),t=this.titleValueFirst?`${this.titleValue}${this.titleName}`:`${this.titleName}${this.titleValue}`,this.title.innerHTML=t,this.dataPointList.innerHTML="",this.listValues.map((t,e)=>{const a=this.colors[e]||"black";let i=0===t.formatted||t.formatted?t.formatted:t.value,s=h.create("li",{styles:{"border-top":`3px solid ${a}`},innerHTML:`${0===i||i?i:""}\n\t\t\t\t\t${t.title?t.title:""}`});this.dataPointList.appendChild(s)})}calcPosition(){let t=this.container.offsetWidth;this.top=this.y-this.container.offsetHeight-Wa,this.left=this.x-t/2;let e=this.parent.offsetWidth-t,a=this.container.querySelector(".svg-pointer");if(this.left<0)a.style.left=`calc(50% - ${-1*this.left}px)`,this.left=0;else if(this.left>e){let t=`calc(50% + ${this.left-e}px)`;a.style.left=t,this.left=e}else a.style.left="50%"}setValues(t,e,a={},i=[],s=-1){this.titleName=a.name,this.titleValue=a.value,this.listValues=i,this.x=t,this.y=e,this.titleValueFirst=a.valueFirst||0,this.index=s,this.refresh()}hideTip(){this.container.style.top="0px",this.container.style.left="0px",this.container.style.opacity="0"}showTip(){this.container.style.top=this.top+"px",this.container.style.left=this.left+"px",this.container.style.opacity="1"}}function la(t){return parseFloat(t.toFixed(2))}function Q(t,e,a,i=!1){a||(a=i?t[0]:t[t.length-1]);let s=new Array(Math.abs(e)).fill(a);return t=i?s.concat(t):t.concat(s)}function ea(t,e){return(t+"").length*e}function q(t,e){return{x:Math.sin(t*na)*e,y:Math.cos(t*na)*e}}function aa(t,e){let a,i;return t<=e?(a=e-t,i=t):(a=t-e,i=e),[a,i]}function d(t,e,a=e.length-t.length){return a>0?t=Q(t,a):e=Q(e,a),[t,e]}const Ba={"light-blue":"#7cd6fd",blue:"#5e64ff",violet:"#743ee2",red:"#ff5858",orange:"#ffa00a",yellow:"#feef72",green:"#28a745","light-green":"#98d85b",purple:"#b554ff",magenta:"#ffa3ef",black:"#36114C",grey:"#bdd3e6","light-grey":"#f0f4f7","dark-grey":"#b8c2cc"};function W(t){return t>255?255:t<0?0:t}function U(t,e){let a=$(t),i=!1;"#"==a[0]&&(a=a.slice(1),i=!0);let s=parseInt(a,16),r=W((s>>16)+e),n=W((s>>8&255)+e);return(i?"#":"")+(W((255&s)+e)|n<<8|r<<16).toString(16)}function Fa(t){return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)}const $=t=>Ba[t]||t,m=6,g=4,c=10,u="#dadada",S="#555b51";function ja(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function b(t,e){var a=document.createElementNS("http://www.w3.org/2000/svg",t);for(var i in e){var s=e[i];if("inside"===i)ja(s).appendChild(a);else if("around"===i){var r=ja(s);r.parentNode.insertBefore(a,r),a.appendChild(r)}else"styles"===i?"object"==typeof s&&Object.keys(s).map(t=>{a.style[t]=s[t]}):("className"===i&&(i="class"),"innerHTML"===i?a.textContent=s:a.setAttribute(i,s))}return a}function $a(t,e){return b("linearGradient",{inside:t,id:e,x1:0,x2:0,y1:0,y2:1})}function P(t,e,a,i){return b("stop",{inside:t,style:`stop-color: ${a}`,offset:e,"stop-opacity":i})}function db(t,e,a,i){return b("svg",{className:e,inside:t,width:a,height:i})}function eb(t){return b("defs",{inside:t})}function L(t,e="",a){let i={className:t,transform:e};return a&&(i.inside=a),b("g",i)}function J(t,e="",a="none",i="none",s=0){return b("path",{className:e,d:t,styles:{stroke:a,fill:i,"stroke-width":s}})}function jb(t,e,a,i,s=1,r=0){let[n,o]=[a.x+t.x,a.y+t.y],[$,l]=[a.x+e.x,a.y+e.y];return`M${a.x} ${a.y}\n\t\tL${n} ${o}\n\t\tA ${i} ${i} 0 ${r} ${s?1:0}\n\t\t${$} ${l} z`}function kb(t,e,a,i,s=1){let[r,n]=[a.x+t.x,a.y+t.y],[o,$]=[a.x+e.x,a.y+e.y];return`M${r} ${n}\n\t\tA ${i} ${i} 0 0 ${s?1:0}\n\t\t${o} ${$}`}function da(t,e,a=!1){let i="path-fill-gradient-"+e+"-"+(a?"lighter":"default"),s=$a(t,i),r=[1,.6,.2];return a&&(r=[.4,.2,0]),P(s,"0%",e,r[0]),P(s,"50%",e,r[1]),P(s,"100%",e,r[2]),i}function nb(t,e,a,i,s=qa,r="none"){return b("rect",{className:"percentage-bar",x:t,y:e,width:a,height:i,fill:r,styles:{stroke:U(r,-25),"stroke-dasharray":`0, ${i+a}, ${a}, ${i}`,"stroke-width":s}})}function va(t,e,a,i,s="none",r={}){let n={className:t,x:e,y:a,width:i,height:i,fill:s};return Object.keys(r).map(t=>{n[t]=r[t]}),b("rect",n)}function rb(t,e,a,i="none",s){let r={className:"legend-bar",x:0,y:0,width:a,height:"2px",fill:i},n=b("text",{className:"legend-dataset-text",x:0,y:0,dy:2*c+"px","font-size":1.2*c+"px","text-anchor":"start",fill:S,innerHTML:s}),o=b("g",{transform:`translate(${t}, ${e})`});return o.appendChild(b("rect",r)),o.appendChild(n),o}function tb(t,e,a,i="none",s){let r={className:"legend-dot",cx:0,cy:0,r:a,fill:i},n=b("text",{className:"legend-dataset-text",x:0,y:0,dx:c+"px",dy:c/3+"px","font-size":1.2*c+"px","text-anchor":"start",fill:S,innerHTML:s}),o=b("g",{transform:`translate(${t}, ${e})`});return o.appendChild(b("circle",r)),o.appendChild(n),o}function C(t,e,a,i,s={}){let r=s.fontSize||c;return b("text",{className:t,x:e,y:a,dy:(void 0!==s.dy?s.dy:r/2)+"px","font-size":r+"px",fill:s.fill||S,"text-anchor":s.textAnchor||"start",innerHTML:i})}function yb(t,e,a,i,s={}){s.stroke||(s.stroke=u);let r=b("line",{className:"line-vertical "+s.className,x1:0,x2:0,y1:a,y2:i,styles:{stroke:s.stroke}}),n=b("text",{x:0,y:a>i?a+g:a-g-c,dy:c+"px","font-size":c+"px","text-anchor":"middle",innerHTML:e+""}),o=b("g",{transform:`translate(${t}, 0)`});return o.appendChild(r),o.appendChild(n),o}function pa(t,e,a,i,s={}){s.stroke||(s.stroke=u),s.lineType||(s.lineType="");let r=b("line",{className:"line-horizontal "+s.className+("dashed"===s.lineType?"dashed":""),x1:a,x2:i,y1:0,y2:0,styles:{stroke:s.stroke}}),n=b("text",{x:at[a]+","+e).join("L"),n=J("M"+r,"line-graph-path",a);if(i.heatline){let t=da(s.svgDefs,a);n.style.stroke=`url(#${t})`}let o={path:n};if(i.regionFill){let e=da(s.svgDefs,a,!0),i="M"+`${t[0]},${s.zeroLine}L`+r+`L${t.slice(-1)[0]},${s.zeroLine}`;o.region=J(i,"region-fill","none",`url(#${e})`)}return o}let Qb={bar:t=>{let e;"rect"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);let a=t.cloneNode();return a.style.fill="#000000",a.style.opacity="0.4",e&&a.setAttribute("transform",e),a},dot:t=>{let e;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);let a=t.cloneNode(),i=t.getAttribute("r"),s=t.getAttribute("fill");return a.setAttribute("r",parseInt(i)+4),a.setAttribute("fill",s),a.style.opacity="0.6",e&&a.setAttribute("transform",e),a},heat_square:t=>{let e;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);let a=t.cloneNode(),i=t.getAttribute("r"),s=t.getAttribute("fill");return a.setAttribute("r",parseInt(i)+4),a.setAttribute("fill",s),a.style.opacity="0.6",e&&a.setAttribute("transform",e),a}},za={bar:(t,e)=>{let a;"rect"!==t.nodeName&&(a=t.getAttribute("transform"),t=t.childNodes[0]);let i=["x","y","width","height"];Object.values(t.attributes).filter(t=>i.includes(t.name)&&t.specified).map(t=>{e.setAttribute(t.name,t.nodeValue)}),a&&e.setAttribute("transform",a)},dot:(t,e)=>{let a;"circle"!==t.nodeName&&(a=t.getAttribute("transform"),t=t.childNodes[0]);let i=["cx","cy"];Object.values(t.attributes).filter(t=>i.includes(t.name)&&t.specified).map(t=>{e.setAttribute(t.name,t.nodeValue)}),a&&e.setAttribute("transform",a)},heat_square:(t,e)=>{let a;"circle"!==t.nodeName&&(a=t.getAttribute("transform"),t=t.childNodes[0]);let i=["cx","cy"];Object.values(t.attributes).filter(t=>i.includes(t.name)&&t.specified).map(t=>{e.setAttribute(t.name,t.nodeValue)}),a&&e.setAttribute("transform",a)}};const B=350,fa=350,v=B,Da=250,j="easein";function w(t,e,a,i){let s="string"==typeof e?e:e.join(", ");return[t,{transform:a.join(", ")},i,j,"translate",{transform:s}]}function Ga(t,e,a){return w(t,[a,0],[e,0],v)}function Z(t,e,a){return w(t,[0,a],[0,e],v)}function Ia(t,e,a,i){let s=e-a,r=t.childNodes[0],n=r.getAttribute("width");return[[r,{height:s,"stroke-dasharray":`${n}, ${s}`},v,j],w(t,[0,i],[0,a],v)]}function Ja(t,e,a,i,s=0,r={}){let[n,o]=aa(a,r.zeroLine);if(o-=s,"rect"!==t.nodeName){let a=[t.childNodes[0],{width:i,height:n},B,j],s=t.getAttribute("transform").split("(")[1].slice(0,-1);return[a,w(t,s,[e,o],v)]}return[[t,{width:i,height:n,x:e,y:o},B,j]]}function Ka(t,e,a){if("circle"!==t.nodeName){let i=t.getAttribute("transform").split("(")[1].slice(0,-1);return[w(t,i,[e,a],v)]}return[[t,{cx:e,cy:a},B,j]]}function La(t,e,a,i){let s=[],r=a.map((t,a)=>e[a]+","+t).join("L");const n=[t.path,{d:"M"+r},fa,j];if(s.push(n),t.region){let a=`${e[0]},${i}L`,n=`L${e.slice(-1)[0]}, ${i}`;const o=[t.region,{d:"M"+a+r+n},fa,j];s.push(o)}return s}function Y(t,e){return[t,{d:e},B,j]}const Na={ease:"0.25 0.1 0.25 1",linear:"0 0 1 1",easein:"0.1 0.8 0.2 1",easeout:"0 0 0.58 1",easeinout:"0.42 0 0.58 1"};function Oa(t,e,a,i="linear",s,r={}){let n=t.cloneNode(!0),o=t.cloneNode(!0);for(var $ in e){let u;u="transform"===$?document.createElementNS("http://www.w3.org/2000/svg","animateTransform"):document.createElementNS("http://www.w3.org/2000/svg","animate");let h=r[$]||t.getAttribute($),d=e[$],c={attributeName:$,from:h,to:d,begin:"0s",dur:a/1e3+"s",values:h+";"+d,keySplines:Na[i],keyTimes:"0;1",calcMode:"spline",fill:"freeze"};for(var l in s&&(c.type=s),c)u.setAttribute(l,c[l]);n.appendChild(u),s?o.setAttribute($,`translate(${d})`):o.setAttribute($,d)}return[n,o]}function D(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.mozTransform=e,t.style.oTransform=e}function Qa(t,e){let a=[],i=[];e.map(t=>{let e,s,r=t[0],n=r.parentNode;t[0]=r,[e,s]=Oa(...t),a.push(s),i.push([e,n]),n.replaceChild(e,r)});let s=t.cloneNode(!0);return i.map((t,i)=>{t[1].replaceChild(a[i],t[0]),e[i][0]=a[i]}),s}function Ra(t,e,a){if(0===a.length)return;let i=Qa(e,a);e.parentNode==t&&(t.removeChild(e),t.appendChild(i)),setTimeout(()=>{i.parentNode==t&&(t.removeChild(i),t.appendChild(e))},Da)}const Sa=".chart-container{position:relative;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Roboto','Oxygen','Ubuntu','Cantarell','Fira Sans','Droid Sans','Helvetica Neue',sans-serif}.chart-container .axis,.chart-container .chart-label{fill:#555b51}.chart-container .axis line,.chart-container .chart-label line{stroke:#dadada}.chart-container .dataset-units circle{stroke:#fff;stroke-width:2}.chart-container .dataset-units path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container .dataset-path{stroke-width:2px}.chart-container .path-group path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container line.dashed{stroke-dasharray:5,3}.chart-container .axis-line .specific-value{text-anchor:start}.chart-container .axis-line .y-line{text-anchor:end}.chart-container .axis-line .x-line{text-anchor:middle}.chart-container .legend-dataset-text{fill:#6c7680;font-weight:600}.graph-svg-tip{position:absolute;z-index:99999;padding:10px;font-size:12px;color:#959da5;text-align:center;background:rgba(0,0,0,.8);border-radius:3px}.graph-svg-tip ul{padding-left:0;display:flex}.graph-svg-tip ol{padding-left:0;display:flex}.graph-svg-tip ul.data-point-list li{min-width:90px;flex:1;font-weight:600}.graph-svg-tip strong{color:#dfe2e5;font-weight:600}.graph-svg-tip .svg-pointer{position:absolute;height:5px;margin:0 0 0 -5px;content:' ';border:5px solid transparent;border-top-color:rgba(0,0,0,.8)}.graph-svg-tip.comparison{padding:0;text-align:left;pointer-events:none}.graph-svg-tip.comparison .title{display:block;padding:10px;margin:0;font-weight:600;line-height:1;pointer-events:none}.graph-svg-tip.comparison ul{margin:0;white-space:nowrap;list-style:none}.graph-svg-tip.comparison li{display:inline-block;padding:5px 10px}";function Ta(t,e){var a=document.createElement("a");a.style="display: none";var i=new Blob(e,{type:"image/svg+xml; charset=utf-8"}),s=window.URL.createObjectURL(i);a.href=s,a.download=t,document.body.appendChild(a),a.click(),setTimeout(function(){document.body.removeChild(a),window.URL.revokeObjectURL(s)},300)}function Ua(t){let e=t.cloneNode(!0);e.classList.add("chart-container"),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");let a=h.create("style",{innerHTML:Sa});e.insertBefore(a,e.firstChild);let i=h.create("div");return i.appendChild(e),i.innerHTML}let ka;class V{constructor(t,e){if(this.parent="string"==typeof t?document.querySelector(t):t,!(this.parent instanceof HTMLElement))throw new Error("No `parent` element to render on was provided.");this.rawChartArgs=e,this.title=e.title||"",this.type=e.type||"",this.realData=this.prepareData(e.data),this.data=this.prepareFirstData(this.realData),this.colors=this.validateColors(e.colors,this.type),this.config={showTooltip:1,showLegend:1,isNavigable:e.isNavigable||0,animate:1},this.measures=JSON.parse(JSON.stringify(Ma));let a=this.measures;this.setMeasures(e),this.title.length||(a.titleHeight=0),this.config.showLegend||(a.legendHeight=0),this.argHeight=e.height||a.baseHeight,this.state={},this.options={},this.initTimeout=lb,this.config.isNavigable&&(this.overlays=[]),this.configure(e)}prepareData(t){return t}prepareFirstData(t){return t}validateColors(t,e){const a=[];return(t=(t||[]).concat(Za[e])).forEach(t=>{const e=$(t);Fa(e)?a.push(e):console.warn("\""+t+"\" is not a valid color.")}),a}setMeasures(){}configure(){let t=this.argHeight;this.baseHeight=t,this.height=t-ua(this.measures),ka=this.boundDrawFn.bind(this),window.addEventListener("resize",ka),window.addEventListener("orientationchange",this.boundDrawFn.bind(this))}boundDrawFn(){this.draw(!0)}unbindWindowEvents(){window.removeEventListener("resize",ka),window.removeEventListener("orientationchange",this.boundDrawFn.bind(this))}setup(){this.makeContainer(),this.updateWidth(),this.makeTooltip(),this.draw(!1,!0)}makeContainer(){this.parent.innerHTML="";let t={inside:this.parent,className:"chart-container"};this.independentWidth&&(t.styles={width:this.independentWidth+"px"}),this.container=h.create("div",t)}makeTooltip(){this.tip=new ib({parent:this.container,colors:this.colors}),this.bindTooltip()}bindTooltip(){}draw(t=!1,e=!1){this.updateWidth(),this.calc(t),this.makeChartArea(),this.setupComponents(),this.components.forEach(t=>t.setup(this.drawArea)),this.render(this.components,!1),e&&(this.data=this.realData,setTimeout(()=>{this.update(this.data)},this.initTimeout)),this.renderLegend(),this.setupNavigation(e)}calc(){}updateWidth(){this.baseWidth=Cb(this.parent),this.width=this.baseWidth-F(this.measures)}makeChartArea(){this.svg&&this.container.removeChild(this.svg);let t=this.measures;this.svg=db(this.container,"frappe-chart chart",this.baseWidth,this.baseHeight),this.svgDefs=eb(this.svg),this.title.length&&(this.titleEL=C("title",t.margins.left,t.margins.top,this.title,{fontSize:t.titleFontSize,fill:"#666666",dy:t.titleFontSize}));let e=r(t);this.drawArea=L(this.type+"-chart chart-draw-area",`translate(${E(t)}, ${e})`),this.config.showLegend&&(e+=this.height+t.paddings.bottom,this.legendArea=L("chart-legend",`translate(${E(t)}, ${e})`)),this.title.length&&this.svg.appendChild(this.titleEL),this.svg.appendChild(this.drawArea),this.config.showLegend&&this.svg.appendChild(this.legendArea),this.updateTipOffset(E(t),r(t))}updateTipOffset(t,e){this.tip.offset={x:t,y:e}}setupComponents(){this.components=new Map}update(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.calc(),this.render()}render(t=this.components,e=!0){this.config.isNavigable&&this.overlays.map(t=>t.parentNode.removeChild(t));let a=[];t.forEach(t=>{a=a.concat(t.update(e))}),a.length>0?(Ra(this.container,this.svg,a),setTimeout(()=>{t.forEach(t=>t.make()),this.updateNav()},ob)):(t.forEach(t=>t.make()),this.updateNav())}updateNav(){this.config.isNavigable&&(this.makeOverlay(),this.bindUnits())}renderLegend(){}setupNavigation(t=!1){this.config.isNavigable&&t&&(this.bindOverlay(),this.keyActions={13:this.onEnterKey.bind(this),37:this.onLeftArrow.bind(this),38:this.onUpArrow.bind(this),39:this.onRightArrow.bind(this),40:this.onDownArrow.bind(this)},document.addEventListener("keydown",t=>{fb(this.container)&&(t=t||window.event,this.keyActions[t.keyCode]&&this.keyActions[t.keyCode]())}))}makeOverlay(){}updateOverlay(){}bindOverlay(){}bindUnits(){}onLeftArrow(){}onRightArrow(){}onUpArrow(){}onDownArrow(){}onEnterKey(){}addDataPoint(){}removeDataPoint(){}getDataPoint(){}setCurrentDataPoint(){}updateDataset(){}export(){let t=Ua(this.svg);Ta(this.title||"Chart",[t])}}class T extends V{constructor(t,e){super(t,e)}configure(t){super.configure(t),this.config.maxSlices=t.maxSlices||20,this.config.maxLegendPoints=t.maxLegendPoints||20}calc(){let t=this.state,e=this.config.maxSlices;t.sliceTotals=[];let a=this.data.labels.map((t,e)=>{let a=0;return this.data.datasets.map(t=>{a+=t.values[e]}),[a,t]}).filter(t=>t[0]>=0),i=a;if(a.length>e){a.sort((t,e)=>e[0]-t[0]),i=a.slice(0,e-1);let t=a.slice(e-1),s=0;t.map(t=>{s+=t[0]}),i.push([s,"Rest"]),this.colors[e-1]="grey"}t.labels=[],i.map(e=>{t.sliceTotals.push(e[0]),t.labels.push(e[1])}),t.grandTotal=t.sliceTotals.reduce((t,e)=>t+e,0),this.center={x:this.width/2,y:this.height/2}}renderLegend(){let t=this.state;this.legendArea.textContent="",this.legendTotals=t.sliceTotals.slice(0,this.config.maxLegendPoints);let e=0,a=0;this.legendTotals.map((i,s)=>{let r=Math.floor((this.width-F(this.measures))/110);e>r&&(e=0,a+=20);let n=tb(110*e+5,a,5,this.colors[s],`${t.labels[s]}: ${i}`);this.legendArea.appendChild(n),e++})}}const _=12,x=7,ba=1e3,_a=86400,ab=["January","February","March","April","May","June","July","August","September","October","November","December"],bb=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function ca(t){let e=new Date(t);return e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),e}function X(t){let e=t.getDate(),a=t.getMonth()+1;return[t.getFullYear(),(a>9?"":"0")+a,(e>9?"":"0")+e].join("-")}function k(t){return new Date(t.getTime())}function R(t,e){let a=ia(t);return Math.ceil(gb(a,e)/x)}function gb(t,e){let a=_a*ba;return(ca(e)-ca(t))/a}function hb(t,e){return t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}function ga(t,e=!1){let a=ab[t];return e?a.slice(0,3):a}function ha(t,e){return new Date(e,t+1,0)}function ia(t){let e=k(t);const a=e.getDay();return 0!==a&&p(e,-1*a),e}function p(t,e){t.setDate(t.getDate()+e)}class mb{constructor({layerClass:t="",layerTransform:e="",constants:a,getData:i,makeElements:s,animateElements:r}){this.layerTransform=e,this.constants=a,this.makeElements=s,this.getData=i,this.animateElements=r,this.store=[],this.labels=[],this.layerClass=t,this.layerClass="function"==typeof this.layerClass?this.layerClass():this.layerClass,this.refresh()}refresh(t){this.data=t||this.getData()}setup(t){this.layer=L(this.layerClass,this.layerTransform,t)}make(){this.render(this.data),this.oldData=this.data}render(t){this.store=this.makeElements(t),this.layer.textContent="",this.store.forEach(t=>{this.layer.appendChild(t)}),this.labels.forEach(t=>{this.layer.appendChild(t)})}update(t=!0){this.refresh();let e=[];return t&&(e=this.animateElements(this.data)||[]),e}}let ya={donutSlices:{layerClass:"donut-slices",makeElements:t=>t.sliceStrings.map((e,a)=>{let i=J(e,"donut-path",t.colors[a],"none",t.strokeWidth);return i.style.transition="transform .3s;",i}),animateElements(t){return this.store.map((e,a)=>Y(e,t.sliceStrings[a]))}},pieSlices:{layerClass:"pie-slices",makeElements:t=>t.sliceStrings.map((e,a)=>{let i=J(e,"pie-path","none",t.colors[a]);return i.style.transition="transform .3s;",i}),animateElements(t){return this.store.map((e,a)=>Y(e,t.sliceStrings[a]))}},percentageBars:{layerClass:"percentage-bars",makeElements(t){return t.xPositions.map((e,a)=>{return nb(e,0,t.widths[a],this.constants.barHeight,this.constants.barDepth,t.colors[a])})},animateElements(t){if(t)return[]}},yAxis:{layerClass:"y axis",makeElements(t){return t.positions.map((e,a)=>Db(e,t.labels[a],this.constants.width,{mode:this.constants.mode,pos:this.constants.pos}))},animateElements(t){let e=t.positions,a=t.labels,i=this.oldData.positions,s=this.oldData.labels;return[i,e]=d(i,e),[s,a]=d(s,a),this.render({positions:i,labels:a}),this.store.map((t,a)=>Z(t,e[a],i[a]))}},xAxis:{layerClass:"x axis",makeElements(t){return t.positions.map((e,a)=>Ib(e,t.calcLabels[a],this.constants.height,{mode:this.constants.mode,pos:this.constants.pos}))},animateElements(t){let e=t.positions,a=t.calcLabels,i=this.oldData.positions,s=this.oldData.calcLabels;return[i,e]=d(i,e),[s,a]=d(s,a),this.render({positions:i,calcLabels:a}),this.store.map((t,a)=>Ga(t,e[a],i[a]))}},yMarkers:{layerClass:"y-markers",makeElements(t){return t.map(t=>Kb(t.position,t.label,this.constants.width,{labelPos:t.options.labelPos,mode:"span",lineType:"dashed"}))},animateElements(t){[this.oldData,t]=d(this.oldData,t);let e=t.map(t=>t.position),a=t.map(t=>t.label),i=t.map(t=>t.options),s=this.oldData.map(t=>t.position);return this.render(s.map((t,e)=>({position:s[e],label:a[e],options:i[e]}))),this.store.map((t,a)=>Z(t,e[a],s[a]))}},yRegions:{layerClass:"y-regions",makeElements(t){return t.map(t=>Mb(t.startPos,t.endPos,this.constants.width,t.label,{labelPos:t.options.labelPos}))},animateElements(t){[this.oldData,t]=d(this.oldData,t);let e=t.map(t=>t.endPos),a=t.map(t=>t.label),i=t.map(t=>t.startPos),s=t.map(t=>t.options),r=this.oldData.map(t=>t.endPos),n=this.oldData.map(t=>t.startPos);this.render(r.map((t,e)=>({startPos:n[e],endPos:r[e],label:a[e],options:s[e]})));let o=[];return this.store.map((t,a)=>{o=o.concat(Ia(t,i[a],e[a],r[a]))}),o}},heatDomain:{layerClass:function(){return"heat-domain domain-"+this.constants.index},makeElements(t){let{index:e,colWidth:a,rowHeight:i,squareSize:s,xTranslate:r}=this.constants,n=r,o=0;return this.serializedSubDomains=[],t.cols.map((t,r)=>{1===r&&this.labels.push(C("domain-name",n,-12,ga(e,!0).toUpperCase(),{fontSize:9})),t.map((t,e)=>{if(t.fill){let a={"data-date":t.yyyyMmDd,"data-value":t.dataValue,"data-day":e},i=va("day",n,o,s,t.fill,a);this.serializedSubDomains.push(i)}o+=i}),o=0,n+=a}),this.serializedSubDomains},animateElements(t){if(t)return[]}},barGraph:{layerClass:function(){return"dataset-units dataset-bars dataset-"+this.constants.index},makeElements(t){let e=this.constants;return this.unitType="bar",this.units=t.yPositions.map((a,i)=>Nb(t.xPositions[i],a,t.barWidth,e.color,t.labels[i],i,t.offsets[i],{zeroLine:t.zeroLine,barsWidth:t.barsWidth,minHeight:e.minHeight})),this.units},animateElements(t){let e=t.xPositions,a=t.yPositions,i=t.offsets,s=t.labels,r=this.oldData.xPositions,n=this.oldData.yPositions,o=this.oldData.offsets,$=this.oldData.labels;[r,e]=d(r,e),[n,a]=d(n,a),[o,i]=d(o,i),[$,s]=d($,s),this.render({xPositions:r,yPositions:n,offsets:o,labels:s,zeroLine:this.oldData.zeroLine,barsWidth:this.oldData.barsWidth,barWidth:this.oldData.barWidth});let l=[];return this.store.map((s,r)=>{l=l.concat(Ja(s,e[r],a[r],t.barWidth,i[r],{zeroLine:t.zeroLine}))}),l}},lineGraph:{layerClass:function(){return"dataset-units dataset-line dataset-"+this.constants.index},makeElements(t){let e=this.constants;return this.unitType="dot",this.paths={},e.hideLine||(this.paths=Pb(t.xPositions,t.yPositions,e.color,{heatline:e.heatline,regionFill:e.regionFill},{svgDefs:e.svgDefs,zeroLine:t.zeroLine})),this.units=[],e.hideDots||(this.units=t.yPositions.map((a,i)=>Rb(t.xPositions[i],a,t.radius,e.color,e.valuesOverPoints?t.values[i]:"",i))),Object.values(this.paths).concat(this.units)},animateElements(t){let e=t.xPositions,a=t.yPositions,i=t.values,s=this.oldData.xPositions,r=this.oldData.yPositions,n=this.oldData.values;[s,e]=d(s,e),[r,a]=d(r,a),[n,i]=d(n,i),this.render({xPositions:s,yPositions:r,values:i,zeroLine:this.oldData.zeroLine,radius:this.oldData.radius});let o=[];return Object.keys(this.paths).length&&(o=o.concat(La(this.paths,e,a,t.zeroLine))),this.units.length&&this.units.map((t,i)=>{o=o.concat(Ka(t,e[i],a[i]))}),o}}};function o(t,e,a){let i=Object.keys(ya).filter(e=>t.includes(e)),s=ya[i[0]];return Object.assign(s,{constants:e,getData:a}),new mb(s)}class pb extends T{constructor(t,e){super(t,e),this.type="percentage",this.setup()}setMeasures(t){let e=this.measures;this.barOptions=t.barOptions||{};let a=this.barOptions;a.height=a.height||Ea,a.depth=a.depth||qa,e.paddings.right=30,e.legendHeight=80,e.baseHeight=8*(a.height+.5*a.depth)}setupComponents(){let t=this.state,e=[["percentageBars",{barHeight:this.barOptions.height,barDepth:this.barOptions.depth},function(){return{xPositions:t.xPositions,widths:t.widths,colors:this.colors}}.bind(this)]];this.components=new Map(e.map(t=>{let e=o(...t);return[t[0],e]}))}calc(){super.calc();let t=this.state;t.xPositions=[],t.widths=[];let e=0;t.sliceTotals.map(a=>{let i=this.width*a/t.grandTotal;t.widths.push(i),t.xPositions.push(e),e+=i})}makeDataByIndex(){}bindTooltip(){let t=this.state;this.container.addEventListener("mousemove",e=>{let a=this.components.get("percentageBars").store,i=e.target;if(a.includes(i)){let e=a.indexOf(i),s=A(this.container),r=A(i),n=r.left-s.left+parseInt(i.getAttribute("width"))/2,o=r.top-s.top,$=(this.formattedLabels&&this.formattedLabels.length>0?this.formattedLabels[e]:this.state.labels[e])+": ",l=t.sliceTotals[e]/t.grandTotal;this.tip.setValues(n,o,{name:$,value:(100*l).toFixed(1)+"%"}),this.tip.showTip()}})}}class qb extends T{constructor(t,e){super(t,e),this.type="pie",this.initTimeout=0,this.init=1,this.setup()}configure(t){super.configure(t),this.mouseMove=this.mouseMove.bind(this),this.mouseLeave=this.mouseLeave.bind(this),this.hoverRadio=t.hoverRadio||.1,this.config.startAngle=t.startAngle||0,this.clockWise=t.clockWise||!1}calc(){super.calc();let t=this.state;this.radius=this.height>this.width?this.center.x:this.center.y;const{radius:e,clockWise:a}=this,i=t.slicesProperties||[];t.sliceStrings=[],t.slicesProperties=[];let s=180-this.config.startAngle;t.sliceTotals.map((r,n)=>{const o=s,$=r/t.grandTotal*ma;let l=0;$>180&&(l=1);const u=a?-$:$,h=s+=u,d=q(o,e),c=q(h,e),p=this.init&&i[n];let S,v;this.init?(S=p?p.startPosition:d,v=p?p.endPosition:d):(S=d,v=c);const P=jb(S,v,this.center,this.radius,a,l);t.sliceStrings.push(P),t.slicesProperties.push({startPosition:d,endPosition:c,value:r,total:t.grandTotal,startAngle:o,endAngle:h,angle:u})}),this.init=0}setupComponents(){let t=this.state,e=[["pieSlices",{},function(){return{sliceStrings:t.sliceStrings,colors:this.colors}}.bind(this)]];this.components=new Map(e.map(t=>{let e=o(...t);return[t[0],e]}))}calTranslateByAngle(t){const{radius:e,hoverRadio:a}=this,i=q(t.startAngle+t.angle/2,e);return`translate3d(${i.x*a}px,${i.y*a}px,0)`}hoverSlice(t,e,a,i){if(!t)return;const s=this.colors[e];if(a){D(t,this.calTranslateByAngle(this.state.slicesProperties[e])),t.style.fill=U(s,50);let a=A(this.svg),r=i.pageX-a.left+10,n=i.pageY-a.top-10,o=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[e]:this.state.labels[e])+": ",$=(100*this.state.sliceTotals[e]/this.state.grandTotal).toFixed(1);this.tip.setValues(r,n,{name:o,value:$+"%"}),this.tip.showTip()}else D(t,"translate3d(0,0,0)"),this.tip.hideTip(),t.style.fill=s}bindTooltip(){this.container.addEventListener("mousemove",this.mouseMove),this.container.addEventListener("mouseleave",this.mouseLeave)}mouseMove(t){const e=t.target;let a=this.components.get("pieSlices").store,i=this.curActiveSliceIndex,s=this.curActiveSlice;if(a.includes(e)){let r=a.indexOf(e);this.hoverSlice(s,i,!1),this.curActiveSlice=e,this.curActiveSliceIndex=r,this.hoverSlice(e,r,!0,t)}else this.mouseLeave()}mouseLeave(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)}}function y(t){if(0===t)return[0,0];if(isNaN(t))return{mantissa:-6755399441055744,exponent:972};var e=t>0?1:-1;if(!isFinite(t))return{mantissa:4503599627370496*e,exponent:972};t=Math.abs(t);var a=Math.floor(Math.log10(t));return[e*(t/Math.pow(10,a)),a]}function sb(t,e=0){let a=Math.ceil(t),i=Math.floor(e),s=a-i,r=s,n=1;s>5&&(s%2!=0&&(s=++a-i),r=s/2,n=2),s<=2&&(n=s/(r=4)),0===s&&(r=5,n=1);let o=[];for(var $=0;$<=r;$++)o.push(i+n*$);return o}function z(t,e=0){let[a,i]=y(t),s=e?e/Math.pow(10,i):0,r=sb(a=a.toFixed(6),s);return r=r.map(t=>t*Math.pow(10,i))}function ub(t,e=!1){let a=Math.max(...t),i=Math.min(...t),s=0,r=[];function n(t,e){let a=z(t),i=a[1]-a[0],s=0;for(var r=1;s=0&&i>=0)s=y(a)[1],r=e?z(a,i):z(a);else if(a>0&&i<0){let t=Math.abs(i);if(a>=t)s=y(a)[1],r=n(a,t);else{s=y(t)[1],r=n(t,a).map(t=>-1*t)}}else if(a<=0&&i<=0){let t=Math.abs(i),n=Math.abs(a);s=y(t)[1],r=(r=e?z(t,n):z(t)).reverse().map(t=>-1*t)}return r}function vb(t){let e,a=oa(t);if(t.indexOf(0)>=0)e=t.indexOf(0);else if(t[0]>0){e=-1*t[0]/a}else{e=-1*t[t.length-1]/a+(t.length-1)}return e}function oa(t){return t[1]-t[0]}function xb(t){return t[t.length-1]-t[0]}function G(t,e){return la(e.zeroLine-t*e.scaleMultiplier)}function zb(t,e,a=!1){let i=e.reduce(function(e,a){return Math.abs(a-t)et.end)throw new Error("Start date cannot be greater than end date.");if(t.start||(t.start=new Date,t.start.setFullYear(t.start.getFullYear()-1)),t.end||(t.end=new Date),t.dataPoints=t.dataPoints||{},parseInt(Object.keys(t.dataPoints)[0])>1e5){let e={};Object.keys(t.dataPoints).forEach(a=>{let i=new Date(a*ba);e[X(i)]=t.dataPoints[a]}),t.dataPoints=e}return t}calc(){let t=this.state;t.start=k(this.data.start),t.end=k(this.data.end),t.firstWeekStart=k(t.start),t.noOfWeeks=R(t.start,t.end),t.distribution=Ab(Object.values(this.data.dataPoints),O),t.domainConfigs=this.getDomains()}setupComponents(){let t=this.state,e=this.discreteDomains?0:1,a=t.domainConfigs.map((a,i)=>["heatDomain",{index:a.index,colWidth:f,rowHeight:l,squareSize:n,xTranslate:t.domainConfigs.filter((t,e)=>et.cols.length-e).reduce((t,e)=>t+e,0)*f},function(){return t.domainConfigs[i]}.bind(this)]);this.components=new Map(a.map((t,e)=>{let a=o(...t);return[t[0]+"-"+e,a]}));let i=0;bb.forEach((t,e)=>{if([1,3,5].includes(e)){let e=C("subdomain-name",-f/2,i,t,{fontSize:n,dy:8,textAnchor:"end"});this.drawArea.appendChild(e)}i+=l})}update(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.draw(),this.bindTooltip()}bindTooltip(){this.container.addEventListener("mousemove",t=>{this.components.forEach(e=>{let a=e.store,i=t.target;if(a.includes(i)){let e=i.getAttribute("data-value"),a=i.getAttribute("data-date").split("-"),s=ga(parseInt(a[1])-1,!0),r=this.container.getBoundingClientRect(),n=i.getBoundingClientRect(),o=parseInt(t.target.getAttribute("width")),$=n.left-r.left+o/2,l=n.top-r.top,u=e+" "+this.countLabel,h=" on "+s+" "+a[0]+", "+a[2];this.tip.setValues($,l,{name:h,value:u,valueFirst:1},[]),this.tip.showTip()}})})}renderLegend(){this.legendArea.textContent="";let t=0,e=l,a=C("subdomain-name",t,e,"Less",{fontSize:n+1,dy:9});t=2*f+f/2,this.legendArea.appendChild(a),this.colors.slice(0,O).map((a,i)=>{const s=va("heatmap-legend-unit",t+(f+3)*i,e,n,a);this.legendArea.appendChild(s)});let i=C("subdomain-name",t+O*(f+3)+f/4,e,"More",{fontSize:n+1,dy:9});this.legendArea.appendChild(i)}getDomains(){let t=this.state;const[e,a]=[t.start.getMonth(),t.start.getFullYear()],[i,s]=[t.end.getMonth(),t.end.getFullYear()],r=i-e+1+12*(s-a);let n=[],o=k(t.start);for(var $=0;$=i.start&&s<=i.end;a||s.getMonth()!==e||!n?t.yyyyMmDd=X(s):t=this.getSubDomainConfig(s),r.push(t)}return r}getSubDomainConfig(t){let e=X(t),a=this.data.dataPoints[e];return{yyyyMmDd:e,dataValue:a||0,fill:this.colors[Bb(a,this.state.distribution)]}}}function Fb(t,e){t.labels=t.labels||[];let a=t.labels.length,i=t.datasets,s=new Array(a).fill(0);return i||(i=[{values:s}]),i.map(t=>{if(t.values){let e=t.values;e=(e=e.map(t=>isNaN(t)?0:t)).length>a?e.slice(0,a):Q(e,a-e.length,0)}else t.values=s;t.chartType||(wb.includes(e),t.chartType=e)}),t.yRegions&&t.yRegions.map(t=>{t.end({name:"",values:a.slice(0,-1),chartType:t.chartType}))};return t.yMarkers&&(i.yMarkers=[{value:0,label:""}]),t.yRegions&&(i.yRegions=[{start:0,end:0,label:""}]),i}function Hb(t,e=[],a=!0){let i=t/e.length;i<=0&&(i=1);let s=i/Va;return e.map((t,e)=>{if((t+="").length>s)if(a){e%Math.ceil(t.length/s)!=0&&(t="")}else t=s-3>0?t.slice(0,s-3)+" ...":t.slice(0,s)+"..";return t})}class N extends V{constructor(t,e){super(t,e),this.barOptions=e.barOptions||{},this.lineOptions=e.lineOptions||{},this.type=e.type||"line",this.init=1,this.setup()}setMeasures(){this.data.datasets.length<=1&&(this.config.showLegend=0,this.measures.paddings.bottom=30)}configure(t){super.configure(t),t.axisOptions=t.axisOptions||{},t.tooltipOptions=t.tooltipOptions||{},this.config.xAxisMode=t.axisOptions.xAxisMode||"span",this.config.yAxisMode=t.axisOptions.yAxisMode||"span",this.config.xIsSeries=t.axisOptions.xIsSeries||0,this.config.formatTooltipX=t.tooltipOptions.formatTooltipX,this.config.formatTooltipY=t.tooltipOptions.formatTooltipY,this.config.valuesOverPoints=t.valuesOverPoints}prepareData(t=this.data){return Fb(t,this.type)}prepareFirstData(t=this.data){return Gb(t)}calc(t=!1){this.calcXPositions(),t||this.calcYAxisParameters(this.getAllYValues(),"line"===this.type),this.makeDataByIndex()}calcXPositions(){let t=this.state,e=this.data.labels;t.datasetLength=e.length,t.unitWidth=this.width/t.datasetLength,t.xOffset=t.unitWidth/2,t.xAxis={labels:e,positions:e.map((e,a)=>la(t.xOffset+a*t.unitWidth))}}calcYAxisParameters(t,e="false"){const a=ub(t,e),i=this.height/xb(a),s=oa(a)*i,r=this.height-vb(a)*s;this.state.yAxis={labels:a,positions:a.map(t=>r-t*i),scaleMultiplier:i,zeroLine:r},this.calcDatasetPoints(),this.calcYExtremes(),this.calcYRegions()}calcDatasetPoints(){let t=this.state,e=e=>e.map(e=>G(e,t.yAxis));t.datasets=this.data.datasets.map((t,a)=>{let i=t.values,s=t.cumulativeYs||[];return{name:t.name,index:a,chartType:t.chartType,values:i,yPositions:e(i),cumulativeYs:s,cumulativeYPos:e(s)}})}calcYExtremes(){let t=this.state;this.barOptions.stacked?t.yExtremes=t.datasets[t.datasets.length-1].cumulativeYPos:(t.yExtremes=new Array(t.datasetLength).fill(9999),t.datasets.map(e=>{e.yPositions.map((e,a)=>{e(e.position=G(e.value,t.yAxis),e.options||(e.options={}),e))),this.data.yRegions&&(this.state.yRegions=this.data.yRegions.map(e=>(e.startPos=G(e.start,t.yAxis),e.endPos=G(e.end,t.yAxis),e.options||(e.options={}),e)))}getAllYValues(){let t="values";if(this.barOptions.stacked){t="cumulativeYs";let e=new Array(this.state.datasetLength).fill(0);this.data.datasets.map((a,i)=>{let s=this.data.datasets[i].values;a[t]=e=e.map((t,e)=>t+s[e])})}let e=this.data.datasets.map(e=>e[t]);return this.data.yMarkers&&e.push(this.data.yMarkers.map(t=>t.value)),this.data.yRegions&&this.data.yRegions.map(t=>{e.push([t.end,t.start])}),[].concat(...e)}setupComponents(){let t=[["yAxis",{mode:this.config.yAxisMode,width:this.width},function(){return this.state.yAxis}.bind(this)],["xAxis",{mode:this.config.xAxisMode,height:this.height},function(){let t=this.state;return t.xAxis.calcLabels=Hb(this.width,t.xAxis.labels,this.config.xIsSeries),t.xAxis}.bind(this)],["yRegions",{width:this.width,pos:"right"},function(){return this.state.yRegions}.bind(this)]],e=this.state.datasets.filter(t=>"bar"===t.chartType),a=this.state.datasets.filter(t=>"line"===t.chartType),i=e.map(t=>{let a=t.index;return["barGraph-"+t.index,{index:a,color:this.colors[a],stacked:this.barOptions.stacked,valuesOverPoints:this.config.valuesOverPoints,minHeight:this.height*Aa},function(){let t=this.state,i=t.datasets[a],s=this.barOptions.stacked,r=this.barOptions.spaceRatio||Ob,n=t.unitWidth*(1-r),o=n/(s?1:e.length),$=t.xAxis.positions.map(t=>t-n/2);s||($=$.map(t=>t+o*a));let l=new Array(t.datasetLength).fill("");this.config.valuesOverPoints&&(l=s&&i.index===t.datasets.length-1?i.cumulativeYs:i.values);let u=new Array(t.datasetLength).fill(0);return s&&(u=i.yPositions.map((t,e)=>t-i.cumulativeYPos[e])),{xPositions:$,yPositions:i.yPositions,offsets:u,labels:l,zeroLine:t.yAxis.zeroLine,barsWidth:n,barWidth:o}}.bind(this)]}),s=a.map(t=>{let e=t.index;return["lineGraph-"+t.index,{index:e,color:this.colors[e],svgDefs:this.svgDefs,heatline:this.lineOptions.heatline,regionFill:this.lineOptions.regionFill,hideDots:this.lineOptions.hideDots,hideLine:this.lineOptions.hideLine,valuesOverPoints:this.config.valuesOverPoints},function(){let t=this.state,a=t.datasets[e],i=t.yAxis.positions[0]!n.includes(t[0])||this.state[t[0]]).map(t=>{let e=o(...t);return(t[0].includes("lineGraph")||t[0].includes("barGraph"))&&this.dataUnitComponents.push(e),[t[0],e]}))}makeDataByIndex(){this.dataByIndex={};let t=this.state,e=this.config.formatTooltipX,a=this.config.formatTooltipY;t.xAxis.labels.map((i,s)=>{let r=this.state.datasets.map((t,e)=>{let i=t.values[s];return{title:t.name,value:i,yPos:t.yPositions[s],color:this.colors[e],formatted:a?a(i):i}});this.dataByIndex[s]={label:i,formattedLabel:e?e(i):i,xPos:t.xAxis.positions[s],values:r,yExtreme:t.yExtremes[s]}})}bindTooltip(){this.container.addEventListener("mousemove",t=>{let e=this.measures,a=A(this.container),i=t.pageX-a.left-E(e),s=t.pageY-a.top;sr(e)?this.mapTooltipXPosition(i):this.tip.hideTip()})}mapTooltipXPosition(t){let e=this.state;if(!e.yExtremes)return;let a=zb(t,e.xAxis.positions,!0),i=this.dataByIndex[a];this.tip.setValues(i.xPos+this.tip.offset.x,i.yExtreme+this.tip.offset.y,{name:i.formattedLabel,value:""},i.values,a),this.tip.showTip()}renderLegend(){let t=this.data;t.datasets.length>1&&(this.legendArea.textContent="",t.datasets.map((t,e)=>{let a=rb(ra*e,"0",ra,this.colors[e],t.name);this.legendArea.appendChild(a)}))}makeOverlay(){this.init?this.init=0:(this.overlayGuides&&this.overlayGuides.forEach(t=>{let e=t.overlay;e.parentNode.removeChild(e)}),this.overlayGuides=this.dataUnitComponents.map(t=>({type:t.unitType,overlay:void 0,units:t.units})),void 0===this.state.currentIndex&&(this.state.currentIndex=this.state.datasetLength-1),this.overlayGuides.map(t=>{let e=t.units[this.state.currentIndex];t.overlay=Qb[t.type](e),this.drawArea.appendChild(t.overlay)}))}updateOverlayGuides(){this.overlayGuides&&this.overlayGuides.forEach(t=>{let e=t.overlay;e.parentNode.removeChild(e)})}bindOverlay(){this.parent.addEventListener("data-select",()=>{this.updateOverlay()})}bindUnits(){this.dataUnitComponents.map(t=>{t.units.map(t=>{t.addEventListener("click",()=>{let e=t.getAttribute("data-point-index");this.setCurrentDataPoint(e)})})}),this.tip.container.addEventListener("click",()=>{let t=this.tip.container.getAttribute("data-point-index");this.setCurrentDataPoint(t)})}updateOverlay(){this.overlayGuides.map(t=>{let e=t.units[this.state.currentIndex];za[t.type](e,t.overlay)})}onLeftArrow(){this.setCurrentDataPoint(this.state.currentIndex-1)}onRightArrow(){this.setCurrentDataPoint(this.state.currentIndex+1)}getDataPoint(t=this.state.currentIndex){let e=this.state;return{index:t,label:e.xAxis.labels[t],values:e.datasets.map(e=>e.values[t])}}setCurrentDataPoint(t){let e=this.state;(t=parseInt(t))<0&&(t=0),t>=e.xAxis.labels.length&&(t=e.xAxis.labels.length-1),t!==e.currentIndex&&(e.currentIndex=t,Ha(this.parent,"data-select",this.getDataPoint()))}addDataPoint(t,e,a=this.state.datasetLength){super.addDataPoint(t,e,a),this.data.labels.splice(a,0,t),this.data.datasets.map((t,i)=>{t.values.splice(a,0,e[i])}),this.update(this.data)}removeDataPoint(t=this.state.datasetLength-1){this.data.labels.length<=1||(super.removeDataPoint(t),this.data.labels.splice(t,1),this.data.datasets.map(e=>{e.values.splice(t,1)}),this.update(this.data))}updateDataset(t,e=0){this.data.datasets[e].values=t,this.update(this.data)}updateDatasets(t){this.data.datasets.map((e,a)=>{t[a]&&(e.values=t[a])}),this.update(this.data)}}class Jb extends T{constructor(t,e){super(t,e),this.type="donut",this.initTimeout=0,this.init=1,this.setup()}configure(t){super.configure(t),this.mouseMove=this.mouseMove.bind(this),this.mouseLeave=this.mouseLeave.bind(this),this.hoverRadio=t.hoverRadio||.1,this.config.startAngle=t.startAngle||0,this.clockWise=t.clockWise||!1,this.strokeWidth=t.strokeWidth||30}calc(){super.calc();let t=this.state;this.radius=this.height>this.width?this.center.x-this.strokeWidth/2:this.center.y-this.strokeWidth/2;const{radius:e,clockWise:a}=this,i=t.slicesProperties||[];t.sliceStrings=[],t.slicesProperties=[];let s=180-this.config.startAngle;t.sliceTotals.map((r,n)=>{const o=s,$=r/t.grandTotal*ma,l=a?-$:$,u=s+=l,h=q(o,e),d=q(u,e),c=this.init&&i[n];let p,S;this.init?(p=c?c.startPosition:h,S=c?c.endPosition:h):(p=h,S=d);const v=kb(p,S,this.center,this.radius,this.clockWise);t.sliceStrings.push(v),t.slicesProperties.push({startPosition:h,endPosition:d,value:r,total:t.grandTotal,startAngle:o,endAngle:u,angle:l})}),this.init=0}setupComponents(){let t=this.state,e=[["donutSlices",{},function(){return{sliceStrings:t.sliceStrings,colors:this.colors,strokeWidth:this.strokeWidth}}.bind(this)]];this.components=new Map(e.map(t=>{let e=o(...t);return[t[0],e]}))}calTranslateByAngle(t){const{radius:e,hoverRadio:a}=this,i=q(t.startAngle+t.angle/2,e);return`translate3d(${i.x*a}px,${i.y*a}px,0)`}hoverSlice(t,e,a,i){if(!t)return;const s=this.colors[e];if(a){D(t,this.calTranslateByAngle(this.state.slicesProperties[e])),t.style.stroke=U(s,50);let a=A(this.svg),r=i.pageX-a.left+10,n=i.pageY-a.top-10,o=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[e]:this.state.labels[e])+": ",$=(100*this.state.sliceTotals[e]/this.state.grandTotal).toFixed(1);this.tip.setValues(r,n,{name:o,value:$+"%"}),this.tip.showTip()}else D(t,"translate3d(0,0,0)"),this.tip.hideTip(),t.style.stroke=s}bindTooltip(){this.container.addEventListener("mousemove",this.mouseMove),this.container.addEventListener("mouseleave",this.mouseLeave)}mouseMove(t){const e=t.target;let a=this.components.get("donutSlices").store,i=this.curActiveSliceIndex,s=this.curActiveSlice;if(a.includes(e)){let r=a.indexOf(e);this.hoverSlice(s,i,!1),this.curActiveSlice=e,this.curActiveSliceIndex=r,this.hoverSlice(e,r,!0,t)}else this.mouseLeave()}mouseLeave(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)}}const ta={bar:N,line:N,percentage:pb,heatmap:Eb,pie:qb,donut:Jb};function Lb(t="line",e,a){return"axis-mixed"===t?(a.type="line",new N(e,a)):ta[t]?new ta[t](e,a):void console.error("Undefined chart type: "+t)}class i{constructor(t,e){return Lb(e.type,t,e)}}var s={components:{Chart:i},data:function(){return{podcasterSlug:null,currentDate:new Date,currentYear:null,yearlyStats:[0],data:{labels:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],datasets:[]}}},computed:{id:function(){return this.$store.state.form.current},pageValues:function(){return this.$store.getters["form/values"](this.id)}},mounted:function(){var t=M(this.currentDate);this.podcasterSlug=this.sanitizeTitle(this.pageValues.podcastertitle),this.getStats(t)},methods:{getStats:function(t){var e=this;fetch("/api/podcaster/stats/"+this.podcasterSlug+"/episodes/yearly-downloads/"+t+"+"+(t-1),{method:"GET",headers:{"X-CSRF":panel.csrf}}).then(function(t){if(200!==t.status)throw"You are tracking your downloads, using the file method. Stats are currently available only when using mysql";return t}).then(function(t){return t.json()}).then(function(a){e.addChartData(a.stats,t)}).catch(function(t){e.error=t})},addChartData:function(t,e){var a={current:{name:e,values:[0,0,0,0,0,0,0,0,0,0,0,0]},past:{name:e-1,values:[0,0,0,0,0,0,0,0,0,0,0,0]}};t.map(function(t){t.year===e?a.current.values[t.month-1]=t.downloaded:a.past.values[t.month-1]=t.downloaded}),this.data.datasets=[a.current,a.past],this.drawChart()},drawChart:function(){new i("#chart",{title:"Monthly Episode Downloads",data:this.data,type:"line",height:350,colors:["green","dark-grey"],lineOptions:{hideLine:0,regionFill:1,hideDots:0},barOptions:{spaceRatio:.25}})},sanitizeTitle:function(t){return t.toLowerCase().replace(/e|é|è|ẽ|ẻ|ẹ|ê|ế|ề|ễ|ể|ệ/gi,"e").replace(/a|á|à|ã|ả|ạ|ă|ắ|ằ|ẵ|ẳ|ặ|â|ấ|ầ|ẫ|ẩ|ậ/gi,"a").replace(/o|ó|ò|õ|ỏ|ọ|ô|ố|ồ|ỗ|ổ|ộ|ơ|ớ|ờ|ỡ|ở|ợ/gi,"o").replace(/u|ú|ù|ũ|ủ|ụ|ư|ứ|ừ|ữ|ử|ự/gi,"u").replace(/đ/gi,"d").replace(/\s*$/g,"").replace(/\s+/g,"-")}}};if(typeof s==="function"){s=s.options}Object.assign(s,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",[_vm._v(" "+_vm._s(_vm.error)+" "),_c("div",{attrs:{"id":"chart"}})])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var wa=function(e){return e.toLowerCase().replace(/e|é|è|ẽ|ẻ|ẹ|ê|ế|ề|ễ|ể|ệ/gi,"e").replace(/a|á|à|ã|ả|ạ|ă|ắ|ằ|ẵ|ẳ|ặ|â|ấ|ầ|ẫ|ẩ|ậ/gi,"a").replace(/o|ó|ò|õ|ỏ|ọ|ô|ố|ồ|ỗ|ổ|ộ|ơ|ớ|ờ|ỡ|ở|ợ/gi,"o").replace(/u|ú|ù|ũ|ủ|ụ|ư|ứ|ừ|ữ|ử|ự/gi,"u").replace(/đ/gi,"d").replace(/\s*$/g,"").replace(/\s+/g,"-")};var e={data:function(){return{limit:10,headline:null,topEpisodes:[],error:null,podcasterSlug:null}},mounted:function(){this.podcasterSlug=wa(this.pageValues.podcastertitle),this.getStats()},created:function(){var t=this;this.load().then(function(e){t.headline=e.headline})},computed:{id:function(){return this.$store.state.form.current},pageValues:function(){return this.$store.getters["form/values"](this.id)}},methods:{getStats:function(){var t=this;fetch("/api/podcaster/stats/"+this.podcasterSlug+"/top/"+this.limit,{method:"GET",headers:{"X-CSRF":panel.csrf}}).then(function(t){if(200!==t.status)throw"You are tracking your downloads, using the file method. Stats are currently available only when using mysql";return t}).then(function(t){return t.json()}).then(function(e){t.topEpisodes=t.computeStats(e.stats)}).catch(function(e){t.error=e})},computeStats:function(t){return t.map(function(t){return{title:t.episode.replace(/-/g," "),downloads:t.downloaded}})}}};if(typeof e==="function"){e=e.options}Object.assign(e,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("section",{staticClass:"k-modified-section"},[_c("k-text",[_vm._v(_vm._s(_vm.error))]),_vm._v(" "),_c("k-headline",[_vm._v(_vm._s(_vm.headline))]),_vm._v(" "),_c("table",{attrs:{"id":"topTen"}},_vm._l(_vm.topEpisodes,function(episode){return _c("tr",[_c("td",[_vm._v(_vm._s(episode.downloads))]),_vm._v(" "),_c("td",[_vm._v(_vm._s(episode.title))])])}),0)],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var K={components:{Chart:i},data:function(){return{podcasterSlug:null,currentDate:new Date,currentYear:null,yearlyStats:[0],data:{labels:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],datasets:[]}}},computed:{id:function(){return this.$store.state.form.current},pageValues:function(){return this.$store.getters["form/values"](this.id)}},mounted:function(){var t=M(this.currentDate);this.podcasterSlug=wa(this.pageValues.podcastertitle),this.getStats(t)},methods:{getStats:function(t){var e=this;fetch("/api/podcaster/stats/"+this.podcasterSlug+"/feed/yearly-downloads/"+t+"+"+(t-1),{method:"GET",headers:{"X-CSRF":panel.csrf}}).then(function(t){if(200!==t.status)throw"You are tracking your downloads, using the file method. Stats are currently available only when using mysql";return t}).then(function(t){return t.json()}).then(function(a){e.addChartData(a.stats,t)}).catch(function(t){e.error=t})},addChartData:function(t,e){var a={current:{name:e,values:[0,0,0,0,0,0,0,0,0,0,0,0]},past:{name:e-1,values:[0,0,0,0,0,0,0,0,0,0,0,0]}};t.map(function(t){t.year===e?a.current.values[t.month-1]=t.downloaded:a.past.values[t.month-1]=t.downloaded}),this.data.datasets=[a.current,a.past],this.drawChart()},drawChart:function(){new i("#feedChart",{title:"Monthly Feed Downloads",data:this.data,type:"line",height:350,colors:["blue","dark-grey"],lineOptions:{hideLine:0,regionFill:1,hideDots:0},barOptions:{spaceRatio:.25}})}}};if(typeof K==="function"){K=K.options}Object.assign(K,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("div",[_vm._v(" "+_vm._s(_vm.error)+" "),_c("div",{attrs:{"id":"feedChart"}})])};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());var H={data:function(){return{headline:null,logs:[],feedItems:[],numItems:0,numRemain:0,numDownload:0,failed:0,feedName:"",currentEpisode:""}},created:function(){},mounted:function(){this.headline=this.pageValues.podcasterWizardSrcFeed},computed:{id:function(){return this.$store.state.form.current},pageValues:function(){return this.$store.getters["form/values"](this.id)}},methods:{startImport:function(e){var t=this.pageValues.podcasterwizardsrcfeed;this.feedName=t,e.target.style="display: none",document.querySelector(".log").style="display: block",this.getFeed(t)},startAudioDownload:function(){this.feedItems.length>0?this.downloadAudio():this.logs.push({id:3,msg:"done"})},getFeed:function(e){var t=this;fetch("/api/podcaster/wizard/checkfeed",{method:"GET",headers:{"X-CSRF":panel.csrf,"X-FEED-URI":e}}).then(function(e){return e.json()}).then(function(e){"error"===e.status&&t.failed++;var i=void 0!==e.channel.item.length?e.channel.item.length:1;t.feedName=e.channel.title,t.numItems=i,t.numRemain=i,t.numDownload=i,t.createFeed(e.channel),t.importEpisodes(e.channel.item)}).catch(function(e){t.error=e,t.failed++})},createFeed:function(e){var t={title:e.title,link:e.link,description:e.description,itunessubtitle:e.itunessubtitle,ituneskeywords:e.ituneskeywords,itunesseason:e.itunesseason,itunesexplicit:e.itunesexplicit,itunesblock:e.itunesblock,itunestype:e.itunestype,language:e.language,copyright:e.copyright};fetch("/api/podcaster/wizard/createFeed",{method:"POST",headers:{"X-CSRF":panel.csrf,"X-TARGET-PAGE":this.pageValues.podcasterwizarddestination[0].id},body:JSON.stringify(t)}).catch(function(e){console.log(e)})},importEpisodes:function(e){if(void 0===e.length){e.title,e.link,e.pubDate,e.description,e.itunessubtitle,e.itunessummary,e.itunesduration,e.itunesseason,e.itunesexplicit,e.itunesblock,e.enclosure["@attributes"].url;this.createEpisode(e)}else for(var t=e.length-1;t>=0;t--)this.createEpisode(e[t])},createEpisode:function(e){var t=this,i={title:e.title,link:e.link,pubDate:e.pubDate,description:e.description,itunessubtitle:e.itunessubtitle,itunessummary:e.itunessummary,itunesduration:e.itunesduration,itunesseason:e.itunesseason,itunesexplicit:e.itunesexplicit,itunesblock:e.itunesblock,file:e.enclosure["@attributes"].url};fetch("/api/podcaster/wizard/createEpisode",{method:"POST",headers:{"X-CSRF":panel.csrf,"X-TARGET-PAGE":this.pageValues.podcasterwizarddestination[0].id,"X-PAGE-TEMPLATE":this.pageValues.podcasterwizardtemplate,"X-PAGE-STATUS":this.pageValues.podcasterwizardpagestatus},body:JSON.stringify(i)}).then(function(e){return e.json()}).then(function(i){t.currentEpisode=e.title,void 0!==i.status?t.numFailed++:(t.feedItems.push({title:i.title,slug:i.slug,file:i.file}),t.numRemain--,0===t.numRemain&&t.startAudioDownload())}).catch(function(e){console.log(e),t.numFailed++})},downloadAudio:function(){var e=this,t=this.feedItems[0].slug,i=this.feedItems[0].file;this.feedItems.shift(),fetch("/api/podcaster/wizard/createFile",{method:"POST",headers:{"X-CSRF":panel.csrf,"X-TARGET-PAGE":t},body:JSON.stringify({file:i})}).then(function(e){return e.json()}).then(function(t){void 0!==t.status?e.failed++:e.numDownload=e.feedItems.length,e.startAudioDownload()}).catch(function(t){console.log(t),e.failed++})}}};if(typeof H==="function"){H=H.options}Object.assign(H,function(){var render=function(){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c("section",{staticClass:"k-modified-section podcaster-import-wizard"},[_c("k-headline",[_vm._v(_vm._s(_vm.headline))]),_vm._v(" "),_c("div",{staticClass:"log"},[_c("div",{staticClass:"important"},[_vm._v("Do not close this page until the import is finished!")]),_vm._v(" "),_c("div",{staticClass:"currentState"},[_vm._v("Processing \xBB"+_vm._s(_vm.currentEpisode)+"\xAB")]),_vm._v(" "),_c("div",[_vm._v("Trying to parse \xBB"+_vm._s(_vm.feedName)+"\xAB")]),_vm._v(" "),_c("div",[_vm._v("Found "+_vm._s(_vm.numItems)+" episodes in feed")]),_vm._v(" "),_c("div",[_vm._v("creating pages, "),_c("strong",[_vm._v(_vm._s(_vm.numRemain))]),_vm._v(" remaining")]),_vm._v(" "),_c("div",[_c("strong",[_vm._v(_vm._s(_vm.numDownload))]),_vm._v(" audio downloads remaining")]),_vm._v(" "),_c("div",[_vm._v(_vm._s(_vm.failed)+" failed attempts")])]),_vm._v(" "),_c("button",{staticClass:"k-button start-import",on:{"click":_vm.startImport}},[_vm._v("Start import")])],1)};var staticRenderFns=[];return{render:render,staticRenderFns:staticRenderFns,_compiled:true,_scopeId:null,functional:undefined}}());panel.plugin("mauricerenck/podcaster",{sections:{podcasterEpisodeStats:t,podcasterYearlyGraph:s,podcasterTopTen:e,podcasterFeedStats:K,podcasterWizard:H}});})(); \ No newline at end of file diff --git a/index.php b/index.php index 675d8a7..a0067f5 100644 --- a/index.php +++ b/index.php @@ -16,6 +16,7 @@ 'Plugin\Podcaster\PodcasterStatsMySql' => 'utils/PodcasterStatsMysql.php', 'Plugin\Podcaster\PodcasterStatsFile' => 'utils/PodcasterStatsFile.php', 'Plugin\Podcaster\PodcasterStatsPodTrac' => 'utils/PodcasterStatsPodTrac.php', + 'Plugin\Podcaster\PodcasterWizard' => 'utils/PodcasterWizard.php', 'Plugin\Podcaster\PiwikTracker' => 'lib/PiwikTracker.php' ], __DIR__); @@ -26,6 +27,7 @@ ], 'blueprints' => [ 'pages/podcasterfeed' => __DIR__ . '/blueprints/pages/podcasterfeed.yml', + 'pages/podcasterwizard' => __DIR__ . '/blueprints/pages/podcasterwizard.yml', 'tabs/podcasterepisode' => __DIR__ . '/blueprints/tabs/episode.yml', 'files/podcaster-episode' => __DIR__ . '/blueprints/files/podcaster-episode.yml' ], @@ -57,6 +59,13 @@ return $headline; } ] + ], + 'podcasterWizard' => [ + 'props' => [ + 'headline' => function ($headline = 'Feed Downloads') { + return $headline; + } + ] ] ], 'snippets' => [ @@ -154,54 +163,6 @@ } ] ], - 'api' => [ - 'routes' => [ - [ - 'pattern' => 'podcaster/stats/(:any)/year/(:num)/month/(:num)', - 'action' => function ($podcast, $year, $month) { - if (option('mauricerenck.podcaster.statsInternal') === false || option('mauricerenck.podcaster.statsType') === 'file') { - $errorMessage = ['error' => 'cannot use stats on file method, use mysql version instead']; - echo new Response(json_encode($errorMessage), 'application/json', 501); - } - - $podcasterStats = new PodcasterStats(); - $stats = $podcasterStats->getEpisodeStatsOfMonth($podcast, $year, $month); - return [ - 'stats' => $stats - ]; - } - ], - [ - 'pattern' => 'podcaster/stats/(:any)/(:any)/yearly-downloads/(:any)', - 'action' => function ($podcast, $type, $year) { - if (option('mauricerenck.podcaster.statsInternal') === false || option('mauricerenck.podcaster.statsType') === 'file') { - $errorMessage = ['error' => 'cannot use stats on file method, use mysql version instead']; - echo new Response(json_encode($errorMessage), 'application/json', 501); - } - - $podcasterStats = new PodcasterStats(); - $stats = $podcasterStats->getDownloadsOfYear($podcast, $year, $type); - return [ - 'stats' => $stats - ]; - } - ], - [ - 'pattern' => 'podcaster/stats/(:any)/top/(:num)', - 'action' => function ($podcast, $limit) { - if (option('mauricerenck.podcaster.statsInternal') === false || option('mauricerenck.podcaster.statsType') === 'file') { - $errorMessage = ['error' => 'cannot use stats on file method, use mysql version instead']; - echo new Response(json_encode($errorMessage), 'application/json', 501); - } - - $podcasterStats = new PodcasterStats(); - $stats = $podcasterStats->getTopDownloads($podcast, $limit); - return [ - 'stats' => $stats - ]; - } - ] - ] - ], + 'api' => require_once(__DIR__ . '/config/api.php'), 'hooks' => require_once(__DIR__ . '/config/hooks.php') ]); diff --git a/package.json b/package.json index 32c9263..5274146 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "podcaster", - "version": "1.1.4", + "version": "1.2.0", "description": "Theme", "main": "index.js", "author": "Maurice Renck", diff --git a/src/components/Wizard.vue b/src/components/Wizard.vue new file mode 100644 index 0000000..42bc7f3 --- /dev/null +++ b/src/components/Wizard.vue @@ -0,0 +1,256 @@ + + + + + + \ No newline at end of file diff --git a/src/index.js b/src/index.js index 100098a..209c53f 100644 --- a/src/index.js +++ b/src/index.js @@ -2,13 +2,14 @@ import Episode from './components/Episode.vue' import YearGraph from './components/YearGraph.vue' import TopTen from './components/TopTen.vue' import FeedStats from './components/FeedStats.vue' - +import Wizard from './components/Wizard.vue' panel.plugin('mauricerenck/podcaster', { sections: { 'podcasterEpisodeStats': Episode, 'podcasterYearlyGraph': YearGraph, 'podcasterTopTen': TopTen, - 'podcasterFeedStats': FeedStats + 'podcasterFeedStats': FeedStats, + 'podcasterWizard': Wizard } }); \ No newline at end of file diff --git a/templates/podcasterfeed.php b/templates/podcasterfeed.php index 4058925..03b4ae5 100644 --- a/templates/podcasterfeed.php +++ b/templates/podcasterfeed.php @@ -89,6 +89,7 @@ printFieldValue('episode', 'itunes:summary', 'podcasterDescription'); ?> getAudioDuration($episode); ?> printFieldValue('episode', 'itunes:season', 'podcasterSeason'); ?> + printFieldValue('episode', 'itunes:episode', 'podcasterEpisode'); ?> printBoolValue('episode', 'itunes:explicit', 'podcasterExplizit'); ?> printBoolValue('episode', 'itunes:block', 'podcasterBlock'); ?> diff --git a/tmp/.gitkeep b/tmp/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/utils/PodcasterWizard.php b/utils/PodcasterWizard.php new file mode 100644 index 0000000..8f65f71 --- /dev/null +++ b/utils/PodcasterWizard.php @@ -0,0 +1,41 @@ +$field)) { + return $data->$field; + } + + return null; + } + + public function getPageSlug($link, $title) + { + if (is_null($link)) { + return Str::slug($title); + } + + return array_slice(explode('/', rtrim($link, '/')), -1)[0]; + } + + public function downloadMp3($url, $filename) + { + $fp = fopen(kirby()->root('plugins') . '/kirby-podcaster/tmp/' . $filename, 'w+'); + + $ch = curl_init(); + $timeout = 5; + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_FILE, $fp); + curl_exec($ch); + curl_close($ch); + fclose($fp); + } +} diff --git a/vendor/autoload.php b/vendor/autoload.php index 5760eff..1406f2d 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit660325cad110ed14730f0fd0071c5b55::getLoader(); +return ComposerAutoloaderInit671e7f7f4385391330dc48edb88c0873::getLoader(); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index d67d693..9b06f0e 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -12,5 +12,6 @@ 'd6802096f93b9e496e07bfb10dc2a836' => $baseDir . '/utils/PodcasterStatsFile.php', '7327ddc355eb971a6be2a8e77299663d' => $baseDir . '/utils/PodcasterStatsMysql.php', 'cd2cab7c530e4a5617b1e4b4473bacd3' => $baseDir . '/utils/PodcasterStatsPodTrac.php', + '4ab2f40a111a21ba0af2a845a2d6ca6a' => $baseDir . '/utils/PodcasterWizard.php', 'afc6d2f72e0b3c2400404a46eb6dd23d' => $baseDir . '/lib/PiwikTracker.php', ); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 4e8939f..84ba65b 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit660325cad110ed14730f0fd0071c5b55 +class ComposerAutoloaderInit671e7f7f4385391330dc48edb88c0873 { private static $loader; @@ -19,15 +19,15 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit660325cad110ed14730f0fd0071c5b55', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit671e7f7f4385391330dc48edb88c0873', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit660325cad110ed14730f0fd0071c5b55', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit671e7f7f4385391330dc48edb88c0873', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit660325cad110ed14730f0fd0071c5b55::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit671e7f7f4385391330dc48edb88c0873::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ public static function getLoader() $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit660325cad110ed14730f0fd0071c5b55::$files; + $includeFiles = Composer\Autoload\ComposerStaticInit671e7f7f4385391330dc48edb88c0873::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire660325cad110ed14730f0fd0071c5b55($fileIdentifier, $file); + composerRequire671e7f7f4385391330dc48edb88c0873($fileIdentifier, $file); } return $loader; } } -function composerRequire660325cad110ed14730f0fd0071c5b55($fileIdentifier, $file) +function composerRequire671e7f7f4385391330dc48edb88c0873($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 7b92fd1..b5d0a66 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit660325cad110ed14730f0fd0071c5b55 +class ComposerStaticInit671e7f7f4385391330dc48edb88c0873 { public static $files = array ( '8df3dfd1f38b5f54e639d8aee9e2bd5b' => __DIR__ . '/../..' . '/utils/PodcasterUtils.php', @@ -13,6 +13,7 @@ class ComposerStaticInit660325cad110ed14730f0fd0071c5b55 'd6802096f93b9e496e07bfb10dc2a836' => __DIR__ . '/../..' . '/utils/PodcasterStatsFile.php', '7327ddc355eb971a6be2a8e77299663d' => __DIR__ . '/../..' . '/utils/PodcasterStatsMysql.php', 'cd2cab7c530e4a5617b1e4b4473bacd3' => __DIR__ . '/../..' . '/utils/PodcasterStatsPodTrac.php', + '4ab2f40a111a21ba0af2a845a2d6ca6a' => __DIR__ . '/../..' . '/utils/PodcasterWizard.php', 'afc6d2f72e0b3c2400404a46eb6dd23d' => __DIR__ . '/../..' . '/lib/PiwikTracker.php', ); @@ -121,9 +122,9 @@ class ComposerStaticInit660325cad110ed14730f0fd0071c5b55 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit660325cad110ed14730f0fd0071c5b55::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit660325cad110ed14730f0fd0071c5b55::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit660325cad110ed14730f0fd0071c5b55::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit671e7f7f4385391330dc48edb88c0873::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit671e7f7f4385391330dc48edb88c0873::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit671e7f7f4385391330dc48edb88c0873::$classMap; }, null, ClassLoader::class); }