From b48d4328ec8ef4b2be6bca4d8c006bcb2ca824ad Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Tue, 6 Feb 2024 12:13:30 +0200 Subject: [PATCH 01/20] feat: add Live Preview blueprint to showcase demo --- assets/blueprints/blueprint.json | 33 ++++++++ js/setup-wizard.js | 77 ++++++++++++----- templates/setup-wizard.php | 138 +++++++++++++++++-------------- 3 files changed, 164 insertions(+), 84 deletions(-) create mode 100644 assets/blueprints/blueprint.json diff --git a/assets/blueprints/blueprint.json b/assets/blueprints/blueprint.json new file mode 100644 index 000000000..ddcca4f5c --- /dev/null +++ b/assets/blueprints/blueprint.json @@ -0,0 +1,33 @@ +{ + "$schema": "https://playground.wordpress.net/blueprint-schema.json", + "_comment1": "Set the Wizard Setup page as landing page with preview environment (which disable distractions)", + "landingPage": "/wp-admin/admin.php?page=visualizer-setup-wizard&env=preview", + "_comment2": "Preferred WordPress instance specifications", + "preferredVersions": { + "php": "8.0", + "wp": "latest" + }, + "features": { + "_comment3.1": "Allow networking for internet access", + "networking": true + }, + "steps": [ + { + "_comment4.1": "Login to the WordPress instance", + "step": "login", + "username": "admin", + "password": "password" + }, + { + "_comment4.2": "Install the Visualizer plugin", + "step": "installPlugin", + "pluginZipFile": { + "resource": "wordpress.org/plugins", + "slug": "visualizer" + }, + "options": { + "activate": true + } + } + ] +} diff --git a/js/setup-wizard.js b/js/setup-wizard.js index ed0aa7fee..823628a62 100644 --- a/js/setup-wizard.js +++ b/js/setup-wizard.js @@ -7,6 +7,48 @@ */ /* jshint unused:false */ jQuery(function ($) { + + /** + * Check if the user is in live preview mode. + * Live Preview is used in WordPress Playground to test the plugin. + * Use this check to deactivate any process that does not showcase the plugin features (e.g. subscription to the newsletter, etc.) + * + * @type {boolean} + */ + const isLivePreview = window.location.search.includes('env=preview'); + + /** + * Redirect to draft page after subscribe (optional). + * + * @param {Object} postData - Post data. + */ + const goToDraftPage = function ( postData = {} ) { + postData ??= {}; + postData.action ??= 'visualizer_wizard_step_process'; + postData.security ??= visualizerSetupWizardData.ajax.security; + postData.step ??= 'step_subscribe'; + + // Subscribe the user using the email if provided. Redirect to the draft page. + $.post(visualizerSetupWizardData.ajax.url, postData, function (res) { + + // Toggle the redirect popup. + $('.redirect-popup').find('h3.popup-title').html(res.message); + $('.redirect-popup').show(); + + if (1 === res.status) { + setTimeout(function () { + window.location.href = res.redirect_to; + }, 5000); + } else { + $('.redirect-popup').hide(); + } + currentStep.find('.spinner').removeClass('is-active'); + }).fail(function () { + $('.redirect-popup').hide(); + currentStep.find('.spinner').removeClass('is-active'); + }); + } + var provideContent = function(id, stepDirection, stepPosition, selStep, callback) { // Import chart data. if ( 1 == id ) { @@ -119,6 +161,7 @@ jQuery(function ($) { ".btn-primary:not(.next-btn,.vz-create-page,.vz-subscribe)", function (e) { var stepNumber = $(this).data("step_number"); + switch (stepNumber) { case 1: if ($(".vz-radio-btn").is(":checked")) { @@ -126,10 +169,14 @@ jQuery(function ($) { } break; case 3: - var urlParams = new URLSearchParams(window.location.search); - urlParams.set('preview_chart', Date.now()); - window.location.hash = "#step-3"; - window.location.search = urlParams; + if ( isLivePreview ) { + $('#smartwizard').smartWizard('next'); + } else { + var urlParams = new URLSearchParams(window.location.search); + urlParams.set('preview_chart', Date.now()); + window.location.hash = "#step-3"; + window.location.search = urlParams; + } break; case 4: $('#step-4').find('.spinner').addClass('is-active'); @@ -181,7 +228,11 @@ jQuery(function ($) { }, function (res) { if (res.status > 0) { - $("#smartwizard").smartWizard("next"); + if ( isLivePreview ) { + goToDraftPage(); + } else { + $("#smartwizard").smartWizard("next"); + } } _this.next(".spinner").removeClass("is-active"); } @@ -235,21 +286,7 @@ jQuery(function ($) { var currentStep = $( '.vz-wizard-wrap .tab-pane:last-child' ); currentStep.find(".spinner").addClass("is-active"); - $.post(visualizerSetupWizardData.ajax.url, postData, function (res) { - $('.redirect-popup').find('h3.popup-title').html(res.message); - $('.redirect-popup').show(); - if (1 === res.status) { - setTimeout(function () { - window.location.href = res.redirect_to; - }, 5000); - } else { - $('.redirect-popup').hide(); - } - currentStep.find('.spinner').removeClass('is-active'); - }).fail(function () { - $('.redirect-popup').hide(); - currentStep.find('.spinner').removeClass('is-active'); - }); + goToDraftPage( postData ); e.preventDefault(); }); diff --git a/templates/setup-wizard.php b/templates/setup-wizard.php index 6ed4cc40c..e0f978340 100644 --- a/templates/setup-wizard.php +++ b/templates/setup-wizard.php @@ -17,20 +17,23 @@ $chart_id = ! empty( $this->wizard_data['chart_id'] ) ? (int) $this->wizard_data['chart_id'] : ''; $wp_optimole_active = is_plugin_active( 'optimole-wp/optimole-wp.php' ); $last_step_number = 5; + +// Check if we are in the Live Preview which is used to showcase only the plugin features without any other distractions. Ideal for marketing purposes (like Live Preview on WordPress.org or on the plugin's website) +$is_live_preview = ! empty( $_GET['env'] ) ? ( 'preview' === sanitize_key( $_GET['env'] ) ) : false; + ?>
@@ -53,25 +56,27 @@ class="dashicons dashicons-arrow-left-alt"> 3 - - - - - - - + + + + + + + + +
@@ -218,7 +223,7 @@ class="btn btn-secondary" target="_blank">
- + >
@@ -260,7 +268,7 @@ class="btn btn-secondary" target="_blank">
- +
@@ -313,41 +321,43 @@ class="btn btn-secondary" target="_blank">
- -
-
-
-
-

-

+ + +
+
+
+
+

+

+
-
-
-
-
-
-
-

-
- +
+
+
+
+
+

+
+ +
+
+
+
-
-
-
-
-
-
- - - +
+
+ + + +
-
+
From b7d35755af0058d01b45ba5f12df658a30610002 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Tue, 6 Feb 2024 12:28:59 +0200 Subject: [PATCH 02/20] refactor: change message for third step live preview --- templates/setup-wizard.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/setup-wizard.php b/templates/setup-wizard.php index e0f978340..bd9d36c9d 100644 --- a/templates/setup-wizard.php +++ b/templates/setup-wizard.php @@ -236,7 +236,8 @@ class="btn btn-secondary" target="_blank"> -

+

+

From 815d7098630a23fd03fb412ba134722fa3f33325 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Fri, 9 Feb 2024 14:39:17 +0200 Subject: [PATCH 03/20] fix: condition and HTML structure --- templates/setup-wizard.php | 121 ++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 61 deletions(-) diff --git a/templates/setup-wizard.php b/templates/setup-wizard.php index bd9d36c9d..dc6803339 100644 --- a/templates/setup-wizard.php +++ b/templates/setup-wizard.php @@ -234,26 +234,25 @@ class="btn btn-secondary" target="_blank">
- - -

-

- -

-
- -
- -
- - + + +

+

+ +

+
+
+ +
+ +
@@ -270,60 +269,60 @@ class="btn btn-secondary" target="_blank">
-
-
-
-
-

-

+
+
+
+
+

+

+
-
-
-
-
- -
-
-
-
- +
+
+
+ +
+
+
+
+ +
+
- -
-
-
-
    -
  • -
    - -
    -
    -
    -

    -
    -
  • -
-
-
- - +
+ + +
-
- +
From 19e1c57e569550c2e7a0d57fa65a3c3f32dc19ee Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Fri, 9 Feb 2024 14:43:24 +0200 Subject: [PATCH 04/20] chore: php format --- templates/setup-wizard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/setup-wizard.php b/templates/setup-wizard.php index dc6803339..ad86c557b 100644 --- a/templates/setup-wizard.php +++ b/templates/setup-wizard.php @@ -322,7 +322,7 @@ class="btn btn-secondary" target="_blank">
- +
From eb34953705c8b38224aca1089a9cb1ab51886023 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Tue, 13 Feb 2024 14:30:12 +0200 Subject: [PATCH 05/20] fix: load necessary chart packages for Gutenberg --- classes/Visualizer/Gutenberg/src/Components/ChartRender.js | 4 +++- classes/Visualizer/Gutenberg/src/Components/ChartSelect.js | 4 +++- classes/Visualizer/Gutenberg/src/Components/Charts.js | 4 +++- classes/Visualizer/Gutenberg/src/utils.js | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/classes/Visualizer/Gutenberg/src/Components/ChartRender.js b/classes/Visualizer/Gutenberg/src/Components/ChartRender.js index 4ef0b922e..606cae942 100644 --- a/classes/Visualizer/Gutenberg/src/Components/ChartRender.js +++ b/classes/Visualizer/Gutenberg/src/Components/ChartRender.js @@ -7,7 +7,7 @@ import DataTable from './DataTable.js'; import merge from 'merge'; -import { compact, formatDate, isValidJSON, formatData } from '../utils.js'; +import { compact, formatDate, isValidJSON, formatData, googleChartPackages } from '../utils.js'; /** * WordPress dependencies @@ -108,6 +108,7 @@ class ChartRender extends Component { } height="500px" formatters={ formatData( data ) } + chartPackages={ googleChartPackages } /> ) : ( ) ) } diff --git a/classes/Visualizer/Gutenberg/src/Components/ChartSelect.js b/classes/Visualizer/Gutenberg/src/Components/ChartSelect.js index fc7bafc4c..9db1b5735 100644 --- a/classes/Visualizer/Gutenberg/src/Components/ChartSelect.js +++ b/classes/Visualizer/Gutenberg/src/Components/ChartSelect.js @@ -23,7 +23,7 @@ import PanelButton from './PanelButton.js'; import merge from 'merge'; -import { compact, formatDate, isValidJSON, formatData } from '../utils.js'; +import { compact, formatDate, isValidJSON, formatData, googleChartPackages } from '../utils.js'; /** * WordPress dependencies @@ -172,6 +172,7 @@ class ChartSelect extends Component { } height="500px" formatters={ formatData( data ) } + chartPackages={ googleChartPackages } /> ) : ( ) ) } diff --git a/classes/Visualizer/Gutenberg/src/Components/Charts.js b/classes/Visualizer/Gutenberg/src/Components/Charts.js index 5e0ce7032..1482fafd5 100644 --- a/classes/Visualizer/Gutenberg/src/Components/Charts.js +++ b/classes/Visualizer/Gutenberg/src/Components/Charts.js @@ -5,7 +5,7 @@ import { Chart } from 'react-google-charts'; import DataTable from './DataTable.js'; -import { formatDate, filterCharts, formatData } from '../utils.js'; +import { formatDate, filterCharts, formatData, googleChartPackages } from '../utils.js'; /** * WordPress dependencies @@ -156,6 +156,7 @@ class Charts extends Component { columns={ data['visualizer-series'] } options={ filterCharts( data['visualizer-settings']) } formatters={ formatData( data ) } + chartPackages={ googleChartPackages } /> ) : ( ) ) } diff --git a/classes/Visualizer/Gutenberg/src/utils.js b/classes/Visualizer/Gutenberg/src/utils.js index 9e0ff4c4c..46c72b5c2 100644 --- a/classes/Visualizer/Gutenberg/src/utils.js +++ b/classes/Visualizer/Gutenberg/src/utils.js @@ -189,3 +189,6 @@ export const getColorCode = ( color ) => { } return color; }; + +// Google Chart Packages +export const googleChartPackages = [ 'corechart', 'geochart', 'gauge', 'table', 'timeline', 'controls' ]; From d31a486d5ffcd9b18879913da5ddfc0cddc1c569 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Tue, 13 Feb 2024 14:30:47 +0200 Subject: [PATCH 06/20] chore: js build --- classes/Visualizer/Gutenberg/build/block.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Visualizer/Gutenberg/build/block.js b/classes/Visualizer/Gutenberg/build/block.js index 82b9b4412..83ce4980b 100644 --- a/classes/Visualizer/Gutenberg/build/block.js +++ b/classes/Visualizer/Gutenberg/build/block.js @@ -251,9 +251,9 @@ function s(){if(n)return e;n=1;const t=[{key:"ZiB",factor:Math.pow(1024,7)},{key * * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday */ -!function(t,r){"use strict";var a;try{a=n(0)}catch(e){}e.exports=function(e){var t="function"==typeof e,n=!!window.addEventListener,r=window.document,a=window.setTimeout,o=function(e,t,r,a){n?e.addEventListener(t,r,!!a):e.attachEvent("on"+t,r)},i=function(e,t,r,a){n?e.removeEventListener(t,r,!!a):e.detachEvent("on"+t,r)},s=function(e,t,n){var a;r.createEvent?((a=r.createEvent("HTMLEvents")).initEvent(t,!0,!1),a=_(a,n),e.dispatchEvent(a)):r.createEventObject&&(a=r.createEventObject(),a=_(a,n),e.fireEvent("on"+t,a))},l=function(e,t){return-1!==(" "+e.className+" ").indexOf(" "+t+" ")},u=function(e){return/Array/.test(Object.prototype.toString.call(e))},c=function(e){return/Date/.test(Object.prototype.toString.call(e))&&!isNaN(e.getTime())},d=function(e){var t=e.getDay();return 0===t||6===t},p=function(e){return e%4==0&&e%100!=0||e%400==0},m=function(e,t){return[31,p(e)?29:28,31,30,31,30,31,31,30,31,30,31][t]},h=function(e){c(e)&&e.setHours(0,0,0,0)},f=function(e,t){return e.getTime()===t.getTime()},_=function(e,t,n){var r,a;for(r in t)(a=void 0!==e[r])&&"object"==typeof t[r]&&null!==t[r]&&void 0===t[r].nodeName?c(t[r])?n&&(e[r]=new Date(t[r].getTime())):u(t[r])?n&&(e[r]=t[r].slice(0)):e[r]=_({},t[r],n):!n&&a||(e[r]=t[r]);return e},y=function(e){return e.month<0&&(e.year-=Math.ceil(Math.abs(e.month)/12),e.month+=12),e.month>11&&(e.year+=Math.floor(Math.abs(e.month)/12),e.month-=12),e},b={field:null,bound:void 0,position:"bottom left",reposition:!0,format:"YYYY-MM-DD",defaultDate:null,setDefaultDate:!1,firstDay:0,formatStrict:!1,minDate:null,maxDate:null,yearRange:10,showWeekNumber:!1,minYear:0,maxYear:9999,minMonth:void 0,maxMonth:void 0,startRange:null,endRange:null,isRTL:!1,yearSuffix:"",showMonthAfterYear:!1,showDaysInNextAndPreviousMonths:!1,numberOfMonths:1,mainCalendar:"left",container:void 0,i18n:{previousMonth:"Previous Month",nextMonth:"Next Month",months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},theme:null,onSelect:null,onOpen:null,onClose:null,onDraw:null},g=function(e,t,n){for(t+=e.firstDay;t>=7;)t-=7;return n?e.i18n.weekdaysShort[t]:e.i18n.weekdays[t]},v=function(e){var t=[],n="false";if(e.isEmpty){if(!e.showDaysInNextAndPreviousMonths)return'';t.push("is-outside-current-month")}return e.isDisabled&&t.push("is-disabled"),e.isToday&&t.push("is-today"),e.isSelected&&(t.push("is-selected"),n="true"),e.isInRange&&t.push("is-inrange"),e.isStartRange&&t.push("is-startrange"),e.isEndRange&&t.push("is-endrange"),'"},w=function(e,t){return""+(t?e.reverse():e).join("")+""},M=function(e,t,n,r,a,o){var i,s,l,c,d,p=e._o,m=n===p.minYear,h=n===p.maxYear,f='
',_=!0,y=!0;for(l=[],i=0;i<12;i++)l.push('");for(c='
'+p.i18n.months[r]+'
",u(p.yearRange)?(i=p.yearRange[0],s=p.yearRange[1]+1):(i=n-p.yearRange,s=1+n+p.yearRange),l=[];i=p.minYear&&l.push('");return d='
'+n+p.yearSuffix+'
",p.showMonthAfterYear?f+=d+c:f+=c+d,m&&(0===r||p.minMonth>=r)&&(_=!1),h&&(11===r||p.maxMonth<=r)&&(y=!1),0===t&&(f+='"),t===e._o.numberOfMonths-1&&(f+='"),f+"
"},L=function(i){var s=this,u=s.config(i);s._onMouseDown=function(e){if(s._v){var t=(e=e||window.event).target||e.srcElement;if(t)if(l(t,"is-disabled")||(!l(t,"pika-button")||l(t,"is-empty")||l(t.parentNode,"is-disabled")?l(t,"pika-prev")?s.prevMonth():l(t,"pika-next")&&s.nextMonth():(s.setDate(new Date(t.getAttribute("data-pika-year"),t.getAttribute("data-pika-month"),t.getAttribute("data-pika-day"))),u.bound&&a((function(){s.hide(),u.field&&u.field.blur()}),100))),l(t,"pika-select"))s._c=!0;else{if(!e.preventDefault)return e.returnValue=!1,!1;e.preventDefault()}}},s._onChange=function(e){var t=(e=e||window.event).target||e.srcElement;t&&(l(t,"pika-select-month")?s.gotoMonth(t.value):l(t,"pika-select-year")&&s.gotoYear(t.value))},s._onKeyChange=function(e){if(e=e||window.event,s.isVisible())switch(e.keyCode){case 13:case 27:u.field.blur();break;case 37:e.preventDefault(),s.adjustDate("subtract",1);break;case 38:s.adjustDate("subtract",7);break;case 39:s.adjustDate("add",1);break;case 40:s.adjustDate("add",7)}},s._onInputChange=function(n){var r;n.firedBy!==s&&(r=t?(r=e(u.field.value,u.format,u.formatStrict))&&r.isValid()?r.toDate():null:new Date(Date.parse(u.field.value)),c(r)&&s.setDate(r),s._v||s.show())},s._onInputFocus=function(){s.show()},s._onInputClick=function(){s.show()},s._onInputBlur=function(){var e=r.activeElement;do{if(l(e,"pika-single"))return}while(e=e.parentNode);s._c||(s._b=a((function(){s.hide()}),50)),s._c=!1},s._onClick=function(e){var t=(e=e||window.event).target||e.srcElement,r=t;if(t){!n&&l(t,"pika-select")&&(t.onchange||(t.setAttribute("onchange","return;"),o(t,"change",s._onChange)));do{if(l(r,"pika-single")||r===u.trigger)return}while(r=r.parentNode);s._v&&t!==u.trigger&&r!==u.trigger&&s.hide()}},s.el=r.createElement("div"),s.el.className="pika-single"+(u.isRTL?" is-rtl":"")+(u.theme?" "+u.theme:""),o(s.el,"mousedown",s._onMouseDown,!0),o(s.el,"touchend",s._onMouseDown,!0),o(s.el,"change",s._onChange),o(r,"keydown",s._onKeyChange),u.field&&(u.container?u.container.appendChild(s.el):u.bound?r.body.appendChild(s.el):u.field.parentNode.insertBefore(s.el,u.field.nextSibling),o(u.field,"change",s._onInputChange),u.defaultDate||(t&&u.field.value?u.defaultDate=e(u.field.value,u.format).toDate():u.defaultDate=new Date(Date.parse(u.field.value)),u.setDefaultDate=!0));var d=u.defaultDate;c(d)?u.setDefaultDate?s.setDate(d,!0):s.gotoDate(d):s.gotoDate(new Date),u.bound?(this.hide(),s.el.className+=" is-bound",o(u.trigger,"click",s._onInputClick),o(u.trigger,"focus",s._onInputFocus),o(u.trigger,"blur",s._onInputBlur)):this.show()};return L.prototype={config:function(e){this._o||(this._o=_({},b,!0));var t=_(this._o,e,!0);t.isRTL=!!t.isRTL,t.field=t.field&&t.field.nodeName?t.field:null,t.theme="string"==typeof t.theme&&t.theme?t.theme:null,t.bound=!!(void 0!==t.bound?t.field&&t.bound:t.field),t.trigger=t.trigger&&t.trigger.nodeName?t.trigger:t.field,t.disableWeekends=!!t.disableWeekends,t.disableDayFn="function"==typeof t.disableDayFn?t.disableDayFn:null;var n=parseInt(t.numberOfMonths,10)||1;if(t.numberOfMonths=n>4?4:n,c(t.minDate)||(t.minDate=!1),c(t.maxDate)||(t.maxDate=!1),t.minDate&&t.maxDate&&t.maxDate100&&(t.yearRange=100);return t},toString:function(n){return c(this._d)?t?e(this._d).format(n||this._o.format):this._d.toDateString():""},getMoment:function(){return t?e(this._d):null},setMoment:function(n,r){t&&e.isMoment(n)&&this.setDate(n.toDate(),r)},getDate:function(){return c(this._d)?new Date(this._d.getTime()):new Date},setDate:function(e,t){if(!e)return this._d=null,this._o.field&&(this._o.field.value="",s(this._o.field,"change",{firedBy:this})),this.draw();if("string"==typeof e&&(e=new Date(Date.parse(e))),c(e)){var n=this._o.minDate,r=this._o.maxDate;c(n)&&er&&(e=r),this._d=new Date(e.getTime()),h(this._d),this.gotoDate(this._d),this._o.field&&(this._o.field.value=this.toString(),s(this._o.field,"change",{firedBy:this})),t||"function"!=typeof this._o.onSelect||this._o.onSelect.call(this,this.getDate())}},gotoDate:function(e){var t=!0;if(c(e)){if(this.calendars){var n=new Date(this.calendars[0].year,this.calendars[0].month,1),r=new Date(this.calendars[this.calendars.length-1].year,this.calendars[this.calendars.length-1].month,1),a=e.getTime();r.setMonth(r.getMonth()+1),r.setDate(r.getDate()-1),t=a=o&&(this._y=o,!isNaN(s)&&this._m>s&&(this._m=s)),t="pika-title-"+Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,2);for(var u=0;u'+M(this,u,this.calendars[u].year,this.calendars[u].month,this.calendars[0].year,t)+this.render(this.calendars[u].year,this.calendars[u].month,t)+"
";this.el.innerHTML=l,n.bound&&"hidden"!==n.field.type&&a((function(){n.trigger.focus()}),1),"function"==typeof this._o.onDraw&&this._o.onDraw(this),n.bound&&n.field.setAttribute("aria-label","Use the arrow keys to pick a date")}},adjustPosition:function(){var e,t,n,a,o,i,s,l,u,c;if(!this._o.container){if(this.el.style.position="absolute",t=e=this._o.trigger,n=this.el.offsetWidth,a=this.el.offsetHeight,o=window.innerWidth||r.documentElement.clientWidth,i=window.innerHeight||r.documentElement.clientHeight,s=window.pageYOffset||r.body.scrollTop||r.documentElement.scrollTop,"function"==typeof e.getBoundingClientRect)l=(c=e.getBoundingClientRect()).left+window.pageXOffset,u=c.bottom+window.pageYOffset;else for(l=t.offsetLeft,u=t.offsetTop+t.offsetHeight;t=t.offsetParent;)l+=t.offsetLeft,u+=t.offsetTop;(this._o.reposition&&l+n>o||this._o.position.indexOf("right")>-1&&l-n+e.offsetWidth>0)&&(l=l-n+e.offsetWidth),(this._o.reposition&&u+a>i+s||this._o.position.indexOf("top")>-1&&u-a-e.offsetHeight>0)&&(u=u-a-e.offsetHeight),this.el.style.left=l+"px",this.el.style.top=u+"px"}},render:function(e,t,n){var r=this._o,a=new Date,o=m(e,t),i=new Date(e,t,1).getDay(),s=[],l=[];h(a),r.firstDay>0&&(i-=r.firstDay)<0&&(i+=7);for(var u,p,_,y,b=0===t?11:t-1,M=11===t?0:t+1,L=0===t?e-1:e,k=11===t?e+1:e,Y=m(L,b),T=o+i,D=T;D>7;)D-=7;T+=7-D;for(var S=0,O=0;S=o+i,C=S-i+1,H=t,z=e,A=r.startRange&&f(r.startRange,j),N=r.endRange&&f(r.endRange,j),R=r.startRange&&r.endRange&&r.startRanger.maxDate||r.disableWeekends&&d(j)||r.disableDayFn&&r.disableDayFn(j),isEmpty:P,isStartRange:A,isEndRange:N,isInRange:R,showDaysInNextAndPreviousMonths:r.showDaysInNextAndPreviousMonths};l.push(v(F)),7==++O&&(r.showWeekNumber&&l.unshift((u=S-i,p=t,_=e,y=void 0,void 0,y=new Date(_,0,1),''+Math.ceil(((new Date(_,p,u)-y)/864e5+y.getDay()+1)/7)+"")),s.push(w(l,r.isRTL)),l=[],O=0)}return function(e,t,n){return''+function(e){var t,n=[];e.showWeekNumber&&n.push("");for(t=0;t<7;t++)n.push('");return""+(e.isRTL?n.reverse():n).join("")+""}(e)+(r=t,""+r.join("")+"
'+g(e,t,!0)+"
");var r}(r,s,n)},isVisible:function(){return this._v},show:function(){var e,t,n;this.isVisible()||(e=this.el,t="is-hidden",e.className=(n=(" "+e.className+" ").replace(" "+t+" "," ")).trim?n.trim():n.replace(/^\s+|\s+$/g,""),this._v=!0,this.draw(),this._o.bound&&(o(r,"click",this._onClick),this.adjustPosition()),"function"==typeof this._o.onOpen&&this._o.onOpen.call(this))},hide:function(){var e,t,n=this._v;!1!==n&&(this._o.bound&&i(r,"click",this._onClick),this.el.style.position="static",this.el.style.left="auto",this.el.style.top="auto",e=this.el,l(e,t="is-hidden")||(e.className=""===e.className?t:e.className+" "+t),this._v=!1,void 0!==n&&"function"==typeof this._o.onClose&&this._o.onClose.call(this))},destroy:function(){this.hide(),i(this.el,"mousedown",this._onMouseDown,!0),i(this.el,"touchend",this._onMouseDown,!0),i(this.el,"change",this._onChange),this._o.field&&(i(this._o.field,"change",this._onInputChange),this._o.bound&&(i(this._o.trigger,"click",this._onInputClick),i(this._o.trigger,"focus",this._onInputFocus),i(this._o.trigger,"blur",this._onInputBlur))),this.el.parentNode&&this.el.parentNode.removeChild(this.el)}},L}(a)}()},,function(e,t,n){},function(e,t,n){"use strict";n.r(t);var r=n(1),a=n.n(r),o=n(129),i=n.n(o),s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function l(e,t){function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var u=function(){return(u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]0){var i=Array.from({length:o-1}).map((function(e,r){var o=t.getColumnID(a,r+1);return t.state.hiddenColumns.includes(o)?"#CCCCCC":void 0!==n.colors&&null!==n.colors?n.colors[r]:_[r]}));r.setOptions(u({},n,{colors:i})),r.draw()}}},t.onResize=function(){t.props.googleChartWrapper.draw()},t}return l(t,e),t.prototype.componentDidMount=function(){this.draw(this.props),window.addEventListener("resize",this.onResize),(this.props.legend_toggle||this.props.legendToggle)&&this.listenToLegendToggle()},t.prototype.componentWillUnmount=function(){var e=this.props,t=e.google,n=e.googleChartWrapper;window.removeEventListener("resize",this.onResize),t.visualization.events.removeAllListeners(n),"Timeline"===n.getChartType()&&n.getChart()&&n.getChart().clearChart()},t.prototype.componentDidUpdate=function(){this.draw(this.props)},t.prototype.render=function(){return null},t}(r.Component),k=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l(t,e),t.prototype.componentDidMount=function(){},t.prototype.componentWillUnmount=function(){},t.prototype.shouldComponentUpdate=function(){return!1},t.prototype.render=function(){var e=this.props,t=e.google,n=e.googleChartWrapper,a=e.googleChartDashboard;return Object(r.createElement)(M,{render:function(e){return Object(r.createElement)(L,u({},e,{google:t,googleChartWrapper:n,googleChartDashboard:a}))}})},t}(r.Component),Y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l(t,e),t.prototype.shouldComponentUpdate=function(){return!1},t.prototype.listenToEvents=function(e){var t=this,n=e.chartEvents,r=e.google,a=e.googleChartWrapper;if(null!==n){r.visualization.events.removeAllListeners(a);for(var o=function(e){var n=e.eventName,o=e.callback;r.visualization.events.addListener(a,n,(function(){for(var e=[],n=0;n)<[^<]*)*<\/script>/gi,""):r.series[t].format.truthy.replace(/)<[^<]*)*<\/script>/gi,"")},a=jQuery.fn.dataTable.render.extra}return a}},{key:"render",value:function(){var e=this.props.options;return wp.element.createElement(W,null,e.customcss&&wp.element.createElement("style",null,e.customcss.oddTableRow&&"#dataTable-instances-".concat(this.props.id,"-").concat(this.uniqueId," tr.odd {\n\t\t\t\t\t\t\t\t").concat(e.customcss.oddTableRow.color?"color: ".concat(e.customcss.oddTableRow.color," !important;"):"","\n\t\t\t\t\t\t\t\t").concat(e.customcss.oddTableRow["background-color"]?"background-color: ".concat(e.customcss.oddTableRow["background-color"]," !important;"):"","\n\t\t\t\t\t\t\t\t").concat(e.customcss.oddTableRow.transform?"transform: rotate( ".concat(e.customcss.oddTableRow.transform,"deg ) !important;"):"","\n\t\t\t\t\t\t\t}"),e.customcss.evenTableRow&&"#dataTable-instances-".concat(this.props.id,"-").concat(this.uniqueId," tr.even {\n\t\t\t\t\t\t\t\t").concat(e.customcss.evenTableRow.color?"color: ".concat(e.customcss.evenTableRow.color," !important;"):"","\n\t\t\t\t\t\t\t\t").concat(e.customcss.evenTableRow["background-color"]?"background-color: ".concat(e.customcss.evenTableRow["background-color"]," !important;"):"","\n\t\t\t\t\t\t\t\t").concat(e.customcss.evenTableRow.transform?"transform: rotate( ".concat(e.customcss.evenTableRow.transform,"deg ) !important;"):"","\n\t\t\t\t\t\t\t}"),e.customcss.tableCell&&"#dataTable-instances-".concat(this.props.id,"-").concat(this.uniqueId," tr td,\n\t\t\t\t\t\t\t#dataTable-instances-").concat(this.props.id,"-").concat(this.uniqueId,"_wrapper tr th {\n\t\t\t\t\t\t\t\t").concat(e.customcss.tableCell.color?"color: ".concat(e.customcss.tableCell.color," !important;"):"","\n\t\t\t\t\t\t\t\t").concat(e.customcss.tableCell["background-color"]?"background-color: ".concat(e.customcss.tableCell["background-color"]," !important;"):"","\n\t\t\t\t\t\t\t\t").concat(e.customcss.tableCell.transform?"transform: rotate( ".concat(e.customcss.tableCell.transform,"deg ) !important;"):"","\n\t\t\t\t\t\t\t}")),wp.element.createElement("table",{id:"dataTable-instances-".concat(this.props.id,"-").concat(this.uniqueId)}))}}])&&P(n.prototype,r),a&&P(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(F),B=n(5),J=n.n(B),U=n(131),G=n.n(U),q=function(e){return Object.keys(e["visualizer-series"]).map((function(t){void 0!==e["visualizer-series"][t].type&&"date"===e["visualizer-series"][t].type&&Object.keys(e["visualizer-data"]).map((function(n){return e["visualizer-data"][n][t]=new Date(e["visualizer-data"][n][t])}))})),e},V=function(e){var t;if(Array.isArray(e))return 0=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function oe(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function ie(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){oe(o,r,a,i,s,"next",e)}function s(e){oe(o,r,a,i,s,"throw",e)}i(void 0)}))}}function se(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function le(e,t){for(var n=0;na.length&&(n=!0),this.setState({charts:this.state.charts.concat(a),isBusy:!1,chartsLoaded:n});case 9:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"render",value:function(){var e=this,t="undefined"!=typeof google?google.visualization.Version:"current",n=this.state,r=n.charts,a=n.isBusy,o=n.chartsLoaded,i=n.perPage;return wp.element.createElement("div",{className:"visualizer-settings__charts"},wp.element.createElement(ke,{status:"warning",isDismissible:!1},fe("ChartJS charts are currently not available for selection here, you must visit the library, get the shortcode, and add the chart here in a shortcode tag."),wp.element.createElement(Le,{href:visualizerLocalize.adminPage},fe("Click here to visit Visualizer Charts Library."))),null!==r?1<=r.length?wp.element.createElement(ge,null,wp.element.createElement("div",{className:"visualizer-settings__charts-grid"},Object.keys(r).map((function(n){var a,o,i,s=q(r[n].chart_data);if(a=s["visualizer-settings"].title?s["visualizer-settings"].title:"#".concat(r[n].id),0<=["gauge","tabular","timeline"].indexOf(s["visualizer-chart-type"])?"DataTable"===s["visualizer-chart-library"]?o=s["visualizer-chart-type"]:("tabular"===(o=s["visualizer-chart-type"])&&(o="table"),o=he(o)):o="".concat(he(s["visualizer-chart-type"]),"Chart"),!s["visualizer-chart-library"]||"ChartJS"!==s["visualizer-chart-library"])return s["visualizer-data-exploded"]&&(i=fe("Annotations in this chart may not display here but they will display in the front end.")),wp.element.createElement("div",{className:"visualizer-settings__charts-single","data-chart-type":o,key:"chart-".concat(r[n].id)},wp.element.createElement("div",{className:"visualizer-settings__charts-title"},a),"DataTable"===s["visualizer-chart-library"]?wp.element.createElement(I,{id:r[n].id,rows:s["visualizer-data"],columns:s["visualizer-series"],chartsScreen:!0,options:s["visualizer-settings"]}):(s["visualizer-data-exploded"],wp.element.createElement(S,{chartVersion:t,chartType:o,rows:s["visualizer-data"],columns:s["visualizer-series"],options:K(s["visualizer-settings"]),formatters:X(s)})),wp.element.createElement("div",{className:"visualizer-settings__charts-footer"},wp.element.createElement("sub",null,i)),wp.element.createElement("div",{className:"visualizer-settings__charts-controls",title:fe("Insert Chart"),onClick:function(){return e.props.getChart(r[n].id)}},wp.element.createElement(Me,{icon:"upload"})))}))),!o&&i-1=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function Ve(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function $e(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Ve(o,r,a,i,s,"next",e)}function s(e){Ve(o,r,a,i,s,"throw",e)}i(void 0)}))}}function Ke(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ze(e,t){for(var n=0;n/g," ➤ "),value:t.data.roots[e]}})),this.setState({isLoading:!1,isFirstStepOpen:!1,isSecondStepOpen:!0,endpointRoots:n})):(this.setState({isLoading:!1}),alert(t.data.msg));case 5:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getJSONData",value:(i=$e(qe().mark((function e(){var t,n;return qe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setState({isLoading:!0}),e.next=3,ot({path:"/visualizer/v1/get-json-data?url=".concat(this.props.chart["visualizer-json-url"],"&chart=").concat(this.props.id),data:{root:this.props.chart["visualizer-json-root"]||this.state.endpointRoots[0].value,method:this.props.chart["visualizer-json-headers"]?this.props.chart["visualizer-json-headers"].method:this.state.requestHeaders.method,username:this.props.chart["visualizer-json-headers"]&&"object"===Ge(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth.username:this.state.requestHeaders.username,password:this.props.chart["visualizer-json-headers"]&&"object"===Ge(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth.password:this.state.requestHeaders.password,auth:this.props.chart["visualizer-json-headers"]&&"object"!==Ge(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth:this.state.requestHeaders.auth},method:"GET"});case 3:(t=e.sent).success?(n=[{label:rt("Don't use pagination"),value:0}],t.data.paging&&"root>next"===t.data.paging[0]&&n.push({label:rt("Get first 5 pages using root ➤ next"),value:"root>next"}),this.setState({isLoading:!1,isSecondStepOpen:!1,isFourthStepOpen:!0,endpointPaging:n,table:t.data.table}),document.querySelector("#visualizer-json-query-table").innerHTML=t.data.table,this.initTable()):(this.setState({isLoading:!1}),alert(t.data.msg));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getTableData",value:(o=$e(qe().mark((function e(){var t,n,r,a,o;return qe().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setState({isLoading:!0}),t=document.querySelectorAll("#visualizer-json-query-table input"),n=document.querySelectorAll("#visualizer-json-query-table select"),r=[],a={},t.forEach((function(e){return r.push(e.value)})),n.forEach((function(e){return a[e.name]=e.value})),e.next=9,ot({path:"/visualizer/v1/set-json-data",data:Je({url:this.props.chart["visualizer-json-url"],method:this.props.chart["visualizer-json-headers"]?this.props.chart["visualizer-json-headers"].method:this.state.requestHeaders.method,username:this.props.chart["visualizer-json-headers"]&&"object"===Ge(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth.username:this.state.requestHeaders.username,password:this.props.chart["visualizer-json-headers"]&&"object"===Ge(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth.password:this.state.requestHeaders.password,auth:this.props.chart["visualizer-json-headers"]&&"object"!==Ge(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth:this.state.requestHeaders.auth,root:this.props.chart["visualizer-json-root"]||this.state.endpointRoots[0].value,paging:this.props.chart["visualizer-json-paging"]||0,header:r},a),method:"GET"});case 9:(o=e.sent).success?(this.props.JSONImportData(o.data.name,JSON.parse(o.data.series),JSON.parse(o.data.data)),this.setState({isOpen:!1,isLoading:!1})):(alert(o.data.msg),this.setState({isLoading:!1}));case 11:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"render",value:function(){var e=this;return wp.element.createElement(pt,{title:rt("Import from JSON"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement("p",null,rt("You can choose here to import or synchronize your chart data with a remote JSON source.")),wp.element.createElement("p",null,wp.element.createElement(ut,{href:"https://docs.themeisle.com/article/1052-how-to-generate-charts-from-json-data-rest-endpoints"},rt("For more info check this tutorial."))),wp.element.createElement(mt,{label:rt("How often do you want to check the url?"),value:this.props.chart["visualizer-json-schedule"]?this.props.chart["visualizer-json-schedule"]:1,options:[{label:rt("One-time"),value:"-1"},{label:rt("Live"),value:"0"},{label:rt("Each hour"),value:"1"},{label:rt("Each 12 hours"),value:"12"},{label:rt("Each day"),value:"24"},{label:rt("Each 3 days"),value:"72"}],onChange:this.props.editSchedule}),wp.element.createElement(lt,{isPrimary:!0,isLarge:!0,onClick:this.openModal},rt("Modify Parameters")),this.state.isOpen&&wp.element.createElement(dt,{title:rt("Import from JSON"),className:"visualizer-json-query-modal",shouldCloseOnClickOutside:!1,onRequestClose:function(){e.setState({isOpen:!1,isTableRendered:!1})}},wp.element.createElement(pt,{title:rt("Step 1: Specify the JSON endpoint/URL"),opened:this.state.isFirstStepOpen,onToggle:function(){return e.onToggle("isFirstStepOpen")}},wp.element.createElement("p",null,rt("If you want to add authentication, add headers to the endpoint or change the request in any way, please refer to our document here:")),wp.element.createElement("p",null,wp.element.createElement(ut,{href:"https://docs.themeisle.com/article/1043-visualizer-how-to-extend-rest-endpoints-with-json-response"},rt("How to extend REST endpoints with JSON response"))),wp.element.createElement(ht,{placeholder:rt("Please enter the URL of your JSON file"),value:this.props.chart["visualizer-json-url"]?this.props.chart["visualizer-json-url"]:"",onChange:this.props.editJSONURL}),wp.element.createElement(ct,{icon:"arrow-right-alt2",label:rt("Add Headers"),onClick:this.toggleHeaders},rt("Add Headers")),this.state.isHeaderPanelOpen&&wp.element.createElement("div",{className:"visualizer-json-query-modal-headers-panel"},wp.element.createElement(mt,{label:rt("Request Type"),value:this.props.chart["visualizer-json-headers"]?this.props.chart["visualizer-json-headers"].method:this.state.requestHeaders.method,options:[{value:"GET",label:rt("GET")},{value:"POST",label:rt("POST")}],onChange:function(t){var n=Je({},e.state.requestHeaders),r=e.state.requestHeaders;n.method=t,r=Je(Je({},r),{},{method:t}),e.setState({requestHeaders:r}),e.props.editJSONHeaders(n)}}),wp.element.createElement("p",null,rt("Credentials")),wp.element.createElement(ht,{label:rt("Username"),placeholder:rt("Username/Access Key"),value:this.props.chart["visualizer-json-headers"]&&"object"===Ge(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth.username:this.state.requestHeaders.username,onChange:function(t){var n=Je({},e.state.requestHeaders),r=e.state.requestHeaders;n.auth={username:t,password:e.props.chart["visualizer-json-headers"]&&"object"===Ge(e.props.chart["visualizer-json-headers"].auth)?e.props.chart["visualizer-json-headers"].auth.password:e.state.requestHeaders.password},r=Je(Je({},r),{},{username:t,password:n.password}),e.setState({requestHeaders:r}),e.props.editJSONHeaders(n)}}),wp.element.createElement("span",{className:"visualizer-json-query-modal-field-separator"},rt("&")),wp.element.createElement(ht,{label:rt("Password"),placeholder:rt("Password/Secret Key"),type:"password",value:this.props.chart["visualizer-json-headers"]&&"object"===Ge(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth.password:this.state.requestHeaders.password,onChange:function(t){var n=Je({},e.state.requestHeaders),r=e.state.requestHeaders;n.auth={username:e.props.chart["visualizer-json-headers"]&&"object"===Ge(e.props.chart["visualizer-json-headers"].auth)?e.props.chart["visualizer-json-headers"].auth.username:e.state.requestHeaders.username,password:t},r=Je(Je({},r),{},{username:n.username,password:t}),e.setState({requestHeaders:r}),e.props.editJSONHeaders(n)}}),wp.element.createElement("p",null,rt("OR")),wp.element.createElement(ht,{label:rt("Authorization"),placeholder:rt("e.g. SharedKey :"),value:this.props.chart["visualizer-json-headers"]&&"object"!==Ge(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth:this.state.requestHeaders.auth,onChange:function(t){var n=Je({},e.state.requestHeaders),r=e.state.requestHeaders;n.auth=t,r=Je(Je({},r),{},{auth:t}),e.setState({requestHeaders:r}),e.props.editJSONHeaders(n)}})),wp.element.createElement(lt,{isPrimary:!0,isLarge:!0,isBusy:this.state.isLoading,disabled:this.state.isLoading,onClick:this.getJSONRoot},rt("Fetch Endpoint"))),wp.element.createElement(pt,{title:rt("Step 2: Choose the JSON root"),initialOpen:!1,opened:this.state.isSecondStepOpen,onToggle:function(){return e.onToggle("isSecondStepOpen")}},wp.element.createElement("p",null,rt("If you see Invalid Data, you may have selected the wrong root to fetch data from. Please select an alternative.")),wp.element.createElement(mt,{value:this.props.chart["visualizer-json-root"],options:this.state.endpointRoots,onChange:this.props.editJSONRoot}),wp.element.createElement(lt,{isPrimary:!0,isLarge:!0,isBusy:this.state.isLoading,disabled:this.state.isLoading,onClick:this.getJSONData},rt("Parse Endpoint"))),wp.element.createElement(pt,{title:rt("Step 3: Specify miscellaneous parameters"),initialOpen:!1,opened:this.state.isThirdStepOpen,onToggle:function(){return e.onToggle("isThirdStepOpen")}},"community"!==visualizerLocalize.isPro?wp.element.createElement(mt,{value:this.props.chart["visualizer-json-paging"]||0,options:this.state.endpointPaging,onChange:this.props.editJSONPaging}):wp.element.createElement("p",null,rt("Enable this feature in PRO version!"))),wp.element.createElement(pt,{title:rt("Step 4: Select the data to display in the chart"),initialOpen:!1,opened:this.state.isFourthStepOpen,onToggle:function(){return e.onToggle("isFourthStepOpen")}},wp.element.createElement("ul",null,wp.element.createElement("li",null,rt("Select whether to include the data in the chart. Each column selected will form one series.")),wp.element.createElement("li",null,rt("If a column is selected to be included, specify its data type.")),wp.element.createElement("li",null,rt("You can use drag/drop to reorder the columns but this column position is not saved. So when you reload the table, you may have to reorder again.")),wp.element.createElement("li",null,rt("You can select any number of columns but the chart type selected will determine how many will display in the chart."))),wp.element.createElement("div",{id:"visualizer-json-query-table"}),wp.element.createElement(lt,{isPrimary:!0,isLarge:!0,isBusy:this.state.isLoading,disabled:this.state.isLoading,onClick:this.getTableData},rt("Save & Show Chart")))))}}])&&Ze(n.prototype,r),a&&Ze(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(it);function _t(e){return(_t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function yt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function bt(e,t){for(var n=0;n=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function Pt(e){return(Pt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ct(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function Ht(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function zt(e,t){for(var n=0;n=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function tn(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function nn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function rn(e,t){for(var n=0;n=["timeline"].indexOf(t)&&(r[1]={label:gr("The tooltip will be displayed when the user selects an element"),value:"selection"}),r[2]={label:gr("The tooltip will not be displayed"),value:"none"};var a=[{label:gr("Left of the chart"),value:"left"},{label:gr("Right of the chart"),value:"right"},{label:gr("Above the chart"),value:"top"},{label:gr("Below the chart"),value:"bottom"},{label:gr("Omit the legend"),value:"none"}];"pie"!==t&&a.push({label:gr("Inside the chart"),value:"in"}),"bubble"===t&&(a=a.filter((function(e){return"left"!==e.value})));var o=gr("Text to display above the chart.");return 0<=["tabular","dataTable","gauge","geo","timeline"].indexOf(t)&&(o=gr("Text to display in the back-end admin area")),wp.element.createElement(Yr,{title:gr("General Settings"),initialOpen:!1,className:"visualizer-advanced-panel"},wp.element.createElement(Yr,{title:gr("Title"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Dr,{label:gr("Chart Title"),help:o,value:n.title,onChange:function(t){n.title=t,e.props.edit(n)}}),-1>=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(t)&&wp.element.createElement(Tr,{label:gr("Chart Title Position"),help:gr("Where to place the chart title, compared to the chart area."),value:n.titlePosition?n.titlePosition:"out",options:[{label:gr("Inside the chart"),value:"in"},{label:gr("Outside the chart"),value:"out"},{label:gr("None"),value:"none"}],onChange:function(t){n.titlePosition=t,e.props.edit(n)}}),-1>=["tabular","dataTable","gauge","geo","timeline"].indexOf(t)&&wp.element.createElement(Lr,{label:gr("Chart Title Color")},wp.element.createElement(wr,{value:n.titleTextStyle.color,onChange:function(t){n.titleTextStyle.color=t,e.props.edit(n)}})),-1>=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(t)&&wp.element.createElement(Tr,{label:gr("Axes Titles Position"),help:gr("Determines where to place the axis titles, compared to the chart area."),value:n.axisTitlesPosition?n.axisTitlesPosition:"out",options:[{label:gr("Inside the chart"),value:"in"},{label:gr("Outside the chart"),value:"out"},{label:gr("None"),value:"none"}],onChange:function(t){n.axisTitlesPosition=t,e.props.edit(n)}})),-1>=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(t)&&wp.element.createElement(Yr,{title:gr("Font Styles"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Tr,{label:gr("Font Family"),help:gr("The default font family for all text in the chart."),value:n.fontName?n.fontName:"Arial",options:[{label:gr("Arial"),value:"Arial"},{label:gr("Sans Serif"),value:"Sans Serif"},{label:gr("Serif"),value:"serif"},{label:gr("Arial"),value:"Arial"},{label:gr("Wide"),value:"Arial black"},{label:gr("Narrow"),value:"Arial Narrow"},{label:gr("Comic Sans MS"),value:"Comic Sans MS"},{label:gr("Courier New"),value:"Courier New"},{label:gr("Garamond"),value:"Garamond"},{label:gr("Georgia"),value:"Georgia"},{label:gr("Tahoma"),value:"Tahoma"},{label:gr("Verdana"),value:"Verdana"}],onChange:function(t){n.fontName=t,e.props.edit(n)}}),wp.element.createElement(Tr,{label:gr("Font Size"),help:gr("The default font size for all text in the chart."),value:n.fontSize?n.fontSize:"15",options:[{label:"7",value:"7"},{label:"8",value:"8"},{label:"9",value:"9"},{label:"10",value:"10"},{label:"11",value:"11"},{label:"12",value:"12"},{label:"13",value:"13"},{label:"14",value:"14"},{label:"15",value:"15"},{label:"16",value:"16"},{label:"17",value:"17"},{label:"18",value:"18"},{label:"19",value:"19"},{label:"20",value:"20"}],onChange:function(t){n.fontSize=t,e.props.edit(n)}})),-1>=["tabular","dataTable","gauge","geo","timeline"].indexOf(t)&&wp.element.createElement(Yr,{title:gr("Legend"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Tr,{label:gr("Position"),help:gr("Determines where to place the legend, compared to the chart area."),value:n.legend.position?n.legend.position:"right",options:a,onChange:function(r){if("pie"!==t){var a="left"===r?1:0;n.series&&Object.keys(n.series).map((function(e){n.series[e].targetAxisIndex=a}))}n.legend.position=r,e.props.edit(n)}}),wp.element.createElement(Tr,{label:gr("Alignment"),help:gr("Determines the alignment of the legend."),value:n.legend.alignment?n.legend.alignment:"15",options:[{label:gr("Aligned to the start of the allocated area"),value:"start"},{label:gr("Centered in the allocated area"),value:"center"},{label:gr("Aligned to the end of the allocated area"),value:"end"}],onChange:function(t){n.legend.alignment=t,e.props.edit(n)}}),wp.element.createElement(Lr,{label:gr("Font Color")},wp.element.createElement(wr,{value:n.legend.textStyle.color,onChange:function(t){n.legend.textStyle.color=t,e.props.edit(n)}}))),-1>=["tabular","gauge","geo","dataTable","timeline"].indexOf(t)&&wp.element.createElement(Yr,{title:gr("Tooltip"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Tr,{label:gr("Trigger"),help:gr("Determines the user interaction that causes the tooltip to be displayed."),value:n.tooltip.trigger?n.tooltip.trigger:"focus",options:r,onChange:function(t){n.tooltip.trigger=t,e.props.edit(n)}}),wp.element.createElement(Tr,{label:gr("Show Color Code"),help:gr("If set to yes, will show colored squares next to the slice information in the tooltip."),value:n.tooltip.showColorCode?n.tooltip.showColorCode:"0",options:[{label:gr("Yes"),value:"1"},{label:gr("No"),value:"0"}],onChange:function(t){n.tooltip.showColorCode=t,e.props.edit(n)}}),0<=["pie"].indexOf(t)&&wp.element.createElement(Tr,{label:gr("Text"),help:gr("Determines what information to display when the user hovers over a pie slice."),value:n.tooltip.text?n.tooltip.text:"both",options:[{label:gr("Display both the absolute value of the slice and the percentage of the whole"),value:"both"},{label:gr("Display only the absolute value of the slice"),value:"value"},{label:gr("Display only the percentage of the whole represented by the slice"),value:"percentage"}],onChange:function(t){n.tooltip.text=t,e.props.edit(n)}})),-1>=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(t)&&wp.element.createElement(Yr,{title:gr("Animation"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(kr,{label:gr("Animate on startup?"),help:gr("Determines if the chart will animate on the initial draw."),checked:Number(n.animation.startup),onChange:function(t){n.animation.startup=t?"1":"0",e.props.edit(n)}}),wp.element.createElement(Dr,{label:gr("Duration"),help:gr("The duration of the animation, in milliseconds."),type:"number",value:n.animation.duration,onChange:function(t){n.animation.duration=t,e.props.edit(n)}}),wp.element.createElement(Tr,{label:gr("Easing"),help:gr("The easing function applied to the animation."),value:n.animation.easing?n.animation.easing:"linear",options:[{label:gr("Constant speed"),value:"linear"},{label:gr("Start slow and speed up"),value:"in"},{label:gr("Start fast and slow down"),value:"out"},{label:gr("Start slow, speed up, then slow down"),value:"inAndOut"}],onChange:function(t){n.animation.easing=t,e.props.edit(n)}})))}}])&&hr(n.prototype,r),a&&hr(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(vr);function Or(e){return(Or="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function jr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Er(e,t){for(var n=0;n=["column"].indexOf(t)&&wp.element.createElement(Xr,null,wp.element.createElement(ia,{label:Kr("Number Format"),help:Kr("Enter custom format pattern to apply to horizontal axis labels."),value:n.hAxis.format,onChange:function(t){n.hAxis.format=t,e.props.edit(n)}}),wp.element.createElement("p",null,Kr("For number axis labels, this is a subset of the formatting "),wp.element.createElement(ra,{href:"http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details"},Kr("ICU pattern set.")),Kr(" For instance, $#,###.## will display values $1,234.56 for value 1234.56. Pay attention that if you use #%% percentage format then your values will be multiplied by 100.")),wp.element.createElement("p",null,Kr("For date axis labels, this is a subset of the date formatting "),wp.element.createElement(ra,{href:"https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax"},Kr("ICU date and time format."))))),-1>=["column"].indexOf(t)&&wp.element.createElement(Xr,null,wp.element.createElement(aa,{title:Kr("Grid Lines"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(ia,{label:Kr("Count"),help:Kr("The approximate number of horizontal gridlines inside the chart area. You can specify a value of -1 to automatically compute the number of gridlines, 0 or 1 to draw no gridlines, or 2 or more to only draw gridline. Any number greater than 2 will be used to compute the minSpacing between gridlines."),value:n.hAxis.gridlines?n.hAxis.gridlines.count:"",onChange:function(t){n.hAxis.gridlines||(n.hAxis.gridlines={}),n.hAxis.gridlines.count=t,e.props.edit(n)}}),wp.element.createElement(na,{label:Kr("Color")},wp.element.createElement(ea,{value:n.hAxis.gridlines?n.hAxis.gridlines.color:"",onChange:function(t){n.hAxis.gridlines||(n.hAxis.gridlines={}),n.hAxis.gridlines.color=t,e.props.edit(n)}}))),wp.element.createElement(aa,{title:Kr("Minor Grid Lines"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(ia,{label:Kr("Count"),help:Kr("Specify 0 to disable the minor gridlines."),value:n.hAxis.minorGridlines?n.hAxis.minorGridlines.count:"",onChange:function(t){n.hAxis.minorGridlines||(n.hAxis.minorGridlines={}),n.hAxis.minorGridlines.count=t,e.props.edit(n)}}),wp.element.createElement(na,{label:Kr("Color")},wp.element.createElement(ea,{value:n.hAxis.minorGridlines?n.hAxis.minorGridlines.color:"",onChange:function(t){n.hAxis.minorGridlines||(n.hAxis.minorGridlines={}),n.hAxis.minorGridlines.color=t,e.props.edit(n)}}))),wp.element.createElement(aa,{title:Kr("View Window"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(ia,{label:Kr("Maximun Value"),help:Kr("The maximum vertical data value to render."),value:n.hAxis.viewWindow?n.hAxis.viewWindow.max:"",onChange:function(t){n.hAxis.viewWindow||(n.hAxis.viewWindow={}),n.hAxis.viewWindow.max=t,e.props.edit(n)}}),wp.element.createElement(ia,{label:Kr("Minimum Value"),help:Kr("The minimum vertical data value to render."),value:n.hAxis.viewWindow?n.hAxis.viewWindow.min:"",onChange:function(t){n.hAxis.viewWindow||(n.hAxis.viewWindow={}),n.hAxis.viewWindow.min=t,e.props.edit(n)}}))))}}])&&Ur(n.prototype,r),a&&Ur(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(Qr);function la(e){return(la="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ua(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ca(e,t){for(var n=0;n=["bar"].indexOf(t)&&wp.element.createElement(ba,null,wp.element.createElement(Ya,{label:fa("Number Format"),help:fa("Enter custom format pattern to apply to Vertical axis labels."),value:n.vAxis.format,onChange:function(t){n.vAxis.format=t,e.props.edit(n)}}),wp.element.createElement("p",null,fa("For number axis labels, this is a subset of the formatting "),wp.element.createElement(Ma,{href:"http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details"},fa("ICU pattern set.")),fa(" For instance, $#,###.## will display values $1,234.56 for value 1234.56. Pay attention that if you use #%% percentage format then your values will be multiplied by 100.")),wp.element.createElement("p",null,fa("For date axis labels, this is a subset of the date formatting "),wp.element.createElement(Ma,{href:"https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax"},fa("ICU date and time format."))))),-1>=["bar"].indexOf(t)&&wp.element.createElement(ba,null,wp.element.createElement(La,{title:fa("Grid Lines"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Ya,{label:fa("Count"),help:fa("The approximate number of vertical gridlines inside the chart area. You can specify a value of -1 to automatically compute the number of gridlines, 0 or 1 to draw no gridlines, or 2 or more to only draw gridline. Any number greater than 2 will be used to compute the minSpacing between gridlines."),value:n.vAxis.gridlines?n.vAxis.gridlines.count:"",onChange:function(t){n.vAxis.gridlines||(n.vAxis.gridlines={}),n.vAxis.gridlines.count=t,e.props.edit(n)}}),wp.element.createElement(wa,{label:fa("Color")},wp.element.createElement(ga,{value:n.vAxis.gridlines?n.vAxis.gridlines.color:"",onChange:function(t){n.vAxis.gridlines||(n.vAxis.gridlines={}),n.vAxis.gridlines.color=t,e.props.edit(n)}}))),wp.element.createElement(La,{title:fa("Minor Grid Lines"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Ya,{label:fa("Count"),help:fa("Specify 0 to disable the minor gridlines."),value:n.vAxis.minorGridlines?n.vAxis.minorGridlines.count:"",onChange:function(t){n.vAxis.minorGridlines||(n.vAxis.minorGridlines={}),n.vAxis.minorGridlines.count=t,e.props.edit(n)}}),wp.element.createElement(wa,{label:fa("Color")},wp.element.createElement(ga,{value:n.vAxis.minorGridlines?n.vAxis.minorGridlines.color:"",onChange:function(t){n.vAxis.minorGridlines||(n.vAxis.minorGridlines={}),n.vAxis.minorGridlines.color=t,e.props.edit(n)}}))),wp.element.createElement(La,{title:fa("View Window"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Ya,{label:fa("Maximun Value"),help:fa("The maximum vertical data value to render."),value:n.vAxis.viewWindow?n.vAxis.viewWindow.max:"",onChange:function(t){n.vAxis.viewWindow||(n.vAxis.viewWindow={}),n.vAxis.viewWindow.max=t,e.props.edit(n)}}),wp.element.createElement(Ya,{label:fa("Minimum Value"),help:fa("The minimum vertical data value to render."),value:n.vAxis.viewWindow?n.vAxis.viewWindow.min:"",onChange:function(t){n.vAxis.viewWindow||(n.vAxis.viewWindow={}),n.vAxis.viewWindow.min=t,e.props.edit(n)}}))))}}])&&ca(n.prototype,r),a&&ca(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(ya);function Da(e){return(Da="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Sa(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Oa(e,t){for(var n=0;n=["area"].indexOf(t)&&wp.element.createElement(wo,{label:fo("Curve Type"),help:fo("Determines whether the series has to be presented in the legend or not."),value:n.curveType?n.curveType:"none",options:[{label:fo("Straight line without curve"),value:"none"},{label:fo("The angles of the line will be smoothed"),value:"function"}],onChange:function(t){n.curveType=t,e.props.edit(n)}}),-1>=["scatter"].indexOf(t)&&wp.element.createElement(wo,{label:fo("Focus Target"),help:fo("The type of the entity that receives focus on mouse hover. Also affects which entity is selected by mouse click."),value:n.focusTarget?n.focusTarget:"datum",options:[{label:fo("Focus on a single data point."),value:"datum"},{label:fo("Focus on a grouping of all data points along the major axis."),value:"category"}],onChange:function(t){n.focusTarget=t,e.props.edit(n)}}),wp.element.createElement(wo,{label:fo("Selection Mode"),help:fo("Determines how many data points an user can select on a chart."),value:n.selectionMode?n.selectionMode:"single",options:[{label:fo("Single data point"),value:"single"},{label:fo("Multiple data points"),value:"multiple"}],onChange:function(t){n.selectionMode=t,e.props.edit(n)}}),wp.element.createElement(wo,{label:fo("Aggregation Target"),help:fo("Determines how multiple data selections are rolled up into tooltips. To make it working you need to set multiple selection mode and tooltip trigger to display it when an user selects an element."),value:n.aggregationTarget?n.aggregationTarget:"auto",options:[{label:fo("Group selected data by x-value"),value:"category"},{label:fo("Group selected data by series"),value:"series"},{label:fo("Group selected data by x-value if all selections have the same x-value, and by series otherwise"),value:"auto"},{label:fo("Show only one tooltip per selection"),value:"none"}],onChange:function(t){n.aggregationTarget=t,e.props.edit(n)}}),wp.element.createElement(Mo,{label:fo("Point Opacity"),help:fo("The transparency of data points, with 1.0 being completely opaque and 0.0 fully transparent."),value:n.dataOpacity,onChange:function(t){n.dataOpacity=t,e.props.edit(n)}}),-1>=["scatter","line"].indexOf(t)&&wp.element.createElement(bo,null,wp.element.createElement(Mo,{label:fo("Area Opacity"),help:fo("The default opacity of the colored area under an area chart series, where 0.0 is fully transparent and 1.0 is fully opaque. To specify opacity for an individual series, set the area opacity value in the series property."),value:n.areaOpacity,onChange:function(t){n.areaOpacity=t,e.props.edit(n)}}),wp.element.createElement(wo,{label:fo("Is Stacked"),help:fo("If set to yes, series elements are stacked."),value:n.isStacked?n.isStacked:"0",options:[{label:fo("Yes"),value:"1"},{label:fo("No"),value:"0"}],onChange:function(t){n.isStacked=t,e.props.edit(n)}})),-1>=["scatter","area"].indexOf(t)&&wp.element.createElement(wo,{label:fo("Interpolate Nulls"),help:fo("Whether to guess the value of missing points. If yes, it will guess the value of any missing data based on neighboring points. If no, it will leave a break in the line at the unknown point."),value:n.interpolateNulls?n.interpolateNulls:"0",options:[{label:fo("Yes"),value:"1"},{label:fo("No"),value:"0"}],onChange:function(t){n.interpolateNulls=t,e.props.edit(n)}}))}}])&&uo(n.prototype,r),a&&uo(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(yo);function ko(e){return(ko="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Yo(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function To(e,t){for(var n=0;n=["tabular","pie"].indexOf(s)&&wp.element.createElement($l,{label:Fl("Visible In Legend"),help:Fl("Determines whether the series has to be presented in the legend or not."),value:t.series[a].visibleInLegend?t.series[a].visibleInLegend:"1",options:[{label:Fl("Yes"),value:"1"},{label:Fl("No"),value:"0"}],onChange:function(n){t.series[a].visibleInLegend=n,e.props.edit(t)}}),-1>=["tabular","candlestick","combo","column","bar"].indexOf(s)&&wp.element.createElement(Bl,null,wp.element.createElement(Kl,{label:Fl("Line Width"),help:Fl("Overrides the global line width value for this series."),value:t.series[a].lineWidth,onChange:function(n){t.series[a].lineWidth=n,e.props.edit(t)},onKeyUp:function(n){clearTimeout(l),l=setTimeout((function(){""!=t.series[a].lineWidth&&0>=t.series[a].lineWidth&&(t.series[a].lineWidth="0.1",e.props.edit(t))}),700)}}),wp.element.createElement(Kl,{label:Fl("Point Size"),help:Fl("Overrides the global point size value for this series."),value:t.series[a].pointSize,onChange:function(n){t.series[a].pointSize=n,e.props.edit(t)}})),-1>=["candlestick"].indexOf(s)&&s&&"number"===s?wp.element.createElement(Bl,null,wp.element.createElement(Kl,{label:Fl("Format"),help:Fl("Enter custom format pattern to apply to this series value."),value:t.series[o].format,onChange:function(n){t.series[o].format=n,e.props.edit(t)}}),wp.element.createElement("p",null,Fl("For number axis labels, this is a subset of the formatting "),wp.element.createElement(ql,{href:"http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details"},Fl("ICU pattern set.")),Fl(" For instance, $#,###.## will display values $1,234.56 for value 1234.56. Pay attention that if you use #%% percentage format then your values will be multiplied by 100."))):0<=["date","datetime","timeofday"].indexOf(s)&&wp.element.createElement(Bl,null,wp.element.createElement(Kl,{label:Fl("Date Format"),help:Fl("Enter custom format pattern to apply to this series value."),placeholder:"dd LLLL yyyy",value:t.series[o].format,onChange:function(n){t.series[o].format=n,e.props.edit(t)}}),wp.element.createElement("p",null,Fl("This is a subset of the date formatting "),wp.element.createElement(ql,{href:"https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax"},Fl("ICU date and time format.")))),0<=["scatter","line"].indexOf(s)&&wp.element.createElement($l,{label:Fl("Curve Type"),help:Fl("Determines whether the series has to be presented in the legend or not."),value:t.series[a].curveType?t.series[a].curveType:"none",options:[{label:Fl("Straight line without curve"),value:"none"},{label:Fl("The angles of the line will be smoothed"),value:"function"}],onChange:function(n){t.series[a].curveType=n,e.props.edit(t)}}),0<=["area"].indexOf(s)&&wp.element.createElement(Kl,{label:Fl("Area Opacity"),help:Fl("The opacity of the colored area, where 0.0 is fully transparent and 1.0 is fully opaque."),value:t.series[a].areaOpacity,onChange:function(n){t.series[a].areaOpacity=n,e.props.edit(t)}}),0<=["combo"].indexOf(s)&&wp.element.createElement($l,{label:Fl("Chart Type"),help:Fl("Select the type of chart to show for this series."),value:t.series[a].type?t.series[a].type:"area",options:[{label:Fl("Area"),value:"area"},{label:Fl("Bar"),value:"bars"},{label:Fl("Candlesticks"),value:"candlesticks"},{label:Fl("Line"),value:"line"},{label:Fl("Stepped Area"),value:"steppedArea"}],onChange:function(n){t.series[a].type=n,e.props.edit(t)}}),-1>=["tabular"].indexOf(s)&&wp.element.createElement(Gl,{label:Fl("Color")},wp.element.createElement(Jl,{value:t.series[a].color,onChange:function(n){t.series[a].color=n,e.props.edit(t)}})))})))}}])&&Hl(n.prototype,r),a&&Hl(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(Il);function Ql(e){return(Ql="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Xl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function eu(e,t){for(var n=0;n=["gauge","tabular"].indexOf(t)&&wp.element.createElement(tc,null,wp.element.createElement(lc,{label:Qu("Stroke Width"),help:Qu("The chart border width in pixels."),value:n.backgroundColor.strokeWidth,onChange:function(t){n.backgroundColor.strokeWidth=t,e.props.edit(n)}}),wp.element.createElement(ac,{label:Qu("Stroke Color")},wp.element.createElement(nc,{value:n.backgroundColor.stroke,onChange:function(t){n.backgroundColor.stroke=t,e.props.edit(n)}})),wp.element.createElement(ac,{label:Qu("Background Color")},wp.element.createElement(nc,{value:n.backgroundColor.fill,onChange:function(t){n.backgroundColor.fill=t,e.props.edit(n)}})),wp.element.createElement(oc,{label:Qu("Transparent Background?"),checked:"transparent"===n.backgroundColor.fill,onChange:function(t){n.backgroundColor.fill="transparent"===n.backgroundColor.fill?"":"transparent",e.props.edit(n)}}))),-1>=["geo","gauge","tabular"].indexOf(t)&&wp.element.createElement(ic,{title:Qu("Chart Area"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(lc,{label:Qu("Left Margin"),help:Qu("Determines how far to draw the chart from the left border."),value:n.chartArea.left,onChange:function(t){n.chartArea.left=t,e.props.edit(n)}}),wp.element.createElement(lc,{label:Qu("Top Margin"),help:Qu("Determines how far to draw the chart from the top border."),value:n.chartArea.top,onChange:function(t){n.chartArea.top=t,e.props.edit(n)}}),wp.element.createElement(lc,{label:Qu("Width Of Chart Area"),help:Qu("Determines the width of the chart area."),value:n.chartArea.width,onChange:function(t){n.chartArea.width=t,e.props.edit(n)}}),wp.element.createElement(lc,{label:Qu("Height Of Chart Area"),help:Qu("Determines the hight of the chart area."),value:n.chartArea.height,onChange:function(t){n.chartArea.height=t,e.props.edit(n)}})))}}])&&qu(n.prototype,r),a&&qu(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(ec);function cc(e){return(cc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function dc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pc(e,t){for(var n=0;n=["dataTable","tabular","gauge","table"].indexOf(n)&&wp.element.createElement(Lc,{label:yc("Download Image"),help:yc("To download the chart as an image."),checked:0<=t.actions.indexOf("image"),onChange:function(n){if(0<=t.actions.indexOf("image")){var r=t.actions.indexOf("image");-1!==r&&t.actions.splice(r,1)}else t.actions.push("image");e.props.edit(t)}}))):wp.element.createElement(kc,{title:yc("Frontend Actions"),initialOpen:!1,icon:"lock",className:"visualizer-advanced-panel"},wp.element.createElement("p",null,yc("Enable this feature in PRO version!")),wp.element.createElement(Mc,{isPrimary:!0,href:visualizerLocalize.proTeaser,target:"_blank"},yc("Upgrade Now")))}}])&&pc(n.prototype,r),a&&pc(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(gc);function Tc(e){return(Tc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Dc(e){var t=function(e,t){if("object"!=Tc(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Tc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Tc(t)?t:String(t)}function Sc(e,t,n){return(t=Dc(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Oc(e){for(var t=1;t{var t=(new Error).stack.replace(/^Error\s+/,"");return t=(t=t.split("\n")[e]).replace(/^\s+at Object./,"").replace(/^\s+at /,"").replace(/ \(.+\)$/,"")},throwError:(e="unknown function",t="unknown parameter",n="to be defined")=>{throw["@",e,"(): Expected parameter '",t,"' ",n].join("")},isUndefined:(e="",t)=>{[null,void 0].indexOf(t)>-1&&xc.throwError(xc.getCaller(2),e)},isFalsy:(e="",t)=>{t||xc.throwError(xc.getCaller(2),e)},isNoneOf:(e="",t,n=[])=>{-1===n.indexOf(t)&&xc.throwError(xc.getCaller(2),e,"to be any of"+JSON.stringify(n))},isAnyOf:(e="",t,n=[])=>{n.indexOf(t)>-1&&xc.throwError(xc.getCaller(2),e,"not to be any of"+JSON.stringify(n))},isNotType:(e="",t,n="")=>{Object(Ec.getType)(t)!==n.toLowerCase()&&xc.throwError(xc.getCaller(2),e,"to be type "+n.toLowerCase())},isAnyTypeOf:(e="",t,n=[])=>{n.forEach(n=>{Object(Ec.getType)(t)===n&&xc.throwError(xc.getCaller(2),e,"not to be type of "+n.toLowerCase())})},missingKey:(e="",t,n="")=>{xc.isUndefined(e,t),-1===Object.keys(t).indexOf(n)&&xc.throwError(xc.getCaller(2),e,"to contain '"+n+"' key")},missingAnyKeys:(e="",t,n=[""])=>{xc.isUndefined(e,t);const r=Object.keys(t);n.forEach(t=>{-1===r.indexOf(t)&&xc.throwError(xc.getCaller(2),e,"to contain '"+t+"' key")})},containsUndefined:(e="",t)=>{[void 0,null].forEach(n=>{const r=Object(Ec.locate)(t,n);r&&xc.throwError(xc.getCaller(2),e,"not to contain '"+JSON.stringify(n)+"' at "+r)})},isInvalidPath:(e="",t)=>{xc.isUndefined(e,t),xc.isNotType(e,t,"string"),xc.isAnyOf(e,t,["","/"]),".$[]#".split().forEach(n=>{t.indexOf(n)>-1&&xc.throwError(xc.getCaller(2),e,"not to contain invalid character '"+n+"'")}),t.match(/\/{2,}/g)&&xc.throwError(xc.getCaller(2),e,"not to contain consecutive forward slash characters")},isInvalidWriteData:(e="",t)=>{xc.isUndefined(e,t),xc.containsUndefined(e,t)}};var Pc=xc;const Cc=(e,t)=>t?Object.keys(t).reduce((e,n)=>e.replace(new RegExp(`\\{${n}\\}`,"gi"),(e=>Array.isArray(e)?e.join(", "):"string"==typeof e?e:""+e)(t[n])),e):e;var Hc={format:"{reason} at line {line}",symbols:{colon:"colon",comma:"comma",semicolon:"semicolon",slash:"slash",backslash:"backslash",brackets:{round:"round brackets",square:"square brackets",curly:"curly brackets",angle:"angle brackets"},period:"period",quotes:{single:"single quote",double:"double quote",grave:"grave accent"},space:"space",ampersand:"ampersand",asterisk:"asterisk",at:"at sign",equals:"equals sign",hash:"hash",percent:"percent",plus:"plus",minus:"minus",dash:"dash",hyphen:"hyphen",tilde:"tilde",underscore:"underscore",bar:"vertical bar"},types:{key:"key",value:"value",number:"number",string:"string",primitive:"primitive",boolean:"boolean",character:"character",integer:"integer",array:"array",float:"float"},invalidToken:{tokenSequence:{prohibited:"'{firstToken}' token cannot be followed by '{secondToken}' token(s)",permitted:"'{firstToken}' token can only be followed by '{secondToken}' token(s)"},termSequence:{prohibited:"A {firstTerm} cannot be followed by a {secondTerm}",permitted:"A {firstTerm} can only be followed by a {secondTerm}"},double:"'{token}' token cannot be followed by another '{token}' token",useInstead:"'{badToken}' token is not accepted. Use '{goodToken}' instead",unexpected:"Unexpected '{token}' token found"},brace:{curly:{missingOpen:"Missing '{' open curly brace",missingClose:"Open '{' curly brace is missing closing '}' curly brace",cannotWrap:"'{token}' token cannot be wrapped in '{}' curly braces"},square:{missingOpen:"Missing '[' open square brace",missingClose:"Open '[' square brace is missing closing ']' square brace",cannotWrap:"'{token}' token cannot be wrapped in '[]' square braces"}},string:{missingOpen:"Missing/invalid opening string '{quote}' token",missingClose:"Missing/invalid closing string '{quote}' token",mustBeWrappedByQuotes:"Strings must be wrapped by quotes",nonAlphanumeric:"Non-alphanumeric token '{token}' is not allowed outside string notation",unexpectedKey:"Unexpected key found at string position"},key:{numberAndLetterMissingQuotes:"Key beginning with number and containing letters must be wrapped by quotes",spaceMissingQuotes:"Key containing space must be wrapped by quotes",unexpectedString:"Unexpected string found at key position"},noTrailingOrLeadingComma:"Trailing or leading commas in arrays and objects are not permitted"}; +!function(t,r){"use strict";var a;try{a=n(0)}catch(e){}e.exports=function(e){var t="function"==typeof e,n=!!window.addEventListener,r=window.document,a=window.setTimeout,o=function(e,t,r,a){n?e.addEventListener(t,r,!!a):e.attachEvent("on"+t,r)},i=function(e,t,r,a){n?e.removeEventListener(t,r,!!a):e.detachEvent("on"+t,r)},s=function(e,t,n){var a;r.createEvent?((a=r.createEvent("HTMLEvents")).initEvent(t,!0,!1),a=_(a,n),e.dispatchEvent(a)):r.createEventObject&&(a=r.createEventObject(),a=_(a,n),e.fireEvent("on"+t,a))},l=function(e,t){return-1!==(" "+e.className+" ").indexOf(" "+t+" ")},u=function(e){return/Array/.test(Object.prototype.toString.call(e))},c=function(e){return/Date/.test(Object.prototype.toString.call(e))&&!isNaN(e.getTime())},d=function(e){var t=e.getDay();return 0===t||6===t},p=function(e){return e%4==0&&e%100!=0||e%400==0},m=function(e,t){return[31,p(e)?29:28,31,30,31,30,31,31,30,31,30,31][t]},h=function(e){c(e)&&e.setHours(0,0,0,0)},f=function(e,t){return e.getTime()===t.getTime()},_=function(e,t,n){var r,a;for(r in t)(a=void 0!==e[r])&&"object"==typeof t[r]&&null!==t[r]&&void 0===t[r].nodeName?c(t[r])?n&&(e[r]=new Date(t[r].getTime())):u(t[r])?n&&(e[r]=t[r].slice(0)):e[r]=_({},t[r],n):!n&&a||(e[r]=t[r]);return e},y=function(e){return e.month<0&&(e.year-=Math.ceil(Math.abs(e.month)/12),e.month+=12),e.month>11&&(e.year+=Math.floor(Math.abs(e.month)/12),e.month-=12),e},b={field:null,bound:void 0,position:"bottom left",reposition:!0,format:"YYYY-MM-DD",defaultDate:null,setDefaultDate:!1,firstDay:0,formatStrict:!1,minDate:null,maxDate:null,yearRange:10,showWeekNumber:!1,minYear:0,maxYear:9999,minMonth:void 0,maxMonth:void 0,startRange:null,endRange:null,isRTL:!1,yearSuffix:"",showMonthAfterYear:!1,showDaysInNextAndPreviousMonths:!1,numberOfMonths:1,mainCalendar:"left",container:void 0,i18n:{previousMonth:"Previous Month",nextMonth:"Next Month",months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},theme:null,onSelect:null,onOpen:null,onClose:null,onDraw:null},g=function(e,t,n){for(t+=e.firstDay;t>=7;)t-=7;return n?e.i18n.weekdaysShort[t]:e.i18n.weekdays[t]},v=function(e){var t=[],n="false";if(e.isEmpty){if(!e.showDaysInNextAndPreviousMonths)return'';t.push("is-outside-current-month")}return e.isDisabled&&t.push("is-disabled"),e.isToday&&t.push("is-today"),e.isSelected&&(t.push("is-selected"),n="true"),e.isInRange&&t.push("is-inrange"),e.isStartRange&&t.push("is-startrange"),e.isEndRange&&t.push("is-endrange"),'"},w=function(e,t){return""+(t?e.reverse():e).join("")+""},M=function(e,t,n,r,a,o){var i,s,l,c,d,p=e._o,m=n===p.minYear,h=n===p.maxYear,f='
',_=!0,y=!0;for(l=[],i=0;i<12;i++)l.push('");for(c='
'+p.i18n.months[r]+'
",u(p.yearRange)?(i=p.yearRange[0],s=p.yearRange[1]+1):(i=n-p.yearRange,s=1+n+p.yearRange),l=[];i=p.minYear&&l.push('");return d='
'+n+p.yearSuffix+'
",p.showMonthAfterYear?f+=d+c:f+=c+d,m&&(0===r||p.minMonth>=r)&&(_=!1),h&&(11===r||p.maxMonth<=r)&&(y=!1),0===t&&(f+='"),t===e._o.numberOfMonths-1&&(f+='"),f+"
"},L=function(i){var s=this,u=s.config(i);s._onMouseDown=function(e){if(s._v){var t=(e=e||window.event).target||e.srcElement;if(t)if(l(t,"is-disabled")||(!l(t,"pika-button")||l(t,"is-empty")||l(t.parentNode,"is-disabled")?l(t,"pika-prev")?s.prevMonth():l(t,"pika-next")&&s.nextMonth():(s.setDate(new Date(t.getAttribute("data-pika-year"),t.getAttribute("data-pika-month"),t.getAttribute("data-pika-day"))),u.bound&&a((function(){s.hide(),u.field&&u.field.blur()}),100))),l(t,"pika-select"))s._c=!0;else{if(!e.preventDefault)return e.returnValue=!1,!1;e.preventDefault()}}},s._onChange=function(e){var t=(e=e||window.event).target||e.srcElement;t&&(l(t,"pika-select-month")?s.gotoMonth(t.value):l(t,"pika-select-year")&&s.gotoYear(t.value))},s._onKeyChange=function(e){if(e=e||window.event,s.isVisible())switch(e.keyCode){case 13:case 27:u.field.blur();break;case 37:e.preventDefault(),s.adjustDate("subtract",1);break;case 38:s.adjustDate("subtract",7);break;case 39:s.adjustDate("add",1);break;case 40:s.adjustDate("add",7)}},s._onInputChange=function(n){var r;n.firedBy!==s&&(r=t?(r=e(u.field.value,u.format,u.formatStrict))&&r.isValid()?r.toDate():null:new Date(Date.parse(u.field.value)),c(r)&&s.setDate(r),s._v||s.show())},s._onInputFocus=function(){s.show()},s._onInputClick=function(){s.show()},s._onInputBlur=function(){var e=r.activeElement;do{if(l(e,"pika-single"))return}while(e=e.parentNode);s._c||(s._b=a((function(){s.hide()}),50)),s._c=!1},s._onClick=function(e){var t=(e=e||window.event).target||e.srcElement,r=t;if(t){!n&&l(t,"pika-select")&&(t.onchange||(t.setAttribute("onchange","return;"),o(t,"change",s._onChange)));do{if(l(r,"pika-single")||r===u.trigger)return}while(r=r.parentNode);s._v&&t!==u.trigger&&r!==u.trigger&&s.hide()}},s.el=r.createElement("div"),s.el.className="pika-single"+(u.isRTL?" is-rtl":"")+(u.theme?" "+u.theme:""),o(s.el,"mousedown",s._onMouseDown,!0),o(s.el,"touchend",s._onMouseDown,!0),o(s.el,"change",s._onChange),o(r,"keydown",s._onKeyChange),u.field&&(u.container?u.container.appendChild(s.el):u.bound?r.body.appendChild(s.el):u.field.parentNode.insertBefore(s.el,u.field.nextSibling),o(u.field,"change",s._onInputChange),u.defaultDate||(t&&u.field.value?u.defaultDate=e(u.field.value,u.format).toDate():u.defaultDate=new Date(Date.parse(u.field.value)),u.setDefaultDate=!0));var d=u.defaultDate;c(d)?u.setDefaultDate?s.setDate(d,!0):s.gotoDate(d):s.gotoDate(new Date),u.bound?(this.hide(),s.el.className+=" is-bound",o(u.trigger,"click",s._onInputClick),o(u.trigger,"focus",s._onInputFocus),o(u.trigger,"blur",s._onInputBlur)):this.show()};return L.prototype={config:function(e){this._o||(this._o=_({},b,!0));var t=_(this._o,e,!0);t.isRTL=!!t.isRTL,t.field=t.field&&t.field.nodeName?t.field:null,t.theme="string"==typeof t.theme&&t.theme?t.theme:null,t.bound=!!(void 0!==t.bound?t.field&&t.bound:t.field),t.trigger=t.trigger&&t.trigger.nodeName?t.trigger:t.field,t.disableWeekends=!!t.disableWeekends,t.disableDayFn="function"==typeof t.disableDayFn?t.disableDayFn:null;var n=parseInt(t.numberOfMonths,10)||1;if(t.numberOfMonths=n>4?4:n,c(t.minDate)||(t.minDate=!1),c(t.maxDate)||(t.maxDate=!1),t.minDate&&t.maxDate&&t.maxDate100&&(t.yearRange=100);return t},toString:function(n){return c(this._d)?t?e(this._d).format(n||this._o.format):this._d.toDateString():""},getMoment:function(){return t?e(this._d):null},setMoment:function(n,r){t&&e.isMoment(n)&&this.setDate(n.toDate(),r)},getDate:function(){return c(this._d)?new Date(this._d.getTime()):new Date},setDate:function(e,t){if(!e)return this._d=null,this._o.field&&(this._o.field.value="",s(this._o.field,"change",{firedBy:this})),this.draw();if("string"==typeof e&&(e=new Date(Date.parse(e))),c(e)){var n=this._o.minDate,r=this._o.maxDate;c(n)&&er&&(e=r),this._d=new Date(e.getTime()),h(this._d),this.gotoDate(this._d),this._o.field&&(this._o.field.value=this.toString(),s(this._o.field,"change",{firedBy:this})),t||"function"!=typeof this._o.onSelect||this._o.onSelect.call(this,this.getDate())}},gotoDate:function(e){var t=!0;if(c(e)){if(this.calendars){var n=new Date(this.calendars[0].year,this.calendars[0].month,1),r=new Date(this.calendars[this.calendars.length-1].year,this.calendars[this.calendars.length-1].month,1),a=e.getTime();r.setMonth(r.getMonth()+1),r.setDate(r.getDate()-1),t=a=o&&(this._y=o,!isNaN(s)&&this._m>s&&(this._m=s)),t="pika-title-"+Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,2);for(var u=0;u'+M(this,u,this.calendars[u].year,this.calendars[u].month,this.calendars[0].year,t)+this.render(this.calendars[u].year,this.calendars[u].month,t)+"
";this.el.innerHTML=l,n.bound&&"hidden"!==n.field.type&&a((function(){n.trigger.focus()}),1),"function"==typeof this._o.onDraw&&this._o.onDraw(this),n.bound&&n.field.setAttribute("aria-label","Use the arrow keys to pick a date")}},adjustPosition:function(){var e,t,n,a,o,i,s,l,u,c;if(!this._o.container){if(this.el.style.position="absolute",t=e=this._o.trigger,n=this.el.offsetWidth,a=this.el.offsetHeight,o=window.innerWidth||r.documentElement.clientWidth,i=window.innerHeight||r.documentElement.clientHeight,s=window.pageYOffset||r.body.scrollTop||r.documentElement.scrollTop,"function"==typeof e.getBoundingClientRect)l=(c=e.getBoundingClientRect()).left+window.pageXOffset,u=c.bottom+window.pageYOffset;else for(l=t.offsetLeft,u=t.offsetTop+t.offsetHeight;t=t.offsetParent;)l+=t.offsetLeft,u+=t.offsetTop;(this._o.reposition&&l+n>o||this._o.position.indexOf("right")>-1&&l-n+e.offsetWidth>0)&&(l=l-n+e.offsetWidth),(this._o.reposition&&u+a>i+s||this._o.position.indexOf("top")>-1&&u-a-e.offsetHeight>0)&&(u=u-a-e.offsetHeight),this.el.style.left=l+"px",this.el.style.top=u+"px"}},render:function(e,t,n){var r=this._o,a=new Date,o=m(e,t),i=new Date(e,t,1).getDay(),s=[],l=[];h(a),r.firstDay>0&&(i-=r.firstDay)<0&&(i+=7);for(var u,p,_,y,b=0===t?11:t-1,M=11===t?0:t+1,L=0===t?e-1:e,k=11===t?e+1:e,Y=m(L,b),T=o+i,D=T;D>7;)D-=7;T+=7-D;for(var S=0,O=0;S=o+i,C=S-i+1,H=t,z=e,A=r.startRange&&f(r.startRange,j),N=r.endRange&&f(r.endRange,j),R=r.startRange&&r.endRange&&r.startRanger.maxDate||r.disableWeekends&&d(j)||r.disableDayFn&&r.disableDayFn(j),isEmpty:P,isStartRange:A,isEndRange:N,isInRange:R,showDaysInNextAndPreviousMonths:r.showDaysInNextAndPreviousMonths};l.push(v(F)),7==++O&&(r.showWeekNumber&&l.unshift((u=S-i,p=t,_=e,y=void 0,void 0,y=new Date(_,0,1),''+Math.ceil(((new Date(_,p,u)-y)/864e5+y.getDay()+1)/7)+"")),s.push(w(l,r.isRTL)),l=[],O=0)}return function(e,t,n){return''+function(e){var t,n=[];e.showWeekNumber&&n.push("");for(t=0;t<7;t++)n.push('");return""+(e.isRTL?n.reverse():n).join("")+""}(e)+(r=t,""+r.join("")+"
'+g(e,t,!0)+"
");var r}(r,s,n)},isVisible:function(){return this._v},show:function(){var e,t,n;this.isVisible()||(e=this.el,t="is-hidden",e.className=(n=(" "+e.className+" ").replace(" "+t+" "," ")).trim?n.trim():n.replace(/^\s+|\s+$/g,""),this._v=!0,this.draw(),this._o.bound&&(o(r,"click",this._onClick),this.adjustPosition()),"function"==typeof this._o.onOpen&&this._o.onOpen.call(this))},hide:function(){var e,t,n=this._v;!1!==n&&(this._o.bound&&i(r,"click",this._onClick),this.el.style.position="static",this.el.style.left="auto",this.el.style.top="auto",e=this.el,l(e,t="is-hidden")||(e.className=""===e.className?t:e.className+" "+t),this._v=!1,void 0!==n&&"function"==typeof this._o.onClose&&this._o.onClose.call(this))},destroy:function(){this.hide(),i(this.el,"mousedown",this._onMouseDown,!0),i(this.el,"touchend",this._onMouseDown,!0),i(this.el,"change",this._onChange),this._o.field&&(i(this._o.field,"change",this._onInputChange),this._o.bound&&(i(this._o.trigger,"click",this._onInputClick),i(this._o.trigger,"focus",this._onInputFocus),i(this._o.trigger,"blur",this._onInputBlur))),this.el.parentNode&&this.el.parentNode.removeChild(this.el)}},L}(a)}()},,function(e,t,n){},function(e,t,n){"use strict";n.r(t);var r=n(1),a=n.n(r),o=n(129),i=n.n(o),s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function l(e,t){function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var u=function(){return(u=Object.assign||function(e){for(var t,n=1,r=arguments.length;na[0]&&o[1])<[^<]*)*<\/script>/gi,""):r.series[t].format.truthy.replace(/)<[^<]*)*<\/script>/gi,"")},a=jQuery.fn.dataTable.render.extra}return a}},{key:"render",value:function(){var e=this.props.options;return wp.element.createElement(W,null,e.customcss&&wp.element.createElement("style",null,e.customcss.oddTableRow&&"#dataTable-instances-".concat(this.props.id,"-").concat(this.uniqueId," tr.odd {\n\t\t\t\t\t\t\t\t").concat(e.customcss.oddTableRow.color?"color: ".concat(e.customcss.oddTableRow.color," !important;"):"","\n\t\t\t\t\t\t\t\t").concat(e.customcss.oddTableRow["background-color"]?"background-color: ".concat(e.customcss.oddTableRow["background-color"]," !important;"):"","\n\t\t\t\t\t\t\t\t").concat(e.customcss.oddTableRow.transform?"transform: rotate( ".concat(e.customcss.oddTableRow.transform,"deg ) !important;"):"","\n\t\t\t\t\t\t\t}"),e.customcss.evenTableRow&&"#dataTable-instances-".concat(this.props.id,"-").concat(this.uniqueId," tr.even {\n\t\t\t\t\t\t\t\t").concat(e.customcss.evenTableRow.color?"color: ".concat(e.customcss.evenTableRow.color," !important;"):"","\n\t\t\t\t\t\t\t\t").concat(e.customcss.evenTableRow["background-color"]?"background-color: ".concat(e.customcss.evenTableRow["background-color"]," !important;"):"","\n\t\t\t\t\t\t\t\t").concat(e.customcss.evenTableRow.transform?"transform: rotate( ".concat(e.customcss.evenTableRow.transform,"deg ) !important;"):"","\n\t\t\t\t\t\t\t}"),e.customcss.tableCell&&"#dataTable-instances-".concat(this.props.id,"-").concat(this.uniqueId," tr td,\n\t\t\t\t\t\t\t#dataTable-instances-").concat(this.props.id,"-").concat(this.uniqueId,"_wrapper tr th {\n\t\t\t\t\t\t\t\t").concat(e.customcss.tableCell.color?"color: ".concat(e.customcss.tableCell.color," !important;"):"","\n\t\t\t\t\t\t\t\t").concat(e.customcss.tableCell["background-color"]?"background-color: ".concat(e.customcss.tableCell["background-color"]," !important;"):"","\n\t\t\t\t\t\t\t\t").concat(e.customcss.tableCell.transform?"transform: rotate( ".concat(e.customcss.tableCell.transform,"deg ) !important;"):"","\n\t\t\t\t\t\t\t}")),wp.element.createElement("table",{id:"dataTable-instances-".concat(this.props.id,"-").concat(this.uniqueId)}))}}])&&P(n.prototype,r),a&&P(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(F),B=n(5),J=n.n(B),U=n(131),G=n.n(U),q=function(e){return Object.keys(e["visualizer-series"]).map((function(t){void 0!==e["visualizer-series"][t].type&&"date"===e["visualizer-series"][t].type&&Object.keys(e["visualizer-data"]).map((function(n){return e["visualizer-data"][n][t]=new Date(e["visualizer-data"][n][t])}))})),e},V=function(e){var t;if(Array.isArray(e))return 0=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function ie(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function se(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){ie(o,r,a,i,s,"next",e)}function s(e){ie(o,r,a,i,s,"throw",e)}i(void 0)}))}}function le(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ue(e,t){for(var n=0;na.length&&(n=!0),this.setState({charts:this.state.charts.concat(a),isBusy:!1,chartsLoaded:n});case 9:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"render",value:function(){var e=this,t="undefined"!=typeof google?google.visualization.Version:"current",n=this.state,r=n.charts,a=n.isBusy,o=n.chartsLoaded,i=n.perPage;return wp.element.createElement("div",{className:"visualizer-settings__charts"},wp.element.createElement(Ye,{status:"warning",isDismissible:!1},_e("ChartJS charts are currently not available for selection here, you must visit the library, get the shortcode, and add the chart here in a shortcode tag."),wp.element.createElement(ke,{href:visualizerLocalize.adminPage},_e("Click here to visit Visualizer Charts Library."))),null!==r?1<=r.length?wp.element.createElement(ve,null,wp.element.createElement("div",{className:"visualizer-settings__charts-grid"},Object.keys(r).map((function(n){var a,o,i,s=q(r[n].chart_data);if(a=s["visualizer-settings"].title?s["visualizer-settings"].title:"#".concat(r[n].id),0<=["gauge","tabular","timeline"].indexOf(s["visualizer-chart-type"])?"DataTable"===s["visualizer-chart-library"]?o=s["visualizer-chart-type"]:("tabular"===(o=s["visualizer-chart-type"])&&(o="table"),o=fe(o)):o="".concat(fe(s["visualizer-chart-type"]),"Chart"),!s["visualizer-chart-library"]||"ChartJS"!==s["visualizer-chart-library"])return s["visualizer-data-exploded"]&&(i=_e("Annotations in this chart may not display here but they will display in the front end.")),wp.element.createElement("div",{className:"visualizer-settings__charts-single","data-chart-type":o,key:"chart-".concat(r[n].id)},wp.element.createElement("div",{className:"visualizer-settings__charts-title"},a),"DataTable"===s["visualizer-chart-library"]?wp.element.createElement(I,{id:r[n].id,rows:s["visualizer-data"],columns:s["visualizer-series"],chartsScreen:!0,options:s["visualizer-settings"]}):(s["visualizer-data-exploded"],wp.element.createElement(S,{chartVersion:t,chartType:o,rows:s["visualizer-data"],columns:s["visualizer-series"],options:K(s["visualizer-settings"]),formatters:X(s),chartPackages:re})),wp.element.createElement("div",{className:"visualizer-settings__charts-footer"},wp.element.createElement("sub",null,i)),wp.element.createElement("div",{className:"visualizer-settings__charts-controls",title:_e("Insert Chart"),onClick:function(){return e.props.getChart(r[n].id)}},wp.element.createElement(Le,{icon:"upload"})))}))),!o&&i-1=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function $e(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function Ke(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){$e(o,r,a,i,s,"next",e)}function s(e){$e(o,r,a,i,s,"throw",e)}i(void 0)}))}}function Ze(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Qe(e,t){for(var n=0;n/g," ➤ "),value:t.data.roots[e]}})),this.setState({isLoading:!1,isFirstStepOpen:!1,isSecondStepOpen:!0,endpointRoots:n})):(this.setState({isLoading:!1}),alert(t.data.msg));case 5:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"getJSONData",value:(i=Ke(Ve().mark((function e(){var t,n;return Ve().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setState({isLoading:!0}),e.next=3,it({path:"/visualizer/v1/get-json-data?url=".concat(this.props.chart["visualizer-json-url"],"&chart=").concat(this.props.id),data:{root:this.props.chart["visualizer-json-root"]||this.state.endpointRoots[0].value,method:this.props.chart["visualizer-json-headers"]?this.props.chart["visualizer-json-headers"].method:this.state.requestHeaders.method,username:this.props.chart["visualizer-json-headers"]&&"object"===qe(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth.username:this.state.requestHeaders.username,password:this.props.chart["visualizer-json-headers"]&&"object"===qe(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth.password:this.state.requestHeaders.password,auth:this.props.chart["visualizer-json-headers"]&&"object"!==qe(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth:this.state.requestHeaders.auth},method:"GET"});case 3:(t=e.sent).success?(n=[{label:at("Don't use pagination"),value:0}],t.data.paging&&"root>next"===t.data.paging[0]&&n.push({label:at("Get first 5 pages using root ➤ next"),value:"root>next"}),this.setState({isLoading:!1,isSecondStepOpen:!1,isFourthStepOpen:!0,endpointPaging:n,table:t.data.table}),document.querySelector("#visualizer-json-query-table").innerHTML=t.data.table,this.initTable()):(this.setState({isLoading:!1}),alert(t.data.msg));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"getTableData",value:(o=Ke(Ve().mark((function e(){var t,n,r,a,o;return Ve().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setState({isLoading:!0}),t=document.querySelectorAll("#visualizer-json-query-table input"),n=document.querySelectorAll("#visualizer-json-query-table select"),r=[],a={},t.forEach((function(e){return r.push(e.value)})),n.forEach((function(e){return a[e.name]=e.value})),e.next=9,it({path:"/visualizer/v1/set-json-data",data:Ue({url:this.props.chart["visualizer-json-url"],method:this.props.chart["visualizer-json-headers"]?this.props.chart["visualizer-json-headers"].method:this.state.requestHeaders.method,username:this.props.chart["visualizer-json-headers"]&&"object"===qe(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth.username:this.state.requestHeaders.username,password:this.props.chart["visualizer-json-headers"]&&"object"===qe(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth.password:this.state.requestHeaders.password,auth:this.props.chart["visualizer-json-headers"]&&"object"!==qe(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth:this.state.requestHeaders.auth,root:this.props.chart["visualizer-json-root"]||this.state.endpointRoots[0].value,paging:this.props.chart["visualizer-json-paging"]||0,header:r},a),method:"GET"});case 9:(o=e.sent).success?(this.props.JSONImportData(o.data.name,JSON.parse(o.data.series),JSON.parse(o.data.data)),this.setState({isOpen:!1,isLoading:!1})):(alert(o.data.msg),this.setState({isLoading:!1}));case 11:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"render",value:function(){var e=this;return wp.element.createElement(mt,{title:at("Import from JSON"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement("p",null,at("You can choose here to import or synchronize your chart data with a remote JSON source.")),wp.element.createElement("p",null,wp.element.createElement(ct,{href:"https://docs.themeisle.com/article/1052-how-to-generate-charts-from-json-data-rest-endpoints"},at("For more info check this tutorial."))),wp.element.createElement(ht,{label:at("How often do you want to check the url?"),value:this.props.chart["visualizer-json-schedule"]?this.props.chart["visualizer-json-schedule"]:1,options:[{label:at("One-time"),value:"-1"},{label:at("Live"),value:"0"},{label:at("Each hour"),value:"1"},{label:at("Each 12 hours"),value:"12"},{label:at("Each day"),value:"24"},{label:at("Each 3 days"),value:"72"}],onChange:this.props.editSchedule}),wp.element.createElement(ut,{isPrimary:!0,isLarge:!0,onClick:this.openModal},at("Modify Parameters")),this.state.isOpen&&wp.element.createElement(pt,{title:at("Import from JSON"),className:"visualizer-json-query-modal",shouldCloseOnClickOutside:!1,onRequestClose:function(){e.setState({isOpen:!1,isTableRendered:!1})}},wp.element.createElement(mt,{title:at("Step 1: Specify the JSON endpoint/URL"),opened:this.state.isFirstStepOpen,onToggle:function(){return e.onToggle("isFirstStepOpen")}},wp.element.createElement("p",null,at("If you want to add authentication, add headers to the endpoint or change the request in any way, please refer to our document here:")),wp.element.createElement("p",null,wp.element.createElement(ct,{href:"https://docs.themeisle.com/article/1043-visualizer-how-to-extend-rest-endpoints-with-json-response"},at("How to extend REST endpoints with JSON response"))),wp.element.createElement(ft,{placeholder:at("Please enter the URL of your JSON file"),value:this.props.chart["visualizer-json-url"]?this.props.chart["visualizer-json-url"]:"",onChange:this.props.editJSONURL}),wp.element.createElement(dt,{icon:"arrow-right-alt2",label:at("Add Headers"),onClick:this.toggleHeaders},at("Add Headers")),this.state.isHeaderPanelOpen&&wp.element.createElement("div",{className:"visualizer-json-query-modal-headers-panel"},wp.element.createElement(ht,{label:at("Request Type"),value:this.props.chart["visualizer-json-headers"]?this.props.chart["visualizer-json-headers"].method:this.state.requestHeaders.method,options:[{value:"GET",label:at("GET")},{value:"POST",label:at("POST")}],onChange:function(t){var n=Ue({},e.state.requestHeaders),r=e.state.requestHeaders;n.method=t,r=Ue(Ue({},r),{},{method:t}),e.setState({requestHeaders:r}),e.props.editJSONHeaders(n)}}),wp.element.createElement("p",null,at("Credentials")),wp.element.createElement(ft,{label:at("Username"),placeholder:at("Username/Access Key"),value:this.props.chart["visualizer-json-headers"]&&"object"===qe(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth.username:this.state.requestHeaders.username,onChange:function(t){var n=Ue({},e.state.requestHeaders),r=e.state.requestHeaders;n.auth={username:t,password:e.props.chart["visualizer-json-headers"]&&"object"===qe(e.props.chart["visualizer-json-headers"].auth)?e.props.chart["visualizer-json-headers"].auth.password:e.state.requestHeaders.password},r=Ue(Ue({},r),{},{username:t,password:n.password}),e.setState({requestHeaders:r}),e.props.editJSONHeaders(n)}}),wp.element.createElement("span",{className:"visualizer-json-query-modal-field-separator"},at("&")),wp.element.createElement(ft,{label:at("Password"),placeholder:at("Password/Secret Key"),type:"password",value:this.props.chart["visualizer-json-headers"]&&"object"===qe(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth.password:this.state.requestHeaders.password,onChange:function(t){var n=Ue({},e.state.requestHeaders),r=e.state.requestHeaders;n.auth={username:e.props.chart["visualizer-json-headers"]&&"object"===qe(e.props.chart["visualizer-json-headers"].auth)?e.props.chart["visualizer-json-headers"].auth.username:e.state.requestHeaders.username,password:t},r=Ue(Ue({},r),{},{username:n.username,password:t}),e.setState({requestHeaders:r}),e.props.editJSONHeaders(n)}}),wp.element.createElement("p",null,at("OR")),wp.element.createElement(ft,{label:at("Authorization"),placeholder:at("e.g. SharedKey :"),value:this.props.chart["visualizer-json-headers"]&&"object"!==qe(this.props.chart["visualizer-json-headers"].auth)?this.props.chart["visualizer-json-headers"].auth:this.state.requestHeaders.auth,onChange:function(t){var n=Ue({},e.state.requestHeaders),r=e.state.requestHeaders;n.auth=t,r=Ue(Ue({},r),{},{auth:t}),e.setState({requestHeaders:r}),e.props.editJSONHeaders(n)}})),wp.element.createElement(ut,{isPrimary:!0,isLarge:!0,isBusy:this.state.isLoading,disabled:this.state.isLoading,onClick:this.getJSONRoot},at("Fetch Endpoint"))),wp.element.createElement(mt,{title:at("Step 2: Choose the JSON root"),initialOpen:!1,opened:this.state.isSecondStepOpen,onToggle:function(){return e.onToggle("isSecondStepOpen")}},wp.element.createElement("p",null,at("If you see Invalid Data, you may have selected the wrong root to fetch data from. Please select an alternative.")),wp.element.createElement(ht,{value:this.props.chart["visualizer-json-root"],options:this.state.endpointRoots,onChange:this.props.editJSONRoot}),wp.element.createElement(ut,{isPrimary:!0,isLarge:!0,isBusy:this.state.isLoading,disabled:this.state.isLoading,onClick:this.getJSONData},at("Parse Endpoint"))),wp.element.createElement(mt,{title:at("Step 3: Specify miscellaneous parameters"),initialOpen:!1,opened:this.state.isThirdStepOpen,onToggle:function(){return e.onToggle("isThirdStepOpen")}},"community"!==visualizerLocalize.isPro?wp.element.createElement(ht,{value:this.props.chart["visualizer-json-paging"]||0,options:this.state.endpointPaging,onChange:this.props.editJSONPaging}):wp.element.createElement("p",null,at("Enable this feature in PRO version!"))),wp.element.createElement(mt,{title:at("Step 4: Select the data to display in the chart"),initialOpen:!1,opened:this.state.isFourthStepOpen,onToggle:function(){return e.onToggle("isFourthStepOpen")}},wp.element.createElement("ul",null,wp.element.createElement("li",null,at("Select whether to include the data in the chart. Each column selected will form one series.")),wp.element.createElement("li",null,at("If a column is selected to be included, specify its data type.")),wp.element.createElement("li",null,at("You can use drag/drop to reorder the columns but this column position is not saved. So when you reload the table, you may have to reorder again.")),wp.element.createElement("li",null,at("You can select any number of columns but the chart type selected will determine how many will display in the chart."))),wp.element.createElement("div",{id:"visualizer-json-query-table"}),wp.element.createElement(ut,{isPrimary:!0,isLarge:!0,isBusy:this.state.isLoading,disabled:this.state.isLoading,onClick:this.getTableData},at("Save & Show Chart")))))}}])&&Qe(n.prototype,r),a&&Qe(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(st);function yt(e){return(yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function bt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function gt(e,t){for(var n=0;n=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function Ct(e){return(Ct="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ht(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function zt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function At(e,t){for(var n=0;n=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function nn(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function rn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function an(e,t){for(var n=0;n=["timeline"].indexOf(t)&&(r[1]={label:vr("The tooltip will be displayed when the user selects an element"),value:"selection"}),r[2]={label:vr("The tooltip will not be displayed"),value:"none"};var a=[{label:vr("Left of the chart"),value:"left"},{label:vr("Right of the chart"),value:"right"},{label:vr("Above the chart"),value:"top"},{label:vr("Below the chart"),value:"bottom"},{label:vr("Omit the legend"),value:"none"}];"pie"!==t&&a.push({label:vr("Inside the chart"),value:"in"}),"bubble"===t&&(a=a.filter((function(e){return"left"!==e.value})));var o=vr("Text to display above the chart.");return 0<=["tabular","dataTable","gauge","geo","timeline"].indexOf(t)&&(o=vr("Text to display in the back-end admin area")),wp.element.createElement(Tr,{title:vr("General Settings"),initialOpen:!1,className:"visualizer-advanced-panel"},wp.element.createElement(Tr,{title:vr("Title"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Sr,{label:vr("Chart Title"),help:o,value:n.title,onChange:function(t){n.title=t,e.props.edit(n)}}),-1>=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(t)&&wp.element.createElement(Dr,{label:vr("Chart Title Position"),help:vr("Where to place the chart title, compared to the chart area."),value:n.titlePosition?n.titlePosition:"out",options:[{label:vr("Inside the chart"),value:"in"},{label:vr("Outside the chart"),value:"out"},{label:vr("None"),value:"none"}],onChange:function(t){n.titlePosition=t,e.props.edit(n)}}),-1>=["tabular","dataTable","gauge","geo","timeline"].indexOf(t)&&wp.element.createElement(kr,{label:vr("Chart Title Color")},wp.element.createElement(Mr,{value:n.titleTextStyle.color,onChange:function(t){n.titleTextStyle.color=t,e.props.edit(n)}})),-1>=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(t)&&wp.element.createElement(Dr,{label:vr("Axes Titles Position"),help:vr("Determines where to place the axis titles, compared to the chart area."),value:n.axisTitlesPosition?n.axisTitlesPosition:"out",options:[{label:vr("Inside the chart"),value:"in"},{label:vr("Outside the chart"),value:"out"},{label:vr("None"),value:"none"}],onChange:function(t){n.axisTitlesPosition=t,e.props.edit(n)}})),-1>=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(t)&&wp.element.createElement(Tr,{title:vr("Font Styles"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Dr,{label:vr("Font Family"),help:vr("The default font family for all text in the chart."),value:n.fontName?n.fontName:"Arial",options:[{label:vr("Arial"),value:"Arial"},{label:vr("Sans Serif"),value:"Sans Serif"},{label:vr("Serif"),value:"serif"},{label:vr("Arial"),value:"Arial"},{label:vr("Wide"),value:"Arial black"},{label:vr("Narrow"),value:"Arial Narrow"},{label:vr("Comic Sans MS"),value:"Comic Sans MS"},{label:vr("Courier New"),value:"Courier New"},{label:vr("Garamond"),value:"Garamond"},{label:vr("Georgia"),value:"Georgia"},{label:vr("Tahoma"),value:"Tahoma"},{label:vr("Verdana"),value:"Verdana"}],onChange:function(t){n.fontName=t,e.props.edit(n)}}),wp.element.createElement(Dr,{label:vr("Font Size"),help:vr("The default font size for all text in the chart."),value:n.fontSize?n.fontSize:"15",options:[{label:"7",value:"7"},{label:"8",value:"8"},{label:"9",value:"9"},{label:"10",value:"10"},{label:"11",value:"11"},{label:"12",value:"12"},{label:"13",value:"13"},{label:"14",value:"14"},{label:"15",value:"15"},{label:"16",value:"16"},{label:"17",value:"17"},{label:"18",value:"18"},{label:"19",value:"19"},{label:"20",value:"20"}],onChange:function(t){n.fontSize=t,e.props.edit(n)}})),-1>=["tabular","dataTable","gauge","geo","timeline"].indexOf(t)&&wp.element.createElement(Tr,{title:vr("Legend"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Dr,{label:vr("Position"),help:vr("Determines where to place the legend, compared to the chart area."),value:n.legend.position?n.legend.position:"right",options:a,onChange:function(r){if("pie"!==t){var a="left"===r?1:0;n.series&&Object.keys(n.series).map((function(e){n.series[e].targetAxisIndex=a}))}n.legend.position=r,e.props.edit(n)}}),wp.element.createElement(Dr,{label:vr("Alignment"),help:vr("Determines the alignment of the legend."),value:n.legend.alignment?n.legend.alignment:"15",options:[{label:vr("Aligned to the start of the allocated area"),value:"start"},{label:vr("Centered in the allocated area"),value:"center"},{label:vr("Aligned to the end of the allocated area"),value:"end"}],onChange:function(t){n.legend.alignment=t,e.props.edit(n)}}),wp.element.createElement(kr,{label:vr("Font Color")},wp.element.createElement(Mr,{value:n.legend.textStyle.color,onChange:function(t){n.legend.textStyle.color=t,e.props.edit(n)}}))),-1>=["tabular","gauge","geo","dataTable","timeline"].indexOf(t)&&wp.element.createElement(Tr,{title:vr("Tooltip"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Dr,{label:vr("Trigger"),help:vr("Determines the user interaction that causes the tooltip to be displayed."),value:n.tooltip.trigger?n.tooltip.trigger:"focus",options:r,onChange:function(t){n.tooltip.trigger=t,e.props.edit(n)}}),wp.element.createElement(Dr,{label:vr("Show Color Code"),help:vr("If set to yes, will show colored squares next to the slice information in the tooltip."),value:n.tooltip.showColorCode?n.tooltip.showColorCode:"0",options:[{label:vr("Yes"),value:"1"},{label:vr("No"),value:"0"}],onChange:function(t){n.tooltip.showColorCode=t,e.props.edit(n)}}),0<=["pie"].indexOf(t)&&wp.element.createElement(Dr,{label:vr("Text"),help:vr("Determines what information to display when the user hovers over a pie slice."),value:n.tooltip.text?n.tooltip.text:"both",options:[{label:vr("Display both the absolute value of the slice and the percentage of the whole"),value:"both"},{label:vr("Display only the absolute value of the slice"),value:"value"},{label:vr("Display only the percentage of the whole represented by the slice"),value:"percentage"}],onChange:function(t){n.tooltip.text=t,e.props.edit(n)}})),-1>=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(t)&&wp.element.createElement(Tr,{title:vr("Animation"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Yr,{label:vr("Animate on startup?"),help:vr("Determines if the chart will animate on the initial draw."),checked:Number(n.animation.startup),onChange:function(t){n.animation.startup=t?"1":"0",e.props.edit(n)}}),wp.element.createElement(Sr,{label:vr("Duration"),help:vr("The duration of the animation, in milliseconds."),type:"number",value:n.animation.duration,onChange:function(t){n.animation.duration=t,e.props.edit(n)}}),wp.element.createElement(Dr,{label:vr("Easing"),help:vr("The easing function applied to the animation."),value:n.animation.easing?n.animation.easing:"linear",options:[{label:vr("Constant speed"),value:"linear"},{label:vr("Start slow and speed up"),value:"in"},{label:vr("Start fast and slow down"),value:"out"},{label:vr("Start slow, speed up, then slow down"),value:"inAndOut"}],onChange:function(t){n.animation.easing=t,e.props.edit(n)}})))}}])&&fr(n.prototype,r),a&&fr(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(wr);function jr(e){return(jr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Er(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function xr(e,t){for(var n=0;n=["column"].indexOf(t)&&wp.element.createElement(ea,null,wp.element.createElement(sa,{label:Zr("Number Format"),help:Zr("Enter custom format pattern to apply to horizontal axis labels."),value:n.hAxis.format,onChange:function(t){n.hAxis.format=t,e.props.edit(n)}}),wp.element.createElement("p",null,Zr("For number axis labels, this is a subset of the formatting "),wp.element.createElement(aa,{href:"http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details"},Zr("ICU pattern set.")),Zr(" For instance, $#,###.## will display values $1,234.56 for value 1234.56. Pay attention that if you use #%% percentage format then your values will be multiplied by 100.")),wp.element.createElement("p",null,Zr("For date axis labels, this is a subset of the date formatting "),wp.element.createElement(aa,{href:"https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax"},Zr("ICU date and time format."))))),-1>=["column"].indexOf(t)&&wp.element.createElement(ea,null,wp.element.createElement(oa,{title:Zr("Grid Lines"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(sa,{label:Zr("Count"),help:Zr("The approximate number of horizontal gridlines inside the chart area. You can specify a value of -1 to automatically compute the number of gridlines, 0 or 1 to draw no gridlines, or 2 or more to only draw gridline. Any number greater than 2 will be used to compute the minSpacing between gridlines."),value:n.hAxis.gridlines?n.hAxis.gridlines.count:"",onChange:function(t){n.hAxis.gridlines||(n.hAxis.gridlines={}),n.hAxis.gridlines.count=t,e.props.edit(n)}}),wp.element.createElement(ra,{label:Zr("Color")},wp.element.createElement(ta,{value:n.hAxis.gridlines?n.hAxis.gridlines.color:"",onChange:function(t){n.hAxis.gridlines||(n.hAxis.gridlines={}),n.hAxis.gridlines.color=t,e.props.edit(n)}}))),wp.element.createElement(oa,{title:Zr("Minor Grid Lines"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(sa,{label:Zr("Count"),help:Zr("Specify 0 to disable the minor gridlines."),value:n.hAxis.minorGridlines?n.hAxis.minorGridlines.count:"",onChange:function(t){n.hAxis.minorGridlines||(n.hAxis.minorGridlines={}),n.hAxis.minorGridlines.count=t,e.props.edit(n)}}),wp.element.createElement(ra,{label:Zr("Color")},wp.element.createElement(ta,{value:n.hAxis.minorGridlines?n.hAxis.minorGridlines.color:"",onChange:function(t){n.hAxis.minorGridlines||(n.hAxis.minorGridlines={}),n.hAxis.minorGridlines.color=t,e.props.edit(n)}}))),wp.element.createElement(oa,{title:Zr("View Window"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(sa,{label:Zr("Maximun Value"),help:Zr("The maximum vertical data value to render."),value:n.hAxis.viewWindow?n.hAxis.viewWindow.max:"",onChange:function(t){n.hAxis.viewWindow||(n.hAxis.viewWindow={}),n.hAxis.viewWindow.max=t,e.props.edit(n)}}),wp.element.createElement(sa,{label:Zr("Minimum Value"),help:Zr("The minimum vertical data value to render."),value:n.hAxis.viewWindow?n.hAxis.viewWindow.min:"",onChange:function(t){n.hAxis.viewWindow||(n.hAxis.viewWindow={}),n.hAxis.viewWindow.min=t,e.props.edit(n)}}))))}}])&&Gr(n.prototype,r),a&&Gr(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(Xr);function ua(e){return(ua="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ca(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function da(e,t){for(var n=0;n=["bar"].indexOf(t)&&wp.element.createElement(ga,null,wp.element.createElement(Ta,{label:_a("Number Format"),help:_a("Enter custom format pattern to apply to Vertical axis labels."),value:n.vAxis.format,onChange:function(t){n.vAxis.format=t,e.props.edit(n)}}),wp.element.createElement("p",null,_a("For number axis labels, this is a subset of the formatting "),wp.element.createElement(La,{href:"http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details"},_a("ICU pattern set.")),_a(" For instance, $#,###.## will display values $1,234.56 for value 1234.56. Pay attention that if you use #%% percentage format then your values will be multiplied by 100.")),wp.element.createElement("p",null,_a("For date axis labels, this is a subset of the date formatting "),wp.element.createElement(La,{href:"https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax"},_a("ICU date and time format."))))),-1>=["bar"].indexOf(t)&&wp.element.createElement(ga,null,wp.element.createElement(ka,{title:_a("Grid Lines"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Ta,{label:_a("Count"),help:_a("The approximate number of vertical gridlines inside the chart area. You can specify a value of -1 to automatically compute the number of gridlines, 0 or 1 to draw no gridlines, or 2 or more to only draw gridline. Any number greater than 2 will be used to compute the minSpacing between gridlines."),value:n.vAxis.gridlines?n.vAxis.gridlines.count:"",onChange:function(t){n.vAxis.gridlines||(n.vAxis.gridlines={}),n.vAxis.gridlines.count=t,e.props.edit(n)}}),wp.element.createElement(Ma,{label:_a("Color")},wp.element.createElement(va,{value:n.vAxis.gridlines?n.vAxis.gridlines.color:"",onChange:function(t){n.vAxis.gridlines||(n.vAxis.gridlines={}),n.vAxis.gridlines.color=t,e.props.edit(n)}}))),wp.element.createElement(ka,{title:_a("Minor Grid Lines"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Ta,{label:_a("Count"),help:_a("Specify 0 to disable the minor gridlines."),value:n.vAxis.minorGridlines?n.vAxis.minorGridlines.count:"",onChange:function(t){n.vAxis.minorGridlines||(n.vAxis.minorGridlines={}),n.vAxis.minorGridlines.count=t,e.props.edit(n)}}),wp.element.createElement(Ma,{label:_a("Color")},wp.element.createElement(va,{value:n.vAxis.minorGridlines?n.vAxis.minorGridlines.color:"",onChange:function(t){n.vAxis.minorGridlines||(n.vAxis.minorGridlines={}),n.vAxis.minorGridlines.color=t,e.props.edit(n)}}))),wp.element.createElement(ka,{title:_a("View Window"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(Ta,{label:_a("Maximun Value"),help:_a("The maximum vertical data value to render."),value:n.vAxis.viewWindow?n.vAxis.viewWindow.max:"",onChange:function(t){n.vAxis.viewWindow||(n.vAxis.viewWindow={}),n.vAxis.viewWindow.max=t,e.props.edit(n)}}),wp.element.createElement(Ta,{label:_a("Minimum Value"),help:_a("The minimum vertical data value to render."),value:n.vAxis.viewWindow?n.vAxis.viewWindow.min:"",onChange:function(t){n.vAxis.viewWindow||(n.vAxis.viewWindow={}),n.vAxis.viewWindow.min=t,e.props.edit(n)}}))))}}])&&da(n.prototype,r),a&&da(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(ba);function Sa(e){return(Sa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Oa(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ja(e,t){for(var n=0;n=["area"].indexOf(t)&&wp.element.createElement(Mo,{label:_o("Curve Type"),help:_o("Determines whether the series has to be presented in the legend or not."),value:n.curveType?n.curveType:"none",options:[{label:_o("Straight line without curve"),value:"none"},{label:_o("The angles of the line will be smoothed"),value:"function"}],onChange:function(t){n.curveType=t,e.props.edit(n)}}),-1>=["scatter"].indexOf(t)&&wp.element.createElement(Mo,{label:_o("Focus Target"),help:_o("The type of the entity that receives focus on mouse hover. Also affects which entity is selected by mouse click."),value:n.focusTarget?n.focusTarget:"datum",options:[{label:_o("Focus on a single data point."),value:"datum"},{label:_o("Focus on a grouping of all data points along the major axis."),value:"category"}],onChange:function(t){n.focusTarget=t,e.props.edit(n)}}),wp.element.createElement(Mo,{label:_o("Selection Mode"),help:_o("Determines how many data points an user can select on a chart."),value:n.selectionMode?n.selectionMode:"single",options:[{label:_o("Single data point"),value:"single"},{label:_o("Multiple data points"),value:"multiple"}],onChange:function(t){n.selectionMode=t,e.props.edit(n)}}),wp.element.createElement(Mo,{label:_o("Aggregation Target"),help:_o("Determines how multiple data selections are rolled up into tooltips. To make it working you need to set multiple selection mode and tooltip trigger to display it when an user selects an element."),value:n.aggregationTarget?n.aggregationTarget:"auto",options:[{label:_o("Group selected data by x-value"),value:"category"},{label:_o("Group selected data by series"),value:"series"},{label:_o("Group selected data by x-value if all selections have the same x-value, and by series otherwise"),value:"auto"},{label:_o("Show only one tooltip per selection"),value:"none"}],onChange:function(t){n.aggregationTarget=t,e.props.edit(n)}}),wp.element.createElement(Lo,{label:_o("Point Opacity"),help:_o("The transparency of data points, with 1.0 being completely opaque and 0.0 fully transparent."),value:n.dataOpacity,onChange:function(t){n.dataOpacity=t,e.props.edit(n)}}),-1>=["scatter","line"].indexOf(t)&&wp.element.createElement(go,null,wp.element.createElement(Lo,{label:_o("Area Opacity"),help:_o("The default opacity of the colored area under an area chart series, where 0.0 is fully transparent and 1.0 is fully opaque. To specify opacity for an individual series, set the area opacity value in the series property."),value:n.areaOpacity,onChange:function(t){n.areaOpacity=t,e.props.edit(n)}}),wp.element.createElement(Mo,{label:_o("Is Stacked"),help:_o("If set to yes, series elements are stacked."),value:n.isStacked?n.isStacked:"0",options:[{label:_o("Yes"),value:"1"},{label:_o("No"),value:"0"}],onChange:function(t){n.isStacked=t,e.props.edit(n)}})),-1>=["scatter","area"].indexOf(t)&&wp.element.createElement(Mo,{label:_o("Interpolate Nulls"),help:_o("Whether to guess the value of missing points. If yes, it will guess the value of any missing data based on neighboring points. If no, it will leave a break in the line at the unknown point."),value:n.interpolateNulls?n.interpolateNulls:"0",options:[{label:_o("Yes"),value:"1"},{label:_o("No"),value:"0"}],onChange:function(t){n.interpolateNulls=t,e.props.edit(n)}}))}}])&&co(n.prototype,r),a&&co(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(bo);function Yo(e){return(Yo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function To(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Do(e,t){for(var n=0;n=["tabular","pie"].indexOf(s)&&wp.element.createElement(Kl,{label:Wl("Visible In Legend"),help:Wl("Determines whether the series has to be presented in the legend or not."),value:t.series[a].visibleInLegend?t.series[a].visibleInLegend:"1",options:[{label:Wl("Yes"),value:"1"},{label:Wl("No"),value:"0"}],onChange:function(n){t.series[a].visibleInLegend=n,e.props.edit(t)}}),-1>=["tabular","candlestick","combo","column","bar"].indexOf(s)&&wp.element.createElement(Jl,null,wp.element.createElement(Zl,{label:Wl("Line Width"),help:Wl("Overrides the global line width value for this series."),value:t.series[a].lineWidth,onChange:function(n){t.series[a].lineWidth=n,e.props.edit(t)},onKeyUp:function(n){clearTimeout(l),l=setTimeout((function(){""!=t.series[a].lineWidth&&0>=t.series[a].lineWidth&&(t.series[a].lineWidth="0.1",e.props.edit(t))}),700)}}),wp.element.createElement(Zl,{label:Wl("Point Size"),help:Wl("Overrides the global point size value for this series."),value:t.series[a].pointSize,onChange:function(n){t.series[a].pointSize=n,e.props.edit(t)}})),-1>=["candlestick"].indexOf(s)&&s&&"number"===s?wp.element.createElement(Jl,null,wp.element.createElement(Zl,{label:Wl("Format"),help:Wl("Enter custom format pattern to apply to this series value."),value:t.series[o].format,onChange:function(n){t.series[o].format=n,e.props.edit(t)}}),wp.element.createElement("p",null,Wl("For number axis labels, this is a subset of the formatting "),wp.element.createElement(Vl,{href:"http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details"},Wl("ICU pattern set.")),Wl(" For instance, $#,###.## will display values $1,234.56 for value 1234.56. Pay attention that if you use #%% percentage format then your values will be multiplied by 100."))):0<=["date","datetime","timeofday"].indexOf(s)&&wp.element.createElement(Jl,null,wp.element.createElement(Zl,{label:Wl("Date Format"),help:Wl("Enter custom format pattern to apply to this series value."),placeholder:"dd LLLL yyyy",value:t.series[o].format,onChange:function(n){t.series[o].format=n,e.props.edit(t)}}),wp.element.createElement("p",null,Wl("This is a subset of the date formatting "),wp.element.createElement(Vl,{href:"https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax"},Wl("ICU date and time format.")))),0<=["scatter","line"].indexOf(s)&&wp.element.createElement(Kl,{label:Wl("Curve Type"),help:Wl("Determines whether the series has to be presented in the legend or not."),value:t.series[a].curveType?t.series[a].curveType:"none",options:[{label:Wl("Straight line without curve"),value:"none"},{label:Wl("The angles of the line will be smoothed"),value:"function"}],onChange:function(n){t.series[a].curveType=n,e.props.edit(t)}}),0<=["area"].indexOf(s)&&wp.element.createElement(Zl,{label:Wl("Area Opacity"),help:Wl("The opacity of the colored area, where 0.0 is fully transparent and 1.0 is fully opaque."),value:t.series[a].areaOpacity,onChange:function(n){t.series[a].areaOpacity=n,e.props.edit(t)}}),0<=["combo"].indexOf(s)&&wp.element.createElement(Kl,{label:Wl("Chart Type"),help:Wl("Select the type of chart to show for this series."),value:t.series[a].type?t.series[a].type:"area",options:[{label:Wl("Area"),value:"area"},{label:Wl("Bar"),value:"bars"},{label:Wl("Candlesticks"),value:"candlesticks"},{label:Wl("Line"),value:"line"},{label:Wl("Stepped Area"),value:"steppedArea"}],onChange:function(n){t.series[a].type=n,e.props.edit(t)}}),-1>=["tabular"].indexOf(s)&&wp.element.createElement(ql,{label:Wl("Color")},wp.element.createElement(Ul,{value:t.series[a].color,onChange:function(n){t.series[a].color=n,e.props.edit(t)}})))})))}}])&&zl(n.prototype,r),a&&zl(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(Bl);function Xl(e){return(Xl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function eu(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function tu(e,t){for(var n=0;n=["gauge","tabular"].indexOf(t)&&wp.element.createElement(nc,null,wp.element.createElement(uc,{label:Xu("Stroke Width"),help:Xu("The chart border width in pixels."),value:n.backgroundColor.strokeWidth,onChange:function(t){n.backgroundColor.strokeWidth=t,e.props.edit(n)}}),wp.element.createElement(oc,{label:Xu("Stroke Color")},wp.element.createElement(rc,{value:n.backgroundColor.stroke,onChange:function(t){n.backgroundColor.stroke=t,e.props.edit(n)}})),wp.element.createElement(oc,{label:Xu("Background Color")},wp.element.createElement(rc,{value:n.backgroundColor.fill,onChange:function(t){n.backgroundColor.fill=t,e.props.edit(n)}})),wp.element.createElement(ic,{label:Xu("Transparent Background?"),checked:"transparent"===n.backgroundColor.fill,onChange:function(t){n.backgroundColor.fill="transparent"===n.backgroundColor.fill?"":"transparent",e.props.edit(n)}}))),-1>=["geo","gauge","tabular"].indexOf(t)&&wp.element.createElement(sc,{title:Xu("Chart Area"),className:"visualizer-inner-sections",initialOpen:!1},wp.element.createElement(uc,{label:Xu("Left Margin"),help:Xu("Determines how far to draw the chart from the left border."),value:n.chartArea.left,onChange:function(t){n.chartArea.left=t,e.props.edit(n)}}),wp.element.createElement(uc,{label:Xu("Top Margin"),help:Xu("Determines how far to draw the chart from the top border."),value:n.chartArea.top,onChange:function(t){n.chartArea.top=t,e.props.edit(n)}}),wp.element.createElement(uc,{label:Xu("Width Of Chart Area"),help:Xu("Determines the width of the chart area."),value:n.chartArea.width,onChange:function(t){n.chartArea.width=t,e.props.edit(n)}}),wp.element.createElement(uc,{label:Xu("Height Of Chart Area"),help:Xu("Determines the hight of the chart area."),value:n.chartArea.height,onChange:function(t){n.chartArea.height=t,e.props.edit(n)}})))}}])&&Vu(n.prototype,r),a&&Vu(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(tc);function dc(e){return(dc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function mc(e,t){for(var n=0;n=["dataTable","tabular","gauge","table"].indexOf(n)&&wp.element.createElement(kc,{label:bc("Download Image"),help:bc("To download the chart as an image."),checked:0<=t.actions.indexOf("image"),onChange:function(n){if(0<=t.actions.indexOf("image")){var r=t.actions.indexOf("image");-1!==r&&t.actions.splice(r,1)}else t.actions.push("image");e.props.edit(t)}}))):wp.element.createElement(Yc,{title:bc("Frontend Actions"),initialOpen:!1,icon:"lock",className:"visualizer-advanced-panel"},wp.element.createElement("p",null,bc("Enable this feature in PRO version!")),wp.element.createElement(Lc,{isPrimary:!0,href:visualizerLocalize.proTeaser,target:"_blank"},bc("Upgrade Now")))}}])&&mc(n.prototype,r),a&&mc(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(vc);function Dc(e){return(Dc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Sc(e){var t=function(e,t){if("object"!=Dc(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Dc(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Dc(t)?t:String(t)}function Oc(e,t,n){return(t=Sc(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jc(e){for(var t=1;t{var t=(new Error).stack.replace(/^Error\s+/,"");return t=(t=t.split("\n")[e]).replace(/^\s+at Object./,"").replace(/^\s+at /,"").replace(/ \(.+\)$/,"")},throwError:(e="unknown function",t="unknown parameter",n="to be defined")=>{throw["@",e,"(): Expected parameter '",t,"' ",n].join("")},isUndefined:(e="",t)=>{[null,void 0].indexOf(t)>-1&&Pc.throwError(Pc.getCaller(2),e)},isFalsy:(e="",t)=>{t||Pc.throwError(Pc.getCaller(2),e)},isNoneOf:(e="",t,n=[])=>{-1===n.indexOf(t)&&Pc.throwError(Pc.getCaller(2),e,"to be any of"+JSON.stringify(n))},isAnyOf:(e="",t,n=[])=>{n.indexOf(t)>-1&&Pc.throwError(Pc.getCaller(2),e,"not to be any of"+JSON.stringify(n))},isNotType:(e="",t,n="")=>{Object(xc.getType)(t)!==n.toLowerCase()&&Pc.throwError(Pc.getCaller(2),e,"to be type "+n.toLowerCase())},isAnyTypeOf:(e="",t,n=[])=>{n.forEach(n=>{Object(xc.getType)(t)===n&&Pc.throwError(Pc.getCaller(2),e,"not to be type of "+n.toLowerCase())})},missingKey:(e="",t,n="")=>{Pc.isUndefined(e,t),-1===Object.keys(t).indexOf(n)&&Pc.throwError(Pc.getCaller(2),e,"to contain '"+n+"' key")},missingAnyKeys:(e="",t,n=[""])=>{Pc.isUndefined(e,t);const r=Object.keys(t);n.forEach(t=>{-1===r.indexOf(t)&&Pc.throwError(Pc.getCaller(2),e,"to contain '"+t+"' key")})},containsUndefined:(e="",t)=>{[void 0,null].forEach(n=>{const r=Object(xc.locate)(t,n);r&&Pc.throwError(Pc.getCaller(2),e,"not to contain '"+JSON.stringify(n)+"' at "+r)})},isInvalidPath:(e="",t)=>{Pc.isUndefined(e,t),Pc.isNotType(e,t,"string"),Pc.isAnyOf(e,t,["","/"]),".$[]#".split().forEach(n=>{t.indexOf(n)>-1&&Pc.throwError(Pc.getCaller(2),e,"not to contain invalid character '"+n+"'")}),t.match(/\/{2,}/g)&&Pc.throwError(Pc.getCaller(2),e,"not to contain consecutive forward slash characters")},isInvalidWriteData:(e="",t)=>{Pc.isUndefined(e,t),Pc.containsUndefined(e,t)}};var Cc=Pc;const Hc=(e,t)=>t?Object.keys(t).reduce((e,n)=>e.replace(new RegExp(`\\{${n}\\}`,"gi"),(e=>Array.isArray(e)?e.join(", "):"string"==typeof e?e:""+e)(t[n])),e):e;var zc={format:"{reason} at line {line}",symbols:{colon:"colon",comma:"comma",semicolon:"semicolon",slash:"slash",backslash:"backslash",brackets:{round:"round brackets",square:"square brackets",curly:"curly brackets",angle:"angle brackets"},period:"period",quotes:{single:"single quote",double:"double quote",grave:"grave accent"},space:"space",ampersand:"ampersand",asterisk:"asterisk",at:"at sign",equals:"equals sign",hash:"hash",percent:"percent",plus:"plus",minus:"minus",dash:"dash",hyphen:"hyphen",tilde:"tilde",underscore:"underscore",bar:"vertical bar"},types:{key:"key",value:"value",number:"number",string:"string",primitive:"primitive",boolean:"boolean",character:"character",integer:"integer",array:"array",float:"float"},invalidToken:{tokenSequence:{prohibited:"'{firstToken}' token cannot be followed by '{secondToken}' token(s)",permitted:"'{firstToken}' token can only be followed by '{secondToken}' token(s)"},termSequence:{prohibited:"A {firstTerm} cannot be followed by a {secondTerm}",permitted:"A {firstTerm} can only be followed by a {secondTerm}"},double:"'{token}' token cannot be followed by another '{token}' token",useInstead:"'{badToken}' token is not accepted. Use '{goodToken}' instead",unexpected:"Unexpected '{token}' token found"},brace:{curly:{missingOpen:"Missing '{' open curly brace",missingClose:"Open '{' curly brace is missing closing '}' curly brace",cannotWrap:"'{token}' token cannot be wrapped in '{}' curly braces"},square:{missingOpen:"Missing '[' open square brace",missingClose:"Open '[' square brace is missing closing ']' square brace",cannotWrap:"'{token}' token cannot be wrapped in '[]' square braces"}},string:{missingOpen:"Missing/invalid opening string '{quote}' token",missingClose:"Missing/invalid closing string '{quote}' token",mustBeWrappedByQuotes:"Strings must be wrapped by quotes",nonAlphanumeric:"Non-alphanumeric token '{token}' is not allowed outside string notation",unexpectedKey:"Unexpected key found at string position"},key:{numberAndLetterMissingQuotes:"Key beginning with number and containing letters must be wrapped by quotes",spaceMissingQuotes:"Key containing space must be wrapped by quotes",unexpectedString:"Unexpected string found at key position"},noTrailingOrLeadingComma:"Trailing or leading commas in arrays and objects are not permitted"}; /** @license react-json-editor-ajrm v2.5.14 * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */class zc extends r.Component{constructor(e){super(e),this.updateInternalProps=this.updateInternalProps.bind(this),this.createMarkup=this.createMarkup.bind(this),this.onClick=this.onClick.bind(this),this.onBlur=this.onBlur.bind(this),this.update=this.update.bind(this),this.getCursorPosition=this.getCursorPosition.bind(this),this.setCursorPosition=this.setCursorPosition.bind(this),this.scheduledUpdate=this.scheduledUpdate.bind(this),this.setUpdateTime=this.setUpdateTime.bind(this),this.renderLabels=this.renderLabels.bind(this),this.newSpan=this.newSpan.bind(this),this.renderErrorMessage=this.renderErrorMessage.bind(this),this.onScroll=this.onScroll.bind(this),this.showPlaceholder=this.showPlaceholder.bind(this),this.tokenize=this.tokenize.bind(this),this.onKeyPress=this.onKeyPress.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onPaste=this.onPaste.bind(this),this.stopEvent=this.stopEvent.bind(this),this.refContent=null,this.refLabels=null,this.updateInternalProps(),this.renderCount=1,this.state={prevPlaceholder:"",markupText:"",plainText:"",json:"",jsObject:void 0,lines:!1,error:!1},this.props.locale||console.warn("[react-json-editor-ajrm - Deprecation Warning] You did not provide a 'locale' prop for your JSON input - This will be required in a future version. English has been set as a default.")}updateInternalProps(){let e={},t={},n=jc.dark_vscode_tribute;"theme"in this.props&&"string"==typeof this.props.theme&&this.props.theme in jc&&(n=jc[this.props.theme]),e=n,"colors"in this.props&&(e={default:"default"in this.props.colors?this.props.colors.default:e.default,string:"string"in this.props.colors?this.props.colors.string:e.string,number:"number"in this.props.colors?this.props.colors.number:e.number,colon:"colon"in this.props.colors?this.props.colors.colon:e.colon,keys:"keys"in this.props.colors?this.props.colors.keys:e.keys,keys_whiteSpace:"keys_whiteSpace"in this.props.colors?this.props.colors.keys_whiteSpace:e.keys_whiteSpace,primitive:"primitive"in this.props.colors?this.props.colors.primitive:e.primitive,error:"error"in this.props.colors?this.props.colors.error:e.error,background:"background"in this.props.colors?this.props.colors.background:e.background,background_warning:"background_warning"in this.props.colors?this.props.colors.background_warning:e.background_warning}),this.colors=e,t="style"in this.props?{outerBox:"outerBox"in this.props.style?this.props.style.outerBox:{},container:"container"in this.props.style?this.props.style.container:{},warningBox:"warningBox"in this.props.style?this.props.style.warningBox:{},errorMessage:"errorMessage"in this.props.style?this.props.style.errorMessage:{},body:"body"in this.props.style?this.props.style.body:{},labelColumn:"labelColumn"in this.props.style?this.props.style.labelColumn:{},labels:"labels"in this.props.style?this.props.style.labels:{},contentBox:"contentBox"in this.props.style?this.props.style.contentBox:{}}:{outerBox:{},container:{},warningBox:{},errorMessage:{},body:{},labelColumn:{},labels:{},contentBox:{}},this.style=t,this.confirmGood=!("confirmGood"in this.props)||this.props.confirmGood;const r=this.props.height||"610px",a=this.props.width||"479px";this.totalHeight=r,this.totalWidth=a,!("onKeyPressUpdate"in this.props)||this.props.onKeyPressUpdate?this.timer||(this.timer=setInterval(this.scheduledUpdate,100)):this.timer&&(clearInterval(this.timer),this.timer=!1),this.updateTime=!1,this.waitAfterKeyPress="waitAfterKeyPress"in this.props?this.props.waitAfterKeyPress:1e3,this.resetConfiguration="reset"in this.props&&this.props.reset}render(){const e=this.props.id,t=this.state.markupText,n=this.props.error||this.state.error,r=this.colors,o=this.style,i=this.confirmGood,s=this.totalHeight,l=this.totalWidth,u=!!this.props.error||!!n&&"token"in n;return this.renderCount++,a.a.createElement("div",{name:"outer-box",id:e&&e+"-outer-box",style:Oc({display:"block",overflow:"none",height:s,width:l,margin:0,boxSizing:"border-box",position:"relative"},o.outerBox)},i?a.a.createElement("div",{style:{opacity:u?0:1,height:"30px",width:"30px",position:"absolute",top:0,right:0,transform:"translate(-25%,25%)",pointerEvents:"none",transitionDuration:"0.2s",transitionTimingFunction:"cubic-bezier(0, 1, 0.5, 1)"}},a.a.createElement("svg",{height:"30px",width:"30px",viewBox:"0 0 100 100"},a.a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"green",opacity:"0.85",d:"M39.363,79L16,55.49l11.347-11.419L39.694,56.49L72.983,23L84,34.085L39.363,79z"}))):void 0,a.a.createElement("div",{name:"container",id:e&&e+"-container",style:Oc({display:"block",height:s,width:l,margin:0,boxSizing:"border-box",overflow:"hidden",fontFamily:"Roboto, sans-serif"},o.container),onClick:this.onClick},a.a.createElement("div",{name:"warning-box",id:e&&e+"-warning-box",style:Oc({display:"block",overflow:"hidden",height:u?"60px":"0px",width:"100%",margin:0,backgroundColor:r.background_warning,transitionDuration:"0.2s",transitionTimingFunction:"cubic-bezier(0, 1, 0.5, 1)"},o.warningBox),onClick:this.onClick},a.a.createElement("span",{style:{display:"inline-block",height:"60px",width:"60px",margin:0,boxSizing:"border-box",overflow:"hidden",verticalAlign:"top",pointerEvents:"none"},onClick:this.onClick},a.a.createElement("div",{style:{position:"relative",top:0,left:0,height:"60px",width:"60px",margin:0,pointerEvents:"none"},onClick:this.onClick},a.a.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none"},onClick:this.onClick},a.a.createElement("svg",{height:"25px",width:"25px",viewBox:"0 0 100 100"},a.a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"red",d:"M73.9,5.75c0.467-0.467,1.067-0.7,1.8-0.7c0.7,0,1.283,0.233,1.75,0.7l16.8,16.8 c0.467,0.5,0.7,1.084,0.7,1.75c0,0.733-0.233,1.334-0.7,1.801L70.35,50l23.9,23.95c0.5,0.467,0.75,1.066,0.75,1.8 c0,0.667-0.25,1.25-0.75,1.75l-16.8,16.75c-0.534,0.467-1.117,0.7-1.75,0.7s-1.233-0.233-1.8-0.7L50,70.351L26.1,94.25 c-0.567,0.467-1.167,0.7-1.8,0.7c-0.667,0-1.283-0.233-1.85-0.7L5.75,77.5C5.25,77,5,76.417,5,75.75c0-0.733,0.25-1.333,0.75-1.8 L29.65,50L5.75,26.101C5.25,25.667,5,25.066,5,24.3c0-0.666,0.25-1.25,0.75-1.75l16.8-16.8c0.467-0.467,1.05-0.7,1.75-0.7 c0.733,0,1.333,0.233,1.8,0.7L50,29.65L73.9,5.75z"}))))),a.a.createElement("span",{style:{display:"inline-block",height:"60px",width:"calc(100% - 60px)",margin:0,overflow:"hidden",verticalAlign:"top",position:"absolute",pointerEvents:"none"},onClick:this.onClick},this.renderErrorMessage())),a.a.createElement("div",{name:"body",id:e&&e+"-body",style:Oc({display:"flex",overflow:"none",height:u?"calc(100% - 60px)":"100%",width:"",margin:0,resize:"none",fontFamily:"Roboto Mono, Monaco, monospace",fontSize:"11px",backgroundColor:r.background,transitionDuration:"0.2s",transitionTimingFunction:"cubic-bezier(0, 1, 0.5, 1)"},o.body),onClick:this.onClick},a.a.createElement("span",{name:"labels",id:e&&e+"-labels",ref:e=>this.refLabels=e,style:Oc({display:"inline-block",boxSizing:"border-box",verticalAlign:"top",height:"100%",width:"44px",margin:0,padding:"5px 0px 5px 10px",overflow:"hidden",color:"#D4D4D4"},o.labelColumn),onClick:this.onClick},this.renderLabels()),a.a.createElement("span",{id:e,ref:e=>this.refContent=e,contentEditable:!0,style:Oc({display:"inline-block",boxSizing:"border-box",verticalAlign:"top",height:"100%",width:"",flex:1,margin:0,padding:"5px",overflowX:"hidden",overflowY:"auto",wordWrap:"break-word",whiteSpace:"pre-line",color:"#D4D4D4",outline:"none"},o.contentBox),dangerouslySetInnerHTML:this.createMarkup(t),onKeyPress:this.onKeyPress,onKeyDown:this.onKeyDown,onClick:this.onClick,onBlur:this.onBlur,onScroll:this.onScroll,onPaste:this.onPaste,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}))))}renderErrorMessage(){const e=this.props.locale||Hc,t=this.props.error||this.state.error,n=this.style;if(t)return a.a.createElement("p",{style:Oc({color:"red",fontSize:"12px",position:"absolute",width:"calc(100% - 60px)",height:"60px",boxSizing:"border-box",margin:0,padding:0,paddingRight:"10px",overflowWrap:"break-word",display:"flex",flexDirection:"column",justifyContent:"center"},n.errorMessage)},Cc(e.format,t))}renderLabels(){const e=this.colors,t=this.style,n=this.props.error||this.state.error,r=n?n.line:-1,o=this.state.lines?this.state.lines:1;let i=new Array(o);for(var s=0;s{const o=n!==r?e.default:"red";return a.a.createElement("div",{key:n,style:Oc({},t.labels,{color:o})},n)})}createMarkup(e){return void 0===e?{__html:""}:{__html:""+e}}newSpan(e,t,n){let r=this.colors,a=t.type,o=t.string,i="";switch(a){case"string":case"number":case"primitive":case"error":i=r[t.type];break;case"key":i=" "===o?r.keys_whiteSpace:r.keys;break;case"symbol":i=":"===o?r.colon:r.default;break;default:i=r.default}return o.length!==o.replace(//g,"").length&&(o=""+o+""),''+o+""}getCursorPosition(e){let t,n=window.getSelection(),r=-1,a=0;if(n.focusNode&&(e=>{for(;null!==e;){if(e===this.refContent)return!0;e=e.parentNode}return!1})(n.focusNode))for(t=n.focusNode,r=n.focusOffset;t&&t!==this.refContent;)if(t.previousSibling)t=t.previousSibling,e&&"BR"===t.nodeName&&a++,r+=t.textContent.length;else if(t=t.parentNode,null===t)break;return r+a}setCursorPosition(e){if([!1,null,void 0].indexOf(e)>-1)return;const t=(e,n,r)=>{if(r||((r=document.createRange()).selectNode(e),r.setStart(e,0)),0===n.count)r.setEnd(e,n.count);else if(e&&n.count>0)if(e.nodeType===Node.TEXT_NODE)e.textContent.length0?(e=>{if(e<0)return;let n=window.getSelection(),r=t(this.refContent,{count:e});r&&(r.collapse(!1),n.removeAllRanges(),n.addRange(r))})(e):this.refContent.focus()}update(e=0,t=!0){const n=this.refContent,r=this.tokenize(n);"onChange"in this.props&&this.props.onChange({plainText:r.indented,markupText:r.markup,json:r.json,jsObject:r.jsObject,lines:r.lines,error:r.error});let a=this.getCursorPosition(r.error)+e;this.setState({plainText:r.indented,markupText:r.markup,json:r.json,jsObject:r.jsObject,lines:r.lines,error:r.error}),this.updateTime=!1,t&&this.setCursorPosition(a)}scheduledUpdate(){if("onKeyPressUpdate"in this.props&&!1===this.props.onKeyPressUpdate)return;const{updateTime:e}=this;!1!==e&&(e>(new Date).getTime()||this.update())}setUpdateTime(){"onKeyPressUpdate"in this.props&&!1===this.props.onKeyPressUpdate||(this.updateTime=(new Date).getTime()+this.waitAfterKeyPress)}stopEvent(e){e&&(e.preventDefault(),e.stopPropagation())}onKeyPress(e){const t=e.ctrlKey||e.metaKey;this.props.viewOnly&&!t&&this.stopEvent(e),t||this.setUpdateTime()}onKeyDown(e){const t=!!this.props.viewOnly,n=e.ctrlKey||e.metaKey;switch(e.key){case"Tab":if(this.stopEvent(e),t)break;document.execCommand("insertText",!1," "),this.setUpdateTime();break;case"Backspace":case"Delete":t&&this.stopEvent(e),this.setUpdateTime();break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":this.setUpdateTime();break;case"a":case"c":t&&!n&&this.stopEvent(e);break;default:t&&this.stopEvent(e)}}onPaste(e){if(this.props.viewOnly)this.stopEvent(e);else{e.preventDefault();var t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)}this.update()}onClick(){!("viewOnly"in this.props)||this.props.viewOnly}onBlur(){if("viewOnly"in this.props&&this.props.viewOnly)return;const e=this.refContent,t=this.tokenize(e);"onBlur"in this.props&&this.props.onBlur({plainText:t.indented,markupText:t.markup,json:t.json,jsObject:t.jsObject,lines:t.lines,error:t.error})}onScroll(e){this.refLabels.scrollTop=e.target.scrollTop}componentDidUpdate(){this.updateInternalProps(),this.showPlaceholder()}componentDidMount(){this.showPlaceholder()}componentWillUnmount(){this.timer&&clearInterval(this.timer)}showPlaceholder(){if(!("placeholder"in this.props))return;const{placeholder:e}=this.props;if([void 0,null].indexOf(e)>-1)return;const{prevPlaceholder:t,jsObject:n}=this.state,{resetConfiguration:r}=this,a=Object(Ec.getType)(e);-1===["object","array"].indexOf(a)&&Pc.throwError("showPlaceholder","placeholder","either an object or an array");let o=!Object(Ec.identical)(e,t);if(o||r&&void 0!==n&&(o=!Object(Ec.identical)(e,n)),!o)return;const i=this.tokenize(e);this.setState({prevPlaceholder:e,plainText:i.indentation,markupText:i.markup,lines:i.lines,error:i.error})}tokenize(e){if("object"!=typeof e)return console.error("tokenize() expects object type properties only. Got '"+typeof e+"' type instead.");const t=this.props.locale||Hc,n=this.newSpan;if("nodeType"in e){const v=e.cloneNode(!0);if(!v.hasChildNodes())return"";const w=v.childNodes;let M={tokens_unknown:[],tokens_proto:[],tokens_split:[],tokens_fallback:[],tokens_normalize:[],tokens_merge:[],tokens_plainText:"",indented:"",json:"",jsObject:void 0,markup:""};for(var r=0;r-1?(n.active&&n.quarks.push({string:n[n.active],type:t+"-"+n.active}),n[n.active]="",n.active=r,n[n.active]=e):n[r]+=e}}for(var a=0;a-1){r(t,"number");break}case".":if(a0&&"0123456789".indexOf(e.charAt(a+1))>-1&&"0123456789".indexOf(e.charAt(a-1))>-1){r(t,"number");break}default:r(t,"string")}}return n.active&&(n.quarks.push({string:n[n.active],type:t+"-"+n.active}),n[n.active]="",n.active=!1),n.quarks}for(r=0;r0&&o-1){if(1===e.length)return!1;if(n!==r)return!1;for(o=0;o0&&o=~*%\\|/-+!?@^  ";for(o=0;o-1)return!1}}break;case"number":for(o=0;o1)return!1;if(-1==="{[:]},".indexOf(e))return!1;break;case"colon":if(e.length>1)return!1;if(":"!==e)return!1;break;default:return!0}return!0}for(r=0;r-1&&(t=t.slice(t.indexOf("-")+1),"string"!==t&&o.push("string"),o.push("key"),o.push("error"));let i={string:n,length:a,type:t,fallback:o};M.tokens_fallback.push(i)}function i(){const e=M.tokens_normalize.length-1;if(e<1)return!1;for(var t=e;t>=0;t--){const e=M.tokens_normalize[t];switch(e.type){case"space":case"linebreak":break;default:return e}}return!1}let L={brackets:[],stringOpen:!1,isValue:!1};for(r=0;r0){const e=M.tokens_fallback[r-1],t=e.string,n=e.type,a=t.charAt(t.length-1);if("string"===n&&"\\"===a)break}if(L.stringOpen===n){L.stringOpen=!1;break}break;case"primitive":case"string":if(["false","true","null","undefined"].indexOf(n)>-1){const e=M.tokens_normalize.length-1;if(e>=0){if("string"!==M.tokens_normalize[e].type){a.type="primitive";break}a.type="string";break}a.type="primitive";break}if("\n"===n&&!L.stringOpen){a.type="linebreak";break}L.isValue?a.type="string":a.type="key";break;case"space":case"number":L.stringOpen&&(L.isValue?a.type="string":a.type="key")}M.tokens_normalize.push(a)}for(r=0;r0?1:0;function c(e,t,n=0){l={token:e,line:u,reason:t},M.tokens_merge[e+n].type="error"}function d(e,t){if(void 0===e&&console.error("tokenID argument must be an integer."),void 0===t&&console.error("options argument must be an array."),e===M.tokens_merge.length-1)return!1;for(var n=e+1;n-1&&n;default:return!1}}return!1}function p(e,t){if(void 0===e&&console.error("tokenID argument must be an integer."),void 0===t&&console.error("options argument must be an array."),0===e)return!1;for(var n=e-1;n>=0;n--){const e=M.tokens_merge[n];switch(e.type){case"space":case"linebreak":break;case"symbol":case"colon":return t.indexOf(e.string)>-1;default:return!1}}return!1}function m(e){if(void 0===e&&console.error("tokenID argument must be an integer."),0===e)return!1;for(var t=e-1;t>=0;t--){const e=M.tokens_merge[t];switch(e.type){case"space":case"linebreak":break;default:return e.type}}return!1}L={brackets:[],stringOpen:!1,isValue:!1};let T=[];for(r=0;r0&&!p(r,[":","[",","])){c(r,Cc(t.invalidToken.tokenSequence.permitted,{firstToken:"[",secondToken:[":","[",","]}));break}if("{"===n&&p(r,["{"])){c(r,Cc(t.invalidToken.double,{token:"{"}));break}L.brackets.push(n),L.isValue="["===L.brackets[L.brackets.length-1],T.push({i:r,line:u,string:n});break;case"}":case"]":if("}"===n&&"{"!==L.brackets[L.brackets.length-1]){c(r,Cc(t.brace.curly.missingOpen));break}if("}"===n&&p(r,[","])){c(r,Cc(t.invalidToken.tokenSequence.prohibited,{firstToken:",",secondToken:"}"}));break}if("]"===n&&"["!==L.brackets[L.brackets.length-1]){c(r,Cc(t.brace.square.missingOpen));break}if("]"===n&&p(r,[":"])){c(r,Cc(t.invalidToken.tokenSequence.prohibited,{firstToken:":",secondToken:"]"}));break}L.brackets.pop(),L.isValue="["===L.brackets[L.brackets.length-1],T.push({i:r,line:u,string:n});break;case",":if(o=p(r,["{"]),o){if(d(r,["}"])){c(r,Cc(t.brace.curly.cannotWrap,{token:","}));break}c(r,Cc(t.invalidToken.tokenSequence.prohibited,{firstToken:"{",secondToken:","}));break}if(d(r,["}",",","]"])){c(r,Cc(t.noTrailingOrLeadingComma));break}switch(o=m(r),o){case"key":case"colon":c(r,Cc(t.invalidToken.termSequence.prohibited,{firstTerm:"key"===o?t.types.key:t.symbols.colon,secondTerm:t.symbols.comma}));break;case"symbol":if(p(r,["{"])){c(r,Cc(t.invalidToken.tokenSequence.prohibited,{firstToken:"{",secondToken:","}));break}}L.isValue="["===L.brackets[L.brackets.length-1]}M.json+=n;break;case"colon":if(o=p(r,["["]),o&&d(r,["]"])){c(r,Cc(t.brace.square.cannotWrap,{token:":"}));break}if(o){c(r,Cc(t.invalidToken.tokenSequence.prohibited,{firstToken:"[",secondToken:":"}));break}if("key"!==m(r)){c(r,Cc(t.invalidToken.termSequence.permitted,{firstTerm:t.symbols.colon,secondTerm:t.types.key}));break}if(d(r,["}","]"])){c(r,Cc(t.invalidToken.termSequence.permitted,{firstTerm:t.symbols.colon,secondTerm:t.types.value}));break}L.isValue=!0,M.json+=n;break;case"key":case"string":let e=n.charAt(0),i=n.charAt(n.length-1);k.indexOf(e);if(-1===k.indexOf(e)&&-1!==k.indexOf(i)){c(r,Cc(t.string.missingOpen,{quote:e}));break}if(-1===k.indexOf(i)&&-1!==k.indexOf(e)){c(r,Cc(t.string.missingClose,{quote:e}));break}if(k.indexOf(e)>-1&&e!==i){c(r,Cc(t.string.missingClose,{quote:e}));break}if("string"===a&&-1===k.indexOf(e)&&-1===k.indexOf(i)){c(r,Cc(t.string.mustBeWrappedByQuotes));break}if("key"===a&&d(r,["}","]"])&&c(r,Cc(t.invalidToken.termSequence.permitted,{firstTerm:t.types.key,secondTerm:t.symbols.colon})),-1===k.indexOf(e)&&-1===k.indexOf(i))for(var h=0;h0&&!isNaN(M.tokens_merge[r-1])){M.tokens_merge[r-1]+=M.tokens_merge[r],c(r,Cc(t.key.numberAndLetterMissingQuotes));break}c(r,Cc(t.key.spaceMissingQuotes));break}if("key"===a&&!p(r,["{",","])){c(r,Cc(t.invalidToken.tokenSequence.permitted,{firstToken:a,secondToken:["{",","]}));break}if("string"===a&&!p(r,["[",":",","])){c(r,Cc(t.invalidToken.tokenSequence.permitted,{firstToken:a,secondToken:["[",":",","]}));break}if("key"===a&&L.isValue){c(r,Cc(t.string.unexpectedKey));break}if("string"===a&&!L.isValue){c(r,Cc(t.key.unexpectedString));break}M.json+=n;break;case"number":case"primitive":if(p(r,["{"]))M.tokens_merge[r].type="key",a=M.tokens_merge[r].type,n='"'+n+'"';else if("key"===m(r))M.tokens_merge[r].type="key",a=M.tokens_merge[r].type;else if(!p(r,["[",":",","])){c(r,Cc(t.invalidToken.tokenSequence.permitted,{firstToken:a,secondToken:["[",":",","]}));break}"key"!==a&&(L.isValue||(M.tokens_merge[r].type="key",a=M.tokens_merge[r].type,n='"'+n+'"')),"primitive"===a&&"undefined"===n&&c(r,Cc(t.invalidToken.useInstead,{badToken:"undefined",goodToken:"null"})),M.json+=n}}let D="";for(r=0;r0;){r=!1;for(var _=0;_-1&&f(_)}if(n++,!r)break;if(n>=e)break}if(T.length>0){const e=T[0].string,n=T[0].i,r="["===e?"]":"}";u=T[0].line,c(n,Cc(t.brace["]"===r?"square":"curly"].missingClose))}}if(!l&&-1===[void 0,""].indexOf(M.json))try{M.jsObject=JSON.parse(M.json)}catch(e){const n=e.message,r=n.indexOf("position");if(-1===r)throw new Error("Error parsing failed");const a=n.substring(r+9,n.length),o=parseInt(a);let i=0,s=0,d=!1,p=1,m=!1;for(;i=o));)s++,M.tokens_merge[s+1]||(m=!0);u=p;let h=0;for(let e=0;e0?h+1:1:(h%2==0&&0!==h||-1==="'\"bfnrt".indexOf(n)&&c(s,Cc(t.invalidToken.unexpected,{token:"\\"})),h=0)}l||c(s,Cc(t.invalidToken.unexpected,{token:d.string}))}let S=1,O=0;function y(e=!1){return function(e=!1){return S++,O>0||e?"
":""}(e)+function(){for(var e=[],t=0;t<2*O;t++)e.push(" ");return e.join("")}()}if(!l)for(r=0;r0?["[","{"].indexOf(M.tokens_merge[r-1].string)>-1?"":y(t):"";M.markup+=a+n(r,e,O);break;case",":M.markup+=n(r,e,O)}}}if(l){let e=1;function b(e){let t=0;for(var n=0;n-1&&t++;return t}S=1;for(r=0;r{let t="",n="",r="";switch(e){case",":t="symbol",n=e,r=e,a.isValue="["===a.brackets[a.brackets.length-1];break;case":":t="symbol",n=e,r=e,a.isValue=!0;break;case"{":case"[":t="symbol",n=e,r=e,a.brackets.push(e),a.isValue="["===a.brackets[a.brackets.length-1];break;case"}":case"]":t="symbol",n=e,r=e,a.brackets.pop(),a.isValue="["===a.brackets[a.brackets.length-1];break;case"undefined":t="primitive",n=e,r=void 0;break;case"null":t="primitive",n=e,r=null;break;case"false":t="primitive",n=e,r=!1;break;case"true":t="primitive",n=e,r=!0;break;default:const i=e.charAt(0);if("'\"".indexOf(i)>-1){if(t=a.isValue?"string":"key","key"===t&&(n=function(e){if(0===e.length)return e;if(['""',"''"].indexOf(e)>-1)return"''";let t=!1;for(var n=0;n<2;n++)if([e.charAt(0),e.charAt(e.length-1)].indexOf(['"',"'"][n])>-1){t=!0;break}t&&e.length>=2&&(e=e.slice(1,-1));const r=e.replace(/\w/g,""),a=(e.replace(/\W+/g,""),((e,t)=>{let n=!1;for(var r=0;r0||n)})(r,e));if((e=>{for(var t=0;t-1)return!0;return!1})(r)){let t="";const n=e.split("");for(var o=0;o-1&&(e="\\"+e),t+=e}e=t}return a?e:"'"+e+"'"}(e)),"string"===t){n="";const t=e.slice(1,-1).split("");for(var o=0;o-1&&(e="\\"+e),n+=e}n="'"+n+"'"}r=n;break}if(!isNaN(e)){t="number",n=e,r=Number(e);break}if(e.length>0&&!a.isValue){t="key",n=e,n.indexOf(" ")>-1&&(n="'"+n+"'"),r=n;break}}return{type:t,string:n,value:r,depth:a.brackets.length}});let o="";for(r=0;r0?"\n":"")+t.join("")}let i="";for(r=0;r0?a.tokens[r-1]:"";-1==="[{".indexOf(n.string)?i+=Y(e.depth)+e.string:i+=e.string;break;case":":i+=e.string+" ";break;case",":i+=e.string+Y(e.depth);break;default:i+=e.string}}let s=1;function T(e){var t=[];e>0&&s++;for(var n=0;n<2*e;n++)t.push(" ");return(e>0?"
":"")+t.join("")}let l="";const u=a.tokens.length-1;for(r=0;r0?a.tokens[r-1]:"";-1==="[{".indexOf(o.string)?l+=T(e.depth)+(u===r?"
":"")+t:l+=t;break;case":":l+=t+" ";break;case",":l+=t+T(e.depth);break;default:l+=t}}return s+=2,{tokens:a.tokens,noSpaces:o,indented:i,json:JSON.stringify(e),jsObject:e,markup:l,lines:s}}}}var Ac=zc,Nc=n(133),Rc=n.n(Nc);function Fc(e){return(Fc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Wc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ic(e,t){for(var n=0;n=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(e)&&wp.element.createElement(sa,{chart:this.props.chart,edit:this.props.edit}),-1>=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(e)&&wp.element.createElement(Ta,{chart:this.props.chart,edit:this.props.edit}),0<=["pie"].indexOf(e)&&wp.element.createElement(ud,null,wp.element.createElement(Ua,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(io,{chart:this.props.chart,edit:this.props.edit})),0<=["area","scatter","line"].indexOf(e)&&wp.element.createElement(Lo,{chart:this.props.chart,edit:this.props.edit}),0<=["bar","column"].indexOf(e)&&wp.element.createElement(Ao,{chart:this.props.chart,edit:this.props.edit}),0<=["candlestick"].indexOf(e)&&wp.element.createElement(Xo,{chart:this.props.chart,edit:this.props.edit}),0<=["geo"].indexOf(e)&&wp.element.createElement(ud,null,wp.element.createElement(hi,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(Oi,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(Ui,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(os,{chart:this.props.chart,edit:this.props.edit})),0<=["gauge"].indexOf(e)&&wp.element.createElement(Ls,{chart:this.props.chart,edit:this.props.edit}),0<=["timeline"].indexOf(e)&&wp.element.createElement(Rs,{chart:this.props.chart,edit:this.props.edit}),0<=["tabular","dataTable"].indexOf(e)&&wp.element.createElement(ud,null,wp.element.createElement(nl,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(gl,{chart:this.props.chart,edit:this.props.edit})),0<=["combo"].indexOf(e)&&wp.element.createElement(xl,{chart:this.props.chart,edit:this.props.edit}),-1>=["timeline","bubble","gauge","geo","pie","tabular","dataTable"].indexOf(e)&&wp.element.createElement(Zl,{chart:this.props.chart,edit:this.props.edit}),"tabular"===e&&"GoogleCharts"===t&&wp.element.createElement(Zl,{chart:this.props.chart,edit:this.props.edit}),0<=["bubble"].indexOf(e)&&wp.element.createElement(Su,{chart:this.props.chart,edit:this.props.edit}),0<=["pie"].indexOf(e)&&wp.element.createElement(pu,{chart:this.props.chart,edit:this.props.edit}),"DataTable"===t&&wp.element.createElement(Ju,{chart:this.props.chart,edit:this.props.edit}),"DataTable"!==t&&wp.element.createElement(uc,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(Yc,{chart:this.props.chart,edit:this.props.edit}),"DataTable"!==t&&wp.element.createElement(Xc,{chart:this.props.chart,edit:this.props.edit}))}}])&&nd(n.prototype,r),a&&nd(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(ld);function dd(e){return(dd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pd(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */pd=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var o=t&&t.prototype instanceof _?t:_,i=Object.create(o.prototype),s=new O(r||[]);return a(i,"_invoke",{value:Y(e,n,s)}),i}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var p="suspendedStart",m="executing",h="completed",f={};function _(){}function y(){}function b(){}var g={};u(g,i,(function(){return this}));var v=Object.getPrototypeOf,w=v&&v(v(j([])));w&&w!==n&&r.call(w,i)&&(g=w);var M=b.prototype=_.prototype=Object.create(g);function L(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function n(a,o,i,s){var l=d(e[a],e,o);if("throw"!==l.type){var u=l.arg,c=u.value;return c&&"object"==dd(c)&&r.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,i,s)}),(function(e){n("throw",e,i,s)})):t.resolve(c).then((function(e){u.value=e,i(u)}),(function(e){return n("throw",e,i,s)}))}s(l.arg)}var o;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return o=o?o.then(a,a):a()}})}function Y(t,n,r){var a=p;return function(o,i){if(a===m)throw new Error("Generator is already running");if(a===h){if("throw"===o)throw i;return{value:e,done:!0}}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var l=T(s,r);if(l){if(l===f)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===p)throw a=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=m;var u=d(t,n,r);if("normal"===u.type){if(a=r.done?h:"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(a=h,r.method="throw",r.arg=u.arg)}}}function T(t,n){var r=n.method,a=t.iterator[r];if(a===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,T(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=d(a,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,f;var i=o.arg;return i?i.done?(n[t.resultName]=i.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,f):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,f)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function j(t){if(t||""===t){var n=t[i];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function n(){for(;++a=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function md(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function hd(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){md(o,r,a,i,s,"next",e)}function s(e){md(o,r,a,i,s,"throw",e)}i(void 0)}))}}function fd(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _d(e,t){for(var n=0;n=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function Sp(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function Op(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Sp(o,r,a,i,s,"next",e)}function s(e){Sp(o,r,a,i,s,"throw",e)}i(void 0)}))}}function jp(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ep(e,t){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0];this.setState({isLoading:"uploadData",isScheduled:t}),Fp({path:"/visualizer/v1/upload-data?url=".concat(this.state.chart["visualizer-chart-url"]),method:"POST"}).then((function(t){if(2<=Object.keys(t).length){var n=Yp({},e.state.chart);n["visualizer-source"]="Visualizer_Source_Csv_Remote",n["visualizer-default-data"]=0,n["visualizer-series"]=t.series,n["visualizer-data"]=t.data;var r=n["visualizer-series"],a=n["visualizer-settings"],o=r,i="series";return"pie"===n["visualizer-chart-type"]&&(o=n["visualizer-data"],i="slices"),o.map((function(e,t){if("pie"===n["visualizer-chart-type"]||0!==t){var r="pie"!==n["visualizer-chart-type"]?t-1:t;void 0===a[i][r]&&(a[i][r]={},a[i][r].temp=1)}})),a[i]=a[i].filter((function(e,t){return t<("pie"!==n["visualizer-chart-type"]?o.length-1:o.length)})),n["visualizer-settings"]=a,e.setState({chart:n,isModified:!0,isLoading:!1}),t}e.setState({isLoading:!1})}),(function(t){return e.setState({isLoading:!1}),t}))}},{key:"getChartData",value:(o=Op(Dp().mark((function e(t){var n,r;return Dp().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setState({isLoading:"getChartData"});case 2:return e.next=4,Rp({path:"wp/v2/visualizer/".concat(t)});case 4:n=e.sent,(r=Yp({},this.state.chart))["visualizer-source"]="Visualizer_Source_Csv",r["visualizer-default-data"]=0,r["visualizer-series"]=n.chart_data["visualizer-series"],r["visualizer-data"]=n.chart_data["visualizer-data"],this.setState({isLoading:!1,chart:r});case 11:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"editChartData",value:function(e,t){var n=Yp({},this.state.chart),r=[],a=Yp({},n["visualizer-settings"]),o=n["visualizer-chart-type"];e[0].map((function(t,n){r[n]={label:t,type:e[1][n]}})),e.splice(0,2);var i=r,s="series";switch(o){case"pie":i=e,s="slices",e.map((function(e,t){switch(r[1].type){case"number":e[1]=parseFloat(e[1])}}));break;case"tabular":e.map((function(e,t){r.map((function(t,n){switch(t.type){case"boolean":"string"==typeof e[n]&&(e[n]="true"===e[n])}}))}))}i.map((function(e,t){if("pie"===o||0!==t){var n="pie"!==o?t-1:t;Array.isArray(a[s])&&void 0===a[s][n]&&(a[s][n]={},a[s][n].temp=1)}})),Array.isArray(a[s])&&(a[s]=a[s].filter((function(e,t){return t<(-1>=["pie","tabular","dataTable"].indexOf(o)?i.length-1:i.length)}))),n["visualizer-source"]=t,n["visualizer-default-data"]=0,n["visualizer-data"]=e,n["visualizer-series"]=r,n["visualizer-settings"]=a,n["visualizer-chart-url"]="",this.setState({chart:n,isModified:!0,isScheduled:!1})}},{key:"updateChart",value:function(){var e=this;this.setState({isLoading:"updateChart"});var t=this.state.chart;!1===this.state.isScheduled&&(t["visualizer-chart-schedule"]="");var n="series";"pie"===t["visualizer-chart-type"]&&(n="slices"),-1>=["bubble","timeline"].indexOf(t["visualizer-chart-type"])&&Object.keys(t["visualizer-settings"][n]).map((function(e){void 0!==t["visualizer-settings"][n][e]&&void 0!==t["visualizer-settings"][n][e].temp&&delete t["visualizer-settings"][n][e].temp})),Fp({path:"/visualizer/v1/update-chart?id=".concat(this.props.attributes.id),method:"POST",data:t}).then((function(t){return e.setState({isLoading:!1,isModified:!1}),t}),(function(e){return e}))}},{key:"render",value:function(){var e=this;return"error"===this.state.route?wp.element.createElement($p,{status:"error",isDismissible:!1},wp.element.createElement(qp,{icon:"chart-pie"}),Ap("This chart is not available; it might have been deleted. Please delete this block and resubmit your chart.")):"1"===visualizerLocalize.isFullSiteEditor?wp.element.createElement($p,{status:"error",isDismissible:!1},wp.element.createElement(qp,{icon:"chart-pie"}),Ap("Visualizer block charts are currently not available for selection here, you must visit the library, get the shortcode, and add the chart here in a shortcode tag.")):"renderChart"===this.state.route&&null!==this.state.chart?wp.element.createElement(Mp,{id:this.props.attributes.id,chart:this.state.chart,className:this.props.className,editChart:this.editChart}):wp.element.createElement("div",{className:"visualizer-settings"},wp.element.createElement("div",{className:"visualizer-settings__title"},wp.element.createElement(qp,{icon:"chart-pie"}),Ap("Visualizer")),"home"===this.state.route&&wp.element.createElement("div",{className:"visualizer-settings__content"},wp.element.createElement("div",{className:"visualizer-settings__content-description"},Ap("Make a new chart or display an existing one?")),wp.element.createElement("a",{href:visualizerLocalize.adminPage,target:"_blank",className:"visualizer-settings__content-option"},wp.element.createElement("span",{className:"visualizer-settings__content-option-title"},Ap("Create a new chart")),wp.element.createElement("div",{className:"visualizer-settings__content-option-icon"},wp.element.createElement(qp,{icon:"arrow-right-alt2"}))),wp.element.createElement("div",{className:"visualizer-settings__content-option",onClick:function(){e.setState({route:"showCharts"}),e.props.setAttributes({route:"showCharts"})}},wp.element.createElement("span",{className:"visualizer-settings__content-option-title"},Ap("Display an existing chart")),wp.element.createElement("div",{className:"visualizer-settings__content-option-icon"},wp.element.createElement(qp,{icon:"arrow-right-alt2"})))),("getChart"===this.state.isLoading||"chartSelect"===this.state.route&&null===this.state.chart||"renderChart"===this.state.route&&null===this.state.chart)&&wp.element.createElement(Vp,null,wp.element.createElement(Kp,null)),"showCharts"===this.state.route&&!1===this.state.isLoading&&wp.element.createElement(De,{getChart:this.getChart}),"chartSelect"===this.state.route&&null!==this.state.chart&&wp.element.createElement(np,{id:this.props.attributes.id,attributes:this.props.attributes,chart:this.state.chart,editSettings:this.editSettings,editPermissions:this.editPermissions,url:this.state.url,readUploadedFile:this.readUploadedFile,editURL:this.editURL,editSchedule:this.editSchedule,editJSONURL:this.editJSONURL,editJSONHeaders:this.editJSONHeaders,editJSONSchedule:this.editJSONSchedule,editJSONRoot:this.editJSONRoot,editJSONPaging:this.editJSONPaging,JSONImportData:this.JSONImportData,editDatabaseSchedule:this.editDatabaseSchedule,databaseImportData:this.databaseImportData,uploadData:this.uploadData,getChartData:this.getChartData,editChartData:this.editChartData,isLoading:this.state.isLoading}),wp.element.createElement("div",{className:"visualizer-settings__controls"},("showCharts"===this.state.route||"chartSelect"===this.state.route)&&wp.element.createElement(Gp,null,wp.element.createElement(Up,{variant:"secondary",isLarge:!0,onClick:function(){var t;"showCharts"===e.state.route?t="home":"chartSelect"===e.state.route&&(t="showCharts"),e.setState({route:t,isLoading:!1}),e.props.setAttributes({route:t})}},Ap("Back")),"chartSelect"===this.state.route&&wp.element.createElement(Bp,null,!1===this.state.isModified?wp.element.createElement(Up,{variant:"secondary",isLarge:!0,className:"visualizer-bttn-done",onClick:function(){e.setState({route:"renderChart",isModified:!0}),e.props.setAttributes({route:"renderChart"})}},Ap("Done")):wp.element.createElement(Up,{isPrimary:!0,isLarge:!0,className:"visualizer-bttn-save",isBusy:"updateChart"===this.state.isLoading,disabled:"updateChart"===this.state.isLoading,onClick:this.updateChart},Ap("Save"))))))}}])&&Ep(n.prototype,r),a&&Ep(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(Ip),Qp=(n(153),wp.i18n.__),Xp=wp.blocks.registerBlockType;t.default=Xp("visualizer/chart",{title:Qp("Visualizer Chart"),description:Qp("A simple, easy to use and quite powerful tool to create, manage and embed interactive charts into your WordPress posts and pages."),category:"common",icon:"chart-pie",keywords:[Qp("Visualizer"),Qp("Chart"),Qp("Google Charts")],attributes:{id:{type:"number"},lazy:{default:"-1",type:"string"},route:{type:"string"}},supports:{customClassName:!1},edit:Zp,save:function(){return null}})}]); \ No newline at end of file + */class Ac extends r.Component{constructor(e){super(e),this.updateInternalProps=this.updateInternalProps.bind(this),this.createMarkup=this.createMarkup.bind(this),this.onClick=this.onClick.bind(this),this.onBlur=this.onBlur.bind(this),this.update=this.update.bind(this),this.getCursorPosition=this.getCursorPosition.bind(this),this.setCursorPosition=this.setCursorPosition.bind(this),this.scheduledUpdate=this.scheduledUpdate.bind(this),this.setUpdateTime=this.setUpdateTime.bind(this),this.renderLabels=this.renderLabels.bind(this),this.newSpan=this.newSpan.bind(this),this.renderErrorMessage=this.renderErrorMessage.bind(this),this.onScroll=this.onScroll.bind(this),this.showPlaceholder=this.showPlaceholder.bind(this),this.tokenize=this.tokenize.bind(this),this.onKeyPress=this.onKeyPress.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onPaste=this.onPaste.bind(this),this.stopEvent=this.stopEvent.bind(this),this.refContent=null,this.refLabels=null,this.updateInternalProps(),this.renderCount=1,this.state={prevPlaceholder:"",markupText:"",plainText:"",json:"",jsObject:void 0,lines:!1,error:!1},this.props.locale||console.warn("[react-json-editor-ajrm - Deprecation Warning] You did not provide a 'locale' prop for your JSON input - This will be required in a future version. English has been set as a default.")}updateInternalProps(){let e={},t={},n=Ec.dark_vscode_tribute;"theme"in this.props&&"string"==typeof this.props.theme&&this.props.theme in Ec&&(n=Ec[this.props.theme]),e=n,"colors"in this.props&&(e={default:"default"in this.props.colors?this.props.colors.default:e.default,string:"string"in this.props.colors?this.props.colors.string:e.string,number:"number"in this.props.colors?this.props.colors.number:e.number,colon:"colon"in this.props.colors?this.props.colors.colon:e.colon,keys:"keys"in this.props.colors?this.props.colors.keys:e.keys,keys_whiteSpace:"keys_whiteSpace"in this.props.colors?this.props.colors.keys_whiteSpace:e.keys_whiteSpace,primitive:"primitive"in this.props.colors?this.props.colors.primitive:e.primitive,error:"error"in this.props.colors?this.props.colors.error:e.error,background:"background"in this.props.colors?this.props.colors.background:e.background,background_warning:"background_warning"in this.props.colors?this.props.colors.background_warning:e.background_warning}),this.colors=e,t="style"in this.props?{outerBox:"outerBox"in this.props.style?this.props.style.outerBox:{},container:"container"in this.props.style?this.props.style.container:{},warningBox:"warningBox"in this.props.style?this.props.style.warningBox:{},errorMessage:"errorMessage"in this.props.style?this.props.style.errorMessage:{},body:"body"in this.props.style?this.props.style.body:{},labelColumn:"labelColumn"in this.props.style?this.props.style.labelColumn:{},labels:"labels"in this.props.style?this.props.style.labels:{},contentBox:"contentBox"in this.props.style?this.props.style.contentBox:{}}:{outerBox:{},container:{},warningBox:{},errorMessage:{},body:{},labelColumn:{},labels:{},contentBox:{}},this.style=t,this.confirmGood=!("confirmGood"in this.props)||this.props.confirmGood;const r=this.props.height||"610px",a=this.props.width||"479px";this.totalHeight=r,this.totalWidth=a,!("onKeyPressUpdate"in this.props)||this.props.onKeyPressUpdate?this.timer||(this.timer=setInterval(this.scheduledUpdate,100)):this.timer&&(clearInterval(this.timer),this.timer=!1),this.updateTime=!1,this.waitAfterKeyPress="waitAfterKeyPress"in this.props?this.props.waitAfterKeyPress:1e3,this.resetConfiguration="reset"in this.props&&this.props.reset}render(){const e=this.props.id,t=this.state.markupText,n=this.props.error||this.state.error,r=this.colors,o=this.style,i=this.confirmGood,s=this.totalHeight,l=this.totalWidth,u=!!this.props.error||!!n&&"token"in n;return this.renderCount++,a.a.createElement("div",{name:"outer-box",id:e&&e+"-outer-box",style:jc({display:"block",overflow:"none",height:s,width:l,margin:0,boxSizing:"border-box",position:"relative"},o.outerBox)},i?a.a.createElement("div",{style:{opacity:u?0:1,height:"30px",width:"30px",position:"absolute",top:0,right:0,transform:"translate(-25%,25%)",pointerEvents:"none",transitionDuration:"0.2s",transitionTimingFunction:"cubic-bezier(0, 1, 0.5, 1)"}},a.a.createElement("svg",{height:"30px",width:"30px",viewBox:"0 0 100 100"},a.a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"green",opacity:"0.85",d:"M39.363,79L16,55.49l11.347-11.419L39.694,56.49L72.983,23L84,34.085L39.363,79z"}))):void 0,a.a.createElement("div",{name:"container",id:e&&e+"-container",style:jc({display:"block",height:s,width:l,margin:0,boxSizing:"border-box",overflow:"hidden",fontFamily:"Roboto, sans-serif"},o.container),onClick:this.onClick},a.a.createElement("div",{name:"warning-box",id:e&&e+"-warning-box",style:jc({display:"block",overflow:"hidden",height:u?"60px":"0px",width:"100%",margin:0,backgroundColor:r.background_warning,transitionDuration:"0.2s",transitionTimingFunction:"cubic-bezier(0, 1, 0.5, 1)"},o.warningBox),onClick:this.onClick},a.a.createElement("span",{style:{display:"inline-block",height:"60px",width:"60px",margin:0,boxSizing:"border-box",overflow:"hidden",verticalAlign:"top",pointerEvents:"none"},onClick:this.onClick},a.a.createElement("div",{style:{position:"relative",top:0,left:0,height:"60px",width:"60px",margin:0,pointerEvents:"none"},onClick:this.onClick},a.a.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none"},onClick:this.onClick},a.a.createElement("svg",{height:"25px",width:"25px",viewBox:"0 0 100 100"},a.a.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",fill:"red",d:"M73.9,5.75c0.467-0.467,1.067-0.7,1.8-0.7c0.7,0,1.283,0.233,1.75,0.7l16.8,16.8 c0.467,0.5,0.7,1.084,0.7,1.75c0,0.733-0.233,1.334-0.7,1.801L70.35,50l23.9,23.95c0.5,0.467,0.75,1.066,0.75,1.8 c0,0.667-0.25,1.25-0.75,1.75l-16.8,16.75c-0.534,0.467-1.117,0.7-1.75,0.7s-1.233-0.233-1.8-0.7L50,70.351L26.1,94.25 c-0.567,0.467-1.167,0.7-1.8,0.7c-0.667,0-1.283-0.233-1.85-0.7L5.75,77.5C5.25,77,5,76.417,5,75.75c0-0.733,0.25-1.333,0.75-1.8 L29.65,50L5.75,26.101C5.25,25.667,5,25.066,5,24.3c0-0.666,0.25-1.25,0.75-1.75l16.8-16.8c0.467-0.467,1.05-0.7,1.75-0.7 c0.733,0,1.333,0.233,1.8,0.7L50,29.65L73.9,5.75z"}))))),a.a.createElement("span",{style:{display:"inline-block",height:"60px",width:"calc(100% - 60px)",margin:0,overflow:"hidden",verticalAlign:"top",position:"absolute",pointerEvents:"none"},onClick:this.onClick},this.renderErrorMessage())),a.a.createElement("div",{name:"body",id:e&&e+"-body",style:jc({display:"flex",overflow:"none",height:u?"calc(100% - 60px)":"100%",width:"",margin:0,resize:"none",fontFamily:"Roboto Mono, Monaco, monospace",fontSize:"11px",backgroundColor:r.background,transitionDuration:"0.2s",transitionTimingFunction:"cubic-bezier(0, 1, 0.5, 1)"},o.body),onClick:this.onClick},a.a.createElement("span",{name:"labels",id:e&&e+"-labels",ref:e=>this.refLabels=e,style:jc({display:"inline-block",boxSizing:"border-box",verticalAlign:"top",height:"100%",width:"44px",margin:0,padding:"5px 0px 5px 10px",overflow:"hidden",color:"#D4D4D4"},o.labelColumn),onClick:this.onClick},this.renderLabels()),a.a.createElement("span",{id:e,ref:e=>this.refContent=e,contentEditable:!0,style:jc({display:"inline-block",boxSizing:"border-box",verticalAlign:"top",height:"100%",width:"",flex:1,margin:0,padding:"5px",overflowX:"hidden",overflowY:"auto",wordWrap:"break-word",whiteSpace:"pre-line",color:"#D4D4D4",outline:"none"},o.contentBox),dangerouslySetInnerHTML:this.createMarkup(t),onKeyPress:this.onKeyPress,onKeyDown:this.onKeyDown,onClick:this.onClick,onBlur:this.onBlur,onScroll:this.onScroll,onPaste:this.onPaste,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}))))}renderErrorMessage(){const e=this.props.locale||zc,t=this.props.error||this.state.error,n=this.style;if(t)return a.a.createElement("p",{style:jc({color:"red",fontSize:"12px",position:"absolute",width:"calc(100% - 60px)",height:"60px",boxSizing:"border-box",margin:0,padding:0,paddingRight:"10px",overflowWrap:"break-word",display:"flex",flexDirection:"column",justifyContent:"center"},n.errorMessage)},Hc(e.format,t))}renderLabels(){const e=this.colors,t=this.style,n=this.props.error||this.state.error,r=n?n.line:-1,o=this.state.lines?this.state.lines:1;let i=new Array(o);for(var s=0;s{const o=n!==r?e.default:"red";return a.a.createElement("div",{key:n,style:jc({},t.labels,{color:o})},n)})}createMarkup(e){return void 0===e?{__html:""}:{__html:""+e}}newSpan(e,t,n){let r=this.colors,a=t.type,o=t.string,i="";switch(a){case"string":case"number":case"primitive":case"error":i=r[t.type];break;case"key":i=" "===o?r.keys_whiteSpace:r.keys;break;case"symbol":i=":"===o?r.colon:r.default;break;default:i=r.default}return o.length!==o.replace(//g,"").length&&(o=""+o+""),''+o+""}getCursorPosition(e){let t,n=window.getSelection(),r=-1,a=0;if(n.focusNode&&(e=>{for(;null!==e;){if(e===this.refContent)return!0;e=e.parentNode}return!1})(n.focusNode))for(t=n.focusNode,r=n.focusOffset;t&&t!==this.refContent;)if(t.previousSibling)t=t.previousSibling,e&&"BR"===t.nodeName&&a++,r+=t.textContent.length;else if(t=t.parentNode,null===t)break;return r+a}setCursorPosition(e){if([!1,null,void 0].indexOf(e)>-1)return;const t=(e,n,r)=>{if(r||((r=document.createRange()).selectNode(e),r.setStart(e,0)),0===n.count)r.setEnd(e,n.count);else if(e&&n.count>0)if(e.nodeType===Node.TEXT_NODE)e.textContent.length0?(e=>{if(e<0)return;let n=window.getSelection(),r=t(this.refContent,{count:e});r&&(r.collapse(!1),n.removeAllRanges(),n.addRange(r))})(e):this.refContent.focus()}update(e=0,t=!0){const n=this.refContent,r=this.tokenize(n);"onChange"in this.props&&this.props.onChange({plainText:r.indented,markupText:r.markup,json:r.json,jsObject:r.jsObject,lines:r.lines,error:r.error});let a=this.getCursorPosition(r.error)+e;this.setState({plainText:r.indented,markupText:r.markup,json:r.json,jsObject:r.jsObject,lines:r.lines,error:r.error}),this.updateTime=!1,t&&this.setCursorPosition(a)}scheduledUpdate(){if("onKeyPressUpdate"in this.props&&!1===this.props.onKeyPressUpdate)return;const{updateTime:e}=this;!1!==e&&(e>(new Date).getTime()||this.update())}setUpdateTime(){"onKeyPressUpdate"in this.props&&!1===this.props.onKeyPressUpdate||(this.updateTime=(new Date).getTime()+this.waitAfterKeyPress)}stopEvent(e){e&&(e.preventDefault(),e.stopPropagation())}onKeyPress(e){const t=e.ctrlKey||e.metaKey;this.props.viewOnly&&!t&&this.stopEvent(e),t||this.setUpdateTime()}onKeyDown(e){const t=!!this.props.viewOnly,n=e.ctrlKey||e.metaKey;switch(e.key){case"Tab":if(this.stopEvent(e),t)break;document.execCommand("insertText",!1," "),this.setUpdateTime();break;case"Backspace":case"Delete":t&&this.stopEvent(e),this.setUpdateTime();break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":this.setUpdateTime();break;case"a":case"c":t&&!n&&this.stopEvent(e);break;default:t&&this.stopEvent(e)}}onPaste(e){if(this.props.viewOnly)this.stopEvent(e);else{e.preventDefault();var t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)}this.update()}onClick(){!("viewOnly"in this.props)||this.props.viewOnly}onBlur(){if("viewOnly"in this.props&&this.props.viewOnly)return;const e=this.refContent,t=this.tokenize(e);"onBlur"in this.props&&this.props.onBlur({plainText:t.indented,markupText:t.markup,json:t.json,jsObject:t.jsObject,lines:t.lines,error:t.error})}onScroll(e){this.refLabels.scrollTop=e.target.scrollTop}componentDidUpdate(){this.updateInternalProps(),this.showPlaceholder()}componentDidMount(){this.showPlaceholder()}componentWillUnmount(){this.timer&&clearInterval(this.timer)}showPlaceholder(){if(!("placeholder"in this.props))return;const{placeholder:e}=this.props;if([void 0,null].indexOf(e)>-1)return;const{prevPlaceholder:t,jsObject:n}=this.state,{resetConfiguration:r}=this,a=Object(xc.getType)(e);-1===["object","array"].indexOf(a)&&Cc.throwError("showPlaceholder","placeholder","either an object or an array");let o=!Object(xc.identical)(e,t);if(o||r&&void 0!==n&&(o=!Object(xc.identical)(e,n)),!o)return;const i=this.tokenize(e);this.setState({prevPlaceholder:e,plainText:i.indentation,markupText:i.markup,lines:i.lines,error:i.error})}tokenize(e){if("object"!=typeof e)return console.error("tokenize() expects object type properties only. Got '"+typeof e+"' type instead.");const t=this.props.locale||zc,n=this.newSpan;if("nodeType"in e){const v=e.cloneNode(!0);if(!v.hasChildNodes())return"";const w=v.childNodes;let M={tokens_unknown:[],tokens_proto:[],tokens_split:[],tokens_fallback:[],tokens_normalize:[],tokens_merge:[],tokens_plainText:"",indented:"",json:"",jsObject:void 0,markup:""};for(var r=0;r-1?(n.active&&n.quarks.push({string:n[n.active],type:t+"-"+n.active}),n[n.active]="",n.active=r,n[n.active]=e):n[r]+=e}}for(var a=0;a-1){r(t,"number");break}case".":if(a0&&"0123456789".indexOf(e.charAt(a+1))>-1&&"0123456789".indexOf(e.charAt(a-1))>-1){r(t,"number");break}default:r(t,"string")}}return n.active&&(n.quarks.push({string:n[n.active],type:t+"-"+n.active}),n[n.active]="",n.active=!1),n.quarks}for(r=0;r0&&o-1){if(1===e.length)return!1;if(n!==r)return!1;for(o=0;o0&&o=~*%\\|/-+!?@^  ";for(o=0;o-1)return!1}}break;case"number":for(o=0;o1)return!1;if(-1==="{[:]},".indexOf(e))return!1;break;case"colon":if(e.length>1)return!1;if(":"!==e)return!1;break;default:return!0}return!0}for(r=0;r-1&&(t=t.slice(t.indexOf("-")+1),"string"!==t&&o.push("string"),o.push("key"),o.push("error"));let i={string:n,length:a,type:t,fallback:o};M.tokens_fallback.push(i)}function i(){const e=M.tokens_normalize.length-1;if(e<1)return!1;for(var t=e;t>=0;t--){const e=M.tokens_normalize[t];switch(e.type){case"space":case"linebreak":break;default:return e}}return!1}let L={brackets:[],stringOpen:!1,isValue:!1};for(r=0;r0){const e=M.tokens_fallback[r-1],t=e.string,n=e.type,a=t.charAt(t.length-1);if("string"===n&&"\\"===a)break}if(L.stringOpen===n){L.stringOpen=!1;break}break;case"primitive":case"string":if(["false","true","null","undefined"].indexOf(n)>-1){const e=M.tokens_normalize.length-1;if(e>=0){if("string"!==M.tokens_normalize[e].type){a.type="primitive";break}a.type="string";break}a.type="primitive";break}if("\n"===n&&!L.stringOpen){a.type="linebreak";break}L.isValue?a.type="string":a.type="key";break;case"space":case"number":L.stringOpen&&(L.isValue?a.type="string":a.type="key")}M.tokens_normalize.push(a)}for(r=0;r0?1:0;function c(e,t,n=0){l={token:e,line:u,reason:t},M.tokens_merge[e+n].type="error"}function d(e,t){if(void 0===e&&console.error("tokenID argument must be an integer."),void 0===t&&console.error("options argument must be an array."),e===M.tokens_merge.length-1)return!1;for(var n=e+1;n-1&&n;default:return!1}}return!1}function p(e,t){if(void 0===e&&console.error("tokenID argument must be an integer."),void 0===t&&console.error("options argument must be an array."),0===e)return!1;for(var n=e-1;n>=0;n--){const e=M.tokens_merge[n];switch(e.type){case"space":case"linebreak":break;case"symbol":case"colon":return t.indexOf(e.string)>-1;default:return!1}}return!1}function m(e){if(void 0===e&&console.error("tokenID argument must be an integer."),0===e)return!1;for(var t=e-1;t>=0;t--){const e=M.tokens_merge[t];switch(e.type){case"space":case"linebreak":break;default:return e.type}}return!1}L={brackets:[],stringOpen:!1,isValue:!1};let T=[];for(r=0;r0&&!p(r,[":","[",","])){c(r,Hc(t.invalidToken.tokenSequence.permitted,{firstToken:"[",secondToken:[":","[",","]}));break}if("{"===n&&p(r,["{"])){c(r,Hc(t.invalidToken.double,{token:"{"}));break}L.brackets.push(n),L.isValue="["===L.brackets[L.brackets.length-1],T.push({i:r,line:u,string:n});break;case"}":case"]":if("}"===n&&"{"!==L.brackets[L.brackets.length-1]){c(r,Hc(t.brace.curly.missingOpen));break}if("}"===n&&p(r,[","])){c(r,Hc(t.invalidToken.tokenSequence.prohibited,{firstToken:",",secondToken:"}"}));break}if("]"===n&&"["!==L.brackets[L.brackets.length-1]){c(r,Hc(t.brace.square.missingOpen));break}if("]"===n&&p(r,[":"])){c(r,Hc(t.invalidToken.tokenSequence.prohibited,{firstToken:":",secondToken:"]"}));break}L.brackets.pop(),L.isValue="["===L.brackets[L.brackets.length-1],T.push({i:r,line:u,string:n});break;case",":if(o=p(r,["{"]),o){if(d(r,["}"])){c(r,Hc(t.brace.curly.cannotWrap,{token:","}));break}c(r,Hc(t.invalidToken.tokenSequence.prohibited,{firstToken:"{",secondToken:","}));break}if(d(r,["}",",","]"])){c(r,Hc(t.noTrailingOrLeadingComma));break}switch(o=m(r),o){case"key":case"colon":c(r,Hc(t.invalidToken.termSequence.prohibited,{firstTerm:"key"===o?t.types.key:t.symbols.colon,secondTerm:t.symbols.comma}));break;case"symbol":if(p(r,["{"])){c(r,Hc(t.invalidToken.tokenSequence.prohibited,{firstToken:"{",secondToken:","}));break}}L.isValue="["===L.brackets[L.brackets.length-1]}M.json+=n;break;case"colon":if(o=p(r,["["]),o&&d(r,["]"])){c(r,Hc(t.brace.square.cannotWrap,{token:":"}));break}if(o){c(r,Hc(t.invalidToken.tokenSequence.prohibited,{firstToken:"[",secondToken:":"}));break}if("key"!==m(r)){c(r,Hc(t.invalidToken.termSequence.permitted,{firstTerm:t.symbols.colon,secondTerm:t.types.key}));break}if(d(r,["}","]"])){c(r,Hc(t.invalidToken.termSequence.permitted,{firstTerm:t.symbols.colon,secondTerm:t.types.value}));break}L.isValue=!0,M.json+=n;break;case"key":case"string":let e=n.charAt(0),i=n.charAt(n.length-1);k.indexOf(e);if(-1===k.indexOf(e)&&-1!==k.indexOf(i)){c(r,Hc(t.string.missingOpen,{quote:e}));break}if(-1===k.indexOf(i)&&-1!==k.indexOf(e)){c(r,Hc(t.string.missingClose,{quote:e}));break}if(k.indexOf(e)>-1&&e!==i){c(r,Hc(t.string.missingClose,{quote:e}));break}if("string"===a&&-1===k.indexOf(e)&&-1===k.indexOf(i)){c(r,Hc(t.string.mustBeWrappedByQuotes));break}if("key"===a&&d(r,["}","]"])&&c(r,Hc(t.invalidToken.termSequence.permitted,{firstTerm:t.types.key,secondTerm:t.symbols.colon})),-1===k.indexOf(e)&&-1===k.indexOf(i))for(var h=0;h0&&!isNaN(M.tokens_merge[r-1])){M.tokens_merge[r-1]+=M.tokens_merge[r],c(r,Hc(t.key.numberAndLetterMissingQuotes));break}c(r,Hc(t.key.spaceMissingQuotes));break}if("key"===a&&!p(r,["{",","])){c(r,Hc(t.invalidToken.tokenSequence.permitted,{firstToken:a,secondToken:["{",","]}));break}if("string"===a&&!p(r,["[",":",","])){c(r,Hc(t.invalidToken.tokenSequence.permitted,{firstToken:a,secondToken:["[",":",","]}));break}if("key"===a&&L.isValue){c(r,Hc(t.string.unexpectedKey));break}if("string"===a&&!L.isValue){c(r,Hc(t.key.unexpectedString));break}M.json+=n;break;case"number":case"primitive":if(p(r,["{"]))M.tokens_merge[r].type="key",a=M.tokens_merge[r].type,n='"'+n+'"';else if("key"===m(r))M.tokens_merge[r].type="key",a=M.tokens_merge[r].type;else if(!p(r,["[",":",","])){c(r,Hc(t.invalidToken.tokenSequence.permitted,{firstToken:a,secondToken:["[",":",","]}));break}"key"!==a&&(L.isValue||(M.tokens_merge[r].type="key",a=M.tokens_merge[r].type,n='"'+n+'"')),"primitive"===a&&"undefined"===n&&c(r,Hc(t.invalidToken.useInstead,{badToken:"undefined",goodToken:"null"})),M.json+=n}}let D="";for(r=0;r0;){r=!1;for(var _=0;_-1&&f(_)}if(n++,!r)break;if(n>=e)break}if(T.length>0){const e=T[0].string,n=T[0].i,r="["===e?"]":"}";u=T[0].line,c(n,Hc(t.brace["]"===r?"square":"curly"].missingClose))}}if(!l&&-1===[void 0,""].indexOf(M.json))try{M.jsObject=JSON.parse(M.json)}catch(e){const n=e.message,r=n.indexOf("position");if(-1===r)throw new Error("Error parsing failed");const a=n.substring(r+9,n.length),o=parseInt(a);let i=0,s=0,d=!1,p=1,m=!1;for(;i=o));)s++,M.tokens_merge[s+1]||(m=!0);u=p;let h=0;for(let e=0;e0?h+1:1:(h%2==0&&0!==h||-1==="'\"bfnrt".indexOf(n)&&c(s,Hc(t.invalidToken.unexpected,{token:"\\"})),h=0)}l||c(s,Hc(t.invalidToken.unexpected,{token:d.string}))}let S=1,O=0;function y(e=!1){return function(e=!1){return S++,O>0||e?"
":""}(e)+function(){for(var e=[],t=0;t<2*O;t++)e.push(" ");return e.join("")}()}if(!l)for(r=0;r0?["[","{"].indexOf(M.tokens_merge[r-1].string)>-1?"":y(t):"";M.markup+=a+n(r,e,O);break;case",":M.markup+=n(r,e,O)}}}if(l){let e=1;function b(e){let t=0;for(var n=0;n-1&&t++;return t}S=1;for(r=0;r{let t="",n="",r="";switch(e){case",":t="symbol",n=e,r=e,a.isValue="["===a.brackets[a.brackets.length-1];break;case":":t="symbol",n=e,r=e,a.isValue=!0;break;case"{":case"[":t="symbol",n=e,r=e,a.brackets.push(e),a.isValue="["===a.brackets[a.brackets.length-1];break;case"}":case"]":t="symbol",n=e,r=e,a.brackets.pop(),a.isValue="["===a.brackets[a.brackets.length-1];break;case"undefined":t="primitive",n=e,r=void 0;break;case"null":t="primitive",n=e,r=null;break;case"false":t="primitive",n=e,r=!1;break;case"true":t="primitive",n=e,r=!0;break;default:const i=e.charAt(0);if("'\"".indexOf(i)>-1){if(t=a.isValue?"string":"key","key"===t&&(n=function(e){if(0===e.length)return e;if(['""',"''"].indexOf(e)>-1)return"''";let t=!1;for(var n=0;n<2;n++)if([e.charAt(0),e.charAt(e.length-1)].indexOf(['"',"'"][n])>-1){t=!0;break}t&&e.length>=2&&(e=e.slice(1,-1));const r=e.replace(/\w/g,""),a=(e.replace(/\W+/g,""),((e,t)=>{let n=!1;for(var r=0;r0||n)})(r,e));if((e=>{for(var t=0;t-1)return!0;return!1})(r)){let t="";const n=e.split("");for(var o=0;o-1&&(e="\\"+e),t+=e}e=t}return a?e:"'"+e+"'"}(e)),"string"===t){n="";const t=e.slice(1,-1).split("");for(var o=0;o-1&&(e="\\"+e),n+=e}n="'"+n+"'"}r=n;break}if(!isNaN(e)){t="number",n=e,r=Number(e);break}if(e.length>0&&!a.isValue){t="key",n=e,n.indexOf(" ")>-1&&(n="'"+n+"'"),r=n;break}}return{type:t,string:n,value:r,depth:a.brackets.length}});let o="";for(r=0;r0?"\n":"")+t.join("")}let i="";for(r=0;r0?a.tokens[r-1]:"";-1==="[{".indexOf(n.string)?i+=Y(e.depth)+e.string:i+=e.string;break;case":":i+=e.string+" ";break;case",":i+=e.string+Y(e.depth);break;default:i+=e.string}}let s=1;function T(e){var t=[];e>0&&s++;for(var n=0;n<2*e;n++)t.push(" ");return(e>0?"
":"")+t.join("")}let l="";const u=a.tokens.length-1;for(r=0;r0?a.tokens[r-1]:"";-1==="[{".indexOf(o.string)?l+=T(e.depth)+(u===r?"
":"")+t:l+=t;break;case":":l+=t+" ";break;case",":l+=t+T(e.depth);break;default:l+=t}}return s+=2,{tokens:a.tokens,noSpaces:o,indented:i,json:JSON.stringify(e),jsObject:e,markup:l,lines:s}}}}var Nc=Ac,Rc=n(133),Fc=n.n(Rc);function Wc(e){return(Wc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ic(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Bc(e,t){for(var n=0;n=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(e)&&wp.element.createElement(la,{chart:this.props.chart,edit:this.props.edit}),-1>=["tabular","dataTable","gauge","geo","pie","timeline"].indexOf(e)&&wp.element.createElement(Da,{chart:this.props.chart,edit:this.props.edit}),0<=["pie"].indexOf(e)&&wp.element.createElement(cd,null,wp.element.createElement(Ga,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(so,{chart:this.props.chart,edit:this.props.edit})),0<=["area","scatter","line"].indexOf(e)&&wp.element.createElement(ko,{chart:this.props.chart,edit:this.props.edit}),0<=["bar","column"].indexOf(e)&&wp.element.createElement(No,{chart:this.props.chart,edit:this.props.edit}),0<=["candlestick"].indexOf(e)&&wp.element.createElement(ei,{chart:this.props.chart,edit:this.props.edit}),0<=["geo"].indexOf(e)&&wp.element.createElement(cd,null,wp.element.createElement(fi,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(ji,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(Gi,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(is,{chart:this.props.chart,edit:this.props.edit})),0<=["gauge"].indexOf(e)&&wp.element.createElement(ks,{chart:this.props.chart,edit:this.props.edit}),0<=["timeline"].indexOf(e)&&wp.element.createElement(Fs,{chart:this.props.chart,edit:this.props.edit}),0<=["tabular","dataTable"].indexOf(e)&&wp.element.createElement(cd,null,wp.element.createElement(rl,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(vl,{chart:this.props.chart,edit:this.props.edit})),0<=["combo"].indexOf(e)&&wp.element.createElement(Pl,{chart:this.props.chart,edit:this.props.edit}),-1>=["timeline","bubble","gauge","geo","pie","tabular","dataTable"].indexOf(e)&&wp.element.createElement(Ql,{chart:this.props.chart,edit:this.props.edit}),"tabular"===e&&"GoogleCharts"===t&&wp.element.createElement(Ql,{chart:this.props.chart,edit:this.props.edit}),0<=["bubble"].indexOf(e)&&wp.element.createElement(Ou,{chart:this.props.chart,edit:this.props.edit}),0<=["pie"].indexOf(e)&&wp.element.createElement(mu,{chart:this.props.chart,edit:this.props.edit}),"DataTable"===t&&wp.element.createElement(Uu,{chart:this.props.chart,edit:this.props.edit}),"DataTable"!==t&&wp.element.createElement(cc,{chart:this.props.chart,edit:this.props.edit}),wp.element.createElement(Tc,{chart:this.props.chart,edit:this.props.edit}),"DataTable"!==t&&wp.element.createElement(ed,{chart:this.props.chart,edit:this.props.edit}))}}])&&rd(n.prototype,r),a&&rd(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(ud);function pd(e){return(pd="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function md(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */md=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,a=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function c(e,t,n,r){var o=t&&t.prototype instanceof _?t:_,i=Object.create(o.prototype),s=new O(r||[]);return a(i,"_invoke",{value:Y(e,n,s)}),i}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var p="suspendedStart",m="executing",h="completed",f={};function _(){}function y(){}function b(){}var g={};u(g,i,(function(){return this}));var v=Object.getPrototypeOf,w=v&&v(v(j([])));w&&w!==n&&r.call(w,i)&&(g=w);var M=b.prototype=_.prototype=Object.create(g);function L(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function n(a,o,i,s){var l=d(e[a],e,o);if("throw"!==l.type){var u=l.arg,c=u.value;return c&&"object"==pd(c)&&r.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,i,s)}),(function(e){n("throw",e,i,s)})):t.resolve(c).then((function(e){u.value=e,i(u)}),(function(e){return n("throw",e,i,s)}))}s(l.arg)}var o;a(this,"_invoke",{value:function(e,r){function a(){return new t((function(t,a){n(e,r,t,a)}))}return o=o?o.then(a,a):a()}})}function Y(t,n,r){var a=p;return function(o,i){if(a===m)throw new Error("Generator is already running");if(a===h){if("throw"===o)throw i;return{value:e,done:!0}}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var l=T(s,r);if(l){if(l===f)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(a===p)throw a=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);a=m;var u=d(t,n,r);if("normal"===u.type){if(a=r.done?h:"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(a=h,r.method="throw",r.arg=u.arg)}}}function T(t,n){var r=n.method,a=t.iterator[r];if(a===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,T(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=d(a,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,f;var i=o.arg;return i?i.done?(n[t.resultName]=i.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,f):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,f)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function j(t){if(t||""===t){var n=t[i];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function n(){for(;++a=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function hd(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function fd(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){hd(o,r,a,i,s,"next",e)}function s(e){hd(o,r,a,i,s,"throw",e)}i(void 0)}))}}function _d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function yd(e,t){for(var n=0;n=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var l=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(l&&u){if(this.prev=0;--n){var a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;S(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:j(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function Op(e,t,n,r,a,o,i){try{var s=e[o](i),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,a)}function jp(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Op(o,r,a,i,s,"next",e)}function s(e){Op(o,r,a,i,s,"throw",e)}i(void 0)}))}}function Ep(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function xp(e,t){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0];this.setState({isLoading:"uploadData",isScheduled:t}),Wp({path:"/visualizer/v1/upload-data?url=".concat(this.state.chart["visualizer-chart-url"]),method:"POST"}).then((function(t){if(2<=Object.keys(t).length){var n=Tp({},e.state.chart);n["visualizer-source"]="Visualizer_Source_Csv_Remote",n["visualizer-default-data"]=0,n["visualizer-series"]=t.series,n["visualizer-data"]=t.data;var r=n["visualizer-series"],a=n["visualizer-settings"],o=r,i="series";return"pie"===n["visualizer-chart-type"]&&(o=n["visualizer-data"],i="slices"),o.map((function(e,t){if("pie"===n["visualizer-chart-type"]||0!==t){var r="pie"!==n["visualizer-chart-type"]?t-1:t;void 0===a[i][r]&&(a[i][r]={},a[i][r].temp=1)}})),a[i]=a[i].filter((function(e,t){return t<("pie"!==n["visualizer-chart-type"]?o.length-1:o.length)})),n["visualizer-settings"]=a,e.setState({chart:n,isModified:!0,isLoading:!1}),t}e.setState({isLoading:!1})}),(function(t){return e.setState({isLoading:!1}),t}))}},{key:"getChartData",value:(o=jp(Sp().mark((function e(t){var n,r;return Sp().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.setState({isLoading:"getChartData"});case 2:return e.next=4,Fp({path:"wp/v2/visualizer/".concat(t)});case 4:n=e.sent,(r=Tp({},this.state.chart))["visualizer-source"]="Visualizer_Source_Csv",r["visualizer-default-data"]=0,r["visualizer-series"]=n.chart_data["visualizer-series"],r["visualizer-data"]=n.chart_data["visualizer-data"],this.setState({isLoading:!1,chart:r});case 11:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"editChartData",value:function(e,t){var n=Tp({},this.state.chart),r=[],a=Tp({},n["visualizer-settings"]),o=n["visualizer-chart-type"];e[0].map((function(t,n){r[n]={label:t,type:e[1][n]}})),e.splice(0,2);var i=r,s="series";switch(o){case"pie":i=e,s="slices",e.map((function(e,t){switch(r[1].type){case"number":e[1]=parseFloat(e[1])}}));break;case"tabular":e.map((function(e,t){r.map((function(t,n){switch(t.type){case"boolean":"string"==typeof e[n]&&(e[n]="true"===e[n])}}))}))}i.map((function(e,t){if("pie"===o||0!==t){var n="pie"!==o?t-1:t;Array.isArray(a[s])&&void 0===a[s][n]&&(a[s][n]={},a[s][n].temp=1)}})),Array.isArray(a[s])&&(a[s]=a[s].filter((function(e,t){return t<(-1>=["pie","tabular","dataTable"].indexOf(o)?i.length-1:i.length)}))),n["visualizer-source"]=t,n["visualizer-default-data"]=0,n["visualizer-data"]=e,n["visualizer-series"]=r,n["visualizer-settings"]=a,n["visualizer-chart-url"]="",this.setState({chart:n,isModified:!0,isScheduled:!1})}},{key:"updateChart",value:function(){var e=this;this.setState({isLoading:"updateChart"});var t=this.state.chart;!1===this.state.isScheduled&&(t["visualizer-chart-schedule"]="");var n="series";"pie"===t["visualizer-chart-type"]&&(n="slices"),-1>=["bubble","timeline"].indexOf(t["visualizer-chart-type"])&&Object.keys(t["visualizer-settings"][n]).map((function(e){void 0!==t["visualizer-settings"][n][e]&&void 0!==t["visualizer-settings"][n][e].temp&&delete t["visualizer-settings"][n][e].temp})),Wp({path:"/visualizer/v1/update-chart?id=".concat(this.props.attributes.id),method:"POST",data:t}).then((function(t){return e.setState({isLoading:!1,isModified:!1}),t}),(function(e){return e}))}},{key:"render",value:function(){var e=this;return"error"===this.state.route?wp.element.createElement(Kp,{status:"error",isDismissible:!1},wp.element.createElement(Vp,{icon:"chart-pie"}),Np("This chart is not available; it might have been deleted. Please delete this block and resubmit your chart.")):"1"===visualizerLocalize.isFullSiteEditor?wp.element.createElement(Kp,{status:"error",isDismissible:!1},wp.element.createElement(Vp,{icon:"chart-pie"}),Np("Visualizer block charts are currently not available for selection here, you must visit the library, get the shortcode, and add the chart here in a shortcode tag.")):"renderChart"===this.state.route&&null!==this.state.chart?wp.element.createElement(Lp,{id:this.props.attributes.id,chart:this.state.chart,className:this.props.className,editChart:this.editChart}):wp.element.createElement("div",{className:"visualizer-settings"},wp.element.createElement("div",{className:"visualizer-settings__title"},wp.element.createElement(Vp,{icon:"chart-pie"}),Np("Visualizer")),"home"===this.state.route&&wp.element.createElement("div",{className:"visualizer-settings__content"},wp.element.createElement("div",{className:"visualizer-settings__content-description"},Np("Make a new chart or display an existing one?")),wp.element.createElement("a",{href:visualizerLocalize.adminPage,target:"_blank",className:"visualizer-settings__content-option"},wp.element.createElement("span",{className:"visualizer-settings__content-option-title"},Np("Create a new chart")),wp.element.createElement("div",{className:"visualizer-settings__content-option-icon"},wp.element.createElement(Vp,{icon:"arrow-right-alt2"}))),wp.element.createElement("div",{className:"visualizer-settings__content-option",onClick:function(){e.setState({route:"showCharts"}),e.props.setAttributes({route:"showCharts"})}},wp.element.createElement("span",{className:"visualizer-settings__content-option-title"},Np("Display an existing chart")),wp.element.createElement("div",{className:"visualizer-settings__content-option-icon"},wp.element.createElement(Vp,{icon:"arrow-right-alt2"})))),("getChart"===this.state.isLoading||"chartSelect"===this.state.route&&null===this.state.chart||"renderChart"===this.state.route&&null===this.state.chart)&&wp.element.createElement($p,null,wp.element.createElement(Zp,null)),"showCharts"===this.state.route&&!1===this.state.isLoading&&wp.element.createElement(Se,{getChart:this.getChart}),"chartSelect"===this.state.route&&null!==this.state.chart&&wp.element.createElement(rp,{id:this.props.attributes.id,attributes:this.props.attributes,chart:this.state.chart,editSettings:this.editSettings,editPermissions:this.editPermissions,url:this.state.url,readUploadedFile:this.readUploadedFile,editURL:this.editURL,editSchedule:this.editSchedule,editJSONURL:this.editJSONURL,editJSONHeaders:this.editJSONHeaders,editJSONSchedule:this.editJSONSchedule,editJSONRoot:this.editJSONRoot,editJSONPaging:this.editJSONPaging,JSONImportData:this.JSONImportData,editDatabaseSchedule:this.editDatabaseSchedule,databaseImportData:this.databaseImportData,uploadData:this.uploadData,getChartData:this.getChartData,editChartData:this.editChartData,isLoading:this.state.isLoading}),wp.element.createElement("div",{className:"visualizer-settings__controls"},("showCharts"===this.state.route||"chartSelect"===this.state.route)&&wp.element.createElement(qp,null,wp.element.createElement(Gp,{variant:"secondary",isLarge:!0,onClick:function(){var t;"showCharts"===e.state.route?t="home":"chartSelect"===e.state.route&&(t="showCharts"),e.setState({route:t,isLoading:!1}),e.props.setAttributes({route:t})}},Np("Back")),"chartSelect"===this.state.route&&wp.element.createElement(Jp,null,!1===this.state.isModified?wp.element.createElement(Gp,{variant:"secondary",isLarge:!0,className:"visualizer-bttn-done",onClick:function(){e.setState({route:"renderChart",isModified:!0}),e.props.setAttributes({route:"renderChart"})}},Np("Done")):wp.element.createElement(Gp,{isPrimary:!0,isLarge:!0,className:"visualizer-bttn-save",isBusy:"updateChart"===this.state.isLoading,disabled:"updateChart"===this.state.isLoading,onClick:this.updateChart},Np("Save"))))))}}])&&xp(n.prototype,r),a&&xp(n,a),Object.defineProperty(n,"prototype",{writable:!1}),t}(Bp),Xp=(n(153),wp.i18n.__),em=wp.blocks.registerBlockType;t.default=em("visualizer/chart",{title:Xp("Visualizer Chart"),description:Xp("A simple, easy to use and quite powerful tool to create, manage and embed interactive charts into your WordPress posts and pages."),category:"common",icon:"chart-pie",keywords:[Xp("Visualizer"),Xp("Chart"),Xp("Google Charts")],attributes:{id:{type:"number"},lazy:{default:"-1",type:"string"},route:{type:"string"}},supports:{customClassName:!1},edit:Qp,save:function(){return null}})}]); \ No newline at end of file From 198d229713f0adb7e2a1dc844675ab6065bb9937 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Wed, 14 Feb 2024 10:00:15 +0200 Subject: [PATCH 07/20] fix: chart submenu slug --- classes/Visualizer/Module/Admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Visualizer/Module/Admin.php b/classes/Visualizer/Module/Admin.php index e74854c37..de11b7401 100644 --- a/classes/Visualizer/Module/Admin.php +++ b/classes/Visualizer/Module/Admin.php @@ -671,14 +671,14 @@ public function registerAdminMenu() { __( 'Chart Library', 'visualizer' ), __( 'Chart Library', 'visualizer' ), 'edit_posts', - admin_url( 'admin.php?page=' . Visualizer_Plugin::NAME ) + 'admin.php?page=' . Visualizer_Plugin::NAME ); add_submenu_page( Visualizer_Plugin::NAME, __( 'Add New Chart', 'visualizer' ), __( 'Add New Chart', 'visualizer' ), 'edit_posts', - admin_url( 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew' ) + 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew' ); add_submenu_page( Visualizer_Plugin::NAME, From ba558149c4f0565cc310693dff2afa2fa7d27323 Mon Sep 17 00:00:00 2001 From: mghenciu <52494172+mghenciu@users.noreply.github.com> Date: Sun, 18 Feb 2024 23:24:31 +0200 Subject: [PATCH 08/20] Updates the Loading bar speed and position --- js/setup-wizard.js | 2 +- templates/setup-wizard.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/js/setup-wizard.js b/js/setup-wizard.js index ed0aa7fee..d94666dca 100644 --- a/js/setup-wizard.js +++ b/js/setup-wizard.js @@ -57,7 +57,7 @@ jQuery(function ($) { }); clearInterval( loaderDelay ); } - }, 100 ); + }, 40 ); }, error: function() { $('#step-2').find('.vz-progress-bar').animate({ width: '0' }); diff --git a/templates/setup-wizard.php b/templates/setup-wizard.php index 6ed4cc40c..d53b25b96 100644 --- a/templates/setup-wizard.php +++ b/templates/setup-wizard.php @@ -173,13 +173,10 @@ class="btn btn-secondary" target="_blank">

-
-
-
-
+
@@ -187,9 +184,12 @@ class="btn btn-secondary" target="_blank">
-
+

-

+

+
+
+
From 779cd66ddfed88a2ea187d416fde24a78a407c54 Mon Sep 17 00:00:00 2001 From: mghenciu <52494172+mghenciu@users.noreply.github.com> Date: Mon, 19 Feb 2024 00:01:47 +0200 Subject: [PATCH 09/20] Changes the loading direction and hides the bar when loaded --- js/setup-wizard.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/js/setup-wizard.js b/js/setup-wizard.js index d94666dca..e130bfd2a 100644 --- a/js/setup-wizard.js +++ b/js/setup-wizard.js @@ -11,13 +11,13 @@ jQuery(function ($) { // Import chart data. if ( 1 == id ) { var chartType = $(".vz-radio-btn:checked").val(); - var percentBarWidth = 100; + var percentBarWidth = 0; var loaderDelay; $.ajax( { beforeSend: function() { loaderDelay = setInterval(function () { $('.vz-progress-bar').css({ - width: percentBarWidth-- + '%' + width: percentBarWidth++ + '%' }); }, 1000); }, @@ -34,9 +34,9 @@ jQuery(function ($) { clearInterval( loaderDelay ); loaderDelay = setInterval(function () { $('.vz-progress-bar').css({ - width: percentBarWidth-- + '%' + width: percentBarWidth++ + '%' }); - if ( percentBarWidth <= 0 ) { + if ( percentBarWidth >= 100 ) { if ( 1 === data.success ) { var importMessage = jQuery('[data-import_message]'); importMessage @@ -53,11 +53,14 @@ jQuery(function ($) { $('#smartwizard').smartWizard('reset'); } $('.vz-progress-bar').css({ - width: 0 + width: 100 + '%' + }); + $('.vz-progress').css({ + display: 'none' }); clearInterval( loaderDelay ); } - }, 40 ); + }, 36 ); }, error: function() { $('#step-2').find('.vz-progress-bar').animate({ width: '0' }); From 30db4c0baeeddaaf74a81925e2f8659b9d14e1c1 Mon Sep 17 00:00:00 2001 From: mghenciu <52494172+mghenciu@users.noreply.github.com> Date: Mon, 19 Feb 2024 00:12:16 +0200 Subject: [PATCH 10/20] Changes from display none to visibility. --- js/setup-wizard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/setup-wizard.js b/js/setup-wizard.js index e130bfd2a..17fe4c93f 100644 --- a/js/setup-wizard.js +++ b/js/setup-wizard.js @@ -56,7 +56,7 @@ jQuery(function ($) { width: 100 + '%' }); $('.vz-progress').css({ - display: 'none' + visibility: 'hidden' }); clearInterval( loaderDelay ); } From 54927d3d3d13e6c834807e8de1ab1596dfa553e5 Mon Sep 17 00:00:00 2001 From: mghenciu <52494172+mghenciu@users.noreply.github.com> Date: Tue, 20 Feb 2024 13:58:05 +0200 Subject: [PATCH 11/20] Minor update on the width to prevent the loading bar to ge to the left --- templates/setup-wizard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/setup-wizard.php b/templates/setup-wizard.php index d53b25b96..11234c2d5 100644 --- a/templates/setup-wizard.php +++ b/templates/setup-wizard.php @@ -188,7 +188,7 @@ class="btn btn-secondary" target="_blank">

-
+
From 15400eb0778bb4547108dcbb9a180d122518e60e Mon Sep 17 00:00:00 2001 From: Soare Robert Daniel Date: Tue, 27 Feb 2024 11:10:43 +0200 Subject: [PATCH 12/20] chore: update docs (#1086) * chore: update docs * chore: setup wizard docs * chore: docs quirks --- CONTRIBUTING.md | 116 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 112 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 36b5b5b16..b0927afd6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,115 @@ How to release a new version: - Clone the master branch - Do your changes - Send a PR to master and merge it using the following subject message - - `release: ` - for patch release - - `release(minor): ` - for minor release - - `release(major): ` - for major release - The release notes will inherit the body of the commit message which triggered the release. For more details check the [simple-preset](https://github.com/Codeinwp/conventional-changelog-simple-preset) that we use. \ No newline at end of file + - `release: ` - for patch release + - `release(minor): ` - for minor release + - `release(major): ` - for major release + The release notes will inherit the body of the commit message which triggered the release. For more details check the [simple-preset](https://github.com/Codeinwp/conventional-changelog-simple-preset) that we use. + +## Architecture + +### Introduction + +The two main features are: + +- data importing +- chart rendering + +Those two options are present in the plugin dashboard and as Gutenberg blocks. + +All the charts are saved as custom post type (`post_type=visualizer`), and the data is saved as post meta (with the prefix `visualizer-`). (Check plugin settings in `classes/Visualizer/Plugin.php`) + +The charts can be embedded in page via shortcode or Gutenberg blocks. + +### Data Importing + +For data importing, the most basic usage is using a CSV or JSON file. The source can be an uploaded file or a URL. The data is then parsed and stored in a format that can be used by the chart rendering feature. + +For parsing the CSV and JSON files, we use built-in PHP functions. + +> [!NOTE] +> The `samples` folder contains some sample data files that can be used for testing. + +Advanced data importing features include data from: + +- a database using a query; +- post meta values withing a desired `post_type`; +- WooCommerce Report API; +- from other charts; +- manually inputted data with the build-in editor. + +Related code is in `classes/Visualizer/Source`. Pro Features like database import are in `visualizer-pro` plugin on `inc/addon.php`. +The rendering for Import dashboard is done in `classes/Visualizer/Render/Layout.php`; for Gutenberg Blocks check `classes/Visualizer/Gutenberg/src/Components/Import`. + +### Chart Rendering + +The chart rendering is done with the help of the [Chart.js](https://www.chartjs.org/) library. The plugin uses the `chartjs` library to render the charts. + +The workflow for rendering a chart is: + +- We add markup for the chart in the page; ( `[visualizer id="5295" lazy="no" class=""]` can be rendered via shortcode or Gutenberg block with function `gutenberg_block_callback` in `Block.php`); +- We load the data into the global object `window.visualizer`. (Beside the object, and endpoint is also created for fetching the data, available with `rest_url` property); +- Using js (with `render-facade.js`), we search the markup in the page, and using the stored ID, we pull the data from the global object and initiate the chart rendering. + +Check the class `Visualizer_Module_Frontend` to see all the hooks and filters that are used to render the charts. + +### Data handling + +While the data importing and rendering are the main selling points, the most of work is done in the data handling which includes interface rendering, storing, and fetching the data. + +The Charts menu settings are available in `Chart Library` page in the admin dashboard, but also in the block `Inspector` as part of the Gutenberg block. The first is done via PHP and jQuery, and the second is done via React. Any design changes should be done in both places. + +Same thing for chart library visualization, it can be either from admin dashboard or from Gutenberg block. + +> [!NOTE] +> The plugin tries to offer seamless experience for both classic and Gutenberg editor. But the bugs resulted might be different, especially in the Gutenberg editor where changes are happening frequently. + +> [!NOTE] +> Unlike the jQeury, the Gutenberg block require a build step, you will need to install all the NPM dependencies and run `npm run dev` or `npm run build` to see the changes. + +### Setup Wizard + +The `Setup Wizard` is an onboarding process that helps the user to set up its first chart. When the plugin is installed for the first time, the user is redirected to the wizard. + +The steps includes: + +1. Choosing the chart type; +2. Importing the sample data; +3. Asking the user if he wants a draft page to show the chart; +4. Promotion (optional); +5. Email subscription; +6. Redirect to draft page if the user marked the option at step 3. Otherwise, redirect to the plugin dashboard. + +The page rendering is done using the `setup-wizard.php` file, and the server logic is in the `Visualizer_Module_Wizard` class. A jQuery script (`setup-wizard`) is used to handle the interactions. + +> [!NOTE] +> The usual process include showing the promotion and email collection form. Those are hidden when the `preview` query parameter is present in the URL. The Preview is used as demo presentation for the `Live Preview` feature of the WordPress store. + +### Quirks + +#### Number Formatting + +The workflow for adding a chart with number formatting is: + +1. Select the chart; +2. Add the data without any other specific sign (`$`, `%`, `.`, etc.) -- `2.5` will be added as `25`; +3. Generate the chart; +4. Add number formatting (`#.#` for `2.5`). + +For displaying data mentioning a percentage (%), amount, or any other specific signs ($, €, etc.); you need to specify the correct number formatting. + +Percentage: + +1. When manually inputting the data, if you want to display 80%, you need to add it as `0.8`. +2. Then you go trough the number formatting box and input `#%`. + +Amounts: + +1. For inputting amounts like `2,345`, you need to input it as `2345`. +2. Then you go to number formatting and input `#,###`. +3. Same thing for `2.5`, you need add the format as `#.#`. + +For specific signs: + +1. For displaying a sign like `$` (like `$2.345`), you need to follow the same steps as for the amount. +2. Except the number formatting will be `$#,###`. From ae7d0406b7253899eaa9feb9b71c897ff1e0430d Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Fri, 1 Mar 2024 14:40:19 +0200 Subject: [PATCH 13/20] fix: missing `customcss` property of chart settings created by wizard (cherry picked from commit 029658496d9240ae008d7ba63a934db32ad0cb2f) --- classes/Visualizer/Module/Wizard.php | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/classes/Visualizer/Module/Wizard.php b/classes/Visualizer/Module/Wizard.php index 1f007e9aa..d2f6290bf 100644 --- a/classes/Visualizer/Module/Wizard.php +++ b/classes/Visualizer/Module/Wizard.php @@ -341,6 +341,43 @@ private function setup_wizard_import_chart() { 'min' => '', ), ), + 'customcss' => array( + 'headerRow' => array( + 'background-color' => '', + 'color' => '', + 'transform' => '', + ), + 'tableRow' => array( + 'background-color' => '', + 'color' => '', + 'transform' => '', + ), + 'oddTableRow' => array( + 'background-color' => '', + 'color' => '', + 'transform' => '', + ), + 'selectedTableRow' => array( + 'background-color' => '', + 'color' => '', + 'transform' => '', + ), + 'hoverTableRow' => array( + 'background-color' => '', + 'color' => '', + 'transform' => '', + ), + 'headerCell' => array( + 'background-color' => '', + 'color' => '', + 'transform' => '', + ), + 'tableCell' => array( + 'background-color' => '', + 'color' => '', + 'transform' => '', + ), + ), ) ); $wizard_data = array( From 6f70f51437e95d28d66bdfc5a2f6acb2784af8a2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:43:41 +0000 Subject: [PATCH 14/20] Bump codeinwp/themeisle-sdk from 3.3.13 to 3.3.14 Bumps [codeinwp/themeisle-sdk](https://github.com/Codeinwp/themeisle-sdk) from 3.3.13 to 3.3.14. - [Release notes](https://github.com/Codeinwp/themeisle-sdk/releases) - [Changelog](https://github.com/Codeinwp/themeisle-sdk/blob/master/CHANGELOG.md) - [Commits](https://github.com/Codeinwp/themeisle-sdk/compare/v3.3.13...v3.3.14) --- updated-dependencies: - dependency-name: codeinwp/themeisle-sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 60991639c..2819ee267 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "codeinwp/themeisle-sdk", - "version": "3.3.13", + "version": "3.3.14", "source": { "type": "git", "url": "https://github.com/Codeinwp/themeisle-sdk.git", - "reference": "2209cdf402e8f97def8d699bb8447dc67585cc95" + "reference": "662952078c57b12e4d3af9bc98ef847ea3500206" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/2209cdf402e8f97def8d699bb8447dc67585cc95", - "reference": "2209cdf402e8f97def8d699bb8447dc67585cc95", + "url": "https://api.github.com/repos/Codeinwp/themeisle-sdk/zipball/662952078c57b12e4d3af9bc98ef847ea3500206", + "reference": "662952078c57b12e4d3af9bc98ef847ea3500206", "shasum": "" }, "require-dev": { @@ -40,7 +40,7 @@ "keywords": [ "wordpress" ], - "time": "2024-02-01T14:10:46+00:00" + "time": "2024-02-27T17:30:04+00:00" }, { "name": "markbaker/complex", From b32a76a573d2a7e169e0ceb2aa9ea9d82aab0656 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Fri, 8 Mar 2024 17:21:15 +0200 Subject: [PATCH 15/20] fix: rendering condition --- js/render-google.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/render-google.js b/js/render-google.js index f84b636ae..80899a3f1 100644 --- a/js/render-google.js +++ b/js/render-google.js @@ -50,11 +50,12 @@ var isResizeRequest = false; function renderSpecificChart(id, chart) { var render, container, series, data, table, settings, i, j, row, date, axis, property, format, formatter; - if ( ! window.isResizeRequest && ( $('#' + id).hasClass('visualizer-chart-loaded') || ( 'canvas' !== id && $('#' + id).children( ':not(.loader)' ).length > 0 ) ) ) { + if( chart.library !== 'google' ) { return; } - if(chart.library !== 'google'){ + // Bail if the chart is already rendered or is being rendered. + if ( ! window.isResizeRequest && ( $('#' + id).hasClass('visualizer-chart-loaded') || ( 'canvas' !== id && $('#' + id).children( '.loader' ).length > 0 ) ) ) { return; } rendered_charts[id] = 'yes'; From 6f0945c22357ada90def3f976abc925f7cf44349 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Fri, 8 Mar 2024 17:27:22 +0200 Subject: [PATCH 16/20] fix: do not count style tag as proof for loading --- js/render-google.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/render-google.js b/js/render-google.js index 80899a3f1..4b0e46a7a 100644 --- a/js/render-google.js +++ b/js/render-google.js @@ -53,9 +53,9 @@ var isResizeRequest = false; if( chart.library !== 'google' ) { return; } - + // Bail if the chart is already rendered or is being rendered. - if ( ! window.isResizeRequest && ( $('#' + id).hasClass('visualizer-chart-loaded') || ( 'canvas' !== id && $('#' + id).children( '.loader' ).length > 0 ) ) ) { + if ( ! window.isResizeRequest && ( $('#' + id).hasClass('visualizer-chart-loaded') || ( 'canvas' !== id && $('#' + id).children( ':not(.loader, style)' ).length > 0 ) ) ) { return; } rendered_charts[id] = 'yes'; From 0d2305930dc88af2f534cf2f47747be3f6ff5ee7 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Fri, 8 Mar 2024 17:42:27 +0200 Subject: [PATCH 17/20] fix: add locker css on the parent of the chart container --- js/media/view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/media/view.js b/js/media/view.js index ab6c4e83c..db717cd7b 100644 --- a/js/media/view.js +++ b/js/media/view.js @@ -57,7 +57,7 @@ chart.settings = model.get('settings'); chart.settings.width = self.options.width; chart.settings.height = self.options.height; - $('#' + self.id).append(model.get('css')); + $('#' + self.id).parent().append(model.get('css')); $('body').trigger('visualizer:render:specificchart:start', {id: self.id, chart: chart, v: {page_type: 'post'}} ); } From 661f2a2715e5e2413bd51959aab8c7ca273f93fb Mon Sep 17 00:00:00 2001 From: Soare Robert Daniel Date: Tue, 12 Mar 2024 08:43:19 +0200 Subject: [PATCH 18/20] Add NPS survey (#1090) * feat: add NPS survey * chore: array key * chore: use only free version install date --- classes/Visualizer/Module/Admin.php | 75 +++++++++++++++++++++++++++++ js/survey.js | 12 +++++ 2 files changed, 87 insertions(+) create mode 100644 js/survey.js diff --git a/classes/Visualizer/Module/Admin.php b/classes/Visualizer/Module/Admin.php index e74854c37..556709532 100644 --- a/classes/Visualizer/Module/Admin.php +++ b/classes/Visualizer/Module/Admin.php @@ -900,6 +900,7 @@ private function getQuery() { */ public function renderSupportPage() { wp_enqueue_style( 'visualizer-upsell', VISUALIZER_ABSURL . 'css/upsell.css', array(), Visualizer_Plugin::VERSION ); + $this->load_survey(); include_once VISUALIZER_ABSPATH . '/templates/support.php'; } @@ -1053,6 +1054,9 @@ public function renderLibraryPage() { 'type' => 'array', ) ); + + $this->load_survey(); + $render->render(); } @@ -1182,4 +1186,75 @@ public static function checkChartStatus( $type ) { } return false; } + + /** + * Get the survey metadata. + * + * @return array The survey metadata. + */ + private function get_survey_metadata() { + $install_date = get_option( 'visualizer_install', false ); + $install_category = 0; + + if ( false !== $install_date ) { + $days_since_install = round( ( time() - $install_date ) / DAY_IN_SECONDS ); + + if ( 0 === $days_since_install || 1 === $days_since_install ) { + $install_category = 0; + } elseif ( 1 < $days_since_install && 8 > $days_since_install ) { + $install_category = 7; + } elseif ( 8 <= $days_since_install && 31 > $days_since_install ) { + $install_category = 30; + } elseif ( 30 < $days_since_install && 90 > $days_since_install ) { + $install_category = 90; + } elseif ( 90 <= $days_since_install ) { + $install_category = 91; + } + } + + $plugin_data = get_plugin_data( VISUALIZER_BASEFILE, false, false ); + $plugin_version = ''; + if ( ! empty( $plugin_data['Version'] ) ) { + $plugin_version = $plugin_data['Version']; + } + + $user_id = 'visualizer_' . preg_replace( '/[^\w\d]*/', '', get_site_url() ); // Use a normalized version of the site URL as a user ID. + + $license_data = get_option( 'visualizer_pro_license_data', false ); + if ( false !== $license_data ) { + $user_id = 'visualizer_' . $license_data->key; + } + + return array( + 'userId' => $user_id, + 'attributes' => array( + 'days_since_install' => $install_category, + 'free_version' => $plugin_version, + 'pro_version' => defined( 'VISUALIZER_PRO_VERSION' ) ? VISUALIZER_PRO_VERSION : '', + 'license_status' => apply_filters( 'product_visualizer_license_status', 'invalid' ), + ), + ); + } + + /** + * Load the survey. + */ + private function load_survey() { + + if ( defined( 'TI_CYPRESS_TESTING' ) ) { + return; + } + + $survey_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'survey' ); + + if ( empty( $survey_handler ) ) { + return; + } + + $metadata = $this->get_survey_metadata(); + + do_action( 'themeisle_sdk_dependency_enqueue_script', 'survey' ); + wp_enqueue_script( 'visualizer_chart_survey', VISUALIZER_ABSURL . 'js/survey.js', array( $survey_handler ), $metadata['attributes']['free_version'], true ); + wp_localize_script( 'visualizer_chart_survey', 'visualizerSurveyData', $metadata ); + } } diff --git a/js/survey.js b/js/survey.js new file mode 100644 index 000000000..6e29d56b8 --- /dev/null +++ b/js/survey.js @@ -0,0 +1,12 @@ +/** + * Initialize the formbricks survey. + * + * @see https://github.com/formbricks/setup-examples/tree/main/html + */ +window.addEventListener('themeisle:survey:loaded', function () { + window?.tsdk_formbricks?.init?.({ + environmentId: "cltef8cut1s7wyyfxy3rlxzs5", + apiHost: "https://app.formbricks.com", + ...(window?.visualizerSurveyData ?? {}), + }); +}); \ No newline at end of file From 5f05f4ce9878f90f5e9806946238c8f83ccb673c Mon Sep 17 00:00:00 2001 From: Bogdan Preda Date: Thu, 14 Mar 2024 11:53:59 +0200 Subject: [PATCH 19/20] [skip ci] add checklist and improve doc --- .distignore | 1 + .github/PULL_REQUEST_TEMPLATE.md | 27 +++ .github/workflows/pr-checklist.yml | 26 +++ CONTRIBUTING.md | 295 ++++++++++++++++++++++++++++- 4 files changed, 348 insertions(+), 1 deletion(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/pr-checklist.yml diff --git a/.distignore b/.distignore index f90ed0281..357e7b949 100755 --- a/.distignore +++ b/.distignore @@ -26,3 +26,4 @@ cypress.json .wordpress-org .releaserc.yml docker-compose.ci.yml +CONTRIBUTING.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..c4b39a78a --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,27 @@ +### Summary + + +### Will affect visual aspect of the product + +YES/NO + +### Screenshots + +### Test instructions + + +- +- + +## Check before Pull Request is ready: + +* [ ] I have [written a test](CONTRIBUTING.md#writing-an-acceptance-test) and included it in this PR +* [ ] I have [run all tests](CONTRIBUTING.md#run-tests) and they pass +* [ ] The code passes when [running the PHP CodeSniffer](CONTRIBUTING.md#run-php-codesniffer) +* [ ] Code meets [WordPress Coding Standards](CONTRIBUTING.md#coding-standards) for PHP, HTML, CSS and JS +* [ ] [Security and Sanitization](CONTRIBUTING.md#security-and-sanitization) requirements have been followed +* [ ] I have assigned a reviewer or two to review this PR (if you're not sure who to assign, we can do this step for you) + + +Closes #. + diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml new file mode 100644 index 000000000..a6e9ba7fe --- /dev/null +++ b/.github/workflows/pr-checklist.yml @@ -0,0 +1,26 @@ +name: Add labels to pull request based on checklist + +on: + pull_request: + types: [ opened, edited, synchronize, labeled, unlabeled ] + branches-ignore: + - 'master' + - 'update_dependencies' + +permissions: write-all + +jobs: + add-labels: + runs-on: ubuntu-latest + name: Label PR based on checklist + if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && github.actor != 'dependabot[bot]' + steps: + - name: Check if checklist items are completed + uses: Codeinwp/gha-pr-check-helper@master + with: + token: ${{ secrets.BOT_TOKEN }} + requireChecklist: true + onlyCheckBody: true + completedLabel: "pr-checklist-complete" + incompleteLabel: "pr-checklist-incomplete" + skipLabel: "pr-checklist-skip" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 36b5b5b16..661b81a56 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,4 +10,297 @@ How to release a new version: - `release: ` - for patch release - `release(minor): ` - for minor release - `release(major): ` - for major release - The release notes will inherit the body of the commit message which triggered the release. For more details check the [simple-preset](https://github.com/Codeinwp/conventional-changelog-simple-preset) that we use. \ No newline at end of file + The release notes will inherit the body of the commit message which triggered the release. For more details check the [simple-preset](https://github.com/Codeinwp/conventional-changelog-simple-preset) that we use. + +# CONTRIBUTING GUIDELINES ++ [Setup Guide](#setup-guide) ++ [Development Guide](#development-guide) ++ [Testing Guide](#testing-guide) + +# Setup Guide + +This document describes how to set up your development environment, so that it is ready to run, develop and test this WordPress Plugin or Theme. + +Suggestions are provided for the LAMP/LEMP stack and Git client are for those who prefer the UI over a command line and/or are less familiar with +WordPress, PHP, MySQL and Git - but you're free to use your preferred software. + +## Setup + +### LAMP/LEMP stack + +Any Apache/nginx, PHP 7.x+ and MySQL 5.8+ stack running WordPress. For example, but not limited to: +- Valet (recommended) +- Local by Flywheel +- Docker +- MAMP +- WAMP + +### Composer + +If [Composer](https://getcomposer.org) is not installed on your local environment, enter the following commands at the command line to install it: + +```bash +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" +php composer-setup.php +php -r "unlink('composer-setup.php');" +sudo mv composer.phar /usr/local/bin/composer +``` + +Confirm that installation was successful by entering the `composer --version` command at the command line + +### Clone Repository + +Using your preferred Git client or command line, clone this repository into the `wp-content/plugins/` folder of your local WordPress installation. + +If you prefer to clone the repository elsewhere, and them symlink it to your local WordPress installation, that will work as well. + +If you're new to this, use [GitHub Desktop](https://desktop.github.com/) or [Tower](https://www.git-tower.com/mac) + +For Plugins the cloned folder should be under `wp-content/plugins/` and for Themes under `wp-content/themes/`. + +### Install Dependencies for PHP and JS + +In the cloned repository's directory, at the command line, run `composer install`. +This will install the development dependencies. If you want to install just the production dependencies, run `composer install --no-dev`. + +The development dependencies include: +- PHPStan +- PHPUnit +- PHP_CodeSniffer +- WordPress Coding Standards +- WordPress PHPUnit Polyfills + +For the JS dependencies, run `npm install`. +To watch for changes in the JS files, run `npm run dev` if present or `npm run dist` to build a new version. + +### PHP_CodeSniffer + +To run PHP_CodeSniffer, run `composer lint`. This will run the WordPress Coding Standards checks. +To fix automatically fixable issues, run `composer format`. + +### PHPUnit + +To run PHPUnit, run `phpunit` or `./vendor/bin/phpunit` if it is not configured globally. + +### E2E Tests +If the folder `e2e-tests` is present, you can run the E2E tests by following the instructions in the [E2E testing](./e2e-tests/README.md). + +### Next Steps + +With your development environment setup, you'll probably want to start development, which is covered bellow in the **Development Guide**. + + + +# Development Guide + +This document describes the high level workflow used when working on a WordPress Plugin or Theme. + +You're free to use your preferred IDE and Git client. We recommend PHPStorm or Visual Studio Code, and GitHub CLI. + +## Prerequisites + +If you haven't yet set up your local development environment with a WordPress Plugin repository installed, refer to the [Setup Guide](#setup-guide). + +his is for a new feature that does not have a GitHub Issue number, enter a short descriptive name for the branch, relative to what you're working on +- If this is for a feature/bug that has a GitHub Issue number, enter feat/issue_name or fix/issue_name, where issue_name is a descriptive name for the issue + +Once done, make sure you've switched to your new branch, and begin making the necessary code additions/changes/deletions. + +## Coding Standards + +Code must follow [WordPress Coding standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/), which is checked +when running tests (more on this below). + +## Security and Sanitization + +When [outputting data](https://developer.wordpress.org/plugins/security/securing-output/), escape it using WordPress' escaping functions such as `esc_html()`, `esc_attr__()`, `wp_kses()`, `wp_kses_post()`. + +When reading [user input](https://developer.wordpress.org/plugins/security/securing-input/), sanitize it using WordPress' sanitization functions such as `sanitize_text_field()`, `sanitize_textarea_field()`. + +When writing to the database, prepare database queries using ``$wpdb->prepare()`` + +Never trust user input. Sanitize it. + +Make use of [WordPress nonces](https://codex.wordpress.org/WordPress_Nonces) for saving form submitted data. + +Coding standards will catch any sanitization, escaping or database queries that aren't prepared. + +## Composer Packages + +We use Composer for package management. A package can be added to one of two sections of the `composer.json` file: `require` or `require-dev`. + +### "require" + +Packages listed in the "require" directive are packages that the Plugin needs in order to function for end users. + +These packages are included when the Plugin is deployed to WordPress.org + +Typically, packages listed in this section would be libraries that the Plugin uses. + +### "require-dev" + +Packages listed in the "require-dev" directive are packages that the Plugin **does not** need in order to function for end users. + +These packages are **not** included when the Plugin is deployed to wordpress.org + +Typically, packages listed in this section would be internal development tools for testing, such as: +- Coding Standards +- PHPStan +- PHPUnit + +## Committing Work + +Remember to commit your changes to your branch relatively frequently, with a meaningful, short summary that explains what the change(s) do. +This helps anyone looking at the commit history in the future to find what they might be looking for. + +If it's a particularly large commit, be sure to include more information in the commit description. + +## Next Steps + +Once you've finished your feature or issue, you must write/amend tests for it. Refer to the [Testing Guide](#testing-guide) for a detailed walkthrough +on how to write a test. + + + +# Testing Guide + +This document describes how to: +- create and run tests for your development work, +- ensure code meets PHP and WordPress Coding Standards, for best practices and security, +- ensure code passes static analysis, to catch potential errors that tests might miss + +If you're new to creating and running tests, this guide will walk you through how to do this. + +For those more experienced with creating and running tests, our tests are written in TS for [Playwright](https://playwright.dev/) used for End-to-End testing, +and in PHP for [PHPUnit](https://phpunit.de/). + +A PHPUnit guide for WordPress can be found [here](https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/). + +## Prerequisites + +If you haven't yet set up your local development environment with this Plugin repository installed, refer to the [Setup Guide](#setup-guide). + +If you haven't yet created a branch and made any code changes to the Plugin or Theme, refer to the [Development Guide](#development-guide) + +## Write (or modify) a test + +If your work creates new functionality, write a test. + +If your work fixes existing functionality, check if a test exists. Either update that test, or create a new test if one doesn't exist. + +Tests are written in TS using [Playwright](https://playwright.dev/) and PHP using [PHPUnit](https://phpunit.de/). + +## Types of Test + +There are different types of tests that can be written: +- Acceptance Tests: Test as a non-technical user in the web browser. +- Functional Tests: Test the framework (WordPress). +- Integration Tests: Test code modules in the context of a WordPress website. +- Unit Tests: Test single PHP classes or functions in isolation. +- WordPress Unit Tests: Test single PHP classes or functions in isolation, with WordPress functions and classes loaded. + +There is no definitive / hard guide, as a test can typically overlap into different types (such as Acceptance and Functional). + +The most important thing is that you have a test for *something*. If in doubt, an Acceptance Test will suffice. + +### Writing an Acceptance Test + +An acceptance test is a test that simulates a user interacting with the Plugin or Theme in a web browser. +Refer to Writing an End-to-End Test below. + +### Writing an End-to-End Test + +To write an End-to-End test, create a new file under `e2e-tests/specs` with the name of the spec or functionality you are testing, and add `.spec.test` to the file name. + +E.g. for `e2e-tests/specs/checkout.spec.test.js`, the test file should be `checkout.spec.test.js`. + +For more information on writing End-to-End tests, refer to the [Playwright documentation](https://playwright.dev/docs/test-intro). + +You can check End-to-End [README](./e2e-tests/README.md) for more details. + +## Writing a WordPress Unit Test + +WordPress Unit tests provide testing of Plugin/Theme specific functions and/or classes, typically to assert that they perform as expected +by a developer. This is primarily useful for testing our API class, and confirming that any Plugin registered filters return +the correct data. + +To create a new WordPress Unit Test, create a new file under `tests/php/unit` with the name of the class you are testing, and the suffix `Test`. +The filename should be in `lower-case-with-dash`, and the class name should be in `CamelCase`. + +E.g. for `tests/php/unit/class-api-test.php`, the test class should be `class APITest extends \PHPUnit\Framework\TestCase`. + +```php +post->create_and_get(); + + $this->assertInstanceOf(\WP_Post::class, $post); + } +} +``` + +## Run PHPUnit Tests + +Once you have written your code and test(s), run the tests to make sure there are no errors. + +```bash +./vendor/bin/phpunit tests/php/unit/class-api-test.php +``` + +Any errors should be corrected by making applicable code or test changes. + +## Run PHP CodeSniffer + +In the Plugin's or Theme's directory, run the following command to run PHP_CodeSniffer, which will check the code meets Coding Standards +as defined in the `phpcs.tests.xml` configuration: + +```bash +composer run lint +``` + +`--standard=phpcs.tests.xml` tells PHP CodeSniffer to use the Coding Standards rules / configuration defined in `phpcs.tests.xml`. +These differ slightly from WordPress' Coding Standards, to ensure that writing tests isn't a laborious task, whilst maintain consistency +in test coding style. +`-v` produces verbose output +`-s` specifies the precise rule that failed + +Any errors should be corrected by either: +- making applicable code changes +- running `composer run format` to automatically fix coding standards + +Need to change the PHP or WordPress coding standard rules applied? Either: +- ignore a rule in the affected code, by adding `phpcs:ignore {rule}`, where {rule} is the given rule that failed in the above output. +- edit the [phpcs.tests.xml](phpcs.tests.xml) file. + +## Next Steps + +Once your test(s) are written and successfully run locally, submit your branch via a new **Pull Request**. + +It's best to create a Pull Request in draft mode, as this will trigger all tests to run as a GitHub Action, allowing you to +double-check all tests pass. + +If the PR tests fail, you can make code changes as necessary, pushing to the same branch. This will trigger the tests to run again. + +If the PR tests pass, you can publish the PR, assigning some reviewers. From c295deed6bf33951f54a11fdfda7b3cb183939a6 Mon Sep 17 00:00:00 2001 From: "themeisle[bot]" <> Date: Thu, 14 Mar 2024 14:45:05 +0000 Subject: [PATCH 20/20] chore(release): 3.10.8 ##### [Version 3.10.8](https://github.com/Codeinwp/visualizer/compare/v3.10.7...v3.10.8) (2024-03-14) ### Bug Fixes - Fix Google chart rendering condition for Classic Plugin - Changes the speed and position of the loading bar ### Improvements - Add a Live Preview button for the plugin page on wordpress.org - Added NPS survey --- CHANGELOG.md | 10 ++++++++++ classes/Visualizer/Plugin.php | 2 +- css/media.css | 2 +- index.php | 2 +- package.json | 2 +- readme.txt | 13 +++++++++++++ 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cd33c117..18782391e 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +##### [Version 3.10.8](https://github.com/Codeinwp/visualizer/compare/v3.10.7...v3.10.8) (2024-03-14) + +### Bug Fixes +- Fix Google chart rendering condition for Classic Plugin +- Changes the speed and position of the loading bar + +### Improvements +- Add a Live Preview button for the plugin page on wordpress.org +- Added NPS survey + ##### [Version 3.10.7](https://github.com/Codeinwp/visualizer/compare/v3.10.6...v3.10.7) (2024-02-06) ### Fixes diff --git a/classes/Visualizer/Plugin.php b/classes/Visualizer/Plugin.php index a17cf9452..a877861d5 100644 --- a/classes/Visualizer/Plugin.php +++ b/classes/Visualizer/Plugin.php @@ -28,7 +28,7 @@ class Visualizer_Plugin { const NAME = 'visualizer'; - const VERSION = '3.10.7'; + const VERSION = '3.10.8'; // custom post types const CPT_VISUALIZER = 'visualizer'; diff --git a/css/media.css b/css/media.css index 5ca15bf0c..231821b90 100644 --- a/css/media.css +++ b/css/media.css @@ -1,5 +1,5 @@ /* - Version: 3.10.7 + Version: 3.10.8 */ #visualizer-library-view { padding: 30px 10px 10px 30px; diff --git a/index.php b/index.php index 03377b11d..358bb2655 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ Plugin Name: Visualizer: Tables and Charts for WordPress Plugin URI: https://themeisle.com/plugins/visualizer-charts-and-graphs/ Description: A simple, easy to use and quite powerful tool to create, manage and embed interactive charts into your WordPress posts and pages. The plugin uses Google Visualization API to render charts, which supports cross-browser compatibility (adopting VML for older IE versions) and cross-platform portability to iOS and new Android releases. - Version: 3.10.7 + Version: 3.10.8 Author: Themeisle Author URI: http://themeisle.com Requires at least: 5.2 diff --git a/package.json b/package.json index f4ca327a9..3634f9a90 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "visualizer", - "version": "3.10.7", + "version": "3.10.8", "description": "Visualizer Lite", "repository": { "type": "git", diff --git a/readme.txt b/readme.txt index bab04d0ab..2a7b62c86 100755 --- a/readme.txt +++ b/readme.txt @@ -157,6 +157,19 @@ Pay attention that to turn your shortcodes into graphs, your theme has to have ` == Changelog == +##### [Version 3.10.8](https://github.com/Codeinwp/visualizer/compare/v3.10.7...v3.10.8) (2024-03-14) + +### Bug Fixes +- Fix Google chart rendering condition for Classic Plugin +- Changes the speed and position of the loading bar + +### Improvements +- Add a Live Preview button for the plugin page on wordpress.org +- Added NPS survey + + + + ##### [Version 3.10.7](https://github.com/Codeinwp/visualizer/compare/v3.10.6...v3.10.7) (2024-02-06) ### Fixes