PluginProbe ʕ •ᴥ•ʔ
AI Engine – The Chatbot, AI Framework & MCP for WordPress / 0.4.8
AI Engine – The Chatbot, AI Framework & MCP for WordPress v0.4.8
3.5.9 3.5.8 3.5.7 3.5.6 3.5.5 3.5.4 3.5.3 3.5.2 3.5.1 3.5.0 3.4.9 3.4.8 3.4.7 0.2.1 1.6.91 0.2.2 1.6.92 0.2.3 1.6.93 0.2.4 1.6.94 0.2.5 1.6.95 0.2.6 1.6.96 0.2.7 1.6.97 0.2.8 1.6.98 0.2.9 1.6.99 0.3.0 1.7.0 0.3.1 1.7.1 0.3.2 1.7.2 0.3.3 1.7.3 0.3.4 1.7.4 0.3.5 1.7.5 0.3.6 1.7.6 0.4.0 1.7.7 0.4.1 1.7.8 0.4.2 1.7.9 0.4.3 1.8.0 0.4.4 1.8.1 0.4.5 1.8.2 0.4.6 1.8.3 0.4.7 1.8.4 0.4.8 1.8.5 0.4.9 1.8.6 0.5.0 1.8.7 0.5.1 1.8.8 0.5.2 1.8.9 0.5.3 1.9.0 0.5.4 1.9.1 0.5.5 1.9.2 0.5.6 1.9.3 0.5.7 1.9.4 0.5.8 1.9.5 0.5.9 1.9.6 0.6.0 1.9.7 0.6.1 1.9.8 0.6.2 1.9.81 0.6.3 1.9.82 0.6.4 1.9.83 0.6.5 1.9.84 0.6.6 1.9.85 0.6.7 1.9.86 0.6.8 1.9.87 0.6.9 1.9.88 0.7.0 1.9.89 0.7.1 1.9.90 0.7.2 1.9.91 0.7.3 1.9.92 0.7.4 1.9.93 0.7.5 1.9.94 0.7.6 1.9.95 0.7.7 1.9.96 0.7.8 1.9.97 0.7.9 1.9.98 0.8.0 1.9.99 0.8.1 2.0.0 0.8.2 2.0.1 0.8.3 2.0.2 0.8.4 2.0.3 0.8.5 2.0.4 0.8.6 2.0.5 0.8.7 2.0.6 0.8.8 2.0.7 0.8.9 2.0.8 0.9.0 2.0.9 0.9.2 2.1.0 0.9.3 2.1.1 0.9.4 2.1.2 0.9.5 2.1.3 0.9.6 2.1.4 0.9.7 2.1.5 0.9.8 2.1.6 0.9.81 2.1.7 0.9.82 2.1.8 0.9.83 2.1.9 0.9.84 2.2.0 0.9.85 2.2.1 0.9.86 2.2.2 0.9.87 2.2.3 0.9.88 2.2.4 0.9.89 2.2.5 0.9.9 2.2.51 0.9.91 2.2.52 0.9.92 2.2.53 0.9.93 2.2.54 0.9.94 2.2.56 0.9.95 2.2.57 0.9.96 2.2.6 0.9.97 2.2.60 0.9.98 2.2.61 0.9.99 2.2.62 1.0.0 2.2.63 1.0.01 2.2.70 1.0.1 2.2.80 1.0.2 2.2.81 1.0.3 2.2.90 1.0.4 2.2.91 1.0.5 2.2.92 1.0.6 2.2.93 1.0.7 2.2.94 1.0.8 2.2.95 1.0.9 2.3.0 1.1.0 2.3.1 1.1.1 2.3.2 1.1.2 2.3.3 1.1.3 2.3.4 1.1.4 2.3.5 1.1.5 2.3.6 1.1.6 2.3.7 1.1.7 2.3.8 1.1.8 2.3.9 1.1.9 2.4.0 1.2.0 2.4.1 1.2.1 2.4.2 1.2.2 2.4.3 1.2.21 2.4.4 1.2.3 2.4.5 1.2.30 2.4.6 1.3.0 2.4.7 1.3.1 2.4.8 1.3.2 2.4.9 1.3.3 2.5.0 1.3.31 2.5.1 1.3.32 2.5.2 1.3.33 2.5.3 1.3.34 2.5.4 1.3.35 2.5.5 1.3.36 2.5.6 1.3.37 2.5.7 1.3.38 2.5.8 1.3.39 2.5.9 1.3.40 2.6.0 1.3.41 2.6.1 1.3.42 2.6.2 1.3.43 2.6.3 1.3.44 2.6.5 1.3.45 2.6.6 1.3.46 2.6.7 1.3.47 2.6.8 1.3.48 2.6.9 1.3.49 2.7.0 1.3.50 2.7.1 1.3.51 2.7.2 1.3.52 2.7.3 1.3.53 2.7.4 1.3.54 2.7.5 1.3.56 2.7.6 1.3.57 2.7.7 1.3.58 2.7.8 1.3.59 2.7.9 1.3.60 2.8.0 1.3.61 2.8.1 1.3.62 2.8.2 1.3.63 2.8.3 1.3.64 2.8.4 1.3.65 2.8.5 1.3.66 2.8.6 1.3.67 2.8.7 1.3.68 2.8.8 1.3.69 2.8.9 1.3.70 2.9.0 1.3.71 2.9.1 1.3.72 2.9.2 1.3.73 2.9.3 1.3.74 2.9.4 1.3.75 2.9.5 1.3.76 2.9.6 1.3.77 2.9.7 1.3.78 2.9.8 1.3.79 2.9.9 1.3.80 3.0.0 1.3.81 3.0.1 1.3.82 3.0.2 1.3.83 3.0.3 1.3.84 3.0.4 1.3.85 3.0.5 1.3.86 3.0.6 1.3.87 3.0.7 1.3.88 3.0.8 1.3.89 3.0.9 1.3.90 3.1.0 1.3.91 3.1.1 1.3.92 3.1.2 1.3.93 3.1.3 1.3.94 3.1.4 1.3.95 3.1.5 1.3.96 3.1.6 1.3.97 3.1.7 1.3.98 3.1.8 1.3.99 3.1.9 1.4.0 3.2.0 1.4.1 3.2.1 1.4.2 3.2.2 1.4.3 3.2.3 1.4.4 3.2.4 1.4.5 3.2.5 1.4.6 3.2.6 1.4.7 3.2.7 1.4.8 3.2.8 1.4.9 3.2.9 1.5.0 3.3.0 1.5.1 3.3.1 1.5.2 3.3.2 1.5.3 3.3.3 1.5.4 3.3.4 1.5.5 3.3.5 1.5.6 3.3.6 1.5.7 3.3.7 1.5.8 3.3.8 1.5.9 3.3.9 1.6.0 3.4.0 1.6.1 3.4.1 1.6.2 3.4.2 1.6.3 3.4.3 1.6.5 3.4.4 1.6.51 3.4.5 1.6.52 3.4.6 1.6.53 1.6.54 1.6.55 1.6.56 1.6.57 1.6.58 1.6.59 1.6.60 1.6.61 1.6.62 1.6.63 1.6.64 1.6.65 1.6.66 1.6.67 1.6.68 trunk 1.6.69 0.0.1 1.6.70 0.0.2 1.6.71 0.0.3 1.6.72 0.0.4 1.6.73 0.0.5 1.6.74 0.0.6 1.6.75 0.0.7 1.6.76 0.0.8 1.6.77 0.0.9 1.6.78 0.1.0 1.6.79 0.1.1 1.6.81 0.1.2 1.6.82 0.1.3 1.6.83 0.1.4 1.6.84 0.1.5 1.6.85 0.1.6 1.6.86 0.1.7 1.6.87 0.1.8 1.6.88 0.1.9 1.6.89 0.2.0 1.6.90
ai-engine / app / index.js
ai-engine / app Last commit date
index.js 3 years ago vendor.js 3 years ago
index.js
8 lines
1 /*! For license information please see index.js.LICENSE.txt */
2 (()=>{"use strict";var e,t={1058:(e,t,n)=>{var r,a,o,i,c,l=n(6488),u=n(5945),s=n(3757),f=n(6160),m=n(749),h=n(1630),p=n(4694),d=n(1254),y=n(8168),v=n(5979),g=n(1488),b=n(7818),w=n(537),E=n(8694),R=mwai_meow_plugin.prefix,x=mwai_meow_plugin.domain,k=mwai_meow_plugin.rest_url.replace(/\/+$/,""),_=mwai_meow_plugin.api_url.replace(/\/+$/,""),S=mwai_meow_plugin.plugin_url.replace(/\/+$/,""),O="1"===mwai_meow_plugin.is_pro,L=O&&"1"===mwai_meow_plugin.is_registered,P=mwai_meow_plugin.rest_nonce,j=mwai_meow_plugin.options,T=mwai_meow_plugin.session,C=mwai_meow_plugin.pricing,N=n(8406),A=n(2788);function I(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var F=A.ZP.div(r||(r=I(["\n color: white;\n padding: 15px;\n margin-bottom: -15px;\n\n a {\n color: #7dedff;\n text-decoration: none;\n }\n\n p {\n font-size: 15px;\n }\n"]))),G=(0,A.ZP)(w.v)(a||(a=I(["\n\n .nui-block-title {\n display: none;\n }\n\n .plugin-desc {\n display: flex;\n flex-direction: column;\n justify-content: center;\n margin-left: 20px;\n\n }\n\n .nui-block-content {\n display: flex;\n padding: 10px;\n item-align: center;\n\n h2 {\n color: #055082;\n font-size: 18px;\n margin: 0;\n\n a {\n text-decoration: none;\n }\n }\n\n p {\n margin: 0px;\n font-size: 15px;\n }\n }\n"]))),z=A.ZP.img(o||(o=I(["\n width: 85px;\n height: 85px;\n padding-right: 10px;\n"]))),M=A.ZP.div(i||(i=I(["\n\n margin: 15px;\n\n .center {\n background: white;\n border-radius: 10px;\n padding: 10px;\n max-width: 100%\n overflow: none;\n\n h2 {\n font-size: 26px;\n }\n\n table {\n width: 100%;\n\n tr td:first-child {\n width: 220px;\n font-weight: bold;\n color: #1e7cba;\n }\n\n * {\n overflow-wrap: anywhere;\n }\n }\n }\n\n hr {\n border-color: #1e7cba;\n }\n"]))),B=A.ZP.ul(c||(c=I(["\n margin-top: 10px;\n background: rgb(0, 72, 88);\n padding: 10px;\n color: rgb(58, 212, 58);\n max-height: 600px;\n min-height: 200px;\n display: block;\n font-family: monospace;\n font-size: 12px;\n white-space: pre;\n overflow-x: auto;\n width: calc(100vw - 276px);\n\n .log-date {\n color: white;\n margin-left: 8px;\n }\n\n .log-type {\n background: #0000004d;\n padding: 2px 5px;\n border-radius: 8px;\n text-transform: uppercase;\n }\n\n .log-content {\n display: block;\n }\n\n .log-warning .log-type {\n background: #ccb028;\n color: white;\n }\n\n .log-fatal .log-type {\n background: #cc2828;\n color: white;\n }\n"])));function D(e){return D="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},D(e)}function q(){q=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function m(){}function h(){}function p(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=p.prototype=m.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==D(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:h,configurable:!0}),h.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function Y(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function W(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Y(o,r,a,i,c,"next",e)}function c(e){Y(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Z(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||H(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 H(e,t){if(e){if("string"==typeof e)return U(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?U(e,t):void 0}}function U(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var V=wp.element,J=V.useState,$=V.useEffect,K="".concat(k,"/meow-common/v1"),Q=function(e){var t=e.request,n=e.title,r=e.max,a=Z(J(!1),2),o=a[0],i=a[1],c=Z(J([]),2),l=c[0],u=c[1],s=l.length>0?l.reduce((function(e,t){return e+t})):0,m=l.length>0?Math.ceil(s/l.length):0,h=!l.length&&o;return $((function(){o&&setTimeout(W(q().mark((function e(){var n,r,a;return q().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(new Date).getTime(),e.next=3,(0,E.PV)("".concat(K,"/").concat(t),{method:"POST",nonce:P});case 3:r=(new Date).getTime(),a=r-n,u((function(e){return[].concat(function(e){if(Array.isArray(e))return U(e)}(t=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||H(t)||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.")}(),[a]);var t}));case 6:case"end":return e.stop()}}),e)}))),1e3)}),[l]),React.createElement(F,{style:{width:200,textAlign:"center"}},React.createElement(f.O,{h2:!0,style:{color:"white"}},n),React.createElement(N._,{size:200,value:h?r:m,max:r},React.createElement("span",{style:{fontSize:20}},h?"START":m+" ms"),React.createElement("span",{style:{fontSize:12}},h?"YOUR ENGINE":l.length+" requests")),React.createElement(b._,{style:{width:"100%",marginTop:10},color:o?"#cc3627":"#ccb027",onClick:function(){o||u([]),i(!o)}},o?"Stop":"Start"))};function X(e){return X="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},X(e)}function ee(){ee=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function m(){}function h(){}function p(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=p.prototype=m.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==X(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:h,configurable:!0}),h.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function te(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ne(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?te(Object(n),!0).forEach((function(t){re(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):te(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function re(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==X(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==X(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===X(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ae(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function oe(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){ae(o,r,a,i,c,"next",e)}function c(e){ae(o,r,a,i,c,"throw",e)}i(void 0)}))}}function ie(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ce(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 ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var le=wp.element,ue=le.useState,se=le.useEffect;_&&k&&S||console.error("[@common/dashboard] apiUrl, restUrl and pluginUrl are mandatory.");var fe="".concat(k,"/meow-common/v1"),me=React.createElement(F,null,React.createElement(f.O,{p:!0},"Meow Apps is a suite of plugins for photography, imaging, optimization, and SEO, run by ",React.createElement("a",{target:"_blank",href:"https://offbeatjapan.org"},"Jordy Meow"),", a photographer and developer in Japan. The goal is to improve and speed up your website. Learn more at ",React.createElement("a",{href:"http://meowapps.com",target:"_blank"},"Meow Apps"),".")),he=React.createElement(F,null,React.createElement(f.O,{p:!0},"⭐️ The ",React.createElement("b",null,"Empty Request Time")," helps you analyzing the raw performance of your install by giving you the average time it takes to run an empty request to your server. You can try to disable some plugins then start this again to see how it modifies the results. Keep it absolutely under 2,000 ms! That said, I recommend it to keep it below 500ms."),React.createElement(f.O,{p:!0},"⭐️ ",React.createElement("b",null,"File Operation Time")," creates a temporary size of 10MB every time."),React.createElement(f.O,{p:!0},"⭐️ ",React.createElement("b",null,"SQL Request Time")," counts the number of posts. Those two should be very fast, and almost the same as the ",React.createElement("b",null,"Empty Request Time"),".")),pe=React.createElement(F,null,React.createElement(f.O,{p:!0},"Keep your WordPress install simple and efficient by using only necessary plugins and a reliable hosting service. Avoid trying to self-host unless you have professional experience. Follow best practices and stay up-to-date with the latest recommendations on the Meow Apps website.",React.createElement("ul",null,React.createElement("li",null,"💜 ",React.createElement("a",{href:"https://meowapps.com/tutorial-improve-seo-wordpress/",target:"_blank"},"SEO Checklist & Optimization")),React.createElement("li",null,"💜 ",React.createElement("a",{href:"https://meowapps.com/tutorial-faster-wordpress-optimize/",target:"_blank"},"Optimize your WordPress Speed")),React.createElement("li",null,"💜 ",React.createElement("a",{href:"https://meowapps.com/tutorial-optimize-images-wordpress/",target:"_blank"},"Optimize Images (CDN, and so on)")),React.createElement("li",null,"💜 ",React.createElement("a",{href:"https://meowapps.com/tutorial-hosting-service-wordpress/",target:"_blank"},"The Best Hosting Services for WordPress"))))),de=["".concat(fe,"/all_settings/"),{headers:{"X-WP-Nonce":P}}],ye=function(){var e=ie(ue(!1),2),t=e[0],n=e[1],r=(0,s.ZP)(de,E.SG),a=r.data,o=r.mutate,i=r.error,c=null==a?void 0:a.data,l=null==c?void 0:c.meowapps_hide_meowapps,u=null==c?void 0:c.force_sslverify,R=ie(ue(!1),2),x=R[0],k=R[1],_=ie(ue([]),2),O=_[0],L=_[1],j=ie(ue(""),2),T=j[0],C=j[1];se((function(){i&&!t&&(n(!0),console.error("Error from UseSWR",i.message))}),[i]),se((function(){var e=document.getElementById("meow-common-phpinfo");C(e.innerHTML)}),[]);var N=function(){var e=oe(ee().mark((function e(t,n){var r,i;return ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=ne({},a.data))[n]=t,o(ne(ne({},a),{},{data:r}),!1),k(!0),e.next=6,(0,E.PV)("".concat(fe,"/update_option"),{method:"POST",nonce:P,json:{name:n,value:t}});case 6:i=e.sent,k(!1),i.success||alert(i.message),o();case 10:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),A=function(){var e=oe(ee().mark((function e(){var t,n;return ee().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return k(!0),e.next=3,(0,E.PV)("".concat(fe,"/error_logs"),{method:"POST",nonce:P});case 3:t=e.sent,n=t&&t.data?t.data:[],L(n.reverse()),k(!1);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),I=React.createElement(m.r,{title:"Main Menu"},React.createElement(h.l,{max:"1"},React.createElement(p.P,{id:"meowapps_hide_meowapps",label:"Hide (Not Recommended)",description:React.createElement(f.O,{p:!0},"This will hide the Meow Apps Menu (on the left side) and everything it contains. You can re-enable it through though an option that will be added in Settings → General."),value:"1",disabled:x,checked:l,onChange:N}))),D=React.createElement(m.r,{title:"SSL Verify"},React.createElement(h.l,{max:"1"},React.createElement(p.P,{id:"force_sslverify",label:"Force (Not Recommended)",description:React.createElement(f.O,{p:!0},"This will enforce the usage of SSL when checking the license or updating the plugin."),value:"1",disabled:x,checked:u,onChange:N})));return React.createElement(d.s,{showRestError:t},React.createElement(y.B,{title:"The Dashboard"}),React.createElement(v.o,null,React.createElement(v.z,{full:!0},React.createElement(g.c,null,React.createElement(g.P,{title:"Meow Apps"},me,React.createElement(v.o,null,React.createElement(v.z,{minimal:!0},React.createElement(G,{title:"Media Cleaner",className:"primary"},React.createElement(z,{src:"".concat(S,"/common/img/media-cleaner.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/media-cleaner/"},"Media Cleaner")),React.createElement("p",null,"Remove the useless media entries and files."))),React.createElement(G,{title:"Database Cleaner",className:"primary"},React.createElement(z,{src:"".concat(S,"/common/img/database-cleaner.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/database-cleaner/"},"Database Cleaner")),React.createElement("p",null,"Clean your database and make it faster."))),React.createElement(G,{title:"Media File Renamer",className:"primary"},React.createElement(z,{src:"".concat(S,"/common/img/media-file-renamer.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/media-file-renamer/"},"Media File Renamer")),React.createElement("p",null,"Rename your filenames for a better SEO."))),React.createElement(G,{title:"Social Engine",className:"primary"},React.createElement(z,{src:"".concat(S,"/common/img/social-engine.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/social-engine/"},"Social Engine")),React.createElement("p",null,"Share your articles and photos on the SNS."))),React.createElement(G,{title:"Meow Analytics",className:"primary"},React.createElement(z,{src:"".concat(S,"/common/img/meow-analytics.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-analytics/"},"Meow Analytics")),React.createElement("p",null,"Google Analytics for your website.")))),React.createElement(v.z,{minimal:!0},React.createElement(G,{title:"Photo Engine",className:"primary"},React.createElement(z,{src:"".concat(S,"/common/img/wplr-sync.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/wplr-sync/"},"Photo Engine")),React.createElement("p",null,"Organize your photos in folders and collections.",React.createElement("br",null),"Synchronize with Lightroom."))),React.createElement(G,{title:"Meow Gallery",className:"primary"},React.createElement(z,{src:"".concat(S,"/common/img/meow-gallery.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-gallery/"},"Meow Gallery")),React.createElement("p",null,"Fast and beautiful gallery with many layouts."))),React.createElement(G,{title:"Meow Lightbox",className:"primary"},React.createElement(z,{src:"".concat(S,"/common/img/meow-lightbox.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-lightbox/"},"Meow Lightbox")),React.createElement("p",null,"Sleek and performant lightbox with EXIF support."))),React.createElement(G,{title:"Perfect Images (Retina)",className:"primary"},React.createElement(z,{src:"".concat(S,"/common/img/wp-retina-2x.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/wp-retina-2x/"},"Perfect Images")),React.createElement("p",null,"Optimize your thumbnails, retina, replace images, etc."))),React.createElement(G,{title:"Contact Form Block",className:"primary"},React.createElement(z,{src:"".concat(S,"/common/img/contact-form-block.png")}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/contact-form-block/"},"Contact Form Block")),React.createElement("p",null,"Simple and straightforward contact form, in one block.")))))),React.createElement(g.P,{title:"Performance"},he,React.createElement("div",{style:{display:"flex",justifyContent:"space-around",marginBottom:25}},React.createElement(Q,{title:"Empty Request Time",request:"empty_request",max:2500}),React.createElement(Q,{title:"File Operation Time",request:"file_operation",max:2600}),React.createElement(Q,{title:"SQL Request Time",request:"sql_request",max:2800})),pe),React.createElement(g.P,{title:"PHP Info"},React.createElement(M,{dangerouslySetInnerHTML:{__html:T}})),React.createElement(g.P,{title:"PHP Error Logs"},React.createElement(F,null,React.createElement(b._,{style:{marginBottom:10},color:"#ccb027",onClick:A},"Load PHP Error Logs"),React.createElement(B,null,O.map((function(e){return React.createElement("li",{class:"log-".concat(e.type)},React.createElement("span",{class:"log-type"},e.type),React.createElement("span",{class:"log-date"},e.date),React.createElement("span",{class:"log-content"},e.content))}))),React.createElement(f.O,{p:!0},"If nothing appears after loading, it might be that your hosting service does not allow you to access the PHP error logs directly from here. Please contact them directly."))),React.createElement(g.P,{title:"Settings"},React.createElement(w.v,{title:"Settings",className:"primary"},I,D))))))},ve=n(1492),ge=n(9137),be=n(3565),we=n(477),Ee=n(3506),Re=n(1203);function xe(e){return xe="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},xe(e)}function ke(){ke=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function m(){}function h(){}function p(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=p.prototype=m.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==xe(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:h,configurable:!0}),h.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function _e(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function Se(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){_e(o,r,a,i,c,"next",e)}function c(e){_e(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Oe(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Le(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Le(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 Le(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Pe=wp.element,je=Pe.useState,Te=Pe.useEffect,Ce="".concat(k,"/meow-licenser/").concat(R,"/v1"),Ne=function(){var e=Oe(je(!1),2),t=e[0],n=e[1],r=Oe(je(!1),2),a=r[0],o=r[1],i=Oe(je(null),2),c=i[0],l=i[1],u=Oe(je(null),2),s=u[0],h=u[1],p=Oe(je(""),2),d=p[0],y=p[1],v=L&&(!s||"valid"!==s.license),g=function(){var e=Se(ke().mark((function e(){var t;return ke().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(O){e.next=2;break}return e.abrupt("return");case 2:return n(!0),e.next=5,(0,E.PV)("".concat(Ce,"/get_license"),{method:"POST",nonce:P});case 5:t=e.sent,h(t.data),t.data.key&&y(t.data.key),n(!1);case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),R=function(){var e=Se(ke().mark((function e(){return ke().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n(!0),e.next=3,(0,E.PV)("".concat(Ce,"/set_license"),{method:"POST",nonce:P,json:{serialKey:null}});case 3:e.sent.success&&(y(""),h(null),l("licenseRemoved")),n(!1);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),x=function(){var e=Se(ke().mark((function e(){var t;return ke().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n(!0),e.next=3,(0,E.PV)("".concat(Ce,"/set_license"),{nonce:P,json:{serialKey:d,override:!0}});case 3:(t=e.sent).success&&(h(t.data),t.data&&!t.data.issue&&l("licenseAdded")),n(!1);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),k=function(){var e=Se(ke().mark((function e(){var t;return ke().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("MEOW_OVERRIDE"!==d){e.next=5;break}return o(!0),h(null),y(""),e.abrupt("return");case 5:return n(!0),e.next=8,(0,E.PV)("".concat(Ce,"/set_license"),{method:"POST",nonce:P,json:{serialKey:d}});case 8:(t=e.sent).success&&(h(t.data),t.data&&!t.data.issue&&l("licenseAdded")),n(!1);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();Te((function(){g()}),[]);var _=v?"Forced License":L?"Enabled":"Disabled",S=v||s&&"valid"===s.license,j="Your license is active. Thanks a lot for your support :)";v&&s&&s.check_url&&(j=React.createElement(React.Fragment,null,React.createElement("span",null,j),React.createElement("br",null),React.createElement("small",null,"This license was enabled manually. To check your license status, please click ",React.createElement("a",{target:"_blank",href:s.check_url+"&cache="+642e3*Math.random()},"here"),"."))),S||(s?"no_activations_left"===s.issue?j=React.createElement("span",null,"There are no activations left for this license. You can visit your account at the ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com"},"Meow Apps Store"),", unregister a site, and click on ",React.createElement("i",null,"Retry to validate"),"."):"expired"===s.issue?j=React.createElement("span",null,"Your license has expired. You can get another license or renew the current one by visiting your account at the ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com"},"Meow Apps Store"),"."):"missing"===s.issue?j="This license does not exist.":"disabled"===s.issue?j="This license has been disabled.":"item_name_mismatch"===s.issue?j="This license seems to be for a different plugin... isn't it? :)":"forced"===s.issue?j="ABC":(j=React.createElement("span",null,"There is an unknown error related to the system or this serial key. Really sorry about this! Make sure your security plugins and systems are off temporarily. If you are still experiencing an issue, please ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com/contact/"},"contact us"),"."),console.error({license:s})):j="Unknown error :(");var T=React.createElement(w.v,{title:"Pro Version (Not Installed)",className:"primary"},"You will find more information about the Pro Version ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com"},"here"),". If you actually bought the Pro Version already, please remove the current plugin and download the Pro Version from your account at the ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com/"},"Meow Apps Store"),"."),C=React.createElement(w.v,{title:"Pro Version (".concat(_,")"),busy:t,className:"primary"},React.createElement(m.r,{title:"Serial Key",style:{fontWeight:"bold"}},React.createElement(ve.A,{id:"mfrh_pro_serial",name:"mfrh_pro_serial",disabled:t,value:d,onChange:function(e){return y(e)},placeholder:""})),s&&!S&&React.createElement(Ee.G,null,j),s&&S&&React.createElement(Ee.C,null,j),!s&&React.createElement(f.O,{p:!0},"Insert your serial key above. If you don't have one yet, you can get one ",React.createElement("a",{href:"https://meowapps.com"},"here"),". If there was an error during the validation, try the ",React.createElement("i",null,"Retry")," to ",React.createElement("i",null,"validate")," button."),React.createElement(m.r,{contentAlign:"right"},s&&!S&&React.createElement(b._,{className:"secondary",disabled:t||!d,onClick:k},"Retry to validate"),s&&s.key===d&&React.createElement(b._,{className:"secondary",disabled:t||!d,onClick:R},"Remove License"),React.createElement(b._,{disabled:t||!d||s&&s.key===d,onClick:k},"Validate License"),a&&!S&&React.createElement(b._,{disabled:t||!d||s&&s.key===d,onClick:x,className:"danger"},"Force License")),React.createElement(Re.L,{isOpen:"licenseAdded"===c,title:"Thank you :)",content:"The Pro features have been enabled. This page should be now reloaded.",ok:"Reload",onOkClick:function(){return location.reload()}}),React.createElement(Re.L,{isOpen:"licenseRemoved"===c,title:"Goodbye :(",content:"The Pro features have been disabled. This page should be now reloaded.",ok:"Reload",onOkClick:function(){return location.reload()}}));return O?C:T},Ae=[{id:"text-davinci-003",name:"text-davinci-003",short:"davinci",description:"Most capable GPT-3 model. Can do any task the other models can do, often with higher quality, longer output and better instruction-following. Also supports inserting completions within text.",strength:"Complex intent, cause and effect, summarization for audience"},{id:"text-curie-001",name:"text-curie-001",short:"curie",description:"Very capable, but faster and lower cost than Davinci.",strength:"Language translation, complex classification, text sentiment, summarization"},{id:"text-babbage-001",name:"text-babbage-001",short:"babbage",description:"Capable of straightforward tasks, very fast, and lower cost.",strength:"Moderate classification, semantic search classification"},{id:"text-ada-001",name:"text-ada-001",short:"ada",description:"Capable of very simple tasks, usually the fastest model in the GPT-3 series, and lowest cost.",strength:"Parsing text, simple classification, address correction, keywords"}],Ie=[{value:"informative",label:"Informative"},{value:"descriptive",label:"Descriptive"},{value:"creative",label:"Creative"},{value:"narrative",label:"Narrative"},{value:"persuasive",label:"Persuasive"},{value:"reflective",label:"Reflective"},{value:"argumentative",label:"Argumentative"},{value:"analytical",label:"Analytical"},{value:"evaluative",label:"Evaluative"},{value:"journalistic",label:"Journalistic"},{value:"technical",label:"Technical"}],Fe=[{value:"neutral",label:"Neutral"},{value:"formal",label:"Formal"},{value:"assertive",label:"Assertive"},{value:"cheerful",label:"Cheerful"},{value:"humorous",label:"Humorous"},{value:"informal",label:"Informal"},{value:"inspirational",label:"Inspirational"},{value:"professional",label:"Professional"},{value:"confvalueent",label:"Confvalueent"},{value:"emotional",label:"Emotional"},{value:"persuasive",label:"Persuasive"},{value:"supportive",label:"Supportive"},{value:"sarcastic",label:"Sarcastic"},{value:"condescending",label:"Condescending"},{value:"skeptical",label:"Skeptical"},{value:"narrative",label:"Narrative"},{value:"journalistic",label:"Journalistic"}],Ge=[{model:"davinci",price:.02},{model:"curie",price:.002},{model:"babbage",price:5e-4},{model:"ada",price:4e-4},{model:"dall-e",price:.02}];function ze(e){return function(e){if(Array.isArray(e))return Be(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Me(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 Me(e,t){if(e){if("string"==typeof e)return Be(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Be(e,t):void 0}}function Be(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var De=wp.element,qe=De.useMemo,Ye=De.useEffect,We=De.useState,Ze=function(e){var t=e.options.openai_apikey;return t&&t.length>0?null:React.createElement(React.Fragment,null,React.createElement(Ee.G,{style:{marginTop:0,marginBottom:25}},"To use the features of AI Engine, you need to have an OpenAI account and create an API Key. Visit the ",React.createElement("a",{href:"https://beta.openai.com/account/api-keys",target:"_blank"},"OpenAI")," website."))};function He(e){return e.split("\n").map((function(e){return(e=e.replace(/^\d+\.\s/,"")).startsWith('"')&&(e=e.slice(1)).endsWith('"')&&(e=e.slice(0,-1)),e})).join("\n")}var Ue,Ve,Je,$e,Ke=function(e){var t,n,r=(t=We(Ae[0].value),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(t,n)||Me(t,n)||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.")}()),a=r[0],o=r[1],i=qe((function(){var t,n=Ae,r="string"==typeof(null==e?void 0:e.extra_models)?null==e?void 0:e.extra_models:"",a=null!=e&&e.openai_finetunes&&(null==e?void 0:e.openai_finetunes.length)>0?null==e?void 0:e.openai_finetunes.filter((function(e){return e.enabled&&e.model})):[];return a.length&&(n=[].concat(ze(n),ze(a.map((function(e){var t=e.model.split(":");return{id:e.model,name:e.suffix,short:"fn-"+t[0],description:"Finetuned",finetuned:!0}}))))),(r=null===(t=r)||void 0===t?void 0:t.split(",").filter((function(e){return e}))).length&&(n=[].concat(ze(n),ze(r.map((function(e){return{id:e,name:e,description:"Extra"}}))))),n}),[e]);return Ye((function(){var e=i.find((function(e){return e.name.includes("davinci")}));e&&o(e.name)}),[i]),{model:a,models:i,setModel:o}},Qe=n(3895);function Xe(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var et=function(e){var t=e.title,n=void 0===t?"Settings":t;return React.createElement(y.B,{title:"AI Engine | ".concat(n),subtitle:"By Jordy Meow"},React.createElement("div",{style:{display:"flex",justifyContent:"flex-end"}},React.createElement(b._,{className:"header",icon:"",onClick:function(){return location.href="edit.php?page=mwai_content_generator"}},"Build Content"),React.createElement(b._,{className:"header",icon:"",onClick:function(){return location.href="edit.php?page=mwai_image_generator"}},"Build Images"),React.createElement(b._,{className:"header",icon:"",onClick:function(){return location.href="tools.php?page=mwai_dashboard"}},"Playground"),React.createElement(b._,{className:"header",icon:"tools",onClick:function(){return location.href="admin.php?page=mwai_settings"}},"Settings")))},tt=((0,A.ZP)(b._)(Ue||(Ue=Xe(["\n"]))),A.ZP.div(Ve||(Ve=Xe(["\n display: flex;\n justify-content: unset;\n align-items: center;\n justify-content: space-between;\n padding: 0 0 2px 0;\n\n h2 {\n margin: 7px 0 0 0;\n padding: 0;\n }\n"])))),nt=A.ZP.div(Je||(Je=Xe(["\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(30%, 1fr));\n grid-template-rows: repeat(auto-fit, minmax(30%, 1fr));\n grid-gap: 10px;\n margin-top: 20px;\n\n img, div {\n width: 100%;\n cursor: pointer;\n }\n .empty-image {\n width: 100%;\n padding-bottom: 100%;\n background-color: #f5f5f5;\n }\n"]))),rt=(0,A.ZP)(Qe.l)($e||($e=Xe(["\n\n .neko-textarea {\n height: 76px;\n border: 1px solid #eaeaea !important;\n background: #fbfbfb !important;\n font-size: 15px !important;\n }\n"]))),at=n(7460),ot=n.n(at),it=n(9995),ct=n(8178),lt=n(9378),ut=n(3103),st=n(2625),ft=n(3676),mt=n(776),ht=n(9746);function pt(e){return pt="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},pt(e)}function dt(e){return function(e){if(Array.isArray(e))return Et(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||wt(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 yt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function vt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?yt(Object(n),!0).forEach((function(t){gt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function gt(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==pt(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==pt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===pt(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||wt(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 wt(e,t){if(e){if("string"==typeof e)return Et(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Et(e,t):void 0}}function Et(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Rt(){Rt=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function m(){}function h(){}function p(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=p.prototype=m.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==pt(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:h,configurable:!0}),h.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function xt(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function kt(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){xt(o,r,a,i,c,"next",e)}function c(e){xt(o,r,a,i,c,"throw",e)}i(void 0)}))}}var _t=wp.element,St=_t.useState,Ot=_t.useMemo,Lt=_t.useRef,Pt=_t.useEffect,jt=[{accessor:"row",title:"#",width:15,verticalAlign:"top"},{accessor:"validPrompt",title:"",width:15,verticalAlign:"top"},{accessor:"prompt",title:"Prompt",width:"42%",verticalAlign:"top"},{accessor:"validCompletion",title:"",width:15,verticalAlign:"top"},{accessor:"completion",title:"Completion",width:"42%",verticalAlign:"top"},{accessor:"actions",title:"",width:55,align:"center"}],Tt=[{accessor:"status",title:"Status",sortable:!0},{accessor:"id",title:"ID"},{accessor:"filename",title:"File"},{accessor:"purpose",title:"Purpose"},{accessor:"filesize",title:"Size",sortable:!0},{accessor:"createdOn",title:"Date",sortable:!0},{accessor:"actions",title:""}],Ct=[{accessor:"status",title:"Status",sortable:!0},{accessor:"id",title:"ID"},{accessor:"suffix",title:"Suffix"},{accessor:"model",title:"Model"},{accessor:"base_model",title:"Based On"},{accessor:"createdOn",title:"Date",sortable:!0},{accessor:"actions",title:""}],Nt="\n\n###\n\n",At="\n\n",It=function(e){var t=e.status,n=e.includeText,r=void 0!==n&&n,a=it.ZP.orange,o=it.ZP.green,i=it.ZP.red,c=null;switch(t){case"pending":case"running":c=React.createElement(ct.J,{title:t,icon:"replay",spinning:!0,width:24,color:a});break;case"succeeded":case"processed":c=React.createElement(ct.J,{title:t,icon:"check-circle",width:24,color:o});break;case"failed":c=React.createElement(ct.J,{title:t,icon:"close",width:24,color:i});break;case"cancelled":c=React.createElement(ct.J,{title:t,icon:"close",width:24,color:a});break;default:c=React.createElement(ct.J,{title:t,icon:"alert",width:24,color:a})}return r?React.createElement("div",{style:{display:"flex",alignItems:"center"}},c,React.createElement("span",{style:{textTransform:"uppercase",fontSize:10,marginLeft:5}},t)):c},Ft=function(){var e=kt(Rt().mark((function e(){var t,n;return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,E.PV)("".concat(_,"/openai_files"),{nonce:P});case 2:return n=e.sent,e.abrupt("return",null==n||null===(t=n.files)||void 0===t?void 0:t.data);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Gt=function(){var e=kt(Rt().mark((function e(){var t,n;return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,E.PV)("".concat(_,"/openai_finetunes"),{nonce:P});case 2:return n=e.sent,e.abrupt("return",null==n||null===(t=n.finetunes)||void 0===t?void 0:t.data);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),zt=function(e){var t=e.children,n=e.data,r=e.onChange,a=void 0===r?function(){}:r,o=bt(St(!1),2),i=o[0],c=o[1],l=function(e){c(!1),e!==n&&a(e)};return i?React.createElement("div",{onKeyUp:function(e){"Escape"===e.key&&l(n)},style:{height:"100%",display:"flex",flexDirection:"column"}},React.createElement(Qe.l,{onBlurForce:!0,autoFocus:!0,fullHeight:!0,rows:3,style:{height:"100%"},onEnter:l,onBlur:l,value:n}),React.createElement(b._,{onClick:l,fullWidth:!0,style:{marginTop:5,height:35}},"Save")):React.createElement("pre",{style:{width:"100%",height:"100%",whiteSpace:"break-spaces",margin:0,padding:0,fontSize:13,fontFamily:"inherit"},onClick:function(){return c(!0)}},t)};const Mt=function(e){var t,n,r=e.options,a=e.updateOption,o=(0,u.NL)(),i=bt(St(),2),c=i[0],l=i[1],s=bt(St(!1),2),f=s[0],m=s[1],h=bt(St("finetunes"),2),p=h[0],d=h[1],y=bt(St(!0),2),v=y[0],g=y[1],w=Ke(r),R=w.models,x=w.model,k=w.setModel,S=bt(St("meow"),2),O=S[0],L=S[1],j=(0,we.a)({queryKey:["datasets"],queryFn:Ft}),T=j.isLoading,C=(j.error,j.data),N=(0,we.a)({queryKey:["finetunes"],queryFn:Gt}),A=(N.isLoading,N.error,N.data),I=(null==r?void 0:r.openai_finetunes_deleted)||[],F=10,G=bt(St(!0),2),z=G[0],M=G[1],B=bt(St(1),2),D=B[0],q=B[1],Y=bt(St([]),2),W=Y[0],Z=Y[1],H=bt(St(""),2),U=H[0],V=H[1],J=Ot((function(){return W.length}),[W]),$=function(){var e=kt(Rt().mark((function e(){return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.invalidateQueries("datasets");case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),K=function(){var e=kt(Rt().mark((function e(){return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return m(!0),e.next=3,$();case 3:m(!1);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Q=function(){var e=kt(Rt().mark((function e(){var t,n,r,a,o;return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c,n=O,r=R.find((function(e){return e.id===x})),m(!0),a=r.short.startsWith("fn-"),e.next=7,(0,E.PV)("".concat(_,"/openai_files_finetune"),{method:"POST",nonce:P,json:{fileId:t,model:a?r.id:r.short,suffix:n}});case 7:if(!(o=e.sent).success){e.next=16;break}return e.next=11,X();case 11:alert("Fine-tuning started! Check its progress in the 'Models' section. Depending on your dataset size, it may take a while (from a few minutes to days)."),d("finetunes"),l(),e.next=17;break;case 16:alert(o.message);case 17:m(!1);case 18:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),X=function(){var e=kt(Rt().mark((function e(){return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o.invalidateQueries("finetunes");case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ee=function(){var e=kt(Rt().mark((function e(){return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return m(!0),e.next=3,X();case 3:m(!1);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),te=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];e&&!confirm("This will delete all the rows in the builder. Are you sure?")||(Z([]),re([]))},ne=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=W.map((function(r,a){return a===e-1?vt(vt({},r),{},n?{completion:t}:{prompt:t}):r}));Z(r)};Pt((function(){if(!W||0===W.length){var e=localStorage.getItem("mwai_builder_data");e&&Z(JSON.parse(e))}}),[]);var re=function(e){!function(){var e=new Date,t=e.toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit"});t=t.replace(/\//g,"."),t+="-"+e.getHours().toString().padStart(2,"0")+"."+e.getMinutes().toString().padStart(2,"0"),V("MEOW-".concat(t,".jsonl"))}();try{e?localStorage.setItem("mwai_builder_data",JSON.stringify(e)):localStorage.removeItem("mwai_builder_data"),M(!0)}catch(e){localStorage.removeItem("mwai_builder_data"),M(!1)}};Pt((function(){W&&W.length>0&&re(W)}),[W]);var ae=Ot((function(){var e=(D-1)*F,t=null==W?void 0:W.slice((D-1)*F,(D-1)*F+F);return null==t?void 0:t.map((function(t){var n,r,a=++e,o=null===(n=t.prompt)||void 0===n?void 0:n.endsWith(Nt),i=null===(r=t.completion)||void 0===r?void 0:r.endsWith(At);return{row:a,validPrompt:o?"�
3 ":"❌",prompt:React.createElement(zt,{data:t.prompt,onChange:function(e){return ne(a,e)}},o?t.prompt.substring(0,t.prompt.length-Nt.length):t.prompt),validCompletion:i?"�
4 ":"❌",completion:React.createElement(zt,{data:t.completion,onChange:function(e){return ne(a,e,!0)}},i?t.completion.substring(0,t.completion.length-At.length):t.completion),actions:React.createElement(b._,{rounded:!0,icon:"trash",onClick:function(){return function(e){var t=W.filter((function(t,n){return n!==e-1}));Z(t),0===t.length&&re([])}(a)}})}}))}),[W,D,F]),oe=function(){var e=kt(Rt().mark((function e(t){var n;return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return m(!0),e.prev=1,e.next=4,(0,E.PV)("".concat(_,"/openai_files"),{method:"DELETE",nonce:P,json:{fileId:t}});case 4:if(!(n=e.sent).success){e.next=10;break}return e.next=8,$();case 8:e.next=11;break;case 10:alert(n.message);case 11:e.next=17;break;case 13:e.prev=13,e.t0=e.catch(1),console.log(e.t0),alert("Error! Check your console.");case 17:m(!1);case 18:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(t){return e.apply(this,arguments)}}(),ie=function(){var e=kt(Rt().mark((function e(t){var n;return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(confirm("You are going to delete this fine-tune. Are you sure?\n\nPlease note that it will take a while before it is actually deleted. This might be a temporary issue of OpenAI.")){e.next=2;break}return e.abrupt("return");case 2:return m(!0),e.prev=3,e.next=6,(0,E.PV)("".concat(_,"/openai_finetunes"),{method:"DELETE",nonce:P,json:{modelId:t}});case 6:if(!(n=e.sent).success){e.next=14;break}return e.next=10,a([].concat(dt(I),[t]),"openai_finetunes_deleted");case 10:return e.next=12,X();case 12:e.next=23;break;case 14:if(!(n.message.indexOf("does not exist")>-1)){e.next=22;break}return alert("This fine-tune was already deleted. It will be removed from the list."),e.next=18,a([].concat(dt(I),[t]),"openai_finetunes_deleted");case 18:return e.next=20,X();case 20:e.next=23;break;case 22:alert(n.message);case 23:e.next=29;break;case 25:e.prev=25,e.t0=e.catch(3),console.log(e.t0),alert("Error! Check your console.");case 29:m(!1);case 30:case"end":return e.stop()}}),e,null,[[3,25]])})));return function(t){return e.apply(this,arguments)}}(),ce=function(){var e=kt(Rt().mark((function e(t,n){var r,a,o,i;return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return m(!0),e.prev=1,console.log({fileId:t,filename:n}),e.next=5,(0,E.PV)("".concat(_,"/openai_files_download"),{method:"POST",nonce:P,json:{fileId:t}});case 5:(r=e.sent).success?(console.log(r),a=new Blob([r.data],{type:"text/plain"}),o=window.URL.createObjectURL(a),(i=document.createElement("a")).setAttribute("href",o),i.setAttribute("download","".concat(n)),document.body.appendChild(i),i.click(),i.remove()):alert(r.message),e.next=13;break;case 9:e.prev=9,e.t0=e.catch(1),console.log(e.t0),alert("Error! Check your console.");case 13:m(!1);case 14:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,n){return e.apply(this,arguments)}}(),le=Ot((function(){return null==C?void 0:C.sort((function(e,t){return t.created_at-e.created_at})).map((function(e){var t=e.id,n=e.filename,r=new Date(1e3*e.created_at),a="fine-tune"===e.purpose;return{status:React.createElement(It,{status:e.status,includeText:!0}),id:t,filename:n,purpose:e.purpose,filesize:(0,E.td)(e.bytes),createdOn:r.toLocaleDateString()+" "+r.toLocaleTimeString(),actions:React.createElement(React.Fragment,null,React.createElement(b._,{disabled:!a,icon:"wand",onClick:function(){return l(t)}},"Train Model"),React.createElement(b._,{rounded:!0,icon:"arrow-down",onClick:function(){return ce(t,n)}}),React.createElement(b._,{className:"danger",rounded:!0,icon:"trash",onClick:function(){return oe(t)}}))}}))}),[C]),ue=Ot((function(){return A?A.sort((function(e,t){return t.created_at-e.created_at})).map((function(e){var t=e.fine_tuned_model,n=new Date(1e3*e.created_at);return{status:React.createElement(It,{status:e.status,includeText:!0}),id:e.id,suffix:e.suffix,model:e.fine_tuned_model,base_model:e.model,createdOn:n.toLocaleDateString()+" "+n.toLocaleTimeString(),actions:React.createElement(b._,{className:"danger",rounded:!0,icon:"trash",onClick:function(){return ie(t)}})}})):[]}),[A]),se=T||f,fe=function(){var e=kt(Rt().mark((function e(){var t,n;return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return m(!0),e.prev=1,t=W.map((function(e){return JSON.stringify(e)})).join("\n"),console.log(t),e.next=6,(0,E.PV)("".concat(_,"/openai_files"),{method:"POST",nonce:P,json:{filename:U,data:t}});case 6:return n=e.sent,e.next=9,$();case 9:n.success?(te(!1),alert("Uploaded successfully! You can now train a model based on this dataset."),d("files"),g(!0)):alert(n.message),e.next=16;break;case 12:e.prev=12,e.t0=e.catch(1),console.log(e.t0),alert("Error! Check your console.");case 16:m(!1);case 17:case"end":return e.stop()}}),e,null,[[1,12]])})));return function(){return e.apply(this,arguments)}}(),me=Ot((function(){var e=new Date,t=e.getFullYear(),n=e.getMonth()+1,r=e.getDate(),a=e.getHours(),o=e.getMinutes(),i=e.getSeconds(),c=R.find((function(e){return e.id===x}));return"".concat(null==c?void 0:c.short,":ft-your-org:").concat(O,"-").concat(t,"-").concat(n<10?"0"+n:n,"-").concat(r<10?"0"+r:r,"-").concat(a<10?"0"+a:a,"-").concat(o<10?"0"+o:o,"-").concat(i<10?"0"+i:i)}),[O,x]),he=function(){var e=kt(Rt().mark((function e(t){var n,r;return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=Rt().mark((function e(){var n,a,o,i,c;return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t[r],a=new FileReader,o=n.name.endsWith(".json"),i=n.name.endsWith(".jsonl"),c=n.name.endsWith(".csv"),o||i||c){e.next=9;break}return alert("This only supports JSON, JSONL, and CSV files."),console.log(n),e.abrupt("return","continue");case 9:a.onload=function(){var e=kt(Rt().mark((function e(t){var n,r,a,l,u,s,f;return Rt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.target.result,r=[],o?r=JSON.parse(n):i?(a=n.split("\n"),r=a.map((function(e){e=e.trim();try{return JSON.parse(e)}catch(t){return console.log(t,e),null}}))):c&&(l=ot().parse(n,{header:!0,skipEmptyLines:!0}),r=l.data,console.log("The CSV was loaded.",r)),u=r.map((function(e){var t=Object.keys(e).reduce((function(t,n){return t[n.toLowerCase()]=e[n],t}),{}),n=["prompt","question","q"].find((function(e){return t[e]})),r=["completion","answer","a"].find((function(e){return t[e]}));return{prompt:t[n],completion:t[r]}})),s=u.filter((function(e){return e.prompt&&e.completion})),u.length!==s.length&&(alert("Some are were empty. Make sure the CSV has a header row and that the columns are named 'prompt' and 'completion'. For debugging, an empty line was logged to the console."),f=u.find((function(e){return!e.prompt||!e.completion})),console.log("Empty line: ",f)),Z(s);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),a.readAsText(n);case 11:case"end":return e.stop()}}),e)})),r=0;case 2:if(!(r<t.length)){e.next=10;break}return e.delegateYield(n(),"t0",4);case 4:if("continue"!==e.t0){e.next=7;break}return e.abrupt("continue",7);case 7:r++,e.next=2;break;case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),pe=Lt(null);return React.createElement(ge.H,{style:{margin:10}},React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement("div",{style:{marginRight:15}},React.createElement(lt.Q,{onLabel:"Model Finetune",offLabel:"Dataset Builder",width:145,onBackgroundColor:it.ZP.purple,offBackgroundColor:it.ZP.green,onChange:g,checked:v})),v&&React.createElement(ut.h,{value:p,busy:se,onChange:function(e){d(e)}},React.createElement(ut.S,{title:"Models",value:"finetunes",count:null!==(t=null==ue?void 0:ue.length)&&void 0!==t?t:null}),React.createElement(ut.S,{title:"Datasets",value:"files",count:null!==(n=null==le?void 0:le.length)&&void 0!==n?n:null})),v&&"finetunes"===p&&React.createElement(React.Fragment,null,React.createElement("div",{style:{flex:"auto"}}),React.createElement(b._,{disabled:f,onClick:ee,className:"primary"},"Refresh Models")),v&&"files"===p&&React.createElement(React.Fragment,null,React.createElement("div",{style:{flex:"auto"}}),React.createElement(b._,{disabled:f,onClick:K,className:"primary"},"Refresh Datasets")),!v&&React.createElement("div",{style:{display:"flex",alignItems:"center",width:"100%"}},React.createElement("div",{style:{display:"flex",alignItems:"center",background:"#ecf3ff",padding:"3px 3px 3px 8px",borderRadius:5,border:"1px solid #cce1ee"}},React.createElement("label",{style:{marginRight:10}},"Filename:"),React.createElement(ve.A,{disabled:!J||f,value:J?U:"",onChange:V,style:{width:210,marginRight:5}}),React.createElement(b._,{disabled:!J||f,icon:"upload",onClick:fe,className:"primary"},"Upload to OpenAI")),React.createElement("div",{style:{flex:"auto"}}),React.createElement(st.b,{ref:pe,onSelectFiles:he,accept:""},React.createElement(b._,{style:{marginLeft:5},onClick:function(){return pe.current.click()}},"Import File")))),v&&"finetunes"===p&&React.createElement(React.Fragment,null,React.createElement("p",null,"The AI models you have fine-tuned. To create more, visit ",React.createElement("b",null,"Datasets"),"."),React.createElement(ft.a,{alternateRowColor:!0,busy:se,data:ue,columns:Ct,emptyMessage:React.createElement(React.Fragment,null,"You do not have any fine-tuned jobs yet.")})),v&&"files"===p&&React.createElement(React.Fragment,null,React.createElement("p",null,"The datasets you have uploaded to OpenAI. To create a new dataset, switch from ",React.createElement("b",null,"Model Finetuner")," to ",React.createElement("b",null,"Dataset Builder"),". To train a new model, click on the ",React.createElement("i",null,"magic wand"),"."),React.createElement(ft.a,{alternateRowColor:!0,busy:se,data:le,columns:Tt,emptyMessage:React.createElement(React.Fragment,null,"You do not have any dataset files yet.")})),!v&&React.createElement(React.Fragment,null,React.createElement("p",null,"You can create your dataset by importing a file (two columns, in the CSV, JSON or JSONL format) or manually by clicking ",React.createElement("b",null,"Add Entry"),". To avoid losing your work, this data is kept in your browser's local storage. ",React.createElement("b",null,"This is actually complex, so learn how to write datasets by studying ",React.createElement("a",{href:"https://beta.openai.com/docs/guides/fine-tuning/conditional-generation",target:"_blank"},"case studies"),".")," Is your dataset ready? Modify the filename to your liking and click ",React.createElement("b",null,"Upload to OpenAI"),"! 😎"),!z&&React.createElement("p",{style:{color:it.ZP.red}},"Caution: The data is too large to be saved in your browser's local storage."),React.createElement("div",{style:{display:"flex"}},React.createElement(b._,{icon:"plus",onClick:function(){Z([].concat(dt(W),[{prompt:"Text...\n\n###\n\n",completion:"Text...\n\n"}]))},style:{paddingLeft:10,paddingRight:10}},"Add Entry"),React.createElement(b._,{icon:"wand",disabled:!0,onClick:function(){return alert("Coming soon! ✌️")}},"Generate Entries"),React.createElement(b._,{disabled:!J,className:"secondary",onClick:function(){var e=W.map((function(e){var t=e.prompt,n=e.completion;return t.endsWith(Nt)||(t+=Nt),n.endsWith(At)||(n+=At),{prompt:t,completion:n}}));Z(e)}},"Format with Defaults"),React.createElement(b._,{disabled:!J,className:"secondary",style:{marginLeft:5},onClick:function(){var e=ot().unparse(W),t=new Blob([e],{type:"text/csv"}),n=URL.createObjectURL(t),r=document.createElement("a");r.href=n;var a=new Date,o="".concat(a.getFullYear(),"-").concat(a.getMonth()+1,"-").concat(a.getDate(),"-WP.csv");r.download=o,document.body.appendChild(r),r.click(),document.body.removeChild(r)}},"Export as CSV"),React.createElement(b._,{disabled:!J,onClick:te,className:"danger"},"Reset Entries"),React.createElement("div",{style:{flex:"auto"}}),React.createElement(mt.Q,{currentPage:D,limit:F,total:J,onCurrentPageChanged:q,onClick:q})),React.createElement(ht.i,{height:20}),React.createElement(ft.a,{alternateRowColor:!0,busy:f,data:ae,columns:jt,emptyMessage:React.createElement(React.Fragment,null,"You can import a file, or create manually each entry by clicking ",React.createElement("b",null,"Add Entry"),".")}),React.createElement(ht.i,{height:20}),React.createElement("div",{style:{display:"flex",justifyContent:"end"}},React.createElement(mt.Q,{currentPage:D,limit:F,total:J,onCurrentPageChanged:q,onClick:q})),React.createElement(ht.i,{height:40,line:!0,style:{marginBottom:0}}),React.createElement("p",null,React.createElement("b",null,"Notes:")),React.createElement("p",null,"• The prompt and the completion should both end with their own special endings. By default, it is ",React.createElement("b",null,"\\n\\n===\\n\\n")," for the prompt, and ",React.createElement("b",null,"\\n\\n")," for the completion. The icon �
5 will be shown next to the prompt and/or completion when this format has been validated, and the ending will be hidden for clarity. I refer to this format (and models trained on it) by the term of ",React.createElement("b",null,"Casually Fine Tuned"),"."),React.createElement("p",null,"• ",React.createElement("b",null,"\\n")," is a line break. You can add line breaks by using ",React.createElement("b",null,"SHIFT+ENTER")," while editing."),React.createElement("p",null,"• The ",React.createElement("b",null,"Format with Defaults")," button will add the ",React.createElement("i",null,"Casually Fine Tuned")," endings format to the prompt and completion, if they are missing."),React.createElement("p",null,"• If you need the chatbot to work with a ",React.createElement("b",null,"Casually Fined Tuned")," model, you can add ",React.createElement("i",null,'casuallyFineTuned="true"')," in the parameter for the shortcode.")),React.createElement(Re.L,{isOpen:c,title:"Train a new model",onOkClick:Q,onRequestClose:function(){return l()},onCancelClick:function(){return l()},ok:"Start",disabled:f,content:React.createElement(React.Fragment,null,React.createElement("p",null,"Exciting! 🎵 You are about to create your own new model, based on your dataset. You simply need to select a base model, and optionally, to modify the ",React.createElement("a",{href:"https://beta.openai.com/docs/guides/fine-tuning/hyperparameters",target:"_blank"},"hyperparameters"),". Before starting the process, make sure that:"),React.createElement("ul",null,React.createElement("li",null,"�
6 The dataset is well-defined."),React.createElement("li",null,"�
7 You understand ",React.createElement("a",{href:"https://openai.com/api/pricing/#faq-fine-tuning-pricing-calculation",target:"_blank"},"OpenAI pricing")," about fine-tuning.")),React.createElement("label",null,"Base model:"),React.createElement(ht.i,{height:5}),React.createElement(be.N,{id:"models",value:x,scrolldown:!0,onChange:k},R.map((function(e){return React.createElement(be.Z,{value:e.id,label:e.name})}))),React.createElement(ht.i,{height:5}),React.createElement("small",null,"For now, the hyperparameters can't be modified - they are set automatically by OpenAI."),React.createElement(ht.i,{height:10}),React.createElement("label",null,"Suffix (for new model name):"),React.createElement(ht.i,{height:5}),React.createElement(ve.A,{value:O,onChange:L}),React.createElement(ht.i,{height:5}),React.createElement("small",null,"The name of the new model name will be decided by OpenAI. You can customize it a bit with this ",React.createElement("a",{href:"https://beta.openai.com/docs/api-reference/fine-tunes/list#fine-tunes/create-suffix",target:"_blank"},"prefix"),". Preview: ",React.createElement("b",null,me),"."))}))};var Bt,Dt,qt,Yt=wp.element,Wt=(Yt.useState,Yt.useEffect,Yt.useMemo,A.ZP.div(Bt||(Dt=["\n display: flex;\n flex-direction: column;\n color: white;\n width: 100%;\n margin-top: -20px;\n\n h3 {\n color: white;\n }\n\n .description {\n background: white;\n color: black;\n padding: 8px 10px;\n border-radius: 5px;\n\n p {\n small {\n color: ",";\n font-size: 13px;\n }\n }\n\n p:first-child {\n margin-top: 0;\n }\n\n p:last-child {\n margin-bottom: 0;\n }\n }\n"],qt||(qt=Dt.slice(0)),Bt=Object.freeze(Object.defineProperties(Dt,{raw:{value:Object.freeze(qt)}}))),it.ZP.orange));const Zt=function(e){var t,n,r=e.incidents,a=e.isLoading,o=(t=new Date,n=new Date(t.toLocaleString("en-US",{timeZone:"America/Los_Angeles"})),((t-n)/36e5).toFixed(0));return React.createElement("div",{style:{padding:"0px 10px 10px 10px"}},React.createElement(f.O,{p:!0,style:{color:"white"}},"Only the incidents which occured ",React.createElement("b",null,"less than a week ago")," are displayed here. For your information, the time difference between the PST time used by OpenAI and your local time is ",o," hours."),React.createElement(Wt,null,a&&React.createElement("div",null,"Loading..."),r&&r.map((function(e){return React.createElement("div",{key:e.guid},React.createElement("h3",null,"⚠️ ",e.date,": ",e.title),React.createElement("div",{className:"description",dangerouslySetInnerHTML:{__html:e.description}}))}))))};var Ht,Ut,Vt;function Jt(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var $t,Kt=A.ZP.div(Ht||(Ht=Jt(["\n background: white;\n padding: 15px;\n border-radius: 5px;\n\n h2 {\n margin-bottom: 8px;\n }\n \n h3:first-child {\n margin-top: 0;\n }\n\n label {\n display: block;\n margin-bottom: 5px;\n }\n\n label {\n margin-top: 10px;\n }\n\n li {\n margin-bottom: 10px;\n border: 1px solid #e5e5e5;\n padding: 10px;\n background: #f5f5f5;\n border-radius: 5px;\n cursor: pointer;\n transition: all 0.2s ease-in-out;\n }\n\n li.active {\n background: #037cba;\n color: white;\n border-color: #037cba;\n }\n\n .information {\n color: #a3a3a3;\n margin-top: 5px;\n font-size: 12px;\n line-height: 100%;\n }\n"]))),Qt=(0,A.ZP)(ve.A)(Ut||(Ut=Jt(["\n flex: auto !important;\n\n input {\n height: 50px !important;\n font-size: 14px !important;\n font-family: monospace !important;\n padding: 20px 20px 20px 45px !important;\n border-color: #333d4e !important;\n background: #333d4e !important;\n color: white !important;\n }\n"]))),Xt=A.ZP.div(Vt||(Vt=Jt(["\n display: flex;\n flex-direction: column;\n\n label {\n margin-bottom: 3px;\n }\n\n .mwai-builder-row {\n margin-top: 10px;\n display: flex;\n flex-direction: row;\n align-items: center;\n\n .neko-color-picker {\n margin-left: 5px;\n }\n }\n\n .mwai-builder-col {\n flex: 1;\n display: flex;\n flex-direction: column;\n margin-right: 5px;\n }\n\n .mwai-builder-col:last-child {\n margin-right: 0;\n }\n\n pre {\n white-space: pre-wrap;\n background: #d4f0ff;\n color: #037cba;\n padding: 10px;\n font-size: 13px;\n font-weight: bold;\n margin: 20px 0;\n }\n\n .neko-spacer {\n margin-bottom: 0 !important;\n }\n\n .neko-input {\n border: 1.5px solid #eaeaea !important;\n background: #fbfbfb !important;\n }\n\n .nui-select-option {\n border: 1.5px solid #eaeaea !important;\n background: #fbfbfb !important;\n }\n\n\n"]))),en=n(5651);function tn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return nn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?nn(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 nn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var rn=wp.element,an=rn.useState,on=rn.useEffect,cn=rn.useRef,ln=rn.useCallback,un=A.ZP.div($t||($t=function(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(["\n position: relative;\n\n .swatch {\n width: 24px;\n height: 24px;\n border-radius: 8px;\n border: 3px solid #fff;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(0, 0, 0, 0.1);\n cursor: pointer;\n }\n \n .popover {\n position: absolute;\n top: -210px;\n left: -80px;\n box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);\n z-index: 9999;\n }\n"]))),sn=function(e){var t,n,r=e.name,a=e.value,o=e.onChange,i=cn(),c=tn(an(!1),2),l=c[0],u=c[1],s=tn(an(a),2),f=s[0],m=s[1],h=ln((function(){f!==a&&o(f,r),u(!1)}),[f,a]);return on((function(){var e=!1,r=!1,a=function(a){!e&&r&&t.current&&!t.current.contains(a.target)&&n(a)},o=function(n){r=t.current,e=t.current&&t.current.contains(n.target)};return document.addEventListener("mousedown",o),document.addEventListener("touchstart",o),document.addEventListener("click",a),function(){document.removeEventListener("mousedown",o),document.removeEventListener("touchstart",o),document.removeEventListener("click",a)}}),[t=i,n=h]),React.createElement(un,{className:"neko-color-picker"},React.createElement("div",{className:"swatch",style:{backgroundColor:f},onClick:function(){return u(!0)}}),l&&React.createElement("div",{className:"popover",ref:i},React.createElement(en.gW,{color:f,onChange:m})))};function fn(e){return fn="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},fn(e)}function mn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return hn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?hn(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 hn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function pn(){pn=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function m(){}function h(){}function p(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=p.prototype=m.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==fn(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:h,configurable:!0}),h.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function dn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function yn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?dn(Object(n),!0).forEach((function(t){vn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function vn(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==fn(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==fn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===fn(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gn(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function bn(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){gn(o,r,a,i,c,"next",e)}function c(e){gn(o,r,a,i,c,"throw",e)}i(void 0)}))}}var wn=wp.element,En=wn.useMemo,Rn=wn.useState,xn=function(){var e=bn(pn().mark((function e(){var t,n;return pn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,E.PV)("".concat(_,"/openai_incidents"),{nonce:P});case 2:if(null==(t=e.sent)||!t.incidents){e.next=6;break}return n=t.incidents.map((function(e){var t=e.date,n=(t=new Date(1e3*t)).toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit"});return yn(yn({},e),{},{date:n})})),e.abrupt("return",n);case 6:return e.abrupt("return",null);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();const kn=function(){var e,t,n,r,a,o,i,c,l,u=mn(Rn(j),2),s=u[0],y=u[1],k=mn(Rn(!1),2),S=k[0],T=k[1],N=Ke(s).models,A=null==s?void 0:s.shortcode_chat_default_params,I=null==s?void 0:s.shortcode_chat_params,F=null==s?void 0:s.shortcode_chat_styles,G=null==s?void 0:s.shortcode_chat_params_override,z=null==s?void 0:s.shortcode_chat_inject,M=null==s?void 0:s.module_titles,B=null==s?void 0:s.module_excerpts,D=null==s?void 0:s.module_blocks,q=null==s?void 0:s.module_statistics,Y=null==s?void 0:s.shortcode_chat,W=null==s?void 0:s.shortcode_chat_formatting,Z=null!=s&&s.openai_apikey?null==s?void 0:s.openai_apikey:"",H=null==s?void 0:s.openai_usage,U=null==s?void 0:s.shortcode_chat_syntax_highlighting,V=null==s?void 0:s.extra_models,J="chat"===I.mode,$="images"===I.mode,K=(0,we.a)({queryKey:["openAI_status"],queryFn:xn}),Q=K.isLoadingIncidents,X=K.data,ee=null==X?void 0:X.filter((function(e){return new Date(e.date)>new Date(Date.now()-864e5)})).length,te=S,ne=En((function(){var e={};if(G)return e;for(var t in A)A[t]!==I[t]&&(e[t]=I[t]);return J&&(delete e.mode,delete e.max_results),$&&(delete e.context,delete e.content_aware,delete e.casually_fined_tuned,delete e.model,delete e.max_tokens,delete e.temperature),e}),[G,A,I]),re=En((function(){var e=[];for(var t in ne)e.push("".concat(t,'="').concat(I[t],'"'));var n=e.join(" ");return"[mwai_chat"+(n?" ".concat(n):"")+"]"}),[ne]),ae=function(){var e=bn(pn().mark((function e(t,n){var r,a;return pn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=yn(yn({},s),{},vn({},n,t)),T(!0),e.prev=2,e.next=5,(0,E.PV)("".concat(_,"/update_option"),{method:"POST",nonce:P,json:{options:r}});case 5:(a=e.sent).success&&y(a.options),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),e.t0.message&&alert(e.t0.message);case 12:return e.prev=12,T(!1),e.finish(12);case 15:case"end":return e.stop()}}),e,null,[[2,9,12,15]])})));return function(t,n){return e.apply(this,arguments)}}(),oe=function(){var e=bn(pn().mark((function e(t,n){var r;return pn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=yn(yn({},I),{},vn({},n,t)),e.next=3,ae(r,"shortcode_chat_params");case 3:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),ie=function(){var e=bn(pn().mark((function e(){return pn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ae(A,"shortcode_chat_params");case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ce=function(){var e=bn(pn().mark((function e(t,n){var r;return pn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=4;break}return r=yn(yn({},F),{},vn({},n,t)),e.next=4,ae(r,"shortcode_chat_styles");case 4:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),le=function(){var e=bn(pn().mark((function e(){return pn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ae({},"shortcode_chat_styles");case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ue=React.createElement(m.r,{title:"Assistants"},React.createElement(h.l,{max:"1"},React.createElement(p.P,{id:"module_titles",label:"Titles",value:"1",checked:M,description:"Suggest a few titles based on your content.",onChange:ae}),React.createElement(p.P,{id:"module_excerpts",label:"Excerpt",value:"1",checked:B,description:"Suggest a few excerpts based on your content.",onChange:ae}))),se=React.createElement(m.r,{title:"Blocks"},React.createElement(h.l,{max:"1"},React.createElement(p.P,{id:"module_blocks",label:"Enable",disabled:!0,value:"1",checked:D,description:"AI Forms, and others. Not available yet.",onChange:ae}))),fe=React.createElement(m.r,{title:"Statistics"},React.createElement(p.P,{id:"module_statistics",label:"Enable",value:"1",checked:q,requirePro:!0,isPro:L,description:"Track interaction with the AI based on the user, session, type, price, and various other factors. This allows to set limits, and more!",onChange:ae})),me=React.createElement(m.r,{title:"Chatbot"},React.createElement(h.l,{max:"1"},React.createElement(p.P,{id:"shortcode_chat",label:"Enable",value:"1",checked:Y,description:"A chatbot that can be similar to ChatGPT. But it has many features! Check the Chatbot tab.",onChange:ae}))),he=React.createElement(m.r,{title:"Formatting"},React.createElement(h.l,{max:"1"},React.createElement(p.P,{id:"shortcode_chat_formatting",label:"Enable",value:"1",checked:W,description:React.createElement(React.Fragment,null,"Convert the reply from the AI into HTML. ",React.createElement("b",null,"Markdown is supported, so it is highly recommended to add 'Use Markdown.' in your context.")),onChange:ae}))),pe=React.createElement(m.r,{title:"Code"},React.createElement(h.l,{max:"1"},React.createElement(p.P,{id:"shortcode_chat_syntax_highlighting",label:"Use Syntax Highlighting",value:"1",checked:U,description:React.createElement(React.Fragment,null,"Add syntax coloring to the code written by the chatbot."),onChange:ae}))),de=React.createElement(m.r,{title:"Extra Models"},React.createElement(ve.A,{id:"extra_models",name:"extra_models",value:V,description:React.createElement(React.Fragment,null,"You can enter additional models you would like to use (separated by a comma). Note that your fine-tuned models are already available."),onBlur:ae})),ye=React.createElement(m.r,{title:"API Key"},React.createElement(ve.A,{id:"openai_apikey",name:"openai_apikey",value:Z,description:React.createElement(React.Fragment,null,"You can get your API Keys in your ",React.createElement("a",{href:"https://beta.openai.com/account/api-keys",target:"_blank"},"OpenAI Account"),"."),onBlur:ae})),Ee=En((function(){var e={};try{Object.keys(H).forEach((function(t){var n=H[t];e[t]||(e[t]={totalPrice:0,data:[]}),Object.keys(n).forEach((function(r){var a=n[r],o=0,i=N.find((function(e){return e.id===r}));if("dall-e"===r){var c=C.find((function(e){return"dall-e"===e.model})).options.find((function(e){return"1024x1024"===e.option})),l=a.images*c.price;return e[t].totalPrice+=l,void e[t].data.push({name:"dall-e",isImage:!0,usage:a.images,price:l})}if(i){var u=C.find((function(e){return e.model===i.short}));if(u){o=a.total_tokens/1e3*u.price,e[t].totalPrice+=o;var s=i?i.name:r;e[t].data.push({name:s,isImage:!1,usage:a.total_tokens,price:o})}else console.log("Cannot find price for model ".concat(r,"."))}else console.log("Cannot find model ".concat(r,"."))}))})),Object.keys(e).forEach((function(t){e[t].data.sort((function(e,t){return t.price-e.price}))}))}catch(e){console.log(e)}return React.createElement("ul",{style:{marginTop:2}},Object.keys(e).map((function(t,n){return React.createElement("li",{key:n},React.createElement("strong",null,"🗓️ ",t," (",e[t].totalPrice.toFixed(2),"$)"),React.createElement("ul",null,e[t].data.map((function(e,t){return React.createElement("li",{key:t,style:{marginTop:5,marginLeft:18}},React.createElement("strong",null,"• ",e.name),e.isImage&&": ".concat(e.usage," images"),!e.isImage&&": ".concat(e.usage," tokens"),e.price>0&&" (".concat(e.price.toFixed(2),"$)"))}))))})))}),[H,N]),Re=React.createElement("div",null,React.createElement("h3",null,"Usage"),React.createElement("div",{style:{marginTop:-10,marginBottom:10,fontSize:12}},"For the exact amounts, please check your ",React.createElement("a",{href:"https://beta.openai.com/account/usage",target:"_blank"},"OpenAI account"),". If you would like to have better control on the amounts, add conditions or set limits to the usage of the AI, consider ",React.createElement("a",{href:"https://meowapps.com/ai-engine/",target:"_blank"},"AI Engine Pro"),"."),!Object.keys(H).length&&React.createElement(f.O,{p:!0},"N/A"),H&&React.createElement(React.Fragment,null,Ee));return React.createElement(d.s,null,React.createElement(et,null),React.createElement(v.o,null,React.createElement(v.z,{full:!0},React.createElement(Ze,{options:s}),React.createElement(ge.H,null,React.createElement(f.O,{p:!0},"Boost your WordPress with AI! Don't forget to visit the ",React.createElement("a",{href:"https://meowapps.com/ai-engine/",target:"_blank"},"AI Engine website")," for more information. Have fun! 🎵")),React.createElement(g.c,{keepTabOnReload:!0},React.createElement(g.P,{title:"Settings"},React.createElement(v.o,null,React.createElement(v.z,{minimal:!0},React.createElement(w.v,{busy:te,title:"Modules",className:"primary"},me,ue,fe,se),React.createElement(w.v,{busy:te,title:"Advanced",className:"primary"},de)),React.createElement(v.z,{minimal:!0},React.createElement(w.v,{busy:te,title:"Open AI",className:"primary"},ye,Re)))),Y&&React.createElement(g.P,{title:"Chatbot"},React.createElement(v.o,null,React.createElement(v.z,{minimal:!0},React.createElement(w.v,{className:"primary"},React.createElement(f.O,{p:!0},React.createElement("p",null,"If you only need one chatbot, set your parameters in the Chatbot Builder, and click on ",React.createElement("b",null,"Set as Default Parameters"),". You can then use the shortcode ",React.createElement("b",null,"[mwai_chat]")," anywhere on your website. You can also add the chatbot everywhere automatically by using ",React.createElement("b",null,"Inject Default Chatbot"),"."),React.createElement("p",null,"Alternatively, you can also play with the params to create different shortcodes. You can have multiple chatbots on your website, or even the same page, each with different parameters. Play with them! 😎"))),React.createElement(w.v,{busy:te,title:"Features",className:"primary"},he,pe),React.createElement(w.v,{busy:te,title:"Styles",className:"primary",action:React.createElement(b._,{className:"danger",onClick:le},"Reset Styles")},React.createElement(Xt,null,React.createElement("p",null,"Keep in mind that you can also style the chatbot (or aspecific chatbot, if you use many) by injecting CSS. Have a look ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/ai-engine/tutorial/#apply-custom-style-to-the-chatbot"},"here"),"."),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Spacing:"),React.createElement(ve.A,{id:"spacing",name:"spacing",value:null!==(e=null==F?void 0:F.spacing)&&void 0!==e?e:"15px",onBlur:ce})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Font Size:"),React.createElement(ve.A,{id:"fontSize",name:"fontSize",value:null!==(t=null==F?void 0:F.fontSize)&&void 0!==t?t:"15px",onBlur:ce})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Border Radius:"),React.createElement(ve.A,{id:"borderRadius",name:"borderRadius",value:null!==(n=null==F?void 0:F.borderRadius)&&void 0!==n?n:"10px",onBlur:ce}))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Font Color:"),React.createElement("div",{style:{display:"flex"}},React.createElement(ve.A,{id:"fontColor",name:"fontColor",value:null!==(r=null==F?void 0:F.fontColor)&&void 0!==r?r:"#FFFFFF",onBlur:ce}),React.createElement(sn,{id:"fontColor",name:"fontColor",value:null!==(a=null==F?void 0:F.fontColor)&&void 0!==a?a:"#FFFFFF",onChange:ce}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Back Primary Color:"),React.createElement("div",{style:{display:"flex"}},React.createElement(ve.A,{id:"backgroundPrimaryColor",name:"backgroundPrimaryColor",value:null!==(o=null==F?void 0:F.backgroundPrimaryColor)&&void 0!==o?o:"#454654",onBlur:ce}),React.createElement(sn,{id:"backgroundPrimaryColor",name:"backgroundPrimaryColor",value:null!==(i=null==F?void 0:F.backgroundPrimaryColor)&&void 0!==i?i:"#454654",onChange:ce}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Back Secondary Color:"),React.createElement("div",{style:{display:"flex"}},React.createElement(ve.A,{id:"backgroundSecondaryColor",name:"backgroundSecondaryColor",value:null!==(c=null==F?void 0:F.backgroundSecondaryColor)&&void 0!==c?c:"#343541",onBlur:ce}),React.createElement(sn,{id:"backgroundSecondaryColor",name:"backgroundSecondaryColor",value:null!==(l=null==F?void 0:F.backgroundSecondaryColor)&&void 0!==l?l:"#343541",onChange:ce}))))))),React.createElement(v.z,{minimal:!0},React.createElement(w.v,{busy:te,title:"Chatbot Builder",className:"primary",action:React.createElement(b._,{className:"danger",onClick:ie},"Reset Parameters")},React.createElement(Xt,null,React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Mode:"),React.createElement(be.N,{scrolldown:!0,id:"mode",name:"mode",value:I.mode,onChange:oe},React.createElement(be.Z,{value:"chat",label:"Chat"}),React.createElement(be.Z,{value:"images",label:"Images"}))),J&&React.createElement("div",{className:"mwai-builder-col",style:{flex:5}},React.createElement("label",null,"Context:"),React.createElement(ve.A,{id:"context",name:"context",value:I.context,onBlur:oe})),$&&React.createElement("div",{className:"mwai-builder-col",style:{flex:5}},React.createElement("label",null,"Max Results (= Number of Images):"),React.createElement(ve.A,{id:"max_results",name:"max_results",type:"number",value:I.max_results,onBlur:oe}))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"AI Name:"),React.createElement(ve.A,{id:"ai_name",name:"ai_name",value:I.ai_name,onBlur:oe})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"User Name:"),React.createElement(ve.A,{id:"user_name",name:"user_name",value:I.user_name,onBlur:oe})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"System Name:"),React.createElement(ve.A,{id:"sys_name",name:"sys_name",value:I.sys_name,onBlur:oe})),React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,"Placeholder:"),React.createElement(ve.A,{id:"text_input_placeholder",name:"text_input_placeholder",value:I.text_input_placeholder,onBlur:oe})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Button:"),React.createElement(ve.A,{id:"text_send",name:"text_send",value:I.text_send,onBlur:oe}))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{textAlign:"right",marginRight:10}},React.createElement("br",null),I.ai_name),React.createElement("div",{className:"mwai-builder-col",style:{flex:5}},React.createElement("label",null,"Start Sentence:"),React.createElement(ve.A,{id:"start_sentence",name:"start_sentence",value:I.start_sentence,onBlur:oe}))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,"Style:"),React.createElement(be.N,{scrolldown:!0,id:"style",name:"style",value:I.style,description:"",onChange:oe},React.createElement(be.Z,{value:"none",label:"None"}),React.createElement(be.Z,{value:"chatgpt",label:"ChatGPT"}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Popup Window:"),React.createElement(p.P,{id:"window",label:"Yes",checked:I.window,value:"1",onChange:oe})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Full Screen:"),React.createElement(p.P,{id:"fullscreen",label:"Yes",checked:I.fullscreen,value:"1",onChange:oe})),J&&React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,"Content Aware:"),React.createElement(p.P,{id:"content_aware",label:"Yes",requirePro:!0,isPro:L,checked:I.content_aware,value:"1",onChange:oe}))),J&&React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,"Model:"),React.createElement(be.N,{scrolldown:!0,id:"model",name:"model",value:I.model,description:"",onChange:oe},N.map((function(e){return React.createElement(be.Z,{value:e.id,label:e.name})})))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Max Tokens:"),React.createElement(ve.A,{id:"max_tokens",name:"max_tokens",type:"number",value:I.max_tokens,onBlur:oe})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Temperature:"),React.createElement(ve.A,{id:"temperature",name:"temperature",type:"number",step:"0.1",min:"0",max:"1",value:I.temperature,onBlur:oe})),React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,"Casually Fine Tuned:"),React.createElement(p.P,{id:"casually_fined_tuned",label:"Yes",checked:I.casually_fined_tuned,value:"1",onChange:oe}))),React.createElement("pre",null,re)),React.createElement(p.P,{id:"shortcode_chat_params_override",label:"Set as Default Parameters",disabled:Object.keys(ne).length<1&&!G,value:"1",checked:G,description:"The parameters set above will be used by default. If you are using 'Popup Window' and many chatbots on the same page, be careful, as they will probably appear on top of each other.",onChange:ae}),React.createElement(p.P,{id:"shortcode_chat_inject",label:"Inject Default Chatbot in Website",value:"1",checked:z,description:React.createElement(React.Fragment,null,React.createElement("span",null,"Inject the default chatbot automatically on your website. It will be available on every page."),I.window?"":React.createElement("span",null," It's highly recommended to enable 'Window (Popup Mode)'")),onChange:ae}))))),React.createElement(g.P,{title:"Fine Tuning: Train your AI"},React.createElement(Mt,{options:s,updateOption:ae})),React.createElement(g.P,{key:"openai-status",title:React.createElement(React.Fragment,null,"OpenAI Status",ee>0?React.createElement(React.Fragment,null," ⚠️"):"")},React.createElement(Zt,{incidents:X,isLoading:Q})),React.createElement(g.P,{title:"License"},React.createElement(Ne,{domain:x,prefix:R,isPro:O,isRegistered:L}))))))};function _n(e){return _n="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},_n(e)}var Sn;function On(){On=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function m(){}function h(){}function p(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=p.prototype=m.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==_n(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:h,configurable:!0}),h.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function Ln(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function Pn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?jn(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 jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Tn=wp.element,Cn=Tn.useState,Nn=Tn.useEffect,An=Tn.useMemo,In=[{id:"none",name:"None",mode:"query",temperature:.8,stopSequence:"",maxTokens:2048,description:""},{id:"casually_fined_tuned",name:"Casually Fined Tuned",mode:"query",temperature:.4,stopSequence:"\\n\\n",maxTokens:1024,description:"Hello! What's your name?\n\n###\n\n"},{id:"wp_assistant",name:"WordPress Assistant",mode:"chat",temperature:.8,stopSequence:"",maxTokens:150,description:"Converse as a WordPress expert. Be helpful, friendly, concise, avoid external URLs and commercial solutions.\n\n AI: Hi! How can I help you with WP today?"},{id:"article_translator",name:"Article Translator",mode:"query",temperature:.3,stopSequence:"",maxTokens:2048,description:"Translate this article into French:\n\nUchiko is located in Ehime prefecture, in the west of the island. The town was prosperous at the end of the 19th century thanks to its production of very good quality white wax. This economic boom allowed wealthy local merchants to build beautiful properties, whose heritage is still visible throughout the town.\n\n"},{id:"article_writer",name:"Article Writer",mode:"query",temperature:.8,stopSequence:"",maxTokens:2048,description:"Write an article about what to do in Paris, in summer, with a few recommendations of restaurants and cafes.\n\n"},{id:"bulk_articles_writer",name:"Bulk Articles Writer",mode:"query",temperature:.8,stopSequence:"",maxTokens:2048,description:"Write titles (TITLE: ) and very short paragraphs (CONTENT: ) for each following topic. Keywords for each topic will be added between parenthesis.\n\n - When to travel to France (seasons, food, ambiance, celebrations)\n - Why one should visit the French countryside (beach, forest, mountain, food, people)\n - Story of a night at Mont Saint-Michel (hotel, ambiance, sea, light)\n - Differences between South West and South East of France (people, food, beach, ambiance)\n"},{id:"article_corrector",name:"Article Corrector",mode:"query",temperature:.2,stopSequence:"",maxTokens:2048,description:"Fix the grammar and spelling mistakes in this text:\n\nI wake up at eleben yesderday, I will go bed eary tonigt.\n"},{id:"seo_assistant",name:"SEO Assistant",mode:"query",temperature:.6,stopSequence:"",maxTokens:1024,description:"For the following article, write a SEO-friendly and short title, keywords for Google, and a short excerpt to introduce it. Use this format:\n\n Title: \n Keywords: \n Excerpt: \n \n Uchiko is located in Ehime prefecture, in the west of the island. The town was prosperous at the end of the 19th century thanks to its production of very good quality white wax. This economic boom allowed wealthy local merchants to build beautiful properties, whose heritage is still visible throughout the town.\n "}],Fn=A.ZP.textarea(Sn||(Sn=function(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(["\n display: block;\n height: 460px;\n width: 100%;\n margin-bottom: 10px;\n background: #333d4e;\n border-radius: 5px;\n border: none;\n color: #d1d5dc;\n font-size: 14px;\n font-family: monospace;\n padding: 20px;\n"])));const Gn=function(){var e=Pn(Cn(),2),t=e[0],n=e[1],r=Pn(Cn(),2),a=r[0],o=r[1],i=Pn(Cn("chat"),2),c=i[0],l=i[1],u=Pn(Cn(""),2),s=u[0],m=u[1],h=Ke(j),p=h.models,y=h.model,g=h.setModel,w=Pn(Cn(1),2),R=w[0],x=w[1],k=Pn(Cn(!1),2),S=k[0],O=k[1],L=Pn(Cn({prompt_tokens:0,completion_tokens:0,total_tokens:0}),2),C=L[0],N=L[1],A=Pn(Cn({prompt_tokens:0,completion_tokens:0,total_tokens:0}),2),I=A[0],F=A[1],G=Pn(Cn(In[2]),2),z=G[0],M=G[1],B=Pn(Cn(""),2),D=B[0],q=B[1],Y=Pn(Cn(2048),2),W=Y[0],Z=Y[1];Nn((function(){var e=z.description.split("\n").map((function(e){return e.trim()}));e=e.join("\n"),o(e),q(z.stopSequence),x(z.temperature),Z(z.maxTokens),l(z.mode)}),[z]);var H=function(){var e,t=(e=On().mark((function e(){var t,r,i,c,l=arguments;return On().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=l.length>0&&void 0!==l[0]?l[0]:a,O(!0),r=D.replace(/\\n/g,"\n"),e.next=5,(0,E.PV)("".concat(_,"/make_completions"),{method:"POST",nonce:P,json:{env:"playground",session:T,prompt:t,temperature:R,model:y,maxTokens:W,stop:r}});case 5:i=e.sent,console.log("Completions",{prompt:t,result:i}),i.success?(o(t+"\n"+i.data),F(i.usage),c={prompt_tokens:C.prompt_tokens+i.usage.prompt_tokens,completion_tokens:C.completion_tokens+i.usage.completion_tokens,total_tokens:C.total_tokens+i.usage.total_tokens},N(c)):n(i.message),O(!1);case 9:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Ln(o,r,a,i,c,"next",e)}function c(e){Ln(o,r,a,i,c,"throw",e)}i(void 0)}))});return function(){return t.apply(this,arguments)}}(),U=An((function(){var e=0,t=0,n=Ge.find((function(e){return y&&y.includes(e.model)}));return n&&(e=(C.total_tokens/1e3*n.price).toFixed(4),t=(I.total_tokens/1e3*n.price).toFixed(4)),{sessionPrice:e,lastRequestPrice:t}}),[C,I]),V=U.sessionPrice,J=U.lastRequestPrice;return React.createElement(d.s,{nekoErrors:[]},React.createElement(et,{title:"Playground"}),React.createElement(v.o,null,React.createElement(v.z,{full:!0},React.createElement(Ze,{options:j}),React.createElement(ge.H,{style:{marginBottom:0}},React.createElement(f.O,{p:!0},"Welcome to the AI Playground! Here, you can play with different AI models and ask the UI to perform various tasks for you. You can ask it to write, rewrite, or translate an article, categorize words or elements into groups, write an email, etc. ",React.createElement("b",null,"Let me know if there are any new features you would like to see!")," Have fun 🥳"))),React.createElement(v.z,null,React.createElement(Kt,null,React.createElement("h3",{style:{marginTop:0}},"Templates"),React.createElement("ul",null,In.map((function(e){return React.createElement("li",{className:z.id===e.id?"active":"",onClick:function(){M(e)}},e.name)}))),React.createElement("h3",{style:{marginTop:0}},"Mode"),React.createElement(be.N,{scrolldown:!0,id:"mode",name:"mode",disabled:!0,value:c,description:"",onChange:l},React.createElement(be.Z,{key:"chat",id:"chat",value:"chat",label:"Chat"}),React.createElement(be.Z,{key:"query",id:"query",value:"query",label:"Query"})))),React.createElement(v.z,{style:{flex:3}},React.createElement(Fn,{onChange:function(e){o(e.target.value)},value:a}),"chat"===c&&React.createElement("div",{style:{display:"flex"}},React.createElement("span",{class:"dashicons dashicons-format-chat",style:{position:"absolute",color:"white",zIndex:200,fontSize:28,marginTop:12,marginLeft:10}}),React.createElement(Qt,{id:"entry",value:s,onChange:m,onEnter:function(){var e=a+"\nHuman: "+s;o(e),m(""),H(e)},disabled:S})),"chat"!==c&&React.createElement("div",{style:{display:"flex"}},React.createElement(b._,{onClick:function(){o(z.description)},disabled:S,style:{height:50,fontSize:14,flex:1}},"Reset"),React.createElement(b._,{onClick:function(){H()},disabled:S,style:{height:50,fontSize:14,flex:4}},"Submit"))),React.createElement(v.z,null,React.createElement(Kt,null,React.createElement("h3",null,"Settings"),React.createElement("label",null,"Model:"),React.createElement(be.N,{id:"models",value:y,scrolldown:!0,onChange:g},p.map((function(e){return React.createElement(be.Z,{value:e.id,label:e.name})}))),React.createElement("label",null,"Temperature:"),React.createElement(ve.A,{id:"temperature",name:"temperature",value:R,type:"number",onBlur:function(e){return x(parseFloat(e))},description:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:R>=0&&R<=1?"inherit":"red"}},"Between 0 and 1. Higher values means the model will take more risks."))}),React.createElement("label",null,"Max Tokens:"),React.createElement(ve.A,{id:"maxTokens",name:"maxTokens",value:W,type:"number",onBlur:function(e){return Z(parseInt(e))},description:React.createElement(React.Fragment,null,React.createElement("span",null,"The maximum number of tokens to generate. The model will stop generating once it hits this limit."))}),React.createElement("label",null,"Stop Sequence:"),React.createElement(ve.A,{id:"stopSequence",name:"stopSequence",value:D,type:"text",onChange:q,onBlur:q,description:React.createElement(React.Fragment,null,React.createElement("span",null,"The sequence of tokens that will cause the model to stop generating text. You absolutely need this with your own models."))})),React.createElement(Kt,{style:{marginTop:20}},React.createElement("h3",null,"Usage"),React.createElement("p",null,"Keeps track of the current usage of the AI."),React.createElement("h4",null,"Session"),React.createElement("div",null,"Tokens: ",C.total_tokens),React.createElement("div",null,"Price: $",V),React.createElement("h4",null,"Last Request"),React.createElement("div",null,"Tokens: ",I.total_tokens),React.createElement("div",null,"Price: $",J),React.createElement(b._,{style:{marginTop:10,width:"100%"},onClick:function(){N({prompt_tokens:0,completion_tokens:0,total_tokens:0}),F({prompt_tokens:0,completion_tokens:0,total_tokens:0})}},"Reset Usage")))),React.createElement(Re.L,{isOpen:t,onRequestClose:function(){n()},onOkClick:function(){n()},title:"Error",content:React.createElement("p",null,t)}))};var zn,Mn,Bn=n(5307);function Dn(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var qn=A.ZP.div(zn||(zn=Dn(["\n margin-bottom: 5px;\n"]))),Yn=A.ZP.div(Mn||(Mn=Dn(["\n margin-top: 15px;\n padding: 15px;\n font-size: 14px;\n cursor: pointer;\n border-radius: 15px;\n background: #dbf2ff;\n line-height: 120%;\n\n &:hover {\n background: #037cba;\n color: white;\n }\n"])));function Wn(e){return Wn="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},Wn(e)}function Zn(){Zn=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function m(){}function h(){}function p(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=p.prototype=m.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==Wn(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:h,configurable:!0}),h.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function Hn(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function Un(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Hn(o,r,a,i,c,"next",e)}function c(e){Hn(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Vn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Jn(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 Jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var $n=wp.element,Kn=$n.useState,Qn=$n.useEffect,Xn=$n.useMemo;const er=function(e){var t=e.post,n=e.onTitleClick,r=void 0===n?{}:n,a=e.onClose,o=void 0===a?{}:a,i=Vn(Kn([]),2),c=i[0],l=i[1],u=Vn(Kn(!1),2),s=u[0],f=u[1],m=Vn(Kn(!1),2),h=m[0],p=m[1];Qn((function(){t&&d(t)}),[t]);var d=function(){var e=Un(Zn().mark((function e(t){var n,r;return Zn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.postId,t.postTitle,f(!0),e.next=4,(0,E.PV)("".concat(_,"/make_titles"),{method:"POST",nonce:P,json:{postId:n}});case 4:(r=e.sent).success&&l(r.data),f(!1);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),y=function(){var e=Un(Zn().mark((function e(t){return Zn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),e.prev=1,e.next=4,r(t);case 4:g(),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(1),p(e.t0.message);case 10:f(!1);case 11:case"end":return e.stop()}}),e,null,[[1,7]])})));return function(t){return e.apply(this,arguments)}}(),g=function(){var e=Un(Zn().mark((function e(){return Zn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o(),l([]),p(),f(!1);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),b=Xn((function(){return s?React.createElement(Bn.S,{type:"circle",size:"10%"}):h?React.createElement(React.Fragment,null,"Error: ",h):(null==c?void 0:c.length)>0?React.createElement(React.Fragment,null,"Pick a new title by clicking on it.",React.createElement(qn,null,c.map((function(e){return React.createElement(Yn,{key:e,onClick:function(){y(e)}},e)})))):React.createElement(React.Fragment,null,"Nothing to display.")}),[s,c,h]);return React.createElement(v.o,null,React.createElement(Re.L,{isOpen:t,onRequestClose:g,title:'New title for "'.concat(null==t?void 0:t.postTitle,'"'),content:b,ok:"Close",onOkClick:g}))};function tr(e){return tr="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},tr(e)}function nr(){nr=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function m(){}function h(){}function p(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=p.prototype=m.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==tr(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:h,configurable:!0}),h.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function rr(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function ar(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var or=wp.element,ir=or.useState,cr=or.useEffect;or.useMemo;const lr=function(){var e,t,n=(e=ir(),t=2,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ar(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ar(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.")}()),r=n[0],a=n[1];cr((function(){document.querySelectorAll(".mwai-link-title").forEach((function(e){var t=e.getAttribute("data-id"),n=e.getAttribute("data-title");e.addEventListener("click",(function(){a({postId:t,postTitle:n})}),!1)}))}),[]);var o=function(){var e,t=(e=nr().mark((function e(t){var n,o,i,c;return nr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,E.PV)("".concat(_,"/update_post_title"),{method:"POST",nonce:P,json:{postId:r.postId,title:t}});case 2:if((n=e.sent).success){e.next=7;break}throw new Error(n.message);case 7:a(),(o=document.querySelector('tr[id="post-'.concat(r.postId,'"]')))&&(i=o.querySelector(".row-title"))&&(i.innerHTML=t),(c=o.querySelector(".hidden .post_title"))&&(c.innerHTML=t);case 12:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){rr(o,r,a,i,c,"next",e)}function c(e){rr(o,r,a,i,c,"throw",e)}i(void 0)}))});return function(e){return t.apply(this,arguments)}}();return React.createElement(v.o,null,React.createElement(er,{post:r,onTitleClick:o,onClose:function(){a()}}))};function ur(e){return ur="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},ur(e)}function sr(){sr=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function m(){}function h(){}function p(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=p.prototype=m.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==ur(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:h,configurable:!0}),h.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function fr(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function mr(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){fr(o,r,a,i,c,"next",e)}function c(e){fr(o,r,a,i,c,"throw",e)}i(void 0)}))}}function hr(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return pr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pr(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 pr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var dr=wp.element,yr=dr.useState,vr=dr.useEffect,gr=dr.useMemo,br=[{id:"none",name:"None",model:"text-davinci-003",temperature:.6,maxTokens:2048},{id:"best-villages-france",name:"Best Villages in France",topic:"The best villages in France. Food, spring, summer, beach, wine. Recommendation of activities."}],wr=(null==j?void 0:j.languages)||[],Er=Object.keys(wr).map((function(e){return{value:e,label:wr[e]}}));const Rr=function(){var e=hr(yr(),2),t=e[0],n=e[1],r=hr(yr(br[0]),2),a=r[0],o=r[1],i=hr(yr(""),2),c=i[0],l=i[1],u=hr(yr(""),2),s=u[0],m=u[1],h=hr(yr(2),2),p=h[0],y=h[1],g=hr(yr(""),2),w=g[0],R=g[1],x=hr(yr(1),2),k=x[0],S=x[1],O=hr(yr(""),2),L=O[0],C=O[1],N=Ke(j),A=N.models,I=N.model,F=N.setModel,G=hr(yr(""),2),z=G[0],M=G[1],B=hr(yr("en"),2),D=B[0],q=B[1],Y=hr(yr("creative"),2),W=Y[0],Z=Y[1],H=hr(yr("cheerful"),2),U=H[0],V=H[1],J=hr(yr('Write a title for an article about "[**TOPIC**]" in [**LANGUAGE**]. Style: [**WRITING-STYLE**]. Tone: [**WRITING-TONE**]. Must be between 40 and 60 characters.'),2),$=J[0],K=J[1],Q=hr(yr('Write [**HEADING-COUNT**] consecutive headings for an article about "[**TITLE**]", in [**LANGUAGE**]. Style: [**WRITING-STYLE**]. Tone: [**WRITING-TONE**].\n\nEach heading is between 40 and 60 characters.\n\nUse Markdown for the headings (## ).'),2),X=Q[0],ee=Q[1],te=hr(yr('Write an article about "[**TITLE**]" in [**LANGUAGE**]. The article is organized by the following headings:\n\n[**HEADS**]\n\nWrite [**PARAGRAPHS_PER_HEAD**] paragraphs per heading.\n\nUse Markdown for formatting.\n\nAdd an introduction prefixed by "===INTRO: ", and a conclusion prefixed by "===OUTRO: ".\n\nStyle: [**WRITING-STYLE**]. Tone: [**WRITING-TONE**].'),2),ne=te[0],re=te[1],ae=hr(yr('Write a short, SEO-friendly excerpt for en article about "[**TITLE**]"'),2),oe=ae[0],ie=ae[1],ce=hr(yr(.6),2),le=ce[0],ue=ce[1],se=hr(yr(2048),2),fe=se[0],me=se[1],he=hr(yr(!1),2),pe=he[0],de=he[1],ye=hr(yr(!1),2),ge=ye[0],we=ye[1],Ee=hr(yr(!1),2),xe=Ee[0],ke=Ee[1],_e=hr(yr(),2),Se=_e[0],Oe=_e[1],Le=gr((function(){return function(e){var t=e.split(" ").length,n=e.length,r=[];if(n)return t<3?r.push("The title is too short. It should be at least 3 words."):t>8?r.push("The title is too long. It should be no more than 8 words."):n<40?r.push("The title is too short. It should be at least 40 characters."):n>70&&r.push("The title is too long. It should be no more than 70 characters."),r.join(" ")}(c)}),[c]),Pe=gr((function(){return Er.find((function(e){return e.value===D})).label}));vr((function(){m(a.topic)}),[a]);var je=function(e){return $.replace("[**TOPIC**]",e).replace("[**LANGUAGE**]",Pe).replace("[**WRITING-STYLE**]",W).replace("[**WRITING-TONE**]",U)},Te=function(e){return X.replace("[**HEADING-COUNT**]",p).replace("[**TITLE**]",e).replace("[**LANGUAGE**]",Pe).replace("[**WRITING-STYLE**]",W).replace("[**WRITING-TONE**]",U)},Ce=function(e,t){return ne.replace("[**TITLE**]",e).replace("[**LANGUAGE**]",Pe).replace("[**HEADS**]",t).replace("[**PARAGRAPHS_PER_HEAD**]",k).replace("[**WRITING-STYLE**]",W).replace("[**WRITING-TONE**]",U)},Ne=function(e){return oe.replace("[**TITLE**]",e)},Ae=function(){var e=mr(sr().mark((function e(){var t,r,a,o=arguments;return sr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.length>0&&void 0!==o[0]?o[0]:prompt,e.next=3,(0,E.PV)("".concat(_,"/make_completions"),{method:"POST",nonce:P,json:{env:"admin-tools",session:T,prompt:t,temperature:le,maxTokens:2048,model:I}});case 3:if(r=e.sent,console.log("Data:",{prompt:t,result:r}),!r.success){e.next=9;break}return(a=r.data).startsWith('"')&&a.endsWith('"')&&(a=a.substring(1,a.length-1)),e.abrupt("return",a);case 9:return n(r.message),e.abrupt("return",null);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Ge=function(){var e=mr(sr().mark((function e(){var t,n,r;return sr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return de(!0),t=je(s),e.next=4,Ae(t);case 4:if(n=e.sent,de(!1),!n){e.next=18;break}return l(n),e.next=10,ze(n);case 10:if(!(r=e.sent)){e.next=18;break}return e.next=14,Me(n,r);case 14:if(!e.sent){e.next=18;break}return e.next=18,Be(n);case 18:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ze=function(){var e=mr(sr().mark((function e(){var t,n,r,a=arguments;return sr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=a.length>0&&void 0!==a[0]?a[0]:c){e.next=4;break}return alert("Title is missing!"),e.abrupt("return");case 4:return de(!0),R(""),n=Te(t),e.next=9,Ae(n);case 9:return(r=He(r=e.sent))&&R(r),de(!1),e.abrupt("return",r);case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Me=function(){var e=mr(sr().mark((function e(){var t,n,r,a,o=arguments;return sr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=o.length>0&&void 0!==o[0]?o[0]:c,n=o.length>1&&void 0!==o[1]?o[1]:w,t){e.next=5;break}return alert("Title is missing!"),e.abrupt("return");case 5:if(n){e.next=8;break}return alert("Headings are missing!"),e.abrupt("return");case 8:return de(!0),C(""),r=Ce(t,n),e.next=13,Ae(r);case 13:return(a=e.sent)&&(a=(a=(a=(a=(a=(a=a.replace(/^===INTRO:\n/,"")).replace(/^===INTRO: \n/,"")).replace(/===INTRO: /,"")).replace(/===OUTRO:\n/,"")).replace(/===OUTRO: \n/,"")).replace(/===OUTRO: /,""),C(a)),de(!1),e.abrupt("return",a);case 17:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Be=function(){var e=mr(sr().mark((function e(){var t,n,r,a=arguments;return sr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=a.length>0&&void 0!==a[0]?a[0]:c){e.next=4;break}return alert("Title is missing!"),e.abrupt("return");case 4:return de(!0),M(""),n=Ne(t),e.next=9,Ae(n);case 9:return(r=e.sent)&&M(r),de(!1),e.abrupt("return",r);case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),De=function(){var e=mr(sr().mark((function e(){var t;return sr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return de(!0),e.next=3,(0,E.PV)("".concat(_,"/create_post"),{method:"POST",nonce:P,json:{title:c,headings:w,content:L,excerpt:z,language:D}});case 3:t=e.sent,de(!1),t.success?Oe(t.postId):n(t.message);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),qe=function(){l(""),R(""),C(""),M(""),Oe()};return React.createElement(d.s,{nekoErrors:[]},React.createElement(et,{title:"Content Generator"}),React.createElement(v.o,null,React.createElement(v.z,{full:!0},React.createElement(Ze,{options:j}),React.createElement(f.O,{p:!0,style:{marginTop:0,marginBottom:0}},React.createElement("b",null,"Write a Topic (followed by a few keywords), and click Generate All. That's it!")," You can also write a Title, generate the Sections, Content, and Excerpt separately (while modifying what was generated previously) to perfect the results. Use the Create Post button when you're happy with the result. You can also modify the prompts that are used by the AI. Don't hesitate to join us on the ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/support/plugin/ai-engine/"},"Support Forums"),". Let's make this better together! 💕")),React.createElement(v.z,{style:{flex:1}},React.createElement(Kt,{style:{marginBottom:25}},React.createElement("h2",{style:{marginTop:0}},"Topic"),React.createElement(Qe.l,{disabled:pe,value:s,onChange:m,rows:5}),React.createElement(ht.i,null),React.createElement(b._,{fullWidth:!0,disabled:!s||pe,onClick:Ge},"Generate All")),React.createElement(Kt,{style:{marginBottom:25}},React.createElement("h3",{style:{marginTop:0}},"Templates"),React.createElement("ul",null,br.map((function(e){return React.createElement("li",{className:a.id===e.id?"active":"",onClick:function(){o(e)}},e.name)}))),React.createElement("div",null,"Soon, you'll be able to create templates and re-use them easily."))),React.createElement(v.z,{style:{flex:3}},React.createElement(Kt,{style:{marginBottom:25}},React.createElement("h2",{style:{marginTop:0}},"Title"),React.createElement(ve.A,{disabled:pe,value:c,onChange:l}),Le&&React.createElement("div",{className:"information"},"Advice: ",Le),React.createElement(ht.i,{height:20}),React.createElement(tt,null,React.createElement("h2",null,"Sections"),React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement("label",{style:{margin:"0 5px 0 0"}},"# of Sections: "),React.createElement(be.N,{scrolldown:!0,id:"headingsCount",disabled:pe,style:{marginRight:10},value:p,description:"",onChange:y},React.createElement(be.Z,{key:2,id:2,value:2,label:2}),React.createElement(be.Z,{key:3,id:3,value:3,label:3}),React.createElement(be.Z,{key:4,id:4,value:4,label:4}),React.createElement(be.Z,{key:6,id:6,value:6,label:6}),React.createElement(be.Z,{key:8,id:8,value:8,label:8}),React.createElement(be.Z,{key:10,id:10,value:10,label:10}),React.createElement(be.Z,{key:12,id:12,value:12,label:12})),React.createElement(b._,{disabled:!c,isBusy:pe,onClick:function(){return ze()}},"Generate Sections"))),React.createElement(ht.i,{height:20}),React.createElement(Qe.l,{disabled:pe,rows:4,value:w,onBlur:R}),React.createElement("div",{className:"information"},'Add, rewrite, remove, or reorganize those sections as you wish before clicking "Generate Content". I recommend using Markdown.'),React.createElement(ht.i,{height:20}),React.createElement(tt,null,React.createElement("h2",null,"Content"),React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement("label",{style:{margin:"0 5px 0 0"}},"# of Paragraphs per Section: "),React.createElement(be.N,{scrolldown:!0,id:"paragraphsCount",disabled:pe,style:{marginRight:10},value:k,description:"",onChange:S},React.createElement(be.Z,{key:1,id:1,value:1,label:1}),React.createElement(be.Z,{key:2,id:2,value:2,label:2}),React.createElement(be.Z,{key:3,id:3,value:3,label:3}),React.createElement(be.Z,{key:4,id:4,value:4,label:4}),React.createElement(be.Z,{key:6,id:6,value:6,label:6}),React.createElement(be.Z,{key:8,id:8,value:8,label:8}),React.createElement(be.Z,{key:10,id:10,value:10,label:10})),React.createElement(b._,{disabled:!c,isBusy:pe,onClick:function(){return Me()}},"Generate Content"))),React.createElement(ht.i,{height:20}),React.createElement(Qe.l,{disabled:pe,rows:18,value:L,onBlur:C}),React.createElement("div",{className:"information"},'You can modify the content before using "Create Post". Markdown is supported, and will be converted to HTML when the post is created.'),React.createElement(ht.i,{height:20}),React.createElement(tt,null,React.createElement("h2",null,"Excerpt"),React.createElement(b._,{disabled:!c,isBusy:pe,onClick:function(){return Be()}},"Generate Excerpt")),React.createElement(ht.i,{height:20}),React.createElement(Qe.l,{disabled:pe,value:z,onBlur:M,rows:3}),React.createElement(ht.i,{height:20}),React.createElement(b._,{fullWidth:!0,style:{height:60},onClick:De,isBusy:pe,disabled:!c||!L},"Create Post"))),React.createElement(v.z,null,React.createElement(Kt,{style:{marginBottom:25}},React.createElement("h2",{style:{marginTop:0}},"Content Params"),React.createElement("label",null,"Language:"),React.createElement(be.N,{scrolldown:!0,id:"language",name:"language",disabled:pe,value:D,description:"",onChange:q},Er.map((function(e){return React.createElement(be.Z,{key:e.value,id:e.value,value:e.value,label:e.label})}))),React.createElement("label",null,"Writing style:"),React.createElement(be.N,{scrolldown:!0,id:"writingStyle",name:"writingStyle",disabled:pe,value:W,description:"",onChange:Z},Ie.map((function(e){return React.createElement(be.Z,{key:e.value,id:e.value,value:e.value,label:e.label})}))),React.createElement("label",null,"Writing tone:"),React.createElement(be.N,{scrolldown:!0,id:"writingTone",name:"writingTone",disabled:pe,value:U,description:"",onChange:V},Fe.map((function(e){return React.createElement(be.Z,{key:e.value,id:e.value,value:e.value,label:e.label})})))),React.createElement(b._,{fullWidth:!0,onClick:function(){l(""),m(""),R(""),C(""),M(""),Oe()}},"Reset"),React.createElement(Kt,{style:{marginTop:25,marginBottom:25}},React.createElement(tt,null,React.createElement("h2",null,"Model Params"),React.createElement(b._,{onClick:function(){return we(!ge)}},ge?"Hide":"Show")),ge&&React.createElement(React.Fragment,null,React.createElement("label",null,"Model:"),React.createElement(be.N,{id:"models",value:I,scrolldown:!0,onChange:F},A.map((function(e){return React.createElement(be.Z,{value:e.id,label:e.name})}))),React.createElement("label",null,"Temperature:"),React.createElement(ve.A,{id:"temperature",name:"temperature",value:le,type:"number",onChange:ue,onBlur:ue,description:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:le>=0&&le<=1?"inherit":"red"}},"Between 0 and 1.")," Higher values means the model will take more risks.")}),React.createElement("label",null,"Max Tokens:"),React.createElement(ve.A,{id:"maxTokens",name:"maxTokens",value:fe,type:"number",onChange:me,onBlur:me,description:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:fe>=1&&fe<=4096?"inherit":"red"}},"Between 1 and 2048.")," Higher values means the model will generate more content.")}))),React.createElement(Kt,null,React.createElement(tt,null,React.createElement("h2",null,"Prompts"),React.createElement(b._,{onClick:function(){return ke(!xe)}},xe?"Hide":"Show")),xe&&React.createElement(React.Fragment,null,React.createElement("p",null,"The prompts are automatically generated for you, but you can enhance them once the values are set."),React.createElement("label",null,"Prompt for ",React.createElement("b",null,"Title")),React.createElement(Qe.l,{disabled:pe,value:$,onChange:K}),React.createElement("label",null,"Prompt for ",React.createElement("b",null,"Sections")),React.createElement(Qe.l,{disabled:pe,value:X,onChange:ee}),React.createElement("label",null,"Prompt for ",React.createElement("b",null,"Content")),React.createElement(Qe.l,{disabled:pe,value:ne,onChange:re}),React.createElement("label",null,"Prompt for ",React.createElement("b",null,"Excerpt")),React.createElement(Qe.l,{disabled:pe,value:oe,onChange:ie}))))),React.createElement(Re.L,{isOpen:Se,onRequestClose:function(){return Oe()},onOkClick:function(){window.open("/wp-admin/post.php?post=".concat(Se,"&action=edit"),"_blank"),qe()},ok:"Edit the Post",cancel:"Close",onCancelClick:qe,title:"Post Created!",content:React.createElement("p",null,"The post was created as draft.")}),React.createElement(Re.L,{isOpen:t,onRequestClose:function(){n()},onOkClick:function(){n()},title:"Error",content:React.createElement("p",null,t)}))};function xr(e){return xr="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},xr(e)}var kr;function _r(){_r=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function m(){}function h(){}function p(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=p.prototype=m.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==xr(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:h,configurable:!0}),h.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function Sr(e){return function(e){if(Array.isArray(e))return Tr(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||jr(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 Or(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function Lr(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Or(o,r,a,i,c,"next",e)}function c(e){Or(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Pr(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||jr(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 jr(e,t){if(e){if("string"==typeof e)return Tr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Tr(e,t):void 0}}function Tr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Cr=wp.element,Nr=Cr.useState,Ar=Cr.useEffect,Ir=Cr.useMemo,Fr=[{id:"none",name:"None",prompt:""},{id:"japan",name:"Ghibli Inspired",prompt:"japan, tokyo, trees, izakaya, anime oil painting, high resolution, ghibli inspired, 4k"},{id:"steampunk",name:"Steampunk Architecture",prompt:"steampunk architecture, exterior view, award-winning architectural photography from magazine, trees, theater"},{id:"modern-illustration",name:"Modern Illustration",prompt:"illustration of a cat, modern design, for the web, cute, happy, 4k, high resolution, trending in artstation"}],Gr=[1,2,3,6,9],zr=A.ZP.div(kr||(kr=function(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(["\n margin-bottom: 5px;\n\n label {\n margin-bottom: 5px;\n display: block;\n }\n"])));const Mr=function(){var e=Pr(Nr(),2),t=e[0],n=e[1],r=Pr(Nr(Fr[0]),2),a=r[0],o=r[1],i=Pr(Nr("japan, tokyo, trees, izakaya, anime oil painting, high resolution, ghibli inspired, 4k"),2),c=i[0],l=i[1],u=Pr(Nr(!0),2),s=u[0],m=u[1],h=Pr(Nr(3),2),y=h[0],g=h[1],w=Pr(Nr([]),2),R=w[0],x=w[1],k=Pr(Nr(),2),S=k[0],O=k[1],L=Pr(Nr(""),2),C=L[0],N=L[1],A=Pr(Nr(""),2),I=A[0],F=A[1],G=Pr(Nr(""),2),z=G[0],M=G[1],B=Pr(Nr(""),2),D=B[0],q=B[1],Y=Pr(Nr(""),2),W=Y[0],Z=Y[1],H=Pr(Nr(!1),2),U=H[0],V=H[1],J=Pr(Nr([]),2),$=J[0],K=J[1],Q=Ir((function(){return R.indexOf(S)}),[S,R]);Ar((function(){l(a.prompt)}),[a]),Ar((function(){if(S){var e=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:42,n=e.replace(/[\s|,]+/g,"-"),r=(n=n.replace(/--+/g,"-")).split("-"),a=r[0],o=1;a.length+r[o].length<t&&o<r.length;)a+="-"+r[o],o++;return a.length>t+1&&(a=a.slice(0,t+2)),a}(c)+".png";Z(e),N(c),F(c),M(c),q(c)}}),[S]);var X=function(){var e=Lr(_r().mark((function e(){var t;return _r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return V(!0),e.next=3,(0,E.PV)("".concat(_,"/make_images"),{method:"POST",nonce:P,json:{env:"admin-tools",session:T,prompt:c,maxResults:y}});case 3:return t=e.sent,V(!1),t.success&&x(s?[].concat(Sr(R),Sr(t.data)):t.data),n(t.message),e.abrupt("return",null);case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ee=function(){var e=Lr(_r().mark((function e(){var t;return _r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return V(!0),e.next=3,(0,E.PV)("".concat(_,"/create_image"),{method:"POST",nonce:P,json:{url:S,title:C,description:I,caption:z,alt:D,filename:W}});case 3:return t=e.sent,V(!1),t.success&&K([].concat(Sr($),[{id:t.attachmentId,url:S}])),n(t.message),e.abrupt("return",null);case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),te=Ir((function(){var e=$.find((function(e){return e.url===S}));return e?e.id:null}),[S,$]);return console.log({createdMediaIds:$,currentCreatedMediaId:te}),React.createElement(d.s,{nekoErrors:[]},React.createElement(et,{title:"Image Generator"}),React.createElement(v.o,null,React.createElement(v.z,{full:!0},React.createElement(Ze,{options:j}),React.createElement(f.O,{p:!0,style:{marginTop:0,marginBottom:0}},"This will also be available in the Post Editor soon. If you have any idea or request, please join us on the ",React.createElement("a",{target:"_blank",href:"https://wordpress.org/support/plugin/ai-engine/"},"Support Forum"),"! 🎵")),React.createElement(v.z,null,React.createElement(Kt,{style:{marginBottom:25}},React.createElement("h3",{style:{marginTop:0}},"Templates"),React.createElement("ul",null,Fr.map((function(e){return React.createElement("li",{className:a.id===e.id?"active":"",onClick:function(){o(e)}},e.name)}))),React.createElement("div",null,"Soon, you'll be able to create templates and re-use them easily."))),React.createElement(v.z,{style:{flex:3}},S&&React.createElement(React.Fragment,null,React.createElement(ge.H,null,React.createElement(tt,{style:{paddingBottom:10}},React.createElement("h2",null,"Images Generator"),React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement(b._,{disabled:Q<1||U,onClick:function(){Q>0&&O(R[Q-1])}},"<"),React.createElement(b._,{disabled:U,onClick:function(){return O()}},"Back to results"),React.createElement(b._,{disabled:Q>=R.length-1||U,onClick:function(){Q<R.length-1&&O(R[Q+1])}},">"))),React.createElement("div",{style:{display:"flex"}},React.createElement("div",{style:{flex:2}},React.createElement("img",{src:S,style:{width:"100%"}})),React.createElement("div",{style:{flex:1,marginLeft:10,display:"flex",flexDirection:"column"}},React.createElement(zr,null,React.createElement("label",null,"Title:"),React.createElement(rt,{value:C,onBlur:N})),React.createElement(zr,null,React.createElement("label",null,"Caption:"),React.createElement(rt,{value:z,onBlur:M})),React.createElement(zr,null,React.createElement("label",null,"Description:"),React.createElement(rt,{value:I,onBlur:F})),React.createElement(zr,null,React.createElement("label",null,"Alternative Text:"),React.createElement(rt,{value:D,onBlur:q})),React.createElement(zr,null,React.createElement("label",null,"Filename:"),React.createElement(ve.A,{value:W,onChange:Z})),React.createElement(b._,{fullWidth:!0,style:{marginTop:7},isBusy:U,onClick:function(){return ee()}},"Add to Media Library"),React.createElement(b._,{fullWidth:!0,style:{marginLeft:0,marginTop:7},isBusy:U,onClick:function(){return(e=document.createElement("a")).href=S,e.target="_blank",e.download=W,void e.click();var e}},"Download"),te&&React.createElement(Ee.C,{style:{fontSize:13,padding:"10px 5px"}},"The media has been created! You can edit it here: ",React.createElement("a",{href:"/wp-admin/post.php?post=".concat(te,"&action=edit"),target:"_blank"},"Edit Media #",te),"."))))),!S&&React.createElement(React.Fragment,null,React.createElement(ge.H,null,React.createElement(tt,null,React.createElement("h2",null,"Generated Images"),React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement("label",{style:{margin:"0 5px 0 0"}},"# of Images: "),React.createElement(be.N,{scrolldown:!0,id:"maxResults",name:"maxResults",disabled:U,style:{marginRight:10},value:y,description:"",onChange:g},Gr.map((function(e){return React.createElement(be.Z,{key:e,id:e,value:e,label:e})}))),React.createElement(b._,{disabled:!c,isBusy:U,onClick:X},"Generate Images"))),React.createElement(rt,{value:c,onBlur:l,style:{marginTop:20}}),React.createElement(nt,null,R.map((function(e){return React.createElement("img",{src:e,onClick:function(){return O(e)}})})),Sr(Array(Math.max(3-R.length,0)).keys()).map((function(e){return React.createElement("div",{class:"empty-image"})})))))),React.createElement(v.z,null,React.createElement(ge.H,{style:{marginBottom:25}},React.createElement("h2",{style:{marginTop:0}},"Settings"),React.createElement(p.P,{id:"continuous_mode ",label:"Continuous",value:"1",checked:s,description:"New images will be added to the already generated images.",onChange:m})))),React.createElement(Re.L,{isOpen:t,onRequestClose:function(){n()},onOkClick:function(){n()},title:"Error",content:React.createElement("p",null,t)}))};function Br(e){return Br="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},Br(e)}function Dr(){Dr=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function m(){}function h(){}function p(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=p.prototype=m.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==Br(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:h,configurable:!0}),h.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function qr(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function Yr(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){qr(o,r,a,i,c,"next",e)}function c(e){qr(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Wr(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Zr(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Zr(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 Zr(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Hr=wp.element,Ur=Hr.useState,Vr=Hr.useEffect,Jr=Hr.useMemo;const $r=function(e){var t=e.post,n=e.onExcerptClick,r=void 0===n?{}:n,a=e.onClose,o=void 0===a?{}:a,i=Wr(Ur([]),2),c=i[0],l=i[1],u=Wr(Ur(!1),2),s=u[0],f=u[1],m=Wr(Ur(!1),2),h=m[0],p=m[1];Vr((function(){t&&d(t)}),[t]);var d=function(){var e=Yr(Dr().mark((function e(t){var n,r;return Dr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.postId,f(!0),e.next=4,(0,E.PV)("".concat(_,"/make_excerpts"),{method:"POST",nonce:P,json:{postId:n}});case 4:(r=e.sent).success&&l(r.data),f(!1);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),y=function(){var e=Yr(Dr().mark((function e(t){return Dr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),e.prev=1,e.next=4,r(t);case 4:g(),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(1),p(e.t0.message);case 10:f(!1);case 11:case"end":return e.stop()}}),e,null,[[1,7]])})));return function(t){return e.apply(this,arguments)}}(),g=function(){var e=Yr(Dr().mark((function e(){return Dr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o(),l([]),p(),f(!1);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),b=Jr((function(){return s?React.createElement(Bn.S,{type:"circle",size:"10%"}):h?React.createElement(React.Fragment,null,"Error: ",h):(null==c?void 0:c.length)>0?React.createElement(React.Fragment,null,"Pick a new excerpt by clicking on it.",React.createElement(qn,null,c.map((function(e){return React.createElement(Yn,{key:e,onClick:function(){y(e)}},e)})))):React.createElement(React.Fragment,null,"Nothing to display.")}),[s,c,h]);return React.createElement(v.o,null,React.createElement(Re.L,{isOpen:t,onRequestClose:g,title:'New excerpt for "'.concat(null==t?void 0:t.postTitle,'"'),content:b,ok:"Close",onOkClick:g}))};function Kr(e){return Kr="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},Kr(e)}function Qr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Xr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qr(Object(n),!0).forEach((function(t){ea(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ea(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==Kr(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==Kr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===Kr(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ta=wp.element,na=(ta.useState,ta.useEffect,ta.useMemo),ra=React.createElement("g",null,React.createElement("g",null,React.createElement("path",{d:"m391 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#39326c"}),React.createElement("path",{d:"m331 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#39326c"}),React.createElement("path",{d:"m271 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#39326c"}),React.createElement("path",{d:"m211 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#5f55af"}),React.createElement("path",{d:"m151 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#5f55af"}),React.createElement("path",{d:"m91 81h30v-66c0-8.284-6.716-15-15-15-8.284 0-15 6.716-15 15z",fill:"#5f55af"}),React.createElement("path",{d:"m406 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z",fill:"#39326c"}),React.createElement("path",{d:"m346 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z",fill:"#39326c"}),React.createElement("path",{d:"m286 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z",fill:"#39326c"}),React.createElement("g",{fill:"#5f55af"},React.createElement("path",{d:"m226 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m166 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m106 512c8.284 0 15-6.716 15-15v-66h-30v66c0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 121h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 181h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 241h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 301h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 361h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"}),React.createElement("path",{d:"m15 421h66v-30h-66c-8.284 0-15 6.716-15 15 0 8.284 6.716 15 15 15z"})),React.createElement("path",{d:"m431 91v30h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15z",fill:"#39326c"}),React.createElement("path",{d:"m431 181h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"}),React.createElement("path",{d:"m431 241h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"}),React.createElement("path",{d:"m431 301h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"}),React.createElement("path",{d:"m431 361h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"}),React.createElement("path",{d:"m431 421h66c8.284 0 15-6.716 15-15 0-8.284-6.716-15-15-15h-66z",fill:"#39326c"})),React.createElement("g",null,React.createElement("path",{d:"m446 51h-380c-8.284 0-15 6.716-15 15v380c0 8.284 6.716 15 15 15h380c8.284 0 15-6.716 15-15v-380c0-8.284-6.716-15-15-15z",fill:"#aed0ff"}),React.createElement("g",null,React.createElement("path",{d:"m461 446v-380c0-8.284-6.716-15-15-15h-190v410h190c8.284 0 15-6.716 15-15z",fill:"#7c84e8"})),React.createElement("path",{d:"m386 111h-260c-8.284 0-15 6.716-15 15v260c0 8.284 6.716 15 15 15h260c8.284 0 15-6.716 15-15v-260c0-8.284-6.716-15-15-15z",fill:"#5f55af"}),React.createElement("g",null,React.createElement("path",{d:"m401 386v-260c0-8.284-6.716-15-15-15h-130v290h130c8.284 0 15-6.716 15-15z",fill:"#39326c"}))),React.createElement("g",null,React.createElement("path",{d:"m247.626 192.389c-.052-.138-.106-.274-.162-.411-2.744-6.671-9.175-10.978-16.387-10.978-.006 0-.012 0-.018 0-7.219.007-13.65 4.329-16.383 11.01-.046.113-.091.227-.134.341l-45.06 118.31c-2.949 7.742.937 16.408 8.679 19.356 7.742 2.95 16.408-.937 19.356-8.679l7.543-19.804h51.691l7.458 19.762c2.267 6.007 7.974 9.708 14.036 9.708 1.76 0 3.55-.312 5.294-.97 7.75-2.925 11.663-11.579 8.737-19.33zm-31.14 79.146 14.538-38.171 14.406 38.171z",fill:"#f9f9f9"}),React.createElement("g",{fill:"#e2dff4"},React.createElement("path",{d:"m264.209 321.296c2.267 6.007 7.974 9.708 14.036 9.708 1.76 0 3.55-.312 5.294-.97 7.75-2.925 11.663-11.579 8.737-19.33l-36.276-96.126v86.956h.751z"}),React.createElement("path",{d:"m328.5 181c-8.284 0-15 6.716-15 15v120c0 8.284 6.716 15 15 15s15-6.716 15-15v-120c0-8.284-6.716-15-15-15z"})))),aa=React.createElement("g",null,React.createElement("path",{d:"m213.46 341.461-139.26 156.08c-16.17 18.48-44.53 19.33-61.8 2.06-17.32-17.32-16.37-45.67 2.06-61.8l156.08-139.26s13.46-2.54 29.46 13.46 13.46 29.46 13.46 29.46z",fill:"#0052be"}),React.createElement("path",{d:"m213.46 341.461-139.26 156.08c-16.17 18.48-44.53 19.33-61.8 2.06l187.6-187.6c16 16 13.46 29.46 13.46 29.46z",fill:"#00429b"}),React.createElement("path",{d:"m304 240.001-90.54 101.46c-14.997-14.997-27.922-27.922-42.92-42.92l101.46-90.54z",fill:"#00429b"}),React.createElement("path",{d:"m304 240.001-90.54 101.46-21.46-21.46 96-96z",fill:"#00337a"}),React.createElement("path",{d:"m400 279.001h-64.4l-42.47 57.87c-7.88 10.735-24.824 6.606-26.91-6.52l-11.56-73.01-73.01-11.56c-13.139-2.087-17.244-19.042-6.52-26.91l57.87-42.47v-64.4c0-12.176 13.797-19.289 23.72-12.21l50.15 35.83 70.92-19.9c11.25-3.168 21.656 7.245 18.49 18.49l-19.9 70.92 35.83 50.15c7.071 9.913-.02 23.72-12.21 23.72z",fill:"#ffdd54"}),React.createElement("path",{d:"m412.21 255.281c7.071 9.913-.02 23.72-12.21 23.72h-64.4l-42.47 57.87c-7.875 10.728-24.823 6.616-26.91-6.52l-11.56-73.01 137.79-137.79c3.83 3.84 5.3 9.44 3.83 14.66l-19.9 70.92z",fill:"#ffb454"}),React.createElement("path",{d:"m512 39.001c0 8.28-6.72 15-15 15h-9v9c0 8.28-6.72 15-15 15s-15-6.72-15-15v-9h-9c-8.28 0-15-6.72-15-15s6.72-15 15-15h9v-9c0-8.28 6.72-15 15-15s15 6.72 15 15v9h9c8.28 0 15 6.719 15 15z",fill:"#bee75e"}),React.createElement("path",{d:"m512 39.001c0 8.28-6.72 15-15 15h-9v9c0 8.28-6.72 15-15 15s-15-6.72-15-15v-9l30-30h9c8.28 0 15 6.719 15 15z",fill:"#00cb75"}),React.createElement("path",{d:"m336 41.001h-9v-9c0-8.284-6.716-15-15-15s-15 6.716-15 15v9h-9c-8.284 0-15 6.716-15 15s6.716 15 15 15h9v9c0 8.284 6.716 15 15 15s15-6.716 15-15v-9h9c8.284 0 15-6.716 15-15s-6.716-15-15-15z",fill:"#f6f9f9"}),React.createElement("path",{d:"m441 224.001c0 8.284 6.716 15 15 15s15-6.716 15-15v-9h9c8.284 0 15-6.716 15-15s-6.716-15-15-15h-9v-9c0-8.284-6.716-15-15-15s-15 6.716-15 15v9h-9c-8.284 0-15 6.716-15 15s6.716 15 15 15h9z",fill:"#e2dff4"}),React.createElement("path",{d:"m497 329.001h-9v-9c0-8.284-6.716-15-15-15s-15 6.716-15 15v9h-9c-8.284 0-15 6.716-15 15s6.716 15 15 15h9v9c0 8.284 6.716 15 15 15s15-6.716 15-15v-9h9c8.284 0 15-6.716 15-15s-6.716-15-15-15z",fill:"#ff4a4a"}),React.createElement("path",{d:"m192 24.001h-9v-9c0-8.284-6.716-15-15-15s-15 6.716-15 15v9h-9c-8.284 0-15 6.716-15 15s6.716 15 15 15h9v9c0 8.284 6.716 15 15 15s15-6.716 15-15v-9h9c8.284 0 15-6.716 15-15s-6.716-15-15-15z",fill:"#ff8659"}),React.createElement("path",{d:"m159.442 122.977-56-32c-7.191-4.109-16.355-1.611-20.466 5.581-4.11 7.193-1.611 16.355 5.581 20.466l56 32c7.16 4.093 16.337 1.644 20.466-5.581 4.111-7.193 1.612-16.355-5.581-20.466z",fill:"#f6f9f9"}),React.createElement("path",{d:"m118.14 169.117-64 8c-8.221 1.027-14.052 8.524-13.023 16.744 1.027 8.218 8.523 14.054 16.744 13.023l64-8c8.221-1.027 14.052-8.524 13.023-16.744-1.028-8.22-8.527-14.062-16.744-13.023z",fill:"#acceff"}),React.createElement("path",{d:"m389.023 352.558c-4.111-7.193-13.274-9.693-20.466-5.581-7.192 4.11-9.691 13.272-5.581 20.466l32 56c2.769 4.845 7.83 7.561 13.037 7.561 11.319 0 18.784-12.341 13.01-22.445z",fill:"#e2dff4"}),React.createElement("path",{d:"m329.86 377.117c-8.222-1.031-15.717 4.804-16.744 13.023l-8 64c-1.117 8.925 5.834 16.862 14.902 16.862 7.455 0 13.917-5.553 14.865-13.142l8-64c1.029-8.219-4.802-15.716-13.023-16.743z",fill:"#6ba7ff"}));const oa=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.icon,n=void 0===t?"ai":t,r=e.style,a=void 0===r?{}:r,o=na((function(){switch(n){case"ai":default:return ra;case"wand":return aa}}),[n]);return React.createElement("svg",{style:Xr({width:20,height:20,marginRight:5},a),"enable-background":"new 0 0 512 512",height:"512",viewBox:"0 0 512 512",width:"512",xmlns:"http://www.w3.org/2000/svg"},o)};function ia(e){return ia="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},ia(e)}function ca(){ca=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,a){var o=t&&t.prototype instanceof m?t:m,i=Object.create(o.prototype),c=new _(a||[]);return r(i,"_invoke",{value:E(e,n,c)}),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function m(){}function h(){}function p(){}var d={};l(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(d=v);var g=p.prototype=m.prototype=Object.create(d);function b(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function a(r,o,i,c){var l=s(e[r],e,o);if("throw"!==l.type){var u=l.arg,f=u.value;return f&&"object"==ia(f)&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){a("next",e,i,c)}),(function(e){a("throw",e,i,c)})):t.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return a("throw",e,i,c)}))}c(l.arg)}var o;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){a(e,n,t,r)}))}return o=o?o.then(r,r):r()}})}function E(e,t,n){var r="suspendedStart";return function(a,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===a)throw o;return{value:void 0,done:!0}}for(n.method=a,n.arg=o;;){var i=n.delegate;if(i){var c=R(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var l=s(e,t,n);if("normal"===l.type){if(r=n.done?"completed":"suspendedYield",l.arg===f)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(r="completed",n.method="throw",n.arg=l.arg)}}}function R(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,R(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var a=s(r,e.iterator,t.arg);if("throw"===a.type)return t.method="throw",t.arg=a.arg,t.delegate=null,f;var o=a.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(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 k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function S(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:O}}function O(){return{value:void 0,done:!0}}return h.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:h,configurable:!0}),h.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,l(e,c,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},b(w.prototype),l(w.prototype,i,(function(){return this})),e.AsyncIterator=w,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new w(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},b(g),l(g,c,"Generator"),l(g,o,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=S,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return i.type="throw",i.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var c=n.call(o,"catchLoc"),l=n.call(o,"finallyLoc");if(c&&l){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var a=r.arg;k(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},e}function la(e,t,n,r,a,o,i){try{var c=e[o](i),l=c.value}catch(e){return void n(e)}c.done?t(l):Promise.resolve(l).then(r,a)}function ua(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){la(o,r,a,i,c,"next",e)}function c(e){la(o,r,a,i,c,"throw",e)}i(void 0)}))}}function sa(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,c=[],l=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(c.push(r.value),c.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(u)throw a}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return fa(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fa(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 fa(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ma=wp.element,ha=ma.useState,pa=(ma.useEffect,ma.useMemo,wp.i18n.__),da=wp.plugins.registerPlugin,ya=wp.components.Button,va=wp.editPost,ga=va.PluginDocumentSettingPanel,ba=va.PluginBlockSettingsMenuItem,wa=function(){alert("Coming soon! Let me know your feedback and ideas, I will make this awesome for you.")};da("ai-engine-menu-paragraph-generate",{render:function(){return React.createElement(React.Fragment,null,React.createElement(ba,{allowedBlocks:["core/paragraph"],icon:React.createElement(oa,{icon:"wand",style:{marginRight:0}}),label:React.createElement(React.Fragment,null," ",pa("Enhance text")),onClick:wa}),React.createElement(ba,{allowedBlocks:["core/paragraph"],icon:React.createElement(oa,{icon:"wand",style:{marginRight:0}}),label:React.createElement(React.Fragment,null," ",pa("Translate text")),onClick:wa}))}});var Ea=function(){var e=sa(ha(),2),t=e[0],n=e[1],r=sa(ha(),2),a=r[0],o=r[1],i=function(){var e=ua(ca().mark((function e(t){return ca().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:wp.data.dispatch("core/editor").editPost({title:t});case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),c=function(){var e=ua(ca().mark((function e(t){return ca().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:wp.data.dispatch("core/editor").editPost({excerpt:t});case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return React.createElement(ga,{name:"mwai-document-settings",title:React.createElement(React.Fragment,null,React.createElement(oa,null)," AI Engine"),className:"mwai-document-settings"},React.createElement("p",null,"Generate:"),React.createElement("div",{style:{display:"flex"}},React.createElement(ya,{variant:"primary",onClick:function(){var e=(0,wp.data.select("core/editor").getCurrentPost)(),t=e.id,r=e.title;e.excerpt,n({postId:t,postTitle:r})},style:{flex:1,marginRight:10}},React.createElement(oa,{icon:"wand",style:{marginRight:8}})," Titles"),React.createElement(ya,{variant:"primary",onClick:function(){var e=(0,wp.data.select("core/editor").getCurrentPost)(),t=e.id,n=e.title;e.excerpt,o({postId:t,postTitle:n})},style:{flex:1}},React.createElement(oa,{icon:"wand",style:{marginRight:8}})," Excerpts")),React.createElement(v.o,null,React.createElement(er,{post:t,onTitleClick:i,onClose:n}),React.createElement($r,{post:a,onExcerptClick:c,onClose:o})))};var Ra=React.createElement("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},React.createElement("rect",{width:"20",height:"20",fill:"white"}),React.createElement("path",{d:"M16.6667 3.33334V13.3333H6.66667V3.33334H16.6667ZM16.6667 1.66667H6.66667L5 3.33334V13.3333L6.66667 15H16.6667L18.3333 13.3333V3.33334L16.6667 1.66667Z",fill:"#2D4B6D"}),React.createElement("path",{d:"M10 10L10.8333 11.6667L13.3333 9.16667L15.8333 12.5H7.5L10 10Z",fill:"#1ABC9C"}),React.createElement("path",{d:"M1.66667 5V16.6667L3.33333 18.3333H15V16.6667H3.33333V5H1.66667Z",fill:"#2D4B6D"})),xa=wp.i18n.__,ka=wp.blocks,_a=ka.registerBlockType,Sa=(ka.createBlock,wp.element),Oa=Sa.useMemo,La=(Sa.useEffect,Sa.useState,wp.components),Pa=(La.Button,La.DropZone,La.PanelBody),ja=(La.RangeControl,La.CheckboxControl,La.TextControl,La.SelectControl,La.Toolbar,La.withNotices,wp.blockEditor),Ta=(ja.BlockControls,ja.InspectorControls),Ca=function(e){var t=e.attributes;return t.id,t.fieldName,t.labelText,console.log(e),React.createElement(React.Fragment,null,"[mwai_chatbot]")},Na=function(e){var t=e.attributes,n=(t.id,t.fieldName,t.labelText,e.setAttributes,Oa((function(){return Ca(e)}),[e]));return React.createElement(React.Fragment,null,n,React.createElement(Ta,null,React.createElement(Pa,{title:xa("Chatbot")}),React.createElement(Pa,{title:xa("Settings")})))};var Aa=wp.i18n.__,Ia=wp.blocks,Fa=Ia.registerBlockType,Ga=(Ia.createBlock,wp.element),za=Ga.useMemo,Ma=(Ga.useEffect,Ga.useState,wp.components),Ba=(Ma.Button,Ma.DropZone,Ma.PanelBody),Da=(Ma.RangeControl,Ma.CheckboxControl,Ma.TextControl),qa=Ma.SelectControl,Ya=(Ma.Toolbar,Ma.withNotices,wp.blockEditor),Wa=(Ya.BlockControls,Ya.InspectorControls),Za=function(e){var t=e.attributes,n=t.id,r=t.fieldName,a=t.labelText;return console.log(e),React.createElement("div",{className:"mwai-field-container"},React.createElement("label",{className:"mwai-label",htmlFor:n},a),React.createElement("input",{className:"mwai-field mwai-input",type:"text",id:n,name:r}))},Ha=function(e){var t=e.attributes,n=t.id,r=t.fieldName,a=t.labelText,o=e.setAttributes,i=za((function(){return Za(e)}),[e]);return React.createElement(React.Fragment,null,i,React.createElement(Wa,null,React.createElement(Ba,{title:Aa("Field")},React.createElement(Da,{label:"Label Text",value:a,onChange:function(e){return o({labelText:e})}}),React.createElement(Da,{label:"Field Name",value:r,onChange:function(e){return o({fieldName:e})}}),React.createElement(qa,{label:"Field Type",value:"text",options:[{label:"TextField",value:"text"},{label:"Select",value:"select"},{label:"Checkbox",value:"checkbox"},{label:"Radio",value:"radio"},{label:"TextArea",value:"textarea"}]})),React.createElement(Ba,{title:Aa("Settings")},React.createElement(Da,{label:"ID",value:n,onChange:function(e){return o({id:e})}}))))};var Ua=wp.element.render,Va=new l.S({defaultOptions:{queries:{refetchOnWindowFocus:!1}}});Fa("ai-engine/form-field",{title:"AI Form Field",description:React.createElement(React.Fragment,null,"This feature is ",React.createElement("b",null,"being built"),". I will allow to create AI forms. Coming soon!"),icon:Ra,category:"layout",keywords:[Aa("ai"),Aa("openai"),Aa("form")],attributes:{id:{type:"string",default:""},fieldName:{type:"string",default:""},labelText:{type:"string",default:"Label: "}},edit:Ha,save:Za}),_a("ai-engine/chatbot",{title:"AI Chatbot",description:React.createElement(React.Fragment,null,"This feature is ",React.createElement("b",null,"being built"),". I will allow to create a chatbot. Coming soon!"),icon:Ra,category:"layout",keywords:[xa("ai"),xa("openai"),xa("chatbot")],attributes:{id:{type:"string",default:""}},edit:Na,save:Ca}),document.addEventListener("DOMContentLoaded",(function(){da("ai-engine-document-settings",{render:Ea});var e=document.getElementById("mwai-admin-settings");e&&Ua(React.createElement(u.aH,{client:Va},React.createElement(kn,null)),e);var t=document.getElementById("mwai-content-generator");t&&Ua(React.createElement(Rr,null),t);var n=document.getElementById("mwai-image-generator");n&&Ua(React.createElement(Mr,null),n);var r=document.getElementById("mwai-playground");r&&Ua(React.createElement(Gn,null),r);var a=document.getElementById("mwai-admin-postsList");a&&Ua(React.createElement(lr,null),a);var o=document.getElementById("meow-common-dashboard");o&&Ua(React.createElement(ye,null),o)}))},7363:e=>{e.exports=React},1533:e=>{e.exports=ReactDOM}},n={};function r(e){var a=n[e];if(void 0!==a)return a.exports;var o=n[e]={exports:{}};return t[e].call(o.exports,o,o.exports,r),o.exports}r.m=t,r.amdO={},e=[],r.O=(t,n,a,o)=>{if(!n){var i=1/0;for(s=0;s<e.length;s++){n=e[s][0],a=e[s][1],o=e[s][2];for(var c=!0,l=0;l<n.length;l++)(!1&o||i>=o)&&Object.keys(r.O).every((e=>r.O[e](n[l])))?n.splice(l--,1):(c=!1,o<i&&(i=o));if(c){e.splice(s--,1);var u=a();void 0!==u&&(t=u)}}return t}o=o||0;for(var s=e.length;s>0&&e[s-1][2]>o;s--)e[s]=e[s-1];e[s]=[n,a,o]},r.n=e=>{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.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})},(()=>{var e={826:0};r.O.j=t=>0===e[t];var t=(t,n)=>{var a,o,i=n[0],c=n[1],l=n[2],u=0;if(i.some((t=>0!==e[t]))){for(a in c)r.o(c,a)&&(r.m[a]=c[a]);if(l)var s=l(r)}for(t&&t(n);u<i.length;u++)o=i[u],r.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return r.O(s)},n=self.wpJsonMwai=self.wpJsonMwai||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})(),r.nc=void 0;var a=r.O(void 0,[736],(()=>r(1058)));a=r.O(a)})();
8 //# sourceMappingURL=index.js.map