this.wp=this.wp||{},this.wp.listReusableBlocks=function(t){vare={};functionn(r){if(e[r])returne[r].exports;varo=e[r]={i:r,l:!1,exports:{}};returnt[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}returnn.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeofSymbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)returnt;if(4&e&&"object"==typeoft&&t&&t.__esModule)returnt;varr=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeoft)for(varoint)n.d(r,o,function(e){returnt[e]}.bind(null,o));returnr},n.n=function(t){vare=t&&t.__esModule?function(){returnt.default}:function(){returnt};returnn.d(e,"a",e),e},n.o=function(t,e){returnObject.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=373)}({0:function(t,e){!function(){t.exports=this.wp.element}()},1:function(t,e){!function(){t.exports=this.wp.i18n}()},10:function(t,e,n){"use strict";functionr(t,e){if(!(tinstanceofe))thrownewTypeError("Cannot call a class as a function")}n.d(e,"a",function(){returnr})},11:function(t,e,n){"use strict";n.d(e,"a",function(){returni});varr=n(32),o=n(3);functioni(t,e){return!e||"object"!==Object(r.a)(e)&&"function"!=typeofe?Object(o.a)(t):e}},12:function(t,e,n){"use strict";functionr(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){returnt.__proto__||Object.getPrototypeOf(t)})(t)}n.d(e,"a",function(){returnr})},13:function(t,e,n){"use strict";functionr(t,e){return(r=Object.setPrototypeOf||function(t,e){returnt.__proto__=e,t})(t,e)}functiono(t,e){if("function"!=typeofe&&null!==e)thrownewTypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}n.d(e,"a",function(){returno})},2:function(t,e){!function(){t.exports=this.lodash}()},23:function(t,e,n){t.exports=n(54)},3:function(t,e,n){"use strict";functionr(t){if(void0===t)thrownewReferenceError("this hasn't been initialised - super() hasn't been called");returnt}n.d(e,"a",function(){returnr})},32:function(t,e,n){"use strict";functionr(t){return(r="function"==typeofSymbol&&"symbol"==typeofSymbol.iterator?function(t){returntypeoft}:function(t){returnt&&"function"==typeofSymbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeoft})(t)}functiono(t){return(o="function"==typeofSymbol&&"symbol"===r(Symbol.iterator)?function(t){returnr(t)}:function(t){returnt&&"function"==typeofSymbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":r(t)})(t)}n.d(e,"a",function(){returno})},33:function(t,e){!function(){t.exports=this.wp.apiFetch}()},373:function(t,e,n){"use strict";n.r(e);varr=n(0),o=n(1),i=n(23),a=n.n(i),c=n(44),u=n(2),s=n(33),l=n.n(s);functionf(t,e,n){varr=newwindow.Blob([e],{type:n});if(window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(r,t);else{varo=document.createElement("a");o.href=URL.createObjectURL(r),o.download=t,o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o)}}functionp(t){vare=newwindow.FileReader;returnnewPromise(function(n){e.onload=function(){n(e.result)},e.readAsText(t)})}functionh(){return(h=Object(c.a)(a.a.mark(functiont(e){varn,r,o,i,c;returna.a.wrap(function(t){for(;;)switch(t.prev=t.next){case0:returnt.next=2,l()({path:"/wp/v2/types/wp_block"});case2:returnn=t.sent,t.next=5,l()({path:"/wp/v2/".concat(n.rest_base,"/").concat(e,"?context=edit")});case5:r=t.sent,o=r.title.raw,i=r.content.raw,c=JSON.stringify({__file:"wp_block",title:o,content:i},null,2),f(Object(u.kebabCase)(o)+".json",c,"application/json");case11:case"end":returnt.stop()}},t,this)}))).apply(this,arguments)}vard=function(t){returnh.apply(this,arguments)},y=n(4),b=n(10),m=n(9),v=n(11),g=n(12),w=n(13),O=n(3),j=n(6);function_(){return(_=Object(c.a)(a.a.mark(functiont(e){varn,r,o,i;returna.a.wrap(function(t){for(;;)switch(t.prev=t.next){case0:returnt.next=2,p(e);case2:n=t.sent,t.prev=3,r=JSON.parse(n),t.next=10;break;case7:throwt.prev=7,t.t0=t.catch(3),newError("Invalid JSON file");case10:if("wp_block"===r.__file&&r.title&&r.content&&Object(u.isString)(r.title)&&Object(u.isString)(r.content)){t.next=12;break}thrownewError("Invalid Reusable Block JSON file");case12:returnt.next=14,l()({path:"/wp/v2/types/wp_block"});case14:returno=t.sent,t.next=17,l()({path:"/wp/v2/".concat(o.rest_base),data:{title:r.title,content:r.content,status:"publish"},method:"POST"});case17:returni=t.sent,t.abrupt("return",i);case19:case"end":returnt.stop()}},t,this,[[3,7]])}))).apply(this,arguments)}varx=function(t){return_.apply(this,arguments)},S=function(t){functione(){vart;returnObject(b.a)(this,e),(t=Object(v.a)(this,Object(g.a)(e).apply(this,arguments))).state={isLoading:!1,error:null,file:null},t.isStillMounted=!0,t.onChangeFile=t.onChangeFile.bind(Object(O.a)(Object(O.a)(t))),t.onSubmit=t.onSubmit.bind(Object(O.a)(Object(O.a)(t))),t}returnObject(w.a)(e,t),Object(m.a)(e,[{key:"componentWillUnmount",value:function(){this.isStillMounted=!1}},{key:"onChangeFile",value:function(t){this.setState({file:t.target.files[0]})}},{key:"onSubmit",value:function(t){vare=this;t.preventDefault();varn=this.state.file,r=this.props.onUpload;n&&(this.setState({isLoading:!0}),x(n).then(function(t){e.isStillMounted&&(e.setState({isLoading:!1}),r(t))}).catch(function(t){if(e.isStillMounted){varn;switch(t.message){case"Invalid JSON file":n=Object(o.__)("Invalid JSON file");break;case"Invalid Reusable Block JSON file":n=Object(o.__)("Invalid Reusable Block JSON file");break;default:n=Object(o.__)("Unknown error")}e.setState({isLoading:!1,error:n})}}))}},{key:"render",value:function(){vart=this.props.instanceId,e=this.state,n=e.file,i=e.isLoading,a=e.error,c="list-reusable-blocks-import-form-"+t;returnObject(r.createElement)("form",{className:"list-reusable-blocks-import-form",onSubmit:this.onSubmit},a&&Object(r.createElement)(y.Notice,{status:"error"},a),Object(r.createElement)("label",{htmlFor:c,className:"list-reusable-blocks-import-form__label"},Object(o.__)("File")),Object(r.createElement)("input",{id:c,type:"file",onChange:this.onChangeFile}),Object(r.createElement)(y.Button,{type:"submit",isBusy:i,disabled:!n||i,isDefault:!0,className:"list-reusable-blocks-import-form__button"},Object(o._x)("Import","button label")))}}]),e}(r.Component),E=Object(j.withInstanceId)(S);vark=function(t){vare=t.onUpload;returnObject(r.createElement)(y.Dropdown,{position:"bottom right",contentClassName:"list-reusable-blocks-import-dropdown__content",renderToggle:function(t){vare=t.isOpen,n=t.onToggle;returnObject(r.createElement)(y.Button,{type:"button","aria-expanded":e,onClick:n,isPrimary:!0},Object(o.__)("Import from JSON"))},renderContent:function(t){varn=t.onClose;returnObject(r.createElement)(E,{onUpload:Object(u.flow)(n,e)})}})};document.body.addEventListener("click",function(t){t.target.classList.contains("wp-list-reusable-blocks__export")&&(t.preventDefault(),d(t.target.dataset.id))}),document.addEventListener("DOMContentLoaded",function(){vart=document.querySelector(".page-title-action");if(t){vare=document.createElement("div");e.className="list-reusable-blocks__container",t.parentNode.insertBefore(e,t),Object(r.render)(Object(r.createElement)(k,{onUpload:function(){vart=document.createElement("div");t.className="notice notice-success is-dismissible",t.innerHTML="<p>".concat(Object(o.__)("Reusable block imported successfully!"),"</p>");vare=document.querySelector(".wp-header-end");e&&e.parentNode.insertBefore(t,e)}}),e)}})},4:function(t,e){!function(){t.exports=this.wp.components}()},44:function(t,e,n){"use strict";functionr(t,e,n,r,o,i,a){try{varc=t[i](a),u=c.value}catch(t){returnvoidn(t)}c.done?e(u):Promise.resolve(u).then(r,o)}functiono(t){returnfunction(){vare=this,n=arguments;returnnewPromise(function(o,i){vara=t.apply(e,n);functionc(t){r(a,o,i,c,u,"next",t)}functionu(t){r(a,o,i,c,u,"throw",t)}c(void0)})}}n.d(e,"a",function(){returno})},54:function(t,e,n){varr=function(){returnthis||"object"==typeofself&&self}()||Function("return this")(),o=r.regeneratorRuntime&&Object.getOwnPropertyNames(r).indexOf("regeneratorRuntime")>=0,i=o&&r.regeneratorRuntime;if(r.regeneratorRuntime=void0,t.exports=n(55),o)r.regeneratorRuntime=i;elsetry{deleter.regeneratorRuntime}catch(t){r.regeneratorRuntime=void0}},55:function(t,e){!function(e){"use strict";varn,r=Object.prototype,o=r.hasOwnProperty,i="function"==typeofSymbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag",s="object"==typeoft,l=e.regeneratorRuntime;if(l)s&&(t.exports=l);else{(l=e.regeneratorRuntime=s?t.exports:{}).wrap=w;varf="suspendedStart",p="suspendedYield",h="executing",d="completed",y={},b={};b[a]=function(){returnthis};varm=Object.getPrototypeOf,v=m&&m(m(R([])));v&&v!==r&&o.call(v,a)&&(b=v);varg=x.prototype=j.prototype=Object.create(b);_.prototype=g.constructor=x,x.constructor=_,x[u]=_.displayName="GeneratorFunction",l.isGeneratorFunction=function(t){vare="function"==typeoft&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},l.mark=function(t){returnObject.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,uint||(t[u]="GeneratorFunction")),t.prototype=Object.create(g),t},l.awrap=function(t){return{__await:t}},S(E.prototype),E.prototype[c]=function(){returnthis},l.AsyncIterator=E,l.async=function(t,e,n,r){varo=newE(w(t,e,n,r));returnl.isGeneratorFunction(e)?o:o.next().then(function(t){returnt.done?t.value:o.next()})},S(g),g[u]="Generator",g[a]=function(){returnthis},g.toString=function(){return"[object Generator]"},l.keys=function(t){vare=[];for(varnint)e.push(n);returne.reverse(),functionn(){for(;e.length;){varr=e.pop();if(rint)returnn.value=r,n.done=!1,n}returnn.done=!0,n}},l.values=R,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(N),!t)for(vareinthis)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;vart=this.tryEntries[0].completion;if("throw"===t.type)throwt.arg;returnthis.rval},dispatchException:function(t){if(this.done)throwt;vare=this;functionr(r,o){returnc.type="throw",c.arg=t,e.next=r,o&&(e.method="next",e.arg=n),!!o}for(vari=this.tryEntries.length-1;i>=0;--i){vara=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)returnr("end");if(a.tryLoc<=this.prev){varu=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)returnr(a.catchLoc,!0);if(this.prev<a.finallyLoc)returnr(a.finallyLoc)}elseif(u){if(this.prev<a.catchLoc)returnr(a.catchLoc,!0)}else{if(!s)thrownewError("try statement without catch or finally");if(this.prev<a.finallyLoc)returnr(a.finallyLoc)}}}},abrupt:function(t,e){for(varn=this.tryEntries.length-1;n>=0;--n){varr=this.tryEntries[n];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev<r.finallyLoc){vari=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);vara=i?i.completion:{};returna.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(t,e){if("throw"===t.type)throwt.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(vare=this.tryEntries.length-1;e>=0;--e){varn=this.tryEntries[e];if(n.finallyLoc===t)returnthis.complete(n.completion,n.afterLoc),N(n),y}},catch:function(t){for(vare=this.tryEntries.length-1;e>=0;--e){varn=this.tryEntries[e];if(n.tryLoc===t){varr=n.completion;if("throw"===r.type){varo=r.arg;N(n)}returno}}thrownewError("illegal catch attempt")},delegateYield:function(t,e,r){returnthis.delegate={iterator:R(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),y}}}functionw(t,e,n,r){varo=e&&e.prototypeinstanceofj?e:j,i=Object.create(o.prototype),a=newP(r||[]);returni._invoke=function(t,e,n){varr=f;returnfunction(o,i){if(r===h)thrownewError("Generator is already running");if(r===d){if("throw"===o)throwi;returnC()}for(n.method=o,n.arg=i;;){vara=n.delegate;if(a){varc=k(a,n);if(c){if(c===y)continue;returnc}}if("next"===n.method)n.sent=n._sent=n.arg;elseif("throw"===n.method){if(r===f)throwr=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=h;varu=O(t,e,n);if("normal"===u.type){if(r=n.done?d:p,u.arg===y)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=d,n.method="throw",n.arg=u.arg)}}}(t,n,a),i}functionO(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}functionj(){}function_(){}functionx(){}functionS(t){["next","throw","return"].forEach(function(e){t[e]=function(t){returnthis._invoke(e,t)}})}functionE(t){vare;this._invoke=function(n,r){functioni(){returnnewPromise(function(e,i){!functione(n,r,i,a){varc=O(t[n],t,r);if("throw"!==c.type){varu=c.arg,s=u.value;returns&&"object"==typeofs&&o.call(s,"__await")?Promise.resolve(s.__await).then(function(t){e("next",t,i,a)},function(t){e("throw",t,i,a)}):Promise.resolve(s).then(function(t){u.value=t,i(u)},function(t){returne("throw",t,i,a)})}a(c.arg)}(n,r,e,i)})}returne=e?e.then(i,i):i()}}functionk(t,e){varr=t.iterator[e.method];if(r===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=n,k(t,e),"throw"===e.method))returny;e.method="throw",e.arg=newTypeError("The iterator does not provide a 'throw' method")}returny}varo=O(r,t.iterator,e.arg);if("throw"===o.type)returne.method="throw",e.arg=o.arg,e.delegate=null,y;vari=o.arg;returni?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,y):i:(e.method="throw",e.arg=newTypeError("iterator result is not an object"),e.delegate=null,y)}functionL(t){vare={tryLoc:t[0]};1int&&(e.catchLoc=t[1]),2int&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}functionN(t){vare=t.completion||{};e.type="normal",deletee.arg,t.completion=e}functionP(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}functionR(t){if(t){vare=t[a];if(e)returne.call(t);if("function"==typeoft.next)returnt;if(!isNaN(t.length)){varr=-1,i=functione(){for(;++r<t.length;)if(o.call(t,r))returne.value=t[r],e.done=!1,e;returne.value=n,e.done=!0,e};returni.next=i}}return{next:C}}functionC(){return{value:n,done:!0}}}(function(){returnthis||"object"==typeofself&&self}()||Function("return this")())},6:function(t,e){!function(){t.exports=this.wp.compose}()},9:function(t,e,n){"use strict";functionr(t,e){for(varn=0;n<e.length;n++){varr=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"inr&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}functiono(t,e,n){returne&&r(t.prototype,e),n&&r(t,n),t}n.d(e,"a",function(){returno})}});