!function(){var e={184:function(e,t){var n;
/*!
  Copyright (c) 2017 Jed Watson.
  Licensed under the MIT License (MIT), see
  http://jedwatson.github.io/classnames
*/!function(){"use strict";var o={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var n=arguments[t];if(n){var a=typeof n;if("string"===a||"number"===a)e.push(n);else if(Array.isArray(n)&&n.length){var i=r.apply(null,n);i&&e.push(i)}else if("object"===a)for(var c in n)o.call(n,c)&&n[c]&&e.push(c)}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(n=function(){return r}.apply(t,[]))||(e.exports=n)}()},496:function(e){for(var t=self.crypto||self.msCrypto,n="-_",o=36;o--;)n+=o.toString(36);for(o=36;o---10;)n+=o.toString(36).toUpperCase();e.exports=function(e){var r="",a=t.getRandomValues(new Uint8Array(e||21));for(o=e||21;o--;)r+=n[63&a[o]];return r}},539:function(e,t){var n,o,r;
/*!
 * php-unserialize-js JavaScript Library
 * https://github.com/bd808/php-unserialize-js
 *
 * Copyright 2013 Bryan Davis and contributors
 * Released under the MIT license
 * http://www.opensource.org/licenses/MIT
 */!function(a,i){"use strict";o=[],void 0===(r="function"==typeof(n=function(){return function(e){var t,n=0,o=[],r=0,a=function(){var t=e.indexOf(":",n),o=e.substring(n,t);return n=t+2,parseInt(o,10)},i=function(){var t=e.indexOf(";",n),o=e.substring(n,t);return n=t+1,parseInt(o,10)},c=function(){var e=i();return o[r++]=e,e},l=function(){var t=e.indexOf(";",n),a=e.substring(n,t);return n=t+1,a=parseFloat(a),o[r++]=a,a},s=function(){var t=e.indexOf(";",n),a=e.substring(n,t);return n=t+1,a="1"===a,o[r++]=a,a},u=function(t='"'){for(var o,r,i=a(),c=0,l=0;l<i;)(o=e.charCodeAt(n+c++))<=127?l++:l+=o>2047?3:2;return e.charAt(n+c)!==t&&(c+=e.indexOf('"',n+c)-n-c),r=e.substring(n,n+c),n+=c+2,r},d=function(){var e=u();return o[r++]=e,e},p=function(){var t=e.charAt(n);return n+=2,t},m=function(){var e=p();switch(e){case"i":return i();case"s":return u();default:throw new Error("Unknown key type '"+e+"' at position "+(n-2))}},f=function(){var e,i,c,l,s,u=a(),d=[],p={},f=d,y=r++;o[y]=f;try{for(c=0;c<u;c++)if(e=m(),i=t(),f===d&&e+""==c+"")d.push(i);else{if(f!==p){for(l=0,s=d.length;l<s;l++)p[l]=d[l];f=p,o[y]=f}p[e]=i}}catch(e){throw e.state=f,e}return n++,f},y=function(e,t){var o,r,a;if("\0"===e.charAt(0)){if((a=e.indexOf("\0",1))>0)return o=e.substring(1,a),r=e.substr(a+1),"*"===o||t===o?r:o+"::"+r;var i="Expected two <NUL> characters in non-public property name '"+e+"' at position "+(n-e.length-2);throw new Error(i)}return e},h=function(){var e,i,c,l,s={},d=r++,p=u();o[d]=s,e=a();try{for(l=0;l<e;l++)i=y(m(),p),c=t(),s[i]=c}catch(e){throw e.state=s,e}return n++,s},v=function(){return{__PHP_Incomplete_Class_Name:u(),serialized:u("}")}},b=function(){var e=i(),t=o[e-1];return o[r++]=t,t},_=function(){var e=i();return o[e-1]},g=function(){var e=null;return o[r++]=e,e};return(t=function(){var e=p();switch(e){case"i":return c();case"d":return l();case"b":return s();case"s":return d();case"a":return f();case"O":return h();case"C":return v();case"r":return b();case"R":return _();case"N":return g();default:throw new Error("Unknown type '"+e+"' at position "+(n-2))}})()}})?n.apply(t,o):n)||(e.exports=r)}()},459:function(e,t,n){var o=n(967);function r(e,t,n,o,a){var i=new Error(n,o,a);return i.name="UseFetchError",i.status=e,i.statusText=t,Object.setPrototypeOf(i,Object.getPrototypeOf(this)),Error.captureStackTrace&&Error.captureStackTrace(i,r),i}r.prototype=Object.create(Error.prototype,{constructor:{value:Error,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf(r,Error),e.exports=function(e,t,n){var a=(n&&n.depends||t&&t.depends||[]).reduce((function(e,t){return e||!t}),!1);return o(!a&&function(e,t,n){return fetch(e,t).then(n&&n.formatter||t&&t.formatter||function(e){if(!e.ok)throw new r(e.status,e.statusText,"Fetch error");return e.json()})},e,t||{},n||{})}},967:function(e,t,n){var o=n(313),r=n(923);e.exports=function(e){var t=Array.prototype.slice.call(arguments,[1]),n=o.useState({isLoading:!!e});return o.useEffect((function(){e&&(!n[0].isLoading&&n[1]({data:n[0].data,isLoading:!0}),e.apply(null,t).then((function(e){n[1]({data:e,isLoading:!1})})).catch((function(e){n[1]({error:e,isLoading:!1})})))}),r(t)),n[0]}},923:function(e){e.exports=function e(){for(var t=[],n=0;n<arguments.length;n++){var o=arguments[n];if(o instanceof Array)for(var r=0;r<o.length;r++)t=t.concat(e(o[r]));else if("undefined"!=typeof URL&&o instanceof URL)t=t.concat(o.toJSON());else if(o instanceof Object)for(var a=Object.keys(o),i=0;i<a.length;i++){var c=a[i];t=t.concat([c]).concat(e(o[c]))}else t=t.concat(o)}return t}},616:function(e,t,n){var o=n(496);e.exports=function(){var e=function(){e.id=o(),e.subscribers.forEach((function(e){e()}))};return e.id=o(),e.subscribers=[],e.subscribe=function(t){e.subscribers.push(t)},e.unsubscribe=function(t){e.subscribers.indexOf(t)>=0&&e.subscribers.splice(e.subscribers.indexOf(t),1)},e}},382:function(e,t,n){var o=n(313);e.exports=function(e){var t=o.useState(e.id),n=function(){return t[1](e.id)};return o.useEffect((function(){return e.subscribe(n),function(){return e.unsubscribe(n)}}),[]),t[0]}},313:function(e){"use strict";e.exports=window.React},61:function(e,t,n){var o=n(698).default;function r(){"use strict";
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */e.exports=r=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},n=Object.prototype,a=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",l=i.asyncIterator||"@@asyncIterator",s=i.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 d(e,t,n,o){var r=t&&t.prototype instanceof f?t:f,a=Object.create(r.prototype),i=new j(o||[]);return a._invoke=function(e,t,n){var o="suspendedStart";return function(r,a){if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===r)throw a;return S()}for(n.method=r,n.arg=a;;){var i=n.delegate;if(i){var c=O(i,n);if(c){if(c===m)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===o)throw o="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o="executing";var l=p(e,t,n);if("normal"===l.type){if(o=n.done?"completed":"suspendedYield",l.arg===m)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o="completed",n.method="throw",n.arg=l.arg)}}}(e,n,i),a}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=d;var m={};function f(){}function y(){}function h(){}var v={};u(v,c,(function(){return this}));var b=Object.getPrototypeOf,_=b&&b(b(C([])));_&&_!==n&&a.call(_,c)&&(v=_);var g=h.prototype=f.prototype=Object.create(v);function E(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function n(r,i,c,l){var s=p(e[r],e,i);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==o(d)&&a.call(d,"__await")?t.resolve(d.__await).then((function(e){n("next",e,c,l)}),(function(e){n("throw",e,c,l)})):t.resolve(d).then((function(e){u.value=e,c(u)}),(function(e){return n("throw",e,c,l)}))}l(s.arg)}var r;this._invoke=function(e,o){function a(){return new t((function(t,r){n(e,o,t,r)}))}return r=r?r.then(a,a):a()}}function O(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method))return m;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var o=p(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,m;var r=o.arg;return r?r.done?(t[e.resultName]=r.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,m):r:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,m)}function k(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 x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function j(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function C(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(a.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:S}}function S(){return{value:void 0,done:!0}}return y.prototype=h,u(g,"constructor",h),u(h,"constructor",y),y.displayName=u(h,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,u(e,s,"GeneratorFunction")),e.prototype=Object.create(g),e},t.awrap=function(e){return{__await:e}},E(w.prototype),u(w.prototype,l,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,o,r,a){void 0===a&&(a=Promise);var i=new w(d(e,n,o,r),a);return t.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(g),u(g,s,"Generator"),u(g,c,(function(){return this})),u(g,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var o=t.pop();if(o in e)return n.value=o,n.done=!1,n}return n.done=!0,n}},t.values=C,j.prototype={constructor:j,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&a.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,o){return i.type="throw",i.arg=e,t.next=n,o&&(t.method="next",t.arg=void 0),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var r=this.tryEntries[o],i=r.completion;if("root"===r.tryLoc)return n("end");if(r.tryLoc<=this.prev){var c=a.call(r,"catchLoc"),l=a.call(r,"finallyLoc");if(c&&l){if(this.prev<r.catchLoc)return n(r.catchLoc,!0);if(this.prev<r.finallyLoc)return n(r.finallyLoc)}else if(c){if(this.prev<r.catchLoc)return n(r.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<r.finallyLoc)return n(r.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&a.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var r=o;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var i=r?r.completion:{};return i.type=e,i.arg=t,r?(this.method="next",this.next=r.finallyLoc,m):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),x(n),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var o=n.completion;if("throw"===o.type){var r=o.arg;x(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:C(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),m}},t}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},698:function(e){function t(n){return e.exports=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.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},687:function(e,t,n){var o=n(61)();e.exports=o;try{regeneratorRuntime=o}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=o:Function("r","regeneratorRuntime = r")(o)}}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var a=t[o]={exports:{}};return e[o].call(a.exports,a,a.exports,n),a.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.element,t=window.wp.components;function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function r(e,t){if(e){if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(a.push(o.value),!t||a.length!==t);i=!0);}catch(e){c=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw r}}return a}}(e,t)||r(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var i=window.wp.i18n,c=window.blocksyOptions;function l(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||r(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var u=n(184),d=n.n(u);function p(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)n=a[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)n=a[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function m(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?m(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var y=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=(0,e.useContext)(M),o=n.isAdvancedMode,r=n.remoteConditions,a=n.allTaxonomies,i=n.allLanguages,c=n.allUsers,s=r;return{isAdvancedMode:o,allRules:s.reduce((function(e,t){var n=t.rules,o=t.title;return[].concat(l(e),l(n.map((function(e){return f(f({},e),{},{group:o})}))))}),[]).reduce((function(e,n){var o=n.title,r=n.id,a=n.sub_ids,i=void 0===a?[]:a,c=p(n,["title","id","sub_ids"]);return[].concat(l(e),[f({key:t&&i.length>0&&i.find((function(e){return e.id===t.rule}))?t.rule:r,value:o,sub_ids:i},c)])}),[]),rulesToUse:s,allTaxonomies:a,allLanguages:i,allUsers:c}};function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function v(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?h(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var b=function(e){return e.filter((function(e,t,n){return n.findIndex((function(t){return t.ID===e.ID}))===t}))},_=[],g=function(t){var n=t.condition,o=t.onChange,r=a((0,e.useState)(_),2),s=r[0],u=r[1],d=(0,e.useMemo)((function(){return{post_ids:"post",page_ids:"page",product_ids:"product",custom_post_type_ids:"ct_cpt"}[n.rule]}),[n.rule]),p=(0,e.useMemo)((function(){return(n.payload||{}).post_id||""}),[n.payload&&n.payload.post_id]),m=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";fetch("".concat(wp.ajax.settings.url,"?action=blocksy_conditions_get_all_posts"),{headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(v(v({post_type:d},e?{search_query:e}:{}),p?{alsoInclude:p}:{})),method:"POST"}).then((function(e){return e.json()})).then((function(e){var t=e.data.posts;u((function(e){return b([].concat(l(e),l(t)))})),_=b([].concat(l(_),l(t)))}))};return(0,e.useEffect)((function(){m()}),[d]),(0,e.createElement)(c.Select,{option:{appendToBody:!0,defaultToFirstItem:!1,searchPlaceholder:(0,i.__)("Type to search by ID or title...","blocksy-companion"),placeholder:"post_ids"===n.rule?(0,i.__)("Select post","blocksy-companion"):"page_ids"===n.rule?(0,i.__)("Select page","blocksy-companion"):"product_ids"===n.rule?(0,i.__)("Select product","blocksy-companion"):(0,i.__)("Custom Post Type ID","blocksy-companion"),choices:l(s.filter((function(e){var t=e.post_type;return"ct_cpt"===d?"post"!==t&&"page"!==t:d===t})).map((function(e){return{key:e.ID,value:e.post_title}}))),search:!0},value:p,onChange:function(e){return o(e)},onInputValueChange:function(e){s.find((function(t){return t.post_title===e}))||m(e)}})};function E(){return E=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},E.apply(this,arguments)}function w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function O(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?w(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var k=function(t){var n=t.onChange,o=t.condition,r=a((0,e.useState)("start"),2),l=r[0],u=r[1],p=(0,e.useRef)(),m=a((0,e.useState)(!1),2),f=m[0],y=m[1],h=(0,c.usePopoverMaker)({ref:p,defaultHeight:228,shouldCalculate:!0}),v=h.styles,b=h.popoverProps,_=o.payload.start||new Date,g=o.payload.end||new Date,w=[wp.date.format("j/n/Y",_),wp.date.format("j/n/Y",g)];return w[0]===w[1]&&(w=[wp.date.format(wp.date.getSettings().formats.time,_),wp.date.format(wp.date.getSettings().formats.time,g)]),(0,e.createElement)(e.Fragment,null,(0,e.createElement)(c.OutsideClickHandler,{className:"ct-select-input",wrapperProps:{ref:p,role:"combobox","aria-expanded":f,"aria-haspopup":"listbox",onClick:function(){y(!f)}},onOutsideClick:function(e){e.target.closest(".ct-select-dropdown")||y(!1)}},(0,e.createElement)("input",{value:w.join(" - "),onChange:function(){},readOnly:!0})),f&&(0,e.createPortal)((0,e.createElement)("div",E({className:d()("ct-select-dropdown ct-date-time-picker-dropdown",{"ct-fixed":!0})},b,{style:v}),(0,e.createElement)("div",{className:"ct-start-end-date-switcher components-button-group"},["start","end"].map((function(t){return(0,e.createElement)("button",{key:t,className:d()("components-button",{"is-primary":t===l}),onClick:function(){u(t)}},"start"===t?"Start Date":"Expiration Date")}))),(0,e.createElement)(c.DateTimePicker,{value:(o.payload||{})[l]||new Date,onChange:function(e){"end"===l&&new Date(e).getTime()<(o.payload.start?new Date(o.payload.start).getTime():(new Date).getTime())&&(e=o.payload.start,alert((0,i.__)("The expiration date cannot be set earlier than the start date.","blocksy-companion"))),"start"===l&&new Date(e).getTime()>(o.payload.end?new Date(o.payload.end).getTime():(new Date).getTime())&&(o.payload.end=e),n(O(O({},o),{},{payload:O(O(O({},o.payload),o.payload.start?{}:{start:_}),{},s({},l,e))}))}})),document.body))},x=window.wp.date;function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function C(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?j(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var S=function(n){var o=n.onChange,r=n.condition,l=(0,e.useRef)(),u=a((0,e.useState)(!1),2),p=u[0],m=u[1],f=(0,c.usePopoverMaker)({ref:l,defaultHeight:228,shouldCalculate:!0}),y=f.styles,h=f.popoverProps,v={monday:!0,tuesday:!0,wednesday:!0,thursday:!0,friday:!0,saturday:!0,sunday:!0},b=Object.keys(v).filter((function(e){return(r.payload.days||v)[e]})),_="Only "+b.map((function(e){return function(e){return{monday:(0,i.__)("Mon","blocksy-companion"),tuesday:(0,i.__)("Tue","blocksy-companion"),wednesday:(0,i.__)("Wed","blocksy-companion"),thursday:(0,i.__)("Thu","blocksy-companion"),friday:(0,i.__)("Fri","blocksy-companion"),saturday:(0,i.__)("Sat","blocksy-companion"),sunday:(0,i.__)("Sun","blocksy-companion")}[e]}(e)})).join(", ");7===b.length&&(_=(0,i.__)("Every day","blocksy-companion")),2===b.length&&b.includes("saturday")&&b.includes("sunday")&&(_=(0,i.__)("Only weekends","blocksy-companion")),5!==b.length||b.includes("saturday")||b.includes("sunday")||(_=(0,i.__)("Only weekdays","blocksy-companion")),0===b.length&&(_=(0,i.__)("Never","blocksy-companion"));var g=r.payload.time_start||"00:00",w=r.payload.time_end||"23:59",O=new Date;O.setHours(g.split(":")[0]),O.setMinutes(g.split(":")[1],0,0);var k=new Date;k.setHours(w.split(":")[0]),k.setMinutes(w.split(":")[1],0,0);var j=(0,x.getSettings)(),S=/a(?!\\)/i.test(j.formats.time.toLowerCase().replace(/\\\\/g,"").split("").reverse().join(""));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(c.OutsideClickHandler,{className:"ct-select-input",wrapperProps:{ref:l,role:"combobox","aria-expanded":p,"aria-haspopup":"listbox",onClick:function(){m(!p)}},onOutsideClick:function(e){e.target.closest(".ct-select-dropdown")||m(!1)}},(0,e.createElement)("input",{value:_,onChange:function(){},readOnly:!0})),p&&(0,e.createPortal)((0,e.createElement)("div",E({className:d()("ct-select-dropdown ct-recurring-scheduling-dropdown",{"ct-fixed":!0})},h,{style:y}),(0,e.createElement)("div",{className:"ct-recurring-scheduling-days"},(0,e.createElement)("label",{className:"ct-label"},(0,i.__)("Recurring Days","blocksy-companion")),[{key:"monday",value:(0,i.__)("Monday","blocksy-companion")},{key:"tuesday",value:(0,i.__)("Tuesday","blocksy-companion")},{key:"wednesday",value:(0,i.__)("Wednesday","blocksy-companion")},{key:"thursday",value:(0,i.__)("Thursday","blocksy-companion")},{key:"friday",value:(0,i.__)("Friday","blocksy-companion")},{key:"saturday",value:(0,i.__)("Saturday","blocksy-companion")},{key:"sunday",value:(0,i.__)("Sunday","blocksy-companion")}].map((function(n){var a=n.key,i=n.value;return(0,e.createElement)(t.CheckboxControl,{label:i,checked:(r.payload.days||v)[a],onChange:function(){o(C(C({},r),{},{payload:C(C({},r.payload),{},{days:C(C({},r.payload.days||v),{},s({},a,!(r.payload.days||v)[a]))})}))}})}))),(0,e.createElement)("div",{className:"ct-recurring-scheduling-time"},(0,e.createElement)("div",{className:"ct-recurring-start-time"},(0,e.createElement)("label",{className:"ct-label"},(0,i.__)("Start Time","blocksy-companion")),(0,e.createElement)(t.TimePicker,{is12Hour:S,currentTime:O,onChange:function(e){o(C(C({},r),{},{payload:C(C({},r.payload),{},{time_start:wp.date.format("H:i",e)})}))}})),(0,e.createElement)("div",{className:"ct-recurring-stop-time"},(0,e.createElement)("label",{className:"ct-label"},(0,i.__)("Stop Time","blocksy-companion")),(0,e.createElement)(t.TimePicker,{is12Hour:S,currentTime:k,onChange:function(e){o(C(C({},r),{},{payload:C(C({},r.payload),{},{time_end:wp.date.format("H:i",e)})}))}})))),document.body))};function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function N(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var D=function(t){var n=t.className,o=void 0===n?"":n,r=t.condition,a=t.onRemove,s=t.onChange;r=N(N({},r),{},{payload:N({},r.payload)});var u=y(r),p=u.allRules,m=u.allTaxonomies,f=u.allLanguages,h=u.allUsers,v=p.find((function(e){return e.key===r.rule})),b="post_ids"===r.rule||"page_ids"===r.rule||"product_ids"===r.rule||"custom_post_type_ids"===r.rule||"taxonomy_ids"===r.rule||"post_with_taxonomy_ids"===r.rule||"card_product_with_taxonomy_ids"===r.rule||"card_post_with_taxonomy_ids"===r.rule||"product_with_taxonomy_ids"===r.rule||"product_taxonomy_ids"===r.rule||"current_language"===r.rule||"user_post_author_id"===r.rule||"author"===r.rule||"start_end_date"===r.rule||"schedule_date"===r.rule||"request_referer"===r.rule||"request_cookie"===r.rule||"request_url"===r.rule||v&&v.sub_ids&&v.sub_ids.length>0;return(0,e.createElement)("div",{className:d()("ct-condition-group",o,{"ct-cols-3":b,"ct-cols-2":!b})},(0,e.createElement)(c.Select,{key:"first",option:{inputClassName:"ct-condition-type",selectInputStart:function(){return"include"===r.type?(0,e.createElement)("span",{className:"ct-include"},(0,e.createElement)("svg",{width:"8",height:"8",fill:"currentColor",viewBox:"0 0 20 20"},(0,e.createElement)("path",{d:"M20,11h-9v9H9v-9H0V9h9V0h2v9h9V11z"}))):"exclude"===r.type?(0,e.createElement)("span",{className:"ct-exclude"},(0,e.createElement)("svg",{width:"8",height:"8",fill:"currentColor",viewBox:"0 0 20 20"},(0,e.createElement)("path",{d:"M20,9v2H0V9H20z"}))):null},placeholder:(0,i.__)("Select variation","blocksy-companion"),choices:{include:(0,i.__)("Include","blocksy-companion"),exclude:(0,i.__)("Exclude","blocksy-companion")}},value:r.type,onChange:function(e){s(N(N({},r),{},{type:e}))}}),(0,e.createElement)(c.Select,{key:"second",option:{appendToBody:!0,placeholder:(0,i.__)("Select rule","blocksy-companion"),choices:p,search:!0},value:r.rule,onChange:function(e){var t=p.find((function(t){return t.key===e}));t.sub_ids&&t.sub_ids.length>0?s(N(N({},r),{},{rule:t.sub_ids[0].id})):s(N(N({},r),{},{rule:e}))}}),("post_ids"===r.rule||"custom_post_type_ids"===r.rule||"product_ids"===r.rule||"page_ids"===r.rule)&&(0,e.createElement)(g,{condition:r,onChange:function(e){s(N(N({},r),{},{payload:N(N({},r.payload),{},{post_id:e})}))}}),("taxonomy_ids"===r.rule||"post_with_taxonomy_ids"===r.rule||"card_post_with_taxonomy_ids"===r.rule)&&(0,e.createElement)(c.Select,{option:{appendToBody:!0,defaultToFirstItem:!1,placeholder:(0,i.__)("Select taxonomy","blocksy-companion"),choices:m.filter((function(e){return!Object.values((null==e?void 0:e.post_types)||[]).includes("product")})).map((function(e){return N({key:e.id,value:e.name},e.group?{group:e.group}:{})})),search:!0},value:(r.payload||{}).taxonomy_id||"",onChange:function(e){s(N(N({},r),{},{payload:N(N({},r.payload),{},{taxonomy_id:e})}))}}),("product_with_taxonomy_ids"===r.rule||"product_taxonomy_ids"===r.rule||"card_product_with_taxonomy_ids"===r.rule)&&(0,e.createElement)(c.Select,{option:{appendToBody:!0,defaultToFirstItem:!1,placeholder:(0,i.__)("Select taxonomy","blocksy-companion"),choices:m.filter((function(e){return((null==e?void 0:e.post_types)||[]).includes("product")})).map((function(e){return N({key:e.id,value:e.name},e.group?{group:e.group}:{})})),search:!0},value:(r.payload||{}).taxonomy_id||"",onChange:function(e){s(N(N({},r),{},{payload:N(N({},r.payload),{},{taxonomy_id:e})}))}}),"current_language"===r.rule&&(0,e.createElement)(c.Select,{option:{appendToBody:!0,defaultToFirstItem:!1,placeholder:(0,i.__)("Select language","blocksy-companion"),choices:f.map((function(e){return{key:e.id,value:e.name}})),search:!0},value:(r.payload||{}).language||"",onChange:function(e){s(N(N({},r),{},{payload:N(N({},r.payload),{},{language:e})}))}}),"user_post_author_id"===r.rule&&(0,e.createElement)(c.Select,{option:{appendToBody:!0,defaultToFirstItem:!1,placeholder:(0,i.__)("Select user","blocksy-companion"),choices:[{key:"current_user",value:(0,i.__)("Current user","blocksy-companion")}].concat(l(h.map((function(e){return{key:e.id,value:e.name}})))),search:!0},value:(r.payload||{}).user_id||"",onChange:function(e){s(N(N({},r),{},{payload:N(N({},r.payload),{},{user_id:e})}))}}),"author"===r.rule&&(0,e.createElement)(c.Select,{option:{appendToBody:!0,placeholder:(0,i.__)("Select user","blocksy-companion"),choices:[{key:"all_users",value:(0,i.__)("All authors","blocksy-companion")}].concat(l(h.map((function(e){return{key:e.id,value:e.name}})))),search:!0},value:(r.payload||{}).user_id||"all_users",onChange:function(e){s(N(N({},r),{},{payload:N(N({},r.payload),{},{user_id:e})}))}}),v&&v.sub_ids&&v.sub_ids.length>0&&(0,e.createElement)(c.Select,{option:{appendToBody:!0,placeholder:(0,i.__)("Select sub field","blocksy-companion"),choices:v.sub_ids.map((function(e){return{key:e.id,value:e.title}})),search:!0,inputClassName:"ct-dropdown-normal-width"},value:r.rule,onChange:function(e){s(N(N({},r),{},{rule:e}))}}),"start_end_date"===r.rule&&(0,e.createElement)(k,{condition:r,onChange:s}),"schedule_date"===r.rule&&(0,e.createElement)(S,{condition:r,onChange:s}),"request_referer"===r.rule&&(0,e.createElement)("div",{className:"ct-option-input"},(0,e.createElement)("input",{type:"text",placeholder:"website.com",value:r.payload.referer,onChange:function(e){s(N(N({},r),{},{payload:N(N({},r.payload),{},{referer:e.target.value})}))}}),(0,e.createElement)("span",{className:"ct-condition-info","data-tooltip-reveal":"top"},(0,e.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M12,2C6.477,2,2,6.477,2,12s4.477,10,10,10s10-4.477,10-10S17.523,2,12,2z M12,17L12,17c-0.552,0-1-0.448-1-1v-4 c0-0.552,0.448-1,1-1h0c0.552,0,1,0.448,1,1v4C13,16.552,12.552,17,12,17z M12.5,9h-1C11.224,9,11,8.776,11,8.5v-1 C11,7.224,11.224,7,11.5,7h1C12.776,7,13,7.224,13,7.5v1C13,8.776,12.776,9,12.5,9z"})),(0,e.createElement)("i",{className:"ct-tooltip"},(0,i.__)("Display based on referer domain","blocksy-companion")))),"request_cookie"===r.rule&&(0,e.createElement)("div",{className:"ct-option-input"},(0,e.createElement)("input",{type:"text",placeholder:"cookie_name",value:(r.payload||{}).cookie||"",onChange:function(e){s(N(N({},r),{},{payload:N(N({},r.payload),{},{cookie:e.target.value})}))}}),(0,e.createElement)("span",{className:"ct-condition-info","data-tooltip-reveal":"top"},(0,e.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M12,2C6.477,2,2,6.477,2,12s4.477,10,10,10s10-4.477,10-10S17.523,2,12,2z M12,17L12,17c-0.552,0-1-0.448-1-1v-4 c0-0.552,0.448-1,1-1h0c0.552,0,1,0.448,1,1v4C13,16.552,12.552,17,12,17z M12.5,9h-1C11.224,9,11,8.776,11,8.5v-1 C11,7.224,11.224,7,11.5,7h1C12.776,7,13,7.224,13,7.5v1C13,8.776,12.776,9,12.5,9z"})),(0,e.createElement)("i",{className:"ct-tooltip"},(0,i.__)("Display if cookie is present","blocksy-companion")))),"request_url"===r.rule&&(0,e.createElement)("div",{className:"ct-option-input"},(0,e.createElement)("input",{type:"text",placeholder:"example=campaignID",value:r.payload.url||"",onChange:function(e){s(N(N({},r),{},{payload:N(N({},r.payload),{},{url:e.target.value})}))}}),(0,e.createElement)("span",{className:"ct-condition-info","data-tooltip-reveal":"top"},(0,e.createElement)("svg",{width:"16",height:"16",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M12,2C6.477,2,2,6.477,2,12s4.477,10,10,10s10-4.477,10-10S17.523,2,12,2z M12,17L12,17c-0.552,0-1-0.448-1-1v-4 c0-0.552,0.448-1,1-1h0c0.552,0,1,0.448,1,1v4C13,16.552,12.552,17,12,17z M12.5,9h-1C11.224,9,11,8.776,11,8.5v-1 C11,7.224,11.224,7,11.5,7h1C12.776,7,13,7.224,13,7.5v1C13,8.776,12.776,9,12.5,9z"})),(0,e.createElement)("i",{className:"ct-tooltip"},(0,i.__)("Display if query string is present in URL","blocksy-companion")))),(0,e.createElement)("button",{type:"button",className:"ct-remove-condition-group",onClick:function(e){e.preventDefault(),a()}},(0,e.createElement)("svg",{width:"7px",height:"7px",fill:"currentColor",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"m12 14.7 9.3 9.3 2.7-2.7-9.3-9.3L24 2.7 21.3 0 12 9.3 2.7 0 0 2.7 9.3 12 0 21.3 2.7 24l9.3-9.3z"}))))};function T(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function L(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?T(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var A=function t(n){var o=n.conditionsListDescriptor,r=n.onChange,i=n.extractRulesIntoRoot,c=void 0===i?null:i,s=n.className,u=void 0===s?"":s,p=a((0,e.useState)(null),2),m=p[0],f=p[1],h=y(),v=h.rulesToUse,b=h.isAdvancedMode;if(0===o.conditions.length)return null;var _=o.conditions.map((function(n,a){var i=null,s="";return m!==a&&m-1!==a||(s="ct-hovered"),n.relation&&(i=(0,e.createElement)(t,{className:s,key:a,conditionsListDescriptor:n,extractRulesIntoRoot:function(e){var t=[].concat(l(n.conditions.slice(0,e-1)),l(n.conditions.slice(e+1)));r([].concat(l(o.conditions.slice(0,a)),l(n.conditions.slice(e-1,e+1)),l(t.length>0?[L(L({},n),{},{conditions:t})]:[]),l(o.conditions.slice(a+1))))},onChange:function(e){0===e.length?r([].concat(l(o.conditions.slice(0,a)),l(o.conditions.slice(a+1)))):r(o.conditions.map((function(t,n){return L({},n===a?L(L({},t),{},{conditions:e}):t)})))}})),n.relation||(i=(0,e.createElement)(D,{className:s,condition:n,onChange:function(e){r(o.conditions.map((function(t,n){return L({},n===a?e:t)})))},onAdd:function(){"OR"!==o.relation?r([].concat(l(o.conditions),[{type:"include",rule:v[0].rules[0].id,payload:{}}])):r(o.conditions.map((function(e,t){return L({},t===a?{relation:"AND",conditions:[e,{type:"include",rule:v[0].rules[0].id,payload:{}}]}:e)})))},onRemove:function(){r([].concat(l(o.conditions.slice(0,a)),l(o.conditions.slice(a+1))))}})),(0,e.createElement)(e.Fragment,{key:a},b&&a>0&&(0,e.createElement)("div",{className:d()("ct-condition-relation",{"ct-hovered":m===a})},(0,e.createElement)("ul",{onMouseEnter:function(){f(a)},onMouseLeave:function(){f(null)}},"AND"===o.relation&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("li",{onClick:function(){c&&(f(null),c(a))}},(0,e.createElement)("span",null,"OR")),(0,e.createElement)("li",{className:"active"},(0,e.createElement)("span",null,"AND"))),"OR"===o.relation&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("li",{className:"active"},(0,e.createElement)("span",null,"OR")),(0,e.createElement)("li",{onClick:function(){f(null),r([].concat(l(o.conditions.slice(0,a-1)),[{relation:"AND",conditions:o.conditions.slice(a-1,a+1).reduce((function(e,t){return[].concat(l(e),l(t.conditions?t.conditions:[t]))}),[])}],l(o.conditions.slice(a+1,o.conditions.length))))}},(0,e.createElement)("span",null,"AND"))))),i)}));return"OR"===o.relation&&1===o.conditions.length||!b?_:(0,e.createElement)("div",{className:d()("ct-relation-group",u),"data-relation":o.relation},_,"AND"===o.relation&&(0,e.createElement)("div",{className:"ct-condition-relation ct-add-and-relation"},(0,e.createElement)("span",{onClick:function(){r([].concat(l(o.conditions),[{type:"include",rule:v[0].rules[0].id,payload:{}}]))}},(0,e.createElement)("svg",{width:"8",height:"8",fill:"currentColor",viewBox:"0 0 20 20"},(0,e.createElement)("path",{d:"M20,11h-9v9H9v-9H0V9h9V0h2v9h9V11z"})))))};function z(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function R(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?z(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):z(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var M=(0,e.createContext)({allTaxonomies:[],allLanguages:[],allUsers:[],remoteConditions:[]}),F=[],I=[],B=[],U=[],H=function(t){var n=t.value,o=t.onChange,r=t.filter,s=void 0===r?"all":r,u=t.addConditionButtonLabel,d=a((0,e.useState)(F),2),p=d[0],m=d[1],f=a((0,e.useState)(I),2),y=f[0],h=f[1],v=a((0,e.useState)(B),2),b=v[0],_=v[1],g=a((0,e.useState)(U),2),E=g[0],w=g[1],O=a((0,e.useState)("__EMPTY__"),2),k=O[0],x=O[1];(0,e.useEffect)((function(){fetch("".concat(wp.ajax.settings.url,"?action=blc_retrieve_conditions_data&filter=").concat(s),{headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"}).then((function(e){return e.json()})).then((function(e){var t=e.data,n=t.taxonomies,o=t.languages,r=t.users,a=t.conditions;m(n),F=n,h(o),I=o,_(r),B=r,w(a),U=a}))}),[]);var j=Array.isArray(n)?{relation:"OR",conditions:n}:n,C="__EMPTY__"!==k&&k;return j.conditions.find((function(e){return e.relation}))&&(C=!0),(0,e.createElement)(M.Provider,{value:{allTaxonomies:p,allLanguages:y,allUsers:b,remoteConditions:E,isAdvancedMode:C}},(0,e.createElement)("div",{className:"ct-display-conditions"},(0,e.createElement)(A,{conditionsListDescriptor:j,onChange:function(e){o(R(R({},j),{},{conditions:e}))}}),(0,e.createElement)("div",{className:"ct-conditions-actions"},(0,e.createElement)("button",{type:"button",className:"button add-condition",onClick:function(e){e.preventDefault(),0!==E.length&&o(R(R({},j),{},{conditions:[].concat(l(j.conditions),[{type:"include",rule:E[0].rules[0].id,payload:{}}])}))}},u),(j.conditions.length>1||j.conditions.find((function(e){return e.relation})))&&(0,e.createElement)("span",null,(0,i.__)("Advanced Mode","blocksy-companion"),(0,e.createElement)(c.Switch,{value:C,onChange:function(e){j.conditions.find((function(e){return e.relation}))&&o(R(R({},j),{},{conditions:j.conditions.reduce((function(e,t){return[].concat(l(e),l(t.conditions?t.conditions:[t]))}),[])})),x(e)},option:{behavior:"boolean"}})))))},V=function(t){var n=t.option,o=n.display,r=void 0===o?"inline":o,l=n.filter,s=void 0===l?"all":l,u=n.modalTitle,d=void 0===u?(0,i.__)("Transparent Header Display Conditions","blocksy-companion"):u,p=n.modalDescription,m=void 0===p?(0,i.__)("Add one or more conditions to display the transparent header.","blocksy-companion"):p,f=n.addConditionButtonLabel,y=void 0===f?(0,i.__)("Add Display Condition","blocksy-companion"):f,h=t.value,v=t.onChange,b=a((0,e.useState)(!1),2),_=b[0],g=b[1],E=a((0,e.useState)(null),2),w=E[0],O=E[1];return"inline"===r?(0,e.createElement)(H,{filter:s,value:h,onChange:v,addConditionButtonLabel:y}):(0,e.createElement)(e.Fragment,null,(0,e.createElement)("button",{className:"button-primary",style:{width:"100%"},onClick:function(e){e.preventDefault(),g(!0),O(null)}},Object.keys(h).length>0?(0,i.__)("Edit Conditions","blocksy-companion"):(0,i.__)("Add Conditions","blocksy-companion")),(0,e.createElement)(c.Overlay,{items:_,className:"ct-admin-modal ct-builder-conditions-modal",onDismiss:function(){g(!1),O(null)},render:function(){return(0,e.createElement)("div",{className:"ct-modal-content"},(0,e.createElement)("h2",null,d),(0,e.createElement)("p",null,m),(0,e.createElement)("div",{className:"ct-modal-scroll"},(0,e.createElement)(H,{filter:s,value:w||h,onChange:function(e){O(e)},addConditionButtonLabel:y})),(0,e.createElement)("div",{className:"ct-modal-actions has-divider"},(0,e.createElement)("button",{className:"button-primary",disabled:!w,onClick:function(){v(w),g(!1)}},(0,i.__)("Save Conditions","blocksy-companion"))))}}))};function G(e){return G="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},G(e)}var q="object"===("undefined"==typeof window?"undefined":G(window))&&window.window===window?window:"object"===("undefined"==typeof self?"undefined":G(self))&&self.self===self?self:"object"===(void 0===n.g?"undefined":G(n.g))&&n.g.global===n.g?n.g:void 0;function Y(e,t,n){var o=new XMLHttpRequest;o.open("GET",e),o.responseType="blob",o.onload=function(){X(o.response,t,n)},o.onerror=function(){console.error("could not download file")},o.send()}function J(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return t.status>=200&&t.status<=299}function W(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var X="object"!==("undefined"==typeof window?"undefined":G(window))||window!==q?function(){}:"download"in HTMLAnchorElement.prototype?function(e,t,n){var o=q.URL||q.webkitURL,r=document.createElement("a");t=t||e.name||"download",r.download=t,r.rel="noopener","string"==typeof e?(r.href=e,r.origin!==location.origin?J(r.href)?Y(e,t,n):W(r,r.target="_blank"):W(r)):(r.href=o.createObjectURL(e),setTimeout((function(){o.revokeObjectURL(r.href)}),4e4),setTimeout((function(){W(r)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,t,n){if(t=t||e.name||"download","string"==typeof e)if(J(e))Y(e,t,n);else{var o=document.createElement("a");o.href=e,o.target="_blank",setTimeout((function(){W(o)}))}else navigator.msSaveOrOpenBlob(function(e,t){return void 0===t?t={autoBom:!1}:"object"!==G(t)&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e}(e,n),t)}:function(e,t,n,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return Y(e,t,n);var r="application/octet-stream"===e.type,a=/constructor/i.test(q.HTMLElement)||q.safari,i=/CriOS\/[\d]+/.test(navigator.userAgent);if((i||r&&a)&&"object"===("undefined"==typeof FileReader?"undefined":G(FileReader))){var c=new FileReader;c.onloadend=function(){var e=c.result;e=i?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},c.readAsDataURL(e)}else{var l=q.URL||q.webkitURL,s=l.createObjectURL(e);o?o.location=s:location.href=s,o=null,setTimeout((function(){l.revokeObjectURL(s)}),4e4)}},K=X,$=n(539),Q=n.n($),Z=function(){var t=a((0,e.useState)(null),2),n=t[0],o=t[1],r=a((0,e.useState)(null),2),s=r[0],u=r[1],p=a((0,e.useState)(!1),2),m=p[0],f=p[1],y=a((0,e.useState)(!1),2),h=y[0],v=y[1],b=a((0,e.useState)(!1),2),_=b[0],g=b[1],E=a((0,e.useState)(["options"]),2),w=E[0],O=E[1],k=(0,e.useRef)(),x=(0,e.useRef)();return(0,e.useEffect)((function(){var e=function(e){e.stopPropagation(),e.preventDefault(),e.dataTransfer.dropEffect="copy",f(!0)},t=function(e){e.stopPropagation(),e.preventDefault(),f(!1)},n=function(e){e.stopPropagation(),e.preventDefault(),f(!1);var t=Array.from(e.dataTransfer.files||[]);if(Array.from(e.dataTransfer.items||[]).length>0){var n=e.dataTransfer.items[0].getAsFile();o(n)}else t.length>0&&o(t[0])};return x.current.addEventListener("dragover",e,!1),x.current.addEventListener("dragleave",t,!1),x.current.addEventListener("drop",n,!1),function(){x.current&&(x.current.removeEventListener("dragover",e,!1),x.current.removeEventListener("dragleave",t,!1),x.current.removeEventListener("drop",n,!1))}}),[]),(0,e.createElement)("div",{className:"ct-import-export"},(0,e.createElement)("div",{className:"ct-title","data-type":"simple"},(0,e.createElement)("h3",null,(0,i.__)("Export Options","blocksy-companion")),(0,e.createElement)("div",{className:"ct-option-description"},(0,i.__)("Easily export the theme customizer settings.","blocksy-companion"))),(0,e.createElement)("div",{className:"ct-control","data-design":"block"},(0,e.createElement)("header",null),(0,e.createElement)("section",null,(0,e.createElement)("button",{className:"button-primary",onClick:function(e){e.preventDefault(),v(!0)}},(0,i.__)("Export Customizations","blocksy-companion")))),(0,e.createElement)("div",{className:"ct-title","data-type":"simple"},(0,e.createElement)("h3",null,(0,i.__)("Import Options","blocksy-companion")),(0,e.createElement)("div",{className:"ct-option-description"},(0,i.__)("Easily import the theme customizer settings.","blocksy-companion"))),(0,e.createElement)("div",{className:"ct-control","data-design":"block"},(0,e.createElement)("header",null),(0,e.createElement)("section",null,(0,e.createElement)("div",{className:"ct-file-upload"},(0,e.createElement)("div",{className:"ct-attachment"},(0,e.createElement)("button",{type:"button",className:d()("ct-upload-button",{active:m}),ref:x,onClick:function(){k.current.click()}},n?n.name:(0,i.__)("Click or drop to upload a file...","blocksy-companion"))),(0,e.createElement)("input",{ref:k,type:"file",onChange:function(e){var t=a(e.target.files,1)[0];o(t)}}),(0,e.createElement)("button",{className:d()("button-primary",{"ct-loading":_}),disabled:!n,onClick:function(e){if(e.preventDefault(),n){g(!0);var t=new FileReader;t.readAsText(n,"UTF-8"),t.onload=function(e){try{fetch("".concat(window.ajaxurl,"?action=blocksy_customizer_import&wp_customize=on&nonce=").concat(ct_customizer_localizations.customizer_reset_none),{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(Q()(e.target.result))}).then((function(e){200===e.status&&e.json().then((function(e){e.success,e.data;location.reload()}))}))}catch(e){}}}}},_?(0,e.createElement)("svg",{width:"14",height:"14",viewBox:"0 0 100 100"},(0,e.createElement)("g",{transform:"translate(50,50)"},(0,e.createElement)("g",{transform:"scale(1)"},(0,e.createElement)("circle",{cx:"0",cy:"0",r:"50",fill:"currentColor"}),(0,e.createElement)("circle",{cx:"0",cy:"-26",r:"12",fill:"var(--ui-accent-color)",transform:"rotate(161.634)"},(0,e.createElement)("animateTransform",{attributeName:"transform",type:"rotate",calcMode:"linear",values:"0 0 0;360 0 0",keyTimes:"0;1",dur:"1s",begin:"0s",repeatCount:"indefinite"}))))):(0,i.__)("Import Customizations","blocksy-companion"))))),ct_customizer_localizations.has_child_theme&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)("div",{className:"ct-title","data-type":"simple"},(0,e.createElement)("h3",null,(0,i.__)("Copy Options","blocksy-companion")),(0,e.createElement)("div",{className:"ct-option-description"},(0,i.__)("Copy and import your customizations from parent or child theme.","blocksy-companion"))),ct_customizer_localizations.is_parent_theme&&(0,e.createElement)("div",{className:"ct-control","data-design":"block"},(0,e.createElement)("header",null),(0,e.createElement)("section",null,(0,e.createElement)("button",{className:"button-primary",onClick:function(e){e.preventDefault(),u("child")}},(0,i.__)("Copy From Child Theme","blocksy-companion")))),!ct_customizer_localizations.is_parent_theme&&(0,e.createElement)("div",{className:"ct-control","data-design":"block"},(0,e.createElement)("header",null),(0,e.createElement)("section",null,(0,e.createElement)("button",{className:"button-primary",onClick:function(e){e.preventDefault(),u("parent")}},(0,i.__)("Copy From Parent Theme","blocksy-companion"))))),(0,e.createElement)(c.Overlay,{items:s,className:"ct-admin-modal ct-import-export-modal",onDismiss:function(){return u(!1)},render:function(){return(0,e.createElement)("div",{className:"ct-modal-content"},(0,e.createElement)("h2",{className:"ct-modal-title"},!ct_customizer_localizations.is_parent_theme&&(0,i.__)("Copy From Parent Theme","blocksy-companion"),ct_customizer_localizations.is_parent_theme&&(0,i.__)("Copy From Child Theme","blocksy-companion")),(0,e.createElement)("p",null,!ct_customizer_localizations.is_parent_theme&&(0,i.__)("You are about to copy all the settings from your parent theme into the child theme. Are you sure you want to continue?","blocksy-companion"),ct_customizer_localizations.is_parent_theme&&(0,i.__)("You are about to copy all the settings from your child theme into the parent theme. Are you sure you want to continue?","blocksy-companion")),(0,e.createElement)("div",{className:"ct-modal-actions has-divider","data-buttons":"2"},(0,e.createElement)("button",{onClick:function(e){e.preventDefault(),e.stopPropagation(),u(!1)},className:"button"},(0,i.__)("Cancel","blocksy-companion")),(0,e.createElement)("button",{className:"button button-primary",onClick:function(e){e.preventDefault();var t=new FormData;t.append("action","blocksy_customizer_copy_options"),t.append("wp_customize","on"),t.append("strategy",s);try{fetch(window.ajaxurl,{method:"POST",body:t}).then((function(e){200===e.status&&e.json().then((function(e){e.success,e.data;location.reload()}))}))}catch(e){}}},(0,i.__)("Yes, I am sure","blocksy-companion"))))}}),(0,e.createElement)(c.Overlay,{items:h,className:"ct-admin-modal ct-export-modal",onDismiss:function(){return v(!1)},render:function(){return(0,e.createElement)("div",{className:"ct-modal-content"},(0,e.createElement)("h2",{className:"ct-modal-title"},(0,i.__)("Export Settings","blocksy-companion")),(0,e.createElement)("p",null,(0,i.__)("Choose what set of settings you want to export.","blocksy-companion")),(0,e.createElement)("div",{className:"ct-checkboxes-container","data-type":"grid:bordered"},["options","widgets"].map((function(t){return(0,e.createElement)("div",{className:"ct-checkbox-container",onClick:function(){1===w.length&&w[0]===t||O((function(e){return e.includes(t)?e.filter((function(e){return e!==t})):[].concat(l(e),[t])}))}},(0,e.createElement)("span",{className:d()("ct-checkbox",{active:w.includes(t)})},(0,e.createElement)("svg",{width:"10",height:"8",viewBox:"0 0 11.2 9.1"},(0,e.createElement)("polyline",{className:"check",points:"1.2,4.8 4.4,7.9 9.9,1.2 "}))),{options:(0,i.__)("Customizer settings","blocksy-companion"),widgets:(0,i.__)("Widgets settings","blocksy-companion")}[t])}))),(0,e.createElement)("div",{className:"ct-modal-actions has-divider","data-buttons":"2"},(0,e.createElement)("button",{onClick:function(e){e.preventDefault(),e.stopPropagation(),v(!1)},className:"button"},(0,i.__)("Cancel","blocksy-companion")),(0,e.createElement)("button",{className:"button button-primary",onClick:function(e){e.preventDefault();var t=new FormData;t.append("action","blocksy_customizer_export"),t.append("strategy",w.join(":")),t.append("wp_customize","on");try{fetch(window.ajaxurl,{method:"POST",body:t}).then((function(e){200===e.status&&e.json().then((function(e){var t=e.success,n=e.data;if(t){var o=new Blob([n.data],{type:"application/octet-stream;charset=utf-8"});K(o,"".concat(n.site_url.replace("http://","").replace("https://","").replace(".","-").replace("/","-"),"-export.dat")),v(!1)}}))}))}catch(e){}}},(0,i.__)("Export","blocksy-companion"))))}}))},ee=window.ctEvents,te=n.n(ee),ne=window.wp.hooks;function oe(e,t,n,o,r,a,i){try{var c=e[a](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(o,r)}var re=n(687),ae=n.n(re),ie=n(459),ce=n.n(ie),le=n(616),se=n.n(le),ue=n(382),de=n.n(ue),pe=se()(),me=function(t){t.forcedEdit;var n,o,r=t.headerId,u=a((0,e.useState)(!1),2),d=u[0],p=u[1],m=a((0,e.useState)(null),2),f=m[0],y=m[1],h=(0,e.useContext)(c.PlacementsDragDropContext),v=(h.builderValueCollection,h.builderValueDispatch,(0,e.useRef)()),b=de()(pe),_=ce()("".concat(blocksy_admin.ajax_url,"?action=blocksy_header_get_all_conditions"),{method:"POST",formatter:(n=ae().mark((function e(t){var n,o,r;return ae().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.json();case 2:if(n=e.sent,o=n.success,r=n.data,o&&r.conditions){e.next=7;break}throw new Error;case 7:return e.abrupt("return",r.conditions);case 8:case"end":return e.stop()}}),e)})),o=function(){var e=this,t=arguments;return new Promise((function(o,r){var a=n.apply(e,t);function i(e){oe(a,o,r,i,c,"next",e)}function c(e){oe(a,o,r,i,c,"throw",e)}i(void 0)}))},function(e){return o.apply(this,arguments)}),depends:[b]}),g=_.data,E=_.isLoading;_.error;return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("button",{className:"button-primary",style:{width:"100%"},onClick:function(e){e.preventDefault(),e.stopPropagation(),E||p(!0)}},(0,i.__)("Add/Edit Conditions","blocksy-companion")),(0,e.createElement)(c.Overlay,{items:d,initialFocusRef:v,className:"ct-admin-modal ct-builder-conditions-modal",onDismiss:function(){p(!1),y(null)},render:function(){var t;return(0,e.createElement)("div",{className:"ct-modal-content",ref:v},(0,e.createElement)("h2",null,sprintf((0,i.__)("Display Conditions","blocksy-companion"))),(0,e.createElement)("p",null,(0,i.__)("Add one or more conditions in order to display your header.","blocksy-companion")),(0,e.createElement)("div",{className:"ct-modal-scroll"},(0,e.createElement)(c.OptionsPanel,{onChange:function(e,t){y((function(e){return[].concat(l((e||g).filter((function(e){return e.id!==r}))),[{id:r,conditions:t}])}))},options:{conditions:(t={type:"blocksy-display-condition",design:"none",value:[]},s(t,"design","none"),s(t,"label",!1),t)},value:{conditions:((f||g).find((function(e){return e.id===r}))||{conditions:[]}).conditions},hasRevertButton:!1})),(0,e.createElement)("div",{className:"ct-modal-actions has-divider"},(0,e.createElement)("button",{className:"button-primary",disabled:!f,onClick:function(){fetch("".concat(wp.ajax.settings.url,"?action=blocksy_header_update_all_conditions"),{headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST",body:JSON.stringify(f)}).then((function(e){return e.json()})).then((function(){pe(),p(!1)}))}},(0,i.__)("Save Conditions","blocksy-companion"))))}}))};function fe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function ye(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?fe(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var he=function(){var n=a((0,e.useState)(!1),2),o=n[0],r=n[1],l=(ct_customizer_localizations.header_builder_data.secondary_items.header,ct_customizer_localizations.header_builder_data.header,(0,e.useContext)(c.PlacementsDragDropContext)),s=l.builderValueDispatch,u=l.builderValue,p=(l.option,l.builderValueCollection),m=l.panelsActions,f=(0,ne.applyFilters)("blocksy.header.available-sections",null,p.sections)||p.sections.filter((function(e){var t=e.id;return"type-2"!==t&&"type-3"!==t&&-1===t.indexOf("ct-custom")}));return(0,e.createElement)(e.Fragment,null,(0,e.createElement)("ul",{className:d()("ct-panels-manager")},f.map((function(t){var n=t.name,o=t.id,a=n||{"type-1":(0,i.__)("Global Header","blocksy-companion")}[o]||o,l="builder_header_panel_".concat(o),p=ct_customizer_localizations.header_builder_data.header_data.header_options,f={label:a,"inner-options":ye(ye({},o.indexOf("ct-custom")>-1?{conditions_button:{label:(0,i.__)("Edit Conditions","blocksy-companion"),type:"jsx",design:"block",render:function(){return(0,e.createElement)(me,{headerId:o})}},divider:{type:"ct-divider"}}:{}),p)};return(0,e.createElement)(c.PanelMetaWrapper,E({id:l,key:o,option:f},m,{getActualOption:function(t){var n=t.open;return(0,e.createElement)(e.Fragment,null,o===u.id&&(0,e.createElement)(c.Panel,{id:l,getValues:function(){return ye({id:o},u.settings||{})},option:f,onChangeFor:function(e,t){s({type:"BUILDER_GLOBAL_SETTING_ON_CHANGE",payload:{optionId:e,optionValue:t,values:(0,c.getValueFromInput)(p,Array.isArray(u.settings)?{}:u.settings||{})}})},view:"simple"}),(0,e.createElement)("li",{className:d()({active:o===u.id,"ct-global":"type-1"===o}),onClick:function(){o===u.id?n():s({type:"PICK_BUILDER_SECTION",payload:{id:o}})}},(0,e.createElement)("span",{className:"ct-panel-name"},a),o.indexOf("ct-custom")>-1&&o!==u.id&&(0,e.createElement)("span",{className:"ct-remove-instance","data-tooltip-reveal":"top",onClick:function(e){e.preventDefault(),e.stopPropagation(),r(o)}},(0,e.createElement)("svg",{width:"11px",height:"11px",viewBox:"0 0 24 24"},(0,e.createElement)("path",{d:"M9.6,0l0,1.2H1.2v2.4h21.6V1.2h-8.4l0-1.2H9.6z M2.8,6l1.8,15.9C4.8,23.1,5.9,24,7.1,24h9.9c1.2,0,2.2-0.9,2.4-2.1L21.2,6H2.8z"})),(0,e.createElement)("i",{className:"ct-tooltip"},(0,i.__)("Remove header","blocksy-companion")))))}}))}))),(0,e.createElement)(t.Slot,{name:"PlacementsBuilderPanelsManagerAfter"},(function(e){return 0===e.length?null:e})),(0,e.createElement)(c.Overlay,{items:o,className:"ct-admin-modal ct-reset-options",onDismiss:function(){return r(!1)},render:function(){return(0,e.createElement)("div",{className:"ct-modal-content"},(0,e.createElement)("h2",{className:"ct-modal-title"},(0,i.__)("Remove Header","blocksy-companion")),(0,e.createElement)("p",null,(0,i.__)("You are about to remove a custom header, are you sure you want to continue?","blocksy-companion")),(0,e.createElement)("div",{className:"ct-modal-actions has-divider","data-buttons":"2"},(0,e.createElement)("button",{onClick:function(e){e.preventDefault(),e.stopPropagation(),r(!1)},className:"button"},(0,i.__)("Cancel","blocksy-companion")),(0,e.createElement)("button",{className:"button button-primary",onClick:function(e){e.preventDefault(),s({type:"REMOVE_BUILDER_SECTION",payload:{id:o}}),r(!1)}},(0,i.__)("Confirm","blocksy-companion"))))}}))};te().on("blocksy:options:before-option",(function(n){if(n.option&&"ct-header-builder"===n.option.type){var o=n.content;n.content=(0,e.createElement)(e.Fragment,null,o,(0,e.createElement)(t.Fill,{name:"PlacementsBuilderPanelsManager"},(0,e.createElement)(he,null)))}})),te().on("blocksy:options:register",(function(e){e["blocksy-display-condition"]=V,e["blocksy-customizer-options-manager"]=Z}))}()}();