Plugin Directory

Changeset 2615551


Ignore:
Timestamp:
10/18/2021 06:06:57 AM (4 years ago)
Author:
resoc
Message:

Version 1.0.13

Location:
resoc/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • resoc/trunk/README.txt

    r2612027 r2615551  
    55Requires at least: 5.0
    66Tested up to: 5.8
    7 Stable tag: 1.0.12
     7Stable tag: 1.0.13
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8181== Changelog ==
    8282
     83= 1.0.13 =
     84* Social images are created asynchronously
     85* Use Resoc's free engine
     86
    8387= 1.0.12 =
    8488* Social image preview
  • resoc/trunk/admin/class-resoc-admin.php

    r2612027 r2615551  
    5454
    5555    add_action( 'save_post',
    56       array( $this, 'save_social_image' ) );
     56      array( $this, 'post_saved' ) );
    5757
    5858    add_action( 'updated_post_meta',
     
    6666
    6767    add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_preview_script' ) );
     68
     69    add_action( 'social_image_generation', array( $this, 'generate_image_for_post' ), 10, 1 );
    6870  }
    6971
     
    8284
    8385    $scriptData = array(
    84       'templatesBaseUrl' => plugins_url('', __FILE__),
     86      'templatesBaseUrl' => Resoc::IMAGE_ENGINE_BASE_URL,
    8587      'template' => $options[ Resoc_Settings::TEMPLATE ],
    8688      'backgroundColor' => $options[ Resoc_Settings::BACKGROUND_COLOR ],
     
    115117    if ( $meta_key == '_thumbnail_id' ) {
    116118      Resoc_Utils::log( "Thumbnail image of post " . $post_ID  . " was updated, regenerate its social image" );
    117       $this->generate_image_for_post( get_post( $post_ID ) );
    118     }
    119   }
    120 
    121   public function save_social_image( $post_ID ) {
    122     Resoc_Utils::log( "Generate social images for post " . $post_ID );
     119      $this->schedule_image_generation_for_post( $post_ID );
     120    }
     121  }
     122
     123  public function post_saved( $post_ID ) {
     124    Resoc_Utils::log( "Post $post_ID saved, maybe generate its social image" );
    123125
    124126    $post = get_post( $post_ID );
    125127    if ( $post->post_type == 'revision' ) {
    126       Resoc_Utils::log( "Post " . $post_ID . " is a revision, skip" );
    127       return;
    128     }
    129 
    130     $this->generate_image_for_post( $post );
    131   }
    132 
    133   public function generate_image_for_post( $post ) {
     128      Resoc_Utils::log( "Post $post_ID is a revision, skip" );
     129      return;
     130    }
     131
     132    $this->schedule_image_generation_for_post( $post_ID );
     133  }
     134
     135  public function schedule_image_generation_for_post( $post_ID ) {
     136    Resoc_Utils::log( "Schedule social image generation for post $post_ID" );
     137    wp_schedule_single_event( time(), 'social_image_generation', array( $post_ID ) );
     138  }
     139
     140  public function generate_image_for_post( $post_ID ) {
     141    Resoc_Utils::log( "Generate social image for post $post_ID" );
     142
     143    $post = get_post( $post_ID );
     144
    134145    $feature_image_url = Resoc_Utils::get_post_featured_image_url( $post->ID );
    135146    if ( !$feature_image_url ) {
     
    172183    }
    173184
    174     $social_image = Resoc_Utils::create_social_image( $request );
     185    $social_image = Resoc_Utils::create_social_image( $request['template'], $request['parameters'] );
    175186    if ( !$social_image ) {
    176187      Resoc_Utils::log( "Cannot generate social image for post " . $post->ID );
  • resoc/trunk/admin/js/preview-metabox.js

    r2612027 r2615551  
    1 !function(){var e={301:function(e,t,r){r(147),e.exports=self.fetch.bind(self)},147:function(e,t,r){"use strict";r.r(t),r.d(t,{Headers:function(){return p},Request:function(){return E},Response:function(){return T},DOMException:function(){return _},fetch:function(){return B}});var n="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==n&&n,o="URLSearchParams"in n,i="Symbol"in n&&"iterator"in Symbol,s="FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(e){return!1}}(),a="FormData"in n,c="ArrayBuffer"in n;if(c)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(e){return e&&u.indexOf(Object.prototype.toString.call(e))>-1};function h(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function f(e){return"string"!=typeof e&&(e=String(e)),e}function d(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i&&(t[Symbol.iterator]=function(){return t}),t}function p(e){this.map={},e instanceof p?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function y(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function b(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function v(e){var t=new FileReader,r=b(t);return t.readAsArrayBuffer(e),r}function g(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:s&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:a&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:o&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():c&&s&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=g(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c&&(ArrayBuffer.prototype.isPrototypeOf(e)||l(e))?this._bodyArrayBuffer=g(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):o&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var e=y(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?y(this)||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer)):this.blob().then(v)}),this.text=function(){var e,t,r,n=y(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,r=b(t=new FileReader),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a&&(this.formData=function(){return this.text().then(x)}),this.json=function(){return this.text().then(JSON.parse)},this}p.prototype.append=function(e,t){e=h(e),t=f(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},p.prototype.delete=function(e){delete this.map[h(e)]},p.prototype.get=function(e){return e=h(e),this.has(e)?this.map[e]:null},p.prototype.has=function(e){return this.map.hasOwnProperty(h(e))},p.prototype.set=function(e,t){this.map[h(e)]=f(t)},p.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},p.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),d(e)},p.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),d(e)},p.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),d(e)},i&&(p.prototype[Symbol.iterator]=p.prototype.entries);var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function E(e,t){if(!(this instanceof E))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,n,o=(t=t||{}).body;if(e instanceof E){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new p(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new p(t.headers)),this.method=(n=(r=t.method||this.method||"GET").toUpperCase(),w.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(o),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var i=/([?&])_=[^&]*/;i.test(this.url)?this.url=this.url.replace(i,"$1_="+(new Date).getTime()):this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}function x(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(o))}})),t}function T(e,t){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new p(t.headers),this.url=t.url||"",this._initBody(e)}E.prototype.clone=function(){return new E(this,{body:this._bodyInit})},m.call(E.prototype),m.call(T.prototype),T.prototype.clone=function(){return new T(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},T.error=function(){var e=new T(null,{status:0,statusText:""});return e.type="error",e};var S=[301,302,303,307,308];T.redirect=function(e,t){if(-1===S.indexOf(t))throw new RangeError("Invalid status code");return new T(null,{status:t,headers:{location:e}})};var _=n.DOMException;try{new _}catch(e){(_=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack}).prototype=Object.create(Error.prototype),_.prototype.constructor=_}function B(e,t){return new Promise((function(r,o){var i=new E(e,t);if(i.signal&&i.signal.aborted)return o(new _("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var e,t,n={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new p,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();t.append(n,o)}})),t)};n.url="responseURL"in a?a.responseURL:n.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;setTimeout((function(){r(new T(o,n))}),0)},a.onerror=function(){setTimeout((function(){o(new TypeError("Network request failed"))}),0)},a.ontimeout=function(){setTimeout((function(){o(new TypeError("Network request failed"))}),0)},a.onabort=function(){setTimeout((function(){o(new _("Aborted","AbortError"))}),0)},a.open(i.method,function(e){try{return""===e&&n.location.href?n.location.href:e}catch(t){return e}}(i.url),!0),"include"===i.credentials?a.withCredentials=!0:"omit"===i.credentials&&(a.withCredentials=!1),"responseType"in a&&(s?a.responseType="blob":c&&i.headers.get("Content-Type")&&-1!==i.headers.get("Content-Type").indexOf("application/octet-stream")&&(a.responseType="arraybuffer")),!t||"object"!=typeof t.headers||t.headers instanceof p?i.headers.forEach((function(e,t){a.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){a.setRequestHeader(e,f(t.headers[e]))})),i.signal&&(i.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&i.signal.removeEventListener("abort",u)}),a.send(void 0===i._bodyInit?null:i._bodyInit)}))}B.polyfill=!0,n.fetch||(n.fetch=B,n.Headers=p,n.Request=E,n.Response=T)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(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.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){"use strict";var e=window.wp.element,t=window.wp.plugins,n=window.wp.editPost,o=Object.prototype.toString,i=Array.isArray||function(e){return"[object Array]"===o.call(e)};function s(e){return"function"==typeof e}function a(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function c(e,t){return null!=e&&"object"==typeof e&&t in e}var u=RegExp.prototype.test,l=/\S/;var h={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"},f=/\s*/,d=/\s+/,p=/\s*=/,y=/\s*\}/,b=/#|\^|\/|>|\{|&|=|!/;function v(e){this.string=e,this.tail=e,this.pos=0}function g(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function m(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}v.prototype.eos=function(){return""===this.tail},v.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var r=t[0];return this.tail=this.tail.substring(r.length),this.pos+=r.length,r},v.prototype.scanUntil=function(e){var t,r=this.tail.search(e);switch(r){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=t.length,t},g.prototype.push=function(e){return new g(e,this)},g.prototype.lookup=function(e){var t,r,n,o=this.cache;if(o.hasOwnProperty(e))t=o[e];else{for(var i,a,u,l=this,h=!1;l;){if(e.indexOf(".")>0)for(i=l.view,a=e.split("."),u=0;null!=i&&u<a.length;)u===a.length-1&&(h=c(i,a[u])||(r=i,n=a[u],null!=r&&"object"!=typeof r&&r.hasOwnProperty&&r.hasOwnProperty(n))),i=i[a[u++]];else i=l.view[e],h=c(l.view,e);if(h){t=i;break}l=l.parent}o[e]=t}return s(t)&&(t=t.call(this.view)),t},m.prototype.clearCache=function(){void 0!==this.templateCache&&this.templateCache.clear()},m.prototype.parse=function(e,t){var r=this.templateCache,n=e+":"+(t||w.tags).join(":"),o=void 0!==r,s=o?r.get(n):void 0;return null==s&&(s=function(e,t){if(!e)return[];var r,n,o,s,c=!1,h=[],g=[],m=[],E=!1,x=!1,T="",S=0;function _(){if(E&&!x)for(;m.length;)delete g[m.pop()];else m=[];E=!1,x=!1}function B(e){if("string"==typeof e&&(e=e.split(d,2)),!i(e)||2!==e.length)throw new Error("Invalid tags: "+e);r=new RegExp(a(e[0])+"\\s*"),n=new RegExp("\\s*"+a(e[1])),o=new RegExp("\\s*"+a("}"+e[1]))}B(t||w.tags);for(var O,R,P,C,A,U,k=new v(e);!k.eos();){if(O=k.pos,P=k.scanUntil(r))for(var j=0,z=P.length;j<z;++j)s=C=P.charAt(j),function(e,t){return u.call(e,t)}(l,s)?(x=!0,c=!0,T+=" "):(m.push(g.length),T+=C),g.push(["text",C,O,O+1]),O+=1,"\n"===C&&(_(),T="",S=0,c=!1);if(!k.scan(r))break;if(E=!0,R=k.scan(b)||"name",k.scan(f),"="===R?(P=k.scanUntil(p),k.scan(p),k.scanUntil(n)):"{"===R?(P=k.scanUntil(o),k.scan(y),k.scanUntil(n),R="&"):P=k.scanUntil(n),!k.scan(n))throw new Error("Unclosed tag at "+k.pos);if(A=">"==R?[R,P,O,k.pos,T,S,c]:[R,P,O,k.pos],S++,g.push(A),"#"===R||"^"===R)h.push(A);else if("/"===R){if(!(U=h.pop()))throw new Error('Unopened section "'+P+'" at '+O);if(U[1]!==P)throw new Error('Unclosed section "'+U[1]+'" at '+O)}else"name"===R||"{"===R||"&"===R?x=!0:"="===R&&B(P)}if(_(),U=h.pop())throw new Error('Unclosed section "'+U[1]+'" at '+k.pos);return function(e){for(var t,r=[],n=r,o=[],i=0,s=e.length;i<s;++i)switch((t=e[i])[0]){case"#":case"^":n.push(t),o.push(t),n=t[4]=[];break;case"/":o.pop()[5]=t[2],n=o.length>0?o[o.length-1][4]:r;break;default:n.push(t)}return r}(function(e){for(var t,r,n=[],o=0,i=e.length;o<i;++o)(t=e[o])&&("text"===t[0]&&r&&"text"===r[0]?(r[1]+=t[1],r[3]=t[3]):(n.push(t),r=t));return n}(g))}(e,t),o&&r.set(n,s)),s},m.prototype.render=function(e,t,r,n){var o=this.getConfigTags(n),i=this.parse(e,o),s=t instanceof g?t:new g(t,void 0);return this.renderTokens(i,s,r,e,n)},m.prototype.renderTokens=function(e,t,r,n,o){for(var i,s,a,c="",u=0,l=e.length;u<l;++u)a=void 0,"#"===(s=(i=e[u])[0])?a=this.renderSection(i,t,r,n,o):"^"===s?a=this.renderInverted(i,t,r,n,o):">"===s?a=this.renderPartial(i,t,r,o):"&"===s?a=this.unescapedValue(i,t):"name"===s?a=this.escapedValue(i,t,o):"text"===s&&(a=this.rawValue(i)),void 0!==a&&(c+=a);return c},m.prototype.renderSection=function(e,t,r,n,o){var a=this,c="",u=t.lookup(e[1]);if(u){if(i(u))for(var l=0,h=u.length;l<h;++l)c+=this.renderTokens(e[4],t.push(u[l]),r,n,o);else if("object"==typeof u||"string"==typeof u||"number"==typeof u)c+=this.renderTokens(e[4],t.push(u),r,n,o);else if(s(u)){if("string"!=typeof n)throw new Error("Cannot use higher-order sections without the original template");null!=(u=u.call(t.view,n.slice(e[3],e[5]),(function(e){return a.render(e,t,r,o)})))&&(c+=u)}else c+=this.renderTokens(e[4],t,r,n,o);return c}},m.prototype.renderInverted=function(e,t,r,n,o){var s=t.lookup(e[1]);if(!s||i(s)&&0===s.length)return this.renderTokens(e[4],t,r,n,o)},m.prototype.indentPartial=function(e,t,r){for(var n=t.replace(/[^ \t]/g,""),o=e.split("\n"),i=0;i<o.length;i++)o[i].length&&(i>0||!r)&&(o[i]=n+o[i]);return o.join("\n")},m.prototype.renderPartial=function(e,t,r,n){if(r){var o=this.getConfigTags(n),i=s(r)?r(e[1]):r[e[1]];if(null!=i){var a=e[6],c=e[5],u=e[4],l=i;0==c&&u&&(l=this.indentPartial(i,u,a));var h=this.parse(l,o);return this.renderTokens(h,t,r,l,n)}}},m.prototype.unescapedValue=function(e,t){var r=t.lookup(e[1]);if(null!=r)return r},m.prototype.escapedValue=function(e,t,r){var n=this.getConfigEscape(r)||w.escape,o=t.lookup(e[1]);if(null!=o)return"number"==typeof o&&n===w.escape?String(o):n(o)},m.prototype.rawValue=function(e){return e[1]},m.prototype.getConfigTags=function(e){return i(e)?e:e&&"object"==typeof e?e.tags:void 0},m.prototype.getConfigEscape=function(e){return e&&"object"==typeof e&&!i(e)?e.escape:void 0};var w={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){E.templateCache=e},get templateCache(){return E.templateCache}},E=new m;w.clearCache=function(){return E.clearCache()},w.parse=function(e,t){return E.parse(e,t)},w.render=function(e,t,r,n){if("string"!=typeof e)throw new TypeError('Invalid template! Template should be a "string" but "'+(i(o=e)?"array":typeof o)+'" was given as the first argument for mustache#render(template, view, partials)');var o;return E.render(e,t,r,n)},w.escape=function(e){return String(e).replace(/[&<>"'`=\/]/g,(function(e){return h[e]}))},w.Scanner=v,w.Context=g,w.Writer=m;var x,T=w,S=r(301),_=r.n(S);!function(e){e.String="string",e.Color="color",e.ImageUrl="imageUrl",e.Choice="choice",e.ObjectList="objectList"}(x||(x={}));function B(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function O(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function R(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,o,(t=e[r](t)).done,t.value)}))}}}var P,C=function(e){return B(void 0,void 0,void 0,(function(){var t;return O(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,_()(e)];case 1:return[2,r.sent().json()];case 2:throw t=r.sent(),new Error("Cannot download manifest file "+e+": "+t);case 3:return[2]}}))}))},A=window.React,U=r.n(A),k=[],j="ResizeObserver loop completed with undelivered notifications.";!function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"}(P||(P={}));var z,I=function(e){return Object.freeze(e)},D=function(e,t){this.inlineSize=e,this.blockSize=t,I(this)},L=function(){function e(e,t,r,n){return this.x=e,this.y=t,this.width=r,this.height=n,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,I(this)}return e.prototype.toJSON=function(){var e=this;return{x:e.x,y:e.y,top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.width,height:e.height}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e}(),M=function(e){return e instanceof SVGElement&&"getBBox"in e},F=function(e){if(M(e)){var t=e.getBBox(),r=t.width,n=t.height;return!r&&!n}var o=e,i=o.offsetWidth,s=o.offsetHeight;return!(i||s||e.getClientRects().length)},N=function(e){var t,r;if(e instanceof Element)return!0;var n=null===(r=null===(t=e)||void 0===t?void 0:t.ownerDocument)||void 0===r?void 0:r.defaultView;return!!(n&&e instanceof n.Element)},V="undefined"!=typeof window?window:{},W=new WeakMap,q=/auto|scroll/,H=/^tb|vertical/,X=/msie|trident/i.test(V.navigator&&V.navigator.userAgent),G=function(e){return parseFloat(e||"0")},$=function(e,t,r){return void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=!1),new D((r?t:e)||0,(r?e:t)||0)},J=I({devicePixelContentBoxSize:$(),borderBoxSize:$(),contentBoxSize:$(),contentRect:new L(0,0,0,0)}),Y=function(e,t){if(void 0===t&&(t=!1),W.has(e)&&!t)return W.get(e);if(F(e))return W.set(e,J),J;var r=getComputedStyle(e),n=M(e)&&e.ownerSVGElement&&e.getBBox(),o=!X&&"border-box"===r.boxSizing,i=H.test(r.writingMode||""),s=!n&&q.test(r.overflowY||""),a=!n&&q.test(r.overflowX||""),c=n?0:G(r.paddingTop),u=n?0:G(r.paddingRight),l=n?0:G(r.paddingBottom),h=n?0:G(r.paddingLeft),f=n?0:G(r.borderTopWidth),d=n?0:G(r.borderRightWidth),p=n?0:G(r.borderBottomWidth),y=h+u,b=c+l,v=(n?0:G(r.borderLeftWidth))+d,g=f+p,m=a?e.offsetHeight-g-e.clientHeight:0,w=s?e.offsetWidth-v-e.clientWidth:0,E=o?y+v:0,x=o?b+g:0,T=n?n.width:G(r.width)-E-w,S=n?n.height:G(r.height)-x-m,_=T+y+w+v,B=S+b+m+g,O=I({devicePixelContentBoxSize:$(Math.round(T*devicePixelRatio),Math.round(S*devicePixelRatio),i),borderBoxSize:$(_,B,i),contentBoxSize:$(T,S,i),contentRect:new L(h,c,T,S)});return W.set(e,O),O},K=function(e,t,r){var n=Y(e,r),o=n.borderBoxSize,i=n.contentBoxSize,s=n.devicePixelContentBoxSize;switch(t){case P.DEVICE_PIXEL_CONTENT_BOX:return s;case P.BORDER_BOX:return o;default:return i}},Q=function(e){var t=Y(e);this.target=e,this.contentRect=t.contentRect,this.borderBoxSize=I([t.borderBoxSize]),this.contentBoxSize=I([t.contentBoxSize]),this.devicePixelContentBoxSize=I([t.devicePixelContentBoxSize])},Z=function(e){if(F(e))return 1/0;for(var t=0,r=e.parentNode;r;)t+=1,r=r.parentNode;return t},ee=function(){var e=1/0,t=[];k.forEach((function(r){if(0!==r.activeTargets.length){var n=[];r.activeTargets.forEach((function(t){var r=new Q(t.target),o=Z(t.target);n.push(r),t.lastReportedSize=K(t.target,t.observedBox),o<e&&(e=o)})),t.push((function(){r.callback.call(r.observer,n,r.observer)})),r.activeTargets.splice(0,r.activeTargets.length)}}));for(var r=0,n=t;r<n.length;r++)(0,n[r])();return e},te=function(e){k.forEach((function(t){t.activeTargets.splice(0,t.activeTargets.length),t.skippedTargets.splice(0,t.skippedTargets.length),t.observationTargets.forEach((function(r){r.isActive()&&(Z(r.target)>e?t.activeTargets.push(r):t.skippedTargets.push(r))}))}))},re=[],ne=0,oe={attributes:!0,characterData:!0,childList:!0,subtree:!0},ie=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],se=function(e){return void 0===e&&(e=0),Date.now()+e},ae=!1,ce=new(function(){function e(){var e=this;this.stopped=!0,this.listener=function(){return e.schedule()}}return e.prototype.run=function(e){var t=this;if(void 0===e&&(e=250),!ae){ae=!0;var r,n=se(e);r=function(){var r=!1;try{r=function(){var e,t=0;for(te(t);k.some((function(e){return e.activeTargets.length>0}));)t=ee(),te(t);return k.some((function(e){return e.skippedTargets.length>0}))&&("function"==typeof ErrorEvent?e=new ErrorEvent("error",{message:j}):((e=document.createEvent("Event")).initEvent("error",!1,!1),e.message=j),window.dispatchEvent(e)),t>0}()}finally{if(ae=!1,e=n-se(),!ne)return;r?t.run(1e3):e>0?t.run(e):t.start()}},function(e){if(!z){var t=0,r=document.createTextNode("");new MutationObserver((function(){return re.splice(0).forEach((function(e){return e()}))})).observe(r,{characterData:!0}),z=function(){r.textContent=""+(t?t--:t++)}}re.push(e),z()}((function(){requestAnimationFrame(r)}))}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var e=this,t=function(){return e.observer&&e.observer.observe(document.body,oe)};document.body?t():V.addEventListener("DOMContentLoaded",t)},e.prototype.start=function(){var e=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),ie.forEach((function(t){return V.addEventListener(t,e.listener,!0)})))},e.prototype.stop=function(){var e=this;this.stopped||(this.observer&&this.observer.disconnect(),ie.forEach((function(t){return V.removeEventListener(t,e.listener,!0)})),this.stopped=!0)},e}()),ue=function(e){!ne&&e>0&&ce.start(),!(ne+=e)&&ce.stop()},le=function(){function e(e,t){this.target=e,this.observedBox=t||P.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var e,t=K(this.target,this.observedBox,!0);return e=this.target,M(e)||function(e){switch(e.tagName){case"INPUT":if("image"!==e.type)break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1}(e)||"inline"!==getComputedStyle(e).display||(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e}(),he=function(e,t){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=t},fe=new WeakMap,de=function(e,t){for(var r=0;r<e.length;r+=1)if(e[r].target===t)return r;return-1},pe=function(){function e(){}return e.connect=function(e,t){var r=new he(e,t);fe.set(e,r)},e.observe=function(e,t,r){var n=fe.get(e),o=0===n.observationTargets.length;de(n.observationTargets,t)<0&&(o&&k.push(n),n.observationTargets.push(new le(t,r&&r.box)),ue(1),ce.schedule())},e.unobserve=function(e,t){var r=fe.get(e),n=de(r.observationTargets,t),o=1===r.observationTargets.length;n>=0&&(o&&k.splice(k.indexOf(r),1),r.observationTargets.splice(n,1),ue(-1))},e.disconnect=function(e){var t=this,r=fe.get(e);r.observationTargets.slice().forEach((function(r){return t.unobserve(e,r.target)})),r.activeTargets.splice(0,r.activeTargets.length)},e}(),ye=function(){function e(e){if(0===arguments.length)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if("function"!=typeof e)throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");pe.connect(this,e)}return e.prototype.observe=function(e,t){if(0===arguments.length)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!N(e))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");pe.observe(this,e,t)},e.prototype.unobserve=function(e){if(0===arguments.length)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!N(e))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");pe.unobserve(this,e)},e.prototype.disconnect=function(){pe.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e}(),be=U()["undefined"!=typeof document&&void 0!==document.createElement?"useLayoutEffect":"useEffect"];const ve="undefined"!=typeof window&&"ResizeObserver"in window?window.ResizeObserver:ye;function ge(){}let me;const we=()=>me||(me=function(){const e=new Map,t=new ve((r=(t,r)=>{for(let n=0;n<t.length;n++){const o=e.get(t[n].target);null==o||o.forEach((e=>e(t[n],r)))}},n=[],o=null,i=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];n=t,o||(o=requestAnimationFrame((function(){o=null,r.apply(void 0,n)})))},i.cancel=function(){o&&(cancelAnimationFrame(o),o=null)},i));var r,n,o,i;return{observer:t,subscribe(r,n){var o;t.observe(r);const i=null!==(o=e.get(r))&&void 0!==o?o:[];i.push(n),e.set(r,i)},unsubscribe(r,n){var o;t.unobserve(r);const i=null!==(o=e.get(r))&&void 0!==o?o:[];if(1===i.length)return void e.delete(r);const s=i.indexOf(n);-1!==s&&i.splice(s,1),e.set(r,i)}}}());var Ee=function(e,t){const r=we(),n=(e=>{const t=A.useRef(e);return A.useEffect((()=>{t.current=e})),t})(t);return be((()=>{let t=!1;const o=e&&"current"in e?e.current:e;if(!o)return ge;function i(e,r){t||n.current(e,r)}return r.subscribe(o,i),()=>{t=!0,r.unsubscribe(o,i)}}),[e,r,n]),r.observer},xe=t=>{const[r,n]=(0,A.useState)(null),o=(0,A.useRef)(null);Ee(o,(e=>{r||n(e.contentRect)}));const[i,s]=(0,A.useState)(null),a=(0,A.useRef)(null);Ee(a,(e=>s(e.contentRect)));let c={position:"relative"},u={position:"absolute"};if(i&&r){const e=i.width/r.width;c={transform:`scale(${e})`,transformOrigin:"top left",height:r.height*e+"px"},u={}}return(0,e.createElement)("div",{ref:a,style:c},(0,e.createElement)("div",{ref:o,style:u},t.children))};const Te=t=>(0,e.createElement)("div",{style:{zIndex:t.current===t.me?2:1,position:"absolute",left:0,right:0}},t.content&&(0,e.createElement)("iframe",{scrolling:"no",srcDoc:t.content,width:t.width,height:t.height,style:{border:0},onLoad:()=>{t.onReady()}}));var Se=t=>{const[r,n]=(0,A.useState)(!0),[o,i]=(0,A.useState)(null),[s,a]=(0,A.useState)(null);return(0,A.useEffect)((()=>{const e=(c=t.template,u=t.parameters,l={width:t.width,height:t.height},h=t.templateBaseUrl,function(e,t,r){return T.render('\n<html>\n  <head>\n    <meta name="viewport" content="width={{ resoc_imageWidth }}, initial-scale=1">\n  </head>\n  <body>\n    {{#resoc_baseUrl}}\n    <base href="{{{ resoc_baseUrl }}}" />\n    {{/resoc_baseUrl}}\n    <style>\n      html {\n        width: {{ resoc_imageWidth }}px;\n        height: {{ resoc_imageHeight }}px;\n        font-size: 3vw;\n        display: flex;\n        align-items: stretch;\n        background-color: white;\n      }\n\n      body {\n        flex: 1 1 0;\n        min-width: 0;\n        margin: 0;\n        display: flex;\n        align-items: stretch;\n      }\n\n      body > div {\n        flex: 1 1 0;\n        min-width: 0;\n      }\n    </style>\n    <style>\n      {{> styles}}\n    </style>\n    {{> content}}\n  </body>\n</html>',r,t.partials)}(0,c,function(e,t,r){return Object.assign({},e,{resoc_imageWidth:t.width,resoc_imageHeight:t.height,resoc_baseUrl:r})}(u,l,h)));var c,u,l,h;r?e!==s?a(e):n(!1):e!==o?i(e):n(!0)}),[t.template,t.parameters,t.width,t.height]),(0,e.createElement)("div",{style:{position:"relative",width:t.width,height:t.height,backgroundColor:"white"}},(0,e.createElement)(Te,{me:"a",current:r?"a":"b",content:o,width:t.width,height:t.height,onReady:()=>n(!0)}),(0,e.createElement)(Te,{me:"b",current:r?"a":"b",content:s,width:t.width,height:t.height,onReady:()=>n(!1)}))},_e=t=>{const[r,n]=(0,A.useState)(null);return(0,A.useEffect)((()=>{t.templateManifestUrl&&!r&&(async()=>{const e=await(r=t.templateManifestUrl,B(void 0,void 0,void 0,(function(){var e,t,n,o,i,s,a,c,u,l,h,f;return O(this,(function(d){switch(d.label){case 0:return[4,C(r)];case 1:e=d.sent(),t={},d.label=2;case 2:d.trys.push([2,9,10,15]),n=R(Object.keys(e.partials)),d.label=3;case 3:return[4,n.next()];case 4:return(o=d.sent()).done?[3,8]:(i=o.value,[4,_()((p=e.partials[i],y=r,(b=y).toLowerCase().startsWith("http://")||b.toLowerCase().startsWith("https://")||b.toLowerCase().startsWith("//")||(y=function(e){return new URL(e,document.baseURI).href}(y)),new URL(p,y).href))]);case 5:return s=d.sent(),a=t,c=i,[4,s.text()];case 6:a[c]=d.sent(),d.label=7;case 7:return[3,3];case 8:return[3,15];case 9:return u=d.sent(),h={error:u},[3,15];case 10:return d.trys.push([10,,13,14]),o&&!o.done&&(f=n.return)?[4,f.call(n)]:[3,12];case 11:d.sent(),d.label=12;case 12:return[3,14];case 13:if(h)throw h.error;return[7];case 14:return[7];case 15:return l=[],e.parameters.forEach((function(e){l.push(e)})),[2,{partials:t,parameters:l}]}var p,y,b}))})));var r;n(e),t.onTemplateLoaded&&t.onTemplateLoaded(e)})()}),[t.templateManifestUrl]),t.templateManifestUrl&&r?(0,e.createElement)(xe,null,(0,e.createElement)(Se,{templateBaseUrl:t.templateManifestUrl,template:r,parameters:t.paramValues,width:1200,height:630})):(0,e.createElement)("div",null,"Loading template...")},Be=window.wp.data;const Oe=(0,Be.withSelect)((e=>{let t,r,n;return t=void 0!==e("core/editor").getPostEdits().title?e("core/editor").getPostEdits().title:e("core/editor").getCurrentPost().title,r=void 0!==e("core/editor").getPostEdits().excerpt?e("core/editor").getPostEdits().excerpt:e("core/editor").getCurrentPost().excerpt,n=void 0!==e("core/editor").getPostEdits().featured_media?e("core/editor").getPostEdits().featured_media:e("core/editor").getCurrentPost().featured_media,n&&e("core").getMedia(n),{title:t,description:r,featuredMediaId:n}}))((0,Be.withSelect)(((e,t)=>{const r=t.featuredMediaId?e("core").getMedia(t.featuredMediaId):null;return{mainImageUrl:r?r.source_url:null,...t}}))((t=>(0,e.createElement)(_e,{templateManifestUrl:`${template_options.templatesBaseUrl}/templates/${template_options.template}/resoc.manifest.json`,paramValues:{title:t.title,description:t.description,mainImageUrl:t.mainImageUrl,textColor:template_options.textColor,backgroundColor:template_options.backgroundColor,brandName:template_options.brandName,textDirection:template_options.textDirection,logoUrl:template_options.logoUrl}}))));(0,t.registerPlugin)("resoc-preview",{render:()=>(0,e.createElement)(n.PluginDocumentSettingPanel,{name:"my-plugin-sidebar",icon:"none",title:"Social image"},(0,e.createElement)(Oe,null))})}()}();
     1!function(){var e={301:function(e,t,r){r(147),e.exports=self.fetch.bind(self)},147:function(e,t,r){"use strict";r.r(t),r.d(t,{Headers:function(){return p},Request:function(){return E},Response:function(){return T},DOMException:function(){return _},fetch:function(){return B}});var n="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==n&&n,o="URLSearchParams"in n,i="Symbol"in n&&"iterator"in Symbol,s="FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(e){return!1}}(),a="FormData"in n,c="ArrayBuffer"in n;if(c)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(e){return e&&u.indexOf(Object.prototype.toString.call(e))>-1};function h(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function f(e){return"string"!=typeof e&&(e=String(e)),e}function d(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i&&(t[Symbol.iterator]=function(){return t}),t}function p(e){this.map={},e instanceof p?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function y(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function b(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function v(e){var t=new FileReader,r=b(t);return t.readAsArrayBuffer(e),r}function g(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:s&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:a&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:o&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():c&&s&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=g(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c&&(ArrayBuffer.prototype.isPrototypeOf(e)||l(e))?this._bodyArrayBuffer=g(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):o&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var e=y(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?y(this)||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer)):this.blob().then(v)}),this.text=function(){var e,t,r,n=y(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,r=b(t=new FileReader),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a&&(this.formData=function(){return this.text().then(x)}),this.json=function(){return this.text().then(JSON.parse)},this}p.prototype.append=function(e,t){e=h(e),t=f(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},p.prototype.delete=function(e){delete this.map[h(e)]},p.prototype.get=function(e){return e=h(e),this.has(e)?this.map[e]:null},p.prototype.has=function(e){return this.map.hasOwnProperty(h(e))},p.prototype.set=function(e,t){this.map[h(e)]=f(t)},p.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},p.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),d(e)},p.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),d(e)},p.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),d(e)},i&&(p.prototype[Symbol.iterator]=p.prototype.entries);var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function E(e,t){if(!(this instanceof E))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,n,o=(t=t||{}).body;if(e instanceof E){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new p(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new p(t.headers)),this.method=(n=(r=t.method||this.method||"GET").toUpperCase(),w.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(o),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var i=/([?&])_=[^&]*/;i.test(this.url)?this.url=this.url.replace(i,"$1_="+(new Date).getTime()):this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}function x(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(o))}})),t}function T(e,t){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new p(t.headers),this.url=t.url||"",this._initBody(e)}E.prototype.clone=function(){return new E(this,{body:this._bodyInit})},m.call(E.prototype),m.call(T.prototype),T.prototype.clone=function(){return new T(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},T.error=function(){var e=new T(null,{status:0,statusText:""});return e.type="error",e};var S=[301,302,303,307,308];T.redirect=function(e,t){if(-1===S.indexOf(t))throw new RangeError("Invalid status code");return new T(null,{status:t,headers:{location:e}})};var _=n.DOMException;try{new _}catch(e){(_=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack}).prototype=Object.create(Error.prototype),_.prototype.constructor=_}function B(e,t){return new Promise((function(r,o){var i=new E(e,t);if(i.signal&&i.signal.aborted)return o(new _("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var e,t,n={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new p,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();t.append(n,o)}})),t)};n.url="responseURL"in a?a.responseURL:n.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;setTimeout((function(){r(new T(o,n))}),0)},a.onerror=function(){setTimeout((function(){o(new TypeError("Network request failed"))}),0)},a.ontimeout=function(){setTimeout((function(){o(new TypeError("Network request failed"))}),0)},a.onabort=function(){setTimeout((function(){o(new _("Aborted","AbortError"))}),0)},a.open(i.method,function(e){try{return""===e&&n.location.href?n.location.href:e}catch(t){return e}}(i.url),!0),"include"===i.credentials?a.withCredentials=!0:"omit"===i.credentials&&(a.withCredentials=!1),"responseType"in a&&(s?a.responseType="blob":c&&i.headers.get("Content-Type")&&-1!==i.headers.get("Content-Type").indexOf("application/octet-stream")&&(a.responseType="arraybuffer")),!t||"object"!=typeof t.headers||t.headers instanceof p?i.headers.forEach((function(e,t){a.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){a.setRequestHeader(e,f(t.headers[e]))})),i.signal&&(i.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&i.signal.removeEventListener("abort",u)}),a.send(void 0===i._bodyInit?null:i._bodyInit)}))}B.polyfill=!0,n.fetch||(n.fetch=B,n.Headers=p,n.Request=E,n.Response=T)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(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.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){"use strict";var e=window.wp.element,t=window.wp.plugins,n=window.wp.editPost,o=Object.prototype.toString,i=Array.isArray||function(e){return"[object Array]"===o.call(e)};function s(e){return"function"==typeof e}function a(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function c(e,t){return null!=e&&"object"==typeof e&&t in e}var u=RegExp.prototype.test,l=/\S/;var h={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"},f=/\s*/,d=/\s+/,p=/\s*=/,y=/\s*\}/,b=/#|\^|\/|>|\{|&|=|!/;function v(e){this.string=e,this.tail=e,this.pos=0}function g(e,t){this.view=e,this.cache={".":this.view},this.parent=t}function m(){this.templateCache={_cache:{},set:function(e,t){this._cache[e]=t},get:function(e){return this._cache[e]},clear:function(){this._cache={}}}}v.prototype.eos=function(){return""===this.tail},v.prototype.scan=function(e){var t=this.tail.match(e);if(!t||0!==t.index)return"";var r=t[0];return this.tail=this.tail.substring(r.length),this.pos+=r.length,r},v.prototype.scanUntil=function(e){var t,r=this.tail.search(e);switch(r){case-1:t=this.tail,this.tail="";break;case 0:t="";break;default:t=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=t.length,t},g.prototype.push=function(e){return new g(e,this)},g.prototype.lookup=function(e){var t,r,n,o=this.cache;if(o.hasOwnProperty(e))t=o[e];else{for(var i,a,u,l=this,h=!1;l;){if(e.indexOf(".")>0)for(i=l.view,a=e.split("."),u=0;null!=i&&u<a.length;)u===a.length-1&&(h=c(i,a[u])||(r=i,n=a[u],null!=r&&"object"!=typeof r&&r.hasOwnProperty&&r.hasOwnProperty(n))),i=i[a[u++]];else i=l.view[e],h=c(l.view,e);if(h){t=i;break}l=l.parent}o[e]=t}return s(t)&&(t=t.call(this.view)),t},m.prototype.clearCache=function(){void 0!==this.templateCache&&this.templateCache.clear()},m.prototype.parse=function(e,t){var r=this.templateCache,n=e+":"+(t||w.tags).join(":"),o=void 0!==r,s=o?r.get(n):void 0;return null==s&&(s=function(e,t){if(!e)return[];var r,n,o,s,c=!1,h=[],g=[],m=[],E=!1,x=!1,T="",S=0;function _(){if(E&&!x)for(;m.length;)delete g[m.pop()];else m=[];E=!1,x=!1}function B(e){if("string"==typeof e&&(e=e.split(d,2)),!i(e)||2!==e.length)throw new Error("Invalid tags: "+e);r=new RegExp(a(e[0])+"\\s*"),n=new RegExp("\\s*"+a(e[1])),o=new RegExp("\\s*"+a("}"+e[1]))}B(t||w.tags);for(var O,R,P,C,A,U,k=new v(e);!k.eos();){if(O=k.pos,P=k.scanUntil(r))for(var j=0,z=P.length;j<z;++j)s=C=P.charAt(j),function(e,t){return u.call(e,t)}(l,s)?(x=!0,c=!0,T+=" "):(m.push(g.length),T+=C),g.push(["text",C,O,O+1]),O+=1,"\n"===C&&(_(),T="",S=0,c=!1);if(!k.scan(r))break;if(E=!0,R=k.scan(b)||"name",k.scan(f),"="===R?(P=k.scanUntil(p),k.scan(p),k.scanUntil(n)):"{"===R?(P=k.scanUntil(o),k.scan(y),k.scanUntil(n),R="&"):P=k.scanUntil(n),!k.scan(n))throw new Error("Unclosed tag at "+k.pos);if(A=">"==R?[R,P,O,k.pos,T,S,c]:[R,P,O,k.pos],S++,g.push(A),"#"===R||"^"===R)h.push(A);else if("/"===R){if(!(U=h.pop()))throw new Error('Unopened section "'+P+'" at '+O);if(U[1]!==P)throw new Error('Unclosed section "'+U[1]+'" at '+O)}else"name"===R||"{"===R||"&"===R?x=!0:"="===R&&B(P)}if(_(),U=h.pop())throw new Error('Unclosed section "'+U[1]+'" at '+k.pos);return function(e){for(var t,r=[],n=r,o=[],i=0,s=e.length;i<s;++i)switch((t=e[i])[0]){case"#":case"^":n.push(t),o.push(t),n=t[4]=[];break;case"/":o.pop()[5]=t[2],n=o.length>0?o[o.length-1][4]:r;break;default:n.push(t)}return r}(function(e){for(var t,r,n=[],o=0,i=e.length;o<i;++o)(t=e[o])&&("text"===t[0]&&r&&"text"===r[0]?(r[1]+=t[1],r[3]=t[3]):(n.push(t),r=t));return n}(g))}(e,t),o&&r.set(n,s)),s},m.prototype.render=function(e,t,r,n){var o=this.getConfigTags(n),i=this.parse(e,o),s=t instanceof g?t:new g(t,void 0);return this.renderTokens(i,s,r,e,n)},m.prototype.renderTokens=function(e,t,r,n,o){for(var i,s,a,c="",u=0,l=e.length;u<l;++u)a=void 0,"#"===(s=(i=e[u])[0])?a=this.renderSection(i,t,r,n,o):"^"===s?a=this.renderInverted(i,t,r,n,o):">"===s?a=this.renderPartial(i,t,r,o):"&"===s?a=this.unescapedValue(i,t):"name"===s?a=this.escapedValue(i,t,o):"text"===s&&(a=this.rawValue(i)),void 0!==a&&(c+=a);return c},m.prototype.renderSection=function(e,t,r,n,o){var a=this,c="",u=t.lookup(e[1]);if(u){if(i(u))for(var l=0,h=u.length;l<h;++l)c+=this.renderTokens(e[4],t.push(u[l]),r,n,o);else if("object"==typeof u||"string"==typeof u||"number"==typeof u)c+=this.renderTokens(e[4],t.push(u),r,n,o);else if(s(u)){if("string"!=typeof n)throw new Error("Cannot use higher-order sections without the original template");null!=(u=u.call(t.view,n.slice(e[3],e[5]),(function(e){return a.render(e,t,r,o)})))&&(c+=u)}else c+=this.renderTokens(e[4],t,r,n,o);return c}},m.prototype.renderInverted=function(e,t,r,n,o){var s=t.lookup(e[1]);if(!s||i(s)&&0===s.length)return this.renderTokens(e[4],t,r,n,o)},m.prototype.indentPartial=function(e,t,r){for(var n=t.replace(/[^ \t]/g,""),o=e.split("\n"),i=0;i<o.length;i++)o[i].length&&(i>0||!r)&&(o[i]=n+o[i]);return o.join("\n")},m.prototype.renderPartial=function(e,t,r,n){if(r){var o=this.getConfigTags(n),i=s(r)?r(e[1]):r[e[1]];if(null!=i){var a=e[6],c=e[5],u=e[4],l=i;0==c&&u&&(l=this.indentPartial(i,u,a));var h=this.parse(l,o);return this.renderTokens(h,t,r,l,n)}}},m.prototype.unescapedValue=function(e,t){var r=t.lookup(e[1]);if(null!=r)return r},m.prototype.escapedValue=function(e,t,r){var n=this.getConfigEscape(r)||w.escape,o=t.lookup(e[1]);if(null!=o)return"number"==typeof o&&n===w.escape?String(o):n(o)},m.prototype.rawValue=function(e){return e[1]},m.prototype.getConfigTags=function(e){return i(e)?e:e&&"object"==typeof e?e.tags:void 0},m.prototype.getConfigEscape=function(e){return e&&"object"==typeof e&&!i(e)?e.escape:void 0};var w={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(e){E.templateCache=e},get templateCache(){return E.templateCache}},E=new m;w.clearCache=function(){return E.clearCache()},w.parse=function(e,t){return E.parse(e,t)},w.render=function(e,t,r,n){if("string"!=typeof e)throw new TypeError('Invalid template! Template should be a "string" but "'+(i(o=e)?"array":typeof o)+'" was given as the first argument for mustache#render(template, view, partials)');var o;return E.render(e,t,r,n)},w.escape=function(e){return String(e).replace(/[&<>"'`=\/]/g,(function(e){return h[e]}))},w.Scanner=v,w.Context=g,w.Writer=m;var x,T=w,S=r(301),_=r.n(S);!function(e){e.String="string",e.Color="color",e.ImageUrl="imageUrl",e.Choice="choice",e.ObjectList="objectList"}(x||(x={}));function B(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function O(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function R(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,o,(t=e[r](t)).done,t.value)}))}}}var P,C=function(e){return B(void 0,void 0,void 0,(function(){var t;return O(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,_()(e)];case 1:return[2,r.sent().json()];case 2:throw t=r.sent(),new Error("Cannot download manifest file "+e+": "+t);case 3:return[2]}}))}))},A=window.React,U=r.n(A),k=[],j="ResizeObserver loop completed with undelivered notifications.";!function(e){e.BORDER_BOX="border-box",e.CONTENT_BOX="content-box",e.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"}(P||(P={}));var z,I=function(e){return Object.freeze(e)},D=function(e,t){this.inlineSize=e,this.blockSize=t,I(this)},L=function(){function e(e,t,r,n){return this.x=e,this.y=t,this.width=r,this.height=n,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,I(this)}return e.prototype.toJSON=function(){var e=this;return{x:e.x,y:e.y,top:e.top,right:e.right,bottom:e.bottom,left:e.left,width:e.width,height:e.height}},e.fromRect=function(t){return new e(t.x,t.y,t.width,t.height)},e}(),M=function(e){return e instanceof SVGElement&&"getBBox"in e},F=function(e){if(M(e)){var t=e.getBBox(),r=t.width,n=t.height;return!r&&!n}var o=e,i=o.offsetWidth,s=o.offsetHeight;return!(i||s||e.getClientRects().length)},N=function(e){var t,r;if(e instanceof Element)return!0;var n=null===(r=null===(t=e)||void 0===t?void 0:t.ownerDocument)||void 0===r?void 0:r.defaultView;return!!(n&&e instanceof n.Element)},V="undefined"!=typeof window?window:{},W=new WeakMap,q=/auto|scroll/,H=/^tb|vertical/,X=/msie|trident/i.test(V.navigator&&V.navigator.userAgent),G=function(e){return parseFloat(e||"0")},$=function(e,t,r){return void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=!1),new D((r?t:e)||0,(r?e:t)||0)},J=I({devicePixelContentBoxSize:$(),borderBoxSize:$(),contentBoxSize:$(),contentRect:new L(0,0,0,0)}),Y=function(e,t){if(void 0===t&&(t=!1),W.has(e)&&!t)return W.get(e);if(F(e))return W.set(e,J),J;var r=getComputedStyle(e),n=M(e)&&e.ownerSVGElement&&e.getBBox(),o=!X&&"border-box"===r.boxSizing,i=H.test(r.writingMode||""),s=!n&&q.test(r.overflowY||""),a=!n&&q.test(r.overflowX||""),c=n?0:G(r.paddingTop),u=n?0:G(r.paddingRight),l=n?0:G(r.paddingBottom),h=n?0:G(r.paddingLeft),f=n?0:G(r.borderTopWidth),d=n?0:G(r.borderRightWidth),p=n?0:G(r.borderBottomWidth),y=h+u,b=c+l,v=(n?0:G(r.borderLeftWidth))+d,g=f+p,m=a?e.offsetHeight-g-e.clientHeight:0,w=s?e.offsetWidth-v-e.clientWidth:0,E=o?y+v:0,x=o?b+g:0,T=n?n.width:G(r.width)-E-w,S=n?n.height:G(r.height)-x-m,_=T+y+w+v,B=S+b+m+g,O=I({devicePixelContentBoxSize:$(Math.round(T*devicePixelRatio),Math.round(S*devicePixelRatio),i),borderBoxSize:$(_,B,i),contentBoxSize:$(T,S,i),contentRect:new L(h,c,T,S)});return W.set(e,O),O},K=function(e,t,r){var n=Y(e,r),o=n.borderBoxSize,i=n.contentBoxSize,s=n.devicePixelContentBoxSize;switch(t){case P.DEVICE_PIXEL_CONTENT_BOX:return s;case P.BORDER_BOX:return o;default:return i}},Q=function(e){var t=Y(e);this.target=e,this.contentRect=t.contentRect,this.borderBoxSize=I([t.borderBoxSize]),this.contentBoxSize=I([t.contentBoxSize]),this.devicePixelContentBoxSize=I([t.devicePixelContentBoxSize])},Z=function(e){if(F(e))return 1/0;for(var t=0,r=e.parentNode;r;)t+=1,r=r.parentNode;return t},ee=function(){var e=1/0,t=[];k.forEach((function(r){if(0!==r.activeTargets.length){var n=[];r.activeTargets.forEach((function(t){var r=new Q(t.target),o=Z(t.target);n.push(r),t.lastReportedSize=K(t.target,t.observedBox),o<e&&(e=o)})),t.push((function(){r.callback.call(r.observer,n,r.observer)})),r.activeTargets.splice(0,r.activeTargets.length)}}));for(var r=0,n=t;r<n.length;r++)(0,n[r])();return e},te=function(e){k.forEach((function(t){t.activeTargets.splice(0,t.activeTargets.length),t.skippedTargets.splice(0,t.skippedTargets.length),t.observationTargets.forEach((function(r){r.isActive()&&(Z(r.target)>e?t.activeTargets.push(r):t.skippedTargets.push(r))}))}))},re=[],ne=0,oe={attributes:!0,characterData:!0,childList:!0,subtree:!0},ie=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],se=function(e){return void 0===e&&(e=0),Date.now()+e},ae=!1,ce=new(function(){function e(){var e=this;this.stopped=!0,this.listener=function(){return e.schedule()}}return e.prototype.run=function(e){var t=this;if(void 0===e&&(e=250),!ae){ae=!0;var r,n=se(e);r=function(){var r=!1;try{r=function(){var e,t=0;for(te(t);k.some((function(e){return e.activeTargets.length>0}));)t=ee(),te(t);return k.some((function(e){return e.skippedTargets.length>0}))&&("function"==typeof ErrorEvent?e=new ErrorEvent("error",{message:j}):((e=document.createEvent("Event")).initEvent("error",!1,!1),e.message=j),window.dispatchEvent(e)),t>0}()}finally{if(ae=!1,e=n-se(),!ne)return;r?t.run(1e3):e>0?t.run(e):t.start()}},function(e){if(!z){var t=0,r=document.createTextNode("");new MutationObserver((function(){return re.splice(0).forEach((function(e){return e()}))})).observe(r,{characterData:!0}),z=function(){r.textContent=""+(t?t--:t++)}}re.push(e),z()}((function(){requestAnimationFrame(r)}))}},e.prototype.schedule=function(){this.stop(),this.run()},e.prototype.observe=function(){var e=this,t=function(){return e.observer&&e.observer.observe(document.body,oe)};document.body?t():V.addEventListener("DOMContentLoaded",t)},e.prototype.start=function(){var e=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),ie.forEach((function(t){return V.addEventListener(t,e.listener,!0)})))},e.prototype.stop=function(){var e=this;this.stopped||(this.observer&&this.observer.disconnect(),ie.forEach((function(t){return V.removeEventListener(t,e.listener,!0)})),this.stopped=!0)},e}()),ue=function(e){!ne&&e>0&&ce.start(),!(ne+=e)&&ce.stop()},le=function(){function e(e,t){this.target=e,this.observedBox=t||P.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return e.prototype.isActive=function(){var e,t=K(this.target,this.observedBox,!0);return e=this.target,M(e)||function(e){switch(e.tagName){case"INPUT":if("image"!==e.type)break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1}(e)||"inline"!==getComputedStyle(e).display||(this.lastReportedSize=t),this.lastReportedSize.inlineSize!==t.inlineSize||this.lastReportedSize.blockSize!==t.blockSize},e}(),he=function(e,t){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=t},fe=new WeakMap,de=function(e,t){for(var r=0;r<e.length;r+=1)if(e[r].target===t)return r;return-1},pe=function(){function e(){}return e.connect=function(e,t){var r=new he(e,t);fe.set(e,r)},e.observe=function(e,t,r){var n=fe.get(e),o=0===n.observationTargets.length;de(n.observationTargets,t)<0&&(o&&k.push(n),n.observationTargets.push(new le(t,r&&r.box)),ue(1),ce.schedule())},e.unobserve=function(e,t){var r=fe.get(e),n=de(r.observationTargets,t),o=1===r.observationTargets.length;n>=0&&(o&&k.splice(k.indexOf(r),1),r.observationTargets.splice(n,1),ue(-1))},e.disconnect=function(e){var t=this,r=fe.get(e);r.observationTargets.slice().forEach((function(r){return t.unobserve(e,r.target)})),r.activeTargets.splice(0,r.activeTargets.length)},e}(),ye=function(){function e(e){if(0===arguments.length)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if("function"!=typeof e)throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");pe.connect(this,e)}return e.prototype.observe=function(e,t){if(0===arguments.length)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!N(e))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");pe.observe(this,e,t)},e.prototype.unobserve=function(e){if(0===arguments.length)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!N(e))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");pe.unobserve(this,e)},e.prototype.disconnect=function(){pe.disconnect(this)},e.toString=function(){return"function ResizeObserver () { [polyfill code] }"},e}(),be=U()["undefined"!=typeof document&&void 0!==document.createElement?"useLayoutEffect":"useEffect"];const ve="undefined"!=typeof window&&"ResizeObserver"in window?window.ResizeObserver:ye;function ge(){}let me;const we=()=>me||(me=function(){const e=new Map,t=new ve((r=(t,r)=>{for(let n=0;n<t.length;n++){const o=e.get(t[n].target);null==o||o.forEach((e=>e(t[n],r)))}},n=[],o=null,i=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];n=t,o||(o=requestAnimationFrame((function(){o=null,r.apply(void 0,n)})))},i.cancel=function(){o&&(cancelAnimationFrame(o),o=null)},i));var r,n,o,i;return{observer:t,subscribe(r,n){var o;t.observe(r);const i=null!==(o=e.get(r))&&void 0!==o?o:[];i.push(n),e.set(r,i)},unsubscribe(r,n){var o;t.unobserve(r);const i=null!==(o=e.get(r))&&void 0!==o?o:[];if(1===i.length)return void e.delete(r);const s=i.indexOf(n);-1!==s&&i.splice(s,1),e.set(r,i)}}}());var Ee=function(e,t){const r=we(),n=(e=>{const t=A.useRef(e);return A.useEffect((()=>{t.current=e})),t})(t);return be((()=>{let t=!1;const o=e&&"current"in e?e.current:e;if(!o)return ge;function i(e,r){t||n.current(e,r)}return r.subscribe(o,i),()=>{t=!0,r.unsubscribe(o,i)}}),[e,r,n]),r.observer},xe=t=>{const[r,n]=(0,A.useState)(null),o=(0,A.useRef)(null);Ee(o,(e=>{r||n(e.contentRect)}));const[i,s]=(0,A.useState)(null),a=(0,A.useRef)(null);Ee(a,(e=>s(e.contentRect)));let c={position:"relative"},u={position:"absolute"};if(i&&r){const e=i.width/r.width;c={transform:`scale(${e})`,transformOrigin:"top left",height:r.height*e+"px"},u={}}return(0,e.createElement)("div",{ref:a,style:c},(0,e.createElement)("div",{ref:o,style:u},t.children))};const Te=t=>(0,e.createElement)("div",{style:{zIndex:t.current===t.me?2:1,position:"absolute",left:0,right:0}},t.content&&(0,e.createElement)("iframe",{scrolling:"no",srcDoc:t.content,width:t.width,height:t.height,style:{border:0},onLoad:()=>{t.onReady()}}));var Se=t=>{const[r,n]=(0,A.useState)(!0),[o,i]=(0,A.useState)(null),[s,a]=(0,A.useState)(null);return(0,A.useEffect)((()=>{const e=(c=t.template,u=t.parameters,l={width:t.width,height:t.height},h=t.templateBaseUrl,function(e,t,r){return T.render('\n<html>\n  <head>\n    <meta name="viewport" content="width={{ resoc_imageWidth }}, initial-scale=1">\n  </head>\n  <body>\n    {{#resoc_baseUrl}}\n    <base href="{{{ resoc_baseUrl }}}" />\n    {{/resoc_baseUrl}}\n    <style>\n      html {\n        width: {{ resoc_imageWidth }}px;\n        height: {{ resoc_imageHeight }}px;\n        font-size: 3vw;\n        display: flex;\n        align-items: stretch;\n        background-color: white;\n      }\n\n      body {\n        flex: 1 1 0;\n        min-width: 0;\n        margin: 0;\n        display: flex;\n        align-items: stretch;\n      }\n\n      body > div {\n        flex: 1 1 0;\n        min-width: 0;\n      }\n    </style>\n    <style>\n      {{> styles}}\n    </style>\n    {{> content}}\n  </body>\n</html>',r,t.partials)}(0,c,function(e,t,r){return Object.assign({},e,{resoc_imageWidth:t.width,resoc_imageHeight:t.height,resoc_baseUrl:r})}(u,l,h)));var c,u,l,h;r?e!==s?a(e):n(!1):e!==o?i(e):n(!0)}),[t.template,t.parameters,t.width,t.height]),(0,e.createElement)("div",{style:{position:"relative",width:t.width,height:t.height,backgroundColor:"white"}},(0,e.createElement)(Te,{me:"a",current:r?"a":"b",content:o,width:t.width,height:t.height,onReady:()=>n(!0)}),(0,e.createElement)(Te,{me:"b",current:r?"a":"b",content:s,width:t.width,height:t.height,onReady:()=>n(!1)}))},_e=t=>{const[r,n]=(0,A.useState)(null);return(0,A.useEffect)((()=>{t.templateManifestUrl&&!r&&(async()=>{const e=await(r=t.templateManifestUrl,B(void 0,void 0,void 0,(function(){var e,t,n,o,i,s,a,c,u,l,h,f;return O(this,(function(d){switch(d.label){case 0:return[4,C(r)];case 1:e=d.sent(),t={},d.label=2;case 2:d.trys.push([2,9,10,15]),n=R(Object.keys(e.partials)),d.label=3;case 3:return[4,n.next()];case 4:return(o=d.sent()).done?[3,8]:(i=o.value,[4,_()((p=e.partials[i],y=r,(b=y).toLowerCase().startsWith("http://")||b.toLowerCase().startsWith("https://")||b.toLowerCase().startsWith("//")||(y=function(e){return new URL(e,document.baseURI).href}(y)),new URL(p,y).href))]);case 5:return s=d.sent(),a=t,c=i,[4,s.text()];case 6:a[c]=d.sent(),d.label=7;case 7:return[3,3];case 8:return[3,15];case 9:return u=d.sent(),h={error:u},[3,15];case 10:return d.trys.push([10,,13,14]),o&&!o.done&&(f=n.return)?[4,f.call(n)]:[3,12];case 11:d.sent(),d.label=12;case 12:return[3,14];case 13:if(h)throw h.error;return[7];case 14:return[7];case 15:return l=[],e.parameters.forEach((function(e){l.push(e)})),[2,{partials:t,parameters:l}]}var p,y,b}))})));var r;n(e),t.onTemplateLoaded&&t.onTemplateLoaded(e)})()}),[t.templateManifestUrl]),t.templateManifestUrl&&r?(0,e.createElement)(xe,null,(0,e.createElement)(Se,{templateBaseUrl:t.templateManifestUrl,template:r,parameters:t.paramValues,width:1200,height:630})):(0,e.createElement)("div",null,"Loading template...")},Be=window.wp.data;const Oe=(0,Be.withSelect)((e=>{let t,r,n;return t=void 0!==e("core/editor").getPostEdits().title?e("core/editor").getPostEdits().title:e("core/editor").getCurrentPost().title,r=void 0!==e("core/editor").getPostEdits().excerpt?e("core/editor").getPostEdits().excerpt:e("core/editor").getCurrentPost().excerpt,n=void 0!==e("core/editor").getPostEdits().featured_media?e("core/editor").getPostEdits().featured_media:e("core/editor").getCurrentPost().featured_media,n&&e("core").getMedia(n),{title:t,description:r,featuredMediaId:n}}))((0,Be.withSelect)(((e,t)=>{const r=t.featuredMediaId?e("core").getMedia(t.featuredMediaId):null;return{mainImageUrl:r?r.source_url:null,...t}}))((t=>(0,e.createElement)(_e,{templateManifestUrl:`${template_options.templatesBaseUrl}/templates/${template_options.template}/content/resoc.manifest.json`,paramValues:{title:t.title,description:t.description,mainImageUrl:t.mainImageUrl,textColor:template_options.textColor,backgroundColor:template_options.backgroundColor,brandName:template_options.brandName,textDirection:template_options.textDirection,logoUrl:template_options.logoUrl}}))));(0,t.registerPlugin)("resoc-preview",{render:()=>(0,e.createElement)(n.PluginDocumentSettingPanel,{name:"my-plugin-sidebar",icon:"none",title:"Social image"},(0,e.createElement)(Oe,null))})}()}();
  • resoc/trunk/includes/class-resoc-utils.php

    r2612027 r2615551  
    5656  }
    5757
    58   public static function create_social_image( $request ) {
    59     $response = wp_remote_post('https://api.resoc.io/images', array(
     58  public static function create_social_image( $template, $paramValues ) {
     59    $response = wp_remote_post( Resoc::IMAGE_ENGINE_BASE_URL . "/templates/$template/images/open-graph.jpg", array(
    6060      'headers' => array('Content-Type' => 'application/json; charset=utf-8'),
    61       'body'    => json_encode( $request ),
    62       'timeout' => 10
     61      'body'    => json_encode( $paramValues ),
     62      'timeout' => 30 // Image generation can take 10-20 seconds, depending on the engine
    6363    ));
    6464
  • resoc/trunk/includes/class-resoc.php

    r2548884 r2615551  
    229229  const POST_META_OG_IMAGE_ID         = 'resoc_og_image_id';
    230230  const POST_META_LATEST_REQUEST_HASH = 'resoc_latest_request_hash';
     231
     232  const IMAGE_ENGINE_BASE_URL = 'https://free-engine.resoc.io/';
    231233}
  • resoc/trunk/resoc.php

    r2612027 r2615551  
    1717 * Plugin URI:        https://resoc.io/resoc-uri/
    1818 * Description:       Improve the images used to illustrate your content when it is share on social networks and messaging services.
    19  * Version:           1.0.12
     19 * Version:           1.0.13
    2020 * Author:            Resoc
    2121 * Author URI:        https://resoc.io/
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'RESOC_VERSION', '1.0.12' );
     38define( 'RESOC_VERSION', '1.0.13' );
    3939
    4040/**
Note: See TracChangeset for help on using the changeset viewer.