diff --git a/.eslintrc.json b/.eslintrc.json
index 6752260..d0c9e98 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -6,7 +6,8 @@
"window": true,
"document": true,
"dlxPatternWranglerLicense": "readonly",
- "dlxPatternWranglerAdminUrl": "readonly"
+ "dlxPatternWranglerAdminUrl": "readonly",
+ "dlxPatternWranglerPreview": "readonly"
},
"env": {
"browser": true,
diff --git a/build/dlx-pw-preview.asset.php b/build/dlx-pw-preview.asset.php
new file mode 100644
index 0000000..6a92f8a
--- /dev/null
+++ b/build/dlx-pw-preview.asset.php
@@ -0,0 +1 @@
+ array('react', 'wp-i18n', 'wp-plugins'), 'version' => '16a2bbd70a4a05074098');
diff --git a/build/dlx-pw-preview.js b/build/dlx-pw-preview.js
new file mode 100644
index 0000000..578872c
--- /dev/null
+++ b/build/dlx-pw-preview.js
@@ -0,0 +1,178 @@
+/******/ (() => { // webpackBootstrap
+/******/ "use strict";
+/******/ var __webpack_modules__ = ({
+
+/***/ "react":
+/*!************************!*\
+ !*** external "React" ***!
+ \************************/
+/***/ ((module) => {
+
+module.exports = window["React"];
+
+/***/ }),
+
+/***/ "@wordpress/i18n":
+/*!******************************!*\
+ !*** external ["wp","i18n"] ***!
+ \******************************/
+/***/ ((module) => {
+
+module.exports = window["wp"]["i18n"];
+
+/***/ }),
+
+/***/ "@wordpress/plugins":
+/*!*********************************!*\
+ !*** external ["wp","plugins"] ***!
+ \*********************************/
+/***/ ((module) => {
+
+module.exports = window["wp"]["plugins"];
+
+/***/ })
+
+/******/ });
+/************************************************************************/
+/******/ // The module cache
+/******/ var __webpack_module_cache__ = {};
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/ // Check if module is in cache
+/******/ var cachedModule = __webpack_module_cache__[moduleId];
+/******/ if (cachedModule !== undefined) {
+/******/ return cachedModule.exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = __webpack_module_cache__[moduleId] = {
+/******/ // no module.id needed
+/******/ // no module.loaded needed
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/************************************************************************/
+/******/ /* webpack/runtime/compat get default export */
+/******/ (() => {
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = (module) => {
+/******/ var getter = module && module.__esModule ?
+/******/ () => (module['default']) :
+/******/ () => (module);
+/******/ __webpack_require__.d(getter, { a: getter });
+/******/ return getter;
+/******/ };
+/******/ })();
+/******/
+/******/ /* webpack/runtime/define property getters */
+/******/ (() => {
+/******/ // define getter functions for harmony exports
+/******/ __webpack_require__.d = (exports, definition) => {
+/******/ for(var key in definition) {
+/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
+/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
+/******/ }
+/******/ }
+/******/ };
+/******/ })();
+/******/
+/******/ /* webpack/runtime/hasOwnProperty shorthand */
+/******/ (() => {
+/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
+/******/ })();
+/******/
+/******/ /* webpack/runtime/make namespace object */
+/******/ (() => {
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = (exports) => {
+/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
+/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
+/******/ }
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/ })();
+/******/
+/************************************************************************/
+var __webpack_exports__ = {};
+// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
+(() => {
+/*!**************************************************!*\
+ !*** ./src/js/blocks/plugins/pattern-preview.js ***!
+ \**************************************************/
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
+/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
+/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
+/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__);
+/* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/plugins */ "@wordpress/plugins");
+/* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_plugins__WEBPACK_IMPORTED_MODULE_2__);
+
+
+
+
+/**
+ * Render a Preview Button.
+ *
+ * @return {Object} The rendered component.
+ */
+var PatternPreviewButton = function PatternPreviewButton() {
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
+ var headerToolbar = document.querySelector('.edit-post-header');
+ if (null === headerToolbar) {
+ return;
+ }
+
+ // Get the left toolbar and add to it.
+ var settingsToolbar = headerToolbar.querySelector('.edit-post-header__settings');
+ if (null === settingsToolbar) {
+ return;
+ }
+
+ // Create the button.
+ var button = document.createElement('a');
+ button.className = 'dlx-button-preview components-button has-icon';
+ button.ariaLabel = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Preview', 'futuris-demo-importer');
+ button.href = dlxPatternWranglerPreview.previewUrl;
+ button.target = '_blank';
+ button.rel = 'noopener noreferrer';
+
+ // Add icon.
+ var icon = document.createElement('svg');
+ icon.className = 'dlx-pattern-wrangler-preview-icon';
+ icon.innerHTML = '';
+ button.prepend(icon);
+ // Add the button to the toolbar as the first child.
+ settingsToolbar.prepend(button);
+ }, []);
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("svg", {
+ height: "0",
+ width: "0",
+ xmlns: "http://www.w3.org/2000/svg",
+ style: {
+ display: 'none'
+ },
+ "aria-hidden": "true"
+ }, /*#__PURE__*/React.createElement("symbol", {
+ id: "dlx-pattern-wrangler-preview-icon",
+ width: "16",
+ height: "16",
+ viewBox: "0 0 512 512"
+ }, /*#__PURE__*/React.createElement("path", {
+ fill: "currentColor",
+ d: "M304 24c0 13.3 10.7 24 24 24h102.1L207 271c-9.4 9.4-9.4 24.6 0 33.9s24.6 9.4 33.9 0l223-223V184c0 13.3 10.7 24 24 24s24-10.7 24-24V24c0-13.3-10.7-24-24-24H328c-13.3 0-24 10.7-24 24zM72 32C32.2 32 0 64.2 0 104v336c0 39.8 32.2 72 72 72h336c39.8 0 72-32.2 72-72V312c0-13.3-10.7-24-24-24s-24 10.7-24 24v128c0 13.3-10.7 24-24 24H72c-13.3 0-24-10.7-24-24V104c0-13.3 10.7-24 24-24h128c13.3 0 24-10.7 24-24s-10.7-24-24-24H72z"
+ }))));
+};
+(0,_wordpress_plugins__WEBPACK_IMPORTED_MODULE_2__.registerPlugin)('dlx-pattern-wrangler-preview-button', {
+ render: PatternPreviewButton
+});
+})();
+
+/******/ })()
+;
\ No newline at end of file
diff --git a/build/index.asset.php b/build/index.asset.php
index 423146e..f1fb6d7 100644
--- a/build/index.asset.php
+++ b/build/index.asset.php
@@ -1 +1 @@
- array('react', 'wp-block-editor', 'wp-blocks', 'wp-commands', 'wp-components', 'wp-compose', 'wp-data', 'wp-edit-post', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives'), 'version' => '26478b4efd64b0e748b5');
+ array('react', 'wp-i18n', 'wp-plugins'), 'version' => 'c12991944f7fcbcff0d1');
diff --git a/build/index.js b/build/index.js
index 56dfb5f..a41b4ed 100644
--- a/build/index.js
+++ b/build/index.js
@@ -1,2 +1,190 @@
-(()=>{var e={924:(e,t,r)=>{"use strict";var n=r(210),o=r(559),i=o(n("String.prototype.indexOf"));e.exports=function(e,t){var r=n(e,!!t);return"function"==typeof r&&i(e,".prototype.")>-1?o(r):r}},559:(e,t,r)=>{"use strict";var n=r(612),o=r(210),i=r(771),a=o("%TypeError%"),c=o("%Function.prototype.apply%"),s=o("%Function.prototype.call%"),l=o("%Reflect.apply%",!0)||n.call(s,c),u=o("%Object.defineProperty%",!0),f=o("%Math.max%");if(u)try{u({},"a",{value:1})}catch(e){u=null}e.exports=function(e){if("function"!=typeof e)throw new a("a function is required");var t=l(n,s,arguments);return i(t,1+f(0,e.length-(arguments.length-1)),!0)};var p=function(){return l(n,c,arguments)};u?u(e.exports,"apply",{value:p}):e.exports.apply=p},296:(e,t,r)=>{"use strict";var n=r(44)(),o=r(210),i=n&&o("%Object.defineProperty%",!0);if(i)try{i({},"a",{value:1})}catch(e){i=!1}var a=o("%SyntaxError%"),c=o("%TypeError%"),s=r(275);e.exports=function(e,t,r){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new c("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new c("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new c("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new c("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new c("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new c("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,u=arguments.length>6&&arguments[6],f=!!s&&s(e,t);if(i)i(e,t,{configurable:null===l&&f?f.configurable:!l,enumerable:null===n&&f?f.enumerable:!n,value:r,writable:null===o&&f?f.writable:!o});else{if(!u&&(n||o||l))throw new a("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=r}}},648:e=>{"use strict";var t=Object.prototype.toString,r=Math.max,n=function(e,t){for(var r=[],n=0;n{"use strict";var n=r(648);e.exports=Function.prototype.bind||n},210:(e,t,r)=>{"use strict";var n,o=SyntaxError,i=Function,a=TypeError,c=function(e){try{return i('"use strict"; return ('+e+").constructor;")()}catch(e){}},s=Object.getOwnPropertyDescriptor;if(s)try{s({},"")}catch(e){s=null}var l=function(){throw new a},u=s?function(){try{return l}catch(e){try{return s(arguments,"callee").get}catch(e){return l}}}():l,f=r(405)(),p=r(185)(),y=Object.getPrototypeOf||(p?function(e){return e.__proto__}:null),d={},h="undefined"!=typeof Uint8Array&&y?y(Uint8Array):n,m={"%AggregateError%":"undefined"==typeof AggregateError?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"%ArrayIteratorPrototype%":f&&y?y([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":d,"%AsyncGenerator%":d,"%AsyncGeneratorFunction%":d,"%AsyncIteratorPrototype%":d,"%Atomics%":"undefined"==typeof Atomics?n:Atomics,"%BigInt%":"undefined"==typeof BigInt?n:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?n:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?n:FinalizationRegistry,"%Function%":i,"%GeneratorFunction%":d,"%Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":f&&y?y(y([][Symbol.iterator]())):n,"%JSON%":"object"==typeof JSON?JSON:n,"%Map%":"undefined"==typeof Map?n:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&f&&y?y((new Map)[Symbol.iterator]()):n,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?n:Promise,"%Proxy%":"undefined"==typeof Proxy?n:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?n:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?n:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&f&&y?y((new Set)[Symbol.iterator]()):n,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":f&&y?y(""[Symbol.iterator]()):n,"%Symbol%":f?Symbol:n,"%SyntaxError%":o,"%ThrowTypeError%":u,"%TypedArray%":h,"%TypeError%":a,"%Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?n:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?n:WeakSet};if(y)try{null.error}catch(e){var g=y(y(e));m["%Error.prototype%"]=g}var b=function e(t){var r;if("%AsyncFunction%"===t)r=c("async function () {}");else if("%GeneratorFunction%"===t)r=c("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=c("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var o=e("%AsyncGenerator%");o&&y&&(r=y(o.prototype))}return m[t]=r,r},v={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},w=r(612),S=r(824),O=w.call(Function.call,Array.prototype.concat),E=w.call(Function.apply,Array.prototype.splice),A=w.call(Function.call,String.prototype.replace),j=w.call(Function.call,String.prototype.slice),x=w.call(Function.call,RegExp.prototype.exec),P=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,k=/\\(\\)?/g,R=function(e,t){var r,n=e;if(S(v,n)&&(n="%"+(r=v[n])[0]+"%"),S(m,n)){var i=m[n];if(i===d&&(i=b(n)),void 0===i&&!t)throw new a("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new o("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new a("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new a('"allowMissing" argument must be a boolean');if(null===x(/^%?[^%]*%?$/,e))throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(e){var t=j(e,0,1),r=j(e,-1);if("%"===t&&"%"!==r)throw new o("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new o("invalid intrinsic syntax, expected opening `%`");var n=[];return A(e,P,(function(e,t,r,o){n[n.length]=r?A(o,k,"$1"):t||e})),n}(e),n=r.length>0?r[0]:"",i=R("%"+n+"%",t),c=i.name,l=i.value,u=!1,f=i.alias;f&&(n=f[0],E(r,O([0,1],f)));for(var p=1,y=!0;p=r.length){var b=s(l,d);l=(y=!!b)&&"get"in b&&!("originalValue"in b.get)?b.get:l[d]}else y=S(l,d),l=l[d];y&&!u&&(m[c]=l)}}return l}},275:(e,t,r)=>{"use strict";var n=r(210)("%Object.getOwnPropertyDescriptor%",!0);if(n)try{n([],"length")}catch(e){n=null}e.exports=n},44:(e,t,r)=>{"use strict";var n=r(210)("%Object.defineProperty%",!0),o=function(){if(n)try{return n({},"a",{value:1}),!0}catch(e){return!1}return!1};o.hasArrayLengthDefineBug=function(){if(!o())return null;try{return 1!==n([],"length",{value:1}).length}catch(e){return!0}},e.exports=o},185:e=>{"use strict";var t={foo:{}},r=Object;e.exports=function(){return{__proto__:t}.foo===t.foo&&!({__proto__:null}instanceof r)}},405:(e,t,r)=>{"use strict";var n="undefined"!=typeof Symbol&&Symbol,o=r(419);e.exports=function(){return"function"==typeof n&&"function"==typeof Symbol&&"symbol"==typeof n("foo")&&"symbol"==typeof Symbol("bar")&&o()}},419:e=>{"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},824:(e,t,r)=>{"use strict";var n=Function.prototype.call,o=Object.prototype.hasOwnProperty,i=r(612);e.exports=i.call(n,o)},461:(e,t,r)=>{var n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g,o="object"==typeof self&&self&&self.Object===Object&&self,i=n||o||Function("return this")(),a=Object.prototype,c=0,s=a.toString,l=i.Symbol,u=l?l.prototype:void 0,f=u?u.toString:void 0;e.exports=function(e){var t,r=++c;return(null==(t=e)?"":function(e){if("string"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==s.call(e)}(e))return f?f.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(t))+r}},631:(e,t,r)=>{var n="function"==typeof Map&&Map.prototype,o=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,i=n&&o&&"function"==typeof o.get?o.get:null,a=n&&Map.prototype.forEach,c="function"==typeof Set&&Set.prototype,s=Object.getOwnPropertyDescriptor&&c?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,l=c&&s&&"function"==typeof s.get?s.get:null,u=c&&Set.prototype.forEach,f="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,p="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,y="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,d=Boolean.prototype.valueOf,h=Object.prototype.toString,m=Function.prototype.toString,g=String.prototype.match,b=String.prototype.slice,v=String.prototype.replace,w=String.prototype.toUpperCase,S=String.prototype.toLowerCase,O=RegExp.prototype.test,E=Array.prototype.concat,A=Array.prototype.join,j=Array.prototype.slice,x=Math.floor,P="function"==typeof BigInt?BigInt.prototype.valueOf:null,k=Object.getOwnPropertySymbols,R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,T="function"==typeof Symbol&&"object"==typeof Symbol.iterator,N="function"==typeof Symbol&&Symbol.toStringTag&&(Symbol.toStringTag,1)?Symbol.toStringTag:null,_=Object.prototype.propertyIsEnumerable,B=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function F(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||O.call(/e/,t))return t;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var n=e<0?-x(-e):x(e);if(n!==e){var o=String(n),i=b.call(t,o.length+1);return v.call(o,r,"$&_")+"."+v.call(v.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return v.call(t,r,"$&_")}var C=r(654),I=C.custom,L=q(I)?I:null;function U(e,t,r){var n="double"===(r.quoteStyle||t)?'"':"'";return n+e+n}function M(e){return v.call(String(e),/"/g,""")}function D(e){return!("[object Array]"!==G(e)||N&&"object"==typeof e&&N in e)}function z(e){return!("[object RegExp]"!==G(e)||N&&"object"==typeof e&&N in e)}function q(e){if(T)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!R)return!1;try{return R.call(e),!0}catch(e){}return!1}e.exports=function e(t,n,o,c){var s=n||{};if(W(s,"quoteStyle")&&"single"!==s.quoteStyle&&"double"!==s.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(W(s,"maxStringLength")&&("number"==typeof s.maxStringLength?s.maxStringLength<0&&s.maxStringLength!==1/0:null!==s.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var h=!W(s,"customInspect")||s.customInspect;if("boolean"!=typeof h&&"symbol"!==h)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(W(s,"indent")&&null!==s.indent&&"\t"!==s.indent&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(W(s,"numericSeparator")&&"boolean"!=typeof s.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var w=s.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return J(t,s);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var O=String(t);return w?F(t,O):O}if("bigint"==typeof t){var x=String(t)+"n";return w?F(t,x):x}var k=void 0===s.depth?5:s.depth;if(void 0===o&&(o=0),o>=k&&k>0&&"object"==typeof t)return D(t)?"[Array]":"[Object]";var I,H=function(e,t){var r;if("\t"===e.indent)r="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;r=A.call(Array(e.indent+1)," ")}return{base:r,prev:A.call(Array(t+1),r)}}(s,o);if(void 0===c)c=[];else if(V(c,t)>=0)return"[Circular]";function $(t,r,n){if(r&&(c=j.call(c)).push(r),n){var i={depth:s.depth};return W(s,"quoteStyle")&&(i.quoteStyle=s.quoteStyle),e(t,i,o+1,c)}return e(t,s,o+1,c)}if("function"==typeof t&&!z(t)){var ee=function(e){if(e.name)return e.name;var t=g.call(m.call(e),/^function\s*([\w$]+)/);return t?t[1]:null}(t),te=Y(t,$);return"[Function"+(ee?": "+ee:" (anonymous)")+"]"+(te.length>0?" { "+A.call(te,", ")+" }":"")}if(q(t)){var re=T?v.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):R.call(t);return"object"!=typeof t||T?re:K(re)}if((I=t)&&"object"==typeof I&&("undefined"!=typeof HTMLElement&&I instanceof HTMLElement||"string"==typeof I.nodeName&&"function"==typeof I.getAttribute)){for(var ne="<"+S.call(String(t.nodeName)),oe=t.attributes||[],ie=0;ie",t.childNodes&&t.childNodes.length&&(ne+="..."),ne+""+S.call(String(t.nodeName))+">"}if(D(t)){if(0===t.length)return"[]";var ae=Y(t,$);return H&&!function(e){for(var t=0;t=0)return!1;return!0}(ae)?"["+Z(ae,H)+"]":"[ "+A.call(ae,", ")+" ]"}if(function(e){return!("[object Error]"!==G(e)||N&&"object"==typeof e&&N in e)}(t)){var ce=Y(t,$);return"cause"in Error.prototype||!("cause"in t)||_.call(t,"cause")?0===ce.length?"["+String(t)+"]":"{ ["+String(t)+"] "+A.call(ce,", ")+" }":"{ ["+String(t)+"] "+A.call(E.call("[cause]: "+$(t.cause),ce),", ")+" }"}if("object"==typeof t&&h){if(L&&"function"==typeof t[L]&&C)return C(t,{depth:k-o});if("symbol"!==h&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!i||!e||"object"!=typeof e)return!1;try{i.call(e);try{l.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var se=[];return a&&a.call(t,(function(e,r){se.push($(r,t,!0)+" => "+$(e,t))})),X("Map",i.call(t),se,H)}if(function(e){if(!l||!e||"object"!=typeof e)return!1;try{l.call(e);try{i.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var le=[];return u&&u.call(t,(function(e){le.push($(e,t))})),X("Set",l.call(t),le,H)}if(function(e){if(!f||!e||"object"!=typeof e)return!1;try{f.call(e,f);try{p.call(e,p)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return Q("WeakMap");if(function(e){if(!p||!e||"object"!=typeof e)return!1;try{p.call(e,p);try{f.call(e,f)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return Q("WeakSet");if(function(e){if(!y||!e||"object"!=typeof e)return!1;try{return y.call(e),!0}catch(e){}return!1}(t))return Q("WeakRef");if(function(e){return!("[object Number]"!==G(e)||N&&"object"==typeof e&&N in e)}(t))return K($(Number(t)));if(function(e){if(!e||"object"!=typeof e||!P)return!1;try{return P.call(e),!0}catch(e){}return!1}(t))return K($(P.call(t)));if(function(e){return!("[object Boolean]"!==G(e)||N&&"object"==typeof e&&N in e)}(t))return K(d.call(t));if(function(e){return!("[object String]"!==G(e)||N&&"object"==typeof e&&N in e)}(t))return K($(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if(t===r.g)return"{ [object globalThis] }";if(!function(e){return!("[object Date]"!==G(e)||N&&"object"==typeof e&&N in e)}(t)&&!z(t)){var ue=Y(t,$),fe=B?B(t)===Object.prototype:t instanceof Object||t.constructor===Object,pe=t instanceof Object?"":"null prototype",ye=!fe&&N&&Object(t)===t&&N in t?b.call(G(t),8,-1):pe?"Object":"",de=(fe||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(ye||pe?"["+A.call(E.call([],ye||[],pe||[]),": ")+"] ":"");return 0===ue.length?de+"{}":H?de+"{"+Z(ue,H)+"}":de+"{ "+A.call(ue,", ")+" }"}return String(t)};var H=Object.prototype.hasOwnProperty||function(e){return e in this};function W(e,t){return H.call(e,t)}function G(e){return h.call(e)}function V(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,n=e.length;rt.maxStringLength){var r=e.length-t.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return J(b.call(e,0,t.maxStringLength),t)+n}return U(v.call(v.call(e,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,$),"single",t)}function $(e){var t=e.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return r?"\\"+r:"\\x"+(t<16?"0":"")+w.call(t.toString(16))}function K(e){return"Object("+e+")"}function Q(e){return e+" { ? }"}function X(e,t,r,n){return e+" ("+t+") {"+(n?Z(r,n):A.call(r,", "))+"}"}function Z(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+A.call(e,","+r)+"\n"+t.prev}function Y(e,t){var r=D(e),n=[];if(r){n.length=e.length;for(var o=0;o{"use strict";var t=String.prototype.replace,r=/%20/g,n="RFC3986";e.exports={default:n,formatters:{RFC1738:function(e){return t.call(e,r,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:n}},129:(e,t,r)=>{"use strict";var n=r(261),o=r(235),i=r(798);e.exports={formats:i,parse:o,stringify:n}},235:(e,t,r)=>{"use strict";var n=r(769),o=Object.prototype.hasOwnProperty,i=Array.isArray,a={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:n.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},c=function(e){return e.replace(/(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},s=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},l=function(e,t,r,n){if(e){var i=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,a=/(\[[^[\]]*])/g,c=r.depth>0&&/(\[[^[\]]*])/.exec(i),l=c?i.slice(0,c.index):i,u=[];if(l){if(!r.plainObjects&&o.call(Object.prototype,l)&&!r.allowPrototypes)return;u.push(l)}for(var f=0;r.depth>0&&null!==(c=a.exec(i))&&f=0;--i){var a,c=e[i];if("[]"===c&&r.parseArrays)a=[].concat(o);else{a=r.plainObjects?Object.create(null):{};var l="["===c.charAt(0)&&"]"===c.charAt(c.length-1)?c.slice(1,-1):c,u=parseInt(l,10);r.parseArrays||""!==l?!isNaN(u)&&c!==l&&String(u)===l&&u>=0&&r.parseArrays&&u<=r.arrayLimit?(a=[])[u]=o:"__proto__"!==l&&(a[l]=o):a={0:o}}o=a}return o}(u,t,r,n)}};e.exports=function(e,t){var r=function(e){if(!e)return a;if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=void 0===e.charset?a.charset:e.charset;return{allowDots:void 0===e.allowDots?a.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:a.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:a.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:a.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:a.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:a.comma,decoder:"function"==typeof e.decoder?e.decoder:a.decoder,delimiter:"string"==typeof e.delimiter||n.isRegExp(e.delimiter)?e.delimiter:a.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:a.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:a.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:a.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:a.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:a.strictNullHandling}}(t);if(""===e||null==e)return r.plainObjects?Object.create(null):{};for(var u="string"==typeof e?function(e,t){var r,l={__proto__:null},u=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,f=t.parameterLimit===1/0?void 0:t.parameterLimit,p=u.split(t.delimiter,f),y=-1,d=t.charset;if(t.charsetSentinel)for(r=0;r-1&&(m=i(m)?[m]:m),o.call(l,h)?l[h]=n.combine(l[h],m):l[h]=m}return l}(e,r):e,f=r.plainObjects?Object.create(null):{},p=Object.keys(u),y=0;y{"use strict";var n=r(478),o=r(769),i=r(798),a=Object.prototype.hasOwnProperty,c={brackets:function(e){return e+"[]"},comma:"comma",indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},s=Array.isArray,l=Array.prototype.push,u=function(e,t){l.apply(e,s(t)?t:[t])},f=Date.prototype.toISOString,p=i.default,y={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:o.encode,encodeValuesOnly:!1,format:p,formatter:i.formatters[p],indices:!1,serializeDate:function(e){return f.call(e)},skipNulls:!1,strictNullHandling:!1},d={},h=function e(t,r,i,a,c,l,f,p,h,m,g,b,v,w,S,O){for(var E,A=t,j=O,x=0,P=!1;void 0!==(j=j.get(d))&&!P;){var k=j.get(t);if(x+=1,void 0!==k){if(k===x)throw new RangeError("Cyclic object value");P=!0}void 0===j.get(d)&&(x=0)}if("function"==typeof p?A=p(r,A):A instanceof Date?A=g(A):"comma"===i&&s(A)&&(A=o.maybeMap(A,(function(e){return e instanceof Date?g(e):e}))),null===A){if(c)return f&&!w?f(r,y.encoder,S,"key",b):r;A=""}if("string"==typeof(E=A)||"number"==typeof E||"boolean"==typeof E||"symbol"==typeof E||"bigint"==typeof E||o.isBuffer(A))return f?[v(w?r:f(r,y.encoder,S,"key",b))+"="+v(f(A,y.encoder,S,"value",b))]:[v(r)+"="+v(String(A))];var R,T=[];if(void 0===A)return T;if("comma"===i&&s(A))w&&f&&(A=o.maybeMap(A,f)),R=[{value:A.length>0?A.join(",")||null:void 0}];else if(s(p))R=p;else{var N=Object.keys(A);R=h?N.sort(h):N}for(var _=a&&s(A)&&1===A.length?r+"[]":r,B=0;B0?S+w:""}},769:(e,t,r)=>{"use strict";var n=r(798),o=Object.prototype.hasOwnProperty,i=Array.isArray,a=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),c=function(e,t){for(var r=t&&t.plainObjects?Object.create(null):{},n=0;n1;){var t=e.pop(),r=t.obj[t.prop];if(i(r)){for(var n=[],o=0;o=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||i===n.RFC1738&&(40===u||41===u)?s+=c.charAt(l):u<128?s+=a[u]:u<2048?s+=a[192|u>>6]+a[128|63&u]:u<55296||u>=57344?s+=a[224|u>>12]+a[128|u>>6&63]+a[128|63&u]:(l+=1,u=65536+((1023&u)<<10|1023&c.charCodeAt(l)),s+=a[240|u>>18]+a[128|u>>12&63]+a[128|u>>6&63]+a[128|63&u])}return s},isBuffer:function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(i(e)){for(var r=[],n=0;n{"use strict";var n=r(210),o=r(296),i=r(44)(),a=r(275),c=n("%TypeError%"),s=n("%Math.floor%");e.exports=function(e,t){if("function"!=typeof e)throw new c("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||s(t)!==t)throw new c("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],n=!0,l=!0;if("length"in e&&a){var u=a(e,"length");u&&!u.configurable&&(n=!1),u&&!u.writable&&(l=!1)}return(n||l||!r)&&(i?o(e,"length",t,!0,!0):o(e,"length",t)),e}},478:(e,t,r)=>{"use strict";var n=r(210),o=r(924),i=r(631),a=n("%TypeError%"),c=n("%WeakMap%",!0),s=n("%Map%",!0),l=o("WeakMap.prototype.get",!0),u=o("WeakMap.prototype.set",!0),f=o("WeakMap.prototype.has",!0),p=o("Map.prototype.get",!0),y=o("Map.prototype.set",!0),d=o("Map.prototype.has",!0),h=function(e,t){for(var r,n=e;null!==(r=n.next);n=r)if(r.key===t)return n.next=r.next,r.next=e.next,e.next=r,r};e.exports=function(){var e,t,r,n={assert:function(e){if(!n.has(e))throw new a("Side channel does not contain "+i(e))},get:function(n){if(c&&n&&("object"==typeof n||"function"==typeof n)){if(e)return l(e,n)}else if(s){if(t)return p(t,n)}else if(r)return function(e,t){var r=h(e,t);return r&&r.value}(r,n)},has:function(n){if(c&&n&&("object"==typeof n||"function"==typeof n)){if(e)return f(e,n)}else if(s){if(t)return d(t,n)}else if(r)return function(e,t){return!!h(e,t)}(r,n);return!1},set:function(n,o){c&&n&&("object"==typeof n||"function"==typeof n)?(e||(e=new c),u(e,n,o)):s?(t||(t=new s),y(t,n,o)):(r||(r={key:{},next:null}),function(e,t,r){var n=h(e,t);n?n.value=r:e.next={key:t,next:e.next,value:r}}(r,n,o))}};return n}},654:()=>{},967:(e,t)=>{var r;!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e="",t=0;t{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{"use strict";var e={};r.r(e),r.d(e,{hasBrowserEnv:()=>pe,hasStandardBrowserEnv:()=>ye,hasStandardBrowserWebWorkerEnv:()=>he});const t=window.React,n=window.wp.blocks,o=window.wp.hooks,i=window.wp.editPost,a=window.wp.data,c=window.wp.plugins;var s=r(461),l=r.n(s);r(967);const u=window.wp.i18n,f=window.wp.components,p=window.wp.blockEditor;function y(e,t){return function(){return e.apply(t,arguments)}}window.wp.compose;const{toString:d}=Object.prototype,{getPrototypeOf:h}=Object,m=(g=Object.create(null),e=>{const t=d.call(e);return g[t]||(g[t]=t.slice(8,-1).toLowerCase())});var g;const b=e=>(e=e.toLowerCase(),t=>m(t)===e),v=e=>t=>typeof t===e,{isArray:w}=Array,S=v("undefined"),O=b("ArrayBuffer"),E=v("string"),A=v("function"),j=v("number"),x=e=>null!==e&&"object"==typeof e,P=e=>{if("object"!==m(e))return!1;const t=h(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},k=b("Date"),R=b("File"),T=b("Blob"),N=b("FileList"),_=b("URLSearchParams");function B(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,o;if("object"!=typeof e&&(e=[e]),w(e))for(n=0,o=e.length;n0;)if(n=r[o],t===n.toLowerCase())return n;return null}const C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,I=e=>!S(e)&&e!==C,L=(U="undefined"!=typeof Uint8Array&&h(Uint8Array),e=>U&&e instanceof U);var U;const M=b("HTMLFormElement"),D=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),z=b("RegExp"),q=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};B(r,((r,o)=>{let i;!1!==(i=t(r,o,e))&&(n[o]=i||r)})),Object.defineProperties(e,n)},H="abcdefghijklmnopqrstuvwxyz",W="0123456789",G={DIGIT:W,ALPHA:H,ALPHA_DIGIT:H+H.toUpperCase()+W},V=b("AsyncFunction"),J={isArray:w,isArrayBuffer:O,isBuffer:function(e){return null!==e&&!S(e)&&null!==e.constructor&&!S(e.constructor)&&A(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||A(e.append)&&("formdata"===(t=m(e))||"object"===t&&A(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&O(e.buffer),t},isString:E,isNumber:j,isBoolean:e=>!0===e||!1===e,isObject:x,isPlainObject:P,isUndefined:S,isDate:k,isFile:R,isBlob:T,isRegExp:z,isFunction:A,isStream:e=>x(e)&&A(e.pipe),isURLSearchParams:_,isTypedArray:L,isFileList:N,forEach:B,merge:function e(){const{caseless:t}=I(this)&&this||{},r={},n=(n,o)=>{const i=t&&F(r,o)||o;P(r[i])&&P(n)?r[i]=e(r[i],n):P(n)?r[i]=e({},n):w(n)?r[i]=n.slice():r[i]=n};for(let e=0,t=arguments.length;e(B(t,((t,n)=>{r&&A(t)?e[n]=y(t,r):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let o,i,a;const c={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)a=o[i],n&&!n(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==r&&h(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:m,kindOfTest:b,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(w(e))return e;let t=e.length;if(!j(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:M,hasOwnProperty:D,hasOwnProp:D,reduceDescriptors:q,freezeMethods:e=>{q(e,((t,r)=>{if(A(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];A(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return w(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:F,global:C,isContextDefined:I,ALPHABET:G,generateString:(e=16,t=G.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r},isSpecCompliantForm:function(e){return!!(e&&A(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(x(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const o=w(e)?[]:{};return B(e,((e,t)=>{const i=r(e,n+1);!S(i)&&(o[t]=i)})),t[n]=void 0,o}}return e};return r(e,0)},isAsyncFn:V,isThenable:e=>e&&(x(e)||A(e))&&A(e.then)&&A(e.catch)};function $(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}J.inherits($,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:J.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const K=$.prototype,Q={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{Q[e]={value:e}})),Object.defineProperties($,Q),Object.defineProperty(K,"isAxiosError",{value:!0}),$.from=(e,t,r,n,o,i)=>{const a=Object.create(K);return J.toFlatObject(e,a,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),$.call(a,e.message,t,r,n,o),a.cause=e,a.name=e.name,i&&Object.assign(a,i),a};const X=$;function Z(e){return J.isPlainObject(e)||J.isArray(e)}function Y(e){return J.endsWith(e,"[]")?e.slice(0,-2):e}function ee(e,t,r){return e?e.concat(t).map((function(e,t){return e=Y(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const te=J.toFlatObject(J,{},null,(function(e){return/^is[A-Z]/.test(e)})),re=function(e,t,r){if(!J.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=J.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!J.isUndefined(t[e])}))).metaTokens,o=r.visitor||l,i=r.dots,a=r.indexes,c=(r.Blob||"undefined"!=typeof Blob&&Blob)&&J.isSpecCompliantForm(t);if(!J.isFunction(o))throw new TypeError("visitor must be a function");function s(e){if(null===e)return"";if(J.isDate(e))return e.toISOString();if(!c&&J.isBlob(e))throw new X("Blob is not supported. Use a Buffer instead.");return J.isArrayBuffer(e)||J.isTypedArray(e)?c&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,r,o){let c=e;if(e&&!o&&"object"==typeof e)if(J.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(J.isArray(e)&&function(e){return J.isArray(e)&&!e.some(Z)}(e)||(J.isFileList(e)||J.endsWith(r,"[]"))&&(c=J.toArray(e)))return r=Y(r),c.forEach((function(e,n){!J.isUndefined(e)&&null!==e&&t.append(!0===a?ee([r],n,i):null===a?r:r+"[]",s(e))})),!1;return!!Z(e)||(t.append(ee(o,r,i),s(e)),!1)}const u=[],f=Object.assign(te,{defaultVisitor:l,convertValue:s,isVisitable:Z});if(!J.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!J.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),J.forEach(r,(function(r,i){!0===(!(J.isUndefined(r)||null===r)&&o.call(t,r,J.isString(i)?i.trim():i,n,f))&&e(r,n?n.concat(i):[i])})),u.pop()}}(e),t};function ne(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function oe(e,t){this._pairs=[],e&&re(e,this,t)}const ie=oe.prototype;ie.append=function(e,t){this._pairs.push([e,t])},ie.toString=function(e){const t=e?function(t){return e.call(this,t,ne)}:ne;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};const ae=oe;function ce(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function se(e,t,r){if(!t)return e;const n=r&&r.encode||ce,o=r&&r.serialize;let i;if(i=o?o(t,r):J.isURLSearchParams(t)?t.toString():new ae(t,r).toString(n),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}const le=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){J.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},ue={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},fe={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:ae,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},pe="undefined"!=typeof window&&"undefined"!=typeof document,ye=(de="undefined"!=typeof navigator&&navigator.product,pe&&["ReactNative","NativeScript","NS"].indexOf(de)<0);var de;const he="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,me={...e,...fe},ge=function(e){function t(e,r,n,o){let i=e[o++];if("__proto__"===i)return!0;const a=Number.isFinite(+i),c=o>=e.length;return i=!i&&J.isArray(n)?n.length:i,c?(J.hasOwnProp(n,i)?n[i]=[n[i],r]:n[i]=r,!a):(n[i]&&J.isObject(n[i])||(n[i]=[]),t(e,r,n[i],o)&&J.isArray(n[i])&&(n[i]=function(e){const t={},r=Object.keys(e);let n;const o=r.length;let i;for(n=0;n{t(function(e){return J.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null},be={transitional:ue,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,o=J.isObject(e);if(o&&J.isHTMLForm(e)&&(e=new FormData(e)),J.isFormData(e))return n?JSON.stringify(ge(e)):e;if(J.isArrayBuffer(e)||J.isBuffer(e)||J.isStream(e)||J.isFile(e)||J.isBlob(e))return e;if(J.isArrayBufferView(e))return e.buffer;if(J.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return re(e,new me.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return me.isNode&&J.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((i=J.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return re(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||n?(t.setContentType("application/json",!1),function(e,t,r){if(J.isString(e))try{return(0,JSON.parse)(e),J.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||be.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(e&&J.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw X.from(e,X.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:me.classes.FormData,Blob:me.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};J.forEach(["delete","get","head","post","put","patch"],(e=>{be.headers[e]={}}));const ve=be,we=J.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Se=Symbol("internals");function Oe(e){return e&&String(e).trim().toLowerCase()}function Ee(e){return!1===e||null==e?e:J.isArray(e)?e.map(Ee):String(e)}function Ae(e,t,r,n,o){return J.isFunction(n)?n.call(this,t,r):(o&&(t=r),J.isString(t)?J.isString(n)?-1!==t.indexOf(n):J.isRegExp(n)?n.test(t):void 0:void 0)}class je{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function o(e,t,r){const o=Oe(t);if(!o)throw new Error("header name must be a non-empty string");const i=J.findKey(n,o);(!i||void 0===n[i]||!0===r||void 0===r&&!1!==n[i])&&(n[i||t]=Ee(e))}const i=(e,t)=>J.forEach(e,((e,r)=>o(e,r,t)));return J.isPlainObject(e)||e instanceof this.constructor?i(e,t):J.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?i((e=>{const t={};let r,n,o;return e&&e.split("\n").forEach((function(e){o=e.indexOf(":"),r=e.substring(0,o).trim().toLowerCase(),n=e.substring(o+1).trim(),!r||t[r]&&we[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t):null!=e&&o(t,e,r),this}get(e,t){if(e=Oe(e)){const r=J.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(J.isFunction(t))return t.call(this,e,r);if(J.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Oe(e)){const r=J.findKey(this,e);return!(!r||void 0===this[r]||t&&!Ae(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function o(e){if(e=Oe(e)){const o=J.findKey(r,e);!o||t&&!Ae(0,r[o],o,t)||(delete r[o],n=!0)}}return J.isArray(e)?e.forEach(o):o(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const o=t[r];e&&!Ae(0,this[o],o,e,!0)||(delete this[o],n=!0)}return n}normalize(e){const t=this,r={};return J.forEach(this,((n,o)=>{const i=J.findKey(r,o);if(i)return t[i]=Ee(n),void delete t[o];const a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(o):String(o).trim();a!==o&&delete t[o],t[a]=Ee(n),r[a]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return J.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&J.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[Se]=this[Se]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=Oe(e);t[n]||(function(e,t){const r=J.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,o){return this[n].call(this,t,e,r,o)},configurable:!0})}))}(r,e),t[n]=!0)}return J.isArray(e)?e.forEach(n):n(e),this}}je.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),J.reduceDescriptors(je.prototype,(({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}})),J.freezeMethods(je);const xe=je;function Pe(e,t){const r=this||ve,n=t||r,o=xe.from(n.headers);let i=n.data;return J.forEach(e,(function(e){i=e.call(r,i,o.normalize(),t?t.status:void 0)})),o.normalize(),i}function ke(e){return!(!e||!e.__CANCEL__)}function Re(e,t,r){X.call(this,null==e?"canceled":e,X.ERR_CANCELED,t,r),this.name="CanceledError"}J.inherits(Re,X,{__CANCEL__:!0});const Te=Re,Ne=me.hasStandardBrowserEnv?{write(e,t,r,n,o,i){const a=[e+"="+encodeURIComponent(t)];J.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),J.isString(n)&&a.push("path="+n),J.isString(o)&&a.push("domain="+o),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function _e(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Be=me.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function n(r){let n=r;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return r=n(window.location.href),function(e){const t=J.isString(e)?n(e):e;return t.protocol===r.protocol&&t.host===r.host}}():function(){return!0};function Fe(e,t){let r=0;const n=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o,i=0,a=0;return t=void 0!==t?t:1e3,function(c){const s=Date.now(),l=n[a];o||(o=s),r[i]=c,n[i]=s;let u=a,f=0;for(;u!==i;)f+=r[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),s-o{const i=o.loaded,a=o.lengthComputable?o.total:void 0,c=i-r,s=n(c);r=i;const l={loaded:i,total:a,progress:a?i/a:void 0,bytes:c,rate:s||void 0,estimated:s&&a&&i<=a?(a-i)/s:void 0,event:o};l[t?"download":"upload"]=!0,e(l)}}const Ce={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){let n=e.data;const o=xe.from(e.headers).normalize();let i,a,{responseType:c,withXSRFToken:s}=e;function l(){e.cancelToken&&e.cancelToken.unsubscribe(i),e.signal&&e.signal.removeEventListener("abort",i)}if(J.isFormData(n))if(me.hasStandardBrowserEnv||me.hasStandardBrowserWebWorkerEnv)o.setContentType(!1);else if(!1!==(a=o.getContentType())){const[e,...t]=a?a.split(";").map((e=>e.trim())).filter(Boolean):[];o.setContentType([e||"multipart/form-data",...t].join("; "))}let u=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",r=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(t+":"+r))}const f=_e(e.baseURL,e.url);function p(){if(!u)return;const n=xe.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders());!function(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new X("Request failed with status code "+r.status,[X.ERR_BAD_REQUEST,X.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),l()}),(function(e){r(e),l()}),{data:c&&"text"!==c&&"json"!==c?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:n,config:e,request:u}),u=null}if(u.open(e.method.toUpperCase(),se(f,e.params,e.paramsSerializer),!0),u.timeout=e.timeout,"onloadend"in u?u.onloadend=p:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(p)},u.onabort=function(){u&&(r(new X("Request aborted",X.ECONNABORTED,e,u)),u=null)},u.onerror=function(){r(new X("Network Error",X.ERR_NETWORK,e,u)),u=null},u.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const n=e.transitional||ue;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new X(t,n.clarifyTimeoutError?X.ETIMEDOUT:X.ECONNABORTED,e,u)),u=null},me.hasStandardBrowserEnv&&(s&&J.isFunction(s)&&(s=s(e)),s||!1!==s&&Be(f))){const t=e.xsrfHeaderName&&e.xsrfCookieName&&Ne.read(e.xsrfCookieName);t&&o.set(e.xsrfHeaderName,t)}void 0===n&&o.setContentType(null),"setRequestHeader"in u&&J.forEach(o.toJSON(),(function(e,t){u.setRequestHeader(t,e)})),J.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),c&&"json"!==c&&(u.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&u.addEventListener("progress",Fe(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",Fe(e.onUploadProgress)),(e.cancelToken||e.signal)&&(i=t=>{u&&(r(!t||t.type?new Te(null,e,u):t),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(i),e.signal&&(e.signal.aborted?i():e.signal.addEventListener("abort",i)));const y=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(f);y&&-1===me.protocols.indexOf(y)?r(new X("Unsupported protocol "+y+":",X.ERR_BAD_REQUEST,e)):u.send(n||null)}))}};J.forEach(Ce,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const Ie=e=>`- ${e}`,Le=e=>J.isFunction(e)||null===e||!1===e,Ue=e=>{e=J.isArray(e)?e:[e];const{length:t}=e;let r,n;const o={};for(let i=0;i`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));let r=t?e.length>1?"since :\n"+e.map(Ie).join("\n"):" "+Ie(e[0]):"as no adapter specified";throw new X("There is no suitable adapter to dispatch the request "+r,"ERR_NOT_SUPPORT")}return n};function Me(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Te(null,e)}function De(e){return Me(e),e.headers=xe.from(e.headers),e.data=Pe.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ue(e.adapter||ve.adapter)(e).then((function(t){return Me(e),t.data=Pe.call(e,e.transformResponse,t),t.headers=xe.from(t.headers),t}),(function(t){return ke(t)||(Me(e),t&&t.response&&(t.response.data=Pe.call(e,e.transformResponse,t.response),t.response.headers=xe.from(t.response.headers))),Promise.reject(t)}))}const ze=e=>e instanceof xe?e.toJSON():e;function qe(e,t){t=t||{};const r={};function n(e,t,r){return J.isPlainObject(e)&&J.isPlainObject(t)?J.merge.call({caseless:r},e,t):J.isPlainObject(t)?J.merge({},t):J.isArray(t)?t.slice():t}function o(e,t,r){return J.isUndefined(t)?J.isUndefined(e)?void 0:n(void 0,e,r):n(e,t,r)}function i(e,t){if(!J.isUndefined(t))return n(void 0,t)}function a(e,t){return J.isUndefined(t)?J.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function c(r,o,i){return i in t?n(r,o):i in e?n(void 0,r):void 0}const s={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c,headers:(e,t)=>o(ze(e),ze(t),!0)};return J.forEach(Object.keys(Object.assign({},e,t)),(function(n){const i=s[n]||o,a=i(e[n],t[n],n);J.isUndefined(a)&&i!==c||(r[n]=a)})),r}const He={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{He[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const We={};He.transitional=function(e,t,r){function n(e,t){return"[Axios v1.6.7] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,o,i)=>{if(!1===e)throw new X(n(o," has been removed"+(t?" in "+t:"")),X.ERR_DEPRECATED);return t&&!We[o]&&(We[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,i)}};const Ge={assertOptions:function(e,t,r){if("object"!=typeof e)throw new X("options must be an object",X.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const i=n[o],a=t[i];if(a){const t=e[i],r=void 0===t||a(t,i,e);if(!0!==r)throw new X("option "+i+" must be "+r,X.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new X("Unknown option "+i,X.ERR_BAD_OPTION)}},validators:He},Ve=Ge.validators;class Je{constructor(e){this.defaults=e,this.interceptors={request:new le,response:new le}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t;Error.captureStackTrace?Error.captureStackTrace(t={}):t=new Error;const r=t.stack?t.stack.replace(/^.+\n/,""):"";e.stack?r&&!String(e.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+r):e.stack=r}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=qe(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:o}=t;void 0!==r&&Ge.assertOptions(r,{silentJSONParsing:Ve.transitional(Ve.boolean),forcedJSONParsing:Ve.transitional(Ve.boolean),clarifyTimeoutError:Ve.transitional(Ve.boolean)},!1),null!=n&&(J.isFunction(n)?t.paramsSerializer={serialize:n}:Ge.assertOptions(n,{encode:Ve.function,serialize:Ve.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&J.merge(o.common,o[t.method]);o&&J.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete o[e]})),t.headers=xe.concat(i,o);const a=[];let c=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(c=c&&e.synchronous,a.unshift(e.fulfilled,e.rejected))}));const s=[];let l;this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)}));let u,f=0;if(!c){const e=[De.bind(this),void 0];for(e.unshift.apply(e,a),e.push.apply(e,s),u=e.length,l=Promise.resolve(t);f{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,o){r.reason||(r.reason=new Te(e,n,o),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;return{token:new Ke((function(t){e=t})),cancel:e}}}const Qe=Ke,Xe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Xe).forEach((([e,t])=>{Xe[t]=e}));const Ze=Xe,Ye=function e(t){const r=new $e(t),n=y($e.prototype.request,r);return J.extend(n,$e.prototype,r,{allOwnKeys:!0}),J.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(qe(t,r))},n}(ve);Ye.Axios=$e,Ye.CanceledError=Te,Ye.CancelToken=Qe,Ye.isCancel=ke,Ye.VERSION="1.6.7",Ye.toFormData=re,Ye.AxiosError=X,Ye.Cancel=Ye.CanceledError,Ye.all=function(e){return Promise.all(e)},Ye.spread=function(e){return function(t){return e.apply(null,t)}},Ye.isAxiosError=function(e){return J.isObject(e)&&!0===e.isAxiosError},Ye.mergeConfig=qe,Ye.AxiosHeaders=xe,Ye.formToJSON=e=>ge(J.isHTMLForm(e)?new FormData(e):e),Ye.getAdapter=Ue,Ye.HttpStatusCode=Ze,Ye.default=Ye;const et=Ye;function tt(e,t,r){return void 0===t&&(t={}),et({method:arguments.length>3&&void 0!==arguments[3]?arguments[3]:"post",url:r,params:t,headers:{"X-WP-Nonce":e},data:t})}function rt(e){return rt="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},rt(e)}function nt(e){return function(e){if(Array.isArray(e))return lt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||st(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 ot(){ot=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=t&&t.prototype instanceof g?t:g,a=Object.create(i.prototype),c=new T(n||[]);return o(a,"_invoke",{value:x(e,r,c)}),a}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var p="suspendedStart",y="suspendedYield",d="executing",h="completed",m={};function g(){}function b(){}function v(){}var w={};l(w,a,(function(){return this}));var S=Object.getPrototypeOf,O=S&&S(S(N([])));O&&O!==r&&n.call(O,a)&&(w=O);var E=v.prototype=g.prototype=Object.create(w);function A(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function j(e,t){function r(o,i,a,c){var s=f(e[o],e,i);if("throw"!==s.type){var l=s.arg,u=l.value;return u&&"object"==rt(u)&&n.call(u,"__await")?t.resolve(u.__await).then((function(e){r("next",e,a,c)}),(function(e){r("throw",e,a,c)})):t.resolve(u).then((function(e){l.value=e,a(l)}),(function(e){return r("throw",e,a,c)}))}c(s.arg)}var i;o(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,o){r(e,n,t,o)}))}return i=i?i.then(o,o):o()}})}function x(t,r,n){var o=p;return function(i,a){if(o===d)throw new Error("Generator is already running");if(o===h){if("throw"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=P(c,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=h,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var l=f(t,r,n);if("normal"===l.type){if(o=n.done?h:y,l.arg===m)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=h,n.method="throw",n.arg=l.arg)}}}function P(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=f(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.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 R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function N(t){if(t||""===t){var r=t[a];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(s&&l){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),R(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;R(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:N(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),m}},t}function it(e,t,r,n,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,o)}function at(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){it(i,n,o,a,c,"next",e)}function c(e){it(i,n,o,a,c,"throw",e)}a(void 0)}))}}function ct(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){l=!0,o=e}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(e,t)||st(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.")}()}function st(e,t){if(e){if("string"==typeof e)return lt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?lt(e,t):void 0}}function lt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r]+src=")([^">]+)("[^>]+>)/gi,ft=/url\(["']?(.+?\.(jpg|jpeg|png|gif|webp))["']?\)/gi,pt=/\"uniqueId\"\:\"([^"]+)\"/gi,yt=[],dt=0;const ht=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","title":"Pattern Inserter","apiVersion":2,"name":"dlxplugins/gbhx-pattern-inserter","category":"generateblocks","icon":"","description":"Paste in a pattern and it will be inserted for you.","keywords":["generateblocks","pattern","inserter"],"version":"1.0.0","textdomain":"gb-hacks","attributes":{"preview":{"type":"boolean","default":false}},"example":{"attributes":{"preview":true}},"editorScript":"gb-hacks-pattern-inserter-block"}');var mt=React.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24"},React.createElement("path",{fill:"currentColor",d:"M0 3v8h11V0H3a3 3 0 0 0-3 3ZM0 21a3 3 0 0 0 3 3h8V13H0ZM13 13v11h8a3 3 0 0 0 3-3v-8ZM17 11h2V7h4V5h-4V1h-2v4h-4v2h4v4z"}));(0,n.registerBlockType)(ht,{edit:function(e){e.attributes,e.setAttributes;var r=e.clientId,o=ct((0,t.useState)(""),2),i=o[0],c=o[1],s=ct((0,t.useState)([]),2),y=s[0],d=s[1],h=ct((0,t.useState)([]),2),m=(h[0],h[1]),g=ct((0,t.useState)(!1),2),b=g[0],v=g[1],w=ct((0,t.useState)(0),2),S=(w[0],w[1]),O=(0,a.useDispatch)(p.store).replaceBlock,E=function(){var e=at(ot().mark((function e(){var t,o,a,s,l,u,f;return ot().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:v(!0),t=function(){var e=at(ot().mark((function e(t,r){var n;return ot().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,tt(gbHacksPatternInserter.restNonce,{imgUrl:t,imgAlt:r},gbHacksPatternInserter.restUrl+"/process_image");case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})));return function(_x,t){return e.apply(this,arguments)}}(),o=nt(i.matchAll(ut)),a=[],o.length&&(d(o),o.forEach((function(e){a.push(e[2])}))),(s=nt(i.matchAll(ft))).length&&(m(s),s.forEach((function(e){a.push(e[1])}))),l=[],u=[],f=i,a.length&&(u=a.map((function(e){try{var r=t(e,"");return r.then((function(t){l.push(e);var r=t.data,n=r.data;if(r.success){dt++,S(dt);var o=n.attachmentUrl;f=f.replace(e,o),c(f)}else dt++,S(dt)})).catch((function(e){dt++,S(dt)})),r}catch(e){dt++,S(dt)}}))),Promise.all(u).then((function(){var e=nt(f.matchAll(pt));e.length&&e.forEach((function(e){var t=A();yt.push(t),i.replace(e[1],'"uniqueId":"'.concat(t,'"'))}));try{var t=(0,n.parse)(f);O(r,t)}catch(e){}})).catch((function(e){var t=nt(f.matchAll(pt));t.length&&t.forEach((function(e){var t=A();yt.push(t),i.replace(e[1],'"uniqueId":"'.concat(t,'"'))}));try{var o=(0,n.parse)(f);O(r,o)}catch(e){}}));case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),A=function e(){var t=r.substring(2,9).replace("-",""),n=l()(t);return yt.includes(n)?e():n},j=React.createElement(React.Fragment,null,React.createElement(f.Card,{className:"dlx-pattern-inserter"},React.createElement(f.CardHeader,null,(0,u.__)("Pattern Importer","alerts-dlx")),React.createElement(f.CardBody,null,React.createElement(f.TextareaControl,{label:(0,u.__)("Paste your pattern here","alerts-dlx"),placeholder:(0,u.__)("Paste your pattern here","alerts-dlx"),value:i,onChange:function(e){return c(e)},disabled:b})),React.createElement(f.CardFooter,null,React.createElement(f.Button,{variant:"primary",disabled:!i||b,onClick:E},(0,u.__)("Import","alerts-dlx")),b&&React.createElement("span",{className:"gb-pattern-importer-image"},React.createElement(f.Spinner,null),"Processing ".concat(dt," of ").concat(y.length," images."))))),x=(0,p.useBlockProps)({className:"dlx-pattern-inserter-wrapper"});return React.createElement(React.Fragment,null,React.createElement("div",x,j))},save:function(){return null},icon:mt});const gt=window.wp.commands,bt=window.wp.primitives,vt=(0,t.createElement)(bt.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,t.createElement)(bt.Path,{d:"m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z"}),(0,t.createElement)(bt.Path,{d:"m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z"}));function wt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){l=!0,o=e}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return St(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?St(e,t):void 0}}(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.")}()}function St(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);re.length)&&(t=e.length);for(var r=0,n=new Array(t);r1?React.createElement(i.PluginBlockSettingsMenuItem,{icon:React.createElement(Ot,null),label:"Wrap in Container",onClick:function(){var t=[];s.forEach((function(e){t.push((0,n.cloneBlock)(e))})),f((0,a.select)("core/block-editor").getMultiSelectedBlockClientIds(),e.blocks.createBlock("generateblocks/container",{},t))}}):null}});var r=[];if((0,c.registerPlugin)("dlx-gb-hacks-generate-unique-ids",{render:function(){var t=(0,a.useSelect)((function(e){return e("core/block-editor").getSelectedBlock()}),[]),n=function e(t){var n=t.substring(2,9).replace("-",""),o=l()(n);return r.includes(o)?e():o},o=function t(r){var o=r.clientId;if(void 0!==r.attributes.uniqueId){var i=n(o);e.data.dispatch("core/block-editor").updateBlockAttributes(o,{uniqueId:i})}void 0!==r.innerBlocks&&r.innerBlocks.length>0&&r.innerBlocks.forEach((function(e){t(e)}))};return null===t||-1===t.name.indexOf("generateblocks")?null:React.createElement(i.PluginBlockSettingsMenuItem,{icon:React.createElement(Et,null),label:"Generate New Unique IDs",onClick:function(){o(t)}})}}),e.hooks.addFilter("blocks.registerBlockType","generateblocks/transform/group",(function(t){if("core/group"===t.name){var r,n=(null===(r=t.transforms)||void 0===r?void 0:r.to)||[];n.push({type:"block",blocks:["generateblocks/container"],transform:function(t,r){return e.blocks.createBlock("generateblocks/container",{},r)}}),t.transforms.to=n}return t})),gbHacksPatternInserter.defaultHeadlineBlockEnabled){var s=gbHacksPatternInserter.defaultHeadlineBlockElement;e.data.subscribe((function(){var t=e.data.select("core/block-editor").getBlocks(),r=e.data.select("core/block-editor").getSelectedBlock();if((0,n.setDefaultBlockName)("generateblocks/headline"),null!=r)if(jt.includes(r.clientId))jt=t;else{jt=t;var o=e.data.select("core/block-editor").getBlockIndex(r.clientId);if(o>0){var i=e.data.select("core/block-editor").getBlocks()[o-1]||null;(null!==i&&"generateblocks/headline"===i.name&&"core/paragraph"===r.name&&""===r.attributes.content||null!==i&&"core/paragraph"===i.name&&"core/paragraph"===r.name&&""===r.attributes.content)&&e.data.dispatch("core/block-editor").replaceBlocks(r.clientId,[e.blocks.createBlock("generateblocks/headline",{uniqueId:"",content:r.attributes.content,element:s})])}}else jt=t})),(0,o.addAction)("generateblocks.editor.renderBlock","generateblocks/editor/renderBlock",(function(e){if(""===e.attributes.uniqueId){e.attributes.element=s;var t=0,r=setInterval((function(){t>50&&clearInterval(r),void 0!==e.headlineRef&&null!==e.headlineRef.current&&(e.headlineRef.current.querySelector(".block-editor-rich-text__editable").focus(),clearInterval(r)),t++}),200)}}))}}(window.wp)})()})();
-//# sourceMappingURL=index.js.map
\ No newline at end of file
+/******/ (() => { // webpackBootstrap
+/******/ "use strict";
+/******/ var __webpack_modules__ = ({
+
+/***/ "./src/js/blocks/plugins/pattern-preview.js":
+/*!**************************************************!*\
+ !*** ./src/js/blocks/plugins/pattern-preview.js ***!
+ \**************************************************/
+/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
+
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
+/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
+/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
+/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__);
+/* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/plugins */ "@wordpress/plugins");
+/* harmony import */ var _wordpress_plugins__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_plugins__WEBPACK_IMPORTED_MODULE_2__);
+
+
+
+
+/**
+ * Render a Preview Button.
+ *
+ * @return {Object} The rendered component.
+ */
+var PatternPreviewButton = function PatternPreviewButton() {
+ (0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
+ var headerToolbar = document.querySelector('.edit-post-header');
+ if (null === headerToolbar) {
+ return;
+ }
+
+ // Get the left toolbar and add to it.
+ var settingsToolbar = headerToolbar.querySelector('.edit-post-header__settings');
+ if (null === settingsToolbar) {
+ return;
+ }
+
+ // Create the button.
+ var button = document.createElement('a');
+ button.className = 'dlx-button-preview components-button has-icon';
+ button.ariaLabel = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Preview', 'futuris-demo-importer');
+ button.href = dlxPatternWranglerPreview.previewUrl;
+ button.target = '_blank';
+ button.rel = 'noopener noreferrer';
+
+ // Add icon.
+ var icon = document.createElement('svg');
+ icon.className = 'dlx-pattern-wrangler-preview-icon';
+ icon.innerHTML = '';
+ button.prepend(icon);
+ // Add the button to the toolbar as the first child.
+ settingsToolbar.prepend(button);
+ }, []);
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("svg", {
+ height: "0",
+ width: "0",
+ xmlns: "http://www.w3.org/2000/svg",
+ style: {
+ display: 'none'
+ },
+ "aria-hidden": "true"
+ }, /*#__PURE__*/React.createElement("symbol", {
+ id: "dlx-pattern-wrangler-preview-icon",
+ width: "16",
+ height: "16",
+ viewBox: "0 0 512 512"
+ }, /*#__PURE__*/React.createElement("path", {
+ fill: "currentColor",
+ d: "M304 24c0 13.3 10.7 24 24 24h102.1L207 271c-9.4 9.4-9.4 24.6 0 33.9s24.6 9.4 33.9 0l223-223V184c0 13.3 10.7 24 24 24s24-10.7 24-24V24c0-13.3-10.7-24-24-24H328c-13.3 0-24 10.7-24 24zM72 32C32.2 32 0 64.2 0 104v336c0 39.8 32.2 72 72 72h336c39.8 0 72-32.2 72-72V312c0-13.3-10.7-24-24-24s-24 10.7-24 24v128c0 13.3-10.7 24-24 24H72c-13.3 0-24-10.7-24-24V104c0-13.3 10.7-24 24-24h128c13.3 0 24-10.7 24-24s-10.7-24-24-24H72z"
+ }))));
+};
+(0,_wordpress_plugins__WEBPACK_IMPORTED_MODULE_2__.registerPlugin)('dlx-pattern-wrangler-preview-button', {
+ render: PatternPreviewButton
+});
+
+/***/ }),
+
+/***/ "react":
+/*!************************!*\
+ !*** external "React" ***!
+ \************************/
+/***/ ((module) => {
+
+module.exports = window["React"];
+
+/***/ }),
+
+/***/ "@wordpress/i18n":
+/*!******************************!*\
+ !*** external ["wp","i18n"] ***!
+ \******************************/
+/***/ ((module) => {
+
+module.exports = window["wp"]["i18n"];
+
+/***/ }),
+
+/***/ "@wordpress/plugins":
+/*!*********************************!*\
+ !*** external ["wp","plugins"] ***!
+ \*********************************/
+/***/ ((module) => {
+
+module.exports = window["wp"]["plugins"];
+
+/***/ })
+
+/******/ });
+/************************************************************************/
+/******/ // The module cache
+/******/ var __webpack_module_cache__ = {};
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/ // Check if module is in cache
+/******/ var cachedModule = __webpack_module_cache__[moduleId];
+/******/ if (cachedModule !== undefined) {
+/******/ return cachedModule.exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = __webpack_module_cache__[moduleId] = {
+/******/ // no module.id needed
+/******/ // no module.loaded needed
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/************************************************************************/
+/******/ /* webpack/runtime/compat get default export */
+/******/ (() => {
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = (module) => {
+/******/ var getter = module && module.__esModule ?
+/******/ () => (module['default']) :
+/******/ () => (module);
+/******/ __webpack_require__.d(getter, { a: getter });
+/******/ return getter;
+/******/ };
+/******/ })();
+/******/
+/******/ /* webpack/runtime/define property getters */
+/******/ (() => {
+/******/ // define getter functions for harmony exports
+/******/ __webpack_require__.d = (exports, definition) => {
+/******/ for(var key in definition) {
+/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
+/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
+/******/ }
+/******/ }
+/******/ };
+/******/ })();
+/******/
+/******/ /* webpack/runtime/hasOwnProperty shorthand */
+/******/ (() => {
+/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
+/******/ })();
+/******/
+/******/ /* webpack/runtime/make namespace object */
+/******/ (() => {
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = (exports) => {
+/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
+/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
+/******/ }
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/ })();
+/******/
+/************************************************************************/
+var __webpack_exports__ = {};
+// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
+(() => {
+/*!**********************!*\
+ !*** ./src/index.js ***!
+ \**********************/
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var _js_blocks_plugins_pattern_preview__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./js/blocks/plugins/pattern-preview */ "./src/js/blocks/plugins/pattern-preview.js");
+
+})();
+
+/******/ })()
+;
\ No newline at end of file
diff --git a/pattern-wrangler.php b/pattern-wrangler.php
index cb9bc52..5cca705 100644
--- a/pattern-wrangler.php
+++ b/pattern-wrangler.php
@@ -71,6 +71,12 @@ public function plugins_loaded() {
$patterns = new Patterns();
$patterns->run();
+ $drafts = new Drafts();
+ $drafts->run();
+
+ $preview = new Preview();
+ $preview->run();
+
/**
* When PatternWrangler can be extended.
*
diff --git a/php/Drafts.php b/php/Drafts.php
new file mode 100644
index 0000000..b84c7d9
--- /dev/null
+++ b/php/Drafts.php
@@ -0,0 +1,157 @@
+%s
',
+ esc_html( $notice_message )
+ );
+ }
+
+ /**
+ * Intercept draft/publish actions.
+ */
+ public function intercept_draft_publish() {
+ $action = sanitize_text_field( filter_input( INPUT_GET, 'action', FILTER_DEFAULT ) );
+ $nonce = sanitize_text_field( filter_input( INPUT_GET, 'nonce', FILTER_DEFAULT ) );
+ $post_id = absint( filter_input( INPUT_GET, 'post', FILTER_DEFAULT ) );
+
+ if ( ! $action ) {
+ return;
+ }
+ if ( ! current_user_can( 'edit_posts' ) ) {
+ return;
+ }
+ $notice_action = 'draft_pattern';
+ switch ( $action ) {
+ case 'draft_pattern':
+ if ( ! wp_verify_nonce( $nonce, 'draft-pattern_' . $post_id ) ) {
+ return;
+ }
+ wp_update_post(
+ array(
+ 'ID' => $post_id,
+ 'post_status' => 'draft',
+ )
+ );
+ break;
+ case 'publish_pattern':
+ if ( ! wp_verify_nonce( $nonce, 'publish-pattern_' . $post_id ) ) {
+ return;
+ }
+ $notice_action = 'publish_pattern';
+ wp_update_post(
+ array(
+ 'ID' => $post_id,
+ 'post_status' => 'publish',
+ )
+ );
+ break;
+ default:
+ return;
+ }
+
+ // Build redirect URL.
+ $redirect_url = add_query_arg(
+ array(
+ 'post_type' => 'wp_block',
+ 'notice_action' => $notice_action,
+ ),
+ admin_url( 'edit.php' )
+ );
+ wp_safe_redirect( esc_url_raw( $redirect_url ) );
+ exit;
+ }
+
+ /**
+ * Add a draft button to the quick actions for the wp_block post type.
+ *
+ * @param array $actions Array of actions.
+ * @param WP_Post $post Post object.
+ *
+ * @return array
+ */
+ public function add_draft_button_quick_action( $actions, $post ) {
+ if ( 'wp_block' !== $post->post_type ) {
+ return $actions;
+ }
+ if ( ! current_user_can( 'edit_posts' ) ) {
+ return $actions;
+ }
+ $draft_disable_url = add_query_arg(
+ array(
+ 'action' => 'draft_pattern',
+ 'nonce' => wp_create_nonce( 'draft-pattern_' . $post->ID ),
+ 'post' => $post->ID,
+ ),
+ admin_url( 'edit.php?post_type=wp_block' )
+ );
+ $draft_publish_url = add_query_arg(
+ array(
+ 'action' => 'publish_pattern',
+ 'nonce' => wp_create_nonce( 'publish-pattern_' . $post->ID ),
+ 'post' => $post->ID,
+ ),
+ admin_url( 'edit.php?post_type=wp_block' )
+ );
+ if ( 'draft' === $post->post_status ) {
+ $actions['draft_pattern'] = sprintf(
+ '%s',
+ esc_url_raw( $draft_publish_url ),
+ esc_html__( 'Publish', 'dlx-pattern-wrangler' )
+ );
+ }
+ if ( 'publish' === $post->post_status ) {
+ $actions['preview_pattern'] = sprintf(
+ '%s',
+ esc_url_raw( $draft_disable_url ),
+ esc_html__( 'Switch to Draft', 'dlx-pattern-wrangler' )
+ );
+ }
+ return $actions;
+ }
+}
diff --git a/php/Functions.php b/php/Functions.php
index 5a9d9bf..a2de0b2 100644
--- a/php/Functions.php
+++ b/php/Functions.php
@@ -182,6 +182,26 @@ function ( $a, $b ) {
return $all_categories;
}
+ /**
+ * Get preview URL for previewing a pattern.
+ *
+ * @param int $post_id The post ID.
+ *
+ * @return string The preview URL (unescaped).
+ */
+ public static function get_pattern_preview_url( $post_id ) {
+ $preview_url = add_query_arg(
+ array(
+ 'dlxpw_preview' => '1',
+ 'action' => 'preview',
+ 'pattern' => $post_id,
+ 'nonce' => wp_create_nonce( 'preview-pattern_' . $post_id ),
+ ),
+ home_url(),
+ );
+ return $preview_url;
+ }
+
/**
* Get the plugin's supported file extensions.
*
diff --git a/php/Options.php b/php/Options.php
index fcfc0bc..03c1fbd 100644
--- a/php/Options.php
+++ b/php/Options.php
@@ -110,6 +110,7 @@ public static function get_defaults() {
'hideUncategorizedPatterns' => false,
'loadCustomizerCSSBlockEditor' => false,
'loadCustomizerCSSFrontend' => true,
+ 'licenseValid' => false,
);
return $defaults;
}
diff --git a/php/Patterns.php b/php/Patterns.php
index 3d05642..a906768 100644
--- a/php/Patterns.php
+++ b/php/Patterns.php
@@ -16,6 +16,8 @@ class Patterns {
* Class runner.
*/
public function run() {
+ $options = Options::get_options();
+
// Deregister any disabled pattern categories.
add_action( 'init', array( $this, 'maybe_deregister_pattern_categories' ), 999 );
@@ -49,8 +51,6 @@ public function run() {
// Add a featured image to the wp_block post type column.
add_action( 'manage_wp_block_posts_custom_column', array( $this, 'add_featured_image_column_content' ), 10, 2 );
- $options = Options::get_options();
-
$hide_all_patterns = (bool) $options['hideAllPatterns'];
if ( $hide_all_patterns ) {
add_action( 'init', array( $this, 'remove_core_patterns' ), 9 );
@@ -93,7 +93,7 @@ public function add_featured_image_column_content( $column_name, $post_id ) {
*/
public function add_featured_image_column( $columns ) {
// Add featured image to 2nd column.
- $columns = array_slice( $columns, 0, 2, true ) + array( 'featured_image' => __( 'Pattern Preview', 'dlx-block-patterns' ) ) + array_slice( $columns, 1, count( $columns ) - 1, true );
+ $columns = array_slice( $columns, 0, 2, true ) + array( 'featured_image' => __( 'Pattern Preview', 'dlx-pattern-wrangler' ) ) + array_slice( $columns, 1, count( $columns ) - 1, true );
return $columns;
}
@@ -105,8 +105,8 @@ public function add_featured_image_column( $columns ) {
* @return object Updated labels.
*/
public function change_featured_image_label( $labels ) {
- $labels->featured_image = __( 'Pattern Preview', 'dlx-block-patterns' );
- $labels->set_featured_image = __( 'Set pattern preview', 'dlx-block-patterns' );
+ $labels->featured_image = __( 'Pattern Preview', 'dlx-pattern-wrangler' );
+ $labels->set_featured_image = __( 'Set pattern preview', 'dlx-pattern-wrangler' );
return $labels;
}
diff --git a/php/Preview.php b/php/Preview.php
new file mode 100644
index 0000000..8a01eba
--- /dev/null
+++ b/php/Preview.php
@@ -0,0 +1,108 @@
+post_type ) {
+ return;
+ }
+ $deps = require_once Functions::get_plugin_dir( 'build/dlx-pw-preview.asset.php' );
+ wp_enqueue_script(
+ 'dlx-pattern-wrangler-preview',
+ Functions::get_plugin_url( 'build/dlx-pw-preview.js' ),
+ $deps['dependencies'],
+ $deps['version'],
+ true
+ );
+ wp_localize_script(
+ 'dlx-pattern-wrangler-preview',
+ 'dlxPatternWranglerPreview',
+ array(
+ 'previewUrl' => Functions::get_pattern_preview_url( get_the_ID() ),
+ )
+ );
+ }
+
+ /**
+ * Override the template for the wp_block post type.
+ *
+ * @param string $template Template path.
+ *
+ * @return string Updated path.
+ */
+ public function maybe_override_template( $template ) {
+ $preview = get_query_var( 'dlxpw_preview' );
+ if ( ! $preview ) {
+ return $template;
+ }
+ $template = Functions::get_plugin_dir( 'templates/pattern.php' );
+ return $template;
+ }
+
+ /**
+ * Add preview query var to frontend.
+ *
+ * @param array $query_vars Array of query vars.
+ *
+ * @return array updated query vars.
+ */
+ public function add_preview_query_var( $query_vars ) {
+ $query_vars[] = 'dlxpw_preview';
+ return $query_vars;
+ }
+
+ /**
+ * Add a preview button to the quick actions for the wp_block post type.
+ *
+ * @param array $actions Array of actions.
+ * @param WP_Post $post Post object.
+ *
+ * @return array
+ */
+ public function add_preview_button_quick_action( $actions, $post ) {
+ if ( 'wp_block' === $post->post_type ) {
+ $actions['preview_pattern'] = sprintf(
+ '%s',
+ esc_url_raw( Functions::get_pattern_preview_url( $post->ID ) ),
+ esc_html__( 'Preview', 'dlx-pattern-wrangler' )
+ );
+ }
+ return $actions;
+ }
+}
diff --git a/src/index.js b/src/index.js
index 2428a92..1ee2d50 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,246 +1 @@
-import { useEffect, useState } from 'react';
-import { setDefaultBlockName, cloneBlock } from '@wordpress/blocks';
-import { addAction } from '@wordpress/hooks';
-import { PluginBlockSettingsMenuItem } from '@wordpress/edit-post';
-import { useSelect, select, useDispatch, store } from '@wordpress/data';
-import { registerPlugin } from '@wordpress/plugins';
-import uniqueId from 'lodash.uniqueid';
-import './js/blocks/pattern-importer/index.js';
-import './js/blocks/commands/index.js';
-import ContainerLogo from './js/blocks/components/icons/ContainerLogo.js';
-import ReplaceIcon from './js/blocks/components/icons/ReplaceIcon.js';
-import { settings } from '@wordpress/icons';
-
-let previousBlocks = [];
-
-// Run on load.
-( function( wp ) {
- /**
- * Add a toolbar option to wrap selected blocks in a container.
- */
- registerPlugin( 'dlx-gb-hacks-wrap-container', {
- render: () => {
- const [ clientIds, setClientIds ] = useState( [] );
-
- // Get the selected block clientIds.
-
- const selectedBlocks = useSelect( ( select ) => {
- return select( 'core/block-editor' ).getMultiSelectedBlocks();
- }, [] );
-
- const { replaceBlocks } = useDispatch( store )( 'core/block-editor' );
-
- useEffect( () => {
- setClientIds( selectedBlocks );
- }, [ selectedBlocks ] );
-
- // If no blocks are selected, return.
- if ( clientIds.length === 0 ) {
- return null;
- }
-
- // If more than one block is selected, add toolbar option to wrap container.
- if ( clientIds.length > 1 ) {
- return (
- }
- label="Wrap in Container"
- onClick={ () => {
- const innerBlocks = [];
- clientIds.forEach( ( clientId ) => {
- innerBlocks.push( cloneBlock( clientId ) );
- } );
- replaceBlocks(
- select( 'core/block-editor' ).getMultiSelectedBlockClientIds(),
- wp.blocks.createBlock(
- 'generateblocks/container', {}, innerBlocks
- )
- );
- } }
- />
- );
- }
- return null;
- },
- } );
-
- // Unique ID storing.
- const uniqueIds = [];
- /**
- * Generate New Unique IDs for selected blocks.
- */
- registerPlugin( 'dlx-gb-hacks-generate-unique-ids', {
- render: () => {
- const selectedBlock = useSelect( ( select ) => {
- return select( 'core/block-editor' ).getSelectedBlock();
- }, [] );
-
- /**
- * Return and generate a new unique ID.
- *
- * @param {string} clientId The client ID of the block.
- *
- * @return {string} The uniqueId.
- */
- const generateUniqueId = ( clientId ) => {
- // Get the substr of current client ID for prefix.
- const prefix = clientId.substring( 2, 9 ).replace( '-', '' );
- const newUniqueId = uniqueId( prefix );
-
- // Make sure it isn't in the array already. Recursive much?
- if ( uniqueIds.includes( newUniqueId ) ) {
- return generateUniqueId();
- }
- return newUniqueId;
- };
-
- /**
- * Replace uniqueId attribute with new uniqueId.
- *
- * @param {Object} block The block object.
- */
- const replaceUniqueId = ( block ) => {
- const blockClientId = block.clientId;
- const blockAttributes = block.attributes;
-
- // If block has a `uniqueId` attribute, generate a new one.
- if ( 'undefined' !== typeof blockAttributes.uniqueId ) {
- const newUniqueId = generateUniqueId( blockClientId );
- wp.data.dispatch( 'core/block-editor' ).updateBlockAttributes( blockClientId, { uniqueId: newUniqueId } );
- }
-
- // Now check if block has innerBlocks.
- if ( 'undefined' !== typeof block.innerBlocks && block.innerBlocks.length > 0 ) {
- block.innerBlocks.forEach( ( innerBlock ) => {
- replaceUniqueId( innerBlock );
- } );
- }
- };
-
- /**
- * Return early if no block is selected.
- */
- if ( null === selectedBlock ) {
- return null;
- }
-
- // Get the block name.
- const { name } = selectedBlock;
-
- // If name contains `generateblocks`, proceed.
- if ( name.indexOf( 'generateblocks' ) === -1 ) {
- return null;
- }
-
- // If more than one block is selected, add toolbar option to replace the Unique ID.
- return (
- }
- label="Generate New Unique IDs"
- onClick={ () => {
- replaceUniqueId( selectedBlock ); // This gets the selected block and all innerBlocks.
- } }
- />
- );
- },
- } );
-
- /**
- * Allow transform from group block.
- */
- wp.hooks.addFilter( 'blocks.registerBlockType', 'generateblocks/transform/group', ( blockSettings ) => {
- if ( blockSettings.name === 'core/group' ) {
- const transformsTo = blockSettings.transforms?.to || [];
- transformsTo.push( {
- type: 'block',
- blocks: [ 'generateblocks/container' ],
- transform: ( attributes, innerBlocks ) => {
- return wp.blocks.createBlock( 'generateblocks/container', {}, innerBlocks );
- },
- } );
- blockSettings.transforms.to = transformsTo;
- }
- return blockSettings;
- } );
- // Check to see if the default block is a headline. If not, return.
- const defaultHeadlineBlockEnabled = gbHacksPatternInserter.defaultHeadlineBlockEnabled;
- if ( ! defaultHeadlineBlockEnabled ) {
- return;
- }
-
- // Get the default element name.
- const defaultHeadlineElement = gbHacksPatternInserter.defaultHeadlineBlockElement;
-
- wp.data.subscribe( () => {
- // Try to find if the paragraph needs to be converted to a headline.
- const currentBlocks = wp.data.select( 'core/block-editor' ).getBlocks();
- const currentBlock = wp.data.select( 'core/block-editor' ).getSelectedBlock();
-
- // Set the default block. Needs to run every render otherwise is forgotten.
- setDefaultBlockName( 'generateblocks/headline' );
-
- // If no block is selected, no need to go further.
- if ( null === currentBlock || 'undefined' === typeof currentBlock ) {
- previousBlocks = currentBlocks;
- return;
- }
-
- // Check that selected block's client ID is not in previous blocks.
- if ( previousBlocks.includes( currentBlock.clientId ) ) {
- previousBlocks = currentBlocks;
- return;
- }
- previousBlocks = currentBlocks;
-
- // Get the block's index.
- const blockIndex = wp.data.select( 'core/block-editor' ).getBlockIndex( currentBlock.clientId );
-
- // If previous block is a headline, then the next block should be a headline too.
- if ( blockIndex > 0 ) {
- const previousSelectedBlock = wp.data.select( 'core/block-editor' ).getBlocks();
- const previousBlock = previousSelectedBlock[ blockIndex - 1 ] || null;
- if ( null !== previousBlock && previousBlock.name === 'generateblocks/headline' && currentBlock.name === 'core/paragraph' && currentBlock.attributes.content === '' ) {
- wp.data.dispatch( 'core/block-editor' ).replaceBlocks( currentBlock.clientId, [
- wp.blocks.createBlock( 'generateblocks/headline', {
- uniqueId: '',
- content: currentBlock.attributes.content,
- element: defaultHeadlineElement,
- } ),
- ] );
- } else if ( null !== previousBlock && previousBlock.name === 'core/paragraph' && currentBlock.name === 'core/paragraph' && currentBlock.attributes.content === '' ) {
- wp.data.dispatch( 'core/block-editor' ).replaceBlocks( currentBlock.clientId, [
- wp.blocks.createBlock( 'generateblocks/headline', {
- uniqueId: '',
- content: currentBlock.attributes.content,
- element: defaultHeadlineElement,
- } ),
- ] );
- }
- }
- } );
-
- /**
- * Change default headline element to paragraph.
- */
- addAction( 'generateblocks.editor.renderBlock', 'generateblocks/editor/renderBlock', function( props ) {
- if ( props.attributes.uniqueId === '' ) {
- props.attributes.element = defaultHeadlineElement;
-
- // Max iterations.
- const maxIterations = 50;
- let currentIteration = 0;
-
- const intervalId = setInterval( function() {
- if ( currentIteration > maxIterations ) {
- clearInterval( intervalId );
- }
- if ( 'undefined' !== typeof props.headlineRef && props.headlineRef.current !== null ) {
- const headline = props.headlineRef.current;
- headline.querySelector( '.block-editor-rich-text__editable' ).focus();
- clearInterval( intervalId );
- }
- currentIteration++;
- }, 200 );
- }
- } );
-}( window.wp ) );
+import './js/blocks/plugins/pattern-preview';
\ No newline at end of file
diff --git a/src/js/blocks/plugins/pattern-preview.js b/src/js/blocks/plugins/pattern-preview.js
new file mode 100644
index 0000000..a3adfa9
--- /dev/null
+++ b/src/js/blocks/plugins/pattern-preview.js
@@ -0,0 +1,57 @@
+import { useEffect } from 'react';
+import { __ } from '@wordpress/i18n';
+import { registerPlugin } from '@wordpress/plugins';
+
+/**
+ * Render a Preview Button.
+ *
+ * @return {Object} The rendered component.
+ */
+const PatternPreviewButton = () => {
+ useEffect( () => {
+ const headerToolbar = document.querySelector( '.edit-post-header' );
+ if ( null === headerToolbar ) {
+ return;
+ }
+
+ // Get the left toolbar and add to it.
+ const settingsToolbar = headerToolbar.querySelector( '.edit-post-header__settings' );
+ if ( null === settingsToolbar ) {
+ return;
+ }
+
+ // Create the button.
+ const button = document.createElement( 'a' );
+ button.className = 'dlx-button-preview components-button has-icon';
+ button.ariaLabel = __( 'Preview', 'dlx-pattern-wrangler' );
+ button.href = dlxPatternWranglerPreview.previewUrl;
+ button.target = '_blank';
+ button.rel = 'noopener noreferrer';
+
+ // Add icon.
+ const icon = document.createElement( 'svg' );
+ icon.className = 'dlx-pattern-wrangler-preview-icon';
+ icon.innerHTML = '';
+ button.prepend( icon );
+ // Add the button to the toolbar as the first child.
+ settingsToolbar.prepend( button );
+ }, [] );
+
+ return (
+ <>
+
+ >
+ );
+};
+registerPlugin( 'dlx-pattern-wrangler-preview-button', {
+ render: PatternPreviewButton,
+} );
+
diff --git a/templates/pattern.php b/templates/pattern.php
new file mode 100644
index 0000000..170f51f
--- /dev/null
+++ b/templates/pattern.php
@@ -0,0 +1,72 @@
+post_content );
+ echo $blocks;
+} else {
+ ?>
+
+ >
+
+
+ post_content );
+ ?>
+
+
+ >
+
+
+
+
+
+
+
+
+
+
+ {
},
mode: env.mode,
devtool: 'production' === env.mode ? 'source-map' : false,
+ entry: {
+ index: '/src/index.js',
+ 'dlx-pw-preview': './src/js/blocks/plugins/pattern-preview.js',
+ },
},
{
entry: {