/home/sylamedg/www/wp-content/plugins/my-wp-ab-testing/js/block.js
!function(t){var e={};function n(a){if(e[a])return e[a].exports;var l=e[a]={i:a,l:!1,exports:{}};return t[a].call(l.exports,l,l.exports,n),l.l=!0,l.exports}n.m=t,n.c=e,n.d=function(t,e,a){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var l in t)n.d(a,l,function(e){return t[e]}.bind(null,l));return a},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function l(t,e){for(var n=0;n<e.length;n++){var a=e[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function r(t,e){return(r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,a=o(t);if(e){var l=o(this).constructor;n=Reflect.construct(a,arguments,l)}else n=a.apply(this,arguments);return i(this,n)}}function i(t,e){return!e||"object"!==a(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}n.r(e);var s=wp.i18n.__,b=wp.element,u=b.Component,_=b.Fragment,p=wp.blockEditor.InspectorControls,g=wp.components,f=g.PanelBody,d=g.SelectControl,m=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}(o,t);var e,n,a,i=c(o);function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=i.call(this,t)).state={listItem:[],isOpen:!1,abtesting_block:[],modal_data:[]},e.getAllAbtesting(),e}return e=o,(n=[{key:"getAllAbtesting",value:function(){var t=this;fetch(REST_API.url+"wp/v2/abtesting?per_page=100").then((function(t){return t.json()})).then((function(e){var n=[],a=new Object;n.push({value:0,label:"Choix"}),e.map((function(t){n.push({value:t.id,label:t.title.rendered}),a[t.id]={abtesting_block_a:{link:t.meta_abtesting.abtesting_block_a.link,title:t.meta_abtesting.abtesting_block_a.title,content:t.meta_abtesting.abtesting_block_a.content,count:t.meta_abtesting.abtesting_block_a.count,conversion:t.meta_abtesting.abtesting_block_a.conversion,percentage:t.meta_abtesting.abtesting_block_a.percentage},abtesting_block_b:{link:t.meta_abtesting.abtesting_block_b.link,title:t.meta_abtesting.abtesting_block_b.title,content:t.meta_abtesting.abtesting_block_b.content,count:t.meta_abtesting.abtesting_block_b.count,conversion:t.meta_abtesting.abtesting_block_b.conversion,percentage:t.meta_abtesting.abtesting_block_b.percentage}}})),t.setState({listItem:n,abtesting_block:a})}))}},{key:"closeModal",value:function(){this.setState({isOpen:!1})}},{key:"openModal",value:function(t,e){var n=this.props,a=n.attributes,l=(n.setAttributes,a.reblexab_id),r=this.state.abtesting_block[l],c={title:"",link:"",id:0};"testing-a"===e?(c.title=r.abtesting_block_a.title,c.link=r.abtesting_block_a.link,c.content=r.abtesting_block_a.content,c.count=r.abtesting_block_a.content):(c.title=r.abtesting_block_b.title,c.link=r.abtesting_block_b.link,c.content=r.abtesting_block_b.content,c.count=r.abtesting_block_b.content),this.setState({isOpen:!0,modal_data:c})}},{key:"componentDidUpdate",value:function(t,e,n){this.loadScript()}},{key:"loadScript",value:function(){$=jQuery,$(document).find(".reblexab_chart").each((function(){var t=$(this);if(t){var e=parseInt($(t).attr("data-a")),n=parseInt($(t).attr("data-b")),a=$(t).attr("data-title");new Chart(t,{type:"pie",data:{labels:["Block B","Block A"],datasets:[{data:[n,e],backgroundColor:["rgba( 51, 153, 204, 0.7 )","rgba( 255, 52, 117, 0.7 )"]}]},options:{title:{display:!0,text:a},legend:{display:!0,position:"bottom",rtl:!0}}})}}))}},{key:"render",value:function(){var t=this.props,e=t.attributes,n=t.setAttributes,a=(t.isSelected,e.reblexab_id);return React.createElement(_,null,React.createElement(p,null,React.createElement(f,null,React.createElement(d,{label:"Block",value:a,options:this.state.listItem,onChange:function(t){return n({reblexab_id:t})}}))),React.createElement("h2",null,s("A/B Testing live results","my-wp-abtesting")),0==a&&React.createElement(_,null,React.createElement("p",{style:{textAlign:"center"}},s("Select Campaign in right panel")),React.createElement("span",{className:"dashicons dashicons-chart-pie",style:{display:"block",margin:"0 auto",width:"200px",height:"110px",fontSize:"100px"}})),this.state.abtesting_block&&this.state.abtesting_block[a]&&React.createElement(_,null,React.createElement("table",{style:{display:"table-caption"},className:"wp-list-table widefat reblexab_stats_wrapper_charts"},React.createElement("tr",null,React.createElement("td",null,React.createElement("canvas",{id:"reblexab_chart_displayed",className:"reblexab_chart","data-title":"Displays","data-a":this.state.abtesting_block[a].abtesting_block_a.count,"data-b":this.state.abtesting_block[a].abtesting_block_b.count})),React.createElement("td",null,React.createElement("canvas",{id:"reblexab_chart_converted",className:"reblexab_chart","data-title":"Conversions","data-a":this.state.abtesting_block[a].abtesting_block_a.conversion,"data-b":this.state.abtesting_block[a].abtesting_block_b.conversion})))),React.createElement("table",{className:"wp-list-table widefat fixed striped reblexab_stats_wrapper_table"},React.createElement("tr",null,React.createElement("th",null,s("Block","my-wp-abtesting")),React.createElement("th",null,s("Displayed","my-wp-abtesting")),React.createElement("th",null,s("Converted","my-wp-abtesting")),React.createElement("th",null,s("Conversion rate","my-wp-abtesting"))),React.createElement("tr",null,React.createElement("th",null,React.createElement("a",{target:"_blank",href:this.state.abtesting_block[a].abtesting_block_a.link},s("Edit block A","my-wp-abtesting"))),React.createElement("td",null,this.state.abtesting_block[a].abtesting_block_a.count),React.createElement("td",null,this.state.abtesting_block[a].abtesting_block_a.conversion),React.createElement("td",null,React.createElement("strong",null,this.state.abtesting_block[a].abtesting_block_a.percentage))),React.createElement("tr",null,React.createElement("th",null,React.createElement("a",{target:"_blank",href:this.state.abtesting_block[a].abtesting_block_b.link},s("Edit block B","my-wp-abtesting"))),React.createElement("td",null,this.state.abtesting_block[a].abtesting_block_b.count),React.createElement("td",null,this.state.abtesting_block[a].abtesting_block_b.conversion),React.createElement("td",null,React.createElement("strong",null,this.state.abtesting_block[a].abtesting_block_b.percentage))))))}}])&&l(e.prototype,n),a&&l(e,a),o}(u);!function(t){var e=t.blocks.registerBlockType,n=t.i18n.__,a=t.element.Fragment;e("reblexab/ab-testing",{title:n("A/B Testing","blocks-and-me"),icon:{src:"chart-pie"},category:"common",attributes:{reblexab_id:{type:"string",default:0}},supports:{className:!1},edit:function(t){var e=t.attributes,n=t.className,l=t.setAttributes,r=(t.isSelected,e.reblexab_id);return React.createElement(a,null,React.createElement(m,{reblexab_id:r,setAttributes:l,attributes:e,className:n}))},save:function(t){t.attributes,t.className,t.setAttributes,t.isSelected;return null}})}(window.wp)}]);